X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=client.c;h=3505e76619eb698cd33d439d6310d98725e56113;hb=3ce8c9f33844a995e79329978db9d2cd3981e032;hp=50e8a94d004d518c299ae286af890bda42783a16;hpb=44ef3f5a07753ecaeacc2fb180e90bf4479ab975;p=dwm.git diff --git a/client.c b/client.c index 50e8a94..3505e76 100644 --- a/client.c +++ b/client.c @@ -68,20 +68,29 @@ xerrordummy(Display *dsply, XErrorEvent *ee) { /* extern */ void +ban(Client *c) { + if(!c || c->isbanned) + return; + c->isbanned = True; + XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); +} + +void configure(Client *c) { - XEvent synev; + XConfigureEvent ce; - synev.type = ConfigureNotify; - synev.xconfigure.display = dpy; - synev.xconfigure.event = c->win; - synev.xconfigure.window = c->win; - synev.xconfigure.x = c->x; - synev.xconfigure.y = c->y; - synev.xconfigure.width = c->w; - synev.xconfigure.height = c->h; - synev.xconfigure.border_width = c->border; - synev.xconfigure.above = None; - XSendEvent(dpy, c->win, True, NoEventMask, &synev); + ce.type = ConfigureNotify; + ce.display = dpy; + ce.event = c->win; + ce.window = c->win; + ce.x = c->x; + ce.y = c->y; + ce.width = c->w; + ce.height = c->h; + ce.border_width = c->border; + ce.above = None; + ce.override_redirect = False; + XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce); } void @@ -120,11 +129,26 @@ getclient(Window w) { return NULL; } +Bool +isprotodel(Client *c) { + int i, n; + Atom *protocols; + Bool ret = False; + + if(XGetWMProtocols(dpy, c->win, &protocols, &n)) { + for(i = 0; !ret && i < n; i++) + if(protocols[i] == wmatom[WMDelete]) + ret = True; + XFree(protocols); + } + return ret; +} + void killclient(Arg *arg) { if(!sel) return; - if(sel->proto & PROTODELWIN) + if(isprotodel(sel)) sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]); else XKillClient(dpy, sel->win); @@ -132,7 +156,7 @@ killclient(Arg *arg) { void manage(Window w, XWindowAttributes *wa) { - Client *c; + Client *c, *t; Window trans; c = emallocz(sizeof(Client)); @@ -159,22 +183,22 @@ manage(Window w, XWindowAttributes *wa) { c->y = way; } updatesizehints(c); - c->proto = getproto(c->win); XSelectInput(dpy, c->win, StructureNotifyMask | PropertyChangeMask | EnterWindowMask); XGetTransientForHint(dpy, c->win, &trans); grabbuttons(c, False); XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]); updatetitle(c); - settags(c, getclient(trans)); + t = getclient(trans); + settags(c, t); if(!c->isfloat) - c->isfloat = trans || c->isfixed; + c->isfloat = (t != 0) || c->isfixed; if(clients) clients->prev = c; c->next = clients; c->snext = stack; stack = clients = c; - XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); + ban(c); XMapWindow(dpy, c->win); setclientstate(c, NormalState); if(isvisible(c)) @@ -288,8 +312,8 @@ updatesizehints(Client *c) { } else c->minax = c->minay = c->maxax = c->maxay = 0; - c->isfixed = (c->maxw && c->minw && c->maxh && c->minh && - c->maxw == c->minw && c->maxh == c->minh); + c->isfixed = (c->maxw && c->minw && c->maxh && c->minh + && c->maxw == c->minw && c->maxh == c->minh); } void @@ -309,7 +333,7 @@ updatetitle(Client *c) { strncpy(c->name, (char *)name.value, sizeof c->name); else { if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success - && n > 0 && *list) + && n > 0 && *list) { strncpy(c->name, *list, sizeof c->name); XFreeStringList(list);