view: fix error messages on region or usable area changes

f58b532 implemented output-relative position saving/restoring on output
un-plugging/re-plugging. It worked as follows:

1. Store the output-relative view geometry in `view->last_placement`
  (if not set) before adding/removing an output from the layout.
2. After adding/removing an output, call `view_adjust_for_layout_change()`
  after the layout change to restore the output-relative view geometry
  based on `view->last_placement`.

However, it didn't consider `view_adjust_for_layout_change()` being
called from other places such as `regions_reconfigure()` and
`output_update_all_usable_areas()`. In such cases,
`view->last_placement` is empty and it emits an error message "view has
no last placement info". This can happen when a panel is mapped or
unmapped, or on Reconfigure.

This commit fixes it by changing the life cycle of
`view->last_placement`. It used to be set only before output layout
changes and cleared on user-initiated moves/resizes, but now it is
always set and updated on user-initiated moves/resizes. I think this is
more intuitive, too.
This commit is contained in:
tokyo4j 2026-01-28 14:28:34 +09:00
parent 55a256f2fa
commit f21d3c7d34
3 changed files with 11 additions and 36 deletions

View file

@ -214,11 +214,13 @@ struct view {
*/
struct wlr_box natural_geometry;
/*
* last_placement represents the last view position set by the user
* before layout changes. output_name and relative_geo are used to
* keep or restore the view position relative to the output and
* layout_geo is used to keep the global position when the output is
* lost.
* last_placement represents the last view position set by the user.
* This is used to keep or restore the view position when the output
* layout changes.
*
* output_name and relative_geo are used to keep or restore the view
* position relative to the output and layout_geo is used to keep the
* global position when the output is lost.
*/
struct {
char *output_name;
@ -542,7 +544,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 views_save_last_placement(struct server *server);
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);