diff options
Diffstat (limited to '')
| -rw-r--r-- | client.c | 49 | ||||
| -rw-r--r-- | dwm.h | 5 | ||||
| -rw-r--r-- | tile.c | 5 | ||||
| -rw-r--r-- | view.c | 11 |
4 files changed, 40 insertions, 30 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); |
| @@ -99,7 +99,11 @@ extern Display *dpy; | |||
| 99 | extern Window root, barwin; | 99 | extern Window root, barwin; |
| 100 | 100 | ||
| 101 | /* client.c */ | 101 | /* client.c */ |
| 102 | extern void attach(Client *c); /* attaches c to global client list */ | ||
| 103 | extern void attachstack(Client *c); /* attaches client to stack */ | ||
| 102 | extern void configure(Client *c); /* send synthetic configure event */ | 104 | extern void configure(Client *c); /* send synthetic configure event */ |
| 105 | extern void detach(Client *c); /* detaches c from global client list */ | ||
| 106 | extern void detachstack(Client *c); /* detaches client from stack */ | ||
| 103 | extern void focus(Client *c); /* focus c, c may be NULL */ | 107 | extern void focus(Client *c); /* focus c, c may be NULL */ |
| 104 | extern Client *getclient(Window w); /* return client of w */ | 108 | extern Client *getclient(Window w); /* return client of w */ |
| 105 | extern Bool isprotodel(Client *c); /* returns True if c->win supports wmatom[WMDelete] */ | 109 | extern Bool isprotodel(Client *c); /* returns True if c->win supports wmatom[WMDelete] */ |
| @@ -144,7 +148,6 @@ extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 * | |||
| 144 | extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */ | 148 | extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */ |
| 145 | 149 | ||
| 146 | /* view.c */ | 150 | /* view.c */ |
| 147 | extern void detach(Client *c); /* detaches c from global client list */ | ||
| 148 | extern void dofloat(void); /* arranges all windows floating */ | 151 | extern void dofloat(void); /* arranges all windows floating */ |
| 149 | extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */ | 152 | extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */ |
| 150 | extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */ | 153 | extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */ |
| @@ -125,10 +125,7 @@ zoom(Arg *arg) { | |||
| 125 | if(!(c = nextmanaged(c->next))) | 125 | if(!(c = nextmanaged(c->next))) |
| 126 | return; | 126 | return; |
| 127 | detach(c); | 127 | detach(c); |
| 128 | if(clients) | 128 | attach(c); |
| 129 | clients->prev = c; | ||
| 130 | c->next = clients; | ||
| 131 | clients = c; | ||
| 132 | focus(c); | 129 | focus(c); |
| 133 | arrange(); | 130 | arrange(); |
| 134 | } | 131 | } |
| @@ -8,17 +8,6 @@ | |||
| 8 | void (*arrange)(void) = DEFMODE; | 8 | void (*arrange)(void) = DEFMODE; |
| 9 | 9 | ||
| 10 | void | 10 | void |
| 11 | detach(Client *c) { | ||
| 12 | if(c->prev) | ||
| 13 | c->prev->next = c->next; | ||
| 14 | if(c->next) | ||
| 15 | c->next->prev = c->prev; | ||
| 16 | if(c == clients) | ||
| 17 | clients = c->next; | ||
| 18 | c->next = c->prev = NULL; | ||
| 19 | } | ||
| 20 | |||
| 21 | void | ||
| 22 | dofloat(void) { | 11 | dofloat(void) { |
| 23 | Client *c; | 12 | Client *c; |
| 24 | 13 | ||
