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()`, causing 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 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 committed by Hiroaki Yamamoto
parent 7fabc6afe3
commit 12b6d05481
3 changed files with 13 additions and 37 deletions

View file

@ -190,9 +190,6 @@ handle_output_destroy(struct wl_listener *listener, void *data)
output->workspace_osd = NULL;
}
/* save the last placement before clearing view->output */
views_save_last_placement(server);
struct view *view;
wl_list_for_each(view, &server->views, link) {
if (view->output == output) {
@ -662,7 +659,6 @@ output_config_apply(struct server *server,
{
bool success = true;
server->pending_output_layout_change++;
views_save_last_placement(server);
struct wlr_output_configuration_head_v1 *head;
wl_list_for_each(head, &config->heads, link) {