From: John Lindgren Date: Sat, 1 Jul 2023 16:37:47 +0000 (-0400) Subject: view: add client_request flag to view->impl->unmap() X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=370cdc80e018876e732ec84a4a1dbd6e5bd206d3;p=proto%2Flabwc.git 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. --- diff --git a/include/view.h b/include/view.h index 1a8e4314..0ea80167 100644 --- a/include/view.h +++ b/include/view.h @@ -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); diff --git a/src/view.c b/src/view.c index e22e264c..8e85fc21 100644 --- a/src/view.c +++ b/src/view.c @@ -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) { /* diff --git a/src/xdg.c b/src/xdg.c index 0df83b04..b397587a 100644 --- a/src/xdg.c +++ b/src/xdg.c @@ -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; diff --git a/src/xwayland.c b/src/xwayland.c index cb9af47c..6e1c7b83 100644 --- a/src/xwayland.c +++ b/src/xwayland.c @@ -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