Add gaps to grid layout

This commit is contained in:
BitHeaven-Official 2023-03-08 11:56:27 +05:00
parent 5ffeb2af73
commit 513ae0cc68
4 changed files with 7 additions and 7 deletions

BIN
dwm

Binary file not shown.

4
dwm.c
View File

@ -133,10 +133,10 @@ struct Monitor {
int nmaster;
int num;
int by; /* bar geometry */
int eby; /* bar geometry */
int eby; /* bar geometry */
int mx, my, mw, mh; /* screen size */
int wx, wy, ww, wh; /* window area */
int gappx;
int gappx;
unsigned int seltags;
unsigned int sellt;
unsigned int tagset[2];

BIN
dwm.o

Binary file not shown.

View File

@ -13,15 +13,15 @@ grid(Monitor *m) {
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);
ch = (m->wh - m->gappx) / (rows ? rows : 1);
cw = (m->ww - m->gappx) / (cols ? cols : 1);
for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
cx = m->wx + (i / rows) * cw;
cy = m->wy + (i % rows) * ch;
/* adjust height/width of last row/column's windows */
ah = ((i + 1) % rows == 0) ? m->wh - ch * rows : 0;
aw = (i >= rows * (cols - 1)) ? m->ww - cw * cols : 0;
resize(c, cx, cy, cw - 2 * c->bw + aw, ch - 2 * c->bw + ah, False);
ah = ((i + 1) % rows == 0) ? m->wh - m->gappx * (rows + 1) - ch * rows : 0;
aw = (i >= rows * (cols - 1)) ? m->ww - m->gappx * (cols + 1) - cw * cols : 0;
resize(c, cx + m->gappx * (i / rows + 1), cy + m->gappx * (i % rows + 1), cw - 2 * c->bw + aw, ch - 2 * c->bw + ah, False);
i++;
}
}