]> git.mdlowis.com Git - proto/labwc.git/commitdiff
view: add client_request flag to view->impl->unmap()
authorJohn Lindgren <john@jlindgren.net>
Sat, 1 Jul 2023 16:37:47 +0000 (12:37 -0400)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Sat, 1 Jul 2023 21:07:39 +0000 (23:07 +0200)
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.

include/view.h
src/view.c
src/xdg.c
src/xwayland.c

index 1a8e43148bc790937460ecce2828edfe2ef3422d..0ea801679c50885e3b12e20710cfb3d381eb11e7 100644 (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);
index e22e264c7ac969a4bed7f609972edfc7f5bc2dec..8e85fc21ed01d4cacc6ba339c5690f95b043d037 100644 (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) {
                        /*
index 0df83b04403c1f9592466f7c53347b9329034e2b..b397587a6a8604b3217c257832b0d12eacea45af 100644 (file)
--- 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;
index cb9af47c774292bdcec9ed8d2df9567e14a2f93a..6e1c7b83f3732d6b4610f6f8c980ce44071e9fba 100644 (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