diff options
| author | Anselm R. Garbe <garbeam@gmail.com> | 2007-08-18 13:48:05 +0200 |
|---|---|---|
| committer | Anselm R. Garbe <garbeam@gmail.com> | 2007-08-18 13:48:05 +0200 |
| commit | 50be6c8b67c500ee4aa07919609fa80785fd389d (patch) | |
| tree | b6cb11170b9273e079a536e6a70c6d8d5bcb7e98 /client.c | |
| parent | applied Gottox mwfact patch (diff) | |
| download | dwm-50be6c8b67c500ee4aa07919609fa80785fd389d.tar.gz dwm-50be6c8b67c500ee4aa07919609fa80785fd389d.zip | |
cleaned up settags-handling
Diffstat (limited to 'client.c')
| -rw-r--r-- | client.c | 45 |
1 files changed, 44 insertions, 1 deletions
| @@ -7,6 +7,8 @@ | |||
| 7 | 7 | ||
| 8 | /* static */ | 8 | /* static */ |
| 9 | 9 | ||
| 10 | static char config[128]; | ||
| 11 | |||
| 10 | static void | 12 | static void |
| 11 | attachstack(Client *c) { | 13 | attachstack(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 | ||
| 184 | Bool | ||
| 185 | loadconfig(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 | |||
| 182 | void | 206 | void |
| 183 | manage(Window w, XWindowAttributes *wa) { | 207 | manage(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 | ||
| 297 | void | 327 | void |
| 328 | saveconfig(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 | |||
| 340 | void | ||
| 298 | unban(Client *c) { | 341 | unban(Client *c) { |
| 299 | if(!c->isbanned) | 342 | if(!c->isbanned) |
| 300 | return; | 343 | return; |
