]> git.mdlowis.com Git - proto/labwc.git/commitdiff
xdg: destroy foreign toplevel handle on unmap
authortokyo4j <hrak1529@gmail.com>
Tue, 13 Aug 2024 01:02:46 +0000 (10:02 +0900)
committerJohan Malm <johanmalm@users.noreply.github.com>
Fri, 16 Aug 2024 20:38:15 +0000 (21:38 +0100)
xdg-shell protocol says:
    All active operations (e.g., move, resize) are canceled and all
    attributes (e.g. title, state, stacking, ...) are discarded for an
    xdg_toplevel surface when it is unmapped.
So, when a xdg-toplevel is unmapped (not minimized), the corresponding
foreign handler should be destroyed to reset attributes.

src/xdg.c

index b75f864f8bb29b3da3726e372fe6dc950e1ab00e..23bceba25b8012a237b77f69535fe7b7c3050091 100644 (file)
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -651,8 +651,6 @@ xdg_toplevel_view_map(struct view *view)
        struct wlr_xdg_surface *xdg_surface = xdg_surface_from_view(view);
        wlr_scene_node_set_enabled(&view->scene_tree->node, true);
        if (!view->been_mapped) {
-               init_foreign_toplevel(view);
-
                if (view_wants_decorations(view)) {
                        view_set_ssd_mode(view, LAB_SSD_MODE_FULL);
                } else {
@@ -687,6 +685,11 @@ xdg_toplevel_view_map(struct view *view)
                view_moved(view);
        }
 
+       if (!view->toplevel.handle) {
+               init_foreign_toplevel(view);
+               foreign_toplevel_update_outputs(view);
+       }
+
        view_impl_map(view);
        view->been_mapped = true;
 }
@@ -699,6 +702,15 @@ xdg_toplevel_view_unmap(struct view *view, bool client_request)
                wlr_scene_node_set_enabled(&view->scene_tree->node, false);
                view_impl_unmap(view);
        }
+
+       /*
+        * 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);
+       }
 }
 
 static pid_t