dotfiles

My collection of dotfiles
git clone git://git.stellar-nexus.ru/dotfiles
Log | Files | Refs

03-dwm-resetlayout-6.2_and_no-border.diff (2473B)


      1 From 4df827a2ec7820f41bdb8576cc39b55fbf35be44 Mon Sep 17 00:00:00 2001
      2 From: Jack Bird <jack.bird@durham.ac.uk>
      3 Date: Mon, 16 Aug 2021 23:25:16 +0100
      4 Subject: [PATCH] Patch applies cleanly
      5 
      6 ---
      7  config.def.h |  1 +
      8  dwm.c        | 15 +++++++++++++++
      9  2 files changed, 16 insertions(+)
     10 
     11 diff --git a/config.def.h b/config.def.h
     12 index 1c0b587..5d118cf 100644
     13 --- a/config.def.h
     14 +++ b/config.def.h
     15 @@ -70,6 +70,7 @@ static Key keys[] = {
     16  	{ MODKEY,                       XK_d,      incnmaster,     {.i = -1 } },
     17  	{ MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
     18  	{ MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
     19 +    { MODKEY,                       XK_r,      resetlayout,    {0} },
     20  	{ MODKEY,                       XK_Return, zoom,           {0} },
     21  	{ MODKEY,                       XK_Tab,    view,           {0} },
     22  	{ MODKEY|ShiftMask,             XK_c,      killclient,     {0} },
     23 diff --git a/dwm.c b/dwm.c
     24 index 4465af1..77727ea 100644
     25 --- a/dwm.c
     26 +++ b/dwm.c
     27 @@ -188,6 +188,7 @@ static void pop(Client *);
     28  static void propertynotify(XEvent *e);
     29  static void quit(const Arg *arg);
     30  static Monitor *recttomon(int x, int y, int w, int h);
     31 +static void resetlayout(const Arg *arg);
     32  static void resize(Client *c, int x, int y, int w, int h, int interact);
     33  static void resizeclient(Client *c, int x, int y, int w, int h);
     34  static void resizemouse(const Arg *arg);
     35 @@ -1265,6 +1266,16 @@ recttomon(int x, int y, int w, int h)
     36  	return r;
     37  }
     38  
     39 +void
     40 +resetlayout(const Arg *arg)
     41 +{
     42 +	Arg default_layout = {.v = &layouts[0]};
     43 +	Arg default_mfact = {.f = mfact + 1};
     44 +
     45 +	setlayout(&default_layout);
     46 +	setmfact(&default_mfact);
     47 +}
     48 +
     49  void
     50  resize(Client *c, int x, int y, int w, int h, int interact)
     51  {
     52 @@ -1282,6 +1293,18 @@ resizeclient(Client *c, int x, int y, int w, int h)
     53  	c->oldw = c->w; c->w = wc.width = w;
     54  	c->oldh = c->h; c->h = wc.height = h;
     55  	wc.border_width = c->bw;
     56 +
     57 +	if ((nexttiled(c->mon->clients) == c) && !(nexttiled(c->next)))
     58 +		resetlayout(NULL);
     59 +
     60 +	if (((nexttiled(c->mon->clients) == c && !nexttiled(c->next))
     61 +	     || &monocle == c->mon->lt[c->mon->sellt]->arrange)
     62 +	     && !c->isfullscreen && !c->isfloating
     63 +	     && NULL != c->mon->lt[c->mon->sellt]->arrange) {
     64 +		c->w = wc.width += c->bw * 2;
     65 +		c->h = wc.height += c->bw *2;
     66 +		wc.border_width = 0;
     67 +	}
     68  	XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
     69  	configure(c);
     70  	XSync(dpy, False);
     71 -- 
     72 2.32.0
     73