xdg: destroy foreign toplevel handle on unmap

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.
This commit is contained in:
tokyo4j 2024-08-13 10:02:46 +09:00 committed by Johan Malm
parent f31457392b
commit 8b12b50137

View file

@ -651,8 +651,6 @@ xdg_toplevel_view_map(struct view *view)
struct wlr_xdg_surface *xdg_surface = xdg_surface_from_view(view); struct wlr_xdg_surface *xdg_surface = xdg_surface_from_view(view);
wlr_scene_node_set_enabled(&view->scene_tree->node, true); wlr_scene_node_set_enabled(&view->scene_tree->node, true);
if (!view->been_mapped) { if (!view->been_mapped) {
init_foreign_toplevel(view);
if (view_wants_decorations(view)) { if (view_wants_decorations(view)) {
view_set_ssd_mode(view, LAB_SSD_MODE_FULL); view_set_ssd_mode(view, LAB_SSD_MODE_FULL);
} else { } else {
@ -687,6 +685,11 @@ xdg_toplevel_view_map(struct view *view)
view_moved(view); view_moved(view);
} }
if (!view->toplevel.handle) {
init_foreign_toplevel(view);
foreign_toplevel_update_outputs(view);
}
view_impl_map(view); view_impl_map(view);
view->been_mapped = true; 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); wlr_scene_node_set_enabled(&view->scene_tree->node, false);
view_impl_unmap(view); 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 static pid_t