Support window-rules

Two types of window rules are supported, actions and properties. They are
defined as shown below.

    <windowRules>

      <!-- Action -->
      <windowRule identifier="some-application">
        <action name="Maximize"/>
      </windowRule>

      <!-- Property -->
      <windowRule identifier="foo*" serverDecoration="yes|no"/>

    </windowRules>

Rules are applied if windows match the criteria defined by the
'identifier' attribute which relates to app_id for native Wayland windows
and WM_CLASS for XWayland clients.

Matching against patterns with '*' (wildcard) and '?' (joker) is
supported.

Add 'serverDecoration' property.
This commit is contained in:
Johan Malm 2023-04-28 21:41:41 +01:00 committed by Johan Malm
parent d0aafb684f
commit d609c9e3f9
12 changed files with 281 additions and 3 deletions

View file

@ -80,6 +80,8 @@ struct rcxml {
bool outlines;
struct wl_list fields; /* struct window_switcher_field.link */
} window_switcher;
struct wl_list window_rules; /* struct window_rule.link */
};
extern struct rcxml rc;

37
include/window-rules.h Normal file
View file

@ -0,0 +1,37 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef __WINDOW_RULES_H
#define __WINDOW_RULES_H
enum window_rule_event {
LAB_WINDOW_RULE_EVENT_ON_FIRST_MAP = 0,
};
enum property {
LAB_PROP_UNSPECIFIED = 0,
LAB_PROP_UNSET,
LAB_PROP_FALSE,
LAB_PROP_TRUE,
};
/*
* 'identifier' represents:
* - 'app_id' for native Wayland windows
* - 'WM_CLASS' for XWayland clients
*/
struct window_rule {
char *identifier;
enum window_rule_event event;
struct wl_list actions;
enum property server_decoration;
struct wl_list link; /* struct rcxml.window_rules */
};
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);
#endif /* __WINDOW_RULES_H */