1
0

added MODKEY-{plus,minus} shortcuts (increasing/decreasing master clients)

This commit is contained in:
Anselm R. Garbe 2007-01-05 14:48:16 +01:00
parent 0b80d1842d
commit 06bae9dfb7
4 changed files with 62 additions and 15 deletions

View File

@ -31,13 +31,13 @@ static Key key[] = { \
{ .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \ { .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \
" | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \ " | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \
"-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" } }, \ "-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" } }, \
{ MODKEY, XK_d, incnmaster, { .i = -1 } }, \
{ MODKEY, XK_j, focusnext, { 0 } }, \ { MODKEY, XK_j, focusnext, { 0 } }, \
{ MODKEY, XK_k, focusprev, { 0 } }, \ { MODKEY, XK_k, focusprev, { 0 } }, \
{ MODKEY, XK_Return, zoom, { 0 } }, \ { MODKEY, XK_Return, zoom, { 0 } }, \
{ MODKEY, XK_g, resizemaster, { .i = 15 } }, \ { MODKEY, XK_g, resizemaster, { .i = 15 } }, \
{ MODKEY, XK_i, incnmaster, { .i = 1 } }, \
{ MODKEY, XK_s, resizemaster, { .i = -15 } }, \ { MODKEY, XK_s, resizemaster, { .i = -15 } }, \
{ MODKEY, XK_plus, incnmaster, { .i = 1 } }, \
{ MODKEY, XK_minus, incnmaster, { .i = -1 } }, \
{ MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \ { MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \ { MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \ { MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \

View File

@ -31,6 +31,8 @@ static Key key[] = { \
{ MODKEY, XK_Return, zoom, { 0 } }, \ { MODKEY, XK_Return, zoom, { 0 } }, \
{ MODKEY, XK_g, resizemaster, { .i = 15 } }, \ { MODKEY, XK_g, resizemaster, { .i = 15 } }, \
{ MODKEY, XK_s, resizemaster, { .i = -15 } }, \ { MODKEY, XK_s, resizemaster, { .i = -15 } }, \
{ MODKEY, XK_plus, incnmaster, { .i = 1 } }, \
{ MODKEY, XK_minus, incnmaster, { .i = -1 } }, \
{ MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \ { MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \ { MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \ { MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \

6
dwm.1
View File

@ -70,6 +70,12 @@ Grow master area (tiling mode only).
.B Mod1-s .B Mod1-s
Shrink master area (tiling mode only). Shrink master area (tiling mode only).
.TP .TP
.B Mod1-plus
Increase clients of master area (tiling mode only).
.TP
.B Mod1-minus
Decrease clients of master area (tiling mode only).
.TP
.B Mod1-Shift-[1..n] .B Mod1-Shift-[1..n]
Apply Apply
.RB nth .RB nth

63
view.c
View File

@ -11,6 +11,40 @@ nexttiled(Client *c) {
return c; return c;
} }
static Bool
ismaster(Client *c) {
Client *cl;
unsigned int i;
for(cl = nexttiled(clients), i = 0; cl && cl != c; cl = nexttiled(cl->next), i++);
return i < nmaster;
}
static void
pop(Client *c) {
detach(c);
if(clients)
clients->prev = c;
c->next = clients;
clients = c;
}
static void
swap(Client *c1, Client *c2) {
Client tmp = *c1;
Client *cp = c1->prev;
Client *cn = c1->next;
*c1 = *c2;
c1->prev = cp;
c1->next = cn;
cp = c2->prev;
cn = c2->next;
*c2 = tmp;
c2->prev = cp;
c2->next = cn;
}
static void static void
togglemax(Client *c) { togglemax(Client *c) {
XEvent ev; XEvent ev;
@ -34,6 +68,15 @@ togglemax(Client *c) {
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
} }
static Client *
topofstack() {
Client *c;
unsigned int i;
for(c = nexttiled(clients), i = 0; c && i < nmaster; c = nexttiled(c->next), i++);
return (i < nmaster) ? NULL : c;
}
/* extern */ /* extern */
void (*arrange)(void) = DEFMODE; void (*arrange)(void) = DEFMODE;
@ -248,7 +291,7 @@ view(Arg *arg) {
void void
zoom(Arg *arg) { zoom(Arg *arg) {
unsigned int i, n; unsigned int n;
Client *c; Client *c;
if(!sel) if(!sel)
@ -262,19 +305,15 @@ zoom(Arg *arg) {
if(n <= nmaster || (arrange == dofloat)) if(n <= nmaster || (arrange == dofloat))
return; return;
for(c = nexttiled(clients), i = 0; c && (c != sel) && i < nmaster; c = nexttiled(c->next)) if(ismaster((c = sel))) {
i++; if(!(c = topofstack()))
if(c == sel && i < nmaster)
for(; c && i < nmaster; c = nexttiled(c->next))
i++;
if(!c)
return; return;
swap(c, sel);
c = sel;
}
else
pop(c);
detach(c);
if(clients)
clients->prev = c;
c->next = clients;
clients = c;
focus(c); focus(c);
arrange(); arrange();
} }