diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2022-03-26 13:59:59 -0400 |
---|---|---|
committer | Benjamin Chausse <benjamin@chausse.xyz> | 2022-03-26 13:59:59 -0400 |
commit | c3b0c43ac2a298345f10589f4c2bf125e0eec2fd (patch) | |
tree | 43a98970b3e3a8f64669cf819fcbe1c6d9c69082 | |
parent | 59b562b09b4cdf0aef9f65b4dd8e1652f21d1a63 (diff) |
Add focusmaster-return patch
-rw-r--r-- | config.def.h | 1 | ||||
-rw-r--r-- | dwm.c | 39 | ||||
-rw-r--r-- | patch/dwm-focusmaster-return-20210804-138b405.diff | 90 |
3 files changed, 130 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h index 8fba104..89e962c 100644 --- a/config.def.h +++ b/config.def.h @@ -71,6 +71,7 @@ static Key keys[] = { { MODKEY, XK_p, spawn, {.v = dmenucmd } }, { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, { MODKEY, XK_b, togglebar, {0} }, + { MODKEY|ShiftMask, XK_b, focusmaster, {0} }, { MODKEY|ShiftMask, XK_j, rotatestack, {.i = +1 } }, { MODKEY|ShiftMask, XK_k, rotatestack, {.i = -1 } }, { MODKEY, XK_j, focusstack, {.i = +1 } }, @@ -127,6 +127,7 @@ struct Monitor { Client *clients; Client *sel; Client *stack; + Client *tagmarked[32]; Monitor *next; Window barwin; const Layout *lt[2]; @@ -169,6 +170,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); @@ -670,6 +672,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; } @@ -852,6 +858,34 @@ focusin(XEvent *e) } void +focusmaster(const Arg *arg) +{ + Client *master; + + if (selmon->nmaster > 1) + return; + if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen)) + 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) { Monitor *m; @@ -1240,6 +1274,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); diff --git a/patch/dwm-focusmaster-return-20210804-138b405.diff b/patch/dwm-focusmaster-return-20210804-138b405.diff new file mode 100644 index 0000000..4783605 --- /dev/null +++ b/patch/dwm-focusmaster-return-20210804-138b405.diff @@ -0,0 +1,90 @@ +From db6a8931a55982b95ed24ef57c8b71a6a3dafab6 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 | 39 +++++++++++++++++++++++++++++++++++++++ + 1 file changed, 39 insertions(+) + +diff --git a/dwm.c b/dwm.c +index 5e4d494..ee28f28 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,34 @@ focusin(XEvent *e) + setfocus(selmon->sel); + } + ++void ++focusmaster(const Arg *arg) ++{ ++ Client *master; ++ ++ if (selmon->nmaster > 1) ++ return; ++ if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen)) ++ 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 +1237,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 + |