static int DGA_Available(void) { const char *display = NULL; Display *dpy = NULL; int available = 0; /* The driver is available is available if the display is local and the DGA 2.0+ extension is available, and we can map mem. */ if ( SDL_X11_LoadSymbols() ) { if ( (SDL_strncmp(XDisplayName(display), ":", 1) == 0) || (SDL_strncmp(XDisplayName(display), "unix:", 5) == 0) ) { dpy = XOpenDisplay(display); if ( dpy ) { int events, errors, major, minor; if ( SDL_NAME(XDGAQueryExtension)(dpy, &events, &errors) && SDL_NAME(XDGAQueryVersion)(dpy, &major, &minor) ) { int screen; screen = DefaultScreen(dpy); if ( (major >= 2) && SDL_NAME(XDGAOpenFramebuffer)(dpy, screen) ) { available = 1; SDL_NAME(XDGACloseFramebuffer)(dpy, screen); } } XCloseDisplay(dpy); } } SDL_X11_UnloadSymbols(); } return(available); }
/* returns non-zero if all needed symbols were loaded. */ int SDL_X11_LoadSymbols(void) { int rc = 1; /* always succeed if not using Dynamic X11 stuff. */ #ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC /* deal with multiple modules (dga, x11, etc) needing these symbols... */ if (x11_load_refcount++ == 0) { int i; int *thismod = NULL; for (i = 0; i < SDL_TABLESIZE(x11libs); i++) { if (x11libs[i].libname != NULL) { x11libs[i].lib = SDL_LoadObject(x11libs[i].libname); } } #define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 1; /* default yes */ #define SDL_X11_SYM(a,fn,x,y,z) #include "SDL_x11sym.h" #undef SDL_X11_MODULE #undef SDL_X11_SYM #define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname; #define SDL_X11_SYM(a,fn,x,y,z) p##fn = (SDL_DYNX11FN_##fn) X11_GetSym(#fn,thismod); #include "SDL_x11sym.h" #undef SDL_X11_MODULE #undef SDL_X11_SYM #ifdef X_HAVE_UTF8_STRING pXCreateIC = (SDL_DYNX11FN_XCreateIC) X11_GetSym("XCreateIC", &SDL_X11_HAVE_UTF8); pXGetICValues = (SDL_DYNX11FN_XGetICValues) X11_GetSym("XGetICValues", &SDL_X11_HAVE_UTF8); #endif if (SDL_X11_HAVE_BASEXLIB) { /* all required symbols loaded. */ SDL_ClearError(); } else { /* in case something got loaded... */ SDL_X11_UnloadSymbols(); rc = 0; } } #else #define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 1; /* default yes */ #define SDL_X11_SYM(a,fn,x,y,z) #include "SDL_x11sym.h" #undef SDL_X11_MODULE #undef SDL_X11_SYM #ifdef X_HAVE_UTF8_STRING pXCreateIC = XCreateIC; pXGetICValues = XGetICValues; #endif #endif return rc; }
static void DGA_DeleteDevice(SDL_VideoDevice *device) { if (device != NULL) { SDL_free(device->hidden); SDL_free(device); SDL_X11_UnloadSymbols(); } }
/* returns non-zero if all needed symbols were loaded. */ int SDL_X11_LoadSymbols(void) { int rc = 1; /* always succeed if not using Dynamic X11 stuff. */ #ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC /* deal with multiple modules (dga, x11, etc) needing these symbols... */ if (x11_load_refcount++ == 0) { int i; int *thismod = NULL; for (i = 0; i < SDL_TABLESIZE(x11libs); i++) { if (x11libs[i].libname != NULL) { x11libs[i].lib = SDL_LoadObject(x11libs[i].libname); } } #define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname; #define SDL_X11_SYM(rc,fn,params,args,ret) \ p##fn = (rc(*)params) X11_GetSym(#fn, thismod); #include "SDL_x11sym.h" #undef SDL_X11_MODULE #undef SDL_X11_SYM #ifdef X_HAVE_UTF8_STRING pXCreateIC = (XIC(*)(XIM,...)) X11_GetSym("XCreateIC", &SDL_X11_HAVE_UTF8); pXGetICValues = (char * (*)(XIC,...)) X11_GetSym("XGetICValues", &SDL_X11_HAVE_UTF8); #endif /* * In case we're built with newer Xlib headers, we need to make sure * that _XGetRequest() is available, even on older systems. * Otherwise, various Xlib macros we use will call a NULL pointer. */ if (!SDL_X11_HAVE_XGETREQUEST) { p_XGetRequest = SDL_XGetRequest_workaround; } if (SDL_X11_HAVE_BASEXLIB) { /* all required symbols loaded. */ SDL_ClearError(); } else { SDL_X11_UnloadSymbols(); /* in case something got loaded... */ rc = 0; } } #else #if DEBUG_DYNAMIC_X11 printf("X11: No dynamic X11 support in this build of SDL.\n"); #endif #ifdef X_HAVE_UTF8_STRING pXCreateIC = XCreateIC; pXGetICValues = XGetICValues; #endif #endif return rc; }
static int X11_Available(void) { Display *display = NULL; if ( SDL_X11_LoadSymbols() ) { display = XOpenDisplay(NULL); if ( display != NULL ) { XCloseDisplay(display); } SDL_X11_UnloadSymbols(); } return(display != NULL); }
static SDL_VideoDevice *DGA_CreateDevice(int devindex) { SDL_VideoDevice *device = NULL; /* Initialize all variables that we clean on shutdown */ if (SDL_X11_LoadSymbols()) { device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) SDL_malloc((sizeof *device->hidden)); } if ( (device == NULL) || (device->hidden == NULL) ) { SDL_OutOfMemory(); if ( device ) { SDL_free(device); } SDL_X11_UnloadSymbols(); return(0); } SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = DGA_VideoInit; device->ListModes = DGA_ListModes; device->SetVideoMode = DGA_SetVideoMode; device->SetColors = DGA_SetColors; device->UpdateRects = NULL; device->VideoQuit = DGA_VideoQuit; device->AllocHWSurface = DGA_AllocHWSurface; device->CheckHWBlit = DGA_CheckHWBlit; device->FillHWRect = DGA_FillHWRect; device->SetHWColorKey = NULL; device->SetHWAlpha = NULL; device->LockHWSurface = DGA_LockHWSurface; device->UnlockHWSurface = DGA_UnlockHWSurface; device->FlipHWSurface = DGA_FlipHWSurface; device->FreeHWSurface = DGA_FreeHWSurface; device->SetGammaRamp = DGA_SetGammaRamp; device->GetGammaRamp = NULL; device->SetCaption = NULL; device->SetIcon = NULL; device->IconifyWindow = NULL; device->GrabInput = NULL; device->GetWMInfo = NULL; device->InitOSKeymap = DGA_InitOSKeymap; device->PumpEvents = DGA_PumpEvents; device->free = DGA_DeleteDevice; } return device; }
static void X11_DeleteDevice(SDL_VideoDevice * device) { SDL_VideoData *data = (SDL_VideoData *) device->driverdata; if (data->display) { X11_XCloseDisplay(data->display); } SDL_free(data->windowlist); SDL_free(device->driverdata); SDL_free(device); SDL_X11_UnloadSymbols(); }
static void X11_DeleteDevice(SDL_VideoDevice *device) { if ( device ) { if ( device->hidden ) { SDL_free(device->hidden); } if ( device->gl_data ) { SDL_free(device->gl_data); } SDL_free(device); SDL_X11_UnloadSymbols(); } }
static void X11_DeleteDevice(SDL_VideoDevice * device) { SDL_VideoData *data = (SDL_VideoData *) device->driverdata; if (data->display) { XCloseDisplay(data->display); } SDL_free(data->windowlist); SDL_free(device->driverdata); #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 SDL_free(device->gles_data); #endif SDL_free(device); SDL_X11_UnloadSymbols(); }
static void X11_DeleteDevice(SDL_VideoDevice * device) { SDL_VideoData *data = (SDL_VideoData *) device->driverdata; if (device->vulkan_config.loader_handle) { device->Vulkan_UnloadLibrary(device); } if (data->display) { X11_XCloseDisplay(data->display); } SDL_free(data->windowlist); SDL_free(device->driverdata); SDL_free(device); SDL_X11_UnloadSymbols(); }