sites

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

dwm-deck-double-6.2.diff (2488B)


      1 From c29cee8186c9a8d117a128b6848afb08035961c1 Mon Sep 17 00:00:00 2001
      2 From: Miles Alan <m@milesalan.com>
      3 Date: Mon, 17 Aug 2020 20:57:03 -0500
      4 Subject: [PATCH] Add doubledeck layout function and bind to MOD+r
      5 
      6 The doubledeck layout is like the deck layout, which stacks clients one ontop
      7 of another in the stack area, however the doubledeck variant additionally
      8 stacks clients one ontop of eachother in the master area.
      9 ---
     10  config.def.h |  2 ++
     11  dwm.c        | 22 ++++++++++++++++++++++
     12  2 files changed, 24 insertions(+)
     13 
     14 diff --git a/config.def.h b/config.def.h
     15 index 1c0b587..6538420 100644
     16 --- a/config.def.h
     17 +++ b/config.def.h
     18 @@ -41,6 +41,7 @@ static const Layout layouts[] = {
     19  	{ "[]=",      tile },    /* first entry is default */
     20  	{ "><>",      NULL },    /* no layout function means floating behavior */
     21  	{ "[M]",      monocle },
     22 +	{ "DD",       doubledeck },
     23  };
     24  
     25  /* key definitions */
     26 @@ -76,6 +77,7 @@ static Key keys[] = {
     27  	{ MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
     28  	{ MODKEY,                       XK_f,      setlayout,      {.v = &layouts[1]} },
     29  	{ MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
     30 +	{ MODKEY,                       XK_r,      setlayout,      {.v = &layouts[3]} },
     31  	{ MODKEY,                       XK_space,  setlayout,      {0} },
     32  	{ MODKEY|ShiftMask,             XK_space,  togglefloating, {0} },
     33  	{ MODKEY,                       XK_0,      view,           {.ui = ~0 } },
     34 diff --git a/dwm.c b/dwm.c
     35 index 4465af1..ce29fb4 100644
     36 --- a/dwm.c
     37 +++ b/dwm.c
     38 @@ -161,6 +161,7 @@ static void destroynotify(XEvent *e);
     39  static void detach(Client *c);
     40  static void detachstack(Client *c);
     41  static Monitor *dirtomon(int dir);
     42 +static void doubledeck(Monitor *m);
     43  static void drawbar(Monitor *m);
     44  static void drawbars(void);
     45  static void enternotify(XEvent *e);
     46 @@ -692,6 +693,27 @@ dirtomon(int dir)
     47  	return m;
     48  }
     49  
     50 +void
     51 +doubledeck(Monitor *m) {
     52 +	unsigned int i, n, mw;
     53 +	Client *c;
     54 +
     55 +	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
     56 +	if(n == 0)
     57 +		return;
     58 +
     59 +	if(n > m->nmaster)
     60 +		mw = m->nmaster ? m->ww * m->mfact : 0;
     61 +	else
     62 +		mw = m->ww;
     63 +
     64 +	for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
     65 +		if(i < m->nmaster)
     66 +			resize(c, m->wx, m->wy, mw - (2*c->bw), m->wh - (2*c->bw), False);
     67 +		else
     68 +			resize(c, m->wx + mw, m->wy, m->ww - mw - (2*c->bw), m->wh - (2*c->bw), False);
     69 +}
     70 +
     71  void
     72  drawbar(Monitor *m)
     73  {
     74 -- 
     75 2.25.4
     76