dwm-meillo
changeset 124:75576e44c1d8
made status bar drawing more robust, implemented togglemax and togglemode, works quite well
author | arg@10ksloc.org |
---|---|
date | Thu, 20 Jul 2006 15:07:35 +0200 |
parents | 61490330e90a |
children | b4b8b4236599 |
files | client.c draw.c dwm.h event.c tag.c |
diffstat | 5 files changed, 59 insertions(+), 33 deletions(-) [+] |
line diff
1.1 --- a/client.c Thu Jul 20 12:18:06 2006 +0200 1.2 +++ b/client.c Thu Jul 20 15:07:35 2006 +0200 1.3 @@ -70,6 +70,9 @@ 1.4 if(!sel) 1.5 return; 1.6 1.7 + if(sel->ismax) 1.8 + togglemax(NULL); 1.9 + 1.10 if(!(c = getnext(sel->next, tsel))) 1.11 c = getnext(clients, tsel); 1.12 if(c) { 1.13 @@ -87,6 +90,9 @@ 1.14 if(!sel) 1.15 return; 1.16 1.17 + if(sel->ismax) 1.18 + togglemax(NULL); 1.19 + 1.20 if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) { 1.21 higher(c); 1.22 focus(c); 1.23 @@ -234,8 +240,6 @@ 1.24 c->next = clients; 1.25 clients = c; 1.26 1.27 - XGrabButton(dpy, Button1, ControlMask, c->win, False, ButtonPressMask, 1.28 - GrabModeAsync, GrabModeSync, None, None); 1.29 XGrabButton(dpy, Button1, MODKEY, c->win, False, ButtonPressMask, 1.30 GrabModeAsync, GrabModeSync, None, None); 1.31 XGrabButton(dpy, Button2, MODKEY, c->win, False, ButtonPressMask, 1.32 @@ -264,19 +268,6 @@ 1.33 } 1.34 1.35 void 1.36 -maximize(Arg *arg) 1.37 -{ 1.38 - if(!sel) 1.39 - return; 1.40 - sel->x = sx; 1.41 - sel->y = sy + bh; 1.42 - sel->w = sw - 2 * sel->border; 1.43 - sel->h = sh - 2 * sel->border - bh; 1.44 - higher(sel); 1.45 - resize(sel, False, TopLeft); 1.46 -} 1.47 - 1.48 -void 1.49 pop(Client *c) 1.50 { 1.51 Client **l; 1.52 @@ -405,6 +396,38 @@ 1.53 } 1.54 1.55 void 1.56 +togglemax(Arg *arg) 1.57 +{ 1.58 + int ox, oy, ow, oh; 1.59 + XEvent ev; 1.60 + 1.61 + if(!sel) 1.62 + return; 1.63 + 1.64 + if((sel->ismax = !sel->ismax)) { 1.65 + ox = sel->x; 1.66 + oy = sel->y; 1.67 + ow = sel->w; 1.68 + oh = sel->h; 1.69 + sel->x = sx; 1.70 + sel->y = sy + bh; 1.71 + sel->w = sw - 2 * sel->border; 1.72 + sel->h = sh - 2 * sel->border - bh; 1.73 + 1.74 + higher(sel); 1.75 + resize(sel, False, TopLeft); 1.76 + 1.77 + sel->x = ox; 1.78 + sel->y = oy; 1.79 + sel->w = ow; 1.80 + sel->h = oh; 1.81 + } 1.82 + else 1.83 + resize(sel, False, TopLeft); 1.84 + while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); 1.85 +} 1.86 + 1.87 +void 1.88 unmanage(Client *c) 1.89 { 1.90 Client **l;
2.1 --- a/draw.c Thu Jul 20 12:18:06 2006 +0200 2.2 +++ b/draw.c Thu Jul 20 15:07:35 2006 +0200 2.3 @@ -107,7 +107,7 @@ 2.4 void 2.5 drawstatus() 2.6 { 2.7 - int i; 2.8 + int i, x; 2.9 Bool istile = arrange == dotile; 2.10 2.11 dc.x = dc.y = 0; 2.12 @@ -123,15 +123,14 @@ 2.13 else 2.14 drawtext(tags[i], (i != tsel), True); 2.15 } 2.16 - if(sel) { 2.17 - dc.x += dc.w; 2.18 - dc.w = textw(sel->name); 2.19 - drawtext(sel->name, istile, True); 2.20 - } 2.21 + x = dc.x + dc.w; 2.22 dc.w = textw(stext); 2.23 dc.x = bx + bw - dc.w; 2.24 drawtext(stext, !istile, False); 2.25 - 2.26 + if(sel && ((dc.w = dc.x - x) >= bh)) { 2.27 + dc.x = x; 2.28 + drawtext(sel->name, istile, True); 2.29 + } 2.30 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0); 2.31 XSync(dpy, False); 2.32 }
3.1 --- a/dwm.h Thu Jul 20 12:18:06 2006 +0200 3.2 +++ b/dwm.h Thu Jul 20 15:07:35 2006 +0200 3.3 @@ -74,6 +74,7 @@ 3.4 unsigned int border; 3.5 long flags; 3.6 Bool isfloat; 3.7 + Bool ismax; 3.8 Client *next; 3.9 Client *revert; 3.10 Window win; 3.11 @@ -104,11 +105,11 @@ 3.12 extern void killclient(Arg *arg); 3.13 extern void lower(Client *c); 3.14 extern void manage(Window w, XWindowAttributes *wa); 3.15 -extern void maximize(Arg *arg); 3.16 extern void pop(Client *c); 3.17 extern void resize(Client *c, Bool inc, Corner sticky); 3.18 extern void setsize(Client *c); 3.19 extern void settitle(Client *c); 3.20 +extern void togglemax(Arg *arg); 3.21 extern void unmanage(Client *c); 3.22 extern void zoom(Arg *arg); 3.23 3.24 @@ -137,6 +138,7 @@ 3.25 extern void heretag(Arg *arg); 3.26 extern void replacetag(Arg *arg); 3.27 extern void settags(Client *c); 3.28 +extern void togglemode(Arg *arg); 3.29 extern void view(Arg *arg); 3.30 3.31 /* util.c */
4.1 --- a/event.c Thu Jul 20 12:18:06 2006 +0200 4.2 +++ b/event.c Thu Jul 20 15:07:35 2006 +0200 4.3 @@ -40,8 +40,8 @@ 4.4 { MODKEY, XK_3, view, { .i = Twork } }, 4.5 { MODKEY, XK_j, focusnext, { 0 } }, 4.6 { MODKEY, XK_k, focusprev, { 0 } }, 4.7 - { MODKEY, XK_m, maximize, { 0 } }, 4.8 - { MODKEY, XK_space, dotile, { 0 } }, 4.9 + { MODKEY, XK_m, togglemax, { 0 } }, 4.10 + { MODKEY, XK_space, togglemode, { 0 } }, 4.11 { MODKEY, XK_Return, zoom, { 0 } }, 4.12 { ControlMask|ShiftMask,XK_0, heretag, { .i = Tscratch } }, 4.13 { ControlMask|ShiftMask,XK_1, heretag, { .i = Tdev } }, 4.14 @@ -55,7 +55,6 @@ 4.15 { MODKEY|ShiftMask, XK_g, spawn, { .argv = gimp } }, 4.16 { MODKEY|ShiftMask, XK_l, spawn, { .argv = xlock } }, 4.17 { MODKEY|ShiftMask, XK_q, quit, { 0 } }, 4.18 - { MODKEY|ShiftMask, XK_space, dofloat, { 0 } }, 4.19 { MODKEY|ShiftMask, XK_w, spawn, { .argv = browse } }, 4.20 { MODKEY|ShiftMask, XK_Return, spawn, { .argv = term } }, 4.21 }; 4.22 @@ -170,11 +169,7 @@ 4.23 default: 4.24 break; 4.25 case Button1: 4.26 - if(arrange == dotile && !c->isfloat) { 4.27 - if((ev->state & ControlMask) && (ev->button == Button1)) 4.28 - zoom(NULL); 4.29 - } 4.30 - else { 4.31 + if(arrange == dofloat || c->isfloat) { 4.32 higher(c); 4.33 movemouse(c); 4.34 }
5.1 --- a/tag.c Thu Jul 20 12:18:06 2006 +0200 5.2 +++ b/tag.c Thu Jul 20 15:07:35 2006 +0200 5.3 @@ -51,8 +51,8 @@ 5.4 { 5.5 Client *c; 5.6 5.7 - arrange = dofloat; 5.8 for(c = clients; c; c = c->next) { 5.9 + c->ismax = False; 5.10 if(c->tags[tsel]) { 5.11 resize(c, True, TopLeft); 5.12 } 5.13 @@ -75,7 +75,6 @@ 5.14 Client *c; 5.15 5.16 w = sw - mw; 5.17 - arrange = dotile; 5.18 for(n = 0, c = clients; c; c = c->next) 5.19 if(c->tags[tsel] && !c->isfloat) 5.20 n++; 5.21 @@ -86,6 +85,7 @@ 5.22 h = sh - bh; 5.23 5.24 for(i = 0, c = clients; c; c = c->next) { 5.25 + c->ismax = False; 5.26 if(c->tags[tsel]) { 5.27 if(c->isfloat) { 5.28 higher(c); 5.29 @@ -213,6 +213,13 @@ 5.30 } 5.31 5.32 void 5.33 +togglemode(Arg *arg) 5.34 +{ 5.35 + arrange = arrange == dofloat ? dotile : dofloat; 5.36 + arrange(NULL); 5.37 +} 5.38 + 5.39 +void 5.40 view(Arg *arg) 5.41 { 5.42 tsel = arg->i;