sites

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

dwm-6.0-smfact.diff (4004B)


      1 --- config.def.h	2013-04-06 21:01:27.750829760 +0200
      2 +++ config.def.h	2013-04-06 21:02:19.557495556 +0200
      3 @@ -10,6 +10,7 @@ static const char selbgcolor[]      = "#
      4  static const char selfgcolor[]      = "#eeeeee";
      5  static const unsigned int borderpx  = 1;        /* border pixel of windows */
      6  static const unsigned int snap      = 32;       /* snap pixel */
      7 +static const unsigned int minwsz    = 20;       /* Minimal heigt of a client for smfact */
      8  static const Bool showbar           = True;     /* False means no bar */
      9  static const Bool topbar            = True;     /* False means bottom bar */
     10  
     11 @@ -24,6 +25,7 @@ static const Rule rules[] = {
     12  
     13  /* layout(s) */
     14  static const float mfact      = 0.55; /* factor of master area size [0.05..0.95] */
     15 +static const float smfact     = 0.00; /* factor of tiled clients [0.00..0.95] */
     16  static const int nmaster      = 1;    /* number of clients in master area */
     17  static const Bool resizehints = True; /* True means respect size hints in tiled resizals */
     18  
     19 @@ -60,6 +62,8 @@ static Key keys[] = {
     20  	{ MODKEY,                       XK_d,      incnmaster,     {.i = -1 } },
     21  	{ MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
     22  	{ MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
     23 +	{ MODKEY|ShiftMask,             XK_h,      setsmfact,      {.f = +0.05} },
     24 +	{ MODKEY|ShiftMask,             XK_l,      setsmfact,      {.f = -0.05} },
     25  	{ MODKEY,                       XK_Return, zoom,           {0} },
     26  	{ MODKEY,                       XK_Tab,    view,           {0} },
     27  	{ MODKEY|ShiftMask,             XK_c,      killclient,     {0} },
     28 --- dwm.c	2011-12-19 16:02:46.000000000 +0100
     29 +++ dwm.c	2013-04-06 21:00:46.620830452 +0200
     30 @@ -69,6 +69,7 @@ typedef union {
     31  	int i;
     32  	unsigned int ui;
     33  	float f;
     34 +	float sf;
     35  	const void *v;
     36  } Arg;
     37  
     38 @@ -127,6 +128,7 @@ typedef struct {
     39  struct Monitor {
     40  	char ltsymbol[16];
     41  	float mfact;
     42 +	float smfact;
     43  	int nmaster;
     44  	int num;
     45  	int by;               /* bar geometry */
     46 @@ -220,6 +222,7 @@ static void setfocus(Client *c);
     47  static void setfullscreen(Client *c, Bool fullscreen);
     48  static void setlayout(const Arg *arg);
     49  static void setmfact(const Arg *arg);
     50 +static void setsmfact(const Arg *arg);
     51  static void setup(void);
     52  static void showhide(Client *c);
     53  static void sigchld(int unused);
     54 @@ -651,6 +654,7 @@ createmon(void) {
     55  		die("fatal: could not malloc() %u bytes\n", sizeof(Monitor));
     56  	m->tagset[0] = m->tagset[1] = 1;
     57  	m->mfact = mfact;
     58 +	m->smfact = smfact;
     59  	m->nmaster = nmaster;
     60  	m->showbar = showbar;
     61  	m->topbar = topbar;
     62 @@ -1581,6 +1585,19 @@ setmfact(const Arg *arg) {
     63  }
     64  
     65  void
     66 +setsmfact(const Arg *arg) {
     67 +	float sf;
     68 +
     69 +	if(!arg || !selmon->lt[selmon->sellt]->arrange)
     70 +		return;
     71 +	sf = arg->sf < 1.0 ? arg->sf + selmon->smfact : arg->sf - 1.0;
     72 +	if(sf < 0 || sf > 0.9)
     73 +		return;
     74 +	selmon->smfact = sf;
     75 +	arrange(selmon);
     76 +}
     77 +
     78 +void
     79  setup(void) {
     80  	XSetWindowAttributes wa;
     81  
     82 @@ -1703,7 +1720,7 @@ textnw(const char *text, unsigned int le
     83  
     84  void
     85  tile(Monitor *m) {
     86 -	unsigned int i, n, h, mw, my, ty;
     87 +	unsigned int i, n, h, smh, mw, my, ty;
     88  	Client *c;
     89  
     90  	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
     91 @@ -1721,9 +1738,23 @@ tile(Monitor *m) {
     92  			my += HEIGHT(c);
     93  		}
     94  		else {
     95 -			h = (m->wh - ty) / (n - i);
     96 -			resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), False);
     97 -			ty += HEIGHT(c);
     98 +			smh = m->mh * m->smfact;
     99 +			if(!(nexttiled(c->next)))
    100 +				h = (m->wh - ty) / (n - i);
    101 +			else
    102 +				h = (m->wh - smh - ty) / (n - i);
    103 +			if(h < minwsz) {
    104 +				c->isfloating = True;
    105 +				XRaiseWindow(dpy, c->win);
    106 +				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);
    107 +				ty -= HEIGHT(c);
    108 +			}
    109 +			else
    110 +				resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), False);
    111 +			if(!(nexttiled(c->next)))
    112 +				ty += HEIGHT(c) + smh;
    113 +			else
    114 +				ty += HEIGHT(c);
    115  		}
    116  }
    117