]> git.mdlowis.com Git - proto/labwc.git/commitdiff
view: respect client-initiated resize of non-maximized axis
authorJohn Lindgren <john@jlindgren.net>
Sat, 23 Aug 2025 14:44:26 +0000 (10:44 -0400)
committerHiroaki Yamamoto <hrak1529@gmail.com>
Sun, 24 Aug 2025 14:05:59 +0000 (23:05 +0900)
When implementing single-axis maximize some time ago, I made the
simplifying assumption that a view couldn't be resized while maximized
(even in only one axis). And indeed for compositor-initiated resize,
we always unmaximize the view first.

However, I didn't account for the client resizing the non-maximized
axis, which we can't (and shouldn't) prevent. When this happens, we
should also update the natural geometry of that single axis so that we
don't undo the resize when un-maximizing.

P.S. xdg-shell clients resizing the *maximized* axis is still an
unsolved problem, exacerbated by the fact that xdg-shell protocol
doesn't allow clients to even know about single-axis maximize.

P.P.S. the view_invalidate_last_layout_geometry() logic may need
similar updates, I'm not sure.

src/interactive.c
src/view.c

index b50d27a4e1abc04ef37165679b0fc6bd144c4ffc..8a8903da356b829d4ae95c7138f87ff7bd6e21d3 100644 (file)
@@ -90,9 +90,9 @@ interactive_begin(struct view *view, enum input_mode mode, uint32_t edges)
                        return;
                }
 
+               /* Store natural geometry at start of move */
+               view_store_natural_geometry(view);
                if (view_is_floating(view)) {
-                       /* Store natural geometry at start of move */
-                       view_store_natural_geometry(view);
                        view_invalidate_last_layout_geometry(view);
                }
 
index a81b03ad0839fd6493fd65d687572aeb86cc12ae..8ddef7d4aee64ee523c70fbf5cd0a2d0dfd79c7c 100644 (file)
@@ -971,8 +971,11 @@ void
 view_store_natural_geometry(struct view *view)
 {
        assert(view);
-       if (!view_is_floating(view)) {
-               /* Do not overwrite the stored geometry with special cases */
+       /*
+        * Do not overwrite the stored geometry if fullscreen or tiled.
+        * Maximized views are handled on a per-axis basis (see below).
+        */
+       if (view->fullscreen || view_is_tiled(view)) {
                return;
        }
 
@@ -983,7 +986,14 @@ view_store_natural_geometry(struct view *view)
         * xdg-toplevel configure event, which means the application should
         * choose its own size.
         */
-       view->natural_geometry = view->pending;
+       if (!(view->maximized & VIEW_AXIS_HORIZONTAL)) {
+               view->natural_geometry.x = view->pending.x;
+               view->natural_geometry.width = view->pending.width;
+       }
+       if (!(view->maximized & VIEW_AXIS_VERTICAL)) {
+               view->natural_geometry.y = view->pending.y;
+               view->natural_geometry.height = view->pending.height;
+       }
 }
 
 int
@@ -1472,11 +1482,20 @@ view_maximize(struct view *view, enum view_axis axis,
                 */
                interactive_cancel(view);
                if (store_natural_geometry && view_is_floating(view)) {
-                       view_store_natural_geometry(view);
                        view_invalidate_last_layout_geometry(view);
                }
        }
 
+       /*
+        * Update natural geometry for any axis that wasn't already
+        * maximized. This is needed even when unmaximizing, because in
+        * single-axis cases the client may have resized the other axis
+        * while one axis was maximized.
+        */
+       if (store_natural_geometry) {
+               view_store_natural_geometry(view);
+       }
+
        /*
         * When natural geometry is unknown (0x0) for an xdg-shell view,
         * we normally send a configure event of 0x0 to get the client's