From 45a4b3c04758542a99eac60607c2f8203e203caf Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Tue, 17 Oct 2023 22:40:57 -0400 Subject: [PATCH] xwayland: honor initially maximized requests via _NET_WM_STATE X11 clients may request to be initially fullscreen or maximized by setting hints in the _NET_WM_STATE property. For some reason, we are currently only honoring fullscreen requests but not maximize. The fixes issues with GTK apps (notably Firefox, but others as well) not starting maximized. There is a remaining issue that the window position may not be set correctly after unmaximizing. This will be fixed in a follow-up commit. --- src/xwayland.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/xwayland.c b/src/xwayland.c index ca1304dd..88ebcf61 100644 --- a/src/xwayland.c +++ b/src/xwayland.c @@ -508,9 +508,25 @@ xwayland_view_map(struct view *view) view->mapped = true; ensure_initial_geometry_and_output(view); wlr_scene_node_set_enabled(&view->scene_tree->node, true); - if (!view->fullscreen && xwayland_surface->fullscreen) { - view_set_fullscreen(view, true); - } + + /* + * Per the Extended Window Manager Hints (EWMH) spec: "The Window + * Manager SHOULD honor _NET_WM_STATE whenever a withdrawn window + * requests to be mapped." + * + * The following order of operations is intended to reduce the + * number of resize (Configure) events: + * 1. set fullscreen state + * 2. set decorations (depends on fullscreen state) + * 3. set maximized (geometry depends on decorations) + * + * TODO: support separate horizontal/vertical maximize + */ + bool maximize = xwayland_surface->maximized_horz + && xwayland_surface->maximized_vert; + view_set_fullscreen(view, xwayland_surface->fullscreen); + view_set_decorations(view, want_deco(xwayland_surface)); + view_maximize(view, maximize, /*store_natural_geometry*/ true); if (view->surface != xwayland_surface->surface) { if (view->surface) { @@ -538,8 +554,6 @@ xwayland_view_map(struct view *view) } if (!view->been_mapped) { - view_set_decorations(view, want_deco(xwayland_surface)); - if (view_is_floating(view)) { set_initial_position(view, xwayland_surface); }