# HG changeset patch # User arg@10ksloc.org # Date 1153400855 -7200 # Node ID 75576e44c1d8fb6c7b5b77d7de87f95fea0656a2 # Parent 61490330e90acab8d2530b4f7aabf6d30ec30249 made status bar drawing more robust, implemented togglemax and togglemode, works quite well diff -r 61490330e90a -r 75576e44c1d8 client.c --- a/client.c Thu Jul 20 12:18:06 2006 +0200 +++ b/client.c Thu Jul 20 15:07:35 2006 +0200 @@ -70,6 +70,9 @@ if(!sel) return; + if(sel->ismax) + togglemax(NULL); + if(!(c = getnext(sel->next, tsel))) c = getnext(clients, tsel); if(c) { @@ -87,6 +90,9 @@ if(!sel) return; + if(sel->ismax) + togglemax(NULL); + if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) { higher(c); focus(c); @@ -234,8 +240,6 @@ c->next = clients; clients = c; - XGrabButton(dpy, Button1, ControlMask, c->win, False, ButtonPressMask, - GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button1, MODKEY, c->win, False, ButtonPressMask, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button2, MODKEY, c->win, False, ButtonPressMask, @@ -264,19 +268,6 @@ } void -maximize(Arg *arg) -{ - if(!sel) - return; - sel->x = sx; - sel->y = sy + bh; - sel->w = sw - 2 * sel->border; - sel->h = sh - 2 * sel->border - bh; - higher(sel); - resize(sel, False, TopLeft); -} - -void pop(Client *c) { Client **l; @@ -405,6 +396,38 @@ } void +togglemax(Arg *arg) +{ + int ox, oy, ow, oh; + XEvent ev; + + if(!sel) + return; + + if((sel->ismax = !sel->ismax)) { + ox = sel->x; + oy = sel->y; + ow = sel->w; + oh = sel->h; + sel->x = sx; + sel->y = sy + bh; + sel->w = sw - 2 * sel->border; + sel->h = sh - 2 * sel->border - bh; + + higher(sel); + resize(sel, False, TopLeft); + + sel->x = ox; + sel->y = oy; + sel->w = ow; + sel->h = oh; + } + else + resize(sel, False, TopLeft); + while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); +} + +void unmanage(Client *c) { Client **l; diff -r 61490330e90a -r 75576e44c1d8 draw.c --- a/draw.c Thu Jul 20 12:18:06 2006 +0200 +++ b/draw.c Thu Jul 20 15:07:35 2006 +0200 @@ -107,7 +107,7 @@ void drawstatus() { - int i; + int i, x; Bool istile = arrange == dotile; dc.x = dc.y = 0; @@ -123,15 +123,14 @@ else drawtext(tags[i], (i != tsel), True); } - if(sel) { - dc.x += dc.w; - dc.w = textw(sel->name); - drawtext(sel->name, istile, True); - } + x = dc.x + dc.w; dc.w = textw(stext); dc.x = bx + bw - dc.w; drawtext(stext, !istile, False); - + if(sel && ((dc.w = dc.x - x) >= bh)) { + dc.x = x; + drawtext(sel->name, istile, True); + } XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0); XSync(dpy, False); } diff -r 61490330e90a -r 75576e44c1d8 dwm.h --- a/dwm.h Thu Jul 20 12:18:06 2006 +0200 +++ b/dwm.h Thu Jul 20 15:07:35 2006 +0200 @@ -74,6 +74,7 @@ unsigned int border; long flags; Bool isfloat; + Bool ismax; Client *next; Client *revert; Window win; @@ -104,11 +105,11 @@ extern void killclient(Arg *arg); extern void lower(Client *c); extern void manage(Window w, XWindowAttributes *wa); -extern void maximize(Arg *arg); extern void pop(Client *c); extern void resize(Client *c, Bool inc, Corner sticky); extern void setsize(Client *c); extern void settitle(Client *c); +extern void togglemax(Arg *arg); extern void unmanage(Client *c); extern void zoom(Arg *arg); @@ -137,6 +138,7 @@ extern void heretag(Arg *arg); extern void replacetag(Arg *arg); extern void settags(Client *c); +extern void togglemode(Arg *arg); extern void view(Arg *arg); /* util.c */ diff -r 61490330e90a -r 75576e44c1d8 event.c --- a/event.c Thu Jul 20 12:18:06 2006 +0200 +++ b/event.c Thu Jul 20 15:07:35 2006 +0200 @@ -40,8 +40,8 @@ { MODKEY, XK_3, view, { .i = Twork } }, { MODKEY, XK_j, focusnext, { 0 } }, { MODKEY, XK_k, focusprev, { 0 } }, - { MODKEY, XK_m, maximize, { 0 } }, - { MODKEY, XK_space, dotile, { 0 } }, + { MODKEY, XK_m, togglemax, { 0 } }, + { MODKEY, XK_space, togglemode, { 0 } }, { MODKEY, XK_Return, zoom, { 0 } }, { ControlMask|ShiftMask,XK_0, heretag, { .i = Tscratch } }, { ControlMask|ShiftMask,XK_1, heretag, { .i = Tdev } }, @@ -55,7 +55,6 @@ { MODKEY|ShiftMask, XK_g, spawn, { .argv = gimp } }, { MODKEY|ShiftMask, XK_l, spawn, { .argv = xlock } }, { MODKEY|ShiftMask, XK_q, quit, { 0 } }, - { MODKEY|ShiftMask, XK_space, dofloat, { 0 } }, { MODKEY|ShiftMask, XK_w, spawn, { .argv = browse } }, { MODKEY|ShiftMask, XK_Return, spawn, { .argv = term } }, }; @@ -170,11 +169,7 @@ default: break; case Button1: - if(arrange == dotile && !c->isfloat) { - if((ev->state & ControlMask) && (ev->button == Button1)) - zoom(NULL); - } - else { + if(arrange == dofloat || c->isfloat) { higher(c); movemouse(c); } diff -r 61490330e90a -r 75576e44c1d8 tag.c --- a/tag.c Thu Jul 20 12:18:06 2006 +0200 +++ b/tag.c Thu Jul 20 15:07:35 2006 +0200 @@ -51,8 +51,8 @@ { Client *c; - arrange = dofloat; for(c = clients; c; c = c->next) { + c->ismax = False; if(c->tags[tsel]) { resize(c, True, TopLeft); } @@ -75,7 +75,6 @@ Client *c; w = sw - mw; - arrange = dotile; for(n = 0, c = clients; c; c = c->next) if(c->tags[tsel] && !c->isfloat) n++; @@ -86,6 +85,7 @@ h = sh - bh; for(i = 0, c = clients; c; c = c->next) { + c->ismax = False; if(c->tags[tsel]) { if(c->isfloat) { higher(c); @@ -213,6 +213,13 @@ } void +togglemode(Arg *arg) +{ + arrange = arrange == dofloat ? dotile : dofloat; + arrange(NULL); +} + +void view(Arg *arg) { tsel = arg->i;