1 #ifndef DALI_INTERNAL_WINDOW_SYSTEM_X11_WINDOW_SYSTEM_H
2 #define DALI_INTERNAL_WINDOW_SYSTEM_X11_WINDOW_SYSTEM_H
5 * COPYRIGHT (c) 2023 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 #include <dali/internal/window-system/common/window-system.h>
27 namespace Dali::Internal::Adaptor::WindowSystem
30 * Class to encapsulate the actual window system calls to X11
32 class WindowSystemX : public WindowSystemBase
35 static Atom ATOM_WM_PROTOCOLS;
36 static Atom ATOM_WM_DELETE_WINDOW;
37 static Atom ATOM_WM_STATE;
38 static Atom ATOM_WM_TRANSIENT_FOR;
39 static Atom ATOM_NET_ACTIVE_WINDOW;
40 static Atom ATOM_NET_STARTUP_ID;
41 static Atom ATOM_NET_WM_PID;
42 static Atom ATOM_NET_WM_WINDOW_TYPE;
43 static Atom ATOM_NET_WM_WINDOW_TYPE_NORMAL;
44 static Atom ATOM_NET_WM_NAME;
45 static Atom ATOM_UTF8_STRING;
47 enum class WindowState
63 virtual ~WindowSystemX();
68 void GetScreenSize(int& width, int& height) override;
71 * Get the connected display
73 Dali::Any GetDisplay() override;
76 * Get the display for this specific implementation
78 ::Display* GetXDisplay();
81 * Synchronize with the display server if needed
86 * Struct that describes a generic X11 event
88 struct X11Event : public EventBase
95 * Event struct that is sent when a window is moved/resized/lowered/raised
97 struct X11ConfigureNotifyEvent : public X11Event
99 int x; // Relative to parent window's origin.
103 ::Window above; // The window that this is now above.
107 * Event struct that is sent when a window property is changed.
109 struct X11PropertyNotifyEvent : public X11Event
111 unsigned long timestamp;
117 * Event struct that is sent when the window needs to be redrawn
119 struct X11ExposeEvent : public X11Event
128 * Event struct that is sent when mouse movement/button press occurs
130 struct X11MouseEvent : public X11Event
132 unsigned long timestamp; ///< time in milliseconds
149 * Event struct that is sent when the mouse wheel is scrolled or pressed
151 struct X11MouseWheelEvent : public X11Event
153 unsigned long timestamp; ///< time in milliseconds
158 unsigned int modifiers;
162 * Event struct that is sent when a keypress or keyrelease occurs
164 struct X11KeyEvent : public X11Event
166 unsigned long timestamp; ///< time in milliseconds
171 unsigned int modifiers;
175 * Event struct that is sent when a selection is cleared
177 struct X11SelectionClearEvent : public X11Event
179 enum class SelectionType
190 * @copydoc WindowSystemBase::AddEventHandler()
192 EventHandler* AddEventHandler(WindowSystemBase::Event event,
193 WindowSystemBase::EventHandlerCallback callback,
194 void* data) override;
196 * @copydoc WindowSystemBase::DeleteEventHandler()
198 void DeleteEventHandler(EventHandler* eventHandler) override;
202 * @param depth The color depth (24/32)
203 * @param x Horizontal position of the window
204 * @param y Vertical position of the window
205 * @param width Width of the new window
206 * @param height Height of the new window
207 * @return An X11 handle to the new window
209 ::Window CreateWindow(int depth, int x, int y, int width, int height);
212 * Set window default parameters (client machine name, PID and window type)
213 * @param window The window to set the default parameters for
215 void SetWindowDefaults(::Window window);
218 * Tells the window manager if the window is transient (e.g. a dialog) for another window
219 * @param window The window to set the hints on
220 * @param forWindow The window that this is transient for
222 void SetTransientForHint(::Window window, ::Window forWindow);
225 * Removes the WM hint that the window is transient for another
226 * @param window The window to remove the hints on
228 void UnsetTransientFor(::Window window);
231 * Set/clear the given Window manager protocol on the given window
232 * @param window The window to modify
233 * @param protocol The protocol to add/modify/remove
234 * @param value True if the protocol should be added, false if it should be removed
236 void SetProtocol(::Window window, Atom protocol, bool value);
239 * Add a hint to the window that it accepts focus
240 * @param window The window to modify
241 * @param acceptsFocus True if the window should accept focus, or false if not
243 void SetWindowHints(::Window window, bool acceptsFocus);
246 * Get the window's current state
247 * @param window The window to check
248 * @return The window state (withdrawn, normal or iconic)
250 WindowState GetWindowState(::Window window);
254 * @param window The window to show
256 void Show(::Window window);
260 * @param window The window to hide
262 void Hide(::Window window);
265 * Activate the window
266 * @param window The window to activate
268 void Activate(::Window window);
271 * Raise the window to the top
272 * @param window The window to raise
274 void Raise(::Window window);
277 * Lower the window to the bottom
278 * @param window The window to lower
280 void Lower(::Window window);
283 * Enables the X window event handlers to trigger listeners
284 * @param eventType The window event type
285 * @param event The window event
287 void TriggerEventHandler(WindowSystemBase::Event eventType, X11Event& event);
290 * Get the DPI of the screen
291 * @param dpiHorizontal
294 void GetDPI(unsigned int& dpiHorizontal, unsigned int& dpiVertical);
297 * Move the window to the new screen coordinates
298 * @param window The window to move
299 * @param x The horizontal position
300 * @param y The vertical position
302 void Move(::Window window, int x, int y);
305 * Resize the window to the given width and height
306 * @param window The window to resize
307 * @param width The new window width
308 * @param height The new window height
310 void Resize(::Window window, int width, int height);
313 * Move and resize the window in one operation
314 * @param window The window to resize and move
315 * @param x The horizontal position
316 * @param y The vertical position
317 * @param width The new window width
318 * @param height The new window height
320 void MoveResize(::Window window, int x, int y, int width, int height);
323 * Set the value of a string property
324 * @param window The window to set the property on
325 * @param atom The property to modify
326 * @param string The new string to set on the property
328 void SetStringProperty(::Window window, Atom atom, const std::string& string);
331 * Set the class of the window
332 * @param window The window to modify
333 * @param name The name (title) of the window
334 * @param className The class of the window
336 void SetClass(::Window window, const std::string& name, const std::string& className);
339 * Initialize multiselection input on the window
340 * @Note NOT IMPLEMENTED
341 * @param window The window to initialize
343 void InputMultiSelect(::Window window);
346 * Initialize drag and drop on the window
347 * @Note NOT IMPLEMENTED
348 * @param window The window to initialize
349 * @param enable True if drag and drop should be enabled, false otherwise
351 void EnableDragAndDrop(::Window window, bool enable);
359 * Get the platform implementation of the window system
360 * @return the platform implementation of the window system
362 WindowSystemX& GetImplementation();
364 } // namespace Dali::Internal::Adaptor::WindowSystem
366 #endif // DALI_INTERNAL_WINDOW_SYSTEM_X11_WINDOW_SYSTEM_H