about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--dwm.h2
-rw-r--r--layout.c6
-rw-r--r--main.c3
-rw-r--r--tag.c29
4 files changed, 33 insertions, 7 deletions
diff --git a/dwm.h b/dwm.h
index 8f5ffdb..b26bd8c 100644
--- a/dwm.h
+++ b/dwm.h
@@ -81,7 +81,7 @@ extern int wax, way, wah, waw;			/* windowarea geometry */
 extern unsigned int bh, blw, bpos;		/* bar height, bar layout label width, bar position */
 extern unsigned int ntags, numlockmask;		/* number of tags, numlock mask */
 extern void (*handler[LASTEvent])(XEvent *);	/* event handler */
-extern Atom wmatom[WMLast], netatom[NetLast];
+extern Atom dwmtags, wmatom[WMLast], netatom[NetLast];
 extern Bool selscreen, *seltag;			/* seltag is array of Bool */
 extern Client *clients, *sel, *stack;		/* global client list and stack */
 extern Cursor cursor[CurLast];
diff --git a/layout.c b/layout.c
index a660fd7..4fb0be3 100644
--- a/layout.c
+++ b/layout.c
@@ -2,6 +2,8 @@
 #include "dwm.h"
 #include <stdlib.h>
 
+/* static */
+
 typedef struct {
 	const char *symbol;
 	void (*arrange)(void);
@@ -10,10 +12,8 @@ typedef struct {
 unsigned int blw = 0;
 static Layout *lt = NULL;
 
-/* static */
-
 static void
-floating(void) {
+floating(void) { /* default floating layout */
 	Client *c;
 
 	for(c = clients; c; c = c->next)
diff --git a/main.c b/main.c
index d72f13d..2140d89 100644
--- a/main.c
+++ b/main.c
@@ -19,7 +19,7 @@ int screen, sx, sy, sw, sh, wax, way, waw, wah;
 unsigned int bh, ntags;
 unsigned int bpos = BARPOS;
 unsigned int numlockmask = 0;
-Atom wmatom[WMLast], netatom[NetLast];
+Atom dwmtags, wmatom[WMLast], netatom[NetLast];
 Bool *seltag;
 Bool selscreen = True;
 Client *clients = NULL;
@@ -139,6 +139,7 @@ setup(void) {
 	XSetWindowAttributes wa;
 
 	/* init atoms */
+	dwmtags = XInternAtom(dpy, "__DWM_TAGS", False);
 	wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
 	wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
 	wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
diff --git a/tag.c b/tag.c
index bbed872..5161ae2 100644
--- a/tag.c
+++ b/tag.c
@@ -3,6 +3,8 @@
 #include <regex.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
+#include <X11/Xatom.h>
 #include <X11/Xutil.h>
 
 /* static */
@@ -23,6 +25,7 @@ RULES
 
 static Regs *regs = NULL;
 static unsigned int nrules = 0;
+static char prop[512];
 
 /* extern */
 
@@ -65,16 +68,32 @@ isvisible(Client *c) {
 
 void
 settags(Client *c, Client *trans) {
-	char prop[512];
 	unsigned int i, j;
 	regmatch_t tmp;
 	Bool matched = trans != NULL;
 	XClassHint ch = { 0 };
+	XTextProperty name;
 
-	if(matched)
+	if(matched) {
 		for(i = 0; i < ntags; i++)
 			c->tags[i] = trans->tags[i];
+		return;
+	}
 	else {
+		/* check if window has set a property */
+		name.nitems = 0;
+		XGetTextProperty(dpy, c->win, &name, dwmtags);
+		if(name.nitems && name.encoding == XA_STRING) {
+			strncpy(prop, (char *)name.value, sizeof prop - 1);
+			prop[sizeof prop - 1] = '\0';
+			XFree(name.value);
+			for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++)
+				if((c->tags[i] = prop[i] == '+'))
+					matched = True;
+		}
+		if(matched)
+			return;
+		/* rule matching */
 		XGetClassHint(dpy, c->win, &ch);
 		snprintf(prop, sizeof prop, "%s:%s:%s",
 				ch.res_class ? ch.res_class : "",
@@ -110,6 +129,12 @@ tag(const char *arg) {
 	i = arg ? atoi(arg) : 0;
 	if(i >= 0 && i < ntags)
 		sel->tags[i] = True;
+	if(sel) {
+		for(i = 0; i < ntags && i < sizeof prop - 1; i++)
+			prop[i] = sel->tags[i] ? '+' : '-';
+		prop[i] = '\0';
+		XChangeProperty(dpy, sel->win, dwmtags, XA_STRING, 8, PropModeReplace, (unsigned char *)prop, i);
+	}
 	arrange();
 }
 
amp;id=a654e4ecace2d506d1b10f1dde2c287ebe84ef37'>a654e4ec ^
dcc060c7 ^
e5c11a51 ^
a654e4ec ^
204dae92 ^






b301e0c0 ^
204dae92 ^
805d58c6 ^

204dae92 ^

805d58c6 ^

204dae92 ^




b301e0c0 ^
204dae92 ^
805d58c6 ^

204dae92 ^

805d58c6 ^

204dae92 ^




b301e0c0 ^
204dae92 ^
805d58c6 ^
204dae92 ^

805d58c6 ^

204dae92 ^


b301e0c0 ^
204dae92 ^
cdf28227 ^
b301e0c0 ^
204dae92 ^

b301e0c0 ^
204dae92 ^




cdf28227 ^
204dae92 ^
4a48bedc ^
204dae92 ^
cdf28227 ^

204dae92 ^



b301e0c0 ^
204dae92 ^
4a48bedc ^
204dae92 ^
b301e0c0 ^
cdf28227 ^

b301e0c0 ^


204dae92 ^


5fe060d5 ^
204dae92 ^


b301e0c0 ^
204dae92 ^
4a48bedc ^
204dae92 ^
b301e0c0 ^
cdf28227 ^

b301e0c0 ^


204dae92 ^









b301e0c0 ^
204dae92 ^
4a48bedc ^
204dae92 ^



dcc060c7 ^


a654e4ec ^
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174