From dec7875a6e23212021e4d9080330a42832dfe02a Mon Sep 17 00:00:00 2001
From: Edward Rudd <urkle@outoforder.cc>
Date: Tue, 15 Jun 2021 01:40:19 +0000
Subject: [PATCH] update SDL soruce to 2.0.14
---
source/src/video/x11/SDL_x11video.c | 56 +++++++++++++-------------------------------------------
1 files changed, 13 insertions(+), 43 deletions(-)
diff --git a/source/src/video/x11/SDL_x11video.c b/source/src/video/x11/SDL_x11video.c
index 76cce58..4ae9544 100644
--- a/source/src/video/x11/SDL_x11video.c
+++ b/source/src/video/x11/SDL_x11video.c
@@ -92,19 +92,7 @@
/* X11 driver bootstrap functions */
-static int
-X11_Available(void)
-{
- Display *display = NULL;
- if (SDL_X11_LoadSymbols()) {
- display = X11_XOpenDisplay(NULL);
- if (display != NULL) {
- X11_XCloseDisplay(display);
- }
- SDL_X11_UnloadSymbols();
- }
- return (display != NULL);
-}
+static int (*orig_x11_errhandler) (Display *, XErrorEvent *) = NULL;
static void
X11_DeleteDevice(SDL_VideoDevice * device)
@@ -114,6 +102,7 @@
device->Vulkan_UnloadLibrary(device);
}
if (data->display) {
+ X11_XSetErrorHandler(orig_x11_errhandler);
X11_XCloseDisplay(data->display);
}
SDL_free(data->windowlist);
@@ -125,7 +114,6 @@
/* An error handler to reset the vidmode and then call the default handler. */
static SDL_bool safety_net_triggered = SDL_FALSE;
-static int (*orig_x11_errhandler) (Display *, XErrorEvent *) = NULL;
static int
X11_SafetyNetErrHandler(Display * d, XErrorEvent * e)
{
@@ -159,6 +147,7 @@
SDL_VideoDevice *device;
SDL_VideoData *data;
const char *display = NULL; /* Use the DISPLAY environment variable */
+ Display *x11_display = NULL;
if (!SDL_X11_LoadSymbols()) {
return NULL;
@@ -167,6 +156,14 @@
/* Need for threading gl calls. This is also required for the proprietary
nVidia driver to be threaded. */
X11_XInitThreads();
+
+ /* Open the display first to be sure that X11 is available */
+ x11_display = X11_XOpenDisplay(display);
+
+ if (!x11_display) {
+ SDL_X11_UnloadSymbols();
+ return NULL;
+ }
/* Initialize all variables that we clean on shutdown */
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
@@ -184,34 +181,7 @@
data->global_mouse_changed = SDL_TRUE;
- /* FIXME: Do we need this?
- if ( (SDL_strncmp(X11_XDisplayName(display), ":", 1) == 0) ||
- (SDL_strncmp(X11_XDisplayName(display), "unix:", 5) == 0) ) {
- local_X11 = 1;
- } else {
- local_X11 = 0;
- }
- */
- data->display = X11_XOpenDisplay(display);
-#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
- /* On some systems if linking without -lX11, it fails and you get following message.
- * Xlib: connection to ":0.0" refused by server
- * Xlib: XDM authorization key matches an existing client!
- *
- * It succeeds if retrying 1 second later
- * or if running xhost +localhost on shell.
- */
- if (data->display == NULL) {
- SDL_Delay(1000);
- data->display = X11_XOpenDisplay(display);
- }
-#endif
- if (data->display == NULL) {
- SDL_free(device->driverdata);
- SDL_free(device);
- SDL_SetError("Couldn't open X11 display");
- return NULL;
- }
+ data->display = x11_display;
#ifdef X11_DEBUG
X11_XSynchronize(data->display, True);
#endif
@@ -317,7 +287,7 @@
VideoBootStrap X11_bootstrap = {
"x11", "SDL X11 video driver",
- X11_Available, X11_CreateDevice
+ X11_CreateDevice
};
static int (*handler) (Display *, XErrorEvent *) = NULL;
--
Gitblit v1.9.3