/* returns non-zero if all needed symbols were loaded. */ int SDL_WAYLAND_LoadSymbols(void) { int rc = 1; /* always succeed if not using Dynamic WAYLAND stuff. */ /* deal with multiple modules (dga, wayland, etc) needing these symbols... */ if (wayland_load_refcount++ == 0) { #ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC int i; int *thismod = NULL; for (i = 0; i < SDL_TABLESIZE(waylandlibs); i++) { if (waylandlibs[i].libname != NULL) { waylandlibs[i].lib = SDL_LoadObject(waylandlibs[i].libname); } } #define SDL_WAYLAND_MODULE(modname) SDL_WAYLAND_HAVE_##modname = 1; /* default yes */ #define SDL_WAYLAND_SYM(rc,fn,params) #define SDL_WAYLAND_INTERFACE(iface) #include "SDL_waylandsym.h" #undef SDL_WAYLAND_MODULE #undef SDL_WAYLAND_SYM #undef SDL_WAYLAND_INTERFACE #define SDL_WAYLAND_MODULE(modname) thismod = &SDL_WAYLAND_HAVE_##modname; #define SDL_WAYLAND_SYM(rc,fn,params) WAYLAND_##fn = (SDL_DYNWAYLANDFN_##fn) WAYLAND_GetSym(#fn,thismod); #define SDL_WAYLAND_INTERFACE(iface) WAYLAND_##iface = (struct wl_interface *) WAYLAND_GetSym(#iface,thismod); #include "SDL_waylandsym.h" #undef SDL_WAYLAND_MODULE #undef SDL_WAYLAND_SYM #undef SDL_WAYLAND_INTERFACE if (SDL_WAYLAND_HAVE_WAYLAND_CLIENT) { /* all required symbols loaded. */ SDL_ClearError(); } else { /* in case something got loaded... */ SDL_WAYLAND_UnloadSymbols(); rc = 0; } #else /* no dynamic WAYLAND */ #define SDL_WAYLAND_MODULE(modname) SDL_WAYLAND_HAVE_##modname = 1; /* default yes */ #define SDL_WAYLAND_SYM(rc,fn,params) WAYLAND_##fn = fn; #define SDL_WAYLAND_INTERFACE(iface) WAYLAND_##iface = &iface; #include "SDL_waylandsym.h" #undef SDL_WAYLAND_MODULE #undef SDL_WAYLAND_SYM #undef SDL_WAYLAND_INTERFACE #endif } return rc; }
static SDL_VideoDevice * Wayland_CreateDevice(int devindex) { SDL_VideoDevice *device; if (!SDL_WAYLAND_LoadSymbols()) { return NULL; } /* Initialize all variables that we clean on shutdown */ device = SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { SDL_WAYLAND_UnloadSymbols(); SDL_OutOfMemory(); return NULL; } /* Set the function pointers */ device->VideoInit = Wayland_VideoInit; device->VideoQuit = Wayland_VideoQuit; device->SetDisplayMode = Wayland_SetDisplayMode; device->GetDisplayModes = Wayland_GetDisplayModes; device->GetWindowWMInfo = Wayland_GetWindowWMInfo; device->PumpEvents = Wayland_PumpEvents; device->GL_SwapWindow = Wayland_GLES_SwapWindow; device->GL_GetSwapInterval = Wayland_GLES_GetSwapInterval; device->GL_SetSwapInterval = Wayland_GLES_SetSwapInterval; device->GL_MakeCurrent = Wayland_GLES_MakeCurrent; device->GL_CreateContext = Wayland_GLES_CreateContext; device->GL_LoadLibrary = Wayland_GLES_LoadLibrary; device->GL_UnloadLibrary = Wayland_GLES_UnloadLibrary; device->GL_GetProcAddress = Wayland_GLES_GetProcAddress; device->GL_DeleteContext = Wayland_GLES_DeleteContext; device->CreateWindow = Wayland_CreateWindow; device->ShowWindow = Wayland_ShowWindow; device->SetWindowFullscreen = Wayland_SetWindowFullscreen; device->MaximizeWindow = Wayland_MaximizeWindow; device->RestoreWindow = Wayland_RestoreWindow; device->SetWindowSize = Wayland_SetWindowSize; device->SetWindowTitle = Wayland_SetWindowTitle; device->DestroyWindow = Wayland_DestroyWindow; device->SetWindowHitTest = Wayland_SetWindowHitTest; device->SetClipboardText = Wayland_SetClipboardText; device->GetClipboardText = Wayland_GetClipboardText; device->HasClipboardText = Wayland_HasClipboardText; device->free = Wayland_DeleteDevice; return device; }
/* Wayland driver bootstrap functions */ static int Wayland_Available(void) { struct wl_display *display = NULL; if (SDL_WAYLAND_LoadSymbols()) { display = WAYLAND_wl_display_connect(NULL); if (display != NULL) { WAYLAND_wl_display_disconnect(display); } SDL_WAYLAND_UnloadSymbols(); } return (display != NULL); }
static void Wayland_DeleteDevice(SDL_VideoDevice *device) { SDL_free(device); SDL_WAYLAND_UnloadSymbols(); }