|
@@ -19,10 +19,11 @@
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
*/
|
|
*/
|
|
|
|
|
|
-#include "SDL_config.h"
|
|
|
|
|
|
+#include "../../SDL_internal.h"
|
|
|
|
|
|
#include "SDL_video.h"
|
|
#include "SDL_video.h"
|
|
#include "SDL_mouse.h"
|
|
#include "SDL_mouse.h"
|
|
|
|
+#include "SDL_stdinc.h"
|
|
#include "../../events/SDL_events_c.h"
|
|
#include "../../events/SDL_events_c.h"
|
|
|
|
|
|
#include "SDL_waylandvideo.h"
|
|
#include "SDL_waylandvideo.h"
|
|
@@ -35,6 +36,9 @@
|
|
#include <fcntl.h>
|
|
#include <fcntl.h>
|
|
#include <xkbcommon/xkbcommon.h>
|
|
#include <xkbcommon/xkbcommon.h>
|
|
|
|
|
|
|
|
+#include "SDL_waylanddyn.h"
|
|
|
|
+#include <wayland-util.h>
|
|
|
|
+
|
|
#define WAYLANDVID_DRIVER_NAME "wayland"
|
|
#define WAYLANDVID_DRIVER_NAME "wayland"
|
|
|
|
|
|
struct wayland_mode {
|
|
struct wayland_mode {
|
|
@@ -59,10 +63,12 @@ static int
|
|
Wayland_Available(void)
|
|
Wayland_Available(void)
|
|
{
|
|
{
|
|
struct wl_display *display = NULL;
|
|
struct wl_display *display = NULL;
|
|
-
|
|
|
|
- display = wl_display_connect(NULL);
|
|
|
|
- if (display != NULL) {
|
|
|
|
- wl_display_disconnect(display);
|
|
|
|
|
|
+ if (SDL_WAYLAND_LoadSymbols()) {
|
|
|
|
+ display = WAYLAND_wl_display_connect(NULL);
|
|
|
|
+ if (display != NULL) {
|
|
|
|
+ WAYLAND_wl_display_disconnect(display);
|
|
|
|
+ }
|
|
|
|
+ SDL_WAYLAND_UnloadSymbols();
|
|
}
|
|
}
|
|
|
|
|
|
return (display != NULL);
|
|
return (display != NULL);
|
|
@@ -72,12 +78,17 @@ static void
|
|
Wayland_DeleteDevice(SDL_VideoDevice *device)
|
|
Wayland_DeleteDevice(SDL_VideoDevice *device)
|
|
{
|
|
{
|
|
SDL_free(device);
|
|
SDL_free(device);
|
|
|
|
+ SDL_WAYLAND_UnloadSymbols();
|
|
}
|
|
}
|
|
|
|
|
|
static SDL_VideoDevice *
|
|
static SDL_VideoDevice *
|
|
Wayland_CreateDevice(int devindex)
|
|
Wayland_CreateDevice(int devindex)
|
|
{
|
|
{
|
|
SDL_VideoDevice *device;
|
|
SDL_VideoDevice *device;
|
|
|
|
+
|
|
|
|
+ if (!SDL_WAYLAND_LoadSymbols()) {
|
|
|
|
+ return NULL;
|
|
|
|
+ }
|
|
|
|
|
|
/* 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));
|
|
@@ -133,13 +144,13 @@ wayland_add_mode(SDL_VideoData *d, SDL_DisplayMode m)
|
|
return;
|
|
return;
|
|
|
|
|
|
/* Add new mode to the list */
|
|
/* Add new mode to the list */
|
|
- mode = SDL_calloc(1, sizeof *mode);
|
|
|
|
|
|
+ mode = (struct wayland_mode *) SDL_calloc(1, sizeof *mode);
|
|
|
|
|
|
if (!mode)
|
|
if (!mode)
|
|
return;
|
|
return;
|
|
|
|
|
|
mode->mode = m;
|
|
mode->mode = m;
|
|
- wl_list_insert(&d->modes_list, &mode->link);
|
|
|
|
|
|
+ WAYLAND_wl_list_insert(&d->modes_list, &mode->link);
|
|
}
|
|
}
|
|
|
|
|
|
static void
|
|
static void
|
|
@@ -227,7 +238,7 @@ display_handle_global(void *data, struct wl_registry *registry, uint32_t id,
|
|
const char *interface, uint32_t version)
|
|
const char *interface, uint32_t version)
|
|
{
|
|
{
|
|
SDL_VideoData *d = data;
|
|
SDL_VideoData *d = data;
|
|
-
|
|
|
|
|
|
+
|
|
if (strcmp(interface, "wl_compositor") == 0) {
|
|
if (strcmp(interface, "wl_compositor") == 0) {
|
|
d->compositor = wl_registry_bind(d->registry, id, &wl_compositor_interface, 1);
|
|
d->compositor = wl_registry_bind(d->registry, id, &wl_compositor_interface, 1);
|
|
} else if (strcmp(interface, "wl_output") == 0) {
|
|
} else if (strcmp(interface, "wl_output") == 0) {
|
|
@@ -239,8 +250,8 @@ display_handle_global(void *data, struct wl_registry *registry, uint32_t id,
|
|
d->shell = wl_registry_bind(d->registry, id, &wl_shell_interface, 1);
|
|
d->shell = wl_registry_bind(d->registry, id, &wl_shell_interface, 1);
|
|
} else if (strcmp(interface, "wl_shm") == 0) {
|
|
} else if (strcmp(interface, "wl_shm") == 0) {
|
|
d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
|
|
d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
|
|
- d->cursor_theme = wl_cursor_theme_load(NULL, 32, d->shm);
|
|
|
|
- d->default_cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "left_ptr");
|
|
|
|
|
|
+ d->cursor_theme = WAYLAND_wl_cursor_theme_load(NULL, 32, d->shm);
|
|
|
|
+ d->default_cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "left_ptr");
|
|
wl_shm_add_listener(d->shm, &shm_listener, d);
|
|
wl_shm_add_listener(d->shm, &shm_listener, d);
|
|
|
|
|
|
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
|
|
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
|
|
@@ -265,7 +276,10 @@ int
|
|
Wayland_VideoInit(_THIS)
|
|
Wayland_VideoInit(_THIS)
|
|
{
|
|
{
|
|
SDL_VideoData *data;
|
|
SDL_VideoData *data;
|
|
-
|
|
|
|
|
|
+ SDL_VideoDisplay display;
|
|
|
|
+ SDL_DisplayMode mode;
|
|
|
|
+ int i;
|
|
|
|
+
|
|
data = malloc(sizeof *data);
|
|
data = malloc(sizeof *data);
|
|
if (data == NULL)
|
|
if (data == NULL)
|
|
return 0;
|
|
return 0;
|
|
@@ -273,29 +287,41 @@ Wayland_VideoInit(_THIS)
|
|
|
|
|
|
_this->driverdata = data;
|
|
_this->driverdata = data;
|
|
|
|
|
|
- wl_list_init(&data->modes_list);
|
|
|
|
|
|
+ WAYLAND_wl_list_init(&data->modes_list);
|
|
|
|
|
|
- data->display = wl_display_connect(NULL);
|
|
|
|
|
|
+ data->display = WAYLAND_wl_display_connect(NULL);
|
|
if (data->display == NULL) {
|
|
if (data->display == NULL) {
|
|
SDL_SetError("Failed to connect to a Wayland display");
|
|
SDL_SetError("Failed to connect to a Wayland display");
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
data->registry = wl_display_get_registry(data->display);
|
|
data->registry = wl_display_get_registry(data->display);
|
|
|
|
+
|
|
|
|
+ if ( data->registry == NULL) {
|
|
|
|
+ SDL_SetError("Failed to get the Wayland registry");
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
wl_registry_add_listener(data->registry, ®istry_listener, data);
|
|
wl_registry_add_listener(data->registry, ®istry_listener, data);
|
|
|
|
|
|
- while (data->screen_allocation.width == 0)
|
|
|
|
- wl_display_dispatch(data->display);
|
|
|
|
|
|
+ for (i=0; i < 100; i++) {
|
|
|
|
+ if (data->screen_allocation.width != 0 || WAYLAND_wl_display_get_error(data->display) != 0) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ WAYLAND_wl_display_dispatch(data->display);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (data->screen_allocation.width == 0) {
|
|
|
|
+ SDL_SetError("Failed while waiting for screen allocation: %d ", WAYLAND_wl_display_get_error(data->display));
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
|
|
- data->xkb_context = xkb_context_new(0);
|
|
|
|
|
|
+ data->xkb_context = WAYLAND_xkb_context_new(0);
|
|
if (!data->xkb_context) {
|
|
if (!data->xkb_context) {
|
|
SDL_SetError("Failed to create XKB context");
|
|
SDL_SetError("Failed to create XKB context");
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
- SDL_VideoDisplay display;
|
|
|
|
- SDL_DisplayMode mode;
|
|
|
|
-
|
|
|
|
/* Use a fake 32-bpp desktop mode */
|
|
/* Use a fake 32-bpp desktop mode */
|
|
mode.format = SDL_PIXELFORMAT_RGB888;
|
|
mode.format = SDL_PIXELFORMAT_RGB888;
|
|
mode.w = data->screen_allocation.width;
|
|
mode.w = data->screen_allocation.width;
|
|
@@ -311,7 +337,7 @@ Wayland_VideoInit(_THIS)
|
|
|
|
|
|
Wayland_InitMouse ();
|
|
Wayland_InitMouse ();
|
|
|
|
|
|
- wayland_schedule_write(data);
|
|
|
|
|
|
+ WAYLAND_wl_display_flush(data->display);
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -363,7 +389,7 @@ Wayland_VideoQuit(_THIS)
|
|
Wayland_display_destroy_input(data);
|
|
Wayland_display_destroy_input(data);
|
|
|
|
|
|
if (data->xkb_context) {
|
|
if (data->xkb_context) {
|
|
- xkb_context_unref(data->xkb_context);
|
|
|
|
|
|
+ WAYLAND_xkb_context_unref(data->xkb_context);
|
|
data->xkb_context = NULL;
|
|
data->xkb_context = NULL;
|
|
}
|
|
}
|
|
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
|
|
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
|
|
@@ -380,7 +406,7 @@ Wayland_VideoQuit(_THIS)
|
|
wl_shm_destroy(data->shm);
|
|
wl_shm_destroy(data->shm);
|
|
|
|
|
|
if (data->cursor_theme)
|
|
if (data->cursor_theme)
|
|
- wl_cursor_theme_destroy(data->cursor_theme);
|
|
|
|
|
|
+ WAYLAND_wl_cursor_theme_destroy(data->cursor_theme);
|
|
|
|
|
|
if (data->shell)
|
|
if (data->shell)
|
|
wl_shell_destroy(data->shell);
|
|
wl_shell_destroy(data->shell);
|
|
@@ -389,12 +415,12 @@ Wayland_VideoQuit(_THIS)
|
|
wl_compositor_destroy(data->compositor);
|
|
wl_compositor_destroy(data->compositor);
|
|
|
|
|
|
if (data->display) {
|
|
if (data->display) {
|
|
- wl_display_flush(data->display);
|
|
|
|
- wl_display_disconnect(data->display);
|
|
|
|
|
|
+ WAYLAND_wl_display_flush(data->display);
|
|
|
|
+ WAYLAND_wl_display_disconnect(data->display);
|
|
}
|
|
}
|
|
|
|
|
|
wl_list_for_each_safe(m, t, &data->modes_list, link) {
|
|
wl_list_for_each_safe(m, t, &data->modes_list, link) {
|
|
- wl_list_remove(&m->link);
|
|
|
|
|
|
+ WAYLAND_wl_list_remove(&m->link);
|
|
free(m);
|
|
free(m);
|
|
}
|
|
}
|
|
|
|
|