mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
Adding horizgrid and gridmode layouts
This commit is contained in:
parent
9081aef748
commit
342fc03b88
10
README.md
10
README.md
@ -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) and gapplessgrid layouts
|
2019-09-09 - Added deck, fibonacci (dwindle and spiral), gridmode, gapplessgrid and horizgrid 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
|
||||||
|
|
||||||
@ -122,4 +122,10 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
|
|||||||
- fibonacci (dwindle and spiral) layouts
|
- fibonacci (dwindle and spiral) layouts
|
||||||
|
|
||||||
- [gapplessgrid](https://dwm.suckless.org/patches/gaplessgrid/)
|
- [gapplessgrid](https://dwm.suckless.org/patches/gaplessgrid/)
|
||||||
- gappless grid layout
|
- gappless grid layout
|
||||||
|
|
||||||
|
- [gridmode](https://dwm.suckless.org/patches/gridmode/)
|
||||||
|
- gridmode (grid) layout
|
||||||
|
|
||||||
|
- [horizgrid](https://dwm.suckless.org/patches/horizgrid/)
|
||||||
|
- horizontal grid layout
|
@ -117,6 +117,12 @@ static const Layout layouts[] = {
|
|||||||
#if FIBONACCI_DWINDLE_LAYOUT
|
#if FIBONACCI_DWINDLE_LAYOUT
|
||||||
{ "[\\]", dwindle },
|
{ "[\\]", dwindle },
|
||||||
#endif // FIBONACCI_DWINDLE_LAYOUT
|
#endif // FIBONACCI_DWINDLE_LAYOUT
|
||||||
|
#if GRIDMODE_LAYOUT
|
||||||
|
{ "HHH", grid },
|
||||||
|
#endif // GRIDMODE_LAYOUT
|
||||||
|
#if HORIZGRID_LAYOUT
|
||||||
|
{ "###", horizgrid },
|
||||||
|
#endif
|
||||||
#if CYCLELAYOUTS_PATCH
|
#if CYCLELAYOUTS_PATCH
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
#endif // CYCLELAYOUTS_PATCH
|
#endif // CYCLELAYOUTS_PATCH
|
||||||
|
50
patch/grid.c
Normal file
50
patch/grid.c
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#if VANITYGAPS_PATCH
|
||||||
|
static void
|
||||||
|
grid(Monitor *m)
|
||||||
|
{
|
||||||
|
unsigned int i, n, cx, cy, cw, ch, cols, rows;
|
||||||
|
int oh, ov, ih, iv;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
getgaps(m, &oh, &ov, &ih, &iv, &n);
|
||||||
|
|
||||||
|
/* grid dimensions */
|
||||||
|
for (rows = 0; rows <= n/2; rows++)
|
||||||
|
if (rows*rows >= n)
|
||||||
|
break;
|
||||||
|
cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows;
|
||||||
|
|
||||||
|
/* window geoms (cell height/width) */
|
||||||
|
ch = (m->wh - 2*oh - ih * (rows - 1)) / (rows ? rows : 1);
|
||||||
|
cw = (m->ww - 2*ov - iv * (cols - 1)) / (cols ? cols : 1);
|
||||||
|
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
||||||
|
cx = m->wx + (i / rows) * (cw + iv) + ov;
|
||||||
|
cy = m->wy + (i % rows) * (ch + ih) + oh;
|
||||||
|
resize(c, cx, cy, cw - 2*c->bw, ch - 2*c->bw, False);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static void
|
||||||
|
grid(Monitor *m)
|
||||||
|
{
|
||||||
|
unsigned int i, n, cx, cy, cw, ch, cols, rows;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
|
|
||||||
|
/* grid dimensions */
|
||||||
|
for (rows = 0; rows <= n/2; rows++)
|
||||||
|
if (rows*rows >= n)
|
||||||
|
break;
|
||||||
|
cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows;
|
||||||
|
|
||||||
|
/* window geoms (cell height/width) */
|
||||||
|
ch = m->wh / (rows ? rows : 1);
|
||||||
|
cw = m->ww / (cols ? cols : 1);
|
||||||
|
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
||||||
|
cx = m->wx + (i / rows) * cw;
|
||||||
|
cy = m->wy + (i % rows) * ch;
|
||||||
|
resize(c, cx, cy, cw - 2*c->bw, ch - 2*c->bw, False);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
1
patch/grid.h
Normal file
1
patch/grid.h
Normal file
@ -0,0 +1 @@
|
|||||||
|
static void grid(Monitor *m);
|
82
patch/horizgrid.c
Normal file
82
patch/horizgrid.c
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
#if VANITYGAPS_PATCH
|
||||||
|
void
|
||||||
|
horizgrid(Monitor *m) {
|
||||||
|
Client *c;
|
||||||
|
unsigned int n, i;
|
||||||
|
int w = 0, oh, ov, ih, iv;
|
||||||
|
int ntop, nbottom = 0;
|
||||||
|
|
||||||
|
/* Count windows */
|
||||||
|
getgaps(m, &oh, &ov, &ih, &iv, &n);
|
||||||
|
|
||||||
|
if (n == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (n == 1) { /* Just fill the whole screen */
|
||||||
|
c = nexttiled(m->clients);
|
||||||
|
resize(c, m->wx + ov, m->wy + oh, m->ww - 2*ov - (2*c->bw), m->wh - 2*oh - (2*c->bw), False);
|
||||||
|
} else if (n == 2) { /* Split vertically */
|
||||||
|
w = (m->ww - 2*ov - iv) / 2;
|
||||||
|
c = nexttiled(m->clients);
|
||||||
|
resize(c, m->wx + ov, m->wy + oh, w - (2*c->bw), m->wh - 2*oh - (2*c->bw), False);
|
||||||
|
c = nexttiled(c->next);
|
||||||
|
resize(c, m->wx + ov + w + iv, m->wy + oh, w - (2*c->bw), m->wh - 2*oh - (2*c->bw), False);
|
||||||
|
} else {
|
||||||
|
ntop = n / 2;
|
||||||
|
nbottom = n - ntop;
|
||||||
|
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
||||||
|
if (i < ntop)
|
||||||
|
resize(
|
||||||
|
c,
|
||||||
|
m->wx + ov + i * ((m->ww - 2*ov - iv*(ntop - 1)) / ntop + iv),
|
||||||
|
m->wy + oh,
|
||||||
|
(m->ww - 2*ov - iv*(ntop - 1)) / ntop - (2*c->bw),
|
||||||
|
(m->wh - 2*oh - ih) / 2 - (2*c->bw),
|
||||||
|
False
|
||||||
|
);
|
||||||
|
else
|
||||||
|
resize(
|
||||||
|
c,
|
||||||
|
m->wx + ov + (i - ntop) * ((m->ww - 2*ov - iv*(nbottom - 1)) / nbottom + iv),
|
||||||
|
m->wy + oh + ih + (m->wh - 2*oh - ih) / 2,
|
||||||
|
(m->ww - 2*ov - iv*(nbottom - 1)) / nbottom - (2*c->bw),
|
||||||
|
(m->wh - 2*oh - ih) / 2 - (2*c->bw),
|
||||||
|
False
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void
|
||||||
|
horizgrid(Monitor *m) {
|
||||||
|
Client *c;
|
||||||
|
unsigned int n, i;
|
||||||
|
int w = 0;
|
||||||
|
int ntop, nbottom = 0;
|
||||||
|
|
||||||
|
/* Count windows */
|
||||||
|
for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
|
|
||||||
|
if(n == 0)
|
||||||
|
return;
|
||||||
|
else if(n == 1) { /* Just fill the whole screen */
|
||||||
|
c = nexttiled(m->clients);
|
||||||
|
resize(c, m->wx, m->wy, m->ww - (2*c->bw), m->wh - (2*c->bw), False);
|
||||||
|
} else if(n == 2) { /* Split vertically */
|
||||||
|
w = m->ww / 2;
|
||||||
|
c = nexttiled(m->clients);
|
||||||
|
resize(c, m->wx, m->wy, w - (2*c->bw), m->wh - (2*c->bw), False);
|
||||||
|
c = nexttiled(c->next);
|
||||||
|
resize(c, m->wx + w, m->wy, w - (2*c->bw), m->wh - (2*c->bw), False);
|
||||||
|
} else {
|
||||||
|
ntop = n / 2;
|
||||||
|
nbottom = n - ntop;
|
||||||
|
for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
||||||
|
if(i < ntop)
|
||||||
|
resize(c, m->wx + i * m->ww / ntop, m->wy, m->ww / ntop - (2*c->bw), m->wh / 2 - (2*c->bw), False);
|
||||||
|
else
|
||||||
|
resize(c, m->wx + (i - ntop) * m->ww / nbottom, m->wy + m->wh / 2, m->ww / nbottom - (2*c->bw), m->wh / 2 - (2*c->bw), False);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
1
patch/horizgrid.h
Normal file
1
patch/horizgrid.h
Normal file
@ -0,0 +1 @@
|
|||||||
|
static void horizgrid(Monitor *m);
|
@ -74,6 +74,14 @@
|
|||||||
#include "gapplessgrid.c"
|
#include "gapplessgrid.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if GRIDMODE_LAYOUT
|
||||||
|
#include "grid.c"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HORIZGRID_LAYOUT
|
||||||
|
#include "horizgrid.c"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if MONOCLE_LAYOUT
|
#if MONOCLE_LAYOUT
|
||||||
#include "monocle.c"
|
#include "monocle.c"
|
||||||
#endif
|
#endif
|
||||||
|
@ -70,6 +70,14 @@
|
|||||||
#include "gapplessgrid.h"
|
#include "gapplessgrid.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if GRIDMODE_LAYOUT
|
||||||
|
#include "grid.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HORIZGRID_LAYOUT
|
||||||
|
#include "horizgrid.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if MONOCLE_LAYOUT
|
#if MONOCLE_LAYOUT
|
||||||
#include "monocle.h"
|
#include "monocle.h"
|
||||||
#endif
|
#endif
|
||||||
|
22
patches.h
22
patches.h
@ -190,32 +190,42 @@
|
|||||||
/* Bottomstack layout.
|
/* Bottomstack layout.
|
||||||
* https://dwm.suckless.org/patches/bottomstack/
|
* https://dwm.suckless.org/patches/bottomstack/
|
||||||
*/
|
*/
|
||||||
#define BSTACK_LAYOUT 1
|
#define BSTACK_LAYOUT 0
|
||||||
|
|
||||||
/* Bottomstack horizontal layout.
|
/* Bottomstack horizontal layout.
|
||||||
* https://dwm.suckless.org/patches/bottomstack/
|
* https://dwm.suckless.org/patches/bottomstack/
|
||||||
*/
|
*/
|
||||||
#define BSTACKHORIZ_LAYOUT 1
|
#define BSTACKHORIZ_LAYOUT 0
|
||||||
|
|
||||||
/* Deck layout.
|
/* Deck layout.
|
||||||
* https://dwm.suckless.org/patches/deck/
|
* https://dwm.suckless.org/patches/deck/
|
||||||
*/
|
*/
|
||||||
#define DECK_LAYOUT 1
|
#define DECK_LAYOUT 0
|
||||||
|
|
||||||
/* Fibonacci dwindle layout.
|
/* Fibonacci dwindle layout.
|
||||||
* https://dwm.suckless.org/patches/fibonacci/
|
* https://dwm.suckless.org/patches/fibonacci/
|
||||||
*/
|
*/
|
||||||
#define FIBONACCI_DWINDLE_LAYOUT 1
|
#define FIBONACCI_DWINDLE_LAYOUT 0
|
||||||
|
|
||||||
/* Fibonacci spiral layout.
|
/* Fibonacci spiral layout.
|
||||||
* https://dwm.suckless.org/patches/fibonacci/
|
* https://dwm.suckless.org/patches/fibonacci/
|
||||||
*/
|
*/
|
||||||
#define FIBONACCI_SPIRAL_LAYOUT 1
|
#define FIBONACCI_SPIRAL_LAYOUT 0
|
||||||
|
|
||||||
/* Gappless grid layout.
|
/* Gappless grid layout.
|
||||||
* https://dwm.suckless.org/patches/gaplessgrid/
|
* https://dwm.suckless.org/patches/gaplessgrid/
|
||||||
*/
|
*/
|
||||||
#define GAPPLESSGRID_LAYOUT 1
|
#define GAPPLESSGRID_LAYOUT 0
|
||||||
|
|
||||||
|
/* Gridmode (grid) layout.
|
||||||
|
* https://dwm.suckless.org/patches/gridmode/
|
||||||
|
*/
|
||||||
|
#define GRIDMODE_LAYOUT 0
|
||||||
|
|
||||||
|
/* Horizontal grid (horizgrid) layout.
|
||||||
|
* https://dwm.suckless.org/patches/horizgrid/
|
||||||
|
*/
|
||||||
|
#define HORIZGRID_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