aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorokan2012-07-13 17:01:04 +0000
committerokan2012-07-13 17:01:04 +0000
commitb6feb9c4c70841ec78711b4ffd93e6bcd578f388 (patch)
treeb60432e1113e366850bcabfec8e5ad7788114fd9
parenta4c958a3f89733566a15f47d5ddc0167fe5e85d4 (diff)
downloadcwm-b6feb9c4c70841ec78711b4ffd93e6bcd578f388.tar.gz
re-use geom struct in client_ctx (saved)geometry.
-rw-r--r--calmwm.h9
-rw-r--r--client.c104
-rw-r--r--kbfunc.c30
-rw-r--r--mousefunc.c32
-rw-r--r--xevents.c14
-rw-r--r--xutil.c6
6 files changed, 95 insertions, 100 deletions
diff --git a/calmwm.h b/calmwm.h
index efbbf3b..dbcb509 100644
--- a/calmwm.h
+++ b/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.151 2012/07/13 15:21:35 okan Exp $
+ * $OpenBSD: calmwm.h,v 1.152 2012/07/13 17:01:04 okan Exp $
*/
#ifndef _CALMWM_H_
@@ -125,12 +125,7 @@ struct client_ctx {
XSizeHints *size;
Colormap cmap;
u_int bwidth; /* border width */
- struct {
- int x; /* x position */
- int y; /* y position */
- int width; /* width */
- int height;/* height */
- } geom, savegeom;
+ struct geom geom, savegeom;
struct {
int basew; /* desired width */
int baseh; /* desired height */
diff --git a/client.c b/client.c
index fbc1ee4..f7629dd 100644
--- a/client.c
+++ b/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.97 2012/07/13 15:21:35 okan Exp $
+ * $OpenBSD: client.c,v 1.98 2012/07/13 17:01:04 okan Exp $
*/
#include <sys/param.h>
@@ -89,8 +89,8 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
XGetWindowAttributes(X_Dpy, cc->win, &wattr);
cc->geom.x = wattr.x;
cc->geom.y = wattr.y;
- cc->geom.width = wattr.width;
- cc->geom.height = wattr.height;
+ cc->geom.w = wattr.width;
+ cc->geom.h = wattr.height;
cc->cmap = wattr.colormap;
if (wattr.map_state != IsViewable) {
@@ -270,12 +270,12 @@ client_maximize(struct client_ctx *cc)
}
if ((cc->flags & CLIENT_VMAXIMIZED) == 0) {
- cc->savegeom.height = cc->geom.height;
+ cc->savegeom.h = cc->geom.h;
cc->savegeom.y = cc->geom.y;
}
if ((cc->flags & CLIENT_HMAXIMIZED) == 0) {
- cc->savegeom.width = cc->geom.width;
+ cc->savegeom.w = cc->geom.w;
cc->savegeom.x = cc->geom.x;
}
@@ -287,8 +287,8 @@ client_maximize(struct client_ctx *cc)
* a window is poking over a boundary
*/
xine = screen_find_xinerama(sc,
- cc->geom.x + cc->geom.width / 2,
- cc->geom.y + cc->geom.height / 2);
+ cc->geom.x + cc->geom.w / 2,
+ cc->geom.y + cc->geom.h / 2);
if (xine == NULL)
goto calc;
x_org = xine->x_org;
@@ -299,8 +299,8 @@ client_maximize(struct client_ctx *cc)
calc:
cc->geom.x = x_org + sc->gap.left;
cc->geom.y = y_org + sc->gap.top;
- cc->geom.height = ymax - (sc->gap.top + sc->gap.bottom);
- cc->geom.width = xmax - (sc->gap.left + sc->gap.right);
+ cc->geom.h = ymax - (sc->gap.top + sc->gap.bottom);
+ cc->geom.w = xmax - (sc->gap.left + sc->gap.right);
cc->bwidth = 0;
cc->flags |= CLIENT_MAXIMIZED;
@@ -319,28 +319,28 @@ client_vertmaximize(struct client_ctx *cc)
if (cc->flags & CLIENT_VMAXIMIZED) {
cc->geom.y = cc->savegeom.y;
- cc->geom.height = cc->savegeom.height;
+ cc->geom.h = cc->savegeom.h;
cc->bwidth = Conf.bwidth;
if (cc->flags & CLIENT_HMAXIMIZED)
- cc->geom.width -= cc->bwidth * 2;
+ cc->geom.w -= cc->bwidth * 2;
cc->flags &= ~CLIENT_VMAXIMIZED;
goto resize;
}
cc->savegeom.y = cc->geom.y;
- cc->savegeom.height = cc->geom.height;
+ cc->savegeom.h = cc->geom.h;
/* if this will make us fully maximized then remove boundary */
if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_HMAXIMIZED) {
- cc->geom.width += Conf.bwidth * 2;
+ cc->geom.w += Conf.bwidth * 2;
cc->bwidth = 0;
}
if (HasXinerama) {
XineramaScreenInfo *xine;
xine = screen_find_xinerama(sc,
- cc->geom.x + cc->geom.width / 2,
- cc->geom.y + cc->geom.height / 2);
+ cc->geom.x + cc->geom.w / 2,
+ cc->geom.y + cc->geom.h / 2);
if (xine == NULL)
goto calc;
y_org = xine->y_org;
@@ -348,7 +348,7 @@ client_vertmaximize(struct client_ctx *cc)
}
calc:
cc->geom.y = y_org + sc->gap.top;
- cc->geom.height = ymax - (cc->bwidth * 2) - (sc->gap.top +
+ cc->geom.h = ymax - (cc->bwidth * 2) - (sc->gap.top +
sc->gap.bottom);
cc->flags |= CLIENT_VMAXIMIZED;
@@ -367,28 +367,28 @@ client_horizmaximize(struct client_ctx *cc)
if (cc->flags & CLIENT_HMAXIMIZED) {
cc->geom.x = cc->savegeom.x;
- cc->geom.width = cc->savegeom.width;
+ cc->geom.w = cc->savegeom.w;
cc->bwidth = Conf.bwidth;
if (cc->flags & CLIENT_VMAXIMIZED)
- cc->geom.height -= cc->bwidth * 2;
+ cc->geom.h -= cc->bwidth * 2;
cc->flags &= ~CLIENT_HMAXIMIZED;
goto resize;
}
cc->savegeom.x = cc->geom.x;
- cc->savegeom.width = cc->geom.width;
+ cc->savegeom.w = cc->geom.w;
/* if this will make us fully maximized then remove boundary */
if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_VMAXIMIZED) {
- cc->geom.height += cc->bwidth * 2;
+ cc->geom.h += cc->bwidth * 2;
cc->bwidth = 0;
}
if (HasXinerama) {
XineramaScreenInfo *xine;
xine = screen_find_xinerama(sc,
- cc->geom.x + cc->geom.width / 2,
- cc->geom.y + cc->geom.height / 2);
+ cc->geom.x + cc->geom.w / 2,
+ cc->geom.y + cc->geom.h / 2);
if (xine == NULL)
goto calc;
x_org = xine->x_org;
@@ -396,7 +396,7 @@ client_horizmaximize(struct client_ctx *cc)
}
calc:
cc->geom.x = x_org + sc->gap.left;
- cc->geom.width = xmax - (cc->bwidth * 2) - (sc->gap.left +
+ cc->geom.w = xmax - (cc->bwidth * 2) - (sc->gap.left +
sc->gap.right);
cc->flags |= CLIENT_HMAXIMIZED;
@@ -410,7 +410,7 @@ client_resize(struct client_ctx *cc)
client_draw_border(cc);
XMoveResizeWindow(X_Dpy, cc->win, cc->geom.x,
- cc->geom.y, cc->geom.width, cc->geom.height);
+ cc->geom.y, cc->geom.w, cc->geom.h);
xu_configure(cc);
}
@@ -439,8 +439,8 @@ client_ptrwarp(struct client_ctx *cc)
int x = cc->ptr.x, y = cc->ptr.y;
if (x == -1 || y == -1) {
- x = cc->geom.width / 2;
- y = cc->geom.height / 2;
+ x = cc->geom.w / 2;
+ y = cc->geom.h / 2;
}
(cc->state == IconicState) ? client_unhide(cc) : client_raise(cc);
@@ -670,8 +670,8 @@ client_placecalc(struct client_ctx *cc)
* XRandR bits mean that {x,y}max shouldn't be outside what's
* currently there.
*/
- xslack = sc->view.w - cc->geom.width - cc->bwidth * 2;
- yslack = sc->view.h - cc->geom.height - cc->bwidth * 2;
+ xslack = sc->view.w - cc->geom.w - cc->bwidth * 2;
+ yslack = sc->view.h - cc->geom.h - cc->bwidth * 2;
if (cc->size->x > 0)
cc->geom.x = MIN(cc->size->x, xslack);
if (cc->size->y > 0)
@@ -696,14 +696,14 @@ noxine:
xmax = sc->view.w;
ymax = sc->view.h;
}
- xmouse = MAX(xmouse, xorig) - cc->geom.width / 2;
- ymouse = MAX(ymouse, yorig) - cc->geom.height / 2;
+ xmouse = MAX(xmouse, xorig) - cc->geom.w / 2;
+ ymouse = MAX(ymouse, yorig) - cc->geom.h / 2;
xmouse = MAX(xmouse, xorig);
ymouse = MAX(ymouse, yorig);
- xslack = xmax - cc->geom.width - cc->bwidth * 2;
- yslack = ymax - cc->geom.height - cc->bwidth * 2;
+ xslack = xmax - cc->geom.w - cc->bwidth * 2;
+ yslack = ymax - cc->geom.h - cc->bwidth * 2;
if (xslack >= xorig) {
cc->geom.x = MAX(MIN(xmouse, xslack),
@@ -712,7 +712,7 @@ noxine:
cc->geom.x -= sc->gap.right;
} else {
cc->geom.x = xorig + sc->gap.left;
- cc->geom.width = xmax - sc->gap.left;
+ cc->geom.w = xmax - sc->gap.left;
}
if (yslack >= yorig) {
cc->geom.y = MAX(MIN(ymouse, yslack),
@@ -721,7 +721,7 @@ noxine:
cc->geom.y -= sc->gap.bottom;
} else {
cc->geom.y = yorig + sc->gap.top;
- cc->geom.height = ymax - sc->gap.top;
+ cc->geom.h = ymax - sc->gap.top;
}
}
}
@@ -796,43 +796,43 @@ client_applysizehints(struct client_ctx *cc)
/* temporarily remove base dimensions, ICCCM 4.1.2.3 */
if (!baseismin) {
- cc->geom.width -= cc->hint.basew;
- cc->geom.height -= cc->hint.baseh;
+ cc->geom.w -= cc->hint.basew;
+ cc->geom.h -= cc->hint.baseh;
}
/* adjust for aspect limits */
if (cc->hint.mina > 0 && cc->hint.maxa > 0) {
if (cc->hint.maxa <
- (float)cc->geom.width / cc->geom.height)
- cc->geom.width = cc->geom.height * cc->hint.maxa;
+ (float)cc->geom.w / cc->geom.h)
+ cc->geom.w = cc->geom.h * cc->hint.maxa;
else if (cc->hint.mina <
- (float)cc->geom.height / cc->geom.width)
- cc->geom.height = cc->geom.width * cc->hint.mina;
+ (float)cc->geom.h / cc->geom.w)
+ cc->geom.h = cc->geom.w * cc->hint.mina;
}
/* remove base dimensions for increment */
if (baseismin) {
- cc->geom.width -= cc->hint.basew;
- cc->geom.height -= cc->hint.baseh;
+ cc->geom.w -= cc->hint.basew;
+ cc->geom.h -= cc->hint.baseh;
}
/* adjust for increment value */
- cc->geom.width -= cc->geom.width % cc->hint.incw;
- cc->geom.height -= cc->geom.height % cc->hint.inch;
+ cc->geom.w -= cc->geom.w % cc->hint.incw;
+ cc->geom.h -= cc->geom.h % cc->hint.inch;
/* restore base dimensions */
- cc->geom.width += cc->hint.basew;
- cc->geom.height += cc->hint.baseh;
+ cc->geom.w += cc->hint.basew;
+ cc->geom.h += cc->hint.baseh;
/* adjust for min width/height */
- cc->geom.width = MAX(cc->geom.width, cc->hint.minw);
- cc->geom.height = MAX(cc->geom.height, cc->hint.minh);
+ cc->geom.w = MAX(cc->geom.w, cc->hint.minw);
+ cc->geom.h = MAX(cc->geom.h, cc->hint.minh);
/* adjust for max width/height */
if (cc->hint.maxw)
- cc->geom.width = MIN(cc->geom.width, cc->hint.maxw);
+ cc->geom.w = MIN(cc->geom.w, cc->hint.maxw);
if (cc->hint.maxh)
- cc->geom.height = MIN(cc->geom.height, cc->hint.maxh);
+ cc->geom.h = MIN(cc->geom.h, cc->hint.maxh);
}
static void
@@ -883,8 +883,8 @@ client_transient(struct client_ctx *cc)
static int
client_inbound(struct client_ctx *cc, int x, int y)
{
- return (x < cc->geom.width && x >= 0 &&
- y < cc->geom.height && y >= 0);
+ return (x < cc->geom.w && x >= 0 &&
+ y < cc->geom.h && y >= 0);
}
int
diff --git a/kbfunc.c b/kbfunc.c
index 67179a4..056dbe9 100644
--- a/kbfunc.c
+++ b/kbfunc.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: kbfunc.c,v 1.61 2012/07/13 15:21:35 okan Exp $
+ * $OpenBSD: kbfunc.c,v 1.62 2012/07/13 17:01:04 okan Exp $
*/
#include <sys/param.h>
@@ -88,22 +88,22 @@ kbfunc_moveresize(struct client_ctx *cc, union arg *arg)
switch (flags & TYPEMASK) {
case CWM_MOVE:
cc->geom.y += my;
- if (cc->geom.y + cc->geom.height < 0)
- cc->geom.y = -cc->geom.height;
+ if (cc->geom.y + cc->geom.h < 0)
+ cc->geom.y = -cc->geom.h;
if (cc->geom.y > sc->view.h - 1)
cc->geom.y = sc->view.h - 1;
cc->geom.x += mx;
- if (cc->geom.x + cc->geom.width < 0)
- cc->geom.x = -cc->geom.width;
+ if (cc->geom.x + cc->geom.w < 0)
+ cc->geom.x = -cc->geom.w;
if (cc->geom.x > sc->view.w - 1)
cc->geom.x = sc->view.w - 1;
cc->geom.x += client_snapcalc(cc->geom.x,
- cc->geom.width, sc->view.w,
+ cc->geom.w, sc->view.w,
cc->bwidth, Conf.snapdist);
cc->geom.y += client_snapcalc(cc->geom.y,
- cc->geom.height, sc->view.h,
+ cc->geom.h, sc->view.h,
cc->bwidth, Conf.snapdist);
client_move(cc);
@@ -113,18 +113,18 @@ kbfunc_moveresize(struct client_ctx *cc, union arg *arg)
client_ptrwarp(cc);
break;
case CWM_RESIZE:
- if ((cc->geom.height += my) < 1)
- cc->geom.height = 1;
- if ((cc->geom.width += mx) < 1)
- cc->geom.width = 1;
+ if ((cc->geom.h += my) < 1)
+ cc->geom.h = 1;
+ if ((cc->geom.w += mx) < 1)
+ cc->geom.w = 1;
client_resize(cc);
/* Make sure the pointer stays within the window. */
xu_ptr_getpos(cc->win, &cc->ptr.x, &cc->ptr.y);
- if (cc->ptr.x > cc->geom.width)
- cc->ptr.x = cc->geom.width - cc->bwidth;
- if (cc->ptr.y > cc->geom.height)
- cc->ptr.y = cc->geom.height - cc->bwidth;
+ if (cc->ptr.x > cc->geom.w)
+ cc->ptr.x = cc->geom.w - cc->bwidth;
+ if (cc->ptr.y > cc->geom.h)
+ cc->ptr.y = cc->geom.h - cc->bwidth;
client_ptrwarp(cc);
break;
case CWM_PTRMOVE:
diff --git a/mousefunc.c b/mousefunc.c
index 1361617..4f6ec66 100644
--- a/mousefunc.c
+++ b/mousefunc.c
@@ -16,7 +16,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: mousefunc.c,v 1.36 2012/07/13 15:21:35 okan Exp $
+ * $OpenBSD: mousefunc.c,v 1.37 2012/07/13 17:01:04 okan Exp $
*/
#include <sys/param.h>
@@ -37,17 +37,17 @@ static void mousefunc_sweep_draw(struct client_ctx *);
static int
mousefunc_sweep_calc(struct client_ctx *cc, int x, int y, int mx, int my)
{
- int width = cc->geom.width, height = cc->geom.height;
+ int width = cc->geom.w, height = cc->geom.h;
- cc->geom.width = abs(x - mx) - cc->bwidth;
- cc->geom.height = abs(y - my) - cc->bwidth;
+ cc->geom.w = abs(x - mx) - cc->bwidth;
+ cc->geom.h = abs(y - my) - cc->bwidth;
client_applysizehints(cc);
- cc->geom.x = x <= mx ? x : x - cc->geom.width;
- cc->geom.y = y <= my ? y : y - cc->geom.height;
+ cc->geom.x = x <= mx ? x : x - cc->geom.w;
+ cc->geom.y = y <= my ? y : y - cc->geom.h;
- return (width != cc->geom.width || height != cc->geom.height);
+ return (width != cc->geom.w || height != cc->geom.h);
}
static void
@@ -58,8 +58,8 @@ mousefunc_sweep_draw(struct client_ctx *cc)
int width, width_size, width_name;
(void)snprintf(asize, sizeof(asize), "%dx%d",
- (cc->geom.width - cc->hint.basew) / cc->hint.incw,
- (cc->geom.height - cc->hint.baseh) / cc->hint.inch);
+ (cc->geom.w - cc->hint.basew) / cc->hint.incw,
+ (cc->geom.h - cc->hint.baseh) / cc->hint.inch);
width_size = font_width(sc, asize, strlen(asize)) + 4;
width_name = font_width(sc, cc->name, strlen(cc->name)) + 4;
width = MAX(width_size, width_name);
@@ -91,7 +91,7 @@ mousefunc_window_resize(struct client_ctx *cc, void *arg)
if (xu_ptr_grab(cc->win, MOUSEMASK, Cursor_resize) < 0)
return;
- xu_ptr_setpos(cc->win, cc->geom.width, cc->geom.height);
+ xu_ptr_setpos(cc->win, cc->geom.w, cc->geom.h);
mousefunc_sweep_draw(cc);
for (;;) {
@@ -121,10 +121,10 @@ mousefunc_window_resize(struct client_ctx *cc, void *arg)
xu_ptr_ungrab();
/* Make sure the pointer stays within the window. */
- if (cc->ptr.x > cc->geom.width)
- cc->ptr.x = cc->geom.width - cc->bwidth;
- if (cc->ptr.y > cc->geom.height)
- cc->ptr.y = cc->geom.height - cc->bwidth;
+ if (cc->ptr.x > cc->geom.w)
+ cc->ptr.x = cc->geom.w - cc->bwidth;
+ if (cc->ptr.y > cc->geom.h)
+ cc->ptr.y = cc->geom.h - cc->bwidth;
client_ptrwarp(cc);
return;
}
@@ -162,10 +162,10 @@ mousefunc_window_move(struct client_ctx *cc, void *arg)
cc->geom.y = ev.xmotion.y_root - py - cc->bwidth;
cc->geom.x += client_snapcalc(cc->geom.x,
- cc->geom.width, sc->view.w,
+ cc->geom.w, sc->view.w,
cc->bwidth, Conf.snapdist);
cc->geom.y += client_snapcalc(cc->geom.y,
- cc->geom.height, sc->view.h,
+ cc->geom.h, sc->view.h,
cc->bwidth, Conf.snapdist);
/* don't move more than 60 times / second */
diff --git a/xevents.c b/xevents.c
index 2a7c5e1..6d98e71 100644
--- a/xevents.c
+++ b/xevents.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: xevents.c,v 1.64 2012/07/13 15:21:35 okan Exp $
+ * $OpenBSD: xevents.c,v 1.65 2012/07/13 17:01:04 okan Exp $
*/
/*
@@ -141,9 +141,9 @@ xev_handle_configurerequest(XEvent *ee)
sc = cc->sc;
if (e->value_mask & CWWidth)
- cc->geom.width = e->width;
+ cc->geom.w = e->width;
if (e->value_mask & CWHeight)
- cc->geom.height = e->height;
+ cc->geom.h = e->height;
if (e->value_mask & CWX)
cc->geom.x = e->x;
if (e->value_mask & CWY)
@@ -151,16 +151,16 @@ xev_handle_configurerequest(XEvent *ee)
if (e->value_mask & CWBorderWidth)
wc.border_width = e->border_width;
- if (cc->geom.x == 0 && cc->geom.width >= sc->view.w)
+ if (cc->geom.x == 0 && cc->geom.w >= sc->view.w)
cc->geom.x -= cc->bwidth;
- if (cc->geom.y == 0 && cc->geom.height >= sc->view.h)
+ if (cc->geom.y == 0 && cc->geom.h >= sc->view.h)
cc->geom.y -= cc->bwidth;
wc.x = cc->geom.x;
wc.y = cc->geom.y;
- wc.width = cc->geom.width;
- wc.height = cc->geom.height;
+ wc.width = cc->geom.w;
+ wc.height = cc->geom.h;
wc.border_width = cc->bwidth;
XConfigureWindow(X_Dpy, cc->win, e->value_mask, &wc);
diff --git a/xutil.c b/xutil.c
index 15e648a..bc0c745 100644
--- a/xutil.c
+++ b/xutil.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: xutil.c,v 1.44 2012/07/13 15:21:35 okan Exp $
+ * $OpenBSD: xutil.c,v 1.45 2012/07/13 17:01:05 okan Exp $
*/
#include <sys/param.h>
@@ -128,8 +128,8 @@ xu_configure(struct client_ctx *cc)
ce.window = cc->win;
ce.x = cc->geom.x;
ce.y = cc->geom.y;
- ce.width = cc->geom.width;
- ce.height = cc->geom.height;
+ ce.width = cc->geom.w;
+ ce.height = cc->geom.h;
ce.border_width = cc->bwidth;
ce.above = None;
ce.override_redirect = 0;