Go to the documentation of this file.
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);
112 if (
device->vulkan_config.loader_handle) {
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) {
138 for (
i = 0;
i <
device->num_displays;
i++) {
148 if (orig_x11_errhandler !=
NULL) {
149 return orig_x11_errhandler(
d,
e);
156 X11_CreateDevice(
int devindex)
160 const char *display =
NULL;
195 #ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
215 X11_XSynchronize(
data->display, True);
220 orig_x11_errhandler = X11_XSetErrorHandler(X11_SafetyNetErrHandler);
223 device->VideoInit = X11_VideoInit;
224 device->VideoQuit = X11_VideoQuit;
269 #if SDL_VIDEO_OPENGL_GLX
270 device->GL_LoadLibrary = X11_GL_LoadLibrary;
271 device->GL_GetProcAddress = X11_GL_GetProcAddress;
272 device->GL_UnloadLibrary = X11_GL_UnloadLibrary;
273 device->GL_CreateContext = X11_GL_CreateContext;
274 device->GL_MakeCurrent = X11_GL_MakeCurrent;
275 device->GL_SetSwapInterval = X11_GL_SetSwapInterval;
276 device->GL_GetSwapInterval = X11_GL_GetSwapInterval;
277 device->GL_SwapWindow = X11_GL_SwapWindow;
278 device->GL_DeleteContext = X11_GL_DeleteContext;
279 #elif SDL_VIDEO_OPENGL_EGL
280 device->GL_LoadLibrary = X11_GLES_LoadLibrary;
281 device->GL_GetProcAddress = X11_GLES_GetProcAddress;
282 device->GL_UnloadLibrary = X11_GLES_UnloadLibrary;
283 device->GL_CreateContext = X11_GLES_CreateContext;
284 device->GL_MakeCurrent = X11_GLES_MakeCurrent;
285 device->GL_SetSwapInterval = X11_GLES_SetSwapInterval;
286 device->GL_GetSwapInterval = X11_GLES_GetSwapInterval;
287 device->GL_SwapWindow = X11_GLES_SwapWindow;
288 device->GL_DeleteContext = X11_GLES_DeleteContext;
298 device->free = X11_DeleteDevice;
301 device->Vulkan_LoadLibrary = X11_Vulkan_LoadLibrary;
302 device->Vulkan_UnloadLibrary = X11_Vulkan_UnloadLibrary;
303 device->Vulkan_GetInstanceExtensions = X11_Vulkan_GetInstanceExtensions;
304 device->Vulkan_CreateSurface = X11_Vulkan_CreateSurface;
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)
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
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) {
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);
394 data->classname = get_classname();
397 data->pid = getpid();
403 #define GET_ATOM(X) data->X = X11_XInternAtom(data->display, #X, False)
439 X11_CheckWindowManager(
_this);
466 if (
data->clipboard_window) {
467 X11_XDestroyWindow(
data->display,
data->clipboard_window);
471 #ifdef X_HAVE_UTF8_STRING
473 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)
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)
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()
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)
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_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)
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)
int X11_ResizeWindowShape(SDL_Window *window)
Atom _NET_WM_STATE_FULLSCREEN
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
Atom _NET_WM_STATE_FOCUSED