commit d5e10bb77eca9542d99ca767b1e9aa1faccfb455
parent a7672e2fbd353fbe1423e503a736d65cbc853c81
Author: Jack Bird <jack.bird@durham.ac.uk>
Date: Wed, 4 Aug 2021 21:48:08 +0100
[dwm][patch][focusmaster] Each tag stores the return client
Diffstat:
3 files changed, 90 insertions(+), 82 deletions(-)
diff --git a/dwm.suckless.org/patches/focusmaster/dwm-focusmaster-return-20210729-138b405.diff b/dwm.suckless.org/patches/focusmaster/dwm-focusmaster-return-20210729-138b405.diff
@@ -1,80 +0,0 @@
-From 36c4e246ad47333f2b8a82610ba2adebeb2043b2 Mon Sep 17 00:00:00 2001
-From: Jack Bird <jack.bird@durham.ac.uk>
-Date: Thu, 29 Jul 2021 21:39:33 +0100
-Subject: [PATCH] Able to switch to master from anywhere in the stack and can
- also return to the previously selected client from the master
-
----
- dwm.c | 28 ++++++++++++++++++++++++++++
- 1 file changed, 28 insertions(+)
-
-diff --git a/dwm.c b/dwm.c
-index 5e4d494..eab8d57 100644
---- a/dwm.c
-+++ b/dwm.c
-@@ -127,6 +127,7 @@ struct Monitor {
- Client *clients;
- Client *sel;
- Client *stack;
-+ Client *stackfocused;
- Monitor *next;
- Window barwin;
- const Layout *lt[2];
-@@ -167,6 +168,7 @@ static void enternotify(XEvent *e);
- static void expose(XEvent *e);
- static void focus(Client *c);
- static void focusin(XEvent *e);
-+static void focusmaster(const Arg *arg);
- static void focusmon(const Arg *arg);
- static void focusstack(const Arg *arg);
- static Atom getatomprop(Client *c, Atom prop);
-@@ -660,6 +662,9 @@ detach(Client *c)
- {
- Client **tc;
-
-+ if (c == c->mon->stackfocused)
-+ c->mon->stackfocused = NULL;
-+
- for (tc = &c->mon->clients; *tc && *tc != c; tc = &(*tc)->next);
- *tc = c->next;
- }
-@@ -816,6 +821,28 @@ focusin(XEvent *e)
- setfocus(selmon->sel);
- }
-
-+void
-+focusmaster(const Arg *arg)
-+{
-+ Client *master;
-+
-+ if (selmon->nmaster > 1)
-+ return;
-+
-+ master = nexttiled(selmon->clients);
-+
-+ if (!master)
-+ return;
-+
-+ if (selmon->sel == master) {
-+ if (master->mon->stackfocused)
-+ focus(master->mon->stackfocused);
-+ } else {
-+ master->mon->stackfocused = master->mon->sel;
-+ focus(master);
-+ }
-+}
-+
- void
- focusmon(const Arg *arg)
- {
-@@ -1203,6 +1230,7 @@ nexttiled(Client *c)
- void
- pop(Client *c)
- {
-+ c->mon->stackfocused = nexttiled(c->mon->clients);
- detach(c);
- attach(c);
- focus(c);
---
-2.32.0
-
diff --git a/dwm.suckless.org/patches/focusmaster/dwm-focusmaster-return-20210804-138b405.diff b/dwm.suckless.org/patches/focusmaster/dwm-focusmaster-return-20210804-138b405.diff
@@ -0,0 +1,88 @@
+From 6c6a6cfaa73bfd24014df5c810cc78756ec325b4 Mon Sep 17 00:00:00 2001
+From: Jack Bird <jack.bird@durham.ac.uk>
+Date: Wed, 4 Aug 2021 20:27:23 +0100
+Subject: [PATCH] Focus master and return supported over all tags
+
+---
+ dwm.c | 37 +++++++++++++++++++++++++++++++++++++
+ 1 file changed, 37 insertions(+)
+
+diff --git a/dwm.c b/dwm.c
+index 5e4d494..dcb98b4 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -127,6 +127,7 @@ struct Monitor {
+ Client *clients;
+ Client *sel;
+ Client *stack;
++ Client *tagmarked[32];
+ Monitor *next;
+ Window barwin;
+ const Layout *lt[2];
+@@ -167,6 +168,7 @@ static void enternotify(XEvent *e);
+ static void expose(XEvent *e);
+ static void focus(Client *c);
+ static void focusin(XEvent *e);
++static void focusmaster(const Arg *arg);
+ static void focusmon(const Arg *arg);
+ static void focusstack(const Arg *arg);
+ static Atom getatomprop(Client *c, Atom prop);
+@@ -660,6 +662,10 @@ detach(Client *c)
+ {
+ Client **tc;
+
++ for (int i = 1; i < LENGTH(tags); i++)
++ if (c == c->mon->tagmarked[i])
++ c->mon->tagmarked[i] = NULL;
++
+ for (tc = &c->mon->clients; *tc && *tc != c; tc = &(*tc)->next);
+ *tc = c->next;
+ }
+@@ -816,6 +822,32 @@ focusin(XEvent *e)
+ setfocus(selmon->sel);
+ }
+
++void
++focusmaster(const Arg *arg)
++{
++ Client *master;
++
++ if (selmon->nmaster > 1)
++ return;
++
++ master = nexttiled(selmon->clients);
++
++ if (!master)
++ return;
++
++ int i;
++ for (i = 0; !(selmon->tagset[selmon->seltags] & 1 << i); i++);
++ i++;
++
++ if (selmon->sel == master) {
++ if (selmon->tagmarked[i] && ISVISIBLE(selmon->tagmarked[i]))
++ focus(selmon->tagmarked[i]);
++ } else {
++ selmon->tagmarked[i] = selmon->sel;
++ focus(master);
++ }
++}
++
+ void
+ focusmon(const Arg *arg)
+ {
+@@ -1203,6 +1235,11 @@ nexttiled(Client *c)
+ void
+ pop(Client *c)
+ {
++ int i;
++ for (i = 0; !(selmon->tagset[selmon->seltags] & 1 << i); i++);
++ i++;
++
++ c->mon->tagmarked[i] = nexttiled(c->mon->clients);
+ detach(c);
+ attach(c);
+ focus(c);
+--
+2.32.0
+
diff --git a/dwm.suckless.org/patches/focusmaster/index.md b/dwm.suckless.org/patches/focusmaster/index.md
@@ -19,9 +19,9 @@ Add the following line to the keys array in your config.h (or config.def.h) to b
Download
--------
* [dwm-focusmaster-20200717-bb2e722.diff](dwm-focusmaster-20200717-bb2e722.diff) (2020.07.17)
-* [dwm-focusmaster-return-20210729-138b405.diff](dwm-focusmaster-return-20210729-138b405.diff) (2021.07.29)
+* [dwm-focusmaster-return-20210804-138b405.diff](dwm-focusmaster-return-20210804-138b405.diff) (2021.08.04)
Author
------
* Mateus Auler - <mateusauler at protonmail dot com>
-* Jack Bird - <jack.bird@dur.ac.uk> (focusmaster return patch)
+* Jack Bird - <jack.bird@dur.ac.uk> (focusmaster return)