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> 50 #define WAYLANDVID_DRIVER_NAME "wayland" 54 Wayland_VideoInit(
_THIS);
62 Wayland_VideoQuit(
_THIS);
76 #if defined(__LINUX__) || defined(__FREEBSD__) 83 spot =
SDL_getenv(
"SDL_VIDEO_WAYLAND_WMCLASS");
95 #if defined(__LINUX__) || defined(__FREEBSD__) 96 #if defined(__LINUX__) 98 #elif defined(__FREEBSD__) 102 #error Where can we find the executable name? 104 linksize = readlink(procfile, linkfile,
sizeof(linkfile) - 1);
106 linkfile[linksize] =
'\0';
122 Wayland_Available(
void)
124 struct wl_display *display =
NULL;
126 display = WAYLAND_wl_display_connect(
NULL);
127 if (display !=
NULL) {
128 WAYLAND_wl_display_disconnect(display);
133 return (display !=
NULL);
144 Wayland_CreateDevice(
int devindex)
200 device->
free = Wayland_DeleteDevice;
206 WAYLANDVID_DRIVER_NAME,
"SDL Wayland video driver",
207 Wayland_Available, Wayland_CreateDevice
211 display_handle_geometry(
void *
data,
229 display_handle_mode(
void *
data,
254 display_handle_done(
void *data,
255 struct wl_output *output)
264 display_handle_scale(
void *data,
265 struct wl_output *output,
272 display_handle_geometry,
299 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 301 windowmanager_hints(
void *data,
struct qt_windowmanager *qt_windowmanager,
307 windowmanager_quit(
void *data,
struct qt_windowmanager *qt_windowmanager)
312 static const struct qt_windowmanager_listener windowmanager_listener = {
320 handle_ping_zxdg_shell(
void *data,
struct zxdg_shell_v6 *zxdg,
uint32_t serial)
326 handle_ping_zxdg_shell
331 display_handle_global(
void *data,
struct wl_registry *registry,
uint32_t id,
332 const char *interface,
uint32_t version)
336 if (strcmp(interface,
"wl_compositor") == 0) {
338 }
else if (strcmp(interface,
"wl_output") == 0) {
339 Wayland_add_display(d,
id);
340 }
else if (strcmp(interface,
"wl_seat") == 0) {
342 }
else if (strcmp(interface,
"zxdg_shell_v6") == 0) {
345 }
else if (strcmp(interface,
"wl_shell") == 0) {
347 }
else if (strcmp(interface,
"wl_shm") == 0) {
350 }
else if (strcmp(interface,
"zwp_relative_pointer_manager_v1") == 0) {
352 }
else if (strcmp(interface,
"zwp_pointer_constraints_v1") == 0) {
354 }
else if (strcmp(interface,
"wl_data_device_manager") == 0) {
357 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 358 }
else if (strcmp(interface,
"qt_touch_extension") == 0) {
359 Wayland_touch_create(d,
id);
360 }
else if (strcmp(interface,
"qt_surface_extension") == 0) {
362 &qt_surface_extension_interface, 1);
363 }
else if (strcmp(interface,
"qt_windowmanager") == 0) {
365 &qt_windowmanager_interface, 1);
366 qt_windowmanager_add_listener(d->windowmanager, &windowmanager_listener, d);
372 display_handle_global,
377 Wayland_VideoInit(
_THIS)
382 memset(data, 0,
sizeof *data);
393 return SDL_SetError(
"Failed to connect to a Wayland display");
398 return SDL_SetError(
"Failed to get the Wayland registry");
404 WAYLAND_wl_display_roundtrip(data->
display);
407 WAYLAND_wl_display_roundtrip(data->
display);
414 WAYLAND_wl_display_flush(data->
display);
433 Wayland_VideoQuit(
_THIS)
438 Wayland_FiniMouse ();
459 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 460 if (data->windowmanager)
461 qt_windowmanager_destroy(data->windowmanager);
463 if (data->surface_extension)
464 qt_surface_extension_destroy(data->surface_extension);
466 Wayland_touch_destroy(data);
488 WAYLAND_wl_display_flush(data->
display);
489 WAYLAND_wl_display_disconnect(data->
display);
int(* Vulkan_LoadLibrary)(_THIS, const char *path)
static void wl_registry_destroy(struct wl_registry *wl_registry)
static struct wl_registry * wl_display_get_registry(struct wl_display *wl_display)
void Wayland_display_destroy_pointer_constraints(SDL_VideoData *d)
void Wayland_SetWindowSize(_THIS, SDL_Window *window)
void(* RestoreWindow)(_THIS, SDL_Window *window)
const struct wl_interface wl_shm_interface
void Wayland_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *_display, SDL_bool fullscreen)
void Wayland_display_destroy_relative_pointer_manager(SDL_VideoData *d)
void SDL_WAYLAND_UnloadSymbols(void)
char * Wayland_GetClipboardText(_THIS)
int(* SetWindowHitTest)(SDL_Window *window, SDL_bool enabled)
GLint GLint GLint GLint GLint x
int Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
struct wl_display * display
void Wayland_MaximizeWindow(_THIS, SDL_Window *window)
VideoBootStrap Wayland_bootstrap
void Wayland_GLES_DeleteContext(_THIS, SDL_GLContext context)
void Wayland_display_add_pointer_constraints(SDL_VideoData *d, uint32_t id)
int Wayland_SetClipboardText(_THIS, const char *text)
static void wl_shell_destroy(struct wl_shell *wl_shell)
#define Wayland_GLES_UnloadLibrary
static void * wl_registry_bind(struct wl_registry *wl_registry, uint32_t name, const struct wl_interface *interface, uint32_t version)
int(* GL_SetSwapInterval)(_THIS, int interval)
void(* ShowWindow)(_THIS, SDL_Window *window)
The structure that defines a display mode.
void Wayland_ShowWindow(_THIS, SDL_Window *window)
void(* SetWindowSize)(_THIS, SDL_Window *window)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
#define Wayland_GLES_GetSwapInterval
struct wl_cursor_theme * cursor_theme
int Wayland_CreateWindow(_THIS, SDL_Window *window)
const struct wl_interface wl_output_interface
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display)
int(* GL_LoadLibrary)(_THIS, const char *path)
static void wl_compositor_destroy(struct wl_compositor *wl_compositor)
GLint GLint GLsizei width
int(* SetDisplayMode)(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
SDL_GLContext Wayland_GLES_CreateContext(_THIS, SDL_Window *window)
void Wayland_display_add_relative_pointer_manager(SDL_VideoData *d, uint32_t id)
static SDL_VideoDevice * _this
static SDL_AudioDeviceID device
const struct wl_interface zxdg_shell_v6_interface
SDL_bool(* Vulkan_GetInstanceExtensions)(_THIS, SDL_Window *window, unsigned *count, const char **names)
struct SDL_VideoData::@36 shell
#define Wayland_GLES_SetSwapInterval
SDL_bool(* GetWindowWMInfo)(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
struct wl_data_device_manager * data_device_manager
void Wayland_SetWindowTitle(_THIS, SDL_Window *window)
void Wayland_DestroyWindow(_THIS, SDL_Window *window)
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
SDL_bool(* Vulkan_CreateSurface)(_THIS, SDL_Window *window, VkInstance instance, VkSurfaceKHR *surface)
int(* GL_MakeCurrent)(_THIS, SDL_Window *window, SDL_GLContext context)
void(* Vulkan_UnloadLibrary)(_THIS)
static void wl_shm_destroy(struct wl_shm *wl_shm)
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)
struct xkb_context * xkb_context
int SDL_WAYLAND_LoadSymbols(void)
SDL_bool Wayland_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
SDL_DisplayMode * display_modes
SDL_DisplayMode current_mode
SDL_VideoDisplay * displays
void(* DestroyWindow)(_THIS, SDL_Window *window)
GLint GLint GLint GLint GLint GLint y
int Wayland_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
static void zxdg_shell_v6_destroy(struct zxdg_shell_v6 *zxdg_shell_v6)
void Wayland_display_add_input(SDL_VideoData *d, uint32_t id)
void(* GL_UnloadLibrary)(_THIS)
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)
void(* GetDisplayModes)(_THIS, SDL_VideoDisplay *display)
int Wayland_GLES_SwapWindow(_THIS, SDL_Window *window)
#define Wayland_GLES_GetProcAddress
static int wl_output_add_listener(struct wl_output *wl_output, const struct wl_output_listener *listener, void *data)
static void wl_output_destroy(struct wl_output *wl_output)
int(* CreateSDLWindow)(_THIS, SDL_Window *window)
#define SDL_OutOfMemory()
SDL_DisplayMode desktop_mode
const struct wl_interface wl_compositor_interface
struct wl_compositor * compositor
GLint GLint GLsizei GLsizei height
void Wayland_RestoreWindow(_THIS, SDL_Window *window)
const struct wl_interface wl_shell_interface
void Wayland_display_destroy_input(SDL_VideoData *d)
void Wayland_PumpEvents(_THIS)
int(* GL_SwapWindow)(_THIS, SDL_Window *window)
GLuint GLenum GLenum transform
struct wl_registry * registry
SDL_bool Wayland_HasClipboardText(_THIS)
SDL_bool(* HasClipboardText)(_THIS)
SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
struct zxdg_shell_v6 * zxdg
#define SDL_arraysize(array)
void(* SetWindowFullscreen)(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
void(* GL_DeleteContext)(_THIS, SDL_GLContext context)
char *(* GetClipboardText)(_THIS)
void(* SetWindowTitle)(_THIS, SDL_Window *window)
const struct wl_interface wl_data_device_manager_interface
int(* GL_GetSwapInterval)(_THIS)
void(* MaximizeWindow)(_THIS, SDL_Window *window)
int(* SetClipboardText)(_THIS, const char *text)
int Wayland_GLES_LoadLibrary(_THIS, const char *path)
static void zxdg_shell_v6_pong(struct zxdg_shell_v6 *zxdg_shell_v6, uint32_t serial)
#define SDL_Unsupported()
void *(* GL_GetProcAddress)(_THIS, const char *proc)
static int wl_registry_add_listener(struct wl_registry *wl_registry, const struct wl_registry_listener *listener, void *data)
void(* PumpEvents)(_THIS)
static int zxdg_shell_v6_add_listener(struct zxdg_shell_v6 *zxdg_shell_v6, const struct zxdg_shell_v6_listener *listener, void *data)