From: Johan Malm Date: Sat, 20 May 2023 09:20:36 +0000 (+0100) Subject: window-rules: add skipTaskbar and skipWindowSwitcher X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=a6f0fc9c6293dfa21c293fdc58b759c01e998403;p=proto%2Flabwc.git window-rules: add skipTaskbar and skipWindowSwitcher --- diff --git a/docs/labwc-config.5.scd b/docs/labwc-config.5.scd index 730af280..e2c23cac 100644 --- a/docs/labwc-config.5.scd +++ b/docs/labwc-config.5.scd @@ -430,6 +430,15 @@ situation. *serverDecoration* over-rules any other setting for server-side window decoration on first map. +** [yes|no|default] + *skipTaskbar* removes window foreign-toplevel protocol handle so that + it does not appear in clients such as panels and taskbars using that + protocol. + +** [yes|no|default] + *skipWindowSwitcher* removes window from the Window Switcher (alt-tab + on-screen-display) + ## ENVIRONMENT VARIABLES *XCURSOR_THEME* and *XCURSOR_SIZE* are supported to set cursor theme diff --git a/include/window-rules.h b/include/window-rules.h index 9a002d08..4d983df0 100644 --- a/include/window-rules.h +++ b/include/window-rules.h @@ -26,6 +26,8 @@ struct window_rule { struct wl_list actions; enum property server_decoration; + enum property skip_taskbar; + enum property skip_window_switcher; struct wl_list link; /* struct rcxml.window_rules */ }; diff --git a/src/config/rcxml.c b/src/config/rcxml.c index 03e15940..b168e0b6 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -110,6 +110,10 @@ fill_window_rule(char *nodename, char *content) /* Properties */ } else if (!strcasecmp(nodename, "serverDecoration")) { set_property(content, ¤t_window_rule->server_decoration); + } else if (!strcasecmp(nodename, "skipTaskbar")) { + set_property(content, ¤t_window_rule->skip_taskbar); + } else if (!strcasecmp(nodename, "skipWindowSwitcher")) { + set_property(content, ¤t_window_rule->skip_window_switcher); /* Actions */ } else if (!strcmp(nodename, "name.action")) { diff --git a/src/desktop.c b/src/desktop.c index bab5d725..9493b696 100644 --- a/src/desktop.c +++ b/src/desktop.c @@ -9,6 +9,7 @@ #include "node.h" #include "ssd.h" #include "view.h" +#include "window-rules.h" #include "workspaces.h" #include "xwayland.h" @@ -191,7 +192,9 @@ desktop_cycle_view(struct server *server, struct view *start_view, continue; } view = node_view_from_node(node); - if (isfocusable(view)) { + + enum property skip = window_rules_get_property(view, "skipWindowSwitcher"); + if (isfocusable(view) && skip != LAB_PROP_TRUE) { return view; } } while (view != start_view); diff --git a/src/osd.c b/src/osd.c index f5ce9199..882a3419 100644 --- a/src/osd.c +++ b/src/osd.c @@ -15,6 +15,7 @@ #include "theme.h" #include "node.h" #include "view.h" +#include "window-rules.h" #include "workspaces.h" #define OSD_ITEM_HEIGHT (20) @@ -69,7 +70,8 @@ get_osd_height(struct wl_list *node_list) continue; } view = node_view_from_node(node); - if (!isfocusable(view)) { + enum property skip = window_rules_get_property(view, "skipWindowSwitcher"); + if (!isfocusable(view) || skip == LAB_PROP_TRUE) { continue; } height += OSD_ITEM_HEIGHT; @@ -344,7 +346,8 @@ render_osd(struct server *server, cairo_t *cairo, int w, int h, continue; } struct view *view = node_view_from_node(node); - if (!isfocusable(view)) { + enum property skip = window_rules_get_property(view, "skipWindowSwitcher"); + if (!isfocusable(view) || skip == LAB_PROP_TRUE) { continue; } diff --git a/src/view-impl-common.c b/src/view-impl-common.c index ce227537..b39fb517 100644 --- a/src/view-impl-common.c +++ b/src/view-impl-common.c @@ -34,6 +34,22 @@ view_impl_map(struct view *view) if (!view->been_mapped) { window_rules_apply(view, LAB_WINDOW_RULE_EVENT_ON_FIRST_MAP); } + + /* + * 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 + */ + enum property ret = window_rules_get_property(view, "skipTaskbar"); + if (ret == LAB_PROP_TRUE) { + if (view->toplevel.handle) { + wlr_foreign_toplevel_handle_v1_destroy(view->toplevel.handle); + } + } + + wlr_log(WLR_DEBUG, "[map] identifier=%s, title=%s\n", + view_get_string_prop(view, "app_id"), + view_get_string_prop(view, "title")); } static bool diff --git a/src/window-rules.c b/src/window-rules.c index 899f89c1..7b366da0 100644 --- a/src/window-rules.c +++ b/src/window-rules.c @@ -81,10 +81,17 @@ window_rules_get_property(struct view *view, const char *property) * for. */ if (view_matches_criteria(rule, view)) { - if (!strcasecmp(property, "serverDecoration")) { - if (rule->server_decoration) { - return rule->server_decoration; - } + if (rule->server_decoration + && !strcasecmp(property, "serverDecoration")) { + return rule->server_decoration; + } + if (rule->skip_taskbar + && !strcasecmp(property, "skipTaskbar")) { + return rule->skip_taskbar; + } + if (rule->skip_window_switcher + && !strcasecmp(property, "skipWindowSwitcher")) { + return rule->skip_window_switcher; } } }