21 #include "../../SDL_internal.h" 23 #if SDL_VIDEO_DRIVER_X11 30 #include "../SDL_sysvideo.h" 31 #include "../SDL_pixels_c.h" 39 #if SDL_VIDEO_OPENGL_EGL 46 static int X11_VideoInit(
_THIS);
47 static void X11_VideoQuit(
_THIS);
54 #if defined(__LINUX__) || defined(__FREEBSD__) 67 #if defined(__LINUX__) || defined(__FREEBSD__) 68 #if defined(__LINUX__) 70 #elif defined(__FREEBSD__) 74 #error Where can we find the executable name? 76 linksize = readlink(procfile, linkfile,
sizeof(linkfile) - 1);
78 linkfile[linksize] =
'\0';
97 Display *display =
NULL;
99 display = X11_XOpenDisplay(
NULL);
100 if (display !=
NULL) {
101 X11_XCloseDisplay(display);
105 return (display !=
NULL);
116 X11_XCloseDisplay(data->
display);
127 static int (*orig_x11_errhandler) (Display *, XErrorEvent *) =
NULL;
129 X11_SafetyNetErrHandler(Display *
d, XErrorEvent *
e)
133 if (!safety_net_triggered) {
136 if (device !=
NULL) {
148 if (orig_x11_errhandler !=
NULL) {
149 return orig_x11_errhandler(d, e);
156 X11_CreateDevice(
int devindex)
160 const char *display =
NULL;
194 data->
display = X11_XOpenDisplay(display);
195 #ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC 205 data->
display = X11_XOpenDisplay(display);
215 X11_XSynchronize(data->
display, True);
220 orig_x11_errhandler = X11_XSetErrorHandler(X11_SafetyNetErrHandler);
269 #if SDL_VIDEO_OPENGL_GLX 279 #elif SDL_VIDEO_OPENGL_EGL 298 device->
free = X11_DeleteDevice;
311 "x11",
"SDL X11 video driver",
312 X11_Available, X11_CreateDevice
315 static int (*handler) (Display *, XErrorEvent *) =
NULL;
317 X11_CheckWindowManagerErrorHandler(Display * d, XErrorEvent * e)
319 if (e->error_code == BadWindow) {
322 return (handler(d, e));
327 X11_CheckWindowManager(
_THIS)
330 Display *display = data->
display;
331 Atom _NET_SUPPORTING_WM_CHECK;
332 int status, real_format;
334 unsigned long items_read = 0, items_left = 0;
335 unsigned char *propdata =
NULL;
336 Window wm_window = 0;
337 #ifdef DEBUG_WINDOW_MANAGER
342 X11_XSync(display, False);
343 handler = X11_XSetErrorHandler(X11_CheckWindowManagerErrorHandler);
345 _NET_SUPPORTING_WM_CHECK = X11_XInternAtom(display,
"_NET_SUPPORTING_WM_CHECK", False);
346 status = X11_XGetWindowProperty(display, DefaultRootWindow(display), _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
347 if (status == Success) {
349 wm_window = ((Window*)propdata)[0];
358 status = X11_XGetWindowProperty(display, wm_window, _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
359 if (status != Success || !items_read || wm_window != ((Window*)propdata)[0]) {
362 if (status == Success && propdata) {
369 X11_XSync(display, False);
370 X11_XSetErrorHandler(handler);
373 #ifdef DEBUG_WINDOW_MANAGER 374 printf(
"Couldn't get _NET_SUPPORTING_WM_CHECK property\n");
380 #ifdef DEBUG_WINDOW_MANAGER 382 printf(
"Window manager: %s\n", wm_name);
397 data->
pid = getpid();
403 #define GET_ATOM(X) data->X = X11_XInternAtom(data->display, #X, False) 439 X11_CheckWindowManager(_this);
471 #ifdef X_HAVE_UTF8_STRING 473 X11_XCloseIM(data->
im);
int(* Vulkan_LoadLibrary)(_THIS, const char *path)
void X11_PumpEvents(_THIS)
int(* GetDisplayDPI)(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi)
int X11_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
Atom _NET_WM_STATE_FULLSCREEN
int X11_ResizeWindowShape(SDL_Window *window)
Atom _NET_WM_ALLOWED_ACTIONS
VideoBootStrap X11_bootstrap
void(* RestoreWindow)(_THIS, SDL_Window *window)
void X11_SetWindowTitle(_THIS, SDL_Window *window)
int X11_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
int(* SetWindowHitTest)(SDL_Window *window, SDL_bool enabled)
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
int X11_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
Atom _NET_WM_STATE_MAXIMIZED_VERT
char * X11_GetClipboardText(_THIS)
void X11_QuitKeyboard(_THIS)
void X11_SetTextInputRect(_THIS, SDL_Rect *rect)
struct wl_display * display
int X11_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shapeMode)
SDL_bool X11_UseDirectColorVisuals(void)
int(* GL_SetSwapInterval)(_THIS, int interval)
void(* ShowWindow)(_THIS, SDL_Window *window)
The structure that defines a display mode.
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 local skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
void X11_ResetTouch(_THIS)
SDL_WindowData ** windowlist
void X11_StartTextInput(_THIS)
void(* StartTextInput)(_THIS)
void(* SetWindowSize)(_THIS, SDL_Window *window)
int X11_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
int(* GetWindowBordersSize)(_THIS, SDL_Window *window, int *top, int *left, int *bottom, int *right)
void X11_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
void X11_MinimizeWindow(_THIS, SDL_Window *window)
Atom _NET_WM_WINDOW_OPACITY
void X11_InitMouse(_THIS)
void X11_DestroyWindowFramebuffer(_THIS, SDL_Window *window)
int(* GL_LoadLibrary)(_THIS, const char *path)
SDL_bool global_mouse_changed
int X11_SetWindowOpacity(_THIS, SDL_Window *window, float opacity)
void X11_MaximizeWindow(_THIS, SDL_Window *window)
int(* SetDisplayMode)(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
void(* SetWindowBordered)(_THIS, SDL_Window *window, SDL_bool bordered)
int X11_GetDisplayBounds(_THIS, SDL_VideoDisplay *sdl_display, SDL_Rect *rect)
static SDL_VideoDevice * _this
void(* HideWindow)(_THIS, SDL_Window *window)
static SDL_AudioDeviceID device
Atom _NET_WM_STATE_SKIP_TASKBAR
void(* RaiseWindow)(_THIS, SDL_Window *window)
int(* SetWindowShape)(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode)
Atom _NET_WM_STATE_HIDDEN
void(* SetTextInputRect)(_THIS, SDL_Rect *rect)
SDL_bool(* Vulkan_GetInstanceExtensions)(_THIS, SDL_Window *window, unsigned *count, const char **names)
SDL_bool X11_HasClipboardText(_THIS)
SDL_bool(* GetWindowWMInfo)(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
int X11_CreateWindow(_THIS, SDL_Window *window)
void X11_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
void X11_SuspendScreenSaver(_THIS)
void X11_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept)
Atom _NET_WM_STATE_SKIP_PAGER
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
SDL_bool(* Vulkan_CreateSurface)(_THIS, SDL_Window *window, VkInstance instance, VkSurfaceKHR *surface)
int X11_SetWindowGammaRamp(_THIS, SDL_Window *window, const Uint16 *ramp)
int(* GL_MakeCurrent)(_THIS, SDL_Window *window, SDL_GLContext context)
int X11_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
void(* Vulkan_UnloadLibrary)(_THIS)
int SDL_X11_LoadSymbols(void)
void(* SetWindowMinimumSize)(_THIS, SDL_Window *window)
int X11_SetWindowInputFocus(_THIS, SDL_Window *window)
int X11_GetDisplayDPI(_THIS, SDL_VideoDisplay *sdl_display, float *ddpi, float *hdpi, float *vdpi)
SDL_DisplayMode current_mode
void X11_RestoreWindow(_THIS, SDL_Window *window)
SDL_VideoDisplay * displays
int(* GetDisplayBounds)(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
int X11_GetWindowBordersSize(_THIS, SDL_Window *window, int *top, int *left, int *bottom, int *right)
void(* DestroyWindow)(_THIS, SDL_Window *window)
void(* StopTextInput)(_THIS)
Atom _NET_WM_ACTION_FULLSCREEN
void(* SetWindowIcon)(_THIS, SDL_Window *window, SDL_Surface *icon)
void X11_ShowWindow(_THIS, SDL_Window *window)
void X11_DestroyWindow(_THIS, SDL_Window *window)
void X11_QuitMouse(_THIS)
SDL_WindowShaper * X11_CreateShaper(SDL_Window *window)
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 local 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
int X11_SetClipboardText(_THIS, const char *text)
void(* DestroyWindowFramebuffer)(_THIS, SDL_Window *window)
void(* ResetTouch)(_THIS)
void(* GL_UnloadLibrary)(_THIS)
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(* GetDisplayModes)(_THIS, SDL_VideoDisplay *display)
void X11_SetWindowMinimumSize(_THIS, SDL_Window *window)
void(* SetWindowMaximumSize)(_THIS, SDL_Window *window)
int(* CreateSDLWindow)(_THIS, SDL_Window *window)
#define SDL_OutOfMemory()
SDL_DisplayMode desktop_mode
int X11_SetWindowModalFor(_THIS, SDL_Window *modal_window, SDL_Window *parent_window)
struct SDL_VideoDevice::@34 vulkan_config
Atom _NET_WM_STATE_MAXIMIZED_HORZ
void X11_StopTextInput(_THIS)
SDL_WindowShaper *(* CreateShaper)(SDL_Window *window)
int(* ResizeWindowShape)(SDL_Window *window)
int(* SetWindowOpacity)(_THIS, SDL_Window *window, float opacity)
int X11_InitKeyboard(_THIS)
void X11_QuitModes(_THIS)
void(* SetWindowPosition)(_THIS, SDL_Window *window)
int(* GL_SwapWindow)(_THIS, SDL_Window *window)
void(* MinimizeWindow)(_THIS, SDL_Window *window)
Atom _NET_WM_STATE_FOCUSED
void X11_RaiseWindow(_THIS, SDL_Window *window)
void X11_InitTouch(_THIS)
void X11_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon)
char * X11_GetWindowTitle(_THIS, Window xwindow)
int(* SetWindowInputFocus)(_THIS, SDL_Window *window)
SDL_bool(* HasClipboardText)(_THIS)
SDL_VideoDevice * SDL_GetVideoDevice(void)
SDL_ShapeDriver shape_driver
int(* CreateSDLWindowFrom)(_THIS, SDL_Window *window, const void *data)
#define SDL_arraysize(array)
void(* SetWindowFullscreen)(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
int(* SetWindowModalFor)(_THIS, SDL_Window *modal_window, SDL_Window *parent_window)
int(* UpdateWindowFramebuffer)(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
void SDL_X11_UnloadSymbols(void)
void(* GL_DeleteContext)(_THIS, SDL_GLContext context)
char *(* GetClipboardText)(_THIS)
void X11_SetWindowSize(_THIS, SDL_Window *window)
void(* SetWindowTitle)(_THIS, SDL_Window *window)
void(* SetWindowResizable)(_THIS, SDL_Window *window, SDL_bool resizable)
int X11_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay *sdl_display, SDL_Rect *rect)
int(* GetDisplayUsableBounds)(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
int(* GL_GetSwapInterval)(_THIS)
void(* MaximizeWindow)(_THIS, SDL_Window *window)
int(* SetClipboardText)(_THIS, const char *text)
int(* SetWindowGammaRamp)(_THIS, SDL_Window *window, const Uint16 *ramp)
void X11_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered)
void X11_HideWindow(_THIS, SDL_Window *window)
void(* SuspendScreenSaver)(_THIS)
void(* SetWindowGrab)(_THIS, SDL_Window *window, SDL_bool grabbed)
void X11_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable)
void X11_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
int(* CreateWindowFramebuffer)(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
void *(* GL_GetProcAddress)(_THIS, const char *proc)
SDL_bool X11_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
void X11_SetWindowMaximumSize(_THIS, SDL_Window *window)
void X11_QuitTouch(_THIS)
void(* PumpEvents)(_THIS)
void(* AcceptDragAndDrop)(SDL_Window *window, SDL_bool accept)
void X11_SetWindowPosition(_THIS, SDL_Window *window)