|
@@ -120,25 +120,15 @@ get_classname()
|
|
return SDL_strdup("SDL_App");
|
|
return SDL_strdup("SDL_App");
|
|
}
|
|
}
|
|
|
|
|
|
-/* 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
|
|
static void
|
|
Wayland_DeleteDevice(SDL_VideoDevice *device)
|
|
Wayland_DeleteDevice(SDL_VideoDevice *device)
|
|
{
|
|
{
|
|
|
|
+ SDL_VideoData *data = (SDL_VideoData *)device->driverdata;
|
|
|
|
+ if (data->display) {
|
|
|
|
+ WAYLAND_wl_display_flush(data->display);
|
|
|
|
+ WAYLAND_wl_display_disconnect(data->display);
|
|
|
|
+ }
|
|
|
|
+ SDL_free(data);
|
|
SDL_free(device);
|
|
SDL_free(device);
|
|
SDL_WAYLAND_UnloadSymbols();
|
|
SDL_WAYLAND_UnloadSymbols();
|
|
}
|
|
}
|
|
@@ -147,23 +137,41 @@ static SDL_VideoDevice *
|
|
Wayland_CreateDevice(int devindex)
|
|
Wayland_CreateDevice(int devindex)
|
|
{
|
|
{
|
|
SDL_VideoDevice *device;
|
|
SDL_VideoDevice *device;
|
|
|
|
+ SDL_VideoData *data;
|
|
|
|
+ struct wl_display *display;
|
|
|
|
|
|
- if (!Wayland_Available()) {
|
|
|
|
|
|
+ if (!SDL_WAYLAND_LoadSymbols()) {
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- if (!SDL_WAYLAND_LoadSymbols()) {
|
|
|
|
|
|
+ display = WAYLAND_wl_display_connect(NULL);
|
|
|
|
+ if (display == NULL) {
|
|
|
|
+ SDL_WAYLAND_UnloadSymbols();
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ data = SDL_calloc(1, sizeof(*data));
|
|
|
|
+ if (data == NULL) {
|
|
|
|
+ WAYLAND_wl_display_disconnect(display);
|
|
|
|
+ SDL_WAYLAND_UnloadSymbols();
|
|
|
|
+ SDL_OutOfMemory();
|
|
|
|
+ return NULL;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ data->display = display;
|
|
|
|
+
|
|
/* Initialize all variables that we clean on shutdown */
|
|
/* Initialize all variables that we clean on shutdown */
|
|
device = SDL_calloc(1, sizeof(SDL_VideoDevice));
|
|
device = SDL_calloc(1, sizeof(SDL_VideoDevice));
|
|
if (!device) {
|
|
if (!device) {
|
|
|
|
+ SDL_free(data);
|
|
|
|
+ WAYLAND_wl_display_disconnect(display);
|
|
SDL_WAYLAND_UnloadSymbols();
|
|
SDL_WAYLAND_UnloadSymbols();
|
|
SDL_OutOfMemory();
|
|
SDL_OutOfMemory();
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ device->driverdata = data;
|
|
|
|
+
|
|
/* Set the function pointers */
|
|
/* Set the function pointers */
|
|
device->VideoInit = Wayland_VideoInit;
|
|
device->VideoInit = Wayland_VideoInit;
|
|
device->VideoQuit = Wayland_VideoQuit;
|
|
device->VideoQuit = Wayland_VideoQuit;
|
|
@@ -417,22 +425,13 @@ static const struct wl_registry_listener registry_listener = {
|
|
int
|
|
int
|
|
Wayland_VideoInit(_THIS)
|
|
Wayland_VideoInit(_THIS)
|
|
{
|
|
{
|
|
- SDL_VideoData *data = SDL_calloc(1, sizeof(*data));
|
|
|
|
- if (data == NULL)
|
|
|
|
- return SDL_OutOfMemory();
|
|
|
|
-
|
|
|
|
- _this->driverdata = data;
|
|
|
|
|
|
+ SDL_VideoData *data = (SDL_VideoData*)_this->driverdata;
|
|
|
|
|
|
data->xkb_context = WAYLAND_xkb_context_new(0);
|
|
data->xkb_context = WAYLAND_xkb_context_new(0);
|
|
if (!data->xkb_context) {
|
|
if (!data->xkb_context) {
|
|
return SDL_SetError("Failed to create XKB context");
|
|
return SDL_SetError("Failed to create XKB context");
|
|
}
|
|
}
|
|
|
|
|
|
- data->display = WAYLAND_wl_display_connect(NULL);
|
|
|
|
- if (data->display == NULL) {
|
|
|
|
- return SDL_SetError("Failed to connect to a Wayland display");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
data->registry = wl_display_get_registry(data->display);
|
|
data->registry = wl_display_get_registry(data->display);
|
|
if (data->registry == NULL) {
|
|
if (data->registry == NULL) {
|
|
return SDL_SetError("Failed to get the Wayland registry");
|
|
return SDL_SetError("Failed to get the Wayland registry");
|
|
@@ -529,14 +528,7 @@ Wayland_VideoQuit(_THIS)
|
|
if (data->registry)
|
|
if (data->registry)
|
|
wl_registry_destroy(data->registry);
|
|
wl_registry_destroy(data->registry);
|
|
|
|
|
|
- if (data->display) {
|
|
|
|
- WAYLAND_wl_display_flush(data->display);
|
|
|
|
- WAYLAND_wl_display_disconnect(data->display);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
SDL_free(data->classname);
|
|
SDL_free(data->classname);
|
|
- SDL_free(data);
|
|
|
|
- _this->driverdata = NULL;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
#endif /* SDL_VIDEO_DRIVER_WAYLAND */
|
|
#endif /* SDL_VIDEO_DRIVER_WAYLAND */
|