stacker patch replaces movestack
This commit is contained in:
parent
e5a3fdff88
commit
927200f32d
2 changed files with 84 additions and 26 deletions
22
config.h
22
config.h
|
@ -44,7 +44,6 @@ static const float mfact = 0.55; /* factor of master area size [0.05..0.95]
|
||||||
static const int nmaster = 1; /* number of clients in master area */
|
static const int nmaster = 1; /* number of clients in master area */
|
||||||
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
||||||
|
|
||||||
#include "shiftview.c"
|
|
||||||
#include "fibonacci.c"
|
#include "fibonacci.c"
|
||||||
static const Layout layouts[] = {
|
static const Layout layouts[] = {
|
||||||
/* symbol arrange function */
|
/* symbol arrange function */
|
||||||
|
@ -64,6 +63,14 @@ static const Layout layouts[] = {
|
||||||
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||||
{ MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
|
{ MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
|
||||||
{ MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.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 */
|
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||||
|
@ -76,10 +83,11 @@ static const char scratchpadname[] = "scratchpad";
|
||||||
static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "120x34", NULL };
|
static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "120x34", NULL };
|
||||||
|
|
||||||
#include <X11/XF86keysym.h>
|
#include <X11/XF86keysym.h>
|
||||||
#include "movestack.c"
|
#include "shiftview.c"
|
||||||
static Key keys[] = {
|
static Key keys[] = {
|
||||||
/* modifier key function argument */
|
/* modifier key function argument */
|
||||||
|
STACKKEYS(MODKEY, focus)
|
||||||
|
STACKKEYS(MODKEY|ShiftMask, push)
|
||||||
{ MODKEY, XK_grave, spawn, SHCMD("dmenuunicode") },
|
{ MODKEY, XK_grave, spawn, SHCMD("dmenuunicode") },
|
||||||
/* { MODKEY|ShiftMask, XK_grave, togglescratch, SHCMD("") }, */
|
/* { MODKEY|ShiftMask, XK_grave, togglescratch, SHCMD("") }, */
|
||||||
TAGKEYS( XK_1, 0)
|
TAGKEYS( XK_1, 0)
|
||||||
|
@ -140,10 +148,10 @@ static Key keys[] = {
|
||||||
{ MODKEY, XK_g, shiftview, { .i = -1 } },
|
{ MODKEY, XK_g, shiftview, { .i = -1 } },
|
||||||
/* { MODKEY|ShiftMask, XK_g, spawn, SHCMD("") }, */
|
/* { MODKEY|ShiftMask, XK_g, spawn, SHCMD("") }, */
|
||||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
/* { MODKEY, XK_j, focusstack, {.i = +1 } }, */
|
||||||
{ MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } },
|
/* { MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } }, */
|
||||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
/* { MODKEY, XK_k, focusstack, {.i = -1 } }, */
|
||||||
{ MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } },
|
/* { MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } }, */
|
||||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||||
{ MODKEY, XK_semicolon, shiftview, { .i = 1 } },
|
{ MODKEY, XK_semicolon, shiftview, { .i = 1 } },
|
||||||
/* { MODKEY|ShiftMask, XK_semicolon, shiftview, SHCMD("") }, */
|
/* { MODKEY|ShiftMask, XK_semicolon, shiftview, SHCMD("") }, */
|
||||||
|
|
86
dwm.c
86
dwm.c
|
@ -48,15 +48,21 @@
|
||||||
/* macros */
|
/* macros */
|
||||||
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
|
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
|
||||||
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
|
#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)) \
|
#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)))
|
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
|
||||||
|
#define ISINC(X) ((X) > 1000 && (X) < 3000)
|
||||||
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]) || C->issticky)
|
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]) || C->issticky)
|
||||||
|
#define PREVSEL 3000
|
||||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||||
|
#define MOD(N,M) ((N)%(M) < 0 ? (N)%(M) + (M) : (N)%(M))
|
||||||
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
||||||
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
||||||
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
||||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||||
|
#define TRUNC(X,A,B) (MAX((A), MIN((X), (B))))
|
||||||
#define XRDB_LOAD_COLOR(R,V) if (XrmGetResource(xrdb, R, NULL, &type, &value) == True) { \
|
#define XRDB_LOAD_COLOR(R,V) if (XrmGetResource(xrdb, R, NULL, &type, &value) == True) { \
|
||||||
if (value.addr != NULL && strnlen(value.addr, 8) == 7 && value.addr[0] == '#') { \
|
if (value.addr != NULL && strnlen(value.addr, 8) == 7 && value.addr[0] == '#') { \
|
||||||
int i = 1; \
|
int i = 1; \
|
||||||
|
@ -213,6 +219,7 @@ static void movemouse(const Arg *arg);
|
||||||
static Client *nexttiled(Client *c);
|
static Client *nexttiled(Client *c);
|
||||||
static void pop(Client *);
|
static void pop(Client *);
|
||||||
static void propertynotify(XEvent *e);
|
static void propertynotify(XEvent *e);
|
||||||
|
static void pushstack(const Arg *arg);
|
||||||
static void quit(const Arg *arg);
|
static void quit(const Arg *arg);
|
||||||
static Monitor *recttomon(int x, int y, int w, int h);
|
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);
|
static void resize(Client *c, int x, int y, int w, int h, int interact);
|
||||||
|
@ -243,6 +250,7 @@ static void seturgent(Client *c, int urg);
|
||||||
static void showhide(Client *c);
|
static void showhide(Client *c);
|
||||||
static void sigchld(int unused);
|
static void sigchld(int unused);
|
||||||
static void spawn(const Arg *arg);
|
static void spawn(const Arg *arg);
|
||||||
|
static int stackpos(const Arg *arg);
|
||||||
static void tag(const Arg *arg);
|
static void tag(const Arg *arg);
|
||||||
static void tagmon(const Arg *arg);
|
static void tagmon(const Arg *arg);
|
||||||
static void tile(Monitor *);
|
static void tile(Monitor *);
|
||||||
|
@ -884,27 +892,16 @@ focusmon(const Arg *arg)
|
||||||
void
|
void
|
||||||
focusstack(const Arg *arg)
|
focusstack(const Arg *arg)
|
||||||
{
|
{
|
||||||
Client *c = NULL, *i;
|
int i = stackpos(arg);
|
||||||
|
Client *c, *p;
|
||||||
|
|
||||||
if (!selmon->sel || selmon->sel->isfullscreen)
|
if (i < 0 || selmon->sel->isfullscreen)
|
||||||
return;
|
return;
|
||||||
if (arg->i > 0) {
|
|
||||||
for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
|
for(p = NULL, c = selmon->clients; c && (i || !ISVISIBLE(c));
|
||||||
if (!c)
|
i -= ISVISIBLE(c) ? 1 : 0, p = c, c = c->next);
|
||||||
for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
|
focus(c ? c : p);
|
||||||
} else {
|
|
||||||
for (i = selmon->clients; i != selmon->sel; i = i->next)
|
|
||||||
if (ISVISIBLE(i))
|
|
||||||
c = i;
|
|
||||||
if (!c)
|
|
||||||
for (; i; i = i->next)
|
|
||||||
if (ISVISIBLE(i))
|
|
||||||
c = i;
|
|
||||||
}
|
|
||||||
if (c) {
|
|
||||||
focus(c);
|
|
||||||
restack(selmon);
|
restack(selmon);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Atom
|
Atom
|
||||||
|
@ -1342,6 +1339,29 @@ pop(Client *c)
|
||||||
arrange(c->mon);
|
arrange(c->mon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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->clients; c; p = c, c = c->next)
|
||||||
|
if(!(i -= (ISVISIBLE(c) && c != sel)))
|
||||||
|
break;
|
||||||
|
c = c ? c : p;
|
||||||
|
detach(sel);
|
||||||
|
sel->next = c->next;
|
||||||
|
c->next = sel;
|
||||||
|
}
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
propertynotify(XEvent *e)
|
propertynotify(XEvent *e)
|
||||||
{
|
{
|
||||||
|
@ -1693,6 +1713,36 @@ incrogaps(const Arg *arg)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
stackpos(const Arg *arg) {
|
||||||
|
int n, i;
|
||||||
|
Client *c, *l;
|
||||||
|
|
||||||
|
if(!selmon->clients)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if(arg->i == PREVSEL) {
|
||||||
|
for(l = selmon->stack; l && (!ISVISIBLE(l) || l == selmon->sel); l = l->snext);
|
||||||
|
if(!l)
|
||||||
|
return -1;
|
||||||
|
for(i = 0, c = selmon->clients; c != l; i += ISVISIBLE(c) ? 1 : 0, c = c->next);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
else if(ISINC(arg->i)) {
|
||||||
|
if(!selmon->sel)
|
||||||
|
return -1;
|
||||||
|
for(i = 0, c = selmon->clients; c != selmon->sel; i += ISVISIBLE(c) ? 1 : 0, c = c->next);
|
||||||
|
for(n = i; c; n += ISVISIBLE(c) ? 1 : 0, c = c->next);
|
||||||
|
return MOD(i + GETINC(arg->i), n);
|
||||||
|
}
|
||||||
|
else if(arg->i < 0) {
|
||||||
|
for(i = 0, c = selmon->clients; c; i += ISVISIBLE(c) ? 1 : 0, c = c->next);
|
||||||
|
return MAX(i + arg->i, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return arg->i;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
incrohgaps(const Arg *arg)
|
incrohgaps(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue