view: add client_request flag to view->impl->unmap()

This makes explicit the subtle behavioral difference between
xwayland_view_unmap() and handle_unmap().

With this change, the XDG and XWayland versions of handle_map/unmap()
are now identical, which will make further refactoring possible.
This commit is contained in:
John Lindgren 2023-07-01 12:37:47 -04:00 committed by Consolatis
parent b200dd2e7b
commit 370cdc80e0
4 changed files with 22 additions and 18 deletions

View file

@ -34,7 +34,13 @@ struct view_impl {
void (*map)(struct view *view);
void (*set_activated)(struct view *view, bool activated);
void (*set_fullscreen)(struct view *view, bool fullscreen);
void (*unmap)(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 (*maximize)(struct view *view, bool maximize);
void (*minimize)(struct view *view, bool minimize);
void (*move_to_front)(struct view *view);

View file

@ -246,7 +246,7 @@ view_minimize(struct view *view, bool minimized)
}
view->minimized = minimized;
if (minimized) {
view->impl->unmap(view);
view->impl->unmap(view, /* client_request */ false);
_view_set_activated(view, false);
if (view == view->server->focused_view) {
/*

View file

@ -151,7 +151,7 @@ static void
handle_unmap(struct wl_listener *listener, void *data)
{
struct view *view = wl_container_of(listener, view, unmap);
view->impl->unmap(view);
view->impl->unmap(view, /* client_request */ true);
}
static void
@ -452,7 +452,7 @@ xdg_toplevel_view_map(struct view *view)
}
static void
xdg_toplevel_view_unmap(struct view *view)
xdg_toplevel_view_unmap(struct view *view, bool client_request)
{
if (view->mapped) {
view->mapped = false;

View file

@ -183,19 +183,7 @@ static void
handle_unmap(struct wl_listener *listener, void *data)
{
struct view *view = wl_container_of(listener, view, unmap);
view->impl->unmap(view);
/*
* Some xwayland clients leave unmapped child views around, typically
* when a dialog window is closed. Although handle_destroy() is not
* called for these, we have to deal with them as such in terms of the
* foreign-toplevel protocol to avoid panels and the like still showing
* them.
*/
if (view->toplevel.handle) {
wlr_foreign_toplevel_handle_v1_destroy(view->toplevel.handle);
view->toplevel.handle = NULL;
}
view->impl->unmap(view, /* client_request */ true);
}
static void
@ -492,7 +480,7 @@ xwayland_view_map(struct view *view)
}
static void
xwayland_view_unmap(struct view *view)
xwayland_view_unmap(struct view *view, bool client_request)
{
if (!view->mapped) {
return;
@ -501,6 +489,16 @@ xwayland_view_unmap(struct view *view)
wl_list_remove(&view->commit.link);
wlr_scene_node_set_enabled(&view->scene_tree->node, false);
desktop_focus_topmost_mapped_view(view->server);
/*
* If the view was explicitly unmapped by the client (rather
* than just minimized), destroy the foreign toplevel handle so
* the unmapped view doesn't show up in panels and the like.
*/
if (client_request && view->toplevel.handle) {
wlr_foreign_toplevel_handle_v1_destroy(view->toplevel.handle);
view->toplevel.handle = NULL;
}
}
static void