sites

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

dwm-rmaster-6.2.diff (3900B)


      1 From de2bfe560a8085630ffe976fd5972ee1e8d03916 Mon Sep 17 00:00:00 2001
      2 From: pskry <peter@skrypalle.dk>
      3 Date: Mon, 16 Nov 2020 17:47:05 +0100
      4 Subject: [PATCH] Enable swapping master- and stack-area
      5 
      6 Enables swapping the master- and stack area such that the master-client
      7 appears on the right and the stack-clients appear on the left.
      8 
      9 A variable and a toggle-function are introduced to achieve this
     10 behaviour which are set in the config.h:
     11 
     12 * The rmaster-variable can be set to 1 to make the right area the
     13 default master-area
     14 * The togglemaster-function can be used to swap the master- and
     15 stack-areas dynamically.
     16 ---
     17  config.def.h |  2 ++
     18  dwm.c        | 23 ++++++++++++++++++++---
     19  2 files changed, 22 insertions(+), 3 deletions(-)
     20 
     21 diff --git a/config.def.h b/config.def.h
     22 index 1c0b587..1d00282 100644
     23 --- a/config.def.h
     24 +++ b/config.def.h
     25 @@ -3,6 +3,7 @@
     26  /* appearance */
     27  static const unsigned int borderpx  = 1;        /* border pixel of windows */
     28  static const unsigned int snap      = 32;       /* snap pixel */
     29 +static const int rmaster            = 1;        /* 1 means master-area is initially on the right */
     30  static const int showbar            = 1;        /* 0 means no bar */
     31  static const int topbar             = 1;        /* 0 means bottom bar */
     32  static const char *fonts[]          = { "monospace:size=10" };
     33 @@ -78,6 +79,7 @@ static Key keys[] = {
     34  	{ MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
     35  	{ MODKEY,                       XK_space,  setlayout,      {0} },
     36  	{ MODKEY|ShiftMask,             XK_space,  togglefloating, {0} },
     37 +	{ MODKEY,                       XK_r,      togglermaster,  {0} },
     38  	{ MODKEY,                       XK_0,      view,           {.ui = ~0 } },
     39  	{ MODKEY|ShiftMask,             XK_0,      tag,            {.ui = ~0 } },
     40  	{ MODKEY,                       XK_comma,  focusmon,       {.i = -1 } },
     41 diff --git a/dwm.c b/dwm.c
     42 index 4465af1..a2d118b 100644
     43 --- a/dwm.c
     44 +++ b/dwm.c
     45 @@ -122,6 +122,7 @@ struct Monitor {
     46  	unsigned int seltags;
     47  	unsigned int sellt;
     48  	unsigned int tagset[2];
     49 +	int rmaster;
     50  	int showbar;
     51  	int topbar;
     52  	Client *clients;
     53 @@ -211,6 +212,7 @@ static void tagmon(const Arg *arg);
     54  static void tile(Monitor *);
     55  static void togglebar(const Arg *arg);
     56  static void togglefloating(const Arg *arg);
     57 +static void togglermaster(const Arg *arg);
     58  static void toggletag(const Arg *arg);
     59  static void toggleview(const Arg *arg);
     60  static void unfocus(Client *c, int setfocus);
     61 @@ -636,6 +638,7 @@ createmon(void)
     62  	m->tagset[0] = m->tagset[1] = 1;
     63  	m->mfact = mfact;
     64  	m->nmaster = nmaster;
     65 +	m->rmaster = rmaster;
     66  	m->showbar = showbar;
     67  	m->topbar = topbar;
     68  	m->lt[0] = &layouts[0];
     69 @@ -1681,17 +1684,21 @@ tile(Monitor *m)
     70  		return;
     71  
     72  	if (n > m->nmaster)
     73 -		mw = m->nmaster ? m->ww * m->mfact : 0;
     74 +		mw = m->nmaster
     75 +			? m->ww * (m->rmaster ? 1.0 - m->mfact : m->mfact)
     76 +			: 0;
     77  	else
     78  		mw = m->ww;
     79  	for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
     80  		if (i < m->nmaster) {
     81  			h = (m->wh - my) / (MIN(n, m->nmaster) - i);
     82 -			resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
     83 +			resize(c, m->rmaster ? m->wx + m->ww - mw : m->wx,
     84 +			       m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
     85  			my += HEIGHT(c);
     86  		} else {
     87  			h = (m->wh - ty) / (n - i);
     88 -			resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
     89 +			resize(c, m->rmaster ? m->wx : m->wx + mw, m->wy + ty,
     90 +			       m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
     91  			ty += HEIGHT(c);
     92  		}
     93  }
     94 @@ -1719,6 +1726,16 @@ togglefloating(const Arg *arg)
     95  	arrange(selmon);
     96  }
     97  
     98 +void
     99 +togglermaster(const Arg *arg)
    100 +{
    101 +	selmon->rmaster = !selmon->rmaster;
    102 +	/* now mfact represents the left factor */
    103 +	selmon->mfact = 1.0 - selmon->mfact;
    104 +	if (selmon->lt[selmon->sellt]->arrange)
    105 +		arrange(selmon);
    106 +}
    107 +
    108  void
    109  toggletag(const Arg *arg)
    110  {
    111 -- 
    112 2.31.1
    113