Browse Source

implemented viewextend and added M-S-C-n shortcuts for extending the current view... updated man page (works great!) nice feature

main
Anselm R.Garbe 18 years ago
parent
commit
292ccc4c43
8 changed files with 100 additions and 68 deletions
  1. +24
    -21
      config.arg.h
  2. +31
    -26
      config.default.h
  3. +2
    -2
      draw.c
  4. +17
    -4
      dwm.1
  5. +2
    -1
      dwm.h
  6. +2
    -5
      event.c
  7. +3
    -3
      main.c
  8. +19
    -6
      tag.c

+ 24
- 21
config.arg.h View File

@ -18,31 +18,34 @@ const char *tags[] = { "work", "net", "fnord", NULL };
#define KEYS \ #define KEYS \
static Key key[] = { \ 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 | " \ { .cmd = "exec `ls -lL /usr/bin /usr/local/bin 2>/dev/null | " \
"awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort | uniq | dmenu`" } }, \ "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 " \ { .cmd = "exec urxvt +sb -tr -bg black -fg '#eeeeee' -cr '#eeeeee' +sb " \
"-fn '-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*'" } }, \ "-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 \ #define RULES \


+ 31
- 26
config.default.h View File

@ -18,32 +18,37 @@ const char *tags[] = { "0", "1", "2", "3", "4", NULL };
#define KEYS \ #define KEYS \
static Key key[] = { \ 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 \ #define RULES \


+ 2
- 2
draw.c View File

@ -109,9 +109,9 @@ drawstatus()
dc.x += dc.w; dc.x += dc.w;
dc.w = textw(tags[i]); dc.w = textw(tags[i]);
if(istile) if(istile)
drawtext(tags[i], tsel[i]);
drawtext(tags[i], seltag[i]);
else else
drawtext(tags[i], !tsel[i]);
drawtext(tags[i], !seltag[i]);
} }
x = dc.x + dc.w; x = dc.x + dc.w;
dc.w = textw(stext); dc.w = textw(stext);


+ 17
- 4
dwm.1 View File

@ -36,14 +36,21 @@ prints version information to standard output, then exits.
.B Standard input .B Standard input
is read and displayed in the status text area. is read and displayed in the status text area.
.TP .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 .TP
.B Button[1,4] .B Button[1,4]
click on the bar focuses the previous tag.
click on the bar focuses the previous
.B tag.
.TP .TP
.B Button[2,5] .B Button[2,5]
click on the bar focuses the next tag.
click on the bar focuses the next
.B tag.
.SS Keyboard commands .SS Keyboard commands
.TP .TP
.B Mod1-Return .B Mod1-Return
@ -108,6 +115,12 @@ Append
.B nth tag .B nth tag
to current to current
.B window. .B window.
.TP
.B Mod1-Control-Shift-[0..n]
(Un)extends
.B nth tag
with current
.B tag.
.SS Mouse commands .SS Mouse commands
.TP .TP
.B Mod1-Button1 .B Mod1-Button1


+ 2
- 1
dwm.h View File

@ -74,7 +74,7 @@ extern unsigned int ntags;
extern void (*handler[LASTEvent])(XEvent *); extern void (*handler[LASTEvent])(XEvent *);
extern void (*arrange)(Arg *); extern void (*arrange)(Arg *);
extern Atom wmatom[WMLast], netatom[NetLast]; extern Atom wmatom[WMLast], netatom[NetLast];
extern Bool running, issel, *tsel;
extern Bool running, issel, *seltag;
extern Client *clients, *sel; extern Client *clients, *sel;
extern Cursor cursor[CurLast]; extern Cursor cursor[CurLast];
extern DC dc; extern DC dc;
@ -128,6 +128,7 @@ extern void replacetag(Arg *arg);
extern void settags(Client *c); extern void settags(Client *c);
extern void togglemode(Arg *arg); extern void togglemode(Arg *arg);
extern void view(Arg *arg); extern void view(Arg *arg);
extern void viewextend(Arg *arg);
extern void viewnext(Arg *arg); extern void viewnext(Arg *arg);
extern void viewprev(Arg *arg); extern void viewprev(Arg *arg);


+ 2
- 5
event.c View File

@ -108,11 +108,8 @@ buttonpress(XEvent *e)
for(a.i = 0; a.i < ntags; a.i++) { for(a.i = 0; a.i < ntags; a.i++) {
x += textw(tags[a.i]); x += textw(tags[a.i]);
if(ev->x < x) { if(ev->x < x) {
if(ev->button == Button3) {
tsel[a.i] = True;
arrange(NULL);
drawall();
}
if(ev->button == Button3)
viewextend(&a);
else else
view(&a); view(&a);
return; return;


+ 3
- 3
main.c View File

@ -83,7 +83,7 @@ xerrorstart(Display *dsply, XErrorEvent *ee)
/* extern */ /* extern */
char stext[1024]; char stext[1024];
Bool *tsel;
Bool *seltag;
int screen, sx, sy, sw, sh, bx, by, bw, bh, mw; int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
unsigned int ntags; unsigned int ntags;
Atom wmatom[WMLast], netatom[NetLast]; Atom wmatom[WMLast], netatom[NetLast];
@ -213,8 +213,8 @@ main(int argc, char *argv[])
initrregs(); initrregs();
for(ntags = 0; tags[ntags]; ntags++); for(ntags = 0; tags[ntags]; ntags++);
tsel = emallocz(sizeof(Bool) * ntags);
tsel[DEFTAG] = True;
seltag = emallocz(sizeof(Bool) * ntags);
seltag[DEFTAG] = True;
/* style */ /* style */
dc.bg = getcolor(BGCOLOR); dc.bg = getcolor(BGCOLOR);


+ 19
- 6
tag.c View File

@ -181,7 +181,7 @@ isvisible(Client *c)
unsigned int i; unsigned int i;
for(i = 0; i < ntags; i++) for(i = 0; i < ntags; i++)
if(c->tags[i] && tsel[i])
if(c->tags[i] && seltag[i])
return True; return True;
return False; return False;
} }
@ -229,7 +229,7 @@ settags(Client *c)
} }
if(!matched) if(!matched)
for(i = 0; i < ntags; i++) for(i = 0; i < ntags; i++)
c->tags[i] = tsel[i];
c->tags[i] = seltag[i];
} }
void void
@ -245,8 +245,21 @@ view(Arg *arg)
unsigned int i; unsigned int i;
for(i = 0; i < ntags; 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); arrange(NULL);
drawall(); drawall();
} }
@ -256,7 +269,7 @@ viewnext(Arg *arg)
{ {
unsigned int i; unsigned int i;
for(i = 0; !tsel[i]; i++);
for(i = 0; !seltag[i]; i++);
arg->i = (i < ntags-1) ? i+1 : 0; arg->i = (i < ntags-1) ? i+1 : 0;
view(arg); view(arg);
} }
@ -266,7 +279,7 @@ viewprev(Arg *arg)
{ {
unsigned int i; unsigned int i;
for(i = 0; !tsel[i]; i++);
for(i = 0; !seltag[i]; i++);
arg->i = (i > 0) ? i-1 : ntags-1; arg->i = (i > 0) ? i-1 : ntags-1;
view(arg); view(arg);
} }

Loading…
Cancel
Save