view: deduplicate foreign-toplevel creation code

This commit is contained in:
tokyo4j 2025-11-23 14:37:12 +09:00 committed by John Lindgren
parent 3c0e010c58
commit 4b0903cfa9
4 changed files with 12 additions and 49 deletions

View file

@ -10,8 +10,6 @@
struct view; struct view;
void view_impl_init_foreign_toplevel(struct view *view);
void view_impl_map(struct view *view); void view_impl_map(struct view *view);
void view_impl_unmap(struct view *view); void view_impl_unmap(struct view *view);

View file

@ -6,24 +6,6 @@
#include "view.h" #include "view.h"
#include "window-rules.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 void
view_impl_map(struct view *view) 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 * Create foreign-toplevel handle, respecting skipTaskbar rules.
* map handlers, but the app_id/title might not have been set at that * Also exclude unfocusable views (popups, floating toolbars,
* point, so it's safer to process the property here * etc.) as these should not be shown in taskbars/docks/etc.
*/ */
enum property ret = window_rules_get_property(view, "skipTaskbar"); if (!view->foreign_toplevel && view_is_focusable(view)
if (ret == LAB_PROP_TRUE) { && window_rules_get_property(view, "skipTaskbar")
if (view->foreign_toplevel) { != LAB_PROP_TRUE) {
foreign_toplevel_destroy(view->foreign_toplevel); view->foreign_toplevel = foreign_toplevel_create(view);
view->foreign_toplevel = NULL;
struct view *parent = view->impl->get_parent(view);
if (parent && parent->foreign_toplevel) {
foreign_toplevel_set_parent(view->foreign_toplevel,
parent->foreign_toplevel);
} }
} }

View file

@ -760,14 +760,6 @@ handle_map(struct wl_listener *listener, void *data)
view->mapped = true; 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->been_mapped) {
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);

View file

@ -832,19 +832,6 @@ handle_map(struct wl_listener *listener, void *data)
view->content_tree = tree; 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) { if (!view->been_mapped) {
check_natural_geometry(view); check_natural_geometry(view);
set_initial_position(view, xwayland_surface); set_initial_position(view, xwayland_surface);