]> git.mdlowis.com Git - proto/labwc.git/commitdiff
xdg: Save natural_geometry.x/y with initially maximized view
authorJohn Lindgren <john@jlindgren.net>
Sat, 18 Feb 2023 05:55:42 +0000 (00:55 -0500)
committerJohn Lindgren <john@jlindgren.net>
Mon, 20 Feb 2023 16:50:12 +0000 (11:50 -0500)
Fixes an issue where, if Thunar was started maximized, it would
un-maximize to the top-left corner rather than the center.

src/xdg.c

index 99b54b75d1e664bd05d364bbe55a86f943f8a949..1d1496cc87ba723369024b79a3f1acae39512dfa 100644 (file)
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -332,6 +332,19 @@ xdg_toplevel_view_map(struct view *view)
                                xdg_surface->current.geometry.height;
                }
 
+               /*
+                * Set initial "pending" position for floating views.
+                * Do this before view_set_fullscreen/view_maximize() so
+                * that the position is saved with the natural geometry.
+                *
+                * FIXME: the natural geometry is not saved if either
+                * handle_request_fullscreen/handle_request_maximize()
+                * is called before map (try "foot --maximized").
+                */
+               if (view_is_floating(view)) {
+                       position_xdg_toplevel_view(view);
+               }
+
                if (!view->fullscreen && requested->fullscreen) {
                        struct output *output = output_from_wlr_output(
                                view->server, requested->fullscreen_output);
@@ -339,10 +352,15 @@ xdg_toplevel_view_map(struct view *view)
                } else if (!view->maximized && requested->maximized) {
                        view_maximize(view, true,
                                /*store_natural_geometry*/ true);
-               } else if (view_is_floating(view)) {
-                       position_xdg_toplevel_view(view);
                }
 
+               /*
+                * Set initial "current" position directly before
+                * calling view_moved() to reduce flicker
+                */
+               view->current.x = view->pending.x;
+               view->current.y = view->pending.y;
+
                view_moved(view);
                view->been_mapped = true;
        }