sites

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

dwm-deck-6.2.diff (2716B)


      1 From 5a61a7c9152019d7097ad5af7300a6f83e053978 Mon Sep 17 00:00:00 2001
      2 From: aleks <aleks.stier@icloud.com>
      3 Date: Sat, 4 May 2019 21:15:25 +0200
      4 Subject: [PATCH] Add deck-layout
      5 
      6 deck is a dwm-layout which is inspired by the TTWM window manager.
      7 It applies the monocle-layout only 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  config.def.h |  2 ++
     12  dwm.c        | 29 +++++++++++++++++++++++++++++
     13  2 files changed, 31 insertions(+)
     14 
     15 diff --git a/config.def.h b/config.def.h
     16 index 1c0b587..f480546 100644
     17 --- a/config.def.h
     18 +++ b/config.def.h
     19 @@ -41,6 +41,7 @@ static const Layout layouts[] = {
     20  	{ "[]=",      tile },    /* first entry is default */
     21  	{ "><>",      NULL },    /* no layout function means floating behavior */
     22  	{ "[M]",      monocle },
     23 +	{ "H[]",      deck },
     24  };
     25  
     26  /* key definitions */
     27 @@ -76,6 +77,7 @@ static Key keys[] = {
     28  	{ MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
     29  	{ MODKEY,                       XK_f,      setlayout,      {.v = &layouts[1]} },
     30  	{ MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
     31 +	{ MODKEY,                       XK_c,      setlayout,      {.v = &layouts[3]} },
     32  	{ MODKEY,                       XK_space,  setlayout,      {0} },
     33  	{ MODKEY|ShiftMask,             XK_space,  togglefloating, {0} },
     34  	{ MODKEY,                       XK_0,      view,           {.ui = ~0 } },
     35 diff --git a/dwm.c b/dwm.c
     36 index 4465af1..59d4ddb 100644
     37 --- a/dwm.c
     38 +++ b/dwm.c
     39 @@ -158,6 +158,7 @@ static void configurenotify(XEvent *e);
     40  static void configurerequest(XEvent *e);
     41  static Monitor *createmon(void);
     42  static void destroynotify(XEvent *e);
     43 +static void deck(Monitor *m);
     44  static void detach(Client *c);
     45  static void detachstack(Client *c);
     46  static Monitor *dirtomon(int dir);
     47 @@ -654,6 +655,34 @@ destroynotify(XEvent *e)
     48  		unmanage(c, 1);
     49  }
     50  
     51 +void
     52 +deck(Monitor *m) {
     53 +	int dn;
     54 +	unsigned int i, n, h, mw, my;
     55 +	Client *c;
     56 +
     57 +	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
     58 +	if(n == 0)
     59 +		return;
     60 +
     61 +	dn = n - m->nmaster;
     62 +	if(dn > 0) /* override layout symbol */
     63 +		snprintf(m->ltsymbol, sizeof m->ltsymbol, "D %d", dn);
     64 +
     65 +	if(n > m->nmaster)
     66 +		mw = m->nmaster ? m->ww * m->mfact : 0;
     67 +	else
     68 +		mw = m->ww;
     69 +	for(i = my = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
     70 +		if(i < m->nmaster) {
     71 +			h = (m->wh - my) / (MIN(n, m->nmaster) - i);
     72 +			resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), False);
     73 +			my += HEIGHT(c);
     74 +		}
     75 +		else
     76 +			resize(c, m->wx + mw, m->wy, m->ww - mw - (2*c->bw), m->wh - (2*c->bw), False);
     77 +}
     78 +
     79  void
     80  detach(Client *c)
     81  {
     82 -- 
     83 2.21.0
     84