dwm-focusmaster-return-20210804-138b405.diff (2031B)
1 From db6a8931a55982b95ed24ef57c8b71a6a3dafab6 Mon Sep 17 00:00:00 2001 2 From: Jack Bird <jack.bird@durham.ac.uk> 3 Date: Wed, 4 Aug 2021 20:27:23 +0100 4 Subject: [PATCH] Focus master and return supported over all tags 5 6 --- 7 dwm.c | 39 +++++++++++++++++++++++++++++++++++++++ 8 1 file changed, 39 insertions(+) 9 10 diff --git a/dwm.c b/dwm.c 11 index 5e4d494..ee28f28 100644 12 --- a/dwm.c 13 +++ b/dwm.c 14 @@ -127,6 +127,7 @@ struct Monitor { 15 Client *clients; 16 Client *sel; 17 Client *stack; 18 + Client *tagmarked[32]; 19 Monitor *next; 20 Window barwin; 21 const Layout *lt[2]; 22 @@ -167,6 +168,7 @@ static void enternotify(XEvent *e); 23 static void expose(XEvent *e); 24 static void focus(Client *c); 25 static void focusin(XEvent *e); 26 +static void focusmaster(const Arg *arg); 27 static void focusmon(const Arg *arg); 28 static void focusstack(const Arg *arg); 29 static Atom getatomprop(Client *c, Atom prop); 30 @@ -660,6 +662,10 @@ detach(Client *c) 31 { 32 Client **tc; 33 34 + for (int i = 1; i < LENGTH(tags); i++) 35 + if (c == c->mon->tagmarked[i]) 36 + c->mon->tagmarked[i] = NULL; 37 + 38 for (tc = &c->mon->clients; *tc && *tc != c; tc = &(*tc)->next); 39 *tc = c->next; 40 } 41 @@ -816,6 +822,34 @@ focusin(XEvent *e) 42 setfocus(selmon->sel); 43 } 44 45 +void 46 +focusmaster(const Arg *arg) 47 +{ 48 + Client *master; 49 + 50 + if (selmon->nmaster > 1) 51 + return; 52 + if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen)) 53 + return; 54 + 55 + master = nexttiled(selmon->clients); 56 + 57 + if (!master) 58 + return; 59 + 60 + int i; 61 + for (i = 0; !(selmon->tagset[selmon->seltags] & 1 << i); i++); 62 + i++; 63 + 64 + if (selmon->sel == master) { 65 + if (selmon->tagmarked[i] && ISVISIBLE(selmon->tagmarked[i])) 66 + focus(selmon->tagmarked[i]); 67 + } else { 68 + selmon->tagmarked[i] = selmon->sel; 69 + focus(master); 70 + } 71 +} 72 + 73 void 74 focusmon(const Arg *arg) 75 { 76 @@ -1203,6 +1237,11 @@ nexttiled(Client *c) 77 void 78 pop(Client *c) 79 { 80 + int i; 81 + for (i = 0; !(selmon->tagset[selmon->seltags] & 1 << i); i++); 82 + i++; 83 + 84 + c->mon->tagmarked[i] = nexttiled(c->mon->clients); 85 detach(c); 86 attach(c); 87 focus(c); 88 -- 89 2.32.0 90