feat: added rotatestack patch

This commit is contained in:
Ryan Kes 2020-12-01 11:04:57 +01:00
parent feefdd57d2
commit 9d8345c8be
4 changed files with 112 additions and 5 deletions

View file

@ -24,6 +24,7 @@ _patches=(
"dwm-hide_vacant_tags-6.2.diff" "dwm-hide_vacant_tags-6.2.diff"
"local-scratchpad-6.2.diff" "local-scratchpad-6.2.diff"
"local-alpha-20201019-61bb8b2.diff" "local-alpha-20201019-61bb8b2.diff"
"dwm-rotatestack-20161021-ab9571b.diff"
) )
source=(http://dl.suckless.org/dwm/dwm-$pkgver.tar.gz source=(http://dl.suckless.org/dwm/dwm-$pkgver.tar.gz
@ -42,7 +43,8 @@ md5sums=('9929845ccdec4d2cc191f16210dd7f3d'
'8c3ad89cb98dd2b9152075b6e29cb579' '8c3ad89cb98dd2b9152075b6e29cb579'
'c446b71a8b8cce25db86a47805500dfa' 'c446b71a8b8cce25db86a47805500dfa'
'8e7bef8198d212f8c33efbf160b44b87' '8e7bef8198d212f8c33efbf160b44b87'
'3f50d21e606afd5c8b3c67dbbbb9ea32') '3f50d21e606afd5c8b3c67dbbbb9ea32'
'882e0783ccedf9fbb8b565e7681116c9')
prepare() { prepare() {
cd $srcdir/dwm-$pkgver cd $srcdir/dwm-$pkgver

View file

@ -5,15 +5,16 @@
[[https://dwm.suckless.org][DWM]] [[https://www.archlinux.org/][Arch]] package with a few patches installed to keep things nice: [[https://dwm.suckless.org][DWM]] [[https://www.archlinux.org/][Arch]] package with a few patches installed to keep things nice:
- [[https://dwm.suckless.org/patches/systray/][systray]] - [[https://dwm.suckless.org/patches/alpha/][alpha]]
- [[https://dwm.suckless.org/patches/noborder/][noborder]]
- [[https://dwm.suckless.org/patches/autostart/][autostart]] - [[https://dwm.suckless.org/patches/autostart/][autostart]]
- [[https://dwm.suckless.org/patches/cyclelayouts/][cyclelayouts]] - [[https://dwm.suckless.org/patches/cyclelayouts/][cyclelayouts]]
- [[https://dwm.suckless.org/patches/gridmode/][gridmode]] - [[https://dwm.suckless.org/patches/gridmode/][gridmode]]
- [[https://dwm.suckless.org/patches/selfrestart/][selfrestart]]
- [[https://dwm.suckless.org/patches/hide_vacant_tags/][hide_vacant_tags]] - [[https://dwm.suckless.org/patches/hide_vacant_tags/][hide_vacant_tags]]
- [[https://dwm.suckless.org/patches/noborder/][noborder]]
- [[https://dwm.suckless.org/patches/rotatestack/][rotatestack]]
- [[https://dwm.suckless.org/patches/scratchpad/][scratchpad]] - [[https://dwm.suckless.org/patches/scratchpad/][scratchpad]]
- [[https://dwm.suckless.org/patches/alpha/][alpha]] - [[https://dwm.suckless.org/patches/selfrestart/][selfrestart]]
- [[https://dwm.suckless.org/patches/systray/][systray]]
** Installation ** Installation
#+BEGIN_EXAMPLE shell #+BEGIN_EXAMPLE shell

View file

@ -109,6 +109,8 @@ static Key keys[] = {
//{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, //{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
{ MODKEY, XK_grave, togglescratch, {.v = scratchpadcmd } }, { MODKEY, XK_grave, togglescratch, {.v = scratchpadcmd } },
{ MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_b, togglebar, {0} },
{ MODKEY|ShiftMask, XK_j, rotatestack, {.i = +1 } },
{ MODKEY|ShiftMask, XK_k, rotatestack, {.i = -1 } },
{ MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } },
{ MODKEY, XK_i, incnmaster, {.i = +1 } }, { MODKEY, XK_i, incnmaster, {.i = +1 } },

View file

@ -0,0 +1,102 @@
diff --git a/config.def.h b/config.def.h
index fd77a07..09737d7 100644
--- a/config.def.h
+++ b/config.def.h
@@ -64,6 +64,8 @@ static Key keys[] = {
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
{ MODKEY, XK_b, togglebar, {0} },
+ { MODKEY|ShiftMask, XK_j, rotatestack, {.i = +1 } },
+ { MODKEY|ShiftMask, XK_k, rotatestack, {.i = -1 } },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
diff --git a/dwm.c b/dwm.c
index 421bf27..1ec8b10 100644
--- a/dwm.c
+++ b/dwm.c
@@ -165,6 +165,8 @@ static void detachstack(Client *c);
static Monitor *dirtomon(int dir);
static void drawbar(Monitor *m);
static void drawbars(void);
+static void enqueue(Client *c);
+static void enqueuestack(Client *c);
static void enternotify(XEvent *e);
static void expose(XEvent *e);
static void focus(Client *c);
@@ -194,6 +196,7 @@ static void resize(Client *c, int x, int y, int w, int h, int interact);
static void resizeclient(Client *c, int x, int y, int w, int h);
static void resizemouse(const Arg *arg);
static void restack(Monitor *m);
+static void rotatestack(const Arg *arg);
static void run(void);
static void scan(void);
static int sendevent(Client *c, Atom proto);
@@ -765,6 +768,28 @@ drawbars(void)
}
void
+enqueue(Client *c)
+{
+ Client *l;
+ for (l = c->mon->clients; l && l->next; l = l->next);
+ if (l) {
+ l->next = c;
+ c->next = NULL;
+ }
+}
+
+void
+enqueuestack(Client *c)
+{
+ Client *l;
+ for (l = c->mon->stack; l && l->snext; l = l->snext);
+ if (l) {
+ l->snext = c;
+ c->snext = NULL;
+ }
+}
+
+void
enternotify(XEvent *e)
{
Client *c;
@@ -1390,6 +1415,38 @@ restack(Monitor *m)
}
void
+rotatestack(const Arg *arg)
+{
+ Client *c = NULL, *f;
+
+ if (!selmon->sel)
+ return;
+ f = selmon->sel;
+ if (arg->i > 0) {
+ for (c = nexttiled(selmon->clients); c && nexttiled(c->next); c = nexttiled(c->next));
+ if (c){
+ detach(c);
+ attach(c);
+ detachstack(c);
+ attachstack(c);
+ }
+ } else {
+ if ((c = nexttiled(selmon->clients))){
+ detach(c);
+ enqueue(c);
+ detachstack(c);
+ enqueuestack(c);
+ }
+ }
+ if (c){
+ arrange(selmon);
+ //unfocus(f, 1);
+ focus(f);
+ restack(selmon);
+ }
+}
+
+void
run(void)
{
XEvent ev;