diff options
author | Okan Demirmen <okan@cvs.openbsd.org> | 2013-11-02 19:13:58 +0000 |
---|---|---|
committer | Okan Demirmen <okan@cvs.openbsd.org> | 2013-11-02 19:13:58 +0000 |
commit | 319800cbacc9b93449328df4b5aa8efb0e71520e (patch) | |
tree | 08373f1eefdbb4d52df98153eca7d7b359cc4591 | |
parent | 1b9f302f2293bf4073bbea8f2010654becb18ee1 (diff) |
The only reason we need to keep XSizeHints in our client_ctx is for
flags, so just add one to hints; consolidates sizehints and shrinks.
Additionally don't abuse PSize for XGetWMNormalHints() failures.
-rw-r--r-- | app/cwm/calmwm.h | 4 | ||||
-rw-r--r-- | app/cwm/client.c | 69 |
2 files changed, 40 insertions, 33 deletions
diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h index baefe603b..741bf8ac0 100644 --- a/app/cwm/calmwm.h +++ b/app/cwm/calmwm.h @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: calmwm.h,v 1.225 2013/11/01 14:07:19 okan Exp $ + * $OpenBSD: calmwm.h,v 1.226 2013/11/02 19:13:56 okan Exp $ */ #ifndef _CALMWM_H_ @@ -137,11 +137,11 @@ struct client_ctx { TAILQ_ENTRY(client_ctx) mru_entry; struct screen_ctx *sc; Window win; - XSizeHints *size; Colormap colormap; u_int bwidth; /* border width */ struct geom geom, savegeom; struct { + long flags; /* defined hints */ int basew; /* desired width */ int baseh; /* desired height */ int minw; /* minimum width */ diff --git a/app/cwm/client.c b/app/cwm/client.c index 294630ca6..d1fce2fd5 100644 --- a/app/cwm/client.c +++ b/app/cwm/client.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: client.c,v 1.144 2013/11/01 21:54:20 okan Exp $ + * $OpenBSD: client.c,v 1.145 2013/11/02 19:13:57 okan Exp $ */ #include <sys/param.h> @@ -73,7 +73,6 @@ client_init(Window win, struct screen_ctx *sc, int mapped) cc->state = mapped ? NormalState : IconicState; cc->sc = sc; cc->win = win; - cc->size = XAllocSizeHints(); client_getsizehints(cc); @@ -175,7 +174,6 @@ client_delete(struct client_ctx *cc, int destroy) if (cc == client_current()) client_none(sc); - XFree(cc->size); if (cc->app_name != NULL) XFree(cc->app_name); if (cc->app_class != NULL) @@ -685,7 +683,7 @@ client_placecalc(struct client_ctx *cc) struct screen_ctx *sc = cc->sc; int xslack, yslack; - if (cc->size->flags & (USPosition|PPosition)) { + if (cc->hint.flags & (USPosition|PPosition)) { /* * Ignore XINERAMA screens, just make sure it's somewhere * in the virtual desktop. else it stops people putting xterms @@ -748,43 +746,52 @@ void client_getsizehints(struct client_ctx *cc) { long tmp; + XSizeHints *size; - if (!XGetWMNormalHints(X_Dpy, cc->win, cc->size, &tmp)) - cc->size->flags = PSize; + if ((size = XAllocSizeHints()) == NULL) + warnx("XAllocSizeHints failure"); - if (cc->size->flags & PBaseSize) { - cc->hint.basew = cc->size->base_width; - cc->hint.baseh = cc->size->base_height; - } else if (cc->size->flags & PMinSize) { - cc->hint.basew = cc->size->min_width; - cc->hint.baseh = cc->size->min_height; + if (!XGetWMNormalHints(X_Dpy, cc->win, size, &tmp)) + size->flags = 0; + + cc->hint.flags = size->flags; + + if (size->flags & PBaseSize) { + cc->hint.basew = size->base_width; + cc->hint.baseh = size->base_height; + } else if (size->flags & PMinSize) { + cc->hint.basew = size->min_width; + cc->hint.baseh = size->min_height; } - if (cc->size->flags & PMinSize) { - cc->hint.minw = cc->size->min_width; - cc->hint.minh = cc->size->min_height; - } else if (cc->size->flags & PBaseSize) { - cc->hint.minw = cc->size->base_width; - cc->hint.minh = cc->size->base_height; + if (size->flags & PMinSize) { + cc->hint.minw = size->min_width; + cc->hint.minh = size->min_height; + } else if (size->flags & PBaseSize) { + cc->hint.minw = size->base_width; + cc->hint.minh = size->base_height; } - if (cc->size->flags & PMaxSize) { - cc->hint.maxw = cc->size->max_width; - cc->hint.maxh = cc->size->max_height; + if (size->flags & PMaxSize) { + cc->hint.maxw = size->max_width; + cc->hint.maxh = size->max_height; } - if (cc->size->flags & PResizeInc) { - cc->hint.incw = cc->size->width_inc; - cc->hint.inch = cc->size->height_inc; + if (size->flags & PResizeInc) { + cc->hint.incw = size->width_inc; + cc->hint.inch = size->height_inc; } cc->hint.incw = MAX(1, cc->hint.incw); cc->hint.inch = MAX(1, cc->hint.inch); - if (cc->size->flags & PAspect) { - if (cc->size->min_aspect.x > 0) - cc->hint.mina = (float)cc->size->min_aspect.y / - cc->size->min_aspect.x; - if (cc->size->max_aspect.y > 0) - cc->hint.maxa = (float)cc->size->max_aspect.x / - cc->size->max_aspect.y; + if (size->flags & PAspect) { + if (size->min_aspect.x > 0) + cc->hint.mina = (float)size->min_aspect.y / + size->min_aspect.x; + if (size->max_aspect.y > 0) + cc->hint.maxa = (float)size->max_aspect.x / + size->max_aspect.y; } + + if (size) + XFree(size); } void |