21 #include "../../SDL_internal.h"
23 #if SDL_VIDEO_DRIVER_X11
31 #include "../SDL_sysvideo.h"
32 #include "../SDL_pixels_c.h"
40 #if SDL_VIDEO_OPENGL_EGL
47 static int X11_VideoInit(
_THIS);
48 static void X11_VideoQuit(
_THIS);
55 #if defined(__LINUX__) || defined(__FREEBSD__)
68 #if defined(__LINUX__) || defined(__FREEBSD__)
69 #if defined(__LINUX__)
71 #elif defined(__FREEBSD__)
75 #error Where can we find the executable name?
77 linksize = readlink(procfile, linkfile,
sizeof(linkfile) - 1);
79 linkfile[linksize] =
'\0';
95 static int (*orig_x11_errhandler) (Display *, XErrorEvent *) =
NULL;
101 if (
device->vulkan_config.loader_handle) {
105 X11_XSetErrorHandler(orig_x11_errhandler);
106 X11_XCloseDisplay(
data->display);
118 X11_SafetyNetErrHandler(Display *
d, XErrorEvent *
e)
122 if (!safety_net_triggered) {
127 for (
i = 0;
i <
device->num_displays;
i++) {
137 if (orig_x11_errhandler !=
NULL) {
138 return orig_x11_errhandler(
d,
e);
145 X11_CreateDevice(
int devindex)
149 const char *display =
NULL;
150 Display *x11_display =
NULL;
161 x11_display = X11_XOpenDisplay(display);
184 data->display = x11_display;
186 X11_XSynchronize(
data->display, True);
191 orig_x11_errhandler = X11_XSetErrorHandler(X11_SafetyNetErrHandler);
194 device->VideoInit = X11_VideoInit;
195 device->VideoQuit = X11_VideoQuit;
240 #if SDL_VIDEO_OPENGL_GLX
241 device->GL_LoadLibrary = X11_GL_LoadLibrary;
242 device->GL_GetProcAddress = X11_GL_GetProcAddress;
243 device->GL_UnloadLibrary = X11_GL_UnloadLibrary;
244 device->GL_CreateContext = X11_GL_CreateContext;
245 device->GL_MakeCurrent = X11_GL_MakeCurrent;
246 device->GL_SetSwapInterval = X11_GL_SetSwapInterval;
247 device->GL_GetSwapInterval = X11_GL_GetSwapInterval;
248 device->GL_SwapWindow = X11_GL_SwapWindow;
249 device->GL_DeleteContext = X11_GL_DeleteContext;
251 #if SDL_VIDEO_OPENGL_EGL
252 #if SDL_VIDEO_OPENGL_GLX
255 device->GL_LoadLibrary = X11_GLES_LoadLibrary;
256 device->GL_GetProcAddress = X11_GLES_GetProcAddress;
257 device->GL_UnloadLibrary = X11_GLES_UnloadLibrary;
258 device->GL_CreateContext = X11_GLES_CreateContext;
259 device->GL_MakeCurrent = X11_GLES_MakeCurrent;
260 device->GL_SetSwapInterval = X11_GLES_SetSwapInterval;
261 device->GL_GetSwapInterval = X11_GLES_GetSwapInterval;
262 device->GL_SwapWindow = X11_GLES_SwapWindow;
263 device->GL_DeleteContext = X11_GLES_DeleteContext;
264 #if SDL_VIDEO_OPENGL_GLX
276 device->free = X11_DeleteDevice;
279 device->Vulkan_LoadLibrary = X11_Vulkan_LoadLibrary;
280 device->Vulkan_UnloadLibrary = X11_Vulkan_UnloadLibrary;
281 device->Vulkan_GetInstanceExtensions = X11_Vulkan_GetInstanceExtensions;
282 device->Vulkan_CreateSurface = X11_Vulkan_CreateSurface;
289 "x11",
"SDL X11 video driver",
293 static int (*handler) (Display *, XErrorEvent *) =
NULL;
295 X11_CheckWindowManagerErrorHandler(Display *
d, XErrorEvent *
e)
297 if (
e->error_code == BadWindow) {
300 return (handler(
d,
e));
305 X11_CheckWindowManager(
_THIS)
309 Atom _NET_SUPPORTING_WM_CHECK;
310 int status, real_format;
312 unsigned long items_read = 0, items_left = 0;
313 unsigned char *propdata =
NULL;
314 Window wm_window = 0;
315 #ifdef DEBUG_WINDOW_MANAGER
321 handler = X11_XSetErrorHandler(X11_CheckWindowManagerErrorHandler);
323 _NET_SUPPORTING_WM_CHECK = X11_XInternAtom(
display,
"_NET_SUPPORTING_WM_CHECK", False);
324 status = X11_XGetWindowProperty(
display, DefaultRootWindow(
display), _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
325 if (status == Success) {
327 wm_window = ((Window*)propdata)[0];
336 status = X11_XGetWindowProperty(
display, wm_window, _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
337 if (status != Success || !items_read || wm_window != ((Window*)propdata)[0]) {
340 if (status == Success && propdata) {
348 X11_XSetErrorHandler(handler);
351 #ifdef DEBUG_WINDOW_MANAGER
352 printf(
"Couldn't get _NET_SUPPORTING_WM_CHECK property\n");
358 #ifdef DEBUG_WINDOW_MANAGER
360 printf(
"Window manager: %s\n", wm_name);
372 data->classname = get_classname();
375 data->pid = getpid();
381 #define GET_ATOM(X) data->X = X11_XInternAtom(data->display, #X, False)
417 X11_CheckWindowManager(
_this);
444 if (
data->clipboard_window) {
445 X11_XDestroyWindow(
data->display,
data->clipboard_window);
449 #ifdef X_HAVE_UTF8_STRING
451 X11_XCloseIM(
data->im);
#define SDL_GetHintBoolean
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 * e
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
#define SDL_OutOfMemory()
#define SDL_HINT_VIDEO_X11_FORCE_EGL
A variable controlling whether X11 should use GLX or EGL by default.
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
#define SDL_arraysize(array)
SDL_VideoDevice * SDL_GetVideoDevice(void)
VideoBootStrap X11_bootstrap
static SDL_VideoDevice * _this
SDL_bool X11_HasClipboardText(_THIS)
char * X11_GetClipboardText(_THIS)
int X11_SetClipboardText(_THIS, const char *text)
void SDL_X11_UnloadSymbols(void)
int SDL_X11_LoadSymbols(void)
void X11_SuspendScreenSaver(_THIS)
void X11_PumpEvents(_THIS)
void X11_DestroyWindowFramebuffer(_THIS, SDL_Window *window)
int X11_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
int X11_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
void X11_QuitKeyboard(_THIS)
int X11_InitKeyboard(_THIS)
void X11_SetTextInputRect(_THIS, SDL_Rect *rect)
void X11_StopTextInput(_THIS)
void X11_StartTextInput(_THIS)
int X11_GetDisplayBounds(_THIS, SDL_VideoDisplay *sdl_display, SDL_Rect *rect)
void X11_QuitModes(_THIS)
int X11_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay *sdl_display, SDL_Rect *rect)
void X11_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
int X11_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
int X11_GetDisplayDPI(_THIS, SDL_VideoDisplay *sdl_display, float *ddpi, float *hdpi, float *vdpi)
void X11_QuitMouse(_THIS)
void X11_InitMouse(_THIS)
SDL_WindowShaper * X11_CreateShaper(SDL_Window *window)
int X11_ResizeWindowShape(SDL_Window *window)
int X11_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shapeMode)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
void X11_QuitTouch(_THIS)
void X11_InitTouch(_THIS)
void X11_ResetTouch(_THIS)
SDL_bool X11_UseDirectColorVisuals(void)
char * X11_GetWindowTitle(_THIS, Window xwindow)
void X11_RaiseWindow(_THIS, SDL_Window *window)
void X11_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered)
int X11_SetWindowModalFor(_THIS, SDL_Window *modal_window, SDL_Window *parent_window)
int X11_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
void X11_MinimizeWindow(_THIS, SDL_Window *window)
int X11_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
void X11_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
void X11_SetWindowTitle(_THIS, SDL_Window *window)
void X11_SetWindowMinimumSize(_THIS, SDL_Window *window)
void X11_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept)
void X11_SetWindowPosition(_THIS, SDL_Window *window)
int X11_SetWindowGammaRamp(_THIS, SDL_Window *window, const Uint16 *ramp)
void X11_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon)
void X11_MaximizeWindow(_THIS, SDL_Window *window)
void X11_HideWindow(_THIS, SDL_Window *window)
void X11_DestroyWindow(_THIS, SDL_Window *window)
int X11_SetWindowInputFocus(_THIS, SDL_Window *window)
void X11_SetWindowSize(_THIS, SDL_Window *window)
void X11_ShowWindow(_THIS, SDL_Window *window)
int X11_SetWindowOpacity(_THIS, SDL_Window *window, float opacity)
int X11_CreateWindow(_THIS, SDL_Window *window)
void X11_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
int X11_GetWindowBordersSize(_THIS, SDL_Window *window, int *top, int *left, int *bottom, int *right)
void X11_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable)
SDL_bool X11_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
void X11_SetWindowMaximumSize(_THIS, SDL_Window *window)
void X11_RestoreWindow(_THIS, SDL_Window *window)
static SDL_AudioDeviceID device
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld endif[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1 beq endif SRC MASK if dst_r_bpp DST_R else add endif PF add sub src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head pixblock_size cache_preload_simple process_pixblock_tail pixinterleave dst_w_basereg irp beq endif process_pixblock_tail_head tst beq irp if pixblock_size chunk_size tst beq pixld_src SRC pixld MASK if DST_R else pixld DST_R endif if
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
The structure that defines a display mode.
Atom _NET_WM_STATE_HIDDEN
Atom _NET_WM_STATE_SKIP_PAGER
Atom _NET_WM_STATE_MAXIMIZED_HORZ
Atom _NET_WM_WINDOW_OPACITY
Atom _NET_WM_STATE_FOCUSED
Atom _NET_WM_STATE_MAXIMIZED_VERT
Atom _NET_WM_STATE_FULLSCREEN
Atom _NET_WM_STATE_SKIP_TASKBAR
Atom _NET_WM_ACTION_FULLSCREEN
Atom _NET_WM_ALLOWED_ACTIONS
struct wl_display * display
SDL_DisplayMode desktop_mode
SDL_DisplayMode current_mode
typedef int(__stdcall *FARPROC)()