26 static Regs *regs = NULL; |
26 static Regs *regs = NULL; |
27 static unsigned int nrules = 0; |
27 static unsigned int nrules = 0; |
28 static char prop[512]; |
28 static char prop[512]; |
29 |
29 |
30 static void |
30 static void |
31 persisttags(Client *c) |
31 persistconfig(Client *c) { |
32 { |
|
33 unsigned int i; |
32 unsigned int i; |
34 |
33 |
35 for(i = 0; i < ntags && i < sizeof prop - 1; i++) |
34 for(i = 0; i < ntags && i < sizeof prop - 1; i++) |
36 prop[i] = c->tags[i] ? '+' : '-'; |
35 prop[i] = c->tags[i] ? '1' : '0'; |
|
36 if(i < sizeof prop - 1) |
|
37 prop[i++] = c->isfloating ? '1' : '0'; |
37 prop[i] = '\0'; |
38 prop[i] = '\0'; |
38 XChangeProperty(dpy, c->win, dwmtags, XA_STRING, 8, |
39 XChangeProperty(dpy, c->win, dwmconfig, XA_STRING, 8, |
39 PropModeReplace, (unsigned char *)prop, i); |
40 PropModeReplace, (unsigned char *)prop, i); |
40 } |
41 } |
41 |
42 |
42 /* extern */ |
43 /* extern */ |
43 |
44 |
91 c->tags[i] = trans->tags[i]; |
92 c->tags[i] = trans->tags[i]; |
92 } |
93 } |
93 else { |
94 else { |
94 /* check if window has set a property */ |
95 /* check if window has set a property */ |
95 name.nitems = 0; |
96 name.nitems = 0; |
96 XGetTextProperty(dpy, c->win, &name, dwmtags); |
97 XGetTextProperty(dpy, c->win, &name, dwmconfig); |
97 if(name.nitems && name.encoding == XA_STRING) { |
98 if(name.nitems && name.encoding == XA_STRING) { |
98 strncpy(prop, (char *)name.value, sizeof prop - 1); |
99 strncpy(prop, (char *)name.value, sizeof prop - 1); |
99 prop[sizeof prop - 1] = '\0'; |
100 prop[sizeof prop - 1] = '\0'; |
100 XFree(name.value); |
101 XFree(name.value); |
101 for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++) |
102 for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++) |
102 if((c->tags[i] = prop[i] == '+')) |
103 if((c->tags[i] = prop[i] == '1')) |
103 matched = True; |
104 matched = True; |
|
105 if(i < sizeof prop - 1 && prop[i] != '\0') |
|
106 c->isfloating = prop[i] == '1'; |
104 } |
107 } |
105 } |
108 } |
106 if(!matched) { |
109 if(!matched) { |
107 /* rule matching */ |
110 /* rule matching */ |
108 XGetClassHint(dpy, c->win, &ch); |
111 XGetClassHint(dpy, c->win, &ch); |
140 sel->tags[i] = arg == NULL; |
143 sel->tags[i] = arg == NULL; |
141 i = arg ? atoi(arg) : 0; |
144 i = arg ? atoi(arg) : 0; |
142 if(i >= 0 && i < ntags) |
145 if(i >= 0 && i < ntags) |
143 sel->tags[i] = True; |
146 sel->tags[i] = True; |
144 if(sel) |
147 if(sel) |
145 persisttags(sel); |
148 persistconfig(sel); |
|
149 arrange(); |
|
150 } |
|
151 |
|
152 void |
|
153 togglefloating(const char *arg) { |
|
154 if(!sel || isfloating()) |
|
155 return; |
|
156 sel->isfloating = !sel->isfloating; |
|
157 if(sel->isfloating) |
|
158 resize(sel, sel->x, sel->y, sel->w, sel->h, True); |
146 arrange(); |
159 arrange(); |
147 } |
160 } |
148 |
161 |
149 void |
162 void |
150 toggletag(const char *arg) { |
163 toggletag(const char *arg) { |