implemented viewextend and added M-S-C-n shortcuts for extending the current view... updated man page (works great!) nice feature - dwm - dynamic window manager HTML git clone https://git.parazyd.org/dwm DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR commit 292ccc4c43d9529cb6db0973fcab6e24c73607a5 DIR parent d7413ffd2d9a84fc3140b28b26f8cb6bb80164e4 HTML Author: Anselm R.Garbe <arg@10ksloc.org> Date: Fri, 11 Aug 2006 19:26:12 +0200 implemented viewextend and added M-S-C-n shortcuts for extending the current view... updated man page (works great!) nice feature Diffstat: M config.arg.h | 45 +++++++++++++++++--------------- M config.default.h | 57 +++++++++++++++++-------------- M draw.c | 4 ++-- M dwm.1 | 21 +++++++++++++++++---- M dwm.h | 3 ++- M event.c | 7 ++----- M main.c | 6 +++--- M tag.c | 25 +++++++++++++++++++------ 8 files changed, 100 insertions(+), 68 deletions(-) --- DIR diff --git a/config.arg.h b/config.arg.h @@ -18,31 +18,34 @@ const char *tags[] = { "work", "net", "fnord", NULL }; #define KEYS \ static Key key[] = { \ - /* modifier key function arguments */ \ - { MODKEY, XK_1, view, { .i = 0 } }, \ - { MODKEY, XK_2, view, { .i = 1 } }, \ - { MODKEY, XK_3, view, { .i = 2 } }, \ - { MODKEY, XK_h, viewprev, { 0 } }, \ - { MODKEY, XK_j, focusnext, { 0 } }, \ - { MODKEY, XK_k, focusprev, { 0 } }, \ - { MODKEY, XK_l, viewnext, { 0 } }, \ - { MODKEY, XK_m, togglemax, { 0 } }, \ - { MODKEY, XK_p, spawn, \ + /* modifier key function arguments */ \ + { MODKEY, XK_1, view, { .i = 0 } }, \ + { MODKEY, XK_2, view, { .i = 1 } }, \ + { MODKEY, XK_3, view, { .i = 2 } }, \ + { MODKEY, XK_h, viewprev, { 0 } }, \ + { MODKEY, XK_j, focusnext, { 0 } }, \ + { MODKEY, XK_k, focusprev, { 0 } }, \ + { MODKEY, XK_l, viewnext, { 0 } }, \ + { MODKEY, XK_m, togglemax, { 0 } }, \ + { MODKEY, XK_p, spawn, \ { .cmd = "exec `ls -lL /usr/bin /usr/local/bin 2>/dev/null | " \ "awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort | uniq | dmenu`" } }, \ - { MODKEY, XK_space, togglemode, { 0 } }, \ - { MODKEY, XK_Return, zoom, { 0 } }, \ - { MODKEY|ControlMask, XK_1, appendtag, { .i = 0 } }, \ - { MODKEY|ControlMask, XK_2, appendtag, { .i = 1 } }, \ - { MODKEY|ControlMask, XK_3, appendtag, { .i = 2 } }, \ - { MODKEY|ShiftMask, XK_1, replacetag, { .i = 0 } }, \ - { MODKEY|ShiftMask, XK_2, replacetag, { .i = 1 } }, \ - { MODKEY|ShiftMask, XK_3, replacetag, { .i = 2 } }, \ - { MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \ - { MODKEY|ShiftMask, XK_q, quit, { 0 } }, \ - { MODKEY|ShiftMask, XK_Return, spawn, \ + { MODKEY, XK_space, togglemode, { 0 } }, \ + { MODKEY, XK_Return, zoom, { 0 } }, \ + { MODKEY|ControlMask, XK_1, appendtag, { .i = 0 } }, \ + { MODKEY|ControlMask, XK_2, appendtag, { .i = 1 } }, \ + { MODKEY|ControlMask, XK_3, appendtag, { .i = 2 } }, \ + { MODKEY|ShiftMask, XK_1, replacetag, { .i = 0 } }, \ + { MODKEY|ShiftMask, XK_2, replacetag, { .i = 1 } }, \ + { MODKEY|ShiftMask, XK_3, replacetag, { .i = 2 } }, \ + { MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \ + { MODKEY|ShiftMask, XK_q, quit, { 0 } }, \ + { MODKEY|ShiftMask, XK_Return, spawn, \ { .cmd = "exec urxvt +sb -tr -bg black -fg '#eeeeee' -cr '#eeeeee' +sb " \ "-fn '-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*'" } }, \ + { MODKEY|ControlMask|ShiftMask, XK_1, viewextend, { .i = 0 } }, \ + { MODKEY|ShiftMask, XK_2, viewextend, { .i = 1 } }, \ + { MODKEY|ShiftMask, XK_3, viewextend, { .i = 2 } }, \ }; #define RULES \ DIR diff --git a/config.default.h b/config.default.h @@ -18,32 +18,37 @@ const char *tags[] = { "0", "1", "2", "3", "4", NULL }; #define KEYS \ static Key key[] = { \ - /* modifier key function arguments */ \ - { MODKEY, XK_0, view, { .i = 0 } }, \ - { MODKEY, XK_1, view, { .i = 1 } }, \ - { MODKEY, XK_2, view, { .i = 2 } }, \ - { MODKEY, XK_3, view, { .i = 3 } }, \ - { MODKEY, XK_4, view, { .i = 4 } }, \ - { MODKEY, XK_h, viewprev, { 0 } }, \ - { MODKEY, XK_j, focusnext, { 0 } }, \ - { MODKEY, XK_k, focusprev, { 0 } }, \ - { MODKEY, XK_l, viewnext, { 0 } }, \ - { MODKEY, XK_m, togglemax, { 0 } }, \ - { MODKEY, XK_space, togglemode, { 0 } }, \ - { MODKEY, XK_Return, zoom, { 0 } }, \ - { MODKEY|ControlMask, XK_0, appendtag, { .i = 0 } }, \ - { MODKEY|ControlMask, XK_1, appendtag, { .i = 1 } }, \ - { MODKEY|ControlMask, XK_2, appendtag, { .i = 2 } }, \ - { MODKEY|ControlMask, XK_3, appendtag, { .i = 3 } }, \ - { MODKEY|ControlMask, XK_4, appendtag, { .i = 4 } }, \ - { MODKEY|ShiftMask, XK_0, replacetag, { .i = 0 } }, \ - { MODKEY|ShiftMask, XK_1, replacetag, { .i = 1 } }, \ - { MODKEY|ShiftMask, XK_2, replacetag, { .i = 2 } }, \ - { MODKEY|ShiftMask, XK_3, replacetag, { .i = 3 } }, \ - { MODKEY|ShiftMask, XK_4, replacetag, { .i = 4 } }, \ - { MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \ - { MODKEY|ShiftMask, XK_q, quit, { 0 } }, \ - { MODKEY|ShiftMask, XK_Return, spawn, { .cmd = "exec xterm" } }, \ + /* modifier key function arguments */ \ + { MODKEY, XK_0, view, { .i = 0 } }, \ + { MODKEY, XK_1, view, { .i = 1 } }, \ + { MODKEY, XK_2, view, { .i = 2 } }, \ + { MODKEY, XK_3, view, { .i = 3 } }, \ + { MODKEY, XK_4, view, { .i = 4 } }, \ + { MODKEY, XK_h, viewprev, { 0 } }, \ + { MODKEY, XK_j, focusnext, { 0 } }, \ + { MODKEY, XK_k, focusprev, { 0 } }, \ + { MODKEY, XK_l, viewnext, { 0 } }, \ + { MODKEY, XK_m, togglemax, { 0 } }, \ + { MODKEY, XK_space, togglemode, { 0 } }, \ + { MODKEY, XK_Return, zoom, { 0 } }, \ + { MODKEY|ControlMask, XK_0, appendtag, { .i = 0 } }, \ + { MODKEY|ControlMask, XK_1, appendtag, { .i = 1 } }, \ + { MODKEY|ControlMask, XK_2, appendtag, { .i = 2 } }, \ + { MODKEY|ControlMask, XK_3, appendtag, { .i = 3 } }, \ + { MODKEY|ControlMask, XK_4, appendtag, { .i = 4 } }, \ + { MODKEY|ShiftMask, XK_0, replacetag, { .i = 0 } }, \ + { MODKEY|ShiftMask, XK_1, replacetag, { .i = 1 } }, \ + { MODKEY|ShiftMask, XK_2, replacetag, { .i = 2 } }, \ + { MODKEY|ShiftMask, XK_3, replacetag, { .i = 3 } }, \ + { MODKEY|ShiftMask, XK_4, replacetag, { .i = 4 } }, \ + { MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \ + { MODKEY|ShiftMask, XK_q, quit, { 0 } }, \ + { MODKEY|ShiftMask, XK_Return, spawn, { .cmd = "exec xterm" } }, \ + { MODKEY|ControlMask|ShiftMask, XK_0, viewextend, { .i = 0 } }, \ + { MODKEY|ControlMask|ShiftMask, XK_1, viewextend, { .i = 1 } }, \ + { MODKEY|ControlMask|ShiftMask, XK_2, viewextend, { .i = 2 } }, \ + { MODKEY|ControlMask|ShiftMask, XK_3, viewextend, { .i = 3 } }, \ + { MODKEY|ControlMask|ShiftMask, XK_4, viewextend, { .i = 4 } }, \ }; #define RULES \ DIR diff --git a/draw.c b/draw.c @@ -109,9 +109,9 @@ drawstatus() dc.x += dc.w; dc.w = textw(tags[i]); if(istile) - drawtext(tags[i], tsel[i]); + drawtext(tags[i], seltag[i]); else - drawtext(tags[i], !tsel[i]); + drawtext(tags[i], !seltag[i]); } x = dc.x + dc.w; dc.w = textw(stext); DIR diff --git a/dwm.1 b/dwm.1 @@ -36,14 +36,21 @@ prints version information to standard output, then exits. .B Standard input is read and displayed in the status text area. .TP -.B Button[1-3] -click on a tag label focuses that tag. +.B Button[1,3] +click on a tag label focuses that +.B tag. +.TP +.B Button2 +click on a tag label (un)extends the current +.B tag. .TP .B Button[1,4] -click on the bar focuses the previous tag. +click on the bar focuses the previous +.B tag. .TP .B Button[2,5] -click on the bar focuses the next tag. +click on the bar focuses the next +.B tag. .SS Keyboard commands .TP .B Mod1-Return @@ -108,6 +115,12 @@ Append .B nth tag to current .B window. +.TP +.B Mod1-Control-Shift-[0..n] +(Un)extends +.B nth tag +with current +.B tag. .SS Mouse commands .TP .B Mod1-Button1 DIR diff --git a/dwm.h b/dwm.h @@ -74,7 +74,7 @@ extern unsigned int ntags; extern void (*handler[LASTEvent])(XEvent *); extern void (*arrange)(Arg *); extern Atom wmatom[WMLast], netatom[NetLast]; -extern Bool running, issel, *tsel; +extern Bool running, issel, *seltag; extern Client *clients, *sel; extern Cursor cursor[CurLast]; extern DC dc; @@ -128,6 +128,7 @@ extern void replacetag(Arg *arg); extern void settags(Client *c); extern void togglemode(Arg *arg); extern void view(Arg *arg); +extern void viewextend(Arg *arg); extern void viewnext(Arg *arg); extern void viewprev(Arg *arg); DIR diff --git a/event.c b/event.c @@ -108,11 +108,8 @@ buttonpress(XEvent *e) for(a.i = 0; a.i < ntags; a.i++) { x += textw(tags[a.i]); if(ev->x < x) { - if(ev->button == Button3) { - tsel[a.i] = True; - arrange(NULL); - drawall(); - } + if(ev->button == Button3) + viewextend(&a); else view(&a); return; DIR diff --git a/main.c b/main.c @@ -83,7 +83,7 @@ xerrorstart(Display *dsply, XErrorEvent *ee) /* extern */ char stext[1024]; -Bool *tsel; +Bool *seltag; int screen, sx, sy, sw, sh, bx, by, bw, bh, mw; unsigned int ntags; Atom wmatom[WMLast], netatom[NetLast]; @@ -213,8 +213,8 @@ main(int argc, char *argv[]) initrregs(); for(ntags = 0; tags[ntags]; ntags++); - tsel = emallocz(sizeof(Bool) * ntags); - tsel[DEFTAG] = True; + seltag = emallocz(sizeof(Bool) * ntags); + seltag[DEFTAG] = True; /* style */ dc.bg = getcolor(BGCOLOR); DIR diff --git a/tag.c b/tag.c @@ -181,7 +181,7 @@ isvisible(Client *c) unsigned int i; for(i = 0; i < ntags; i++) - if(c->tags[i] && tsel[i]) + if(c->tags[i] && seltag[i]) return True; return False; } @@ -229,7 +229,7 @@ settags(Client *c) } if(!matched) for(i = 0; i < ntags; i++) - c->tags[i] = tsel[i]; + c->tags[i] = seltag[i]; } void @@ -245,8 +245,21 @@ view(Arg *arg) unsigned int i; for(i = 0; i < ntags; i++) - tsel[i] = False; - tsel[arg->i] = True; + seltag[i] = False; + seltag[arg->i] = True; + arrange(NULL); + drawall(); +} + +void +viewextend(Arg *arg) +{ + unsigned int i; + + seltag[arg->i] = !seltag[arg->i]; + for(i = 0; !seltag[i] && i < ntags; i++); + if(i == ntags) + seltag[arg->i] = True; /* cannot toggle last view */ arrange(NULL); drawall(); } @@ -256,7 +269,7 @@ viewnext(Arg *arg) { unsigned int i; - for(i = 0; !tsel[i]; i++); + for(i = 0; !seltag[i]; i++); arg->i = (i < ntags-1) ? i+1 : 0; view(arg); } @@ -266,7 +279,7 @@ viewprev(Arg *arg) { unsigned int i; - for(i = 0; !tsel[i]; i++); + for(i = 0; !seltag[i]; i++); arg->i = (i > 0) ? i-1 : ntags-1; view(arg); }