diff options
| author | Anselm R. Garbe <arg@suckless.org> | 2007-02-19 13:42:39 +0100 |
|---|---|---|
| committer | Anselm R. Garbe <arg@suckless.org> | 2007-02-19 13:42:39 +0100 |
| commit | 30af19d4426ca32dc38318bbe87534cc44484998 (patch) | |
| tree | c3d862223531f5b02e3cb6e31b7e9ee5d38193a6 /client.c | |
| parent | some more refactoring (diff) | |
| download | dwm-30af19d4426ca32dc38318bbe87534cc44484998.tar.gz dwm-30af19d4426ca32dc38318bbe87534cc44484998.zip | |
added some new convenience functions
Diffstat (limited to 'client.c')
| -rw-r--r-- | client.c | 49 |
1 files changed, 35 insertions, 14 deletions
| @@ -10,13 +10,6 @@ | |||
| 10 | /* static */ | 10 | /* static */ |
| 11 | 11 | ||
| 12 | static void | 12 | static void |
| 13 | detachstack(Client *c) { | ||
| 14 | Client **tc; | ||
| 15 | for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext); | ||
| 16 | *tc = c->snext; | ||
| 17 | } | ||
| 18 | |||
| 19 | static void | ||
| 20 | grabbuttons(Client *c, Bool focused) { | 13 | grabbuttons(Client *c, Bool focused) { |
| 21 | XUngrabButton(dpy, AnyButton, AnyModifier, c->win); | 14 | XUngrabButton(dpy, AnyButton, AnyModifier, c->win); |
| 22 | 15 | ||
| @@ -68,6 +61,20 @@ xerrordummy(Display *dsply, XErrorEvent *ee) { | |||
| 68 | /* extern */ | 61 | /* extern */ |
| 69 | 62 | ||
| 70 | void | 63 | void |
| 64 | attach(Client *c) { | ||
| 65 | if(clients) | ||
| 66 | clients->prev = c; | ||
| 67 | c->next = clients; | ||
| 68 | clients = c; | ||
| 69 | } | ||
| 70 | |||
| 71 | void | ||
| 72 | attachstack(Client *c) { | ||
| 73 | c->snext = stack; | ||
| 74 | stack = c; | ||
| 75 | } | ||
| 76 | |||
| 77 | void | ||
| 71 | configure(Client *c) { | 78 | configure(Client *c) { |
| 72 | XConfigureEvent ce; | 79 | XConfigureEvent ce; |
| 73 | 80 | ||
| @@ -86,6 +93,24 @@ configure(Client *c) { | |||
| 86 | } | 93 | } |
| 87 | 94 | ||
| 88 | void | 95 | void |
| 96 | detach(Client *c) { | ||
| 97 | if(c->prev) | ||
| 98 | c->prev->next = c->next; | ||
| 99 | if(c->next) | ||
| 100 | c->next->prev = c->prev; | ||
| 101 | if(c == clients) | ||
| 102 | clients = c->next; | ||
| 103 | c->next = c->prev = NULL; | ||
| 104 | } | ||
| 105 | |||
| 106 | void | ||
| 107 | detachstack(Client *c) { | ||
| 108 | Client **tc; | ||
| 109 | for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext); | ||
| 110 | *tc = c->snext; | ||
| 111 | } | ||
| 112 | |||
| 113 | void | ||
| 89 | focus(Client *c) { | 114 | focus(Client *c) { |
| 90 | if(c && !isvisible(c)) | 115 | if(c && !isvisible(c)) |
| 91 | return; | 116 | return; |
| @@ -95,8 +120,7 @@ focus(Client *c) { | |||
| 95 | } | 120 | } |
| 96 | if(c) { | 121 | if(c) { |
| 97 | detachstack(c); | 122 | detachstack(c); |
| 98 | c->snext = stack; | 123 | attachstack(c); |
| 99 | stack = c; | ||
| 100 | grabbuttons(c, True); | 124 | grabbuttons(c, True); |
| 101 | } | 125 | } |
| 102 | sel = c; | 126 | sel = c; |
| @@ -189,11 +213,8 @@ manage(Window w, XWindowAttributes *wa) { | |||
| 189 | settags(c, t); | 213 | settags(c, t); |
| 190 | if(!c->isfloat) | 214 | if(!c->isfloat) |
| 191 | c->isfloat = (t != 0) || c->isfixed; | 215 | c->isfloat = (t != 0) || c->isfixed; |
| 192 | if(clients) | 216 | attach(c); |
| 193 | clients->prev = c; | 217 | attachstack(c); |
| 194 | c->next = clients; | ||
| 195 | c->snext = stack; | ||
| 196 | stack = clients = c; | ||
| 197 | c->isbanned = True; | 218 | c->isbanned = True; |
| 198 | XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); | 219 | XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); |
| 199 | XMapWindow(dpy, c->win); | 220 | XMapWindow(dpy, c->win); |
