sites

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

dwm-nrowgrid-6.1.diff (2308B)


      1 Author: Chris Noxz <chris@noxz.tech>
      2 
      3 diff -upN dwm-6.1/config.def.h dwm-nrowgrid-6.1/config.def.h
      4 --- dwm-6.1/config.def.h	2015-11-08 23:11:48.000000000 +0100
      5 +++ dwm-nrowgrid-6.1/config.def.h	2018-10-01 10:44:05.631382842 +0200
      6 @@ -34,11 +34,15 @@ static const float mfact     = 0.55; /*
      7  static const int nmaster     = 1;    /* number of clients in master area */
      8  static const int resizehints = 1;    /* 1 means respect size hints in tiled resizals */
      9  
     10 +#define FORCE_VSPLIT 1
     11 +#include "nrowgrid.c"
     12 +
     13  static const Layout layouts[] = {
     14  	/* symbol     arrange function */
     15  	{ "[]=",      tile },    /* first entry is default */
     16  	{ "><>",      NULL },    /* no layout function means floating behavior */
     17  	{ "[M]",      monocle },
     18 +	{ "###",      nrowgrid },
     19  };
     20  
     21  /* key definitions */
     22 diff -upN dwm-6.1/nrowgrid.c dwm-nrowgrid-6.1/nrowgrid.c
     23 --- dwm-6.1/nrowgrid.c	1970-01-01 01:00:00.000000000 +0100
     24 +++ dwm-nrowgrid-6.1/nrowgrid.c	2018-10-01 10:44:27.741263063 +0200
     25 @@ -0,0 +1,52 @@
     26 +void
     27 +nrowgrid(Monitor *m)
     28 +{
     29 +    unsigned int n = 0, i = 0, ri = 0, ci = 0;  /* counters */
     30 +    unsigned int cx, cy, cw, ch;                /* client geometry */
     31 +    unsigned int uw = 0, uh = 0, uc = 0;        /* utilization trackers */
     32 +    unsigned int cols, rows = m->nmaster + 1;
     33 +    Client *c;
     34 +
     35 +    /* count clients */
     36 +    for (c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
     37 +
     38 +    /* nothing to do here */
     39 +    if (n == 0)
     40 +        return;
     41 +
     42 +    /* force 2 clients to always split vertically */
     43 +    if (FORCE_VSPLIT && n == 2)
     44 +        rows = 1;
     45 +
     46 +    /* never allow empty rows */
     47 +    if (n < rows)
     48 +        rows = n;
     49 +
     50 +    /* define first row */
     51 +    cols = n / rows;
     52 +    uc = cols;
     53 +    cy = m->wy;
     54 +    ch = m->wh / rows;
     55 +    uh = ch;
     56 +
     57 +    for (c = nexttiled(m->clients); c; c = nexttiled(c->next), i++, ci++) {
     58 +        if (ci == cols) {
     59 +            uw = 0;
     60 +            ci = 0;
     61 +            ri++;
     62 +
     63 +            /* next row */
     64 +            cols = (n - uc) / (rows - ri);
     65 +            uc += cols;
     66 +            cy = m->wy + uh;
     67 +            ch = (m->wh - uh) / (rows - ri);
     68 +            uh += ch;
     69 +        }
     70 +
     71 +        cx = m->wx + uw;
     72 +        cw = (m->ww - uw) / (cols - ci);
     73 +        uw += cw;
     74 +
     75 +        resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, 0);
     76 +    }
     77 +}