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>
53 #define WAYLANDVID_DRIVER_NAME "wayland"
57 Wayland_VideoInit(
_THIS);
65 Wayland_VideoQuit(
_THIS);
79 #if defined(__LINUX__) || defined(__FREEBSD__)
86 spot =
SDL_getenv(
"SDL_VIDEO_WAYLAND_WMCLASS");
98 #if defined(__LINUX__) || defined(__FREEBSD__)
99 #if defined(__LINUX__)
101 #elif defined(__FREEBSD__)
105 #error Where can we find the executable name?
107 linksize = readlink(procfile, linkfile,
sizeof(linkfile) - 1);
109 linkfile[linksize] =
'\0';
128 WAYLAND_wl_display_flush(
data->display);
129 WAYLAND_wl_display_disconnect(
data->display);
137 Wayland_CreateDevice(
int devindex)
141 struct wl_display *display;
147 display = WAYLAND_wl_display_connect(
NULL);
148 if (display ==
NULL) {
155 WAYLAND_wl_display_disconnect(display);
161 data->display = display;
167 WAYLAND_wl_display_disconnect(display);
176 device->VideoInit = Wayland_VideoInit;
177 device->VideoQuit = Wayland_VideoQuit;
178 device->SetDisplayMode = Wayland_SetDisplayMode;
179 device->GetDisplayModes = Wayland_GetDisplayModes;
212 device->Vulkan_LoadLibrary = Wayland_Vulkan_LoadLibrary;
213 device->Vulkan_UnloadLibrary = Wayland_Vulkan_UnloadLibrary;
214 device->Vulkan_GetInstanceExtensions = Wayland_Vulkan_GetInstanceExtensions;
215 device->Vulkan_CreateSurface = Wayland_Vulkan_CreateSurface;
216 device->Vulkan_GetDrawableSize = Wayland_Vulkan_GetDrawableSize;
219 device->free = Wayland_DeleteDevice;
225 WAYLANDVID_DRIVER_NAME,
"SDL Wayland video driver",
230 display_handle_geometry(
void *
data,
247 display_handle_mode(
void *
data,
261 mode.refresh_rate = refresh / 1000;
272 display_handle_done(
void *
data,
284 display_handle_scale(
void *
data,
293 display_handle_geometry,
319 data->scale_factor = 1.0;
325 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
327 windowmanager_hints(
void *
data,
struct qt_windowmanager *qt_windowmanager,
333 windowmanager_quit(
void *
data,
struct qt_windowmanager *qt_windowmanager)
338 static const struct qt_windowmanager_listener windowmanager_listener = {
346 handle_ping_zxdg_shell(
void *
data,
struct zxdg_shell_v6 *zxdg,
uint32_t serial)
352 handle_ping_zxdg_shell
357 handle_ping_xdg_wm_base(
void *
data,
struct xdg_wm_base *xdg,
uint32_t serial)
363 handle_ping_xdg_wm_base
368 display_handle_global(
void *
data,
struct wl_registry *registry,
uint32_t id,
369 const char *interface,
uint32_t version)
375 if (strcmp(interface,
"wl_compositor") == 0) {
377 }
else if (strcmp(interface,
"wl_output") == 0) {
378 Wayland_add_display(
d,
id);
379 }
else if (strcmp(interface,
"wl_seat") == 0) {
381 }
else if (strcmp(interface,
"xdg_wm_base") == 0) {
384 }
else if (strcmp(interface,
"zxdg_shell_v6") == 0) {
387 }
else if (strcmp(interface,
"wl_shell") == 0) {
389 }
else if (strcmp(interface,
"wl_shm") == 0) {
391 d->cursor_theme = WAYLAND_wl_cursor_theme_load(
NULL, 32,
d->shm);
392 }
else if (strcmp(interface,
"zwp_relative_pointer_manager_v1") == 0) {
394 }
else if (strcmp(interface,
"zwp_pointer_constraints_v1") == 0) {
396 }
else if (strcmp(interface,
"wl_data_device_manager") == 0) {
398 }
else if (strcmp(interface,
"zxdg_decoration_manager_v1") == 0) {
400 }
else if (strcmp(interface,
"org_kde_kwin_server_decoration_manager") == 0) {
403 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
404 }
else if (strcmp(interface,
"qt_touch_extension") == 0) {
405 Wayland_touch_create(
d,
id);
406 }
else if (strcmp(interface,
"qt_surface_extension") == 0) {
408 &qt_surface_extension_interface, 1);
409 }
else if (strcmp(interface,
"qt_windowmanager") == 0) {
411 &qt_windowmanager_interface, 1);
412 qt_windowmanager_add_listener(
d->windowmanager, &windowmanager_listener,
d);
418 display_remove_global(
void *
data,
struct wl_registry *registry,
uint32_t id) {}
421 display_handle_global,
422 display_remove_global
426 Wayland_VideoInit(
_THIS)
430 data->xkb_context = WAYLAND_xkb_context_new(0);
431 if (!
data->xkb_context) {
437 return SDL_SetError(
"Failed to get the Wayland registry");
443 WAYLAND_wl_display_roundtrip(
data->display);
446 WAYLAND_wl_display_roundtrip(
data->display);
451 data->classname = get_classname();
453 WAYLAND_wl_display_flush(
data->display);
472 Wayland_VideoQuit(
_THIS)
477 Wayland_FiniMouse ();
496 if (
data->xkb_context) {
497 WAYLAND_xkb_context_unref(
data->xkb_context);
500 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
501 if (
data->windowmanager)
502 qt_windowmanager_destroy(
data->windowmanager);
504 if (
data->surface_extension)
505 qt_surface_extension_destroy(
data->surface_extension);
507 Wayland_touch_destroy(
data);
513 if (
data->cursor_theme)
514 WAYLAND_wl_cursor_theme_destroy(
data->cursor_theme);
522 if (
data->shell.zxdg)
525 if (
data->compositor)
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
#define SDL_OutOfMemory()
#define SDL_Unsupported()
GLint GLint GLint GLint GLint GLint y
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLint GLint GLsizei width
GLint GLint GLint GLint GLint x
GLint GLint GLsizei GLsizei height
GLuint GLenum GLenum transform
#define SDL_arraysize(array)
VideoBootStrap Wayland_bootstrap
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display, SDL_bool send_event)
SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
static SDL_VideoDevice * _this
char * Wayland_GetClipboardText(_THIS)
SDL_bool Wayland_HasClipboardText(_THIS)
int Wayland_SetClipboardText(_THIS, const char *text)
int SDL_WAYLAND_LoadSymbols(void)
void SDL_WAYLAND_UnloadSymbols(void)
void Wayland_display_destroy_input(SDL_VideoData *d)
void Wayland_display_add_input(SDL_VideoData *d, uint32_t id, uint32_t version)
void Wayland_display_destroy_relative_pointer_manager(SDL_VideoData *d)
void Wayland_display_destroy_pointer_constraints(SDL_VideoData *d)
void Wayland_display_add_pointer_constraints(SDL_VideoData *d, uint32_t id)
void Wayland_display_add_relative_pointer_manager(SDL_VideoData *d, uint32_t id)
void Wayland_PumpEvents(_THIS)
#define Wayland_GLES_UnloadLibrary
int Wayland_GLES_SwapWindow(_THIS, SDL_Window *window)
int Wayland_GLES_LoadLibrary(_THIS, const char *path)
int Wayland_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
SDL_GLContext Wayland_GLES_CreateContext(_THIS, SDL_Window *window)
#define Wayland_GLES_SetSwapInterval
void Wayland_GLES_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h)
#define Wayland_GLES_GetSwapInterval
#define Wayland_GLES_GetProcAddress
void Wayland_GLES_DeleteContext(_THIS, SDL_GLContext context)
void Wayland_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *_display, SDL_bool fullscreen)
SDL_bool Wayland_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
void Wayland_RestoreWindow(_THIS, SDL_Window *window)
void Wayland_SetWindowTitle(_THIS, SDL_Window *window)
int Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
void Wayland_ShowWindow(_THIS, SDL_Window *window)
int Wayland_CreateWindow(_THIS, SDL_Window *window)
void Wayland_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
void Wayland_SetWindowSize(_THIS, SDL_Window *window)
void Wayland_DestroyWindow(_THIS, SDL_Window *window)
void Wayland_MaximizeWindow(_THIS, SDL_Window *window)
void Wayland_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered)
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)
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)
static void wl_compositor_destroy(struct wl_compositor *wl_compositor)
static struct wl_registry * wl_display_get_registry(struct wl_display *wl_display)
static void wl_output_set_user_data(struct wl_output *wl_output, void *user_data)
static void wl_output_destroy(struct wl_output *wl_output)
static int wl_output_add_listener(struct wl_output *wl_output, const struct wl_output_listener *listener, void *data)
static void wl_registry_destroy(struct wl_registry *wl_registry)
static int wl_registry_add_listener(struct wl_registry *wl_registry, const struct wl_registry_listener *listener, void *data)
static void * wl_registry_bind(struct wl_registry *wl_registry, uint32_t name, const struct wl_interface *interface, uint32_t version)
static void wl_shell_destroy(struct wl_shell *wl_shell)
static void wl_shm_destroy(struct wl_shm *wl_shm)
static void xdg_wm_base_destroy(struct xdg_wm_base *xdg_wm_base)
static int xdg_wm_base_add_listener(struct xdg_wm_base *xdg_wm_base, const struct xdg_wm_base_listener *listener, void *data)
static void xdg_wm_base_pong(struct xdg_wm_base *xdg_wm_base, uint32_t serial)
static void zxdg_shell_v6_destroy(struct zxdg_shell_v6 *zxdg_shell_v6)
static int zxdg_shell_v6_add_listener(struct zxdg_shell_v6 *zxdg_shell_v6, const struct zxdg_shell_v6_listener *listener, void *data)
static void zxdg_shell_v6_pong(struct zxdg_shell_v6 *zxdg_shell_v6, uint32_t serial)
static SDL_AudioDeviceID device
const struct wl_interface org_kde_kwin_server_decoration_manager_interface
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
The structure that defines a display mode.
SDL_VideoDisplay * displays
SDL_DisplayMode desktop_mode
SDL_DisplayMode * display_modes
SDL_DisplayMode current_mode
const struct wl_interface wl_shm_interface
const struct wl_interface wl_output_interface
const struct wl_interface wl_shell_interface
const struct wl_interface wl_compositor_interface
const struct wl_interface wl_data_device_manager_interface
const struct wl_interface zxdg_decoration_manager_v1_interface
const struct wl_interface xdg_wm_base_interface
const struct wl_interface zxdg_shell_v6_interface