aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/dwm/client.c
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2020-06-06 19:56:41 -0700
committerNicholas Noll <nbnoll@eml.cc>2020-06-06 19:56:41 -0700
commit4e0318919dd726f485ea3a495ff0989f69f35630 (patch)
treeff22628bcaa163881afad87fc2501d5dffa43be2 /sys/cmd/dwm/client.c
parent186fe25ab798fe559be242dbe2eaff8e553c4e06 (diff)
hand added swallow patch
Diffstat (limited to 'sys/cmd/dwm/client.c')
-rw-r--r--sys/cmd/dwm/client.c106
1 files changed, 104 insertions, 2 deletions
diff --git a/sys/cmd/dwm/client.c b/sys/cmd/dwm/client.c
index d2ea972..1401677 100644
--- a/sys/cmd/dwm/client.c
+++ b/sys/cmd/dwm/client.c
@@ -11,7 +11,8 @@ applyrules(Client *c)
/* rule matching */
c->isfloating = 0;
- c->tags = 0;
+ c->tags = 0;
+ c->noswallow = -1;
XGetClassHint(dpy, c->win, &ch);
class = ch.res_class ? ch.res_class : broken;
instance = ch.res_name ? ch.res_name : broken;
@@ -22,8 +23,10 @@ applyrules(Client *c)
&& (!r->class || strstr(class, r->class))
&& (!r->instance || strstr(instance, r->instance)))
{
+ c->isterm = r->isterm;
+ c->noswallow = r->noswallow;
c->isfloating = r->isfloating;
- c->tags |= r->tags;
+ c->tags |= r->tags;
for (m = mons; m && m->num != r->monitor; m = m->next)
;
if (m)
@@ -415,6 +418,60 @@ showhide(Client *c)
}
void
+swallow(Client *p, Client *c)
+{
+ Client *s;
+
+
+ if (c->noswallow > 0 || c->isterm)
+ return;
+ if (c->noswallow < 0 && !swallowfloating && c->isfloating)
+ 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;
+
+ XChangeProperty(dpy, c->win, netatom[NetClientList], XA_WINDOW, 32, PropModeReplace,
+ (unsigned char *) &(p->win), 1);
+
+ updatetitle(p);
+ s = scanner ? c : p;
+ XMoveResizeWindow(dpy, p->win, s->x, s->y, s->w, s->h);
+ arrange(p->mon);
+ configure(p);
+ updateclientlist();
+}
+
+Client *
+termof(Client *w)
+{
+ Client *c;
+ Monitor *m;
+
+ if (!w->pid || w->isterm)
+ return NULL;
+
+ for (m = mons; m; m = m->next) {
+ for (c = m->clients; c; c = c->next) {
+ if (c->isterm && !c->swallowing && c->pid && isdescendent(c->pid, w->pid))
+ return c;
+ }
+ }
+
+ return NULL;
+}
+
+void
unfocus(Client *c, int setfocus)
{
if (!c)
@@ -430,11 +487,28 @@ unfocus(Client *c, int setfocus)
void
unmanage(Client *c, int destroyed)
{
+ Client *s;
Monitor *m = c->mon;
XWindowChanges wc;
+ if (c->swallowing) {
+ unswallow(c);
+ return;
+ }
+
+ s = swallowing(c->win);
+ if (s) {
+ free(s->swallowing);
+ s->swallowing = nil;
+ arrange(m);
+ focus(nil);
+ return;
+ }
+
+
detach(c);
detachstack(c);
+
if (!destroyed) {
wc.border_width = c->oldbw;
XGrabServer(dpy); /* avoid race conditions */
@@ -450,8 +524,36 @@ unmanage(Client *c, int destroyed)
focus(nil);
updateclientlist();
arrange(m);
+
+ if (!s) {
+ // arrange(m);
+ focus(nil);
+ updateclientlist();
+ }
+}
+
+void
+unswallow(Client *c)
+{
+ c->win = c->swallowing->win;
+
+ free(c->swallowing);
+ c->swallowing = nil;
+
+ XDeleteProperty(dpy, c->win, netatom[NetClientList]);
+
+ /* unfullscreen the client */
+ setfullscreen(c, 0);
+ updatetitle(c);
+ arrange(c->mon);
+ XMapWindow(dpy, c->win);
+ XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
+ setclientstate(c, NormalState);
+ focus(nil);
+ arrange(c->mon);
}
+
void
updatesizehints(Client *c)
{