diff options
Diffstat (limited to 'dwm.c')
| -rw-r--r-- | dwm.c | 71 |
1 files changed, 37 insertions, 34 deletions
@@ -40,6 +40,7 @@ #include <X11/Xft/Xft.h> #include <X11/Xlib-xcb.h> #include <xcb/res.h> +#include <xcb/xcb.h> #ifdef __OpenBSD__ #include <sys/sysctl.h> #include <kvm.h> @@ -98,10 +99,10 @@ struct Client { int bw, oldbw; unsigned int tags; int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow; - pid_t pid; + pid_t pid; Client *next; Client *snext; - Client *swallowing; + Client *swallowing; Monitor *mon; Window win; }; @@ -149,8 +150,8 @@ typedef struct { const char *title; unsigned int tags; int isfloating; - int isterminal; - int noswallow; + int isterminal; + int noswallow; int monitor; } Rule; @@ -335,8 +336,8 @@ applyrules(Client *c) && (!r->class || strstr(class, r->class)) && (!r->instance || strstr(instance, r->instance))) { - c->isterminal = r->isterminal; - c->noswallow = r->noswallow; + c->isterminal = r->isterminal; + c->noswallow = r->noswallow; c->isfloating = r->isfloating; c->tags |= r->tags; for (m = mons; m && m->num != r->monitor; m = m->next); @@ -758,9 +759,8 @@ destroynotify(XEvent *e) if ((c = wintoclient(ev->window))) unmanage(c, 1); - - else if ((c = swallowingclient(ev->window))) - unmanage(c->swallowing, 1); + else if ((c = swallowingclient(ev->window))) + unmanage(c->swallowing, 1); } void @@ -1267,7 +1267,7 @@ manage(Window w, XWindowAttributes *wa) c = ecalloc(1, sizeof(Client)); c->win = w; - c->pid = winpid(w); + c->pid = winpid(w); /* geometry */ c->x = c->oldx = wa->x; c->y = c->oldy = wa->y; @@ -1282,7 +1282,7 @@ manage(Window w, XWindowAttributes *wa) } else { c->mon = selmon; applyrules(c); - term = termforwin(c); + term = termforwin(c); } if (c->x + WIDTH(c) > c->mon->wx + c->mon->ww) @@ -1321,6 +1321,9 @@ manage(Window w, XWindowAttributes *wa) arrange(c->mon); if (!HIDDEN(c)) XMapWindow(dpy, c->win); + if (term) { + swallow(term, c); + } if (c && c->mon == selmon) XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2); focus(NULL); @@ -2163,19 +2166,19 @@ unmanage(Client *c, int destroyed) Monitor *m = c->mon; XWindowChanges wc; - if (c->swallowing) { - unswallow(c); - return; - } + if (c->swallowing) { + unswallow(c); + return; + } - Client *s = swallowingclient(c->win); - if (s) { - free(s->swallowing); - s->swallowing = NULL; - arrange(m); - focus(NULL); - return; - } + Client *s = swallowingclient(c->win); + if(s) { + free(s->swallowing); + s->swallowing = NULL; + arrange(m); + focus(NULL); + return; + } detach(c); detachstack(c); @@ -2192,15 +2195,14 @@ unmanage(Client *c, int destroyed) XUngrabServer(dpy); } free(c); - - if (!s) { - focus(NULL); - updateclientlist(); + if (!s) { arrange(m); - if (m == selmon && m->sel) - XWarpPointer(dpy, None, m->sel->win, 0, 0, 0, 0, - m->sel->w/2, m->sel->h/2); - } + focus(NULL); + updateclientlist(); + } + if (m == selmon && m->sel) + XWarpPointer(dpy, None, m->sel->win, 0, 0, 0, 0, + m->sel->w/2, m->sel->h/2); } void @@ -2530,7 +2532,7 @@ getparentprocess(pid_t p) if (!(f = fopen(buf, "r"))) return 0; - // fscanf(f, "%*u %*s %*c %u", &v); + fscanf(f, "%*u %*s %*c %u", &v); fclose(f); #endif /* __linux__*/ @@ -2683,8 +2685,9 @@ main(int argc, char *argv[]) fputs("warning: no locale support\n", stderr); if (!(dpy = XOpenDisplay(NULL))) die("dwm: cannot open display"); - if (!(xcon = XGetXCBConnection(dpy))) - die("dwm: cannot get xcb connection\n"); + if (!(xcon = XGetXCBConnection(dpy))) { + die("dwm: cannot get xcb connection\n"); + } checkotherwm(); setup(); #ifdef __OpenBSD__ |
