Go to the documentation of this file.
22 #include "../../SDL_internal.h"
24 #if SDL_VIDEO_DRIVER_WAYLAND
29 #include "../../events/SDL_events_c.h"
40 #include <sys/types.h>
43 #include <xkbcommon/xkbcommon.h>
46 #include <wayland-util.h>
51 #define WAYLANDVID_DRIVER_NAME "wayland"
55 Wayland_VideoInit(
_THIS);
63 Wayland_VideoQuit(
_THIS);
77 #if defined(__LINUX__) || defined(__FREEBSD__)
84 spot =
SDL_getenv(
"SDL_VIDEO_WAYLAND_WMCLASS");
96 #if defined(__LINUX__) || defined(__FREEBSD__)
97 #if defined(__LINUX__)
99 #elif defined(__FREEBSD__)
103 #error Where can we find the executable name?
105 linksize = readlink(procfile, linkfile,
sizeof(linkfile) - 1);
107 linkfile[linksize] =
'\0';
123 Wayland_Available(
void)
125 struct wl_display *display =
NULL;
127 display = WAYLAND_wl_display_connect(
NULL);
128 if (display !=
NULL) {
129 WAYLAND_wl_display_disconnect(display);
134 return (display !=
NULL);
145 Wayland_CreateDevice(
int devindex)
162 device->VideoInit = Wayland_VideoInit;
163 device->VideoQuit = Wayland_VideoQuit;
164 device->SetDisplayMode = Wayland_SetDisplayMode;
165 device->GetDisplayModes = Wayland_GetDisplayModes;
195 device->Vulkan_LoadLibrary = Wayland_Vulkan_LoadLibrary;
196 device->Vulkan_UnloadLibrary = Wayland_Vulkan_UnloadLibrary;
197 device->Vulkan_GetInstanceExtensions = Wayland_Vulkan_GetInstanceExtensions;
198 device->Vulkan_CreateSurface = Wayland_Vulkan_CreateSurface;
201 device->free = Wayland_DeleteDevice;
207 WAYLANDVID_DRIVER_NAME,
"SDL Wayland video driver",
208 Wayland_Available, Wayland_CreateDevice
212 display_handle_geometry(
void *
data,
230 display_handle_mode(
void *
data,
244 mode.refresh_rate = refresh / 1000;
255 display_handle_done(
void *
data,
265 display_handle_scale(
void *
data,
273 display_handle_geometry,
300 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
302 windowmanager_hints(
void *
data,
struct qt_windowmanager *qt_windowmanager,
308 windowmanager_quit(
void *
data,
struct qt_windowmanager *qt_windowmanager)
313 static const struct qt_windowmanager_listener windowmanager_listener = {
321 handle_ping_zxdg_shell(
void *
data,
struct zxdg_shell_v6 *zxdg,
uint32_t serial)
327 handle_ping_zxdg_shell
332 handle_ping_xdg_wm_base(
void *
data,
struct xdg_wm_base *xdg,
uint32_t serial)
338 handle_ping_xdg_wm_base
343 display_handle_global(
void *
data,
struct wl_registry *registry,
uint32_t id,
344 const char *interface,
uint32_t version)
348 if (strcmp(interface,
"wl_compositor") == 0) {
350 }
else if (strcmp(interface,
"wl_output") == 0) {
351 Wayland_add_display(
d,
id);
352 }
else if (strcmp(interface,
"wl_seat") == 0) {
354 }
else if (strcmp(interface,
"xdg_wm_base") == 0) {
357 }
else if (strcmp(interface,
"zxdg_shell_v6") == 0) {
360 }
else if (strcmp(interface,
"wl_shell") == 0) {
362 }
else if (strcmp(interface,
"wl_shm") == 0) {
364 d->cursor_theme = WAYLAND_wl_cursor_theme_load(
NULL, 32,
d->shm);
365 }
else if (strcmp(interface,
"zwp_relative_pointer_manager_v1") == 0) {
367 }
else if (strcmp(interface,
"zwp_pointer_constraints_v1") == 0) {
369 }
else if (strcmp(interface,
"wl_data_device_manager") == 0) {
372 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
373 }
else if (strcmp(interface,
"qt_touch_extension") == 0) {
374 Wayland_touch_create(
d,
id);
375 }
else if (strcmp(interface,
"qt_surface_extension") == 0) {
377 &qt_surface_extension_interface, 1);
378 }
else if (strcmp(interface,
"qt_windowmanager") == 0) {
380 &qt_windowmanager_interface, 1);
381 qt_windowmanager_add_listener(
d->windowmanager, &windowmanager_listener,
d);
387 display_handle_global,
392 Wayland_VideoInit(
_THIS)
401 data->xkb_context = WAYLAND_xkb_context_new(0);
402 if (!
data->xkb_context) {
406 data->display = WAYLAND_wl_display_connect(
NULL);
408 return SDL_SetError(
"Failed to connect to a Wayland display");
413 return SDL_SetError(
"Failed to get the Wayland registry");
419 WAYLAND_wl_display_roundtrip(
data->display);
422 WAYLAND_wl_display_roundtrip(
data->display);
427 data->classname = get_classname();
429 WAYLAND_wl_display_flush(
data->display);
448 Wayland_VideoQuit(
_THIS)
453 Wayland_FiniMouse ();
470 if (
data->xkb_context) {
471 WAYLAND_xkb_context_unref(
data->xkb_context);
474 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
475 if (
data->windowmanager)
476 qt_windowmanager_destroy(
data->windowmanager);
478 if (
data->surface_extension)
479 qt_surface_extension_destroy(
data->surface_extension);
481 Wayland_touch_destroy(
data);
487 if (
data->cursor_theme)
488 WAYLAND_wl_cursor_theme_destroy(
data->cursor_theme);
496 if (
data->shell.zxdg)
499 if (
data->compositor)
506 WAYLAND_wl_display_flush(
data->display);
507 WAYLAND_wl_display_disconnect(
data->display);
#define Wayland_GLES_SetSwapInterval
void SDL_WAYLAND_UnloadSymbols(void)
static void zxdg_shell_v6_destroy(struct zxdg_shell_v6 *zxdg_shell_v6)
static struct wl_registry * wl_display_get_registry(struct wl_display *wl_display)
static int zxdg_shell_v6_add_listener(struct zxdg_shell_v6 *zxdg_shell_v6, const struct zxdg_shell_v6_listener *listener, void *data)
SDL_DisplayMode * display_modes
static int wl_output_add_listener(struct wl_output *wl_output, const struct wl_output_listener *listener, void *data)
SDL_bool Wayland_HasClipboardText(_THIS)
int Wayland_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
static void wl_output_destroy(struct wl_output *wl_output)
int Wayland_GLES_LoadLibrary(_THIS, const char *path)
GLint GLint GLsizei width
static void wl_compositor_destroy(struct wl_compositor *wl_compositor)
static void xdg_wm_base_pong(struct xdg_wm_base *xdg_wm_base, uint32_t serial)
SDL_GLContext Wayland_GLES_CreateContext(_THIS, SDL_Window *window)
const struct wl_interface xdg_wm_base_interface
void Wayland_display_add_input(SDL_VideoData *d, uint32_t id)
void Wayland_MaximizeWindow(_THIS, SDL_Window *window)
int Wayland_GLES_SwapWindow(_THIS, SDL_Window *window)
SDL_DisplayMode desktop_mode
void Wayland_PumpEvents(_THIS)
void Wayland_display_destroy_input(SDL_VideoData *d)
static void wl_shell_destroy(struct wl_shell *wl_shell)
const struct wl_interface wl_compositor_interface
static void zxdg_shell_v6_pong(struct zxdg_shell_v6 *zxdg_shell_v6, uint32_t serial)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
The structure that defines a display mode.
SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
#define Wayland_GLES_GetSwapInterval
const struct wl_interface wl_data_device_manager_interface
void Wayland_GLES_DeleteContext(_THIS, SDL_GLContext context)
static void * wl_registry_bind(struct wl_registry *wl_registry, uint32_t name, const struct wl_interface *interface, uint32_t version)
void Wayland_ShowWindow(_THIS, SDL_Window *window)
static int xdg_wm_base_add_listener(struct xdg_wm_base *xdg_wm_base, const struct xdg_wm_base_listener *listener, void *data)
void Wayland_SetWindowTitle(_THIS, SDL_Window *window)
static SDL_VideoDevice * _this
GLint GLint GLint GLint GLint x
const struct wl_interface wl_shell_interface
void Wayland_display_destroy_pointer_constraints(SDL_VideoData *d)
GLint GLint GLsizei GLsizei height
const struct wl_interface wl_shm_interface
static void xdg_wm_base_destroy(struct xdg_wm_base *xdg_wm_base)
SDL_VideoDisplay * displays
void Wayland_RestoreWindow(_THIS, SDL_Window *window)
const struct wl_interface zxdg_shell_v6_interface
const struct wl_interface wl_output_interface
static void wl_shm_destroy(struct wl_shm *wl_shm)
#define Wayland_GLES_GetProcAddress
SDL_bool Wayland_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display)
void Wayland_DestroyWindow(_THIS, SDL_Window *window)
VideoBootStrap Wayland_bootstrap
void Wayland_display_destroy_relative_pointer_manager(SDL_VideoData *d)
void Wayland_display_add_pointer_constraints(SDL_VideoData *d, uint32_t id)
int Wayland_SetClipboardText(_THIS, const char *text)
#define SDL_OutOfMemory()
GLint GLint GLint GLint GLint GLint y
int SDL_WAYLAND_LoadSymbols(void)
#define SDL_arraysize(array)
GLuint GLenum GLenum transform
char * Wayland_GetClipboardText(_THIS)
void Wayland_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *_display, SDL_bool fullscreen)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)
int Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
void Wayland_display_add_relative_pointer_manager(SDL_VideoData *d, uint32_t id)
#define Wayland_GLES_UnloadLibrary
#define SDL_Unsupported()
SDL_DisplayMode current_mode
static int wl_registry_add_listener(struct wl_registry *wl_registry, const struct wl_registry_listener *listener, void *data)
static SDL_AudioDeviceID device
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
static void wl_registry_destroy(struct wl_registry *wl_registry)
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
int Wayland_CreateWindow(_THIS, SDL_Window *window)
void Wayland_SetWindowSize(_THIS, SDL_Window *window)