mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
Adding nrowgrid layout
This commit is contained in:
parent
342fc03b88
commit
973d64f51b
@ -11,7 +11,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
|
|||||||
|
|
||||||
### Changelog:
|
### Changelog:
|
||||||
|
|
||||||
2019-09-09 - Added deck, fibonacci (dwindle and spiral), gridmode, gapplessgrid and horizgrid layouts
|
2019-09-09 - Added deck, fibonacci (dwindle and spiral), gridmode, gapplessgrid, horizgrid and nrowgrid layouts
|
||||||
|
|
||||||
2019-09-08 - Added cfacts and vanitygaps patches, added bstack and bstackhoriz layouts
|
2019-09-08 - Added cfacts and vanitygaps patches, added bstack and bstackhoriz layouts
|
||||||
|
|
||||||
@ -129,3 +129,6 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
|
|||||||
|
|
||||||
- [horizgrid](https://dwm.suckless.org/patches/horizgrid/)
|
- [horizgrid](https://dwm.suckless.org/patches/horizgrid/)
|
||||||
- horizontal grid layout
|
- horizontal grid layout
|
||||||
|
|
||||||
|
- [nrowgrid](https://dwm.suckless.org/patches/nrowgrid/)
|
||||||
|
- nrowgrid layout, number of rows in grid controlled by nmaster
|
30
config.def.h
30
config.def.h
@ -93,39 +93,49 @@ static const float mfact = 0.55; /* factor of master area size [0.05..0.95]
|
|||||||
static const int nmaster = 1; /* number of clients in master area */
|
static const int nmaster = 1; /* number of clients in master area */
|
||||||
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
||||||
|
|
||||||
|
#if NROWGRID_LAYOUT
|
||||||
|
#define FORCE_VSPLIT 1
|
||||||
|
#endif
|
||||||
|
|
||||||
static const Layout layouts[] = {
|
static const Layout layouts[] = {
|
||||||
/* symbol arrange function */
|
/* symbol arrange function */
|
||||||
#if TILE_LAYOUT
|
#if TILE_LAYOUT
|
||||||
{ "[]=", tile }, /* first entry is default */
|
{ "[]=", tile }, /* first entry is default */
|
||||||
#endif // TILE_LAYOUT
|
#endif
|
||||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||||
#if MONOCLE_LAYOUT
|
#if MONOCLE_LAYOUT
|
||||||
{ "[M]", monocle },
|
{ "[M]", monocle },
|
||||||
#endif // MONOCLE_LAYOUT
|
#endif
|
||||||
#if BSTACK_LAYOUT
|
#if BSTACK_LAYOUT
|
||||||
{ "TTT", bstack },
|
{ "TTT", bstack },
|
||||||
#endif // BSTACK_LAYOUT
|
#endif
|
||||||
#if BSTACKHORIZ_LAYOUT
|
#if BSTACKHORIZ_LAYOUT
|
||||||
{ "===", bstackhoriz },
|
{ "===", bstackhoriz },
|
||||||
#endif // BSTACKHORIZ_LAYOUT
|
#endif
|
||||||
#if DECK_LAYOUT
|
#if DECK_LAYOUT
|
||||||
{ "[D]", deck },
|
{ "[D]", deck },
|
||||||
#endif // DECK_LAYOUT
|
#endif
|
||||||
#if FIBONACCI_SPIRAL_LAYOUT
|
#if FIBONACCI_SPIRAL_LAYOUT
|
||||||
{ "(@)", spiral },
|
{ "(@)", spiral },
|
||||||
#endif // FIBONACCI_SPIRAL_LAYOUT
|
#endif
|
||||||
#if FIBONACCI_DWINDLE_LAYOUT
|
#if FIBONACCI_DWINDLE_LAYOUT
|
||||||
{ "[\\]", dwindle },
|
{ "[\\]", dwindle },
|
||||||
#endif // FIBONACCI_DWINDLE_LAYOUT
|
#endif
|
||||||
#if GRIDMODE_LAYOUT
|
#if GRIDMODE_LAYOUT
|
||||||
{ "HHH", grid },
|
{ "HHH", grid },
|
||||||
#endif // GRIDMODE_LAYOUT
|
#endif
|
||||||
#if HORIZGRID_LAYOUT
|
#if HORIZGRID_LAYOUT
|
||||||
{ "###", horizgrid },
|
{ "---", horizgrid },
|
||||||
|
#endif
|
||||||
|
#if GAPPLESSGRID_LAYOUT
|
||||||
|
{ ":::", gaplessgrid },
|
||||||
|
#endif
|
||||||
|
#if NROWGRID_LAYOUT
|
||||||
|
{ "###", nrowgrid },
|
||||||
#endif
|
#endif
|
||||||
#if CYCLELAYOUTS_PATCH
|
#if CYCLELAYOUTS_PATCH
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
#endif // CYCLELAYOUTS_PATCH
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/* key definitions */
|
/* key definitions */
|
||||||
|
@ -86,6 +86,10 @@
|
|||||||
#include "monocle.c"
|
#include "monocle.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if NROWGRID_LAYOUT
|
||||||
|
#include "nrowgrid.c"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if TILE_LAYOUT
|
#if TILE_LAYOUT
|
||||||
#include "tile.c"
|
#include "tile.c"
|
||||||
#endif
|
#endif
|
@ -82,6 +82,10 @@
|
|||||||
#include "monocle.h"
|
#include "monocle.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if NROWGRID_LAYOUT
|
||||||
|
#include "nrowgrid.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if TILE_LAYOUT
|
#if TILE_LAYOUT
|
||||||
#include "tile.h"
|
#include "tile.h"
|
||||||
#endif
|
#endif
|
103
patch/nrowgrid.c
Normal file
103
patch/nrowgrid.c
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
#if VANITYGAPS_PATCH
|
||||||
|
void
|
||||||
|
nrowgrid(Monitor *m)
|
||||||
|
{
|
||||||
|
unsigned int n = 0, i = 0, ri = 0, ci = 0; /* counters */
|
||||||
|
int oh, ov, ih, iv; /* vanitygap settings */
|
||||||
|
unsigned int cx, cy, cw, ch; /* client geometry */
|
||||||
|
unsigned int uw = 0, uh = 0, uc = 0; /* utilization trackers */
|
||||||
|
unsigned int cols, rows = m->nmaster + 1;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
/* count clients */
|
||||||
|
getgaps(m, &oh, &ov, &ih, &iv, &n);
|
||||||
|
|
||||||
|
/* nothing to do here */
|
||||||
|
if (n == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* force 2 clients to always split vertically */
|
||||||
|
if (FORCE_VSPLIT && n == 2)
|
||||||
|
rows = 1;
|
||||||
|
|
||||||
|
/* never allow empty rows */
|
||||||
|
if (n < rows)
|
||||||
|
rows = n;
|
||||||
|
|
||||||
|
/* define first row */
|
||||||
|
cols = n / rows;
|
||||||
|
uc = cols;
|
||||||
|
cy = m->wy + oh;
|
||||||
|
ch = (m->wh - 2*oh - ih*(rows - 1)) / rows;
|
||||||
|
uh = ch;
|
||||||
|
|
||||||
|
for (c = nexttiled(m->clients); c; c = nexttiled(c->next), i++, ci++) {
|
||||||
|
if (ci == cols) {
|
||||||
|
uw = 0;
|
||||||
|
ci = 0;
|
||||||
|
ri++;
|
||||||
|
|
||||||
|
/* next row */
|
||||||
|
cols = (n - uc) / (rows - ri);
|
||||||
|
uc += cols;
|
||||||
|
cy = m->wy + oh + uh + ih;
|
||||||
|
uh += ch + ih;
|
||||||
|
}
|
||||||
|
|
||||||
|
cx = m->wx + ov + uw;
|
||||||
|
cw = (m->ww - 2*ov - uw) / (cols - ci);
|
||||||
|
uw += cw + iv;
|
||||||
|
|
||||||
|
resize(c, cx, cy, cw - (2*c->bw), ch - (2*c->bw), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void
|
||||||
|
nrowgrid(Monitor *m)
|
||||||
|
{
|
||||||
|
unsigned int n = 0, i = 0, ri = 0, ci = 0; /* counters */
|
||||||
|
unsigned int cx, cy, cw, ch; /* client geometry */
|
||||||
|
unsigned int uw = 0, uh = 0, uc = 0; /* utilization trackers */
|
||||||
|
unsigned int cols, rows = m->nmaster + 1;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
|
if (n == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* force 2 clients to always split vertically */
|
||||||
|
if (FORCE_VSPLIT && n == 2)
|
||||||
|
rows = 1;
|
||||||
|
|
||||||
|
/* never allow empty rows */
|
||||||
|
if (n < rows)
|
||||||
|
rows = n;
|
||||||
|
|
||||||
|
/* define first row */
|
||||||
|
cols = n / rows;
|
||||||
|
uc = cols;
|
||||||
|
cy = m->wy;
|
||||||
|
ch = m->wh / rows;
|
||||||
|
uh = ch;
|
||||||
|
|
||||||
|
for (c = nexttiled(m->clients); c; c = nexttiled(c->next), i++, ci++) {
|
||||||
|
if (ci == cols) {
|
||||||
|
uw = 0;
|
||||||
|
ci = 0;
|
||||||
|
ri++;
|
||||||
|
|
||||||
|
/* next row */
|
||||||
|
cols = (n - uc) / (rows - ri);
|
||||||
|
uc += cols;
|
||||||
|
cy = m->wy + uh;
|
||||||
|
uh += ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
cx = m->wx + uw;
|
||||||
|
cw = (m->ww - uw) / (cols - ci);
|
||||||
|
uw += cw;
|
||||||
|
|
||||||
|
resize(c, cx, cy, cw - (2*c->bw), ch - (2*c->bw), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
1
patch/nrowgrid.h
Normal file
1
patch/nrowgrid.h
Normal file
@ -0,0 +1 @@
|
|||||||
|
static void nrowgrid(Monitor *m);
|
@ -227,6 +227,11 @@
|
|||||||
*/
|
*/
|
||||||
#define HORIZGRID_LAYOUT 0
|
#define HORIZGRID_LAYOUT 0
|
||||||
|
|
||||||
|
/* Grid layout where nmaster controls the number of rows.
|
||||||
|
* https://dwm.suckless.org/patches/nrowgrid/
|
||||||
|
*/
|
||||||
|
#define NROWGRID_LAYOUT 0
|
||||||
|
|
||||||
/* The default tile layout.
|
/* The default tile layout.
|
||||||
* This can be optionally disabled in favour of other layouts.
|
* This can be optionally disabled in favour of other layouts.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user