[wiki] [sites] [dwm][patch][focusmaster] Added focusmaster-return patch. || Jack Bird
commit 4848ac0a24058de328e405863687240730859fc2
Author: Jack Bird <jack.bird_AT_durham.ac.uk>
Date: Thu Jul 29 23:19:56 2021 +0100
[dwm][patch][focusmaster] Added focusmaster-return patch.
Allows for returning to the client you switched from.
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
new file mode 100644
index 00000000..47cb9890
--- /dev/null
+++ b/dwm.suckless.org/patches/focusmaster/dwm-focusmaster-return-20210729-138b405.diff
_AT_@ -0,0 +1,80 @@
+From 36c4e246ad47333f2b8a82610ba2adebeb2043b2 Mon Sep 17 00:00:00 2001
+From: Jack Bird <jack.bird_AT_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
+_AT_@ -127,6 +127,7 @@ struct Monitor {
+ Client *clients;
+ Client *sel;
+ Client *stack;
++ Client *stackfocused;
+ Monitor *next;
+ Window barwin;
+ const Layout *lt[2];
+_AT_@ -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);
+_AT_@ -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;
+ }
+_AT_@ -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)
+ {
+_AT_@ -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/index.md b/dwm.suckless.org/patches/focusmaster/index.md
index b0f3e427..3c3e5019 100644
--- a/dwm.suckless.org/patches/focusmaster/index.md
+++ b/dwm.suckless.org/patches/focusmaster/index.md
_AT_@ -5,6 +5,11 @@ Description
-----------
Switch focus to the (tiled) master client from anywhere in the stack.
+focusmaster-return
+------------------
+Switch to the master from anywhere in the stack, when the master is selected
+return to the client switched from using the same keybind.
+
Configuration
-------------
Add the following line to the keys array in your config.h (or config.def.h) to bind Mod+Ctrl+Space to focusmaster.
_AT_@ -14,7 +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)
Author
------
* Mateus Auler - <mateusauler at protonmail dot com>
+* Jack Bird - <jack.bird_AT_dur.ac.uk> (focusmaster return patch)
Received on Fri Jul 30 2021 - 00:28:07 CEST
This archive was generated by hypermail 2.3.0
: Fri Jul 30 2021 - 00:36:40 CEST