diff options
Diffstat (limited to 'localports/dwl')
| -rw-r--r-- | localports/dwl/APKBUILD | 4 | ||||
| -rw-r--r-- | localports/dwl/config.h | 4 | ||||
| -rw-r--r-- | localports/dwl/swallow.patch | 197 |
3 files changed, 202 insertions, 3 deletions
diff --git a/localports/dwl/APKBUILD b/localports/dwl/APKBUILD index 9157488..764a540 100644 --- a/localports/dwl/APKBUILD +++ b/localports/dwl/APKBUILD @@ -11,6 +11,7 @@ options="!check" # no tests subpackages="$pkgname-doc" source="$pkgname-$pkgver.tar.gz::https://github.com/djpohly/dwl/archive/refs/tags/v$pkgver.tar.gz xwayland.patch + swallow.patch config.h " @@ -30,5 +31,6 @@ package() { sha512sums=" 6e15e05001e6469d13bef2d532980585d57de55c8feb461a7c25a76d7cdaee022785485faca02cd9d1214457fbeb1bec0eb652700ba0ddccca4aa780df0046b2 dwl-0.4.tar.gz 7c7952ede929faa137f690b3d1f44c1af4b40a3a6dac7bc3d5a377c8c454b35de1becdbbd1f3cbbde56c798f4f3bf78bc7eef4d7faa0e761d317179c072c629f xwayland.patch -37599d1a6488c18938c5dde425e26e19aab9586b9c64bd6a4fb1aa82f4539f09cc3e56ff50f560233fafe204cc3f7c531eeb65387c6c0c9d5781a5499704e2dd config.h +9429d836ac66670616f91004108c1b682f01e8d477318b82037e7b5d94fc01593b662fc5970911931046173eecacdc4d3a36d8f598ad76d286df862e4d23f4d6 swallow.patch +d49469a143ced21eeb80310e95d0d555539589f4b1847b854e6ee49b58f7879391b7cf248c8812ceb11fc4e2a4d83dcbd24d796174ecc126b54493b3f5db7058 config.h " diff --git a/localports/dwl/config.h b/localports/dwl/config.h index ceeaf16..17caed3 100644 --- a/localports/dwl/config.h +++ b/localports/dwl/config.h @@ -12,8 +12,8 @@ static const float fullscreen_bg[] = {0.141, 0.153, 0.227, 1.0}; static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; static const Rule rules[] = { - /* app_id title tags mask isfloating monitor */ - { "dummy", NULL, 0, 0, -1 }, + /* app_id title tags mask isfloating isterm noswallow monitor */ + { "foot", NULL, 0, 0, 1, 0, -1 }, }; /* layout(s) */ diff --git a/localports/dwl/swallow.patch b/localports/dwl/swallow.patch new file mode 100644 index 0000000..fa0d56f --- /dev/null +++ b/localports/dwl/swallow.patch @@ -0,0 +1,197 @@ +From bc61a2cc74f65ab5bba51ba65edc1efd1269d510 Mon Sep 17 00:00:00 2001 +From: Dmitry Zakharchenko <dmitz@disroot.org> +Date: Thu, 5 Jan 2023 14:57:48 +0200 +Subject: [PATCH] swallow: sync with 0.4 + +--- + config.def.h | 6 ++-- + dwl.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++-- + 2 files changed, 100 insertions(+), 6 deletions(-) + +diff --git a/config.def.h b/config.def.h +index a4f7c13d..9dcedacd 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -12,11 +12,11 @@ static const float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0}; + static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; + + static const Rule rules[] = { +- /* app_id title tags mask isfloating monitor */ ++ /* app_id title tags mask isfloating isterm noswallow monitor */ + /* examples: +- { "Gimp", NULL, 0, 1, -1 }, ++ { "Gimp", NULL, 0, 1, 0, 1, -1 }, + */ +- { "firefox", NULL, 1 << 8, 0, -1 }, ++ { "firefox", NULL, 1 << 8, 0, 0, 1, -1 }, + }; + + /* layout(s) */ +diff --git a/dwl.c b/dwl.c +index 19bb6ce3..262fa62c 100644 +--- a/dwl.c ++++ b/dwl.c +@@ -95,7 +95,8 @@ typedef struct { + } Button; + + typedef struct Monitor Monitor; +-typedef struct { ++typedef struct Client Client; ++struct Client { + /* Must keep these three elements in this order */ + unsigned int type; /* XDGShell or X11* */ + struct wlr_box geom; /* layout-relative, includes border */ +@@ -124,9 +125,11 @@ typedef struct { + #endif + unsigned int bw; + unsigned int tags; +- int isfloating, isurgent, isfullscreen; ++ int isfloating, isurgent, isfullscreen, isterm, noswallow; + uint32_t resize; /* configure serial of a pending resize */ +-} Client; ++ pid_t pid; ++ Client *swallowing, *swallowedby; ++}; + + typedef struct { + uint32_t mod; +@@ -201,6 +204,8 @@ typedef struct { + const char *title; + unsigned int tags; + int isfloating; ++ int isterm; ++ int noswallow; + int monitor; + } Rule; + +@@ -310,6 +315,10 @@ static Monitor *xytomon(double x, double y); + static struct wlr_scene_node *xytonode(double x, double y, struct wlr_surface **psurface, + Client **pc, LayerSurface **pl, double *nx, double *ny); + static void zoom(const Arg *arg); ++static pid_t getparentprocess(pid_t p); ++static int isdescprocess(pid_t p, pid_t c); ++static Client *termforwin(Client *w); ++static void swallow(Client *c, Client *w); + + /* variables */ + static const char broken[] = "broken"; +@@ -453,6 +462,8 @@ applyrules(Client *c) + if ((!r->title || strstr(title, r->title)) + && (!r->id || strstr(appid, r->id))) { + c->isfloating = r->isfloating; ++ c->isterm = r->isterm; ++ c->noswallow = r->noswallow; + newtags |= r->tags; + i = 0; + wl_list_for_each(m, &mons, link) +@@ -990,6 +1001,8 @@ createnotify(struct wl_listener *listener, void *data) + c->surface.xdg = xdg_surface; + c->bw = borderpx; + ++ wl_client_get_credentials(c->surface.xdg->client->client, &c->pid, NULL, NULL); ++ + LISTEN(&xdg_surface->events.map, &c->map, mapnotify); + LISTEN(&xdg_surface->events.unmap, &c->unmap, unmapnotify); + LISTEN(&xdg_surface->events.destroy, &c->destroy, destroynotify); +@@ -1308,6 +1321,61 @@ fullscreennotify(struct wl_listener *listener, void *data) + setfullscreen(c, client_wants_fullscreen(c)); + } + ++pid_t ++getparentprocess(pid_t p) ++{ ++ unsigned int v = 0; ++ ++ 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); ++ ++ 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(Client *w) ++{ ++ Client *c; ++ ++ if (!w->pid || w->isterm || w->noswallow) ++ return NULL; ++ ++ wl_list_for_each(c, &clients, link) ++ if (c->isterm && !c->swallowing && c->pid && isdescprocess(c->pid, w->pid)) ++ return c; ++ ++ return NULL; ++} ++ ++void ++swallow(Client *c, Client *w) { ++ c->bw = w->bw; ++ c->isfloating = w->isfloating; ++ c->isurgent = w->isurgent; ++ c->isfullscreen = w->isfullscreen; ++ resize(c, w->geom, 0); ++ wl_list_insert(&w->link, &c->link); ++ wl_list_insert(&w->flink, &c->flink); ++ wlr_scene_node_set_enabled(&w->scene->node, 0); ++ wlr_scene_node_set_enabled(&c->scene->node, 1); ++} ++ + void + incnmaster(const Arg *arg) + { +@@ -1528,6 +1596,20 @@ mapnotify(struct wl_listener *listener, void *data) + } + printstatus(); + ++ if (!c->noswallow) { ++ Client *p = termforwin(c); ++ if (p) { ++ c->swallowedby = p; ++ p->swallowing = c; ++ wl_list_remove(&c->link); ++ wl_list_remove(&c->flink); ++ swallow(c,p); ++ wl_list_remove(&p->link); ++ wl_list_remove(&p->flink); ++ arrange(c->mon); ++ } ++ } ++ + unset_fullscreen: + m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y); + wl_list_for_each(w, &clients, link) +@@ -2409,6 +2491,18 @@ unmapnotify(struct wl_listener *listener, void *data) + grabc = NULL; + } + ++ if (c->swallowing) { ++ c->swallowing->swallowedby = NULL; ++ c->swallowing = NULL; ++ } ++ ++ if (c->swallowedby) { ++ setfullscreen(c->swallowedby, 0); ++ swallow(c->swallowedby, c); ++ c->swallowedby->swallowing = NULL; ++ c->swallowedby = NULL; ++ } ++ + if (client_is_unmanaged(c)) { + if (c == exclusive_focus) + exclusive_focus = NULL; |
