wayland: Add support for maximized/restored events
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
index a154785..cbd7325 100644
--- a/src/video/wayland/SDL_waylandwindow.c
+++ b/src/video/wayland/SDL_waylandwindow.c
@@ -272,9 +272,12 @@ handle_configure_zxdg_toplevel(void *data,
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;
}
}
@@ -283,6 +286,7 @@ handle_configure_zxdg_toplevel(void *data,
/* 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) {
@@ -310,6 +314,19 @@ handle_configure_zxdg_toplevel(void *data,
}
}
+ /* 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;
@@ -388,9 +405,12 @@ handle_configure_xdg_toplevel(void *data,
enum xdg_toplevel_state *state;
SDL_bool fullscreen = SDL_FALSE;
+ SDL_bool maximized = SDL_FALSE;
wl_array_for_each(state, states) {
if (*state == XDG_TOPLEVEL_STATE_FULLSCREEN) {
fullscreen = SDL_TRUE;
+ } else if (*state == XDG_TOPLEVEL_STATE_MAXIMIZED) {
+ maximized = SDL_TRUE;
}
}
@@ -399,6 +419,7 @@ handle_configure_xdg_toplevel(void *data,
/* 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) {
@@ -426,6 +447,19 @@ handle_configure_xdg_toplevel(void *data,
}
}
+ /* 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 xdg-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;