sites

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

dwm-bstackmfact-6.6.diff (7218B)


      1 diff --git a/config.def.h b/config.def.h
      2 index 9efa774..c0bfede 100644
      3 --- a/config.def.h
      4 +++ b/config.def.h
      5 @@ -3,6 +3,7 @@
      6  /* appearance */
      7  static const unsigned int borderpx  = 1;        /* border pixel of windows */
      8  static const unsigned int snap      = 32;       /* snap pixel */
      9 +static const unsigned int minwsz    = 20;       /* Minimal heigt of a client for smfact */
     10  static const int showbar            = 1;        /* 0 means no bar */
     11  static const int topbar             = 1;        /* 0 means bottom bar */
     12  static const char *fonts[]          = { "monospace:size=10" };
     13 @@ -33,6 +34,7 @@ static const Rule rules[] = {
     14  
     15  /* layout(s) */
     16  static const float mfact     = 0.55; /* factor of master area size [0.05..0.95] */
     17 +static const float smfact     = 0.00; /* factor of tiled clients [0.00..0.95] */
     18  static const int nmaster     = 1;    /* number of clients in master area */
     19  static const int resizehints = 1;    /* 1 means respect size hints in tiled resizals */
     20  static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
     21 @@ -42,6 +44,8 @@ static const Layout layouts[] = {
     22  	{ "[]=",      tile },    /* first entry is default */
     23  	{ "><>",      NULL },    /* no layout function means floating behavior */
     24  	{ "[M]",      monocle },
     25 +	{ "TTT",      bstack },
     26 +	{ "===",      bstackhoriz },
     27  };
     28  
     29  /* key definitions */
     30 @@ -71,12 +75,16 @@ static const Key keys[] = {
     31  	{ MODKEY,                       XK_d,      incnmaster,     {.i = -1 } },
     32  	{ MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
     33  	{ MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
     34 +	{ MODKEY|ShiftMask,             XK_h,      setsmfact,      {.f = +0.05} },
     35 +	{ MODKEY|ShiftMask,             XK_l,      setsmfact,      {.f = -0.05} },
     36  	{ MODKEY,                       XK_Return, zoom,           {0} },
     37  	{ MODKEY,                       XK_Tab,    view,           {0} },
     38  	{ MODKEY|ShiftMask,             XK_c,      killclient,     {0} },
     39  	{ MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
     40  	{ MODKEY,                       XK_f,      setlayout,      {.v = &layouts[1]} },
     41  	{ MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
     42 +	{ MODKEY,                       XK_s,      setlayout,      {.v = &layouts[3]} },
     43 +	{ MODKEY,                       XK_z,      setlayout,      {.v = &layouts[4]} },
     44  	{ MODKEY,                       XK_space,  setlayout,      {0} },
     45  	{ MODKEY|ShiftMask,             XK_space,  togglefloating, {0} },
     46  	{ MODKEY,                       XK_0,      view,           {.ui = ~0 } },
     47 diff --git a/dwm.c b/dwm.c
     48 index 1443802..1f829b8 100644
     49 --- a/dwm.c
     50 +++ b/dwm.c
     51 @@ -70,6 +70,7 @@ typedef union {
     52  	int i;
     53  	unsigned int ui;
     54  	float f;
     55 +	float sf;
     56  	const void *v;
     57  } Arg;
     58  
     59 @@ -113,6 +114,7 @@ typedef struct {
     60  struct Monitor {
     61  	char ltsymbol[16];
     62  	float mfact;
     63 +	float smfact;
     64  	int nmaster;
     65  	int num;
     66  	int by;               /* bar geometry */
     67 @@ -201,6 +203,7 @@ static void setfocus(Client *c);
     68  static void setfullscreen(Client *c, int fullscreen);
     69  static void setlayout(const Arg *arg);
     70  static void setmfact(const Arg *arg);
     71 +static void setsmfact(const Arg *arg);
     72  static void setup(void);
     73  static void seturgent(Client *c, int urg);
     74  static void showhide(Client *c);
     75 @@ -232,6 +235,8 @@ static int xerror(Display *dpy, XErrorEvent *ee);
     76  static int xerrordummy(Display *dpy, XErrorEvent *ee);
     77  static int xerrorstart(Display *dpy, XErrorEvent *ee);
     78  static void zoom(const Arg *arg);
     79 +static void bstack(Monitor *m);
     80 +static void bstackhoriz(Monitor *m);
     81  
     82  /* variables */
     83  static const char broken[] = "broken";
     84 @@ -633,10 +638,10 @@ Monitor *
     85  createmon(void)
     86  {
     87  	Monitor *m;
     88 -
     89  	m = ecalloc(1, sizeof(Monitor));
     90  	m->tagset[0] = m->tagset[1] = 1;
     91  	m->mfact = mfact;
     92 +	m->smfact = smfact;
     93  	m->nmaster = nmaster;
     94  	m->showbar = showbar;
     95  	m->topbar = topbar;
     96 @@ -1535,6 +1540,20 @@ setmfact(const Arg *arg)
     97  	arrange(selmon);
     98  }
     99  
    100 + void
    101 +setsmfact(const Arg *arg) {
    102 +	float sf;
    103 +
    104 +	if(!arg || !selmon->lt[selmon->sellt]->arrange)
    105 +		return;
    106 +	sf = arg->sf < 1.0 ? arg->sf + selmon->smfact : arg->sf - 1.0;
    107 +	if(sf < 0 || sf > 0.9)
    108 +		return;
    109 +	selmon->smfact = sf;
    110 +	arrange(selmon);
    111 +}
    112 +
    113 +
    114  void
    115  setup(void)
    116  {
    117 @@ -1686,7 +1705,7 @@ tagmon(const Arg *arg)
    118  void
    119  tile(Monitor *m)
    120  {
    121 -	unsigned int i, n, h, mw, my, ty;
    122 +	unsigned int i, n, h, smh, mw, my, ty;
    123  	Client *c;
    124  
    125  	for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
    126 @@ -1704,9 +1723,22 @@ tile(Monitor *m)
    127  			if (my + HEIGHT(c) < m->wh)
    128  				my += HEIGHT(c);
    129  		} else {
    130 -			h = (m->wh - ty) / (n - i);
    131 -			resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
    132 -			if (ty + HEIGHT(c) < m->wh)
    133 +			smh = m->mh * m->smfact;
    134 +			if(!(nexttiled(c->next)))
    135 +				h = (m->wh - ty) / (n - i);
    136 +			else
    137 +				h = (m->wh - smh - ty) / (n - i);
    138 +			if(h < minwsz) {
    139 +				c->isfloating = True;
    140 +				XRaiseWindow(dpy, c->win);
    141 +				resize(c, m->mx + (m->mw / 2 - WIDTH(c) / 2), m->my + (m->mh / 2 - HEIGHT(c) / 2), m->ww - mw - (2*c->bw), h - (2*c->bw), False);
    142 +				ty -= HEIGHT(c);
    143 +			}
    144 +			else
    145 +				resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), False);
    146 +			if(!(nexttiled(c->next)))
    147 +				ty += HEIGHT(c) + smh;
    148 +			else
    149  				ty += HEIGHT(c);
    150  		}
    151  }
    152 @@ -2162,3 +2194,69 @@ main(int argc, char *argv[])
    153  	XCloseDisplay(dpy);
    154  	return EXIT_SUCCESS;
    155  }
    156 +
    157 +static void
    158 +bstack(Monitor *m) {
    159 +	int w, h, mh, mx, tx, ty, tw, tws;
    160 +	unsigned int i, n;
    161 +	Client *c;
    162 +
    163 +	for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
    164 +	if (n == 0)
    165 +		return;
    166 +	if (n > m->nmaster) {
    167 +		mh = m->nmaster ? m->mfact * m->wh : 0;
    168 +		tw = m->ww / (n - m->nmaster);
    169 +		ty = m->wy + mh;
    170 +	} else {
    171 +		mh = m->wh;
    172 +		tw = m->ww;
    173 +		ty = m->wy;
    174 +	}
    175 +	for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
    176 +		if (i < m->nmaster) {
    177 +			w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
    178 +   		resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0);
    179 +			mx += WIDTH(c);
    180 +		} else {
    181 +			h = m->wh - mh;
    182 +            if (i == m->nmaster) {
    183 +                tws = (n > 2) ? tw + m->mw * m->smfact / 2: tw;} 
    184 +            else {
    185 +                tws = tw - m->mw * m->smfact/MAX(n-2, 1) / 2;}
    186 +            resize(c, tx, ty, tws - (2 * c->bw), h - (2 * c->bw), 0);
    187 +			if (tw != m->ww)
    188 +				tx += WIDTH(c);
    189 +		}
    190 +	}
    191 +}
    192 +
    193 +static void
    194 +bstackhoriz(Monitor *m) {
    195 +	int w, mh, mx, tx, ty, th;
    196 +	unsigned int i, n;
    197 +	Client *c;
    198 +
    199 +	for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
    200 +	if (n == 0)
    201 +		return;
    202 +	if (n > m->nmaster) {
    203 +		mh = m->nmaster ? m->mfact * m->wh : 0;
    204 +		th = (m->wh - mh) / (n - m->nmaster);
    205 +		ty = m->wy + mh;
    206 +	} else {
    207 +		th = mh = m->wh;
    208 +		ty = m->wy;
    209 +	}
    210 +	for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
    211 +		if (i < m->nmaster) {
    212 +			w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
    213 +			resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0);
    214 +			mx += WIDTH(c);
    215 +		} else {
    216 +			resize(c, tx, ty, m->ww - (2 * c->bw), th - (2 * c->bw), 0);
    217 +			if (th != m->wh)
    218 +				ty += HEIGHT(c);
    219 +		}
    220 +	}
    221 +}