all repos — dwm @ 4688ad181da14be36e034918580ec0ce5968ffdb

my dwm build

made status bar drawing more robust, implemented togglemax and togglemode, works quite well
arg@10ksloc.org unknown
Thu, 20 Jul 2006 15:07:35 +0200
commit

4688ad181da14be36e034918580ec0ce5968ffdb

parent

dc5d967ee61046f899b3b49daeb9268c8161844a

5 files changed, 59 insertions(+), 33 deletions(-)

jump to
M client.cclient.c

@@ -70,6 +70,9 @@

if(!sel) return; + if(sel->ismax) + togglemax(NULL); + if(!(c = getnext(sel->next, tsel))) c = getnext(clients, tsel); if(c) {

@@ -86,6 +89,9 @@ Client *c;

if(!sel) return; + + if(sel->ismax) + togglemax(NULL); if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) { higher(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;

@@ -402,6 +393,38 @@ }

} XFree(name.value); resizetitle(c); +} + +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
M draw.cdraw.c

@@ -107,7 +107,7 @@

void drawstatus() { - int i; + int i, x; Bool istile = arrange == dotile; dc.x = dc.y = 0;

@@ -123,15 +123,14 @@ drawtext(tags[i], (i == tsel), True);

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); }
M dwm.hdwm.h

@@ -74,6 +74,7 @@ int grav;

unsigned int border; long flags; Bool isfloat; + Bool ismax; Client *next; Client *revert; Window win;

@@ -104,11 +105,11 @@ extern void higher(Client *c);

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 Client *getnext(Client *c, unsigned int t);

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 */
M event.cevent.c

@@ -40,8 +40,8 @@ { MODKEY, XK_2, view, { .i = Twww } },

{ 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_c, killclient, { 0 } },

{ 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 @@ switch(ev->button) {

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); }
M tag.ctag.c

@@ -51,8 +51,8 @@ dofloat(Arg *arg)

{ 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 @@ int n, i, w, h;

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 @@ else

h = sh - bh; for(i = 0, c = clients; c; c = c->next) { + c->ismax = False; if(c->tags[tsel]) { if(c->isfloat) { higher(c);

@@ -210,6 +210,13 @@ XFree(ch.res_name);

} if(!matched) c->tags[tsel] = tags[tsel]; +} + +void +togglemode(Arg *arg) +{ + arrange = arrange == dofloat ? dotile : dofloat; + arrange(NULL); } void