From 60ac03ebafaf8f8f2850698218070d2acfee252f Mon Sep 17 00:00:00 2001 From: Quantum Date: Fri, 25 Nov 2022 13:23:24 -0500 Subject: [PATCH] [client] wayland: implement window size setting for xdg-shell This should allow win:autoResize to work on Wayland when the compositor supports such an operation. --- client/displayservers/Wayland/shell_xdg.c | 32 ++++++++++++++++++++--- client/displayservers/Wayland/wayland.h | 1 + 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/client/displayservers/Wayland/shell_xdg.c b/client/displayservers/Wayland/shell_xdg.c index 41fd324c..543e4dda 100644 --- a/client/displayservers/Wayland/shell_xdg.c +++ b/client/displayservers/Wayland/shell_xdg.c @@ -65,15 +65,30 @@ static const struct xdg_surface_listener xdgSurfaceListener = { static void xdgToplevelConfigure(void * data, struct xdg_toplevel * xdgToplevel, int32_t width, int32_t height, struct wl_array * states) { - wlWm.width = width; - wlWm.height = height; + wlWm.width = width; + wlWm.height = height; wlWm.fullscreen = false; + wlWm.floating = true; enum xdg_toplevel_state * state; wl_array_for_each(state, states) { - if (*state == XDG_TOPLEVEL_STATE_FULLSCREEN) + switch (*state) + { + case XDG_TOPLEVEL_STATE_FULLSCREEN: wlWm.fullscreen = true; + // fallthrough + case XDG_TOPLEVEL_STATE_MAXIMIZED: + case XDG_TOPLEVEL_STATE_TILED_LEFT: + case XDG_TOPLEVEL_STATE_TILED_RIGHT: + case XDG_TOPLEVEL_STATE_TILED_TOP: + case XDG_TOPLEVEL_STATE_TILED_BOTTOM: + wlWm.floating = false; + break; + + default: + break; + } } } @@ -156,5 +171,14 @@ void waylandMinimize(void) void waylandShellResize(int w, int h) { - //TODO: Implement resize for XDG. + if (!wlWm.floating) + return; + + wlWm.width = w; + wlWm.height = h; + xdg_surface_set_window_geometry(wlWm.xdgSurface, 0, 0, w, h); + + wlWm.needsResize = true; + app_invalidateWindow(true); + waylandStopWaitFrame(); } diff --git a/client/displayservers/Wayland/wayland.h b/client/displayservers/Wayland/wayland.h index 72268585..8cc780ef 100644 --- a/client/displayservers/Wayland/wayland.h +++ b/client/displayservers/Wayland/wayland.h @@ -112,6 +112,7 @@ struct WaylandDSState bool fractionalScale; bool needsResize; bool fullscreen; + bool floating; uint32_t resizeSerial; bool configured; bool warpSupport;