window-rules: add skipTaskbar and skipWindowSwitcher

This commit is contained in:
Johan Malm 2023-05-20 10:20:36 +01:00 committed by Johan Malm
parent 15cd093f2e
commit a6f0fc9c62
7 changed files with 51 additions and 7 deletions

View file

@ -430,6 +430,15 @@ situation.
*serverDecoration* over-rules any other setting for server-side window
decoration on first map.
*<windowRules><windowRule skipTaskbar="">* [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.
*<windowRules><windowRule skipWindowSwitcher="">* [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

View file

@ -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 */
};

View file

@ -110,6 +110,10 @@ fill_window_rule(char *nodename, char *content)
/* Properties */
} else if (!strcasecmp(nodename, "serverDecoration")) {
set_property(content, &current_window_rule->server_decoration);
} else if (!strcasecmp(nodename, "skipTaskbar")) {
set_property(content, &current_window_rule->skip_taskbar);
} else if (!strcasecmp(nodename, "skipWindowSwitcher")) {
set_property(content, &current_window_rule->skip_window_switcher);
/* Actions */
} else if (!strcmp(nodename, "name.action")) {

View file

@ -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);

View file

@ -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;
}

View file

@ -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

View file

@ -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;
}
}
}