From 4b0903cfa9c40f323227a74640dddec03d2672ba Mon Sep 17 00:00:00 2001 From: tokyo4j Date: Sun, 23 Nov 2025 14:37:12 +0900 Subject: [PATCH] view: deduplicate foreign-toplevel creation code --- include/view-impl-common.h | 2 -- src/view-impl-common.c | 38 ++++++++++++-------------------------- src/xdg.c | 8 -------- src/xwayland.c | 13 ------------- 4 files changed, 12 insertions(+), 49 deletions(-) diff --git a/include/view-impl-common.h b/include/view-impl-common.h index 5c5f90f7..31513b5a 100644 --- a/include/view-impl-common.h +++ b/include/view-impl-common.h @@ -10,8 +10,6 @@ struct view; -void view_impl_init_foreign_toplevel(struct view *view); - void view_impl_map(struct view *view); void view_impl_unmap(struct view *view); diff --git a/src/view-impl-common.c b/src/view-impl-common.c index cf23a798..8f4e2795 100644 --- a/src/view-impl-common.c +++ b/src/view-impl-common.c @@ -6,24 +6,6 @@ #include "view.h" #include "window-rules.h" -void -view_impl_init_foreign_toplevel(struct view *view) -{ - if (view->foreign_toplevel) { - return; - } - - view->foreign_toplevel = foreign_toplevel_create(view); - - if (view->impl->get_parent) { - struct view *parent = view->impl->get_parent(view); - if (parent && parent->foreign_toplevel) { - foreign_toplevel_set_parent(view->foreign_toplevel, - parent->foreign_toplevel); - } - } -} - void view_impl_map(struct view *view) { @@ -34,15 +16,19 @@ view_impl_map(struct view *view) } /* - * It's tempting to just never create the foreign-toplevel handle in the - * map handlers, but the app_id/title might not have been set at that - * point, so it's safer to process the property here + * Create foreign-toplevel handle, respecting skipTaskbar rules. + * Also exclude unfocusable views (popups, floating toolbars, + * etc.) as these should not be shown in taskbars/docks/etc. */ - enum property ret = window_rules_get_property(view, "skipTaskbar"); - if (ret == LAB_PROP_TRUE) { - if (view->foreign_toplevel) { - foreign_toplevel_destroy(view->foreign_toplevel); - view->foreign_toplevel = NULL; + if (!view->foreign_toplevel && view_is_focusable(view) + && window_rules_get_property(view, "skipTaskbar") + != LAB_PROP_TRUE) { + view->foreign_toplevel = foreign_toplevel_create(view); + + struct view *parent = view->impl->get_parent(view); + if (parent && parent->foreign_toplevel) { + foreign_toplevel_set_parent(view->foreign_toplevel, + parent->foreign_toplevel); } } diff --git a/src/xdg.c b/src/xdg.c index b763c03b..f11d522c 100644 --- a/src/xdg.c +++ b/src/xdg.c @@ -760,14 +760,6 @@ handle_map(struct wl_listener *listener, void *data) view->mapped = true; - if (!view->foreign_toplevel) { - view_impl_init_foreign_toplevel(view); - /* - * Initial outputs will be synced via - * view->events.new_outputs on view_moved() - */ - } - if (!view->been_mapped) { if (view_wants_decorations(view)) { view_set_ssd_mode(view, LAB_SSD_MODE_FULL); diff --git a/src/xwayland.c b/src/xwayland.c index 528ee85d..4be48c69 100644 --- a/src/xwayland.c +++ b/src/xwayland.c @@ -832,19 +832,6 @@ handle_map(struct wl_listener *listener, void *data) view->content_tree = tree; } - /* - * Exclude unfocusable views from wlr-foreign-toplevel. These - * views (notifications, floating toolbars, etc.) should not be - * shown in taskbars/docks/etc. - */ - if (!view->foreign_toplevel && view_is_focusable(view)) { - view_impl_init_foreign_toplevel(view); - /* - * Initial outputs will be synced via - * view->events.new_outputs on view_moved() - */ - } - if (!view->been_mapped) { check_natural_geometry(view); set_initial_position(view, xwayland_surface);