Improve code of func "updatesizehints"
This commit is contained in:
parent
5525b13991
commit
ec91e36622
28
src/dwm.c
28
src/dwm.c
|
@ -1803,43 +1803,55 @@ void updatenumlockmask()
|
|||
|
||||
void updatesizehints(Client *c)
|
||||
{
|
||||
long msize;
|
||||
XSizeHints size;
|
||||
XSizeHints size = { 0 };
|
||||
long msize = 0;
|
||||
|
||||
if (!XGetWMNormalHints(dpy, c->win, &size, &msize))
|
||||
if (!XGetWMNormalHints(dpy, c->win, &size, &msize)) {
|
||||
/* size is uninitialized, ensure that size.flags aren't used */
|
||||
size.flags = PSize;
|
||||
}
|
||||
|
||||
if (size.flags & PBaseSize) {
|
||||
c->basew = size.base_width;
|
||||
c->baseh = size.base_height;
|
||||
} else if (size.flags & PMinSize) {
|
||||
c->basew = size.min_width;
|
||||
c->baseh = size.min_height;
|
||||
} else
|
||||
} else {
|
||||
c->basew = c->baseh = 0;
|
||||
}
|
||||
|
||||
if (size.flags & PResizeInc) {
|
||||
c->incw = size.width_inc;
|
||||
c->inch = size.height_inc;
|
||||
} else
|
||||
} else {
|
||||
c->incw = c->inch = 0;
|
||||
}
|
||||
|
||||
if (size.flags & PMaxSize) {
|
||||
c->maxw = size.max_width;
|
||||
c->maxh = size.max_height;
|
||||
} else
|
||||
} else {
|
||||
c->maxw = c->maxh = 0;
|
||||
}
|
||||
|
||||
if (size.flags & PMinSize) {
|
||||
c->minw = size.min_width;
|
||||
c->minh = size.min_height;
|
||||
} else if (size.flags & PBaseSize) {
|
||||
c->minw = size.base_width;
|
||||
c->minh = size.base_height;
|
||||
} else
|
||||
} else {
|
||||
c->minw = c->minh = 0;
|
||||
}
|
||||
|
||||
if (size.flags & PAspect) {
|
||||
c->mina = (float)size.min_aspect.y / size.min_aspect.x;
|
||||
c->maxa = (float)size.max_aspect.x / size.max_aspect.y;
|
||||
} else
|
||||
} else {
|
||||
c->maxa = c->mina = 0.0;
|
||||
}
|
||||
|
||||
c->isfixed = (c->maxw && c->maxh && c->maxw == c->minw && c->maxh == c->minh);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue