view: separate (un)minimize and (un)map logic

Map/unmap logic is currently re-used for minimize/unminimize, but lots
of it doesn't actually apply in that case. This is both confusing and
creates some extra complexity, such as:

 - extra "client_request" parameter to unmap(), in which case it has to
   still do some cleanup even if view->mapped is already false

 - various "view->mapped || view->minimized" checks when we really just
   mean "is the view mapped"

To clean this all up, let's put the logic that really is common into
a new view_update_visiblity() function, and stop using map/unmap for
minimize/unminimize.

Note that this changes the meaning of "view->mapped", which used to
mean "mapped and not minimized" but now really just means "mapped".
I left some "view->mapped" conditions as-is (rather than changing to
"view->mapped && !view->minimized") where it seemed to make sense.

v2: add view_update_visibility() as suggested by tokyo4j
This commit is contained in:
John Lindgren 2025-11-20 19:41:00 -05:00 committed by Hiroaki Yamamoto
parent 20087e89b2
commit b5e2eb216e
6 changed files with 75 additions and 110 deletions

View file

@ -110,13 +110,7 @@ struct view_impl {
void (*set_activated)(struct view *view, bool activated);
void (*set_fullscreen)(struct view *view, bool fullscreen);
void (*notify_tiled)(struct view *view);
/*
* client_request is true if the client unmapped its own
* surface; false if we are just minimizing the view. The two
* cases are similar but have subtle differences (e.g., when
* minimizing we don't destroy the foreign toplevel handle).
*/
void (*unmap)(struct view *view, bool client_request);
void (*unmap)(struct view *view);
void (*maximize)(struct view *view, enum view_axis maximized);
void (*minimize)(struct view *view, bool minimize);
struct view *(*get_parent)(struct view *self);
@ -591,6 +585,7 @@ void view_adjust_size(struct view *view, int *w, int *h);
void view_evacuate_region(struct view *view);
void view_on_output_destroy(struct view *view);
void view_connect_map(struct view *view, struct wlr_surface *surface);
void view_update_visibility(struct view *view);
void view_init(struct view *view);
void view_destroy(struct view *view);