xwayland: add sensible rules for NET_WM_WINDOW_TYPE_DESKTOP windows

This commit is contained in:
Grigory Kirillov 2024-05-11 22:40:27 +03:00
parent b41af54a1b
commit 5825db86b7
4 changed files with 51 additions and 11 deletions

View file

@ -891,6 +891,16 @@ situation.
can be caused by *<margin>* 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 `<windowRules><clear>`.
## MENU
```

View file

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

View file

@ -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, &current_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)
{

View file

@ -7,7 +7,9 @@
#include <strings.h>
#include <wlr/util/log.h>
#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);
}