sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-focusmaster-return-6.2.diff (1999B)


      1 From 8f662e7a556f94bda83ec724fb036e15b2badaac Mon Sep 17 00:00:00 2001
      2 From: Jack Bird <jack.bird@durham.ac.uk>
      3 Date: Fri, 27 Aug 2021 01:14:44 +0100
      4 Subject: [PATCH] 6.2 focusmaster return
      5 
      6 ---
      7  dwm.c | 39 +++++++++++++++++++++++++++++++++++++++
      8  1 file changed, 39 insertions(+)
      9 
     10 diff --git a/dwm.c b/dwm.c
     11 index 4465af1..5219cbd 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 int getrootptr(int *x, int *y);
     30 @@ -659,6 +661,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 @@ -815,6 +821,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 @@ -1202,6 +1236,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.33.0
     90