diff -r 0c051f7b88e6 config.def.h --- a/config.def.h Thu May 15 10:51:37 2008 +0100 +++ b/config.def.h Sat May 17 14:50:26 2008 +0200 @@ -25,9 +25,8 @@ Layout layouts[] = { /* symbol function isfloating */ - { "[]=", tilev, False }, /* first entry is default */ - { "><>", NULL, True }, - { "", monocle, True }, + { "[]=", tilev }, /* first entry is default */ + { "><>", NULL }, }; /* key definitions */ @@ -45,7 +44,7 @@ { MODKEY, XK_h, setmfact, "-0.05" }, { MODKEY, XK_l, setmfact, "+0.05" }, { MODKEY, XK_Return, zoom, NULL }, - { MODKEY, XK_m, setlayout, "" }, + { MODKEY, XK_m, togglemax, NULL }, { MODKEY, XK_Tab, viewprevtag, NULL }, { MODKEY|ShiftMask, XK_c, killclient, NULL }, { MODKEY, XK_space, setlayout, NULL }, diff -r 0c051f7b88e6 dwm.c --- a/dwm.c Thu May 15 10:51:37 2008 +0100 +++ b/dwm.c Sat May 17 14:50:26 2008 +0200 @@ -60,7 +60,6 @@ struct Client { char name[256]; int x, y, w, h; - int fx, fy, fw, fh; int basew, baseh, incw, inch, maxw, maxh, minw, minh; int minax, maxax, minay, maxay; long flags; @@ -97,8 +96,7 @@ typedef struct { const char *symbol; - void (*arrange)(void); - Bool isfloating; + void (*tile)(void); } Layout; typedef struct { @@ -153,7 +151,6 @@ void manage(Window w, XWindowAttributes *wa); void mappingnotify(XEvent *e); void maprequest(XEvent *e); -void monocle(void); void movemouse(Client *c); Client *nexttiled(Client *c); void propertynotify(XEvent *e); @@ -179,6 +176,7 @@ void tilev(void); void tilevstack(unsigned int n); void togglefloating(const char *arg); +void togglemax(const char *arg); void toggletag(const char *arg); void toggleview(const char *arg); void unban(Client *c); @@ -201,6 +199,7 @@ int screen, sx, sy, sw, sh; int (*xerrorxlib)(Display *, XErrorEvent *); int bx, by, bw, bh, blw, mx, my, mw, mh, tx, ty, tw, th, wx, wy, ww, wh; +int rx, ry, rw, rh; int seltags = 0; double mfact; unsigned int numlockmask = 0; @@ -219,10 +218,12 @@ [UnmapNotify] = unmapnotify }; Atom wmatom[WMLast], netatom[NetLast]; +Bool domax = False; Bool otherwm, readin; Bool running = True; Bool *tagset[2]; Client *clients = NULL; +Client *revert = NULL; Client *sel = NULL; Client *stack = NULL; Cursor cursor[CurLast]; @@ -271,18 +272,18 @@ arrange(void) { Client *c; + focus(NULL); for(c = clients; c; c = c->next) if(isvisible(c, NULL)) { unban(c); - if(lt->isfloating || c->isfloating) - resize(c, c->fx, c->fy, c->fw, c->fh, True); + if(!lt->tile || c->isfloating) + resize(c, c->x, c->y, c->w, c->h, True); } else ban(c); - focus(NULL); - if(lt->arrange) - lt->arrange(); + if(lt->tile && !domax) + lt->tile(); restack(); } @@ -334,8 +335,12 @@ return; } } - if((ev->x < x + blw) && ev->button == Button1) - setlayout(NULL); + if(ev->x < x + blw) { + if(ev->button == Button1) + setlayout(NULL); + else if(ev->button == Button3) + togglemax(NULL); + } } else if((c = getclient(ev->window))) { focus(c); @@ -346,7 +351,7 @@ movemouse(c); } else if(ev->button == Button2) { - if(!lt->isfloating && c->isfloating) + if(!lt->tile && c->isfloating) togglefloating(NULL); else zoom(NULL); @@ -436,7 +441,7 @@ if((c = getclient(ev->window))) { if(ev->value_mask & CWBorderWidth) c->bw = ev->border_width; - if(c->isfixed || c->isfloating || lt->isfloating) { + if(c->isfixed || c->isfloating || !lt->tile) { if(ev->value_mask & CWX) c->x = sx + ev->x; if(ev->value_mask & CWY) @@ -529,7 +534,7 @@ } if(blw > 0) { dc.w = blw; - drawtext(lt->symbol, dc.norm, False); + drawtext(lt->symbol, dc.norm, domax); x = dc.x + dc.w; } else @@ -626,7 +631,7 @@ Client *c; XCrossingEvent *ev = &e->xcrossing; - if((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root) + if(((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root) || domax) return; if((c = getclient(ev->window))) focus(c); @@ -656,6 +661,10 @@ focus(Client *c) { if(!c || (c && !isvisible(c, NULL))) for(c = stack; c && !isvisible(c, NULL); c = c->snext); + if(revert) { + resize(revert, rx, ry, rw, rh, RESIZEHINTS | revert->isfloating); + revert = NULL; + } if(sel && sel != c) { grabbuttons(sel, False); XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]); @@ -667,6 +676,15 @@ } sel = c; if(c) { + if(domax) { + rx = c->x; + ry = c->y; + rw = c->w; + rh = c->h; + XRaiseWindow(dpy, c->win); + resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw, RESIZEHINTS); + revert = c; + } XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]); XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); } @@ -969,8 +987,8 @@ /* geometry */ c->x = wa->x; c->y = wa->y; - c->w = c->fw = wa->width; - c->h = c->fh = wa->height; + c->w = wa->width; + c->h = wa->height; c->oldbw = wa->border_width; if(c->w == sw && c->h == sh) { c->x = sx; @@ -986,8 +1004,6 @@ c->y = MAX(c->y, wy); c->bw = BORDERPX; } - c->fx = c->x; - c->fy = c->y; wc.border_width = c->bw; XConfigureWindow(dpy, w, CWBorderWidth, &wc); @@ -1037,15 +1053,6 @@ } void -monocle(void) { - Client *c; - - for(c = clients; c; c = c->next) - if((lt->isfloating || !c->isfloating) && isvisible(c, NULL)) - resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw, RESIZEHINTS); -} - -void movemouse(Client *c) { int x1, y1, ocx, ocy, di, nx, ny; unsigned int dui; @@ -1081,13 +1088,10 @@ ny = wy; else if(abs((wy + wh) - (ny + c->h + 2 * c->bw)) < SNAP) ny = wy + wh - c->h - 2 * c->bw; - if(!c->isfloating && !lt->isfloating && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP)) + if(!c->isfloating && lt->tile && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP)) togglefloating(NULL); - if(lt->isfloating || c->isfloating) { - c->fx = nx; - c->fy = ny; + if(!lt->tile || c->isfloating) resize(c, nx, ny, c->w, c->h, False); - } break; } } @@ -1241,16 +1245,10 @@ XSync(dpy, False); nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); - if(!c->isfloating && !lt->isfloating && (abs(nw - c->w) > SNAP || abs(nh - c->h) > SNAP)) { - c->fx = c->x; - c->fy = c->y; + if(!c->isfloating && lt->tile && (abs(nw - c->w) > SNAP || abs(nh - c->h) > SNAP)) togglefloating(NULL); - } - if((lt->isfloating) || c->isfloating) { + if((!lt->tile) || c->isfloating) resize(c, c->x, c->y, nw, nh, True); - c->fw = nw; - c->fh = nh; - } break; } } @@ -1265,9 +1263,9 @@ drawbar(); if(!sel) return; - if(sel->isfloating || lt->isfloating) + if(sel->isfloating || !lt->tile) XRaiseWindow(dpy, sel->win); - if(!lt->isfloating) { + if(lt->tile) { wc.stack_mode = Below; wc.sibling = barwin; for(c = stack; c; c = c->snext) @@ -1401,7 +1399,7 @@ setmfact(const char *arg) { double d; - if(lt->isfloating) + if(!lt->tile) return; if(!arg) mfact = MFACT; @@ -1632,6 +1630,12 @@ sel->isfloating = !sel->isfloating; if(sel->isfloating) resize(sel, sel->x, sel->y, sel->w, sel->h, True); + arrange(); +} + +void +togglemax(const char *arg) { + domax = !domax; arrange(); } @@ -1861,7 +1865,7 @@ if(c == nexttiled(clients)) if(!c || !(c = nexttiled(c->next))) return; - if(!lt->isfloating && !sel->isfloating) { + if(lt->tile && !sel->isfloating) { detach(c); attach(c); focus(c);