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
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);
void
manage(Window w, XWindowAttributes *wa) {
- Client *c;
+ Client *c, *t;
Window trans;
c = emallocz(sizeof(Client));
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;
void
resize(Client *c, Bool sizehints) {
+ float actual, dx, dy, max, min;
XWindowChanges wc;
if(c->w <= 0 || c->h <= 0)
return;
if(sizehints) {
- if(c->incw)
- c->w -= (c->w - c->basew) % c->incw;
- if(c->inch)
- c->h -= (c->h - c->baseh) % c->inch;
if(c->minw && c->w < c->minw)
c->w = c->minw;
if(c->minh && c->h < c->minh)
c->w = c->maxw;
if(c->maxh && c->h > c->maxh)
c->h = c->maxh;
+ /* inspired by algorithm from fluxbox */
+ if(c->minay > 0 && c->maxay && (c->h - c->baseh) > 0) {
+ dx = (float)(c->w - c->basew);
+ dy = (float)(c->h - c->baseh);
+ min = (float)(c->minax) / (float)(c->minay);
+ max = (float)(c->maxax) / (float)(c->maxay);
+ actual = dx / dy;
+ if(max > 0 && min > 0 && actual > 0) {
+ if(actual < 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) {
+ dy = (dx * min + dy) / (max * max + 1);
+ dx = dy * min;
+ c->w = (int)dx + c->basew;
+ c->h = (int)dy + c->baseh;
+ }
+ }
+ }
+ if(c->incw)
+ c->w -= (c->w - c->basew) % c->incw;
+ if(c->inch)
+ c->h -= (c->h - c->baseh) % c->inch;
}
if(c->w == sw && c->h == sh)
c->border = 0;
}
else
c->minw = c->minh = 0;
+ if(c->flags & PAspect) {
+ c->minax = size.min_aspect.x;
+ c->minay = size.min_aspect.y;
+ c->maxax = size.max_aspect.x;
+ c->maxay = size.max_aspect.y;
+ }
+ 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);
}