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" 36 #include "xdg-shell-client-protocol.h" 37 #include "xdg-shell-unstable-v6-client-protocol.h" 38 #include "xdg-decoration-unstable-v1-client-protocol.h" 39 #include "org-kde-kwin-server-decoration-manager-client-protocol.h" 51 handle_ping_wl_shell_surface(
void *
data,
struct wl_shell_surface *shell_surface,
54 wl_shell_surface_pong(shell_surface, serial);
58 handle_configure_wl_shell_surface(
void *
data,
struct wl_shell_surface *shell_surface,
67 if (width == 0 || height == 0) {
73 if (window->
max_w > 0) {
78 if (window->
max_h > 0) {
93 handle_popup_done_wl_shell_surface(
void *data,
struct wl_shell_surface *shell_surface)
97 static const struct wl_shell_surface_listener shell_surface_listener_wl = {
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;
120 wl_surface_set_buffer_scale(wind->
surface, get_window_scale_factor(window));
121 WAYLAND_wl_egl_window_resize(wind->
egl_window, window->
w * get_window_scale_factor(window), window->
h * get_window_scale_factor(window), 0, 0);
123 zxdg_surface_v6_ack_configure(zxdg, serial);
126 wl_region_add(region, 0, 0, window->
w, window->
h);
127 wl_surface_set_opaque_region(wind->
surface, region);
128 wl_region_destroy(region);
138 static const struct zxdg_surface_v6_listener shell_surface_listener_zxdg = {
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)
153 enum zxdg_toplevel_v6_state *
state;
155 wl_array_for_each(state, states) {
156 if (*state == ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN) {
162 if (width == 0 || height == 0) {
171 if (window->
max_w > 0) {
176 if (window->
max_h > 0) {
187 if (width == 0 || height == 0) {
198 handle_close_zxdg_toplevel(
void *data,
struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
204 static const struct zxdg_toplevel_v6_listener toplevel_listener_zxdg = {
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;
225 wl_surface_set_buffer_scale(wind->
surface, get_window_scale_factor(window));
226 WAYLAND_wl_egl_window_resize(wind->
egl_window, window->
w * get_window_scale_factor(window), window->
h * get_window_scale_factor(window), 0, 0);
228 xdg_surface_ack_configure(xdg, serial);
231 wl_region_add(region, 0, 0, window->
w, window->
h);
232 wl_surface_set_opaque_region(wind->
surface, region);
233 wl_region_destroy(region);
243 static const struct xdg_surface_listener shell_surface_listener_xdg = {
244 handle_configure_xdg_shell_surface
249 handle_configure_xdg_toplevel(
void *data,
250 struct xdg_toplevel *xdg_toplevel,
253 struct wl_array *states)
258 enum xdg_toplevel_state *
state;
260 wl_array_for_each(state, states) {
261 if (*state == XDG_TOPLEVEL_STATE_FULLSCREEN) {
267 if (width == 0 || height == 0) {
276 if (window->
max_w > 0) {
281 if (window->
max_h > 0) {
292 if (width == 0 || height == 0) {
303 handle_close_xdg_toplevel(
void *data,
struct xdg_toplevel *xdg_toplevel)
309 static const struct xdg_toplevel_listener toplevel_listener_xdg = {
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;
355 new_factor = old_factor;
364 if (factor > new_factor) {
369 if (new_factor != old_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) {
397 if (window->
outputs[i] != output) {
411 update_scale_factor(window);
414 static const struct wl_surface_listener surface_listener = {
415 handle_surface_enter,
437 if (version < 2000006) {
478 WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
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)
565 SetFullscreen(
_this, window, fullscreen ? output :
NULL);
589 const enum zxdg_toplevel_decoration_v1_mode
mode = bordered ? ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE : ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE;
592 const enum org_kde_kwin_server_decoration_mode
mode = bordered ? ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER : ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_NONE;
611 WAYLAND_wl_display_flush( viddata->
display );
618 struct wl_region *region;
620 data = calloc(1,
sizeof *data);
664 wl_surface_add_listener(data->
surface, &surface_listener, data);
683 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 684 if (c->surface_extension) {
686 c->surface_extension, data->
surface);
700 return SDL_SetError(
"failed to create a window surface");
716 wl_shell_surface_add_listener(data->
shell_surface.
wl, &shell_surface_listener_wl, data);
720 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 724 &extended_surface_listener, data);
732 const enum zxdg_toplevel_decoration_v1_mode
mode = bordered ? ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE : ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE;
739 const enum org_kde_kwin_server_decoration_mode
mode = bordered ? ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER : ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_NONE;
744 region = wl_compositor_create_region(c->
compositor);
745 wl_region_add(region, 0, 0, window->
w, window->
h);
746 wl_surface_set_opaque_region(data->
surface, region);
747 wl_region_destroy(region);
753 wl_surface_commit(data->
surface);
754 WAYLAND_wl_display_flush(c->
display);
761 WAYLAND_wl_display_flush(c->
display);
762 WAYLAND_wl_display_dispatch(c->
display);
768 WAYLAND_wl_display_flush(c->
display);
769 WAYLAND_wl_display_dispatch(c->
display);
781 struct wl_region *region;
783 wl_surface_set_buffer_scale(wind->
surface, get_window_scale_factor(window));
784 WAYLAND_wl_egl_window_resize(wind->
egl_window, window->
w * get_window_scale_factor(window), window->
h * get_window_scale_factor(window), 0, 0);
786 region = wl_compositor_create_region(data->
compositor);
787 wl_region_add(region, 0, 0, window->
w, window->
h);
788 wl_surface_set_opaque_region(wind->
surface, region);
789 wl_region_destroy(region);
817 WAYLAND_wl_egl_window_destroy(wind->
egl_window);
847 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 854 wl_surface_destroy(wind->
surface);
857 WAYLAND_wl_display_flush(data->
display);
#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 org_kde_kwin_server_decoration * kwin_server_decoration
void Wayland_SetWindowSize(_THIS, SDL_Window *window)
#define SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION
A variable describing the content orientation on QtWayland-based platforms.
struct qt_extended_surface * extended_surface
struct zxdg_toplevel_v6 * toplevel
struct SDL_VideoData::@264 shell
union SDL_WindowData::@267 shell_surface
void Wayland_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *_display, SDL_bool fullscreen)
SDL_DisplayMode fullscreen_mode
struct zxdg_surface_v6 * surface
struct wl_shell_surface * wl
#define FULLSCREEN_VISIBLE(W)
int Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
struct wl_display * display
void Wayland_MaximizeWindow(_THIS, SDL_Window *window)
SDL_bool initial_configure_seen
SDL_bool initial_configure_seen
void Wayland_ShowWindow(_THIS, SDL_Window *window)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
struct SDL_WindowData::@268 resize
int Wayland_input_lock_pointer(struct SDL_WaylandInput *input)
#define SDL_WINDOWPOS_UNDEFINED
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
#define SDL_GL_LoadLibrary
struct SDL_WaylandInput * input
int Wayland_CreateWindow(_THIS, SDL_Window *window)
GLuint const GLchar * name
GLint GLint GLsizei width
static SDL_VideoDevice * _this
SDL_xdg_shell_surface xdg
struct zxdg_decoration_manager_v1 * decoration_manager
struct SDL_SysWMinfo::@17::@19 wl
struct zxdg_toplevel_decoration_v1 * server_decoration
void Wayland_SetWindowTitle(_THIS, SDL_Window *window)
void Wayland_DestroyWindow(_THIS, SDL_Window *window)
struct xdg_toplevel * toplevel
void Wayland_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered)
SDL_bool Wayland_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
SDL_VideoData * waylandData
GLsizei const GLfloat * value
SDL_VideoDisplay * displays
union SDL_zxdg_shell_surface::@265 roleobj
struct wl_output ** outputs
union SDL_xdg_shell_surface::@266 roleobj
GLenum GLenum GLsizei const GLuint GLboolean enabled
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)
#define SDL_OutOfMemory()
struct wl_compositor * compositor
GLint GLint GLsizei GLsizei height
void Wayland_RestoreWindow(_THIS, SDL_Window *window)
SDL_zxdg_shell_surface zxdg
EGLSurface EGLNativeWindowType * window
The type used to identify a window.
struct xdg_surface * surface
union SDL_SysWMinfo::@17 info
#define SDL_AddHintCallback
#define SDL_DelHintCallback
struct org_kde_kwin_server_decoration_manager * kwin_server_decoration_manager
SDL_VideoDevice * SDL_GetVideoDevice(void)
struct zxdg_shell_v6 * zxdg
struct wl_egl_window * egl_window