22 #include "../../SDL_internal.h" 24 #if SDL_VIDEO_DRIVER_WAYLAND 29 #include "../../events/SDL_events_c.h" 39 #include <xkbcommon/xkbcommon.h> 42 #include <wayland-util.h> 44 #define WAYLANDVID_DRIVER_NAME "wayland" 48 Wayland_VideoInit(
_THIS);
56 Wayland_VideoQuit(
_THIS);
60 Wayland_Available(
void)
62 struct wl_display *display =
NULL;
64 display = WAYLAND_wl_display_connect(
NULL);
65 if (display !=
NULL) {
66 WAYLAND_wl_display_disconnect(display);
71 return (display !=
NULL);
82 Wayland_CreateDevice(
int devindex)
124 device->
free = Wayland_DeleteDevice;
130 WAYLANDVID_DRIVER_NAME,
"SDL Wayland video driver",
131 Wayland_Available, Wayland_CreateDevice
135 display_handle_geometry(
void *
data,
148 display->
name = strdup(model);
153 display_handle_mode(
void *
data,
169 if (flags & WL_OUTPUT_MODE_CURRENT) {
176 display_handle_done(
void *data,
177 struct wl_output *output)
186 display_handle_scale(
void *data,
187 struct wl_output *output,
193 static const struct wl_output_listener output_listener = {
194 display_handle_geometry,
211 output = wl_registry_bind(d->
registry,
id, &wl_output_interface, 2);
217 wl_output_add_listener(output, &output_listener, display);
220 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 222 windowmanager_hints(
void *data,
struct qt_windowmanager *qt_windowmanager,
228 windowmanager_quit(
void *data,
struct qt_windowmanager *qt_windowmanager)
233 static const struct qt_windowmanager_listener windowmanager_listener = {
240 display_handle_global(
void *data,
struct wl_registry *registry,
uint32_t id,
241 const char *interface,
uint32_t version)
245 if (strcmp(interface,
"wl_compositor") == 0) {
247 }
else if (strcmp(interface,
"wl_output") == 0) {
248 Wayland_add_display(d,
id);
249 }
else if (strcmp(interface,
"wl_seat") == 0) {
251 }
else if (strcmp(interface,
"wl_shell") == 0) {
252 d->
shell = wl_registry_bind(d->
registry,
id, &wl_shell_interface, 1);
253 }
else if (strcmp(interface,
"wl_shm") == 0) {
254 d->
shm = wl_registry_bind(registry,
id, &wl_shm_interface, 1);
258 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 259 }
else if (strcmp(interface,
"qt_touch_extension") == 0) {
260 Wayland_touch_create(d,
id);
261 }
else if (strcmp(interface,
"qt_surface_extension") == 0) {
262 d->surface_extension = wl_registry_bind(registry,
id,
263 &qt_surface_extension_interface, 1);
264 }
else if (strcmp(interface,
"qt_windowmanager") == 0) {
265 d->windowmanager = wl_registry_bind(registry,
id,
266 &qt_windowmanager_interface, 1);
267 qt_windowmanager_add_listener(d->windowmanager, &windowmanager_listener, d);
272 static const struct wl_registry_listener registry_listener = {
273 display_handle_global
277 Wayland_VideoInit(
_THIS)
282 memset(data, 0,
sizeof *data);
288 return SDL_SetError(
"Failed to connect to a Wayland display");
293 return SDL_SetError(
"Failed to get the Wayland registry");
296 wl_registry_add_listener(data->
registry, ®istry_listener, data);
299 WAYLAND_wl_display_roundtrip(data->
display);
302 WAYLAND_wl_display_roundtrip(data->
display);
311 WAYLAND_wl_display_flush(data->
display);
330 Wayland_VideoQuit(
_THIS)
335 Wayland_FiniMouse ();
349 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 350 if (data->windowmanager)
351 qt_windowmanager_destroy(data->windowmanager);
353 if (data->surface_extension)
354 qt_surface_extension_destroy(data->surface_extension);
356 Wayland_touch_destroy(data);
360 wl_shm_destroy(data->
shm);
366 wl_shell_destroy(data->
shell);
372 wl_registry_destroy(data->
registry);
375 WAYLAND_wl_display_flush(data->
display);
376 WAYLAND_wl_display_disconnect(data->
display);
void Wayland_SetWindowSize(_THIS, SDL_Window *window)
void Wayland_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *_display, SDL_bool fullscreen)
void SDL_WAYLAND_UnloadSymbols(void)
int(* SetWindowHitTest)(SDL_Window *window, SDL_bool enabled)
int Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
struct wl_display * display
void Wayland_GLES_DeleteContext(_THIS, SDL_GLContext context)
#define Wayland_GLES_UnloadLibrary
int(* GL_SetSwapInterval)(_THIS, int interval)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
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 GLint GLsizei width
#define Wayland_GLES_GetSwapInterval
struct wl_cursor_theme * cursor_theme
void(* GL_SwapWindow)(_THIS, SDL_Window *window)
GLint GLint GLint GLint GLint x
int Wayland_CreateWindow(_THIS, SDL_Window *window)
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display)
int(* GL_LoadLibrary)(_THIS, const char *path)
int(* SetDisplayMode)(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
SDL_GLContext Wayland_GLES_CreateContext(_THIS, SDL_Window *window)
static SDL_VideoDevice * _this
void * SDL_calloc(size_t nmemb, size_t size)
#define Wayland_GLES_SetSwapInterval
GLint GLint GLsizei GLsizei height
SDL_bool(* GetWindowWMInfo)(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
SDL_GLContext(* GL_CreateContext)(_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
int(* GL_MakeCurrent)(_THIS, SDL_Window *window, SDL_GLContext context)
struct xkb_context * xkb_context
int SDL_WAYLAND_LoadSymbols(void)
SDL_bool Wayland_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
SDL_DisplayMode current_mode
SDL_VideoDisplay * displays
void(* DestroyWindow)(_THIS, SDL_Window *window)
int Wayland_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
void Wayland_display_add_input(SDL_VideoData *d, uint32_t id)
void(* GL_UnloadLibrary)(_THIS)
struct wl_cursor * default_cursor
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)
#define Wayland_GLES_GetProcAddress
#define SDL_OutOfMemory()
SDL_DisplayMode desktop_mode
struct wl_compositor * compositor
GLint GLint GLint GLint GLint GLint y
void Wayland_display_destroy_input(SDL_VideoData *d)
void Wayland_PumpEvents(_THIS)
int(* CreateWindow)(_THIS, SDL_Window *window)
GLuint GLenum GLenum transform
struct wl_registry * registry
SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
void(* SetWindowFullscreen)(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
void(* GL_DeleteContext)(_THIS, SDL_GLContext context)
int(* GL_GetSwapInterval)(_THIS)
int Wayland_GLES_LoadLibrary(_THIS, const char *path)
void Wayland_GLES_SwapWindow(_THIS, SDL_Window *window)
#define SDL_Unsupported()
void *(* GL_GetProcAddress)(_THIS, const char *proc)
void(* PumpEvents)(_THIS)