Merged laptop version with remote

Laptop had gapless grid
This commit is contained in:
2024-04-18 11:09:36 +01:00
parent dde3212820
commit 92a9e09643
3 changed files with 86 additions and 6 deletions

View File

@@ -54,7 +54,6 @@ static const Rule rules[] = {
{ "qutebrowser", NULL, NULL, GTMask(2), 0, -1 },
{ "firefox", NULL, NULL, GTMask(2), 0, -1 },
{ "Chromium", NULL, NULL, GTMask(2), 0, -1 },
{ "mpv", NULL, NULL, GTMask(3), 0, -1 },
{ "media-term", NULL, NULL, GTMask(3), 0, -1 },
{ "Spotify", NULL, NULL, GTMask(3), 0, -1 },
{ "Zathura", NULL, NULL, GTMask(4), 0, -1 },
@@ -67,6 +66,7 @@ static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
#include "./fibonacci.c"
#include "./gaplessgrid.c"
static const Layout layouts[] = {
/* symbol arrange function */
@@ -77,6 +77,7 @@ static const Layout layouts[] = {
{ ">M>", centeredfloatingmaster },
{ "[@]", spiral },
{ "[\\]", dwindle },
{ "###", gaplessgrid },
{ "[D]", deck },
};
@@ -119,11 +120,12 @@ static Key keys[] = {
{ MODKEY|ShiftMask, XK_t, setlayout, {.v = &layouts[0]} }, //tiling
{ MODKEY|ShiftMask, XK_f, setlayout, {.v = &layouts[1]} }, //floating
{ MODKEY|ShiftMask, XK_m, setlayout, {.v = &layouts[2]} }, //monocle
{ MODKEY|ShiftMask, XK_n, setlayout, {.v = &layouts[3]} }, //cmonocle
{ MODKEY|ShiftMask, XK_b, setlayout, {.v = &layouts[4]} }, //cfmonocle
{ MODKEY|ShiftMask, XK_y, setlayout, {.v = &layouts[5]} }, //fib-spiral
{ MODKEY|ShiftMask, XK_u, setlayout, {.v = &layouts[6]} }, //fib-spiral
{ MODKEY|ShiftMask, XK_i, setlayout, {.v = &layouts[7]} }, //deck
{ MODKEY|ShiftMask, XK_u, setlayout, {.v = &layouts[3]} }, //cmonocle
{ MODKEY|ShiftMask, XK_o, setlayout, {.v = &layouts[4]} }, //cfmonocle
{ MODKEY|ShiftMask, XK_s, setlayout, {.v = &layouts[5]} }, //fib-spiral
{ MODKEY|ShiftMask, XK_d, setlayout, {.v = &layouts[6]} }, //fib-spiral
{ MODKEY|ShiftMask, XK_g, setlayout, {.v = &layouts[7]} }, //gapless-grid
{ MODKEY|ShiftMask, XK_i, setlayout, {.v = &layouts[8]} }, //deck
{ MODKEY|ShiftMask, XK_space, setlayout, {0} },
{ MODKEY, XK_space, togglefloating, {0} },
{ MODKEY, XK_m, focusmon, {.i = -1 } },

View File

@@ -0,0 +1,43 @@
URL: http://dwm.suckless.org/patches/gapless_grid
Add gapless grid layout.
Index: dwm/gaplessgrid.c
===================================================================
--- /dev/null
+++ dwm/gaplessgrid.c
@@ -0,0 +1,35 @@
+void
+gaplessgrid(Monitor *m) {
+ unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch;
+ Client *c;
+
+ for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) ;
+ if(n == 0)
+ return;
+
+ /* grid dimensions */
+ for(cols = 0; cols <= n/2; cols++)
+ if(cols*cols >= n)
+ break;
+ if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
+ cols = 2;
+ rows = n/cols;
+
+ /* window geometries */
+ cw = cols ? m->ww / cols : m->ww;
+ cn = 0; /* current column number */
+ rn = 0; /* current row number */
+ for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
+ if(i/rows + 1 > cols - n%cols)
+ rows = n/cols + 1;
+ ch = rows ? m->wh / rows : m->wh;
+ cx = m->wx + cn*cw;
+ cy = m->wy + rn*ch;
+ resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, False);
+ rn++;
+ if(rn >= rows) {
+ rn = 0;
+ cn++;
+ }
+ }
+}

35
gaplessgrid.c Normal file
View File

@@ -0,0 +1,35 @@
void
gaplessgrid(Monitor *m) {
unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch;
Client *c;
for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) ;
if(n == 0)
return;
/* grid dimensions */
for(cols = 0; cols <= n/2; cols++)
if(cols*cols >= n)
break;
if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
cols = 2;
rows = n/cols;
/* window geometries */
cw = cols ? m->ww / cols : m->ww;
cn = 0; /* current column number */
rn = 0; /* current row number */
for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
if(i/rows + 1 > cols - n%cols)
rows = n/cols + 1;
ch = (rows ? m->wh / rows : m->wh) - m->gappx;
cx = (m->wx + cn*cw) + m->gappx;
cy = (m->wy + rn*ch) + m->gappx;
resize(c, cx + m->gappx, cy, cw - 2 * c->bw - m->gappx, ch - 2 * c->bw, False);
rn++;
if(rn >= rows) {
rn = 0;
cn++;
}
}
}