[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.
This commit is contained in:
Quantum 2022-11-25 13:23:24 -05:00 committed by Geoffrey McRae
parent e1ebde3cd2
commit 60ac03ebaf
2 changed files with 29 additions and 4 deletions

View File

@ -65,15 +65,30 @@ static const struct xdg_surface_listener xdgSurfaceListener = {
static void xdgToplevelConfigure(void * data, struct xdg_toplevel * xdgToplevel, static void xdgToplevelConfigure(void * data, struct xdg_toplevel * xdgToplevel,
int32_t width, int32_t height, struct wl_array * states) int32_t width, int32_t height, struct wl_array * states)
{ {
wlWm.width = width; wlWm.width = width;
wlWm.height = height; wlWm.height = height;
wlWm.fullscreen = false; wlWm.fullscreen = false;
wlWm.floating = true;
enum xdg_toplevel_state * state; enum xdg_toplevel_state * state;
wl_array_for_each(state, states) wl_array_for_each(state, states)
{ {
if (*state == XDG_TOPLEVEL_STATE_FULLSCREEN) switch (*state)
{
case XDG_TOPLEVEL_STATE_FULLSCREEN:
wlWm.fullscreen = true; 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) 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();
} }

View File

@ -112,6 +112,7 @@ struct WaylandDSState
bool fractionalScale; bool fractionalScale;
bool needsResize; bool needsResize;
bool fullscreen; bool fullscreen;
bool floating;
uint32_t resizeSerial; uint32_t resizeSerial;
bool configured; bool configured;
bool warpSupport; bool warpSupport;