From ebd39dfe0d1ded5af933075f5400909c9d2a2c99 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Sat, 23 Aug 2025 10:44:26 -0400 Subject: [PATCH] view: respect client-initiated resize of non-maximized axis 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 | 4 ++-- src/view.c | 27 +++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/interactive.c b/src/interactive.c index b50d27a4..8a8903da 100644 --- a/src/interactive.c +++ b/src/interactive.c @@ -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); } diff --git a/src/view.c b/src/view.c index a81b03ad..8ddef7d4 100644 --- a/src/view.c +++ b/src/view.c @@ -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