21 #include "../../SDL_internal.h" 23 #if SDL_VIDEO_DRIVER_X11 29 #include "../SDL_sysvideo.h" 30 #include "../SDL_pixels_c.h" 38 #if SDL_VIDEO_OPENGL_EGL 42 #ifdef X_HAVE_UTF8_STRING 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';
98 Display *display =
NULL;
100 display = X11_XOpenDisplay(
NULL);
101 if (display !=
NULL) {
102 X11_XCloseDisplay(display);
106 return (display !=
NULL);
114 X11_XCloseDisplay(data->
display);
125 static int (*orig_x11_errhandler) (Display *, XErrorEvent *) =
NULL;
127 X11_SafetyNetErrHandler(Display *
d, XErrorEvent *
e)
131 if (!safety_net_triggered) {
134 if (device !=
NULL) {
146 if (orig_x11_errhandler !=
NULL) {
147 return orig_x11_errhandler(d, e);
154 X11_CreateDevice(
int devindex)
158 const char *display =
NULL;
192 data->
display = X11_XOpenDisplay(display);
193 #if defined(__osf__) && defined(SDL_VIDEO_DRIVER_X11_DYNAMIC) 203 data->
display = X11_XOpenDisplay(display);
213 X11_XSynchronize(data->
display, True);
218 orig_x11_errhandler = X11_XSetErrorHandler(X11_SafetyNetErrHandler);
265 #if SDL_VIDEO_OPENGL_GLX 275 #elif SDL_VIDEO_OPENGL_EGL 294 device->
free = X11_DeleteDevice;
300 "x11",
"SDL X11 video driver",
301 X11_Available, X11_CreateDevice
304 static int (*handler) (Display *, XErrorEvent *) =
NULL;
306 X11_CheckWindowManagerErrorHandler(Display * d, XErrorEvent * e)
308 if (e->error_code == BadWindow) {
311 return (handler(d, e));
316 X11_CheckWindowManager(
_THIS)
319 Display *display = data->
display;
320 Atom _NET_SUPPORTING_WM_CHECK;
321 int status, real_format;
323 unsigned long items_read = 0, items_left = 0;
324 unsigned char *propdata =
NULL;
325 Window wm_window = 0;
326 #ifdef DEBUG_WINDOW_MANAGER
331 X11_XSync(display, False);
332 handler = X11_XSetErrorHandler(X11_CheckWindowManagerErrorHandler);
334 _NET_SUPPORTING_WM_CHECK = X11_XInternAtom(display,
"_NET_SUPPORTING_WM_CHECK", False);
335 status = X11_XGetWindowProperty(display, DefaultRootWindow(display), _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
336 if (status == Success) {
338 wm_window = ((Window*)propdata)[0];
347 status = X11_XGetWindowProperty(display, wm_window, _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
348 if (status != Success || !items_read || wm_window != ((Window*)propdata)[0]) {
351 if (status == Success && propdata) {
358 X11_XSync(display, False);
359 X11_XSetErrorHandler(handler);
362 #ifdef DEBUG_WINDOW_MANAGER 363 printf(
"Couldn't get _NET_SUPPORTING_WM_CHECK property\n");
369 #ifdef DEBUG_WINDOW_MANAGER 371 printf(
"Window manager: %s\n", wm_name);
386 data->
pid = getpid();
392 #ifdef X_HAVE_UTF8_STRING 393 if (SDL_X11_HAVE_UTF8) {
396 char *prev_locale = setlocale(LC_ALL,
NULL);
397 char *prev_xmods = X11_XSetLocaleModifiers(
NULL);
398 const char *new_xmods =
"";
399 #if defined(HAVE_IBUS_IBUS_H) || defined(HAVE_FCITX_FRONTEND_H) 400 const char *env_xmods =
SDL_getenv(
"XMODIFIERS");
416 #ifdef HAVE_IBUS_IBUS_H 421 #ifdef HAVE_FCITX_FRONTEND_H 426 if (has_dbus_ime_support) {
427 new_xmods =
"@im=none";
430 setlocale(LC_ALL,
"");
431 X11_XSetLocaleModifiers(new_xmods);
437 setlocale(LC_ALL, prev_locale);
438 X11_XSetLocaleModifiers(prev_xmods);
451 #define GET_ATOM(X) data->X = X11_XInternAtom(data->display, #X, False) 487 X11_CheckWindowManager(_this);
515 #ifdef X_HAVE_UTF8_STRING 517 X11_XCloseIM(data->
im);
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
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)
int(* CreateWindowFrom)(_THIS, SDL_Window *window, const void *data)
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)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
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
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)
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)
void(* GL_SwapWindow)(_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)
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)
void * SDL_calloc(size_t nmemb, size_t size)
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)
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
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)
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(* 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)
#define SDL_OutOfMemory()
SDL_DisplayMode desktop_mode
int X11_SetWindowModalFor(_THIS, SDL_Window *modal_window, SDL_Window *parent_window)
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(* CreateWindow)(_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
#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 X11_SetWindowPosition(_THIS, SDL_Window *window)