diff options
| author | Anselm R Garbe <garbeam@gmail.com> | 2008-05-26 09:39:57 +0100 |
|---|---|---|
| committer | Anselm R Garbe <garbeam@gmail.com> | 2008-05-26 09:39:57 +0100 |
| commit | 0fe2e783e9e6b097bc6529dc286b4b697f7e1fde (patch) | |
| tree | 65f5b49cdee714a3c6f3194d7f18e1268cac8ecf /dwm.c | |
| parent | replaced isvisible with a macro (diff) | |
| download | dwm-0fe2e783e9e6b097bc6529dc286b4b697f7e1fde.tar.gz dwm-0fe2e783e9e6b097bc6529dc286b4b697f7e1fde.zip | |
applied yiyus domax patch with slight modifications
Diffstat (limited to '')
| -rw-r--r-- | dwm.c | 76 |
1 files changed, 36 insertions, 40 deletions
| @@ -71,7 +71,7 @@ struct Client { | |||
| 71 | int minax, maxax, minay, maxay; | 71 | int minax, maxax, minay, maxay; |
| 72 | long flags; | 72 | long flags; |
| 73 | int bw, oldbw; | 73 | int bw, oldbw; |
| 74 | Bool isbanned, isfixed, isfloating, isurgent; | 74 | Bool isbanned, isfixed, isfloating, ismax, isurgent; |
| 75 | uint tags; | 75 | uint tags; |
| 76 | Client *next; | 76 | Client *next; |
| 77 | Client *prev; | 77 | Client *prev; |
| @@ -120,7 +120,6 @@ void applyrules(Client *c); | |||
| 120 | void arrange(void); | 120 | void arrange(void); |
| 121 | void attach(Client *c); | 121 | void attach(Client *c); |
| 122 | void attachstack(Client *c); | 122 | void attachstack(Client *c); |
| 123 | void ban(Client *c); | ||
| 124 | void buttonpress(XEvent *e); | 123 | void buttonpress(XEvent *e); |
| 125 | void checkotherwm(void); | 124 | void checkotherwm(void); |
| 126 | void cleanup(void); | 125 | void cleanup(void); |
| @@ -176,9 +175,9 @@ void tileresize(Client *c, int x, int y, int w, int h); | |||
| 176 | void togglebar(const void *arg); | 175 | void togglebar(const void *arg); |
| 177 | void togglefloating(const void *arg); | 176 | void togglefloating(const void *arg); |
| 178 | void togglelayout(const void *arg); | 177 | void togglelayout(const void *arg); |
| 178 | void togglemax(const void *arg); | ||
| 179 | void toggletag(const void *arg); | 179 | void toggletag(const void *arg); |
| 180 | void toggleview(const void *arg); | 180 | void toggleview(const void *arg); |
| 181 | void unban(Client *c); | ||
| 182 | void unmanage(Client *c); | 181 | void unmanage(Client *c); |
| 183 | void unmapnotify(XEvent *e); | 182 | void unmapnotify(XEvent *e); |
| 184 | void updatebar(void); | 183 | void updatebar(void); |
| @@ -217,6 +216,7 @@ void (*handler[LASTEvent]) (XEvent *) = { | |||
| 217 | [UnmapNotify] = unmapnotify | 216 | [UnmapNotify] = unmapnotify |
| 218 | }; | 217 | }; |
| 219 | Atom wmatom[WMLast], netatom[NetLast]; | 218 | Atom wmatom[WMLast], netatom[NetLast]; |
| 219 | Bool domax = False; | ||
| 220 | Bool otherwm, readin; | 220 | Bool otherwm, readin; |
| 221 | Bool running = True; | 221 | Bool running = True; |
| 222 | uint tagset[] = {1, 1}; /* after start, first tag is selected */ | 222 | uint tagset[] = {1, 1}; /* after start, first tag is selected */ |
| @@ -268,15 +268,16 @@ arrange(void) { | |||
| 268 | 268 | ||
| 269 | for(c = clients; c; c = c->next) | 269 | for(c = clients; c; c = c->next) |
| 270 | if(VISIBLE(c)) { | 270 | if(VISIBLE(c)) { |
| 271 | unban(c); | ||
| 272 | if(!lt->arrange || c->isfloating) | 271 | if(!lt->arrange || c->isfloating) |
| 273 | resize(c, c->x, c->y, c->w, c->h, True); | 272 | resize(c, c->x, c->y, c->w, c->h, True); |
| 274 | } | 273 | } |
| 275 | else | 274 | else if(!c->isbanned) { |
| 276 | ban(c); | 275 | XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); |
| 276 | c->isbanned = True; | ||
| 277 | } | ||
| 277 | 278 | ||
| 278 | focus(NULL); | 279 | focus(NULL); |
| 279 | if(lt->arrange) | 280 | if(lt->arrange && !domax) |
| 280 | lt->arrange(); | 281 | lt->arrange(); |
| 281 | restack(); | 282 | restack(); |
| 282 | } | 283 | } |
| @@ -296,14 +297,6 @@ attachstack(Client *c) { | |||
| 296 | } | 297 | } |
| 297 | 298 | ||
| 298 | void | 299 | void |
| 299 | ban(Client *c) { | ||
| 300 | if(c->isbanned) | ||
| 301 | return; | ||
| 302 | XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); | ||
| 303 | c->isbanned = True; | ||
| 304 | } | ||
| 305 | |||
| 306 | void | ||
| 307 | buttonpress(XEvent *e) { | 300 | buttonpress(XEvent *e) { |
| 308 | uint i, x, mask; | 301 | uint i, x, mask; |
| 309 | Client *c; | 302 | Client *c; |
| @@ -330,23 +323,23 @@ buttonpress(XEvent *e) { | |||
| 330 | return; | 323 | return; |
| 331 | } | 324 | } |
| 332 | } | 325 | } |
| 333 | if((ev->x < x + blw) && ev->button == Button1) | 326 | if(ev->x < x + blw) { |
| 334 | togglelayout(NULL); | 327 | if(ev->button == Button1) |
| 328 | togglelayout(NULL); | ||
| 329 | else if(ev->button == Button3) | ||
| 330 | togglemax(NULL); | ||
| 331 | } | ||
| 335 | } | 332 | } |
| 336 | else if((c = getclient(ev->window))) { | 333 | else if((c = getclient(ev->window))) { |
| 337 | focus(c); | 334 | focus(c); |
| 338 | if(CLEANMASK(ev->state) != MODKEY) | 335 | if(CLEANMASK(ev->state) != MODKEY || domax) |
| 339 | return; | 336 | return; |
| 340 | if(ev->button == Button1) { | 337 | if(ev->button == Button1) |
| 341 | restack(); | ||
| 342 | movemouse(c); | 338 | movemouse(c); |
| 343 | } | ||
| 344 | else if(ev->button == Button2) | 339 | else if(ev->button == Button2) |
| 345 | togglefloating(NULL); | 340 | togglefloating(NULL); |
| 346 | else if(ev->button == Button3 && !c->isfixed) { | 341 | else if(ev->button == Button3 && !c->isfixed) |
| 347 | restack(); | ||
| 348 | resizemouse(c); | 342 | resizemouse(c); |
| 349 | } | ||
| 350 | } | 343 | } |
| 351 | } | 344 | } |
| 352 | 345 | ||
| @@ -369,10 +362,9 @@ checkotherwm(void) { | |||
| 369 | void | 362 | void |
| 370 | cleanup(void) { | 363 | cleanup(void) { |
| 371 | close(STDIN_FILENO); | 364 | close(STDIN_FILENO); |
| 372 | while(stack) { | 365 | view(NULL); |
| 373 | unban(stack); | 366 | while(stack) |
| 374 | unmanage(stack); | 367 | unmanage(stack); |
| 375 | } | ||
| 376 | if(dc.font.set) | 368 | if(dc.font.set) |
| 377 | XFreeFontSet(dpy, dc.font.set); | 369 | XFreeFontSet(dpy, dc.font.set); |
| 378 | else | 370 | else |
| @@ -512,7 +504,7 @@ drawbar(void) { | |||
| 512 | } | 504 | } |
| 513 | if(blw > 0) { | 505 | if(blw > 0) { |
| 514 | dc.w = blw; | 506 | dc.w = blw; |
| 515 | drawtext(lt->symbol, dc.norm, False); | 507 | drawtext(lt->symbol, dc.norm, domax); |
| 516 | x = dc.x + dc.w; | 508 | x = dc.x + dc.w; |
| 517 | } | 509 | } |
| 518 | else | 510 | else |
| @@ -641,6 +633,10 @@ focus(Client *c) { | |||
| 641 | } | 633 | } |
| 642 | sel = c; | 634 | sel = c; |
| 643 | if(c) { | 635 | if(c) { |
| 636 | if(domax) { | ||
| 637 | XMoveResizeWindow(dpy, c->win, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw); | ||
| 638 | c->ismax = True; | ||
| 639 | } | ||
| 644 | XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]); | 640 | XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]); |
| 645 | XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); | 641 | XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); |
| 646 | } | 642 | } |
| @@ -960,7 +956,6 @@ manage(Window w, XWindowAttributes *wa) { | |||
| 960 | attach(c); | 956 | attach(c); |
| 961 | attachstack(c); | 957 | attachstack(c); |
| 962 | XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); /* some windows require this */ | 958 | XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); /* some windows require this */ |
| 963 | ban(c); | ||
| 964 | XMapWindow(dpy, c->win); | 959 | XMapWindow(dpy, c->win); |
| 965 | setclientstate(c, NormalState); | 960 | setclientstate(c, NormalState); |
| 966 | arrange(); | 961 | arrange(); |
| @@ -995,6 +990,7 @@ movemouse(Client *c) { | |||
| 995 | Window dummy; | 990 | Window dummy; |
| 996 | XEvent ev; | 991 | XEvent ev; |
| 997 | 992 | ||
| 993 | restack(); | ||
| 998 | ocx = nx = c->x; | 994 | ocx = nx = c->x; |
| 999 | ocy = ny = c->y; | 995 | ocy = ny = c->y; |
| 1000 | if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, | 996 | if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, |
| @@ -1130,7 +1126,8 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) { | |||
| 1130 | x = sx; | 1126 | x = sx; |
| 1131 | if(y + h + 2 * c->bw < sy) | 1127 | if(y + h + 2 * c->bw < sy) |
| 1132 | y = sy; | 1128 | y = sy; |
| 1133 | if(c->x != x || c->y != y || c->w != w || c->h != h) { | 1129 | if(c->x != x || c->y != y || c->w != w || c->h != h || c->isbanned || c->ismax) { |
| 1130 | c->isbanned = c->ismax = False; | ||
| 1134 | c->x = wc.x = x; | 1131 | c->x = wc.x = x; |
| 1135 | c->y = wc.y = y; | 1132 | c->y = wc.y = y; |
| 1136 | c->w = wc.width = w; | 1133 | c->w = wc.width = w; |
| @@ -1149,6 +1146,7 @@ resizemouse(Client *c) { | |||
| 1149 | int nw, nh; | 1146 | int nw, nh; |
| 1150 | XEvent ev; | 1147 | XEvent ev; |
| 1151 | 1148 | ||
| 1149 | restack(); | ||
| 1152 | ocx = c->x; | 1150 | ocx = c->x; |
| 1153 | ocy = c->y; | 1151 | ocy = c->y; |
| 1154 | if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, | 1152 | if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, |
| @@ -1196,9 +1194,9 @@ restack(void) { | |||
| 1196 | drawbar(); | 1194 | drawbar(); |
| 1197 | if(!sel) | 1195 | if(!sel) |
| 1198 | return; | 1196 | return; |
| 1199 | if(sel->isfloating || !lt->arrange) | 1197 | if(domax || sel->isfloating || !lt->arrange) |
| 1200 | XRaiseWindow(dpy, sel->win); | 1198 | XRaiseWindow(dpy, sel->win); |
| 1201 | if(lt->arrange) { | 1199 | if(!domax && lt->arrange) { |
| 1202 | wc.stack_mode = Below; | 1200 | wc.stack_mode = Below; |
| 1203 | wc.sibling = barwin; | 1201 | wc.sibling = barwin; |
| 1204 | for(c = stack; c; c = c->snext) | 1202 | for(c = stack; c; c = c->snext) |
| @@ -1532,6 +1530,12 @@ togglelayout(const void *arg) { | |||
| 1532 | } | 1530 | } |
| 1533 | 1531 | ||
| 1534 | void | 1532 | void |
| 1533 | togglemax(const void *arg) { | ||
| 1534 | domax = !domax; | ||
| 1535 | arrange(); | ||
| 1536 | } | ||
| 1537 | |||
| 1538 | void | ||
| 1535 | toggletag(const void *arg) { | 1539 | toggletag(const void *arg) { |
| 1536 | if(sel && (sel->tags ^ ((*(int *)arg) & TAGMASK))) { | 1540 | if(sel && (sel->tags ^ ((*(int *)arg) & TAGMASK))) { |
| 1537 | sel->tags ^= (*(int *)arg) & TAGMASK; | 1541 | sel->tags ^= (*(int *)arg) & TAGMASK; |
| @@ -1548,14 +1552,6 @@ toggleview(const void *arg) { | |||
| 1548 | } | 1552 | } |
| 1549 | 1553 | ||
| 1550 | void | 1554 | void |
| 1551 | unban(Client *c) { | ||
| 1552 | if(!c->isbanned) | ||
| 1553 | return; | ||
| 1554 | XMoveWindow(dpy, c->win, c->x, c->y); | ||
| 1555 | c->isbanned = False; | ||
| 1556 | } | ||
| 1557 | |||
| 1558 | void | ||
| 1559 | unmanage(Client *c) { | 1555 | unmanage(Client *c) { |
| 1560 | XWindowChanges wc; | 1556 | XWindowChanges wc; |
| 1561 | 1557 | ||
