]> git.mdlowis.com Git - proto/labwc.git/commitdiff
xwayland: honor initially maximized requests via _NET_WM_STATE
authorJohn Lindgren <john@jlindgren.net>
Wed, 18 Oct 2023 02:40:57 +0000 (22:40 -0400)
committerJohan Malm <johanmalm@users.noreply.github.com>
Wed, 18 Oct 2023 18:49:53 +0000 (19:49 +0100)
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

index ca1304dd06d658b789a75d60da0d0aef1f888170..88ebcf61e228f82750659bc994a372af46b25e3d 100644 (file)
@@ -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);
                }