X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=client.c;h=e37b9e6d65b5e7a36ccf58eecdd240df6357a349;hb=dc9f62f39370455b217595a0fbd34b405585c45f;hp=2b194d7f39b5a836e8b4af849842ed6eaf8b6d39;hpb=2ddc78720aceda76e22fd3584740fc86a2e7c677;p=dwm.git diff --git a/client.c b/client.c index 2b194d7..e37b9e6 100644 --- a/client.c +++ b/client.c @@ -9,13 +9,6 @@ /* static */ -static void -closestpt(float *rx, float *ry, float x, float y, float grad) { - float u = (x * grad + y) / (grad * grad + 1); - *rx = u * grad; - *ry = u; -} - static void detachstack(Client *c) { Client **tc; @@ -127,11 +120,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); @@ -166,7 +174,6 @@ 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); @@ -191,7 +198,7 @@ manage(Window w, XWindowAttributes *wa) { void resize(Client *c, Bool sizehints) { - float dx, dy, min, max, actual; + float actual, dx, dy, max, min; XWindowChanges wc; if(c->w <= 0 || c->h <= 0) @@ -214,12 +221,14 @@ resize(Client *c, Bool sizehints) { actual = dx / dy; if(max > 0 && min > 0 && actual > 0) { if(actual < min) { - closestpt(&dx, &dy, dx, dy, min); + dy = (dx * min + dy) / (min * min + 1); + dx = dy * min; c->w = (int)dx + c->basew; c->h = (int)dy + c->baseh; } else if(actual > max) { - closestpt(&dx, &dy, dx, dy, max); + dy = (dx * min + dy) / (max * max + 1); + dx = dy * min; c->w = (int)dx + c->basew; c->h = (int)dy + c->baseh; }