sites

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

dwm-tilewide-6.4-for-uselessgap-20211119-58414bee958f2.diff (2614B)


      1 From 6a88229721cabfd6e288c31e8a539f68684f4761 Mon Sep 17 00:00:00 2001
      2 From: sympodius <mail@sympodius.net>
      3 Date: Fri, 10 Mar 2023 21:57:10 +0000
      4 Subject: [PATCH] Patch tested for 20211119-58414bee958f2 release of useless
      5  gap.
      6 
      7 ---
      8  config.def.h |  2 ++
      9  dwm.c        | 29 +++++++++++++++++++++++++++++
     10  2 files changed, 31 insertions(+)
     11 
     12 diff --git a/config.def.h b/config.def.h
     13 index 79ae7cf..e3e9708 100644
     14 --- a/config.def.h
     15 +++ b/config.def.h
     16 @@ -43,6 +43,7 @@ static const Layout layouts[] = {
     17  	{ "[]=",      tile },    /* first entry is default */
     18  	{ "><>",      NULL },    /* no layout function means floating behavior */
     19  	{ "[M]",      monocle },
     20 +	{ "[][]=",    tilewide },
     21  };
     22  
     23  /* key definitions */
     24 @@ -78,6 +79,7 @@ static const Key keys[] = {
     25  	{ MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
     26  	{ MODKEY,                       XK_f,      setlayout,      {.v = &layouts[1]} },
     27  	{ MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
     28 +	{ MODKEY,                       XK_w,      setlayout,      {.v = &layouts[3]} },
     29  	{ MODKEY,                       XK_space,  setlayout,      {0} },
     30  	{ MODKEY|ShiftMask,             XK_space,  togglefloating, {0} },
     31  	{ MODKEY,                       XK_0,      view,           {.ui = ~0 } },
     32 diff --git a/dwm.c b/dwm.c
     33 index a747f60..87bbc23 100644
     34 --- a/dwm.c
     35 +++ b/dwm.c
     36 @@ -209,6 +209,7 @@ static void spawn(const Arg *arg);
     37  static void tag(const Arg *arg);
     38  static void tagmon(const Arg *arg);
     39  static void tile(Monitor *m);
     40 +static void tilewide(Monitor *m);
     41  static void togglebar(const Arg *arg);
     42  static void togglefloating(const Arg *arg);
     43  static void toggletag(const Arg *arg);
     44 @@ -1728,6 +1729,34 @@ tile(Monitor *m)
     45  		}
     46  }
     47  
     48 +void
     49 +tilewide(Monitor *m)
     50 +{
     51 +        unsigned int i, n, w, h, mw, mx, ty;
     52 +	Client *c;
     53 +
     54 +	for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
     55 +	if (n == 0)
     56 +		return;
     57 +
     58 +	if (n > m->nmaster)
     59 +		mw = m->nmaster ? m->ww * m->mfact : 0;
     60 +	else
     61 +		mw = m->ww;
     62 +	for (i = mx = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
     63 +		if (i < m->nmaster) {
     64 +		        w = (mw - mx) / (MIN(n, m->nmaster) - i);
     65 +		        resize(c, m->wx + mx, m->wy, w - (2*c->bw) + (n > 1 ? gappx : 0), (m->wh - ty) - (2*c->bw), 0);
     66 +		        if  (mx + WIDTH(c) < m->ww)
     67 +		                mx += WIDTH(c);
     68 +		} else {
     69 +			h = (m->wh - ty) / (n - i);
     70 +			resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
     71 +			if (ty + HEIGHT(c) < m->wh)
     72 +				ty += HEIGHT(c);
     73 +		}
     74 +}
     75 +
     76  void
     77  togglebar(const Arg *arg)
     78  {
     79 -- 
     80 2.39.2
     81