summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tag.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/tag.c b/tag.c
index 5161ae2..a532761 100644
--- a/tag.c
+++ b/tag.c
@@ -27,6 +27,18 @@ static Regs *regs = NULL;
27static unsigned int nrules = 0; 27static unsigned int nrules = 0;
28static char prop[512]; 28static char prop[512];
29 29
30static void
31persisttags(Client *c)
32{
33 unsigned int i;
34
35 for(i = 0; i < ntags && i < sizeof prop - 1; i++)
36 prop[i] = c->tags[i] ? '+' : '-';
37 prop[i] = '\0';
38 XChangeProperty(dpy, c->win, dwmtags, XA_STRING, 8,
39 PropModeReplace, (unsigned char *)prop, i);
40}
41
30/* extern */ 42/* extern */
31 43
32void 44void
@@ -77,7 +89,6 @@ settags(Client *c, Client *trans) {
77 if(matched) { 89 if(matched) {
78 for(i = 0; i < ntags; i++) 90 for(i = 0; i < ntags; i++)
79 c->tags[i] = trans->tags[i]; 91 c->tags[i] = trans->tags[i];
80 return;
81 } 92 }
82 else { 93 else {
83 /* check if window has set a property */ 94 /* check if window has set a property */
@@ -91,8 +102,8 @@ settags(Client *c, Client *trans) {
91 if((c->tags[i] = prop[i] == '+')) 102 if((c->tags[i] = prop[i] == '+'))
92 matched = True; 103 matched = True;
93 } 104 }
94 if(matched) 105 }
95 return; 106 if(!matched) {
96 /* rule matching */ 107 /* rule matching */
97 XGetClassHint(dpy, c->win, &ch); 108 XGetClassHint(dpy, c->win, &ch);
98 snprintf(prop, sizeof prop, "%s:%s:%s", 109 snprintf(prop, sizeof prop, "%s:%s:%s",
@@ -116,6 +127,7 @@ settags(Client *c, Client *trans) {
116 if(!matched) 127 if(!matched)
117 for(i = 0; i < ntags; i++) 128 for(i = 0; i < ntags; i++)
118 c->tags[i] = seltag[i]; 129 c->tags[i] = seltag[i];
130 persisttags(c);
119} 131}
120 132
121void 133void
@@ -129,12 +141,8 @@ tag(const char *arg) {
129 i = arg ? atoi(arg) : 0; 141 i = arg ? atoi(arg) : 0;
130 if(i >= 0 && i < ntags) 142 if(i >= 0 && i < ntags)
131 sel->tags[i] = True; 143 sel->tags[i] = True;
132 if(sel) { 144 if(sel)
133 for(i = 0; i < ntags && i < sizeof prop - 1; i++) 145 persisttags(sel);
134 prop[i] = sel->tags[i] ? '+' : '-';
135 prop[i] = '\0';
136 XChangeProperty(dpy, sel->win, dwmtags, XA_STRING, 8, PropModeReplace, (unsigned char *)prop, i);
137 }
138 arrange(); 146 arrange();
139} 147}
140 148
@@ -149,6 +157,8 @@ toggletag(const char *arg) {
149 for(j = 0; j < ntags && !sel->tags[j]; j++); 157 for(j = 0; j < ntags && !sel->tags[j]; j++);
150 if(j == ntags) 158 if(j == ntags)
151 sel->tags[i] = True; 159 sel->tags[i] = True;
160 if(sel)
161 persisttags(sel);
152 arrange(); 162 arrange();
153} 163}
154 164