summaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--client.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/client.c b/client.c
index c6cf770..882b8ee 100644
--- a/client.c
+++ b/client.c
@@ -7,6 +7,8 @@
7 7
8/* static */ 8/* static */
9 9
10static char config[128];
11
10static void 12static void
11attachstack(Client *c) { 13attachstack(Client *c) {
12 c->snext = stack; 14 c->snext = stack;
@@ -179,8 +181,31 @@ killclient(const char *arg) {
179 XKillClient(dpy, sel->win); 181 XKillClient(dpy, sel->win);
180} 182}
181 183
184Bool
185loadconfig(Client *c) {
186 unsigned int i;
187 Bool result = False;
188 XTextProperty name;
189
190 /* check if window has set a property */
191 name.nitems = 0;
192 XGetTextProperty(dpy, c->win, &name, dwmconfig);
193 if(name.nitems && name.encoding == XA_STRING) {
194 strncpy(config, (char *)name.value, sizeof config - 1);
195 config[sizeof config - 1] = '\0';
196 XFree(name.value);
197 for(i = 0; i < ntags && i < sizeof config - 1 && config[i] != '\0'; i++)
198 if((c->tags[i] = config[i] == '1'))
199 result = True;
200 if(i < sizeof config - 1 && config[i] != '\0')
201 c->isfloating = config[i] == '1';
202 }
203 return result;
204}
205
182void 206void
183manage(Window w, XWindowAttributes *wa) { 207manage(Window w, XWindowAttributes *wa) {
208 unsigned int i;
184 Client *c, *t = NULL; 209 Client *c, *t = NULL;
185 Window trans; 210 Window trans;
186 Status rettrans; 211 Status rettrans;
@@ -221,9 +246,14 @@ manage(Window w, XWindowAttributes *wa) {
221 updatetitle(c); 246 updatetitle(c);
222 if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success)) 247 if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
223 for(t = clients; t && t->win != trans; t = t->next); 248 for(t = clients; t && t->win != trans; t = t->next);
224 settags(c, t); 249 if(t)
250 for(i = 0; i < ntags; i++)
251 c->tags[i] = t->tags[i];
252 if(!loadconfig(c))
253 applyrules(c);
225 if(!c->isfloating) 254 if(!c->isfloating)
226 c->isfloating = (rettrans == Success) || c->isfixed; 255 c->isfloating = (rettrans == Success) || c->isfixed;
256 saveconfig(c);
227 attach(c); 257 attach(c);
228 attachstack(c); 258 attachstack(c);
229 XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); /* some windows require this */ 259 XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); /* some windows require this */
@@ -295,6 +325,19 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
295} 325}
296 326
297void 327void
328saveconfig(Client *c) {
329 unsigned int i;
330
331 for(i = 0; i < ntags && i < sizeof config - 1; i++)
332 config[i] = c->tags[i] ? '1' : '0';
333 if(i < sizeof config - 1)
334 config[i++] = c->isfloating ? '1' : '0';
335 config[i] = '\0';
336 XChangeProperty(dpy, c->win, dwmconfig, XA_STRING, 8,
337 PropModeReplace, (unsigned char *)config, i);
338}
339
340void
298unban(Client *c) { 341unban(Client *c) {
299 if(!c->isbanned) 342 if(!c->isbanned)
300 return; 343 return;