Go to the documentation of this file.
22 #include "../../SDL_internal.h"
24 #if SDL_VIDEO_DRIVER_WAYLAND && SDL_VIDEO_OPENGL_EGL
26 #include "../SDL_sysvideo.h"
27 #include "../../events/SDL_windowevents_c.h"
28 #include "../SDL_egl_c.h"
51 handle_ping_wl_shell_surface(
void *
data,
struct wl_shell_surface *shell_surface,
58 handle_configure_wl_shell_surface(
void *
data,
struct wl_shell_surface *shell_surface,
93 handle_popup_done_wl_shell_surface(
void *
data,
struct wl_shell_surface *shell_surface)
98 handle_ping_wl_shell_surface,
99 handle_configure_wl_shell_surface,
100 handle_popup_done_wl_shell_surface
107 handle_configure_zxdg_shell_surface(
void *
data,
struct zxdg_surface_v6 *zxdg,
uint32_t serial)
111 struct wl_region *region;
139 handle_configure_zxdg_shell_surface
144 handle_configure_zxdg_toplevel(
void *
data,
145 struct zxdg_toplevel_v6 *zxdg_toplevel_v6,
148 struct wl_array *states)
155 wl_array_for_each(
state, states) {
198 handle_close_zxdg_toplevel(
void *
data,
struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
205 handle_configure_zxdg_toplevel,
206 handle_close_zxdg_toplevel
212 handle_configure_xdg_shell_surface(
void *
data,
struct xdg_surface *xdg,
uint32_t serial)
216 struct wl_region *region;
244 handle_configure_xdg_shell_surface
249 handle_configure_xdg_toplevel(
void *
data,
250 struct xdg_toplevel *xdg_toplevel,
253 struct wl_array *states)
260 wl_array_for_each(
state, states) {
303 handle_close_xdg_toplevel(
void *
data,
struct xdg_toplevel *xdg_toplevel)
310 handle_configure_xdg_toplevel,
311 handle_close_xdg_toplevel
317 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
319 handle_onscreen_visibility(
void *
data,
320 struct qt_extended_surface *qt_extended_surface,
int32_t visible)
325 handle_set_generic_property(
void *
data,
326 struct qt_extended_surface *qt_extended_surface,
const char *
name,
327 struct wl_array *
value)
332 handle_close(
void *
data,
struct qt_extended_surface *qt_extended_surface)
338 static const struct qt_extended_surface_listener extended_surface_listener = {
339 handle_onscreen_visibility,
340 handle_set_generic_property,
347 float old_factor =
window->scale_factor, new_factor = 0.0;
354 if (!
window->num_outputs) {
355 new_factor = old_factor;
362 for (
i = 0;
i <
window->num_outputs;
i++) {
364 if (factor > new_factor) {
369 if (new_factor != old_factor) {
373 window->resize.scale_factor = new_factor;
379 handle_surface_enter(
void *
data,
struct wl_surface *
surface,
380 struct wl_output *
output) {
385 update_scale_factor(
window);
389 handle_surface_leave(
void *
data,
struct wl_surface *
surface,
390 struct wl_output *
output) {
394 if (
window->num_outputs > 1) {
395 struct wl_output **new_outputs =
SDL_malloc((
window->num_outputs - 1) *
sizeof *
window->outputs), **iter = new_outputs;
396 for (
i=0;
i <
window->num_outputs;
i++) {
403 window->outputs = new_outputs;
411 update_scale_factor(
window);
415 handle_surface_enter,
437 if (version < 2000006) {
443 info->
info.
wl.display =
data->waylandData->display;
445 info->
info.
wl.shell_surface =
data->shell_surface.wl;
490 struct wl_output *
output = (
struct wl_output *)
window->fullscreen_mode.driverdata;
494 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
496 QtExtendedSurface_OnHintChanged(
void *userdata,
const char *
name,
497 const char *oldValue,
const char *newValue)
499 struct qt_extended_surface *qt_extended_surface = userdata;
506 int32_t orientation = QT_EXTENDED_SURFACE_ORIENTATION_PRIMARYORIENTATION;
508 if (newValue !=
NULL) {
509 if (strcmp(newValue,
"portrait") == 0) {
510 orientation = QT_EXTENDED_SURFACE_ORIENTATION_PORTRAITORIENTATION;
511 }
else if (strcmp(newValue,
"landscape") == 0) {
512 orientation = QT_EXTENDED_SURFACE_ORIENTATION_LANDSCAPEORIENTATION;
513 }
else if (strcmp(newValue,
"inverted-portrait") == 0) {
514 orientation = QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDPORTRAITORIENTATION;
515 }
else if (strcmp(newValue,
"inverted-landscape") == 0) {
516 orientation = QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION;
520 qt_extended_surface_set_content_orientation(qt_extended_surface, orientation);
524 if (newValue !=
NULL) {
525 char *tmp =
strdup(newValue);
526 char *saveptr =
NULL;
528 char *flag = strtok_r(tmp,
" ", &saveptr);
530 if (strcmp(flag,
"OverridesSystemGestures") == 0) {
531 flags |= QT_EXTENDED_SURFACE_WINDOWFLAG_OVERRIDESSYSTEMGESTURES;
532 }
else if (strcmp(flag,
"StaysOnTop") == 0) {
533 flags |= QT_EXTENDED_SURFACE_WINDOWFLAG_STAYSONTOP;
534 }
else if (strcmp(flag,
"BypassWindowManager") == 0) {
539 flag = strtok_r(
NULL,
" ", &saveptr);
545 qt_extended_surface_set_window_flags(qt_extended_surface,
flags);
549 static void QtExtendedSurface_Subscribe(
struct qt_extended_surface *
surface,
const char *
name)
554 static void QtExtendedSurface_Unsubscribe(
struct qt_extended_surface *
surface,
const char *
name)
611 WAYLAND_wl_display_flush( viddata->
display );
618 struct wl_region *region;
639 data->waylandData =
c;
642 data->scale_factor = 1.0;
657 data->resize.scale_factor =
data->scale_factor;
660 data->num_outputs = 0;
672 }
else if (
c->shell.zxdg) {
683 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
684 if (
c->surface_extension) {
685 data->extended_surface = qt_surface_extension_get_extended_surface(
686 c->surface_extension,
data->surface);
693 data->egl_window = WAYLAND_wl_egl_window_create(
data->surface,
700 return SDL_SetError(
"failed to create a window surface");
704 if (
data->shell_surface.xdg.surface) {
708 }
else if (
c->shell.zxdg) {
709 if (
data->shell_surface.zxdg.surface) {
714 if (
data->shell_surface.wl) {
720 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
721 if (
data->extended_surface) {
722 qt_extended_surface_set_user_data(
data->extended_surface,
data);
723 qt_extended_surface_add_listener(
data->extended_surface,
724 &extended_surface_listener,
data);
728 if (
c->decoration_manager &&
c->shell.xdg &&
data->shell_surface.xdg.surface) {
730 if (
data->server_decoration) {
735 }
else if (
c->kwin_server_decoration_manager) {
737 if (
data->kwin_server_decoration) {
749 if (
c->relative_mouse_mode) {
754 WAYLAND_wl_display_flush(
c->display);
759 if (
data->shell_surface.xdg.surface) {
760 while (!
data->shell_surface.xdg.initial_configure_seen) {
761 WAYLAND_wl_display_flush(
c->display);
762 WAYLAND_wl_display_dispatch(
c->display);
765 }
else if (
c->shell.zxdg) {
766 if (
data->shell_surface.zxdg.surface) {
767 while (!
data->shell_surface.zxdg.initial_configure_seen) {
768 WAYLAND_wl_display_flush(
c->display);
769 WAYLAND_wl_display_dispatch(
c->display);
781 struct wl_region *region;
817 WAYLAND_wl_egl_window_destroy(wind->
egl_window);
827 if (
data->shell.xdg) {
834 }
else if (
data->shell.zxdg) {
847 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
857 WAYLAND_wl_display_flush(
data->display);
static void zxdg_toplevel_v6_unset_fullscreen(struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
struct zxdg_toplevel_v6 * toplevel
#define SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION
A variable describing the content orientation on QtWayland-based platforms.
static struct wl_surface * wl_compositor_create_surface(struct wl_compositor *wl_compositor)
static struct wl_shell_surface * wl_shell_get_shell_surface(struct wl_shell *wl_shell, struct wl_surface *surface)
@ ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE
@ SDL_WINDOW_ALLOW_HIGHDPI
#define SDL_HINT_QTWAYLAND_WINDOW_FLAGS
Flags to set on QtWayland windows to integrate with the native window manager.
GLenum GLenum GLenum GLenum GLenum scale
struct zxdg_shell_v6 * zxdg
static void * wl_output_get_user_data(struct wl_output *wl_output)
static void wl_surface_commit(struct wl_surface *wl_surface)
static void zxdg_toplevel_decoration_v1_set_mode(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1, uint32_t mode)
static void wl_surface_set_opaque_region(struct wl_surface *wl_surface, struct wl_region *region)
GLint GLint GLsizei width
@ ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER
static void wl_shell_surface_pong(struct wl_shell_surface *wl_shell_surface, uint32_t serial)
static void zxdg_toplevel_v6_destroy(struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
static int wl_shell_surface_add_listener(struct wl_shell_surface *wl_shell_surface, const struct wl_shell_surface_listener *listener, void *data)
@ ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE
static struct zxdg_toplevel_v6 * zxdg_surface_v6_get_toplevel(struct zxdg_surface_v6 *zxdg_surface_v6)
void Wayland_MaximizeWindow(_THIS, SDL_Window *window)
@ SDL_WINDOWEVENT_RESIZED
struct xdg_surface * surface
static void wl_region_add(struct wl_region *wl_region, int32_t x, int32_t y, int32_t width, int32_t height)
#define SDL_WINDOWPOS_UNDEFINED
static struct zxdg_toplevel_decoration_v1 * zxdg_decoration_manager_v1_get_toplevel_decoration(struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1, struct xdg_toplevel *toplevel)
static void xdg_toplevel_set_fullscreen(struct xdg_toplevel *xdg_toplevel, struct wl_output *output)
union SDL_WindowData::@268 shell_surface
#define SDL_GL_LoadLibrary
struct zxdg_decoration_manager_v1 * decoration_manager
struct zxdg_surface_v6 * surface
static void xdg_toplevel_set_app_id(struct xdg_toplevel *xdg_toplevel, const char *app_id)
static void zxdg_toplevel_v6_set_maximized(struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
struct wl_shell_surface * wl
static void xdg_surface_destroy(struct xdg_surface *xdg_surface)
static void xdg_toplevel_unset_fullscreen(struct xdg_toplevel *xdg_toplevel)
struct SDL_WindowData::@269 resize
struct wl_compositor * compositor
static void zxdg_surface_v6_ack_configure(struct zxdg_surface_v6 *zxdg_surface_v6, uint32_t serial)
@ ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_NONE
static int xdg_toplevel_add_listener(struct xdg_toplevel *xdg_toplevel, const struct xdg_toplevel_listener *listener, void *data)
SDL_VideoData * waylandData
union SDL_SysWMinfo::@17 info
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
The type used to identify a window.
static int xdg_surface_add_listener(struct xdg_surface *xdg_surface, const struct xdg_surface_listener *listener, void *data)
static void xdg_toplevel_set_title(struct xdg_toplevel *xdg_toplevel, const char *title)
org_kde_kwin_server_decoration_mode
static int zxdg_toplevel_v6_add_listener(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, const struct zxdg_toplevel_v6_listener *listener, void *data)
static void wl_region_destroy(struct wl_region *wl_region)
static void wl_shell_surface_set_class(struct wl_shell_surface *wl_shell_surface, const char *class_)
static struct wl_region * wl_compositor_create_region(struct wl_compositor *wl_compositor)
void Wayland_ShowWindow(_THIS, SDL_Window *window)
static void xdg_toplevel_destroy(struct xdg_toplevel *xdg_toplevel)
static void wl_shell_surface_destroy(struct wl_shell_surface *wl_shell_surface)
void Wayland_SetWindowTitle(_THIS, SDL_Window *window)
static SDL_VideoDevice * _this
static struct xdg_surface * xdg_wm_base_get_xdg_surface(struct xdg_wm_base *xdg_wm_base, struct wl_surface *surface)
static void wl_shell_surface_set_title(struct wl_shell_surface *wl_shell_surface, const char *title)
struct SDL_VideoData::@265 shell
EGLSurface EGLNativeWindowType * window
static void xdg_surface_ack_configure(struct xdg_surface *xdg_surface, uint32_t serial)
GLint GLint GLsizei GLsizei height
static int wl_surface_add_listener(struct wl_surface *wl_surface, const struct wl_surface_listener *listener, void *data)
GLuint const GLchar * name
SDL_VideoDisplay * displays
void Wayland_RestoreWindow(_THIS, SDL_Window *window)
SDL_bool initial_configure_seen
static void zxdg_toplevel_v6_set_title(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, const char *title)
static struct xdg_toplevel * xdg_surface_get_toplevel(struct xdg_surface *xdg_surface)
struct qt_extended_surface * extended_surface
@ WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT
SDL_xdg_shell_surface xdg
union SDL_zxdg_shell_surface::@266 roleobj
@ ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN
SDL_bool Wayland_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
static void xdg_surface_set_user_data(struct xdg_surface *xdg_surface, void *user_data)
static struct org_kde_kwin_server_decoration * org_kde_kwin_server_decoration_manager_create(struct org_kde_kwin_server_decoration_manager *org_kde_kwin_server_decoration_manager, struct wl_surface *surface)
void Wayland_DestroyWindow(_THIS, SDL_Window *window)
static int zxdg_surface_v6_add_listener(struct zxdg_surface_v6 *zxdg_surface_v6, const struct zxdg_surface_v6_listener *listener, void *data)
void Wayland_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered)
static void wl_shell_surface_set_maximized(struct wl_shell_surface *wl_shell_surface, struct wl_output *output)
struct wl_egl_window * egl_window
#define SDL_OutOfMemory()
struct org_kde_kwin_server_decoration_manager * kwin_server_decoration_manager
static void zxdg_surface_v6_set_user_data(struct zxdg_surface_v6 *zxdg_surface_v6, void *user_data)
static void org_kde_kwin_server_decoration_release(struct org_kde_kwin_server_decoration *org_kde_kwin_server_decoration)
SDL_bool initial_configure_seen
static void wl_surface_set_buffer_scale(struct wl_surface *wl_surface, int32_t scale)
#define FULLSCREEN_VISIBLE(W)
struct wl_display * display
static void wl_shell_surface_set_fullscreen(struct wl_shell_surface *wl_shell_surface, uint32_t method, uint32_t framerate, struct wl_output *output)
#define SDL_AddHintCallback
union SDL_xdg_shell_surface::@267 roleobj
GLsizei const GLfloat * value
static void zxdg_toplevel_decoration_v1_destroy(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
void Wayland_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *_display, SDL_bool fullscreen)
SDL_zxdg_shell_surface zxdg
struct SDL_SysWMinfo::@17::@19 wl
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
int Wayland_input_lock_pointer(struct SDL_WaylandInput *input)
struct xdg_toplevel * toplevel
int Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
GLenum GLenum GLsizei const GLuint GLboolean enabled
static struct zxdg_surface_v6 * zxdg_shell_v6_get_xdg_surface(struct zxdg_shell_v6 *zxdg_shell_v6, struct wl_surface *surface)
static void zxdg_toplevel_v6_set_app_id(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, const char *app_id)
@ XDG_TOPLEVEL_STATE_FULLSCREEN
SDL_VideoDevice * SDL_GetVideoDevice(void)
#define SDL_DelHintCallback
static void wl_surface_destroy(struct wl_surface *wl_surface)
static void xdg_toplevel_set_maximized(struct xdg_toplevel *xdg_toplevel)
static void wl_shell_surface_set_user_data(struct wl_shell_surface *wl_shell_surface, void *user_data)
static void wl_shell_surface_set_toplevel(struct wl_shell_surface *wl_shell_surface)
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)
zxdg_toplevel_decoration_v1_mode
static void zxdg_surface_v6_destroy(struct zxdg_surface_v6 *zxdg_surface_v6)
static void zxdg_toplevel_v6_set_fullscreen(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, struct wl_output *output)
struct org_kde_kwin_server_decoration * kwin_server_decoration
static void org_kde_kwin_server_decoration_request_mode(struct org_kde_kwin_server_decoration *org_kde_kwin_server_decoration, uint32_t mode)
int Wayland_CreateWindow(_THIS, SDL_Window *window)
void Wayland_SetWindowSize(_THIS, SDL_Window *window)
struct zxdg_toplevel_decoration_v1 * server_decoration