static int X11_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid) { int ret; SDL_MessageBoxDataX11 data; #if SDL_SET_LOCALE char *origlocale; #endif SDL_zero(data); if ( !SDL_X11_LoadSymbols() ) return -1; #if SDL_SET_LOCALE origlocale = setlocale(LC_ALL, NULL); if (origlocale != NULL) { origlocale = SDL_strdup(origlocale); if (origlocale == NULL) { return SDL_OutOfMemory(); } setlocale(LC_ALL, ""); } #endif /* This code could get called from multiple threads maybe? */ X11_XInitThreads(); /* Initialize the return buttonid value to -1 (for error or dialogbox closed). */ *buttonid = -1; /* Init and display the message box. */ ret = X11_MessageBoxInit( &data, messageboxdata, buttonid ); if ( ret != -1 ) { ret = X11_MessageBoxInitPositions( &data ); if ( ret != -1 ) { ret = X11_MessageBoxCreateWindow( &data ); if ( ret != -1 ) { ret = X11_MessageBoxLoop( &data ); } } } X11_MessageBoxShutdown( &data ); #if SDL_SET_LOCALE if (origlocale) { setlocale(LC_ALL, origlocale); SDL_free(origlocale); } #endif return ret; }
static SDL_VideoDevice * X11_CreateDevice(int devindex) { SDL_VideoDevice *device; SDL_VideoData *data; const char *display = NULL; /* Use the DISPLAY environment variable */ if (!SDL_X11_LoadSymbols()) { return NULL; } /* Need for threading gl calls. This is also required for the proprietary nVidia driver to be threaded. */ X11_XInitThreads(); /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { SDL_OutOfMemory(); return NULL; } data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); if (!data) { SDL_free(device); SDL_OutOfMemory(); return NULL; } device->driverdata = data; 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); #if defined(__osf__) && defined(SDL_VIDEO_DRIVER_X11_DYNAMIC) /* On Tru64 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; } #ifdef X11_DEBUG X11_XSynchronize(data->display, True); #endif /* Hook up an X11 error handler to recover the desktop resolution. */ safety_net_triggered = SDL_FALSE; orig_x11_errhandler = X11_XSetErrorHandler(X11_SafetyNetErrHandler); /* Set the function pointers */ device->VideoInit = X11_VideoInit; device->VideoQuit = X11_VideoQuit; device->GetDisplayModes = X11_GetDisplayModes; device->GetDisplayBounds = X11_GetDisplayBounds; device->GetDisplayUsableBounds = X11_GetDisplayUsableBounds; device->GetDisplayDPI = X11_GetDisplayDPI; device->SetDisplayMode = X11_SetDisplayMode; device->SuspendScreenSaver = X11_SuspendScreenSaver; device->PumpEvents = X11_PumpEvents; device->CreateWindow = X11_CreateWindow; device->CreateWindowFrom = X11_CreateWindowFrom; device->SetWindowTitle = X11_SetWindowTitle; device->SetWindowIcon = X11_SetWindowIcon; device->SetWindowPosition = X11_SetWindowPosition; device->SetWindowSize = X11_SetWindowSize; device->SetWindowMinimumSize = X11_SetWindowMinimumSize; device->SetWindowMaximumSize = X11_SetWindowMaximumSize; device->GetWindowBordersSize = X11_GetWindowBordersSize; device->SetWindowOpacity = X11_SetWindowOpacity; device->SetWindowModalFor = X11_SetWindowModalFor; device->SetWindowInputFocus = X11_SetWindowInputFocus; device->ShowWindow = X11_ShowWindow; device->HideWindow = X11_HideWindow; device->RaiseWindow = X11_RaiseWindow; device->MaximizeWindow = X11_MaximizeWindow; device->MinimizeWindow = X11_MinimizeWindow; device->RestoreWindow = X11_RestoreWindow; device->SetWindowBordered = X11_SetWindowBordered; device->SetWindowResizable = X11_SetWindowResizable; device->SetWindowFullscreen = X11_SetWindowFullscreen; device->SetWindowGammaRamp = X11_SetWindowGammaRamp; device->SetWindowGrab = X11_SetWindowGrab; device->DestroyWindow = X11_DestroyWindow; device->CreateWindowFramebuffer = X11_CreateWindowFramebuffer; device->UpdateWindowFramebuffer = X11_UpdateWindowFramebuffer; device->DestroyWindowFramebuffer = X11_DestroyWindowFramebuffer; device->GetWindowWMInfo = X11_GetWindowWMInfo; device->SetWindowHitTest = X11_SetWindowHitTest; device->shape_driver.CreateShaper = X11_CreateShaper; device->shape_driver.SetWindowShape = X11_SetWindowShape; device->shape_driver.ResizeWindowShape = X11_ResizeWindowShape; #if SDL_VIDEO_OPENGL_GLX device->GL_LoadLibrary = X11_GL_LoadLibrary; device->GL_GetProcAddress = X11_GL_GetProcAddress; device->GL_UnloadLibrary = X11_GL_UnloadLibrary; device->GL_CreateContext = X11_GL_CreateContext; device->GL_MakeCurrent = X11_GL_MakeCurrent; device->GL_SetSwapInterval = X11_GL_SetSwapInterval; device->GL_GetSwapInterval = X11_GL_GetSwapInterval; device->GL_SwapWindow = X11_GL_SwapWindow; device->GL_DeleteContext = X11_GL_DeleteContext; #elif SDL_VIDEO_OPENGL_EGL device->GL_LoadLibrary = X11_GLES_LoadLibrary; device->GL_GetProcAddress = X11_GLES_GetProcAddress; device->GL_UnloadLibrary = X11_GLES_UnloadLibrary; device->GL_CreateContext = X11_GLES_CreateContext; device->GL_MakeCurrent = X11_GLES_MakeCurrent; device->GL_SetSwapInterval = X11_GLES_SetSwapInterval; device->GL_GetSwapInterval = X11_GLES_GetSwapInterval; device->GL_SwapWindow = X11_GLES_SwapWindow; device->GL_DeleteContext = X11_GLES_DeleteContext; #endif device->SetClipboardText = X11_SetClipboardText; device->GetClipboardText = X11_GetClipboardText; device->HasClipboardText = X11_HasClipboardText; device->StartTextInput = X11_StartTextInput; device->StopTextInput = X11_StopTextInput; device->SetTextInputRect = X11_SetTextInputRect; device->free = X11_DeleteDevice; return device; }