[wiki] [sites] stacker patch: add focus/push prev sel client. || memeplex
commit 1f1f11f631003e21c9d2983fb57c4280608308a3
Author: memeplex <carlosjosepita_AT_gmail.com>
Date: Mon Jan 13 23:13:15 2014 -0300
stacker patch: add focus/push prev sel client.
Also: documentation was updated to reflect addition and xtile patch was updated to reduce
merge conflicts for people using both xtile and stacker.
diff --git a/dwm.suckless.org/patches/dwm-6.0-stacker.diff b/dwm.suckless.org/patches/dwm-6.0-stacker.diff
index 8e77337..eb7ed1d 100644
--- a/dwm.suckless.org/patches/dwm-6.0-stacker.diff
+++ b/dwm.suckless.org/patches/dwm-6.0-stacker.diff
_AT_@ -1,22 +1,23 @@
diff --git a/config.def.h b/config.def.h
-index 77ff358..236800d 100644
+index 77ff358..566e0c7 100644
--- a/config.def.h
+++ b/config.def.h
-_AT_@ -41,6 +41,13 @@ static const Layout layouts[] = {
+_AT_@ -41,6 +41,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 = 0 } }, \
-+ { MOD, XK_q, ACTION##stack, {.i = 1 } }, \
-+ { MOD, XK_a, ACTION##stack, {.i = 2 } }, \
-+ { MOD, XK_z, ACTION##stack, {.i = -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 } }
-_AT_@ -54,8 +61,8 @@ static Key keys[] = {
+_AT_@ -54,8 +62,8 @@ static Key keys[] = {
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
{ MODKEY, XK_b, togglebar, {0} },
_AT_@ -27,7 +28,7 @@ index 77ff358..236800d 100644
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
-_AT_@ -83,7 +90,7 @@ static Key keys[] = {
+_AT_@ -83,7 +91,7 @@ static Key keys[] = {
TAGKEYS( XK_7, 6)
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
_AT_@ -37,19 +38,20 @@ index 77ff358..236800d 100644
/* button definitions */
diff --git a/dwm.c b/dwm.c
-index 1d78655..8bded5d 100644
+index 1d78655..6129f56 100644
--- a/dwm.c
+++ b/dwm.c
-_AT_@ -43,17 +43,22 @@
+_AT_@ -43,17 +43,23 @@
/* macros */
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
-+#define GETINC(X) ((X) < 0 ? X + 1000 : X - 1000)
-+#define INC(X) ((X) < 0 ? X - 1000 : X + 1000)
++#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 ISINC(X) ((X) <= -1000 || (X) >= 1000)
++#define ISINC(X) ((X) > 1000 && (X) < 3000)
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
++#define PREVSEL 3000
#define LENGTH(X) (sizeof X / sizeof X[0])
#define MAX(A, B) ((A) > (B) ? (A) : (B))
#define MIN(A, B) ((A) < (B) ? (A) : (B))
_AT_@ -63,7 +65,7 @@ index 1d78655..8bded5d 100644
/* enums */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
-_AT_@ -205,6 +210,7 @@ static void movemouse(const Arg *arg);
+_AT_@ -205,6 +211,7 @@ static void movemouse(const Arg *arg);
static Client *nexttiled(Client *c);
static void pop(Client *);
static void propertynotify(XEvent *e);
_AT_@ -71,7 +73,7 @@ index 1d78655..8bded5d 100644
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, Bool interact);
-_AT_@ -224,6 +230,7 @@ static void setup(void);
+_AT_@ -224,6 +231,7 @@ static void setup(void);
static void showhide(Client *c);
static void sigchld(int unused);
static void spawn(const Arg *arg);
_AT_@ -79,7 +81,7 @@ index 1d78655..8bded5d 100644
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static int textnw(const char *text, unsigned int len);
-_AT_@ -887,28 +894,16 @@ focusmon(const Arg *arg) {
+_AT_@ -887,28 +895,16 @@ focusmon(const Arg *arg) {
void
focusstack(const Arg *arg) {
_AT_@ -116,7 +118,7 @@ index 1d78655..8bded5d 100644
}
Atom
-_AT_@ -1324,6 +1319,29 @@ propertynotify(XEvent *e) {
+_AT_@ -1324,6 +1320,29 @@ propertynotify(XEvent *e) {
}
void
_AT_@ -146,19 +148,26 @@ index 1d78655..8bded5d 100644
quit(const Arg *arg) {
running = False;
}
-_AT_@ -1674,6 +1692,29 @@ spawn(const Arg *arg) {
+_AT_@ -1674,6 +1693,36 @@ spawn(const Arg *arg) {
}
}
+int
+stackpos(const Arg *arg) {
+ int n, i;
-+ Client *c;
++ Client *c, *l;
+
+ if(!selmon->clients)
+ return -1;
+
-+ if(ISINC(arg->i)) {
++ 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);
diff --git a/dwm.suckless.org/patches/dwm-6.0-xtile.diff b/dwm.suckless.org/patches/dwm-6.0-xtile.diff
index 495b472..03fc5c2 100644
--- a/dwm.suckless.org/patches/dwm-6.0-xtile.diff
+++ b/dwm.suckless.org/patches/dwm-6.0-xtile.diff
_AT_@ -46,18 +46,18 @@ index 77ff358..ac895db 100644
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
diff --git a/dwm.c b/dwm.c
-index c9ad1f2..5dd2673 100644
+index c9ad1f2..9cae5b5 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -43,17 +43,22 @@
/* macros */
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
-+#define GETINC(X) ((X) < 0 ? X + 1000 : X - 1000)
-+#define INC(X) ((X) < 0 ? X - 1000 : X + 1000)
++#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 ISINC(X) ((X) <= -1000 || (X) >= 1000)
++#define ISINC(X) ((X) > 1000 && (X) < 3000)
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
#define LENGTH(X) (sizeof X / sizeof X[0])
#define MAX(A, B) ((A) > (B) ? (A) : (B))
diff --git a/dwm.suckless.org/patches/stacker.md b/dwm.suckless.org/patches/stacker.md
index 6b51dd0..1d8a908 100644
--- a/dwm.suckless.org/patches/stacker.md
+++ b/dwm.suckless.org/patches/stacker.md
_AT_@ -4,21 +4,24 @@ Stacker
Description
-----------
-This patch provides basic utilities for managing the client stack. It implements two new
-commands: `focusstack` (which is a replacement for the original `focusstack` command) and
-`pushstack`. The first one is for focusing clients while the second one moves clients
-around the stack. Both commands take the same kind of argument:
+This patch provides comprehensive utilities for managing the client stack. It implements
+two new commands: `focusstack` (which is a replacement for the original `focusstack`
+command) and `pushstack`. The first one is for focusing clients while the second one moves
+clients around the stack. Both commands take the same kind of argument:
-* Pass `INC(inc)` to focus/push relatively to the selected client. This will wrap around the
- stack limits.
+* Pass `PREVSEL` to focus/push the previously selected client in the current tagset.
+
+* Pass `INC(+/-inc)` to focus/push relatively to the selected client. This will wrap
+ around the stack limits.
* Pass a positive number to focus/push relatively to the beginning of the stack. Out of
- limit values will be truncated to the position of the last visible client and won't
- wrap around.
+ limit values will be truncated to the position of the last visible client and won't wrap
+ around.
* Pass a negative number to focus/push relatively to the last visible client in the stack.
Here -1 means the last client, -2 the previous to last client, etc. Out of limit values
- will be truncated to the position of the first visible client (0) and won't wrap around.
+ will be truncated to the position of the first visible client (0) and won't wrap
+ around.
Default key bindings
--------------------
_AT_@ -29,18 +32,20 @@ simply `MODKEY` for the `focus*` family and `MODKEY|ShiftMask` for the `push*` f
Key | Argument | Description
:------:|:-----------:|-----------------------
+ \` | `PREVSEL` | Previously selected
`j` | `INC(+1)` | Next to selected
`k` | `INC(-1)` | Previous to selected
- \` | `0` | First position
- `q` | `1` | Second position
- `a` | `2` | Third position
- `z` | `-1` | Last position
-
-The \`, `q`, `a`, `z` keys are aligned more or less in the same keyboard column in the us
-layout. The first three are intended to be used as quick positional shortcuts to specific
-applications. So if you have 9 tags you get 9\*3=27 shortcuts in a two-level hierarchy of
-windows. The `z` key is more like "I don't care so much about you just right now but you
-can still live in this tag".
+ `q` | `0` | First position
+ `a` | `1` | Second position
+ `z` | `2` | Third position
+ `x` | `-1` | Last position
+
+The `q`, `a`, `z` keys are aligned more or less vertically in the us keyboard layout. They
+are intended to be used as quick positional shortcuts to specific applications. So if you
+have 9 tags you get 9\*3=27 shortcuts in a two-level hierarchy of clients. The \` key is
+above the `Tab` key and it's intended to complement the "move to previously selected
+tag" function of dwm at the intra-tag level. Finally, the `x` key is like "I don't care so
+much about you just right now but you can still live in this tag".
Notice that `MODKEY|ShiftMask+q` collides with the default binding for quitting dwm, which
stacker changes to `MODKEY|ShiftMask+BackSpace`.
Received on Tue Jan 14 2014 - 03:35:24 CET
This archive was generated by hypermail 2.3.0
: Thu Jun 18 2015 - 17:38:07 CEST