[wiki] [sites] dwm: patch - Added gaplessgridleftright patch || Shlomo Aknin

From: <git_AT_suckless.org>
Date: Sun, 19 Dec 2021 16:36:46 +0100

commit 69edf52375ad37543a137800962fc068ccf2e250
Author: Shlomo Aknin <shlomi.aknin_AT_gmail.com>
Date: Sun Dec 19 17:36:10 2021 +0200

    dwm: patch - Added gaplessgridleftright patch

diff --git a/dwm.suckless.org/patches/gaplessgridleftright/dwm-gaplessgridleftright-20211216-76d72e24.diff b/dwm.suckless.org/patches/gaplessgridleftright/dwm-gaplessgridleftright-20211216-76d72e24.diff
new file mode 100644
index 00000000..aa373519
--- /dev/null
+++ b/dwm.suckless.org/patches/gaplessgridleftright/dwm-gaplessgridleftright-20211216-76d72e24.diff
_AT_@ -0,0 +1,154 @@
+From 76d72e24117a5626827cfb0ef49515ec7f7dd4fe Mon Sep 17 00:00:00 2001
+From: shlomi-aknin <shlomi.aknin_AT_gmail.com>
+Date: Thu, 16 Dec 2021 14:53:02 +0200
+Subject: [PATCH] This patch incorporates gaplessgrid patch. This patch adds
+ the ability to focus on left or right window of the current window (works in
+ gaplessgrid layout only)
+
+---
+ config.def.h | 5 +++-
+ dwm.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++-
+ 2 files changed, 77 insertions(+), 2 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index a2ac963..c63a640 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -42,6 +42,7 @@ static const Layout layouts[] = {
+ { "[]=", tile }, /* first entry is default */
+ { "><>", NULL }, /* no layout function means floating behavior */
+ { "[M]", monocle },
++ { "###", gaplessgrid },
+ };
+
+ /* key definitions */
+_AT_@ -77,6 +78,7 @@ static Key keys[] = {
+ { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
+ { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
+ { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
++ { MODKEY, XK_g, setlayout, {.v = &layouts[3]} },
+ { MODKEY, XK_space, setlayout, {0} },
+ { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
+ { MODKEY, XK_0, view, {.ui = ~0 } },
+_AT_@ -85,6 +87,8 @@ static Key keys[] = {
+ { MODKEY, XK_period, focusmon, {.i = +1 } },
+ { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
+ { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
++ { MODKEY|ControlMask, XK_l, gaplessgridleftright, {.i = +1 } },
++ { MODKEY|ControlMask, XK_h, gaplessgridleftright, {.i = -1 } },
+ TAGKEYS( XK_1, 0)
+ TAGKEYS( XK_2, 1)
+ TAGKEYS( XK_3, 2)
+_AT_@ -113,4 +117,3 @@ static Button buttons[] = {
+ { ClkTagBar, MODKEY, Button1, tag, {0} },
+ { ClkTagBar, MODKEY, Button3, toggletag, {0} },
+ };
+-
+diff --git a/dwm.c b/dwm.c
+index 5e4d494..a7fb265 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -91,6 +91,7 @@ struct Client {
+ int oldx, oldy, oldw, oldh;
+ int basew, baseh, incw, inch, maxw, maxh, minw, minh;
+ int bw, oldbw;
++ int gridrow, gridcol;
+ unsigned int tags;
+ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
+ Client *next;
+_AT_@ -169,6 +170,8 @@ static void focus(Client *c);
+ static void focusin(XEvent *e);
+ static void focusmon(const Arg *arg);
+ static void focusstack(const Arg *arg);
++static void gaplessgrid(Monitor *m);
++static void gaplessgridleftright(const Arg *arg);
+ static Atom getatomprop(Client *c, Atom prop);
+ static int getrootptr(int *x, int *y);
+ static long getstate(Window w);
+_AT_@ -856,6 +859,76 @@ focusstack(const Arg *arg)
+ }
+ }
+
++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;
++ c->gridrow = rn;
++ c->gridcol = cn;
++ resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, False);
++ rn++;
++ if(rn >= rows) {
++ rn = 0;
++ cn++;
++ }
++ }
++}
++
++void
++gaplessgridleftright(const Arg *arg)
++{
++ Client *c = selmon->sel;
++ Client *t = NULL;
++ int found = 0;
++ if(selmon->lt[selmon->sellt]->arrange != gaplessgrid || !ISVISIBLE(c)) return;
++
++ if (arg->i > 0) {
++ for(t = selmon->sel->next; t; t = t->next) {
++ if (t->gridcol == c->gridcol + 1 && t->gridrow == c->gridrow) break;
++ }
++ } else {
++ for(t = selmon->clients; t; t = t->next) {
++ if (t->gridcol == c->gridcol - 1 && t->gridrow == c->gridrow) {
++ found = 1;
++ break;
++ }
++ }
++
++ if (found == 0) {
++ for(t = selmon->clients; t; t = t->next) {
++ if (t->gridcol == c->gridcol - 1 && t->gridrow == c->gridrow - 1) break;
++ }
++ }
++ }
++
++ focus(t);
++ arrange(selmon);
++}
++
+ Atom
+ getatomprop(Client *c, Atom prop)
+ {
+_AT_@ -1597,7 +1670,6 @@ setup(void)
+ focus(NULL);
+ }
+
+-
+ void
+ seturgent(Client *c, int urg)
+ {
+--
+2.34.1
diff --git a/dwm.suckless.org/patches/gaplessgridleftright/index.md b/dwm.suckless.org/patches/gaplessgridleftright/index.md
new file mode 100644
index 00000000..a4797641
--- /dev/null
+++ b/dwm.suckless.org/patches/gaplessgridleftright/index.md
_AT_@ -0,0 +1,18 @@
+togglefloatingcenter
+====================
+
+Description
+-----------
+Default behaviour when togglefloating() is floating from top-left corner.
+This patch will allows you to toggle floating window client will be centered
+position.
+
+The original code is from [alwayscenter](../alwayscenter/) patch.
+
+Download
+--------
+* [dwm-togglefloatingcenter-20210806-138b405f.diff](dwm-togglefloatingcenter-20210806-138b405f.diff)
+
+Author
+------
+* Rizqi Nur Assyaufi - <bandithijo_AT_gmail.com>
diff --git a/dwm.suckless.org/patches/togglefloatingcenter/index.md b/dwm.suckless.org/patches/togglefloatingcenter/index.md
index a4797641..1e7c129b 100644
--- a/dwm.suckless.org/patches/togglefloatingcenter/index.md
+++ b/dwm.suckless.org/patches/togglefloatingcenter/index.md
_AT_@ -1,18 +1,14 @@
-togglefloatingcenter
+gaplessgridleftright
 ====================
 
 Description
 -----------
-Default behaviour when togglefloating() is floating from top-left corner.
-This patch will allows you to toggle floating window client will be centered
-position.
-
-The original code is from [alwayscenter](../alwayscenter/) patch.
+This patch incorporates [gaplessgrid](../gaplessgrid/) patch. This patch adds the ability to focus on left or right window of the current window (works in gaplessgrid layout only)
 
 Download
 --------
-* [dwm-togglefloatingcenter-20210806-138b405f.diff](dwm-togglefloatingcenter-20210806-138b405f.diff)
+* [dwm-gaplessgridleftright-20211216-76d72e24.diff](dwm-gaplessgridleftright-20211216-76d72e24.diff)
 
 Author
 ------
-* Rizqi Nur Assyaufi - <bandithijo_AT_gmail.com>
+* Shlomo Aknin - <shlomi.aknin_AT_gmail.com>
Received on Sun Dec 19 2021 - 16:36:46 CET

This archive was generated by hypermail 2.3.0 : Sun Dec 19 2021 - 16:48:43 CET