|
@@ -92,20 +92,6 @@ get_classname()
|
|
|
|
|
|
/* 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 void
|
|
|
X11_DeleteDevice(SDL_VideoDevice * device)
|
|
|
{
|
|
@@ -159,10 +145,7 @@ X11_CreateDevice(int devindex)
|
|
|
SDL_VideoDevice *device;
|
|
|
SDL_VideoData *data;
|
|
|
const char *display = NULL; /* Use the DISPLAY environment variable */
|
|
|
-
|
|
|
- if (!X11_Available()) {
|
|
|
- return NULL;
|
|
|
- }
|
|
|
+ Display *x11_display = NULL;
|
|
|
|
|
|
if (!SDL_X11_LoadSymbols()) {
|
|
|
return NULL;
|
|
@@ -172,6 +155,14 @@ X11_CreateDevice(int devindex)
|
|
|
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));
|
|
|
if (!device) {
|
|
@@ -188,34 +179,7 @@ X11_CreateDevice(int devindex)
|
|
|
|
|
|
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
|