mirror of
https://github.com/zoriya/dwm.git
synced 2026-05-28 00:32:22 +00:00
stacker updated for version 6.2
This commit is contained in:
+11
-3
@@ -87,6 +87,14 @@ static const Layout layouts[] = {
|
||||
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
|
||||
#define STACKKEYS(MOD,ACTION) \
|
||||
{ MOD, XK_j, ACTION##stack, {.i = INC(+1) } }, \
|
||||
{ MOD, XK_k, ACTION##stack, {.i = INC(-1) } }, \
|
||||
{ MOD, XK_grave, ACTION##stack, {.i = PREVSEL } }, \
|
||||
{ MOD, XK_q, ACTION##stack, {.i = 0 } }, \
|
||||
{ MOD, XK_a, ACTION##stack, {.i = 1 } }, \
|
||||
{ MOD, XK_z, ACTION##stack, {.i = 2 } }, \
|
||||
{ MOD, XK_x, ACTION##stack, {.i = -1 } },
|
||||
|
||||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
@@ -101,8 +109,8 @@ static Key keys[] = {
|
||||
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
||||
{ MODKEY, XK_b, togglebar, {0} },
|
||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||
STACKKEYS(MODKEY, focus)
|
||||
STACKKEYS(MODKEY|ShiftMask, push)
|
||||
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||
@@ -172,7 +180,7 @@ static Key keys[] = {
|
||||
TAGKEYS( XK_7, 6)
|
||||
TAGKEYS( XK_8, 7)
|
||||
TAGKEYS( XK_9, 8)
|
||||
{ MODKEY|ShiftMask, XK_q, quit, {0} },
|
||||
{ MODKEY|ShiftMask, XK_BackSpace, quit, {0} },
|
||||
};
|
||||
|
||||
/* button definitions */
|
||||
|
||||
@@ -103,17 +103,26 @@ static const Layout layouts[] = {
|
||||
{ MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
|
||||
|
||||
#define STACKKEYS(MOD,ACTION) \
|
||||
{ MOD, XK_j, ACTION##stack, {.i = INC(+1) } }, \
|
||||
{ MOD, XK_k, ACTION##stack, {.i = INC(-1) } }, \
|
||||
{ MOD, XK_Tab, ACTION##stack, {.i = PREVSEL } }, \
|
||||
{ MOD, XK_a, ACTION##stack, {.i = 0 } }, \
|
||||
{ MOD, XK_s, ACTION##stack, {.i = 1 } }, \
|
||||
{ MOD, XK_d, ACTION##stack, {.i = 2 } }, \
|
||||
{ MOD, XK_g, ACTION##stack, {.i = -1 } },
|
||||
|
||||
static Key keys[] = {
|
||||
/* modifier key function argument */
|
||||
{ MODKEY, XK_b, togglebar, {0} },
|
||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||
STACKKEYS(MODKEY, focus)
|
||||
STACKKEYS(MODKEY|ShiftMask, push)
|
||||
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||
{ MODKEY, XK_u, incnmaster, {.i = -1 } },
|
||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||
{ MODKEY, XK_Return, zoom, {0} },
|
||||
{ MODKEY, XK_Tab, view, {0} },
|
||||
{ Mod1Mask, XK_Tab, view, {0} },
|
||||
{ MODKEY, XK_c, killclient, {0} },
|
||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY|ShiftMask, XK_f, setlayout, {.v = &layouts[1]} },
|
||||
|
||||
@@ -48,10 +48,15 @@
|
||||
#define BARRULES 20
|
||||
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
|
||||
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
|
||||
#define GETINC(X) ((X) - 2000)
|
||||
#define INC(X) ((X) + 2000)
|
||||
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
|
||||
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
|
||||
#define ISVISIBLE(C, M) ((C->tags & M->tagset[M->seltags]))
|
||||
#define ISINC(X) ((X) > 1000 && (X) < 3000)
|
||||
#define PREVSEL 3000
|
||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||
#define MOD(N,M) ((N)%(M) < 0 ? (N)%(M) + (M) : (N)%(M))
|
||||
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
||||
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
||||
@@ -60,6 +65,7 @@
|
||||
#define SPTAG(i) ((1 << LENGTH(tags)) << (i))
|
||||
#define SPTAGMASK (((1 << LENGTH(scratchpads))-1) << LENGTH(tags))
|
||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||
#define TRUNC(X,A,B) (MAX((A), MIN((X), (B))))
|
||||
|
||||
/* enums */
|
||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||
@@ -257,6 +263,7 @@ static void movemouse(const Arg *arg);
|
||||
static Client *nexttiled(Client *c, Monitor *m);
|
||||
static void pop(Client *);
|
||||
static void propertynotify(XEvent *e);
|
||||
static void pushstack(const Arg *arg);
|
||||
static void quit(const Arg *arg);
|
||||
static Monitor *recttomon(int x, int y, int w, int h);
|
||||
static void resize(Client *c, int x, int y, int w, int h, int interact);
|
||||
@@ -278,6 +285,7 @@ static void seturgent(Client *c, int urg);
|
||||
static void showhide(Client *c);
|
||||
static void sigchld(int unused);
|
||||
static void spawn(const Arg *arg);
|
||||
static int stackpos(const Arg *arg);
|
||||
static void tag(const Arg *arg);
|
||||
static void tagmon(const Arg *arg);
|
||||
static void tile(Monitor *);
|
||||
@@ -1164,28 +1172,16 @@ focusmon(const Arg *arg)
|
||||
void
|
||||
focusstack(const Arg *arg)
|
||||
{
|
||||
Client *c = NULL, *i;
|
||||
int i = stackpos(arg);
|
||||
Client *c, *p;
|
||||
|
||||
if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen))
|
||||
if (i < 0 || !selmon->sel || (selmon->sel->isfullscreen && lockfullscreen))
|
||||
return;
|
||||
if (arg->i > 0) {
|
||||
for (c = selmon->sel->next; c && !ISVISIBLE(c, selmon); c = c->next);
|
||||
if (!c)
|
||||
for (c = selmon->cl->clients; c && !ISVISIBLE(c, selmon); c = c->next);
|
||||
} else {
|
||||
for (i = selmon->cl->clients; i != selmon->sel; i = i->next)
|
||||
if (ISVISIBLE(i, selmon))
|
||||
c = i;
|
||||
if (!c)
|
||||
for (; i; i = i->next)
|
||||
if (ISVISIBLE(i, selmon))
|
||||
c = i;
|
||||
}
|
||||
if (c) {
|
||||
losefullscreen(selmon->sel, c);
|
||||
focus(c);
|
||||
restack(selmon);
|
||||
}
|
||||
|
||||
for(p = NULL, c = selmon->cl->clients; c && (i || !ISVISIBLE(c, selmon));
|
||||
i -= ISVISIBLE(c, selmon) ? 1 : 0, p = c, c = c->next);
|
||||
focus(c ? c : p);
|
||||
restack(selmon);
|
||||
}
|
||||
|
||||
Atom
|
||||
@@ -1729,6 +1725,29 @@ propertynotify(XEvent *e)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
pushstack(const Arg *arg) {
|
||||
int i = stackpos(arg);
|
||||
Client *sel = selmon->sel, *c, *p;
|
||||
|
||||
if(i < 0)
|
||||
return;
|
||||
else if(i == 0) {
|
||||
detach(sel);
|
||||
attach(sel);
|
||||
}
|
||||
else {
|
||||
for(p = NULL, c = selmon->cl->clients; c; p = c, c = c->next)
|
||||
if(!(i -= (ISVISIBLE(c, selmon) && c != sel)))
|
||||
break;
|
||||
c = c ? c : p;
|
||||
detach(sel);
|
||||
sel->next = c->next;
|
||||
c->next = sel;
|
||||
}
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
void
|
||||
quit(const Arg *arg)
|
||||
{
|
||||
@@ -2213,6 +2232,36 @@ spawn(const Arg *arg)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
stackpos(const Arg *arg) {
|
||||
int n, i;
|
||||
Client *c, *l;
|
||||
|
||||
if(!selmon->cl->clients)
|
||||
return -1;
|
||||
|
||||
if(arg->i == PREVSEL) {
|
||||
for(l = selmon->cl->stack; l && (!ISVISIBLE(l, selmon) || l == selmon->sel); l = l->snext);
|
||||
if(!l)
|
||||
return -1;
|
||||
for(i = 0, c = selmon->cl->clients; c != l; i += ISVISIBLE(c, selmon) ? 1 : 0, c = c->next);
|
||||
return i;
|
||||
}
|
||||
else if(ISINC(arg->i)) {
|
||||
if(!selmon->sel)
|
||||
return -1;
|
||||
for(i = 0, c = selmon->cl->clients; c != selmon->sel; i += ISVISIBLE(c, selmon) ? 1 : 0, c = c->next);
|
||||
for(n = i; c; n += ISVISIBLE(c, selmon) ? 1 : 0, c = c->next);
|
||||
return MOD(i + GETINC(arg->i), n);
|
||||
}
|
||||
else if(arg->i < 0) {
|
||||
for(i = 0, c = selmon->cl->clients; c; i += ISVISIBLE(c, selmon) ? 1 : 0, c = c->next);
|
||||
return MAX(i + arg->i, 0);
|
||||
}
|
||||
else
|
||||
return arg->i;
|
||||
}
|
||||
|
||||
void
|
||||
tag(const Arg *arg)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user