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_x11window_h_ |
24 | #define SDL_x11window_h_ |
25 | |
26 | /* We need to queue the focus in/out changes because they may occur during |
27 | video mode changes and we can respond to them by triggering more mode |
28 | changes. |
29 | */ |
30 | #define PENDING_FOCUS_TIME 200 |
31 | |
32 | #ifdef SDL_VIDEO_OPENGL_EGL |
33 | #include <EGL/egl.h> |
34 | #endif |
35 | |
36 | typedef enum |
37 | { |
38 | PENDING_FOCUS_NONE, |
39 | PENDING_FOCUS_IN, |
40 | PENDING_FOCUS_OUT |
41 | } PendingFocusEnum; |
42 | |
43 | struct SDL_WindowData |
44 | { |
45 | SDL_Window *window; |
46 | Window xwindow; |
47 | Visual *visual; |
48 | Colormap colormap; |
49 | #ifndef NO_SHARED_MEMORY |
50 | // MIT shared memory extension information |
51 | bool use_mitshm; |
52 | XShmSegmentInfo shminfo; |
53 | #endif |
54 | XImage *ximage; |
55 | GC gc; |
56 | XIC ic; |
57 | bool created; |
58 | int border_left; |
59 | int border_right; |
60 | int border_top; |
61 | int border_bottom; |
62 | bool xinput2_mouse_enabled; |
63 | bool xinput2_keyboard_enabled; |
64 | bool mouse_grabbed; |
65 | Uint64 last_focus_event_time; |
66 | PendingFocusEnum pending_focus; |
67 | Uint64 pending_focus_time; |
68 | bool pending_move; |
69 | SDL_Point pending_move_point; |
70 | XConfigureEvent last_xconfigure; |
71 | struct SDL_VideoData *videodata; |
72 | unsigned long user_time; |
73 | Atom xdnd_req; |
74 | Window xdnd_source; |
75 | bool flashing_window; |
76 | Uint64 flash_cancel_time; |
77 | SDL_Window *keyboard_focus; |
78 | #ifdef SDL_VIDEO_OPENGL_EGL |
79 | EGLSurface egl_surface; |
80 | #endif |
81 | #ifdef SDL_VIDEO_DRIVER_X11_XFIXES |
82 | bool pointer_barrier_active; |
83 | PointerBarrier barrier[4]; |
84 | SDL_Rect barrier_rect; |
85 | #endif // SDL_VIDEO_DRIVER_X11_XFIXES |
86 | #ifdef SDL_VIDEO_DRIVER_X11_XSYNC |
87 | XSyncCounter resize_counter; |
88 | XSyncValue resize_id; |
89 | bool resize_in_progress; |
90 | #endif /* SDL_VIDEO_DRIVER_X11_XSYNC */ |
91 | |
92 | SDL_Rect expected; |
93 | SDL_DisplayMode requested_fullscreen_mode; |
94 | |
95 | enum |
96 | { |
97 | X11_PENDING_OP_NONE = 0x00, |
98 | X11_PENDING_OP_RESTORE = 0x01, |
99 | X11_PENDING_OP_MINIMIZE = 0x02, |
100 | X11_PENDING_OP_MAXIMIZE = 0x04, |
101 | X11_PENDING_OP_FULLSCREEN = 0x08, |
102 | X11_PENDING_OP_MOVE = 0x10, |
103 | X11_PENDING_OP_RESIZE = 0x20 |
104 | } pending_operation; |
105 | |
106 | enum |
107 | { |
108 | X11_SIZE_MOVE_EVENTS_DISABLE = 0x01, // Events are completely disabled. |
109 | X11_SIZE_MOVE_EVENTS_WAIT_FOR_BORDERS = 0x02, // Events are disabled until a _NET_FRAME_EXTENTS event arrives. |
110 | } size_move_event_flags; |
111 | |
112 | bool pending_size; |
113 | bool pending_position; |
114 | bool window_was_maximized; |
115 | bool previous_borders_nonzero; |
116 | bool toggle_borders; |
117 | bool fullscreen_borders_forced_on; |
118 | SDL_HitTestResult hit_test_result; |
119 | |
120 | XPoint xim_spot; |
121 | char *preedit_text; |
122 | XIMFeedback *preedit_feedback; |
123 | int preedit_length; |
124 | int preedit_cursor; |
125 | bool ime_needs_clear_composition; |
126 | }; |
127 | |
128 | extern void X11_SetNetWMState(SDL_VideoDevice *_this, Window xwindow, SDL_WindowFlags flags); |
129 | extern Uint32 X11_GetNetWMState(SDL_VideoDevice *_this, SDL_Window *window, Window xwindow); |
130 | |
131 | extern bool X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); |
132 | extern char *X11_GetWindowTitle(SDL_VideoDevice *_this, Window xwindow); |
133 | extern void X11_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window); |
134 | extern bool X11_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *icon); |
135 | extern bool X11_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window); |
136 | extern void X11_SetWindowMinimumSize(SDL_VideoDevice *_this, SDL_Window *window); |
137 | extern void X11_SetWindowMaximumSize(SDL_VideoDevice *_this, SDL_Window *window); |
138 | extern void X11_SetWindowAspectRatio(SDL_VideoDevice *_this, SDL_Window *window); |
139 | extern bool (SDL_VideoDevice *_this, SDL_Window *window, int *top, int *left, int *bottom, int *right); |
140 | extern bool X11_SetWindowOpacity(SDL_VideoDevice *_this, SDL_Window *window, float opacity); |
141 | extern bool X11_SetWindowParent(SDL_VideoDevice *_this, SDL_Window *window, SDL_Window *parent); |
142 | extern bool X11_SetWindowModal(SDL_VideoDevice *_this, SDL_Window *window, bool modal); |
143 | extern void X11_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window); |
144 | extern void X11_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window); |
145 | extern void X11_HideWindow(SDL_VideoDevice *_this, SDL_Window *window); |
146 | extern void X11_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window); |
147 | extern void X11_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window); |
148 | extern void X11_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); |
149 | extern void X11_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window); |
150 | extern void X11_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered); |
151 | extern void X11_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable); |
152 | extern void X11_SetWindowAlwaysOnTop(SDL_VideoDevice *_this, SDL_Window *window, bool on_top); |
153 | extern SDL_FullscreenResult X11_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen); |
154 | extern void *X11_GetWindowICCProfile(SDL_VideoDevice *_this, SDL_Window *window, size_t *size); |
155 | extern bool X11_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); |
156 | extern bool X11_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); |
157 | extern void X11_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); |
158 | extern bool X11_SetWindowHitTest(SDL_Window *window, bool enabled); |
159 | extern void X11_AcceptDragAndDrop(SDL_Window *window, bool accept); |
160 | extern bool X11_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation); |
161 | extern void (SDL_Window *window, int x, int y); |
162 | extern bool X11_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window); |
163 | extern bool X11_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, bool focusable); |
164 | |
165 | extern bool SDL_X11_SetWindowTitle(Display *display, Window xwindow, char *title); |
166 | extern void X11_UpdateWindowPosition(SDL_Window *window, bool use_current_position); |
167 | extern void X11_SetWindowMinMax(SDL_Window *window, bool use_current); |
168 | |
169 | #endif // SDL_x11window_h_ |
170 | |