Go to the documentation of this file.
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';
98 Display *display =
NULL;
100 display = X11_XOpenDisplay(
NULL);
101 if (display !=
NULL) {
102 X11_XCloseDisplay(display);
106 return (display !=
NULL);
113 if (
device->vulkan_config.loader_handle) {
117 X11_XCloseDisplay(
data->display);
128 static int (*orig_x11_errhandler) (Display *, XErrorEvent *) =
NULL;
130 X11_SafetyNetErrHandler(Display *
d, XErrorEvent *
e)
134 if (!safety_net_triggered) {
139 for (
i = 0;
i <
device->num_displays;
i++) {
149 if (orig_x11_errhandler !=
NULL) {
150 return orig_x11_errhandler(
d,
e);
157 X11_CreateDevice(
int devindex)
161 const char *display =
NULL;
196 #ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
216 X11_XSynchronize(
data->display, True);
221 orig_x11_errhandler = X11_XSetErrorHandler(X11_SafetyNetErrHandler);
224 device->VideoInit = X11_VideoInit;
225 device->VideoQuit = X11_VideoQuit;
270 #if SDL_VIDEO_OPENGL_GLX
271 device->GL_LoadLibrary = X11_GL_LoadLibrary;
272 device->GL_GetProcAddress = X11_GL_GetProcAddress;
273 device->GL_UnloadLibrary = X11_GL_UnloadLibrary;
274 device->GL_CreateContext = X11_GL_CreateContext;
275 device->GL_MakeCurrent = X11_GL_MakeCurrent;
276 device->GL_SetSwapInterval = X11_GL_SetSwapInterval;
277 device->GL_GetSwapInterval = X11_GL_GetSwapInterval;
278 device->GL_SwapWindow = X11_GL_SwapWindow;
279 device->GL_DeleteContext = X11_GL_DeleteContext;
281 #if SDL_VIDEO_OPENGL_EGL
282 #if SDL_VIDEO_OPENGL_GLX
285 device->GL_LoadLibrary = X11_GLES_LoadLibrary;
286 device->GL_GetProcAddress = X11_GLES_GetProcAddress;
287 device->GL_UnloadLibrary = X11_GLES_UnloadLibrary;
288 device->GL_CreateContext = X11_GLES_CreateContext;
289 device->GL_MakeCurrent = X11_GLES_MakeCurrent;
290 device->GL_SetSwapInterval = X11_GLES_SetSwapInterval;
291 device->GL_GetSwapInterval = X11_GLES_GetSwapInterval;
292 device->GL_SwapWindow = X11_GLES_SwapWindow;
293 device->GL_DeleteContext = X11_GLES_DeleteContext;
294 #if SDL_VIDEO_OPENGL_GLX
306 device->free = X11_DeleteDevice;
309 device->Vulkan_LoadLibrary = X11_Vulkan_LoadLibrary;
310 device->Vulkan_UnloadLibrary = X11_Vulkan_UnloadLibrary;
311 device->Vulkan_GetInstanceExtensions = X11_Vulkan_GetInstanceExtensions;
312 device->Vulkan_CreateSurface = X11_Vulkan_CreateSurface;
319 "x11",
"SDL X11 video driver",
320 X11_Available, X11_CreateDevice
323 static int (*handler) (Display *, XErrorEvent *) =
NULL;
325 X11_CheckWindowManagerErrorHandler(Display *
d, XErrorEvent *
e)
327 if (
e->error_code == BadWindow) {
330 return (handler(
d,
e));
335 X11_CheckWindowManager(
_THIS)
339 Atom _NET_SUPPORTING_WM_CHECK;
340 int status, real_format;
342 unsigned long items_read = 0, items_left = 0;
343 unsigned char *propdata =
NULL;
344 Window wm_window = 0;
345 #ifdef DEBUG_WINDOW_MANAGER
351 handler = X11_XSetErrorHandler(X11_CheckWindowManagerErrorHandler);
353 _NET_SUPPORTING_WM_CHECK = X11_XInternAtom(
display,
"_NET_SUPPORTING_WM_CHECK", False);
354 status = X11_XGetWindowProperty(
display, DefaultRootWindow(
display), _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
355 if (status == Success) {
357 wm_window = ((Window*)propdata)[0];
366 status = X11_XGetWindowProperty(
display, wm_window, _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
367 if (status != Success || !items_read || wm_window != ((Window*)propdata)[0]) {
370 if (status == Success && propdata) {
378 X11_XSetErrorHandler(handler);
381 #ifdef DEBUG_WINDOW_MANAGER
382 printf(
"Couldn't get _NET_SUPPORTING_WM_CHECK property\n");
388 #ifdef DEBUG_WINDOW_MANAGER
390 printf(
"Window manager: %s\n", wm_name);
402 data->classname = get_classname();
405 data->pid = getpid();
411 #define GET_ATOM(X) data->X = X11_XInternAtom(data->display, #X, False)
447 X11_CheckWindowManager(
_this);
474 if (
data->clipboard_window) {
475 X11_XDestroyWindow(
data->display,
data->clipboard_window);
479 #ifdef X_HAVE_UTF8_STRING
481 X11_XCloseIM(
data->im);
void X11_MaximizeWindow(_THIS, SDL_Window *window)
void X11_DestroyWindow(_THIS, SDL_Window *window)
SDL_bool X11_UseDirectColorVisuals(void)
void X11_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon)
int X11_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shapeMode)
char * X11_GetClipboardText(_THIS)
void X11_MinimizeWindow(_THIS, SDL_Window *window)
void X11_DestroyWindowFramebuffer(_THIS, SDL_Window *window)
void X11_QuitTouch(_THIS)
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
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
VideoBootStrap X11_bootstrap
void X11_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
int X11_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
void X11_RestoreWindow(_THIS, SDL_Window *window)
int X11_GetWindowBordersSize(_THIS, SDL_Window *window, int *top, int *left, int *bottom, int *right)
void X11_InitTouch(_THIS)
int SDL_X11_LoadSymbols(void)
int X11_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
SDL_DisplayMode desktop_mode
void X11_QuitKeyboard(_THIS)
void X11_SetWindowMinimumSize(_THIS, SDL_Window *window)
void X11_SetTextInputRect(_THIS, SDL_Rect *rect)
void SDL_X11_UnloadSymbols(void)
SDL_bool X11_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
void X11_StartTextInput(_THIS)
int X11_SetWindowOpacity(_THIS, SDL_Window *window, float opacity)
void X11_QuitModes(_THIS)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
void X11_HideWindow(_THIS, SDL_Window *window)
The structure that defines a display mode.
char * X11_GetWindowTitle(_THIS, Window xwindow)
int X11_SetWindowInputFocus(_THIS, SDL_Window *window)
#define SDL_GetHintBoolean
void X11_SetWindowPosition(_THIS, SDL_Window *window)
static SDL_VideoDevice * _this
Atom _NET_WM_STATE_MAXIMIZED_HORZ
void X11_ShowWindow(_THIS, SDL_Window *window)
int X11_SetWindowModalFor(_THIS, SDL_Window *modal_window, SDL_Window *parent_window)
int X11_GetDisplayDPI(_THIS, SDL_VideoDisplay *sdl_display, float *ddpi, float *hdpi, float *vdpi)
Atom _NET_WM_STATE_SKIP_TASKBAR
int X11_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay *sdl_display, SDL_Rect *rect)
void X11_SetWindowTitle(_THIS, SDL_Window *window)
Atom _NET_WM_STATE_HIDDEN
void X11_ResetTouch(_THIS)
Atom _NET_WM_STATE_MAXIMIZED_VERT
void X11_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept)
int X11_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
void X11_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable)
SDL_bool X11_HasClipboardText(_THIS)
void X11_RaiseWindow(_THIS, SDL_Window *window)
int X11_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
void X11_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered)
Atom _NET_WM_ACTION_FULLSCREEN
#define SDL_OutOfMemory()
#define SDL_HINT_VIDEO_X11_FORCE_EGL
A variable controlling whether X11 should use GLX or EGL by default.
Atom _NET_WM_WINDOW_OPACITY
Atom _NET_WM_ALLOWED_ACTIONS
#define SDL_arraysize(array)
void X11_SuspendScreenSaver(_THIS)
void X11_StopTextInput(_THIS)
struct wl_display * display
int X11_CreateWindow(_THIS, SDL_Window *window)
void X11_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
int X11_SetWindowGammaRamp(_THIS, SDL_Window *window, const Uint16 *ramp)
void X11_SetWindowMaximumSize(_THIS, SDL_Window *window)
int X11_GetDisplayBounds(_THIS, SDL_VideoDisplay *sdl_display, SDL_Rect *rect)
const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char const char const SDL_SCANF_FORMAT_STRING 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_InitKeyboard(_THIS)
void X11_InitMouse(_THIS)
int X11_SetClipboardText(_THIS, const char *text)
SDL_VideoDevice * SDL_GetVideoDevice(void)
Atom _NET_WM_STATE_SKIP_PAGER
SDL_DisplayMode current_mode
void X11_QuitMouse(_THIS)
SDL_WindowShaper * X11_CreateShaper(SDL_Window *window)
void X11_SetWindowSize(_THIS, SDL_Window *window)
static SDL_AudioDeviceID device
int X11_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
void X11_PumpEvents(_THIS)
void X11_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
int X11_ResizeWindowShape(SDL_Window *window)
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)
Atom _NET_WM_STATE_FULLSCREEN
const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char const char const SDL_SCANF_FORMAT_STRING 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
Atom _NET_WM_STATE_FOCUSED