sites

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

dwm-deck-tilegap-6.2.diff (2930B)


      1 From 0da1bf76c63fa285abcb9241babc4a33ed11cca7 Mon Sep 17 00:00:00 2001
      2 From: aleks <aleks.stier@icloud.com>
      3 Date: Mon, 6 May 2019 16:21:02 +0200
      4 Subject: [PATCH] Add deck-tilegap-layout
      5 
      6 deck is a dwm-layout which is inspired by the TTWM window manager.
      7 It applies the monocle-layout to the clients in the stack.
      8 The master-client is still visible. The stacked clients are like
      9 a deck of cards, hence the name.
     10 
     11 This patch is ment to be used in combination with the tilegap-patch
     12 to preserve the gaps when the deck-layout is activated.
     13 ---
     14  config.def.h |  2 ++
     15  dwm.c        | 29 +++++++++++++++++++++++++++++
     16  2 files changed, 31 insertions(+)
     17 
     18 diff --git a/config.def.h b/config.def.h
     19 index 2ca9e56..3606a2e 100644
     20 --- a/config.def.h
     21 +++ b/config.def.h
     22 @@ -42,6 +42,7 @@ static const Layout layouts[] = {
     23  	{ "[]=",      tile },    /* first entry is default */
     24  	{ "><>",      NULL },    /* no layout function means floating behavior */
     25  	{ "[M]",      monocle },
     26 +	{ "[D]",      deck },
     27  };
     28  
     29  /* key definitions */
     30 @@ -77,6 +78,7 @@ static Key keys[] = {
     31  	{ MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
     32  	{ MODKEY,                       XK_f,      setlayout,      {.v = &layouts[1]} },
     33  	{ MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
     34 +	{ MODKEY,                       XK_c,      setlayout,      {.v = &layouts[3]} },
     35  	{ MODKEY,                       XK_space,  setlayout,      {0} },
     36  	{ MODKEY|ShiftMask,             XK_space,  togglefloating, {0} },
     37  	{ MODKEY,                       XK_0,      view,           {.ui = ~0 } },
     38 diff --git a/dwm.c b/dwm.c
     39 index c556a2d..c5b96dd 100644
     40 --- a/dwm.c
     41 +++ b/dwm.c
     42 @@ -157,6 +157,7 @@ static void configure(Client *c);
     43  static void configurenotify(XEvent *e);
     44  static void configurerequest(XEvent *e);
     45  static Monitor *createmon(void);
     46 +static void deck(Monitor *m);
     47  static void destroynotify(XEvent *e);
     48  static void detach(Client *c);
     49  static void detachstack(Client *c);
     50 @@ -654,6 +655,34 @@ destroynotify(XEvent *e)
     51  		unmanage(c, 1);
     52  }
     53  
     54 +void
     55 +deck(Monitor *m)
     56 +{
     57 +	unsigned int i, n, h, mw, my, ns;
     58 +	Client *c;
     59 +
     60 +	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
     61 +	if(n == 0)
     62 +		return;
     63 +
     64 +	if(n > m->nmaster) {
     65 +		mw = m->nmaster ? m->ww * m->mfact : 0;
     66 +		ns = m->nmaster > 0 ? 2 : 1;
     67 +		snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n - m->nmaster);
     68 +	} else {
     69 +		mw = m->ww;
     70 +		ns = 1;
     71 +	}
     72 +	for(i = 0, my = gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
     73 +		if(i < m->nmaster) {
     74 +			h = (m->wh - my) / (MIN(n, m->nmaster) - i) - gappx;
     75 +			resize(c, m->wx + gappx, m->wy + my, mw - (2*c->bw) - gappx*(5-ns)/2, h - (2*c->bw), False);
     76 +			my += HEIGHT(c) + gappx;
     77 +		}
     78 +		else
     79 +			resize(c, m->wx + mw + gappx/ns, m->wy + gappx, m->ww - mw - (2*c->bw) - gappx*(5-ns)/2, m->wh - (2*c->bw) - 2*gappx, False);
     80 +}
     81 +
     82  void
     83  detach(Client *c)
     84  {
     85 -- 
     86 2.21.0
     87