From 5825db86b7bc31b302c137b057217b514b2dfac6 Mon Sep 17 00:00:00 2001 From: Grigory Kirillov Date: Sat, 11 May 2024 22:40:27 +0300 Subject: [PATCH] xwayland: add sensible rules for NET_WM_WINDOW_TYPE_DESKTOP windows --- docs/labwc-config.5.scd | 10 ++++++++++ include/window-rules.h | 1 + src/config/rcxml.c | 30 +++++++++++++++++++----------- src/window-rules.c | 21 +++++++++++++++++++++ 4 files changed, 51 insertions(+), 11 deletions(-) diff --git a/docs/labwc-config.5.scd b/docs/labwc-config.5.scd index d86634a8..4b6e1681 100644 --- a/docs/labwc-config.5.scd +++ b/docs/labwc-config.5.scd @@ -891,6 +891,16 @@ situation. can be caused by ** settings or exclusive layer-shell clients such as panels. +*Window type rules* + +To make X11 desktop managers work more seamless in a Wayland environment, labwc +sets a special window rule by default, targeting EWMH desktop windows +(NET_WM_WINDOW_TYPE_DESKTOP). It sets these windows to have the properties that +would normally be expected from a desktop manager, like *skipTaskbar*, +*skipWindowSwitcher*, *fixedPosition*, *ToggleAlwaysOnBottom*, etc. + +Default window rules can be removed with ``. + ## MENU ``` diff --git a/include/window-rules.h b/include/window-rules.h index 17c5dca3..675b20c2 100644 --- a/include/window-rules.h +++ b/include/window-rules.h @@ -44,5 +44,6 @@ struct view; void window_rules_apply(struct view *view, enum window_rule_event event); enum property window_rules_get_property(struct view *view, const char *property); +void create_default_window_type_rules(void); #endif /* LABWC_WINDOW_RULES_H */ diff --git a/src/config/rcxml.c b/src/config/rcxml.c index 1e268f47..362e202a 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -161,10 +161,26 @@ set_property(const char *str, enum property *variable) *variable = ret ? LAB_PROP_TRUE : LAB_PROP_FALSE; } +static void +rule_destroy(struct window_rule *rule) +{ + wl_list_remove(&rule->link); + zfree(rule->identifier); + zfree(rule->title); + action_list_free(&rule->actions); + zfree(rule); +} + static void fill_window_rule(char *nodename, char *content) { - if (!strcasecmp(nodename, "windowRule.windowRules")) { + if (!strcasecmp(nodename, "clear.windowRules")) { + struct window_rule *rule, *rule_tmp; + wl_list_for_each_safe(rule, rule_tmp, &rc.window_rules, link) { + rule_destroy(rule); + } + return; + } else if (!strcasecmp(nodename, "windowRule.windowRules")) { current_window_rule = znew(*current_window_rule); current_window_rule->window_type = -1; // Window types are >= 0 wl_list_append(&rc.window_rules, ¤t_window_rule->link); @@ -1242,6 +1258,8 @@ rcxml_init(void) rc.workspace_config.min_nr_workspaces = 1; rc.menu_ignore_button_release_period = 250; + + create_default_window_type_rules(); } static void @@ -1470,16 +1488,6 @@ post_processing(void) } } -static void -rule_destroy(struct window_rule *rule) -{ - wl_list_remove(&rule->link); - zfree(rule->identifier); - zfree(rule->title); - action_list_free(&rule->actions); - zfree(rule); -} - static void validate_actions(void) { diff --git a/src/window-rules.c b/src/window-rules.c index b6b29995..ef15b031 100644 --- a/src/window-rules.c +++ b/src/window-rules.c @@ -7,7 +7,9 @@ #include #include #include "action.h" +#include "common/list.h" #include "common/match.h" +#include "common/mem.h" #include "config/rcxml.h" #include "labwc.h" #include "view.h" @@ -126,3 +128,22 @@ window_rules_get_property(struct view *view, const char *property) } return LAB_PROP_UNSPECIFIED; } + +void +create_default_window_type_rules(void) +{ + // Desktop window type + struct window_rule *rule = znew(*rule); + rule->window_type = NET_WM_WINDOW_TYPE_DESKTOP; + rule->server_decoration = LAB_PROP_FALSE; + rule->skip_taskbar = LAB_PROP_TRUE; + rule->skip_window_switcher = LAB_PROP_TRUE; + rule->ignore_focus_request = LAB_PROP_TRUE; + rule->fixed_position = LAB_PROP_TRUE; + struct action *action_on_bottom = action_create("ToggleAlwaysOnBottom"); + struct action *action_move_to = action_create("MoveTo"); + wl_list_init(&rule->actions); + wl_list_append(&rule->actions, &action_on_bottom->link); + wl_list_append(&rule->actions, &action_move_to->link); + wl_list_append(&rc.window_rules, &rule->link); +}