sites

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

nmaster+bstack-5.6.1.diff (5927B)


      1 diff -r e47a47bd3ed4 config.def.h
      2 --- a/config.def.h	Tue Jul 21 10:57:54 2009 +0100
      3 +++ b/config.def.h	Mon Aug 24 17:14:00 2009 +0200
      4 @@ -24,11 +24,13 @@
      5  
      6  /* layout(s) */
      7  static const float mfact      = 0.55; /* factor of master area size [0.05..0.95] */
      8 +static const int nmaster      = 1;    /* default number of master windows */
      9  static const Bool resizehints = True; /* False means respect size hints in tiled resizals */
     10  
     11  static const Layout layouts[] = {
     12  	/* symbol     arrange function */
     13  	{ "[]=",      tile },    /* first entry is default */
     14 +	{ "TTT",      bstack },
     15  	{ "><>",      NULL },    /* no layout function means floating behavior */
     16  	{ "[M]",      monocle },
     17  };
     18 @@ -57,12 +59,15 @@
     19  	{ MODKEY,                       XK_k,      focusstack,     {.i = -1 } },
     20  	{ MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
     21  	{ MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
     22 +	{ MODKEY|ShiftMask,             XK_h,      incnmaster,     {.i = +1 } },
     23 +	{ MODKEY|ShiftMask,             XK_l,      incnmaster,     {.i = -1 } },
     24  	{ MODKEY,                       XK_Return, zoom,           {0} },
     25  	{ MODKEY,                       XK_Tab,    view,           {0} },
     26  	{ MODKEY|ShiftMask,             XK_c,      killclient,     {0} },
     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_o,      setlayout,      {.v = &layouts[1]} },
     31 +	{ MODKEY,                       XK_f,      setlayout,      {.v = &layouts[2]} },
     32 +	{ MODKEY,                       XK_m,      setlayout,      {.v = &layouts[3]} },
     33  	{ MODKEY,                       XK_space,  setlayout,      {0} },
     34  	{ MODKEY|ShiftMask,             XK_space,  togglefloating, {0} },
     35  	{ MODKEY,                       XK_0,      view,           {.ui = ~0 } },
     36 diff -r e47a47bd3ed4 dwm.c
     37 --- a/dwm.c	Tue Jul 21 10:57:54 2009 +0100
     38 +++ b/dwm.c	Mon Aug 24 17:14:00 2009 +0200
     39 @@ -122,6 +122,7 @@
     40  
     41  struct Monitor {
     42  	float mfact;
     43 +	int nmaster;
     44  	int num;
     45  	int by;               /* bar geometry */
     46  	int mx, my, mw, mh;   /* screen size */
     47 @@ -205,6 +206,8 @@
     48  static void setclientstate(Client *c, long state);
     49  static void setlayout(const Arg *arg);
     50  static void setmfact(const Arg *arg);
     51 +static void incnmaster(const Arg *arg);
     52 +static void setnmaster(const Arg *arg);
     53  static void setup(void);
     54  static void showhide(Client *c);
     55  static void sigchld(int signal);
     56 @@ -213,6 +216,7 @@
     57  static void tagmon(const Arg *arg);
     58  static int textnw(const char *text, unsigned int len);
     59  static void tile(Monitor *);
     60 +static void bstack(Monitor *);
     61  static void togglebar(const Arg *arg);
     62  static void togglefloating(const Arg *arg);
     63  static void toggletag(const Arg *arg);
     64 @@ -1423,6 +1427,24 @@
     65  }
     66  
     67  void
     68 +incnmaster(const Arg *arg) {
     69 +	if(!arg || !selmon->lt[selmon->sellt]->arrange)
     70 +		return;
     71 +	selmon->nmaster += arg->i;
     72 +	if(selmon->nmaster < 0) selmon->nmaster = 0;
     73 +	arrange();
     74 +}
     75 +
     76 +void
     77 +setnmaster(const Arg *arg) {
     78 +	if(!arg || !selmon->lt[selmon->sellt]->arrange)
     79 +		return;
     80 +	selmon->nmaster = arg->i;
     81 +	if(selmon->nmaster < 0) selmon->nmaster = 0;
     82 +	arrange();
     83 +}
     84 +
     85 +void
     86  setup(void) {
     87  	unsigned int i;
     88  	int w;
     89 @@ -1542,7 +1564,7 @@
     90  
     91  void
     92  tile(Monitor *m) {
     93 -	int x, y, h, w, mw;
     94 +	int x, y, h, w, mw, nm;
     95  	unsigned int i, n;
     96  	Client *c;
     97  
     98 @@ -1550,23 +1572,81 @@
     99  	if(n == 0)
    100  		return;
    101  	/* master */
    102 -	c = nexttiled(m->clients);
    103 -	mw = m->mfact * m->ww;
    104 -	resize(c, m->wx, m->wy, (n == 1 ? m->ww : mw) - 2 * c->bw, m->wh - 2 * c->bw, False);
    105 -	if(--n == 0)
    106 -		return;
    107 +	if(m->nmaster > 0) {
    108 +		nm = n < m->nmaster ? n : m->nmaster;
    109 +		c = nexttiled(m->clients);
    110 +		mw = m->mfact * m->ww;
    111 +		h = m->wh / nm;
    112 +		y = m->wy;
    113 +		for(i=0; i<nm; i++, c = nexttiled(c->next)) {
    114 +			resize(c, m->wx, y, (n == nm ? m->ww : mw) - 2 * c->bw,
    115 +					((i + 1 == nm) ? m->wy + m->wh - y : h) - 2 * c->bw, False);
    116 +			if(h != m->wh)
    117 +				y = c->y + HEIGHT(c);
    118 +		}
    119 +		n -= nm;
    120 +		if(n == 0) return;
    121 +	} else {
    122 +		mw = 0;
    123 +		c = nexttiled(m->clients);
    124 +	}
    125  	/* tile stack */
    126 -	x = (m->wx + mw > c->x + c->w) ? c->x + c->w + 2 * c->bw : m->wx + mw;
    127 +	x = m->wx + mw;
    128  	y = m->wy;
    129 -	w = (m->wx + mw > c->x + c->w) ? m->wx + m->ww - x : m->ww - mw;
    130 +	w = m->ww - mw;
    131  	h = m->wh / n;
    132  	if(h < bh)
    133  		h = m->wh;
    134 -	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
    135 +	for(i = 0; c; c = nexttiled(c->next), i++) {
    136  		resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
    137  		       ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw), False);
    138  		if(h != m->wh)
    139  			y = c->y + HEIGHT(c);
    140 +	}
    141 +}
    142 +
    143 +void
    144 +bstack(Monitor *m) {
    145 +	int x, y, h, w, mh, nm;
    146 +	unsigned int i, n;
    147 +	Client *c;
    148 +
    149 +	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
    150 +	if(n == 0)
    151 +		return;
    152 +
    153 +	if(m->nmaster > 0) {
    154 +		nm = n < m->nmaster ? n : m->nmaster;
    155 +		c = nexttiled(m->clients);
    156 +		mh = m->mfact * m->wh;
    157 +		x = m->wx;
    158 +		h = m->wh;
    159 +		w = m->ww / nm;
    160 +		for(i=0; i<nm; i++, c = nexttiled(c->next)) {
    161 +			resize(c, x, m->wy, ((i + 1 == nm) ? m->wx + m->ww - x : w) - 2 * c->bw,
    162 +					(n == nm ? m->wh : mh) - 2 * c->bw, False);
    163 +			if(w != m->ww)
    164 +				x = c->x + WIDTH(c);
    165 +		}
    166 +		n -= nm;
    167 +		if(n == 0) return;
    168 +	} else {
    169 +		mh = 0;
    170 +		c = nexttiled(m->clients);
    171 +	}
    172 +
    173 +	x = m->wx;
    174 +	y = m->wy + mh;
    175 +	w = m->ww / n;
    176 +	h = m->wh - mh;
    177 +	if(h < bh)
    178 +		h = m->wh;
    179 +
    180 +	for(i = 0; c; c = nexttiled(c->next), i++) {
    181 +		resize(c, x, y, ((i + 1 == n) ? m->wx + m->ww - x : w) - 2 * c->bw,
    182 +		       h - 2 * c->bw, False);
    183 +		if(w != m->ww)
    184 +			x = c->x + WIDTH(c);	
    185  	}
    186  }
    187  
    188 @@ -1734,6 +1814,7 @@
    189  		m->sellt = 0;
    190  		m->tagset[0] = m->tagset[1] = 1;
    191  		m->mfact = mfact;
    192 +		m->nmaster = nmaster;
    193  		m->showbar = showbar;
    194  		m->topbar = topbar;
    195  		m->lt[0] = &layouts[0];