[wiki] [sites] Update deck, gridmode and swallow patches. || Joshua Haase

From: <git_AT_suckless.org>
Date: Sun, 10 Sep 2017 00:44:37 +0200

commit aba3885977a22fffe52ac5e8081329815cddc4c7
Author: Joshua Haase <hahj87_AT_gmail.com>
Date: Sat Sep 9 17:42:38 2017 -0500

    Update deck, gridmode and swallow patches.

diff --git a/dwm.suckless.org/patches/deck.md b/dwm.suckless.org/patches/deck.md
index af005718..216be851 100644
--- a/dwm.suckless.org/patches/deck.md
+++ b/dwm.suckless.org/patches/deck.md
_AT_@ -32,6 +32,8 @@ Description
 Download
 --------
 * [dwm-6.0-deck.diff](dwm-6.0-deck.diff)
+* [dwm-deck-20170909-ceac8c9.diff](dwm-deck-20170909-ceac8c9.diff)
+
 
 Author
 ------
diff --git a/dwm.suckless.org/patches/dwm-deck-20170909-ceac8c9.diff b/dwm.suckless.org/patches/dwm-deck-20170909-ceac8c9.diff
new file mode 100644
index 00000000..5c3a5f9a
--- /dev/null
+++ b/dwm.suckless.org/patches/dwm-deck-20170909-ceac8c9.diff
_AT_@ -0,0 +1,75 @@
+From c1b5c188abe327751f9abce367acc1e7be727514 Mon Sep 17 00:00:00 2001
+From: Joshua Haase <hahj87_AT_gmail.com>
+Date: Tue, 16 Aug 2016 10:00:05 -0500
+Subject: [PATCH] Apply a modified deck patch.
+
+---
+ config.def.h | 3 +++
+ layouts.c | 29 +++++++++++++++++++++++++++++
+ 2 files changed, 32 insertions(+)
+ create mode 100644 layouts.c
+
+diff --git a/config.def.h b/config.def.h
+index a9ac303..37ec7f3 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -36,11 +36,13 @@ 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 resizehints = 1; /* 1 means respect size hints in tiled resizals */
+
++#include "layouts.c"
+ static const Layout layouts[] = {
+ /* symbol arrange function */
+ { "[]=", tile }, /* first entry is default */
+ { "><>", NULL }, /* no layout function means floating behavior */
+ { "[M]", monocle },
++ { "H[]", deck },
+ };
+
+ /* key definitions */
+_AT_@ -76,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_c, setlayout, {.v = &layouts[3]} },
+ { MODKEY, XK_space, setlayout, {0} },
+ { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
+ { MODKEY, XK_0, view, {.ui = ~0 } },
+diff --git a/layouts.c b/layouts.c
+new file mode 100644
+index 0000000..e2c17f2
+--- /dev/null
++++ b/layouts.c
+_AT_@ -0,0 +1,29 @@
++static void deck(Monitor *m);
++
++void
++deck(Monitor *m) {
++ int dn;
++ unsigned int i, n, h, mw, my;
++ Client *c;
++
++ for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
++ if(n == 0)
++ return;
++
++ dn = n - m->nmaster;
++ if(dn > 0) /* override layout symbol */
++ snprintf(m->ltsymbol, sizeof m->ltsymbol, "D %d", dn);
++
++ if(n > m->nmaster)
++ mw = m->nmaster ? m->ww * m->mfact : 0;
++ else
++ mw = m->ww;
++ for(i = my = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
++ if(i < m->nmaster) {
++ h = (m->wh - my) / (MIN(n, m->nmaster) - i);
++ resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), False);
++ my += HEIGHT(c);
++ }
++ else
++ resize(c, m->wx + mw, m->wy, m->ww - mw - (2*c->bw), m->wh - (2*c->bw), False);
++}
+--
+2.14.1
+
diff --git a/dwm.suckless.org/patches/dwm-gridmode-20170909-ceac8c9.diff b/dwm.suckless.org/patches/dwm-gridmode-20170909-ceac8c9.diff
new file mode 100644
index 00000000..feec67b0
--- /dev/null
+++ b/dwm.suckless.org/patches/dwm-gridmode-20170909-ceac8c9.diff
_AT_@ -0,0 +1,73 @@
+From b04bb473cf9818277d33a591f7fe2dfae96afaaf Mon Sep 17 00:00:00 2001
+From: Joshua Haase <hahj87_AT_gmail.com>
+Date: Mon, 15 Aug 2016 17:06:18 -0500
+Subject: [PATCH] Apply modified gridmode patch.
+
+---
+ config.def.h | 3 +++
+ layouts.c | 27 +++++++++++++++++++++++++++
+ 2 files changed, 30 insertions(+)
+ create mode 100644 layouts.c
+
+diff --git a/config.def.h b/config.def.h
+index a9ac303..30b7c4a 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -36,11 +36,13 @@ 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 resizehints = 1; /* 1 means respect size hints in tiled resizals */
+
++#include "layouts.c"
+ static const Layout layouts[] = {
+ /* symbol arrange function */
+ { "[]=", tile }, /* first entry is default */
+ { "><>", NULL }, /* no layout function means floating behavior */
+ { "[M]", monocle },
++ { "HHH", grid },
+ };
+
+ /* key definitions */
+_AT_@ -76,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 } },
+diff --git a/layouts.c b/layouts.c
+new file mode 100644
+index 0000000..d26acf3
+--- /dev/null
++++ b/layouts.c
+_AT_@ -0,0 +1,27 @@
++void
++grid(Monitor *m) {
++ unsigned int i, n, cx, cy, cw, ch, aw, ah, 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)) {
++ 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);
++ i++;
++ }
++}
+--
+2.14.1
+
diff --git a/dwm.suckless.org/patches/dwm-swallow-20170909-ceac8c9.diff b/dwm.suckless.org/patches/dwm-swallow-20170909-ceac8c9.diff
new file mode 100644
index 00000000..65aa2b2b
--- /dev/null
+++ b/dwm.suckless.org/patches/dwm-swallow-20170909-ceac8c9.diff
_AT_@ -0,0 +1,350 @@
+From 16cfa88ca5ee5f93f62953cc5ed2355417d51420 Mon Sep 17 00:00:00 2001
+From: Joshua Haase <hahj87_AT_gmail.com>
+Date: Sat, 9 Sep 2017 17:07:40 -0500
+Subject: [PATCH] Apply swallow patch.
+
+---
+ config.def.h | 7 ++-
+ config.mk | 2 +-
+ dwm.c | 189 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
+ 3 files changed, 189 insertions(+), 9 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index a9ac303..2d26a23 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -26,9 +26,10 @@ static const Rule rules[] = {
+ * WM_CLASS(STRING) = instance, class
+ * WM_NAME(STRING) = title
+ */
+- /* class instance title tags mask isfloating monitor */
+- { "Gimp", NULL, NULL, 0, 1, -1 },
+- { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
++ /* class instance title tags mask isfloating isterminal noswallow monitor */
++ { "Gimp", NULL, NULL, 0, 1, 0, 0, -1 },
++ { "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, -1 },
++ { "st", NULL, NULL, 0, 0, 1, 1, -1 },
+ };
+
+ /* layout(s) */
+diff --git a/config.mk b/config.mk
+index 80dc936..5ed14e3 100644
+--- a/config.mk
++++ b/config.mk
+_AT_@ -22,7 +22,7 @@ FREETYPEINC = /usr/include/freetype2
+
+ # includes and libs
+ INCS = -I${X11INC} -I${FREETYPEINC}
+-LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
++LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res
+
+ # flags
+ CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
+diff --git a/dwm.c b/dwm.c
+index a5ce993..20b635b 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -40,6 +40,8 @@
+ #include <X11/extensions/Xinerama.h>
+ #endif /* XINERAMA */
+ #include <X11/Xft/Xft.h>
++#include <X11/Xlib-xcb.h>
++#include <xcb/res.h>
+
+ #include "drw.h"
+ #include "util.h"
+_AT_@ -93,9 +95,11 @@ struct Client {
+ int basew, baseh, incw, inch, maxw, maxh, minw, minh;
+ int bw, oldbw;
+ unsigned int tags;
+- int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
++ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow;
++ pid_t pid;
+ Client *next;
+ Client *snext;
++ Client *swallowing;
+ Monitor *mon;
+ Window win;
+ };
+_AT_@ -139,6 +143,8 @@ typedef struct {
+ const char *title;
+ unsigned int tags;
+ int isfloating;
++ int isterminal;
++ int noswallow;
+ int monitor;
+ } Rule;
+
+_AT_@ -235,6 +241,13 @@ static int xerrordummy(Display *dpy, XErrorEvent *ee);
+ static int xerrorstart(Display *dpy, XErrorEvent *ee);
+ static void zoom(const Arg *arg);
+
++static pid_t getparentprocess(pid_t p);
++static int isdescprocess(pid_t p, pid_t c);
++static Client *swallowingclient(Window w);
++static Client *termforwin(const Client *c);
++static pid_t winpid(Window w);
++
++
+ /* variables */
+ static const char broken[] = "broken";
+ static char stext[256];
+_AT_@ -269,6 +282,8 @@ static Drw *drw;
+ static Monitor *mons, *selmon;
+ static Window root, wmcheckwin;
+
++static xcb_connection_t *xcon;
++
+ /* configuration, allows nested code to access above variables */
+ #include "config.h"
+
+_AT_@ -298,6 +313,7 @@ applyrules(Client *c)
+ && (!r->class || strstr(class, r->class))
+ && (!r->instance || strstr(instance, r->instance)))
+ {
++ c->isterminal = r->isterminal;
+ c->isfloating = r->isfloating;
+ c->tags |= r->tags;
+ for (m = mons; m && m->num != r->monitor; m = m->next);
+_AT_@ -414,6 +430,46 @@ attachstack(Client *c)
+ c->mon->stack = c;
+ }
+
++void
++swallow(Client *p, Client *c)
++{
++ if (c->noswallow || c->isterminal)
++ return;
++
++ detach(c);
++ detachstack(c);
++
++ setclientstate(c, WithdrawnState);
++ XUnmapWindow(dpy, p->win);
++
++ p->swallowing = c;
++ c->mon = p->mon;
++
++ Window w = p->win;
++ p->win = c->win;
++ c->win = w;
++ updatetitle(p);
++ arrange(p->mon);
++ configure(p);
++ updateclientlist();
++}
++
++void
++unswallow(Client *c)
++{
++ c->win = c->swallowing->win;
++
++ free(c->swallowing);
++ c->swallowing = NULL;
++
++ updatetitle(c);
++ arrange(c->mon);
++ XMapWindow(dpy, c->win);
++ XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
++ configure(c);
++ setclientstate(c, NormalState);
++}
++
+ void
+ buttonpress(XEvent *e)
+ {
+_AT_@ -653,6 +709,9 @@ destroynotify(XEvent *e)
+
+ if ((c = wintoclient(ev->window)))
+ unmanage(c, 1);
++
++ else if ((c = swallowingclient(ev->window)))
++ unmanage(c->swallowing, 1);
+ }
+
+ void
+_AT_@ -1019,12 +1078,13 @@ killclient(const Arg *arg)
+ void
+ manage(Window w, XWindowAttributes *wa)
+ {
+- Client *c, *t = NULL;
++ Client *c, *t = NULL, *term = NULL;
+ Window trans = None;
+ XWindowChanges wc;
+
+ c = ecalloc(1, sizeof(Client));
+ c->win = w;
++ c->pid = winpid(w);
+ /* geometry */
+ c->x = c->oldx = wa->x;
+ c->y = c->oldy = wa->y;
+_AT_@ -1039,6 +1099,7 @@ manage(Window w, XWindowAttributes *wa)
+ } else {
+ c->mon = selmon;
+ applyrules(c);
++ term = termforwin(c);
+ }
+
+ if (c->x + WIDTH(c) > c->mon->mx + c->mon->mw)
+_AT_@ -1075,6 +1136,8 @@ manage(Window w, XWindowAttributes *wa)
+ c->mon->sel = c;
+ arrange(c->mon);
+ XMapWindow(dpy, c->win);
++ if (term)
++ swallow(term, c);
+ focus(NULL);
+ }
+
+_AT_@ -1767,6 +1830,20 @@ unmanage(Client *c, int destroyed)
+ Monitor *m = c->mon;
+ XWindowChanges wc;
+
++ if (c->swallowing) {
++ unswallow(c);
++ return;
++ }
++
++ Client *s = swallowingclient(c->win);
++ if (s) {
++ free(s->swallowing);
++ s->swallowing = NULL;
++ arrange(m);
++ focus(NULL);
++ return;
++ }
++
+ detach(c);
+ detachstack(c);
+ if (!destroyed) {
+_AT_@ -1781,9 +1858,12 @@ unmanage(Client *c, int destroyed)
+ XUngrabServer(dpy);
+ }
+ free(c);
+- focus(NULL);
+- updateclientlist();
+- arrange(m);
++
++ if (!s) {
++ arrange(m);
++ focus(NULL);
++ updateclientlist();
++ }
+ }
+
+ void
+_AT_@ -2045,6 +2125,103 @@ view(const Arg *arg)
+ arrange(selmon);
+ }
+
++pid_t
++winpid(Window w)
++{
++ pid_t result = 0;
++
++ xcb_res_client_id_spec_t spec = {0};
++ spec.client = w;
++ spec.mask = XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID;
++
++ xcb_generic_error_t *e = NULL;
++ xcb_res_query_client_ids_cookie_t c = xcb_res_query_client_ids(xcon, 1, &spec);
++ xcb_res_query_client_ids_reply_t *r = xcb_res_query_client_ids_reply(xcon, c, &e);
++
++ if (!r)
++ return (pid_t)0;
++
++ xcb_res_client_id_value_iterator_t i = xcb_res_query_client_ids_ids_iterator(r);
++ for (; i.rem; xcb_res_client_id_value_next(&i)) {
++ spec = i.data->spec;
++ if (spec.mask & XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID) {
++ uint32_t *t = xcb_res_client_id_value_value(i.data);
++ result = *t;
++ break;
++ }
++ }
++
++ free(r);
++
++ if (result == (pid_t)-1)
++ result = 0;
++ return result;
++}
++
++pid_t
++getparentprocess(pid_t p)
++{
++ unsigned int v = 0;
++
++#ifdef __linux__
++ FILE *f;
++ char buf[256];
++ snprintf(buf, sizeof(buf) - 1, "/proc/%u/stat", (unsigned)p);
++
++ if (!(f = fopen(buf, "r")))
++ return 0;
++
++ fscanf(f, "%*u %*s %*c %u", &v);
++ fclose(f);
++#endif /* __linux__ */
++
++ return (pid_t)v;
++}
++
++int
++isdescprocess(pid_t p, pid_t c)
++{
++ while (p != c && c != 0)
++ c = getparentprocess(c);
++
++ return (int)c;
++}
++
++Client *
++termforwin(const Client *w)
++{
++ Client *c;
++ Monitor *m;
++
++ if (!w->pid || w->isterminal)
++ return NULL;
++
++ for (m = mons; m; m = m->next) {
++ for (c = m->clients; c; c = c->next) {
++ if (c->isterminal && !c->swallowing && c->pid && isdescprocess(c->pid, w->pid))
++ return c;
++ }
++ }
++
++ return NULL;
++}
++
++Client *
++swallowingclient(Window w)
++{
++ Client *c;
++ Monitor *m;
++
++ for (m = mons; m; m = m->next) {
++ for (c = m->clients; c; c = c->next) {
++ if (c->swallowing && c->swallowing->win == w)
++ return c;
++ }
++ }
++
++ return NULL;
++}
++
+ Client *
+ wintoclient(Window w)
+ {
+_AT_@ -2136,6 +2313,8 @@ main(int argc, char *argv[])
+ fputs("warning: no locale support
", stderr);
+ if (!(dpy = XOpenDisplay(NULL)))
+ die("dwm: cannot open display");
++ if (!(xcon = XGetXCBConnection(dpy)))
++ die("dwm: cannot get xcb connection
");
+ checkotherwm();
+ setup();
+ scan();
+--
+2.14.1
+
diff --git a/dwm.suckless.org/patches/gridmode.md b/dwm.suckless.org/patches/gridmode.md
index 71210b64..6acdf834 100644
--- a/dwm.suckless.org/patches/gridmode.md
+++ b/dwm.suckless.org/patches/gridmode.md
_AT_@ -9,6 +9,7 @@ tools that operate on multiple windows at once; e.g. Cluster SSH.
 
 Download
 --------
+* [dwm-gridmode-20170909-ceac8c9.diff](dwm-grid-20170909-ceac8c9.diff)
 * [dwm-gridmode-5.8.2.diff](dwm-gridmode-5.8.2.diff)
 * See older versions in [historical](historical/gridmode).
 
diff --git a/dwm.suckless.org/patches/swallow.md b/dwm.suckless.org/patches/swallow.md
index 62e1ba36..7cb4c67e 100644
--- a/dwm.suckless.org/patches/swallow.md
+++ b/dwm.suckless.org/patches/swallow.md
_AT_@ -30,6 +30,7 @@ Resource Extension which is unsupported in vanilla Xlib.
 Download
 --------
 
+ * [dwm-swallow-20170909-ceac8c9.diff](dwm-swallow-20170909-ceac8c9.diff)
  * [dwm-swallow-6.1.diff](dwm-swallow-6.1.diff)
  * [dwm-swallow-20160717-56a31dc.diff](dwm-swallow-20160717-56a31dc.diff)
 
Received on Sun Sep 10 2017 - 00:44:37 CEST

This archive was generated by hypermail 2.3.0 : Sun Sep 10 2017 - 00:48:19 CEST