view: rework saving/restoring geometry across layout changes

After several iterations, this is basically a complete re-work. The old
implementation was difficult to follow and sometimes failed to restore
fullscreen/maximized/tiled geometry correctly, since it was based
entirely on natural (floating) geometry.

The new implementation:
 - always saves the actual (pending) geometry at first layout change
 - explicitly tracks whether a view has moved between outputs
 - consolidates invalidating the saved geometry into one place, rather
   than having lots of invalidate() calls sprinkled everywhere
This commit is contained in:
John Lindgren 2026-01-11 13:03:23 -05:00 committed by Hiroaki Yamamoto
parent c1c156ef39
commit 20929c0484
3 changed files with 55 additions and 131 deletions

View file

@ -215,11 +215,14 @@ struct view {
struct wlr_box natural_geometry;
/*
* Whenever an output layout change triggers a view relocation, the
* last pending position (or natural geometry) will be saved so the
* view may be restored to its original location on a subsequent layout
* change.
* last pending position will be saved so the view may be restored
* to its original location on a subsequent layout change.
*/
struct wlr_box last_layout_geometry;
/* Set temporarily when moving view due to layout change */
bool adjusting_for_layout_change;
/* True if original output was disconnected or disabled */
bool lost_output_due_to_layout_change;
/* used by xdg-shell views */
uint32_t pending_configure_serial;
@ -533,7 +536,6 @@ bool view_titlebar_visible(struct view *view);
void view_set_ssd_mode(struct view *view, enum lab_ssd_mode mode);
void view_set_decorations(struct view *view, enum lab_ssd_mode mode, bool force_ssd);
void view_toggle_fullscreen(struct view *view);
void view_invalidate_last_layout_geometry(struct view *view);
void view_adjust_for_layout_change(struct view *view);
void view_move_to_edge(struct view *view, enum lab_edge direction, bool snap_to_windows);
void view_grow_to_edge(struct view *view, enum lab_edge direction);