1 | /* |
2 | Simple DirectMedia Layer |
3 | Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> |
4 | |
5 | This software is provided 'as-is', without any express or implied |
6 | warranty. In no event will the authors be held liable for any damages |
7 | arising from the use of this software. |
8 | |
9 | Permission is granted to anyone to use this software for any purpose, |
10 | including commercial applications, and to alter it and redistribute it |
11 | freely, subject to the following restrictions: |
12 | |
13 | 1. The origin of this software must not be misrepresented; you must not |
14 | claim that you wrote the original software. If you use this software |
15 | in a product, an acknowledgment in the product documentation would be |
16 | appreciated but is not required. |
17 | 2. Altered source versions must be plainly marked as such, and must not be |
18 | misrepresented as being the original software. |
19 | 3. This notice may not be removed or altered from any source distribution. |
20 | */ |
21 | #include "SDL_internal.h" |
22 | |
23 | #ifndef SDL_x11video_h_ |
24 | #define SDL_x11video_h_ |
25 | |
26 | #include "../SDL_sysvideo.h" |
27 | |
28 | #include "../../core/linux/SDL_dbus.h" |
29 | #include "../../core/linux/SDL_ime.h" |
30 | |
31 | #include "SDL_x11dyn.h" |
32 | |
33 | #include "SDL_x11clipboard.h" |
34 | #include "SDL_x11events.h" |
35 | #include "SDL_x11keyboard.h" |
36 | #include "SDL_x11modes.h" |
37 | #include "SDL_x11mouse.h" |
38 | #include "SDL_x11opengl.h" |
39 | #include "SDL_x11settings.h" |
40 | #include "SDL_x11window.h" |
41 | #include "SDL_x11vulkan.h" |
42 | |
43 | // Private display data |
44 | |
45 | struct SDL_VideoData |
46 | { |
47 | Display *display; |
48 | Display *request_display; |
49 | pid_t pid; |
50 | XIM im; |
51 | Uint64 screensaver_activity; |
52 | int numwindows; |
53 | SDL_WindowData **windowlist; |
54 | int windowlistlength; |
55 | XID window_group; |
56 | Window clipboard_window; |
57 | SDLX11_ClipboardData clipboard; |
58 | SDLX11_ClipboardData primary_selection; |
59 | #ifdef SDL_VIDEO_DRIVER_X11_XFIXES |
60 | SDL_Window *active_cursor_confined_window; |
61 | #endif // SDL_VIDEO_DRIVER_X11_XFIXES |
62 | Window xsettings_window; |
63 | SDLX11_SettingsData xsettings_data; |
64 | |
65 | // This is true for ICCCM2.0-compliant window managers |
66 | bool net_wm; |
67 | |
68 | // Useful atoms |
69 | struct { |
70 | Atom WM_PROTOCOLS; |
71 | Atom WM_DELETE_WINDOW; |
72 | Atom WM_TAKE_FOCUS; |
73 | Atom WM_NAME; |
74 | Atom WM_TRANSIENT_FOR; |
75 | Atom _NET_WM_STATE; |
76 | Atom _NET_WM_STATE_HIDDEN; |
77 | Atom _NET_WM_STATE_FOCUSED; |
78 | Atom _NET_WM_STATE_MAXIMIZED_VERT; |
79 | Atom _NET_WM_STATE_MAXIMIZED_HORZ; |
80 | Atom _NET_WM_STATE_FULLSCREEN; |
81 | Atom _NET_WM_STATE_ABOVE; |
82 | Atom _NET_WM_STATE_SKIP_TASKBAR; |
83 | Atom ; |
84 | Atom _NET_WM_STATE_MODAL; |
85 | Atom _NET_WM_MOVERESIZE; |
86 | Atom _NET_WM_ALLOWED_ACTIONS; |
87 | Atom _NET_WM_ACTION_FULLSCREEN; |
88 | Atom _NET_WM_NAME; |
89 | Atom _NET_WM_ICON_NAME; |
90 | Atom _NET_WM_ICON; |
91 | Atom _NET_WM_PING; |
92 | Atom _NET_WM_SYNC_REQUEST; |
93 | Atom _NET_WM_SYNC_REQUEST_COUNTER; |
94 | Atom _NET_WM_WINDOW_OPACITY; |
95 | Atom _NET_WM_USER_TIME; |
96 | Atom _NET_ACTIVE_WINDOW; |
97 | Atom _NET_FRAME_EXTENTS; |
98 | Atom _SDL_WAKEUP; |
99 | Atom UTF8_STRING; |
100 | Atom PRIMARY; |
101 | Atom CLIPBOARD; |
102 | Atom INCR; |
103 | Atom SDL_SELECTION; |
104 | Atom TARGETS; |
105 | Atom SDL_FORMATS; |
106 | Atom XdndAware; |
107 | Atom XdndEnter; |
108 | Atom XdndLeave; |
109 | Atom XdndPosition; |
110 | Atom XdndStatus; |
111 | Atom XdndTypeList; |
112 | Atom XdndActionCopy; |
113 | Atom XdndDrop; |
114 | Atom XdndFinished; |
115 | Atom XdndSelection; |
116 | Atom XKLAVIER_STATE; |
117 | |
118 | // Pen atoms (these have names that don't map well to C symbols) |
119 | Atom pen_atom_device_product_id; |
120 | Atom pen_atom_abs_pressure; |
121 | Atom pen_atom_abs_tilt_x; |
122 | Atom pen_atom_abs_tilt_y; |
123 | Atom pen_atom_wacom_serial_ids; |
124 | Atom pen_atom_wacom_tool_type; |
125 | } atoms; |
126 | |
127 | SDL_Scancode key_layout[256]; |
128 | bool selection_waiting; |
129 | bool selection_incr_waiting; |
130 | |
131 | bool broken_pointer_grab; // true if XGrabPointer seems unreliable. |
132 | |
133 | Uint64 last_mode_change_deadline; |
134 | |
135 | bool global_mouse_changed; |
136 | SDL_Point global_mouse_position; |
137 | Uint32 global_mouse_buttons; |
138 | |
139 | SDL_XInput2DeviceInfo *mouse_device_info; |
140 | int xinput_master_pointer_device; |
141 | bool xinput_hierarchy_changed; |
142 | |
143 | int xrandr_event_base; |
144 | struct |
145 | { |
146 | #ifdef SDL_VIDEO_DRIVER_X11_HAS_XKBLOOKUPKEYSYM |
147 | XkbDescPtr desc_ptr; |
148 | #endif |
149 | int event; |
150 | unsigned int current_group; |
151 | unsigned int xkb_modifiers; |
152 | |
153 | SDL_Keymod sdl_modifiers; |
154 | |
155 | Uint32 numlock_mask; |
156 | Uint32 scrolllock_mask; |
157 | } xkb; |
158 | |
159 | KeyCode filter_code; |
160 | Time filter_time; |
161 | |
162 | #ifdef SDL_VIDEO_VULKAN |
163 | // Vulkan variables only valid if _this->vulkan_config.loader_handle is not NULL |
164 | SDL_SharedObject *vulkan_xlib_xcb_library; |
165 | PFN_XGetXCBConnection vulkan_XGetXCBConnection; |
166 | #endif |
167 | |
168 | // Used to interact with the on-screen keyboard |
169 | bool is_steam_deck; |
170 | bool steam_keyboard_open; |
171 | |
172 | bool is_xwayland; |
173 | }; |
174 | |
175 | extern bool X11_UseDirectColorVisuals(void); |
176 | |
177 | #endif // SDL_x11video_h_ |
178 | |