-
Notifications
You must be signed in to change notification settings - Fork 30
/
dwm-windowrolerule-6.5.diff
85 lines (78 loc) · 3.17 KB
/
dwm-windowrolerule-6.5.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
From 1e1d09432ab56632be4e69efec6cc233d18953a1 Mon Sep 17 00:00:00 2001
From: Bakkeby <[email protected]>
Date: Wed, 26 Jun 2024 22:32:14 +0200
Subject: [PATCH] Adding window role rule
This patch adds a new rule property based on WM_WINDOW_ROLE(STRING) so that one can
differentiate between window roles, e.g. Firefox "browser" vs "Preferences".
---
config.def.h | 7 ++++---
dwm.c | 7 ++++++-
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/config.def.h b/config.def.h
index 9efa774..6c77472 100644
--- a/config.def.h
+++ b/config.def.h
@@ -25,10 +25,11 @@ static const Rule rules[] = {
/* xprop(1):
* WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title
+ * WM_WINDOW_ROLE(STRING) = role
*/
- /* class instance title tags mask isfloating monitor */
- { "Gimp", NULL, NULL, 0, 1, -1 },
- { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
+ /* class role instance title tags mask isfloating monitor */
+ { "Gimp", NULL, NULL, NULL, 0, 1, -1 },
+ { "Firefox", NULL, NULL, NULL, 1 << 8, 0, -1 },
};
/* layout(s) */
diff --git a/dwm.c b/dwm.c
index f1d86b2..b7ff653 100644
--- a/dwm.c
+++ b/dwm.c
@@ -63,7 +63,7 @@ enum { SchemeNorm, SchemeSel }; /* color schemes */
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
-enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
+enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMWindowRole, WMLast }; /* default atoms */
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
@@ -134,6 +134,7 @@ struct Monitor {
typedef struct {
const char *class;
+ const char *role;
const char *instance;
const char *title;
unsigned int tags;
@@ -279,6 +280,7 @@ void
applyrules(Client *c)
{
const char *class, *instance;
+ char role[64];
unsigned int i;
const Rule *r;
Monitor *m;
@@ -290,11 +292,13 @@ applyrules(Client *c)
XGetClassHint(dpy, c->win, &ch);
class = ch.res_class ? ch.res_class : broken;
instance = ch.res_name ? ch.res_name : broken;
+ gettextprop(c->win, wmatom[WMWindowRole], role, sizeof(role));
for (i = 0; i < LENGTH(rules); i++) {
r = &rules[i];
if ((!r->title || strstr(c->name, r->title))
&& (!r->class || strstr(class, r->class))
+ && (!r->role || strstr(role, r->role))
&& (!r->instance || strstr(instance, r->instance)))
{
c->isfloating = r->isfloating;
@@ -1570,6 +1574,7 @@ setup(void)
wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
wmatom[WMTakeFocus] = XInternAtom(dpy, "WM_TAKE_FOCUS", False);
+ wmatom[WMWindowRole] = XInternAtom(dpy, "WM_WINDOW_ROLE", False);
netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
--
2.45.2