From 6aae5b44f825ff925268281d202852718849d146 Mon Sep 17 00:00:00 2001
From: Simon Zeni <[EMAIL REDACTED]>
Date: Tue, 27 Jul 2021 17:12:26 -0400
Subject: [PATCH] Remove wl-shell and xdg-shell-unstable-v6 support (#4323)
* wayland-protocol: update wayland.xml to 1.19.0
* wayland: remove shell_surface field from SDL_SysWMinfo
* wayland: remove wl_shell support
* waypand-protocols: update xdg-shell.xml to 1.20
* wayland: remove xdg-shell-unstable-v6 support
* wayland: deprecate wl shell surface syswm info, add xdg surface
---
include/SDL_syswm.h | 3 +-
src/video/wayland/SDL_waylanddyn.h | 4 +-
src/video/wayland/SDL_waylandevents.c | 44 +-
src/video/wayland/SDL_waylandopengles.c | 12 +-
src/video/wayland/SDL_waylandsym.h | 2 -
src/video/wayland/SDL_waylandvideo.c | 32 -
src/video/wayland/SDL_waylandvideo.h | 11 -
src/video/wayland/SDL_waylandwindow.c | 346 +-----
src/video/wayland/SDL_waylandwindow.h | 13 +-
wayland-protocols/wayland.xml | 212 +++-
wayland-protocols/xdg-shell-unstable-v6.xml | 1044 -------------------
wayland-protocols/xdg-shell.xml | 198 +++-
12 files changed, 378 insertions(+), 1543 deletions(-)
delete mode 100644 wayland-protocols/xdg-shell-unstable-v6.xml
diff --git a/include/SDL_syswm.h b/include/SDL_syswm.h
index d2608013a8..046a096eed 100644
--- a/include/SDL_syswm.h
+++ b/include/SDL_syswm.h
@@ -289,8 +289,9 @@ struct SDL_SysWMinfo
{
struct wl_display *display; /**< Wayland display */
struct wl_surface *surface; /**< Wayland surface */
- struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */
+ void *shell_surface; /**< DEPRECATED Wayland shell_surface (window manager handle) */
struct wl_egl_window *egl_window; /**< Wayland EGL window (native window) */
+ struct xdg_surface *xdg_surface; /**< Wayland xdg surface (window manager handle) */
} wl;
#endif
#if defined(SDL_VIDEO_DRIVER_MIR) /* no longer available, left for API/ABI compatibility. Remove in 2.1! */
diff --git a/src/video/wayland/SDL_waylanddyn.h b/src/video/wayland/SDL_waylanddyn.h
index f44da989eb..f3e39453b5 100644
--- a/src/video/wayland/SDL_waylanddyn.h
+++ b/src/video/wayland/SDL_waylanddyn.h
@@ -24,7 +24,7 @@
#include "../../SDL_internal.h"
-/* We can't include wayland-client.h here
+/* We can't include wayland-client.h here
* but we need some structs from it
*/
struct wl_interface;
@@ -103,13 +103,11 @@ void SDL_WAYLAND_UnloadSymbols(void);
#define wl_shm_pool_interface (*WAYLAND_wl_shm_pool_interface)
#define wl_buffer_interface (*WAYLAND_wl_buffer_interface)
#define wl_registry_interface (*WAYLAND_wl_registry_interface)
-#define wl_shell_surface_interface (*WAYLAND_wl_shell_surface_interface)
#define wl_region_interface (*WAYLAND_wl_region_interface)
#define wl_pointer_interface (*WAYLAND_wl_pointer_interface)
#define wl_keyboard_interface (*WAYLAND_wl_keyboard_interface)
#define wl_compositor_interface (*WAYLAND_wl_compositor_interface)
#define wl_output_interface (*WAYLAND_wl_output_interface)
-#define wl_shell_interface (*WAYLAND_wl_shell_interface)
#define wl_shm_interface (*WAYLAND_wl_shm_interface)
#define wl_data_device_interface (*WAYLAND_wl_data_device_interface)
#define wl_data_offer_interface (*WAYLAND_wl_data_offer_interface)
diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c
index d0c681173a..068173f4cb 100644
--- a/src/video/wayland/SDL_waylandevents.c
+++ b/src/video/wayland/SDL_waylandevents.c
@@ -40,7 +40,6 @@
#include "pointer-constraints-unstable-v1-client-protocol.h"
#include "relative-pointer-unstable-v1-client-protocol.h"
#include "xdg-shell-client-protocol.h"
-#include "xdg-shell-unstable-v6-client-protocol.h"
#include "keyboard-shortcuts-inhibit-unstable-v1-client-protocol.h"
#ifdef HAVE_LIBDECOR_H
@@ -330,20 +329,16 @@ ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial)
const SDL_Point point = { wl_fixed_to_int(input->sx_w), wl_fixed_to_int(input->sy_w) };
const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data);
- static const uint32_t directions_wl[] = {
- WL_SHELL_SURFACE_RESIZE_TOP_LEFT, WL_SHELL_SURFACE_RESIZE_TOP,
- WL_SHELL_SURFACE_RESIZE_TOP_RIGHT, WL_SHELL_SURFACE_RESIZE_RIGHT,
- WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT, WL_SHELL_SURFACE_RESIZE_BOTTOM,
- WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT, WL_SHELL_SURFACE_RESIZE_LEFT
+ static const uint32_t directions[] = {
+ XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT, XDG_TOPLEVEL_RESIZE_EDGE_TOP,
+ XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT, XDG_TOPLEVEL_RESIZE_EDGE_RIGHT,
+ XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT, XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM,
+ XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT, XDG_TOPLEVEL_RESIZE_EDGE_LEFT
};
- /* the names are different (ZXDG_TOPLEVEL_V6_RESIZE_EDGE_* vs
- WL_SHELL_SURFACE_RESIZE_*), but the values are the same. */
- const uint32_t *directions_zxdg = directions_wl;
-
#ifdef HAVE_LIBDECOR_H
/* ditto for libdecor. */
- const uint32_t *directions_libdecor = directions_wl;
+ const uint32_t *directions_libdecor = directions;
#endif
switch (rc) {
@@ -361,16 +356,6 @@ ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial)
input->seat,
serial);
}
- } else if (input->display->shell.zxdg) {
- if (window_data->shell_surface.zxdg.roleobj.toplevel) {
- zxdg_toplevel_v6_move(window_data->shell_surface.zxdg.roleobj.toplevel,
- input->seat,
- serial);
- }
- } else {
- if (window_data->shell_surface.wl) {
- wl_shell_surface_move(window_data->shell_surface.wl, input->seat, serial);
- }
}
return SDL_TRUE;
@@ -394,18 +379,7 @@ ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial)
xdg_toplevel_resize(window_data->shell_surface.xdg.roleobj.toplevel,
input->seat,
serial,
- directions_zxdg[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
- }
- } else if (input->display->shell.zxdg) {
- if (window_data->shell_surface.zxdg.roleobj.toplevel) {
- zxdg_toplevel_v6_resize(window_data->shell_surface.zxdg.roleobj.toplevel,
- input->seat,
- serial,
- directions_zxdg[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
- }
- } else {
- if (window_data->shell_surface.wl) {
- wl_shell_surface_resize(window_data->shell_surface.wl, input->seat, serial, directions_wl[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
+ directions[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
}
}
return SDL_TRUE;
@@ -784,7 +758,7 @@ keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,
/* Stop key repeat before clearing keyboard focus */
keyboard_repeat_clear(&input->keyboard_repeat);
- /* This will release any keys still pressed */
+ /* This will release any keys still pressed */
SDL_SetKeyboardFocus(NULL);
#ifdef SDL_USE_IME
SDL_IME_SetFocus(SDL_FALSE);
@@ -1615,7 +1589,7 @@ int Wayland_input_grab_keyboard(SDL_Window *window, struct SDL_WaylandInput *inp
zwp_keyboard_shortcuts_inhibit_manager_v1_inhibit_shortcuts(d->key_inhibitor_manager,
w->surface,
input->seat);
-
+
return 0;
}
diff --git a/src/video/wayland/SDL_waylandopengles.c b/src/video/wayland/SDL_waylandopengles.c
index 7b33223e3d..f4736e12f2 100644
--- a/src/video/wayland/SDL_waylandopengles.c
+++ b/src/video/wayland/SDL_waylandopengles.c
@@ -33,7 +33,6 @@
#include "SDL_waylanddyn.h"
#include "xdg-shell-client-protocol.h"
-#include "xdg-shell-unstable-v6-client-protocol.h"
/* EGL implementation of SDL OpenGL ES support */
@@ -41,12 +40,12 @@ int
Wayland_GLES_LoadLibrary(_THIS, const char *path) {
int ret;
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
-
+
ret = SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType) data->display, 0);
Wayland_PumpEvents(_this);
WAYLAND_wl_display_flush(data->display);
-
+
return ret;
}
@@ -57,6 +56,7 @@ Wayland_GLES_CreateContext(_THIS, SDL_Window * window)
SDL_GLContext context;
context = SDL_EGL_CreateContext(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
+
return context;
}
@@ -160,14 +160,14 @@ int
Wayland_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
{
int ret;
-
+
if (window && context) {
ret = SDL_EGL_MakeCurrent(_this, ((SDL_WindowData *) window->driverdata)->egl_surface, context);
}
else {
ret = SDL_EGL_MakeCurrent(_this, NULL, NULL);
}
-
+
WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
_this->egl_data->eglSwapInterval(_this->egl_data->egl_display, 0); /* see comments on Wayland_GLES_SetSwapInterval. */
@@ -192,7 +192,7 @@ Wayland_GLES_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
}
}
-void
+void
Wayland_GLES_DeleteContext(_THIS, SDL_GLContext context)
{
SDL_EGL_DeleteContext(_this, context);
diff --git a/src/video/wayland/SDL_waylandsym.h b/src/video/wayland/SDL_waylandsym.h
index 88df1afb00..e14d33fdb9 100644
--- a/src/video/wayland/SDL_waylandsym.h
+++ b/src/video/wayland/SDL_waylandsym.h
@@ -82,13 +82,11 @@ SDL_WAYLAND_INTERFACE(wl_surface_interface)
SDL_WAYLAND_INTERFACE(wl_shm_pool_interface)
SDL_WAYLAND_INTERFACE(wl_buffer_interface)
SDL_WAYLAND_INTERFACE(wl_registry_interface)
-SDL_WAYLAND_INTERFACE(wl_shell_surface_interface)
SDL_WAYLAND_INTERFACE(wl_region_interface)
SDL_WAYLAND_INTERFACE(wl_pointer_interface)
SDL_WAYLAND_INTERFACE(wl_keyboard_interface)
SDL_WAYLAND_INTERFACE(wl_compositor_interface)
SDL_WAYLAND_INTERFACE(wl_output_interface)
-SDL_WAYLAND_INTERFACE(wl_shell_interface)
SDL_WAYLAND_INTERFACE(wl_shm_interface)
SDL_WAYLAND_INTERFACE(wl_data_device_interface)
SDL_WAYLAND_INTERFACE(wl_data_source_interface)
diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c
index ba5dc23762..7510714ee1 100644
--- a/src/video/wayland/SDL_waylandvideo.c
+++ b/src/video/wayland/SDL_waylandvideo.c
@@ -47,7 +47,6 @@
#include <wayland-util.h>
#include "xdg-shell-client-protocol.h"
-#include "xdg-shell-unstable-v6-client-protocol.h"
#include "xdg-decoration-unstable-v1-client-protocol.h"
#include "keyboard-shortcuts-inhibit-unstable-v1-client-protocol.h"
#include "idle-inhibit-unstable-v1-client-protocol.h"
@@ -414,18 +413,6 @@ static const struct qt_windowmanager_listener windowmanager_listener = {
};
#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
-
-static void
-handle_ping_zxdg_shell(void *data, struct zxdg_shell_v6 *zxdg, uint32_t serial)
-{
- zxdg_shell_v6_pong(zxdg, serial);
-}
-
-static const struct zxdg_shell_v6_listener shell_listener_zxdg = {
- handle_ping_zxdg_shell
-};
-
-
static void
handle_ping_xdg_wm_base(void *data, struct xdg_wm_base *xdg, uint32_t serial)
{
@@ -473,19 +460,6 @@ display_handle_global(void *data, struct wl_registry *registry, uint32_t id,
SDL_strcmp(interface, "xdg_wm_base") == 0) {
d->shell.xdg = wl_registry_bind(d->registry, id, &xdg_wm_base_interface, 1);
xdg_wm_base_add_listener(d->shell.xdg, &shell_listener_xdg, NULL);
- } else if (
-#ifdef HAVE_LIBDECOR_H
- !d->shell.libdecor &&
-#endif
- SDL_strcmp(interface, "zxdg_shell_v6") == 0) {
- d->shell.zxdg = wl_registry_bind(d->registry, id, &zxdg_shell_v6_interface, 1);
- zxdg_shell_v6_add_listener(d->shell.zxdg, &shell_listener_zxdg, NULL);
- } else if (
-#ifdef HAVE_LIBDECOR_H
- !d->shell.libdecor &&
-#endif
- SDL_strcmp(interface, "wl_shell") == 0) {
- d->shell.wl = wl_registry_bind(d->registry, id, &wl_shell_interface, 1);
} else if (SDL_strcmp(interface, "wl_shm") == 0) {
d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
d->cursor_theme = WAYLAND_wl_cursor_theme_load(NULL, 32, d->shm);
@@ -657,15 +631,9 @@ Wayland_VideoQuit(_THIS)
if (data->cursor_theme)
WAYLAND_wl_cursor_theme_destroy(data->cursor_theme);
- if (data->shell.wl)
- wl_shell_destroy(data->shell.wl);
-
if (data->shell.xdg)
xdg_wm_base_destroy(data->shell.xdg);
- if (data->shell.zxdg)
- zxdg_shell_v6_destroy(data->shell.zxdg);
-
if (data->decoration_manager)
zxdg_decoration_manager_v1_destroy(data->decoration_manager);
diff --git a/src/video/wayland/SDL_waylandvideo.h b/src/video/wayland/SDL_waylandvideo.h
index 54201e2269..64f4bdac4b 100644
--- a/src/video/wayland/SDL_waylandvideo.h
+++ b/src/video/wayland/SDL_waylandvideo.h
@@ -25,15 +25,6 @@
#ifndef SDL_waylandvideo_h_
#define SDL_waylandvideo_h_
-
-/*
-!!! FIXME: xdg_wm_base is the stable replacement for zxdg_shell_v6. While it's
-!!! FIXME: harmless to leave it here, consider deleting the obsolete codepath
-!!! FIXME: soon, since Wayland (with xdg_wm_base) will probably be mainline
-!!! FIXME: by the time people are relying on this SDL target. It's available
-!!! FIXME: in Ubuntu 18.04 (and other distros).
-*/
-
#include <EGL/egl.h>
#include "wayland-util.h"
@@ -60,8 +51,6 @@ typedef struct {
struct wl_pointer *pointer;
struct {
struct xdg_wm_base *xdg;
- struct zxdg_shell_v6 *zxdg;
- struct wl_shell *wl;
#ifdef HAVE_LIBDECOR_H
struct libdecor *libdecor;
#endif
diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
index 8a19b36e6a..d4bbb44b9c 100644
--- a/src/video/wayland/SDL_waylandwindow.c
+++ b/src/video/wayland/SDL_waylandwindow.c
@@ -34,7 +34,6 @@
#include "SDL_hints.h"
#include "xdg-shell-client-protocol.h"
-#include "xdg-shell-unstable-v6-client-protocol.h"
#include "xdg-decoration-unstable-v1-client-protocol.h"
#include "idle-inhibit-unstable-v1-client-protocol.h"
#include "xdg-activation-v1-client-protocol.h"
@@ -61,7 +60,7 @@ static void
CommitMinMaxDimensions(SDL_Window *window)
{
SDL_WindowData *wind = window->driverdata;
- SDL_VideoData *data = wind->waylandData;
+ SDL_VideoData *viddata = wind->waylandData;
int min_width, min_height, max_width, max_height;
if (window->flags & SDL_WINDOW_FULLSCREEN) {
@@ -82,7 +81,7 @@ CommitMinMaxDimensions(SDL_Window *window)
}
#ifdef HAVE_LIBDECOR_H
- if (data->shell.libdecor) {
+ if (viddata->shell.libdecor) {
if (wind->shell_surface.libdecor.frame == NULL) {
return; /* Can't do anything yet, wait for ShowWindow */
}
@@ -94,7 +93,7 @@ CommitMinMaxDimensions(SDL_Window *window)
max_height);
} else
#endif
- if (data->shell.xdg) {
+ if (viddata->shell.xdg) {
if (wind->shell_surface.xdg.roleobj.toplevel == NULL) {
return; /* Can't do anything yet, wait for ShowWindow */
}
@@ -105,17 +104,6 @@ CommitMinMaxDimensions(SDL_Window *window)
max_width,
max_height);
wl_surface_commit(wind->surface);
- } else if (data->shell.zxdg) {
- if (wind->shell_surface.zxdg.roleobj.toplevel == NULL) {
- return; /* Can't do anything yet, wait for ShowWindow */
- }
- zxdg_toplevel_v6_set_min_size(wind->shell_surface.zxdg.roleobj.toplevel,
- min_width,
- min_height);
- zxdg_toplevel_v6_set_max_size(wind->shell_surface.zxdg.roleobj.toplevel,
- max_width,
- max_height);
- wl_surface_commit(wind->surface);
}
}
@@ -159,92 +147,9 @@ SetFullscreen(SDL_Window *window, struct wl_output *output)
} else {
xdg_toplevel_unset_fullscreen(wind->shell_surface.xdg.roleobj.toplevel);
}
- } else if (viddata->shell.zxdg) {
- if (wind->shell_surface.zxdg.roleobj.toplevel == NULL) {
- return; /* Can't do anything yet, wait for ShowWindow */
- }
- if (output) {
- zxdg_toplevel_v6_set_fullscreen(wind->shell_surface.zxdg.roleobj.toplevel, output);
- } else {
- zxdg_toplevel_v6_unset_fullscreen(wind->shell_surface.zxdg.roleobj.toplevel);
- }
- } else {
- if (wind->shell_surface.wl == NULL) {
- return; /* Can't do anything yet, wait for ShowWindow */
- }
- if (output) {
- wl_shell_surface_set_fullscreen(wind->shell_surface.wl,
- WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
- 0, output);
- } else {
- wl_shell_surface_set_toplevel(wind->shell_surface.wl);
- }
}
}
-/* On modern desktops, we probably will use the xdg-shell protocol instead
- of wl_shell, but wl_shell might be useful on older Wayland installs that
- don't have the newer protocol, or embedded things that don't have a full
- window manager. */
-
-static void
-handle_ping_wl_shell_surface(void *data, struct wl_shell_surface *shell_surface,
- uint32_t serial)
-{
- wl_shell_surface_pong(shell_surface, serial);
-}
-
-static void
-handle_configure_wl_shell_surface(void *data, struct wl_shell_surface *shell_surface,
- uint32_t edges, int32_t width, int32_t height)
-{
- SDL_WindowData *wind = (SDL_WindowData *)data;
- SDL_Window *window = wind->sdlwindow;
-
- /* wl_shell_surface spec states that this is a suggestion.
- Ignore if less than or greater than max/min size. */
-
- if (width == 0 || height == 0) {
- return;
- }
-
- if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
- if ((window->flags & SDL_WINDOW_RESIZABLE)) {
- if (window->max_w > 0) {
- width = SDL_min(width, window->max_w);
- }
- width = SDL_max(width, window->min_w);
-
- if (window->max_h > 0) {
- height = SDL_min(height, window->max_h);
- }
- height = SDL_max(height, window->min_h);
- } else {
- return;
- }
- }
-
- wind->resize.width = width;
- wind->resize.height = height;
- wind->resize.pending = SDL_TRUE;
-
- if (!(window->flags & SDL_WINDOW_OPENGL)) {
- Wayland_HandlePendingResize(window); /* OpenGL windows handle this in SwapWindow */
- }
-}
-
-static void
-handle_popup_done_wl_shell_surface(void *data, struct wl_shell_surface *shell_surface)
-{
-}
-
-static const struct wl_shell_surface_listener shell_surface_listener_wl = {
- handle_ping_wl_shell_surface,
- handle_configure_wl_shell_surface,
- handle_popup_done_wl_shell_surface
-};
-
-
static const struct wl_callback_listener surface_frame_listener;
static void
@@ -263,140 +168,6 @@ static const struct wl_callback_listener surface_frame_listener = {
handle_surface_frame_done
};
-
-static void
-handle_configure_zxdg_shell_surface(void *data, struct zxdg_surface_v6 *zxdg, uint32_t serial)
-{
- SDL_WindowData *wind = (SDL_WindowData *)data;
- SDL_Window *window = wind->sdlwindow;
- struct wl_region *region;
-
- if (!wind->shell_surface.zxdg.initial_configure_seen) {
- window->w = 0;
- window->h = 0;
- SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, wind->resize.width, wind->resize.height);
- window->w = wind->resize.width;
- window->h = wind->resize.height;
-
- wl_surface_set_buffer_scale(wind->surface, get_window_scale_factor(window));
- if (wind->egl_window) {
- WAYLAND_wl_egl_window_resize(wind->egl_window, window->w * get_window_scale_factor(window), window->h * get_window_scale_factor(window), 0, 0);
- }
-
- zxdg_surface_v6_ack_configure(zxdg, serial);
-
- region = wl_compositor_create_region(wind->waylandData->compositor);
- wl_region_add(region, 0, 0, window->w, window->h);
- wl_surface_set_opaque_region(wind->surface, region);
- wl_region_destroy(region);
-
- wind->shell_surface.zxdg.initial_configure_seen = SDL_TRUE;
- } else {
- wind->resize.pending = SDL_TRUE;
- wind->resize.configure = SDL_TRUE;
- wind->resize.serial = serial;
- if (!(window->flags & SDL_WINDOW_OPENGL)) {
- Wayland_HandlePendingResize(window); /* OpenGL windows handle this in SwapWindow */
- }
- }
-}
-
-static const struct zxdg_surface_v6_listener shell_surface_listener_zxdg = {
- handle_configure_zxdg_shell_surface
-};
-
-
-static void
-handle_configure_zxdg_toplevel(void *data,
- struct zxdg_toplevel_v6 *zxdg_toplevel_v6,
- int32_t width,
- int32_t height,
- struct wl_array *states)
-{
- SDL_WindowData *wind = (SDL_WindowData *)data;
- SDL_Window *window = wind->sdlwindow;
-
- enum zxdg_toplevel_v6_state *state;
- SDL_bool fullscreen = SDL_FALSE;
- SDL_bool maximized = SDL_FALSE;
- wl_array_for_each(state, states) {
- if (*state == ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN) {
- fullscreen = SDL_TRUE;
- } else if (*state == ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED) {
- maximized = SDL_TRUE;
- }
- }
-
- if (!fullscreen) {
- if (window->flags & SDL_WINDOW_FULLSCREEN) {
- /* We might need to re-enter fullscreen after being restored from minimized */
- SDL_WaylandOutputData *driverdata = (SDL_WaylandOutputData *) SDL_GetDisplayForWindow(window)->driverdata;
- SetFullscreen(window, driverdata->output);
- fullscreen = SDL_TRUE;
- }
-
- if (width == 0 || height == 0) {
- width = window->windowed.w;
- height = window->windowed.h;
- }
-
- /* zxdg_toplevel spec states that this is a suggestion.
- Ignore if less than or greater than max/min size. */
-
- if ((window->flags & SDL_WINDOW_RESIZABLE)) {
- if (window->max_w > 0) {
- width = SDL_min(width, window->max_w);
- }
- width = SDL_max(width, window->min_w);
-
- if (window->max_h > 0) {
- height = SDL_min(height, window->max_h);
- }
- height = SDL_max(height, window->min_h);
- } else {
- wind->resize.width = window->w;
- wind->resize.height = window->h;
- return;
- }
- }
-
- /* Always send a maximized/restore event; if the event is redundant it will
- * automatically be discarded (see src/events/SDL_windowevents.c).
- *
- * No, we do not get minimize events from zxdg-shell.
- */
- if (!fullscreen) {
- SDL_SendWindowEvent(window,
- maximized ?
- SDL_WINDOWEVENT_MAXIMIZED :
- SDL_WINDOWEVENT_RESTORED,
- 0, 0);
- }
-
- if (width == 0 || height == 0) {
- wind->resize.width = window->w;
- wind->resize.height = window->h;
- return;
- }
-
- wind->resize.width = width;
- wind->resize.height = height;
-}
-
-static void
-handle_close_zxdg_toplevel(void *data, struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
-{
- SDL_WindowData *window = (SDL_WindowData *)data;
- SDL_SendWindowEvent(window->sdlwindow, SDL_WINDOWEVENT_CLOSE, 0, 0);
-}
-
-static const struct zxdg_toplevel_v6_listener toplevel_listener_zxdg = {
- handle_configure_zxdg_toplevel,
- handle_close_zxdg_toplevel
-};
-
-
-
static void
handle_configure_xdg_shell_surface(void *data, struct xdg_surface *xdg, uint32_t serial)
{
@@ -438,7 +209,6 @@ static const struct xdg_surface_listener shell_surface_listener_xdg = {
handle_configure_xdg_shell_surface
};
-
static void
handle_configure_xdg_toplevel(void *data,
struct xdg_toplevel *xdg_toplevel,
@@ -784,10 +554,14 @@ Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
info->info.wl.display = data->waylandData->display;
info->info.wl.surface = data->surface;
- info->info.wl.shell_surface = data->shell_surface.wl;
if (version >= SDL_VERSIONNUM(2, 0, 15)) {
info->info.wl.egl_window = data->egl_window;
}
+
+ info->info.wl.shell_surface = NULL;
+ info->info.wl.xdg_surface = data->shell_surface.xdg.surface;
+
+
info->subsystem = SDL_SYSWM_WAYLAND;
return SDL_TRUE;
@@ -802,7 +576,7 @@ Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
int
Wayland_SetWindowModalFor(_THIS, SDL_Window *modal_window, SDL_Window *parent_window)
{
- const SDL_VideoData *viddata = (const SDL_VideoData *) _this->driverdata;
+ SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata;
SDL_WindowData *modal_data = modal_window->driverdata;
SDL_WindowData *parent_data = parent_window->driverdata;
@@ -815,20 +589,9 @@ Wayland_SetWindowModalFor(_THIS, SDL_Window *modal_window, SDL_Window *parent_wi
}
xdg_toplevel_set_parent(modal_data->shell_surface.xdg.roleobj.toplevel,
parent_data->shell_surface.xdg.roleobj.toplevel);
- } else if (viddata->shell.zxdg) {
- if (modal_data->shell_surface.zxdg.roleobj.toplevel == NULL) {
- return SDL_SetError("Modal window was hidden");
- }
- if (parent_data->shell_surface.zxdg.roleobj.toplevel == NULL) {
- return SDL_SetError("Parent window was hidden");
- }
- zxdg_toplevel_v6_set_parent(modal_data->shell_surface.zxdg.roleobj.toplevel,
- parent_data->shell_surface.zxdg.roleobj.toplevel);
- } else {
- return SDL_Unsupported();
}
- WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
+ WAYLAND_wl_display_flush(viddata->display);
return 0;
}
@@ -868,20 +631,11 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
data->shell_surface.xdg.roleobj.toplevel = xdg_surface_get_toplevel(data->shell_surface.xdg.surface);
xdg_toplevel_set_app_id(data->shell_surface.xdg.roleobj.toplevel, c->classname);
xdg_toplevel_add_listener(data->shell_surface.xdg.roleobj.toplevel, &toplevel_listener_xdg, data);
- } else if (c->shell.zxdg) {
- data->shell_surface.zxdg.surface = zxdg_shell_v6_get_xdg_surface(c->shell.zxdg, data->surface);
- zxdg_surface_v6_set_user_data(data->shell_surface.zxdg.surface, data);
- zxdg_surface_v6_add_listener(data->shell_surface.zxdg.surface, &shell_surface_listener_zxdg, data);
+ }
- /* !!! FIXME: add popup role */
- data->shell_surface.zxdg.roleobj.toplevel = zxdg_surface_v6_get_toplevel(data->shell_surface.zxdg.surface);
- zxdg_toplevel_v6_add_listener(data->shell_surface.zxdg.roleobj.toplevel, &toplevel_listener_zxdg, data);
- zxdg_toplevel_v6_set_app_id(data->shell_surface.zxdg.roleobj.toplevel, c->classname);
- } else {
- data->shell_surface.wl = wl_shell_get_shell_surface(c->shell.wl, data->surface);
- wl_shell_surface_set_class(data->shell_surface.wl, c->classname);
- wl_shell_surface_set_user_data(data->shell_surface.wl, data);
- wl_shell_surface_add_listener(data->shell_surface.wl, &shell_surface_listener_wl, data);
+ /* Create the window decorations */
+ if (c->decoration_manager) {
+ data->server_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(c->decoration_manager, data->shell_surface.xdg.roleobj.toplevel);
}
/* Restore state that was set prior to this call */
@@ -919,13 +673,6 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
if (data->shell_surface.xdg.roleobj.toplevel && c->decoration_manager) {
data->server_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(c->decoration_manager, data->shell_surface.xdg.roleobj.toplevel);
}
- } else if (c->shell.zxdg) {
- if (data->shell_surface.zxdg.surface) {
- while (!data->shell_surface.zxdg.initial_configure_seen) {
- WAYLAND_wl_display_flush(c->display);
- WAYLAND_wl_display_dispatch(c->display);
- }
- }
}
/* Unlike the rest of window state we have to set this _after_ flushing the
@@ -981,20 +728,6 @@ void Wayland_HideWindow(_THIS, SDL_Window *window)
xdg_surface_destroy(wind->shell_surface.xdg.surface);
wind->shell_surface.xdg.surface = NULL;
}
- } else if (data->shell.zxdg) {
- if (wind->shell_surface.zxdg.roleobj.toplevel) {
- zxdg_toplevel_v6_destroy(wind->shell_surface.zxdg.roleobj.toplevel);
- wind->shell_surface.zxdg.roleobj.toplevel = NULL;
- }
- if (wind->shell_surface.zxdg.surface) {
- zxdg_surface_v6_destroy(wind->shell_surface.zxdg.surface);
- wind->shell_surface.zxdg.surface = NULL;
- }
- } else {
- if (wind->shell_surface.wl) {
- wl_shell_surface_destroy(wind->shell_surface.wl);
- wind->shell_surface.wl = NULL;
- }
}
}
@@ -1191,7 +924,7 @@ void
Wayland_RestoreWindow(_THIS, SDL_Window * window)
{
SDL_WindowData *wind = window->driverdata;
- const SDL_VideoData *viddata = (const SDL_VideoData *) _this->driverdata;
+ SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata;
/* Set this flag now even if we never actually maximized, eventually
* ShowWindow will take care of it along with the other window state.
@@ -1212,19 +945,9 @@ Wayland_RestoreWindow(_THIS, SDL_Window * window)
return; /* Can't do anything yet, wait for ShowWindow */
}
xdg_toplevel_unset_maximized(wind->shell_surface.xdg.roleobj.toplevel);
- } else if (viddata->shell.zxdg) {
- if (wind->shell_surface.zxdg.roleobj.toplevel == NULL) {
- return; /* Can't do anything yet, wait for ShowWindow */
- }
- zxdg_toplevel_v6_unset_maximized(wind->shell_surface.zxdg.roleobj.toplevel);
- } else {
- if (wind->shell_surface.wl == NULL) {
- return; /* Can't do anything yet, wait for ShowWindow */
- }
- wl_shell_surface_set_toplevel(wind->shell_surface.wl);
}
- WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
+ WAYLAND_wl_display_flush(
(Patch may be truncated, please check the link at the top of this post.)