added some new convenience functions
30af19d4
4 file(s) · +40 −30
| 10 | 10 | /* static */ |
|
| 11 | 11 | ||
| 12 | 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 | 13 | grabbuttons(Client *c, Bool focused) { |
|
| 21 | 14 | XUngrabButton(dpy, AnyButton, AnyModifier, c->win); |
|
| 22 | 15 | ||
| 68 | 61 | /* extern */ |
|
| 69 | 62 | ||
| 70 | 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 | 78 | configure(Client *c) { |
|
| 72 | 79 | XConfigureEvent ce; |
|
| 73 | 80 | ||
| 86 | 93 | } |
|
| 87 | 94 | ||
| 88 | 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 | 114 | focus(Client *c) { |
|
| 90 | 115 | if(c && !isvisible(c)) |
|
| 91 | 116 | return; |
|
| 95 | 120 | } |
|
| 96 | 121 | if(c) { |
|
| 97 | 122 | detachstack(c); |
|
| 98 | - | c->snext = stack; |
|
| 99 | - | stack = c; |
|
| 123 | + | attachstack(c); |
|
| 100 | 124 | grabbuttons(c, True); |
|
| 101 | 125 | } |
|
| 102 | 126 | sel = c; |
|
| 189 | 213 | settags(c, t); |
|
| 190 | 214 | if(!c->isfloat) |
|
| 191 | 215 | c->isfloat = (t != 0) || c->isfixed; |
|
| 192 | - | if(clients) |
|
| 193 | - | clients->prev = c; |
|
| 194 | - | c->next = clients; |
|
| 195 | - | c->snext = stack; |
|
| 196 | - | stack = clients = c; |
|
| 216 | + | attach(c); |
|
| 217 | + | attachstack(c); |
|
| 197 | 218 | c->isbanned = True; |
|
| 198 | 219 | XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); |
|
| 199 | 220 | XMapWindow(dpy, c->win); |
|
| 99 | 99 | extern Window root, barwin; |
|
| 100 | 100 | ||
| 101 | 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 | 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 | 107 | extern void focus(Client *c); /* focus c, c may be NULL */ |
|
| 104 | 108 | extern Client *getclient(Window w); /* return client of w */ |
|
| 105 | 109 | extern Bool isprotodel(Client *c); /* returns True if c->win supports wmatom[WMDelete] */ |
|
| 144 | 148 | extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */ |
|
| 145 | 149 | ||
| 146 | 150 | /* view.c */ |
|
| 147 | - | extern void detach(Client *c); /* detaches c from global client list */ |
|
| 148 | 151 | extern void dofloat(void); /* arranges all windows floating */ |
|
| 149 | 152 | extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */ |
|
| 150 | 153 | extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */ |
|
| 125 | 125 | if(!(c = nextmanaged(c->next))) |
|
| 126 | 126 | return; |
|
| 127 | 127 | detach(c); |
|
| 128 | - | if(clients) |
|
| 129 | - | clients->prev = c; |
|
| 130 | - | c->next = clients; |
|
| 131 | - | clients = c; |
|
| 128 | + | attach(c); |
|
| 132 | 129 | focus(c); |
|
| 133 | 130 | arrange(); |
|
| 134 | 131 | } |
| 8 | 8 | void (*arrange)(void) = DEFMODE; |
|
| 9 | 9 | ||
| 10 | 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 | 11 | dofloat(void) { |
|
| 23 | 12 | Client *c; |
|
| 24 | 13 |