diff options
Diffstat (limited to 'client.c')
| -rw-r--r-- | client.c | 73 |
1 files changed, 60 insertions, 13 deletions
| @@ -10,6 +10,19 @@ | |||
| 10 | /* static */ | 10 | /* static */ |
| 11 | 11 | ||
| 12 | static void | 12 | static void |
| 13 | attachstack(Client *c) { | ||
| 14 | c->snext = stack; | ||
| 15 | stack = c; | ||
| 16 | } | ||
| 17 | |||
| 18 | static void | ||
| 19 | detachstack(Client *c) { | ||
| 20 | Client **tc; | ||
| 21 | for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext); | ||
| 22 | *tc = c->snext; | ||
| 23 | } | ||
| 24 | |||
| 25 | static void | ||
| 13 | grabbuttons(Client *c, Bool focused) { | 26 | grabbuttons(Client *c, Bool focused) { |
| 14 | XUngrabButton(dpy, AnyButton, AnyModifier, c->win); | 27 | XUngrabButton(dpy, AnyButton, AnyModifier, c->win); |
| 15 | 28 | ||
| @@ -68,6 +81,24 @@ setclientstate(Client *c, long state) { | |||
| 68 | PropModeReplace, (unsigned char *)data, 2); | 81 | PropModeReplace, (unsigned char *)data, 2); |
| 69 | } | 82 | } |
| 70 | 83 | ||
| 84 | static void | ||
| 85 | togglemax(Client *c) { | ||
| 86 | XEvent ev; | ||
| 87 | |||
| 88 | if(c->isfixed) | ||
| 89 | return; | ||
| 90 | if((c->ismax = !c->ismax)) { | ||
| 91 | c->rx = c->x; | ||
| 92 | c->ry = c->y; | ||
| 93 | c->rw = c->w; | ||
| 94 | c->rh = c->h; | ||
| 95 | resize(c, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True); | ||
| 96 | } | ||
| 97 | else | ||
| 98 | resize(c, c->rx, c->ry, c->rw, c->rh, True); | ||
| 99 | while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); | ||
| 100 | } | ||
| 101 | |||
| 71 | static int | 102 | static int |
| 72 | xerrordummy(Display *dsply, XErrorEvent *ee) { | 103 | xerrordummy(Display *dsply, XErrorEvent *ee) { |
| 73 | return 0; | 104 | return 0; |
| @@ -84,12 +115,6 @@ attach(Client *c) { | |||
| 84 | } | 115 | } |
| 85 | 116 | ||
| 86 | void | 117 | void |
| 87 | attachstack(Client *c) { | ||
| 88 | c->snext = stack; | ||
| 89 | stack = c; | ||
| 90 | } | ||
| 91 | |||
| 92 | void | ||
| 93 | configure(Client *c) { | 118 | configure(Client *c) { |
| 94 | XConfigureEvent ce; | 119 | XConfigureEvent ce; |
| 95 | 120 | ||
| @@ -119,13 +144,6 @@ detach(Client *c) { | |||
| 119 | } | 144 | } |
| 120 | 145 | ||
| 121 | void | 146 | void |
| 122 | detachstack(Client *c) { | ||
| 123 | Client **tc; | ||
| 124 | for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext); | ||
| 125 | *tc = c->snext; | ||
| 126 | } | ||
| 127 | |||
| 128 | void | ||
| 129 | focus(Client *c) { | 147 | focus(Client *c) { |
| 130 | if(c && !isvisible(c)) | 148 | if(c && !isvisible(c)) |
| 131 | return; | 149 | return; |
| @@ -256,6 +274,12 @@ manage(Window w, XWindowAttributes *wa) { | |||
| 256 | arrange(); | 274 | arrange(); |
| 257 | } | 275 | } |
| 258 | 276 | ||
| 277 | Client * | ||
| 278 | nexttiled(Client *c) { | ||
| 279 | for(; c && (c->isfloat || !isvisible(c)); c = c->next); | ||
| 280 | return c; | ||
| 281 | } | ||
| 282 | |||
| 259 | void | 283 | void |
| 260 | resize(Client *c, int x, int y, int w, int h, Bool sizehints) { | 284 | resize(Client *c, int x, int y, int w, int h, Bool sizehints) { |
| 261 | float actual, dx, dy, max, min; | 285 | float actual, dx, dy, max, min; |
| @@ -416,3 +440,26 @@ unmanage(Client *c) { | |||
| 416 | XUngrabServer(dpy); | 440 | XUngrabServer(dpy); |
| 417 | arrange(); | 441 | arrange(); |
| 418 | } | 442 | } |
| 443 | |||
| 444 | void | ||
| 445 | zoom(Arg *arg) { | ||
| 446 | unsigned int n; | ||
| 447 | Client *c; | ||
| 448 | |||
| 449 | if(!sel) | ||
| 450 | return; | ||
| 451 | if(sel->isfloat || (arrange == dofloat)) { | ||
| 452 | togglemax(sel); | ||
| 453 | return; | ||
| 454 | } | ||
| 455 | for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) | ||
| 456 | n++; | ||
| 457 | |||
| 458 | if((c = sel) == nexttiled(clients)) | ||
| 459 | if(!(c = nexttiled(c->next))) | ||
| 460 | return; | ||
| 461 | detach(c); | ||
| 462 | attach(c); | ||
| 463 | focus(c); | ||
| 464 | arrange(); | ||
| 465 | } | ||
