mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
re-use geom struct in client_ctx (saved)geometry.
This commit is contained in:
parent
186a78ff1e
commit
0e8815dfb0
7
calmwm.h
7
calmwm.h
@ -125,12 +125,7 @@ struct client_ctx {
|
|||||||
XSizeHints *size;
|
XSizeHints *size;
|
||||||
Colormap cmap;
|
Colormap cmap;
|
||||||
u_int bwidth; /* border width */
|
u_int bwidth; /* border width */
|
||||||
struct {
|
struct geom geom, savegeom;
|
||||||
int x; /* x position */
|
|
||||||
int y; /* y position */
|
|
||||||
int width; /* width */
|
|
||||||
int height;/* height */
|
|
||||||
} geom, savegeom;
|
|
||||||
struct {
|
struct {
|
||||||
int basew; /* desired width */
|
int basew; /* desired width */
|
||||||
int baseh; /* desired height */
|
int baseh; /* desired height */
|
||||||
|
102
client.c
102
client.c
@ -89,8 +89,8 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
|
|||||||
XGetWindowAttributes(X_Dpy, cc->win, &wattr);
|
XGetWindowAttributes(X_Dpy, cc->win, &wattr);
|
||||||
cc->geom.x = wattr.x;
|
cc->geom.x = wattr.x;
|
||||||
cc->geom.y = wattr.y;
|
cc->geom.y = wattr.y;
|
||||||
cc->geom.width = wattr.width;
|
cc->geom.w = wattr.width;
|
||||||
cc->geom.height = wattr.height;
|
cc->geom.h = wattr.height;
|
||||||
cc->cmap = wattr.colormap;
|
cc->cmap = wattr.colormap;
|
||||||
|
|
||||||
if (wattr.map_state != IsViewable) {
|
if (wattr.map_state != IsViewable) {
|
||||||
@ -270,12 +270,12 @@ client_maximize(struct client_ctx *cc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((cc->flags & CLIENT_VMAXIMIZED) == 0) {
|
if ((cc->flags & CLIENT_VMAXIMIZED) == 0) {
|
||||||
cc->savegeom.height = cc->geom.height;
|
cc->savegeom.h = cc->geom.h;
|
||||||
cc->savegeom.y = cc->geom.y;
|
cc->savegeom.y = cc->geom.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((cc->flags & CLIENT_HMAXIMIZED) == 0) {
|
if ((cc->flags & CLIENT_HMAXIMIZED) == 0) {
|
||||||
cc->savegeom.width = cc->geom.width;
|
cc->savegeom.w = cc->geom.w;
|
||||||
cc->savegeom.x = cc->geom.x;
|
cc->savegeom.x = cc->geom.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,8 +287,8 @@ client_maximize(struct client_ctx *cc)
|
|||||||
* a window is poking over a boundary
|
* a window is poking over a boundary
|
||||||
*/
|
*/
|
||||||
xine = screen_find_xinerama(sc,
|
xine = screen_find_xinerama(sc,
|
||||||
cc->geom.x + cc->geom.width / 2,
|
cc->geom.x + cc->geom.w / 2,
|
||||||
cc->geom.y + cc->geom.height / 2);
|
cc->geom.y + cc->geom.h / 2);
|
||||||
if (xine == NULL)
|
if (xine == NULL)
|
||||||
goto calc;
|
goto calc;
|
||||||
x_org = xine->x_org;
|
x_org = xine->x_org;
|
||||||
@ -299,8 +299,8 @@ client_maximize(struct client_ctx *cc)
|
|||||||
calc:
|
calc:
|
||||||
cc->geom.x = x_org + sc->gap.left;
|
cc->geom.x = x_org + sc->gap.left;
|
||||||
cc->geom.y = y_org + sc->gap.top;
|
cc->geom.y = y_org + sc->gap.top;
|
||||||
cc->geom.height = ymax - (sc->gap.top + sc->gap.bottom);
|
cc->geom.h = ymax - (sc->gap.top + sc->gap.bottom);
|
||||||
cc->geom.width = xmax - (sc->gap.left + sc->gap.right);
|
cc->geom.w = xmax - (sc->gap.left + sc->gap.right);
|
||||||
cc->bwidth = 0;
|
cc->bwidth = 0;
|
||||||
cc->flags |= CLIENT_MAXIMIZED;
|
cc->flags |= CLIENT_MAXIMIZED;
|
||||||
|
|
||||||
@ -319,28 +319,28 @@ client_vertmaximize(struct client_ctx *cc)
|
|||||||
|
|
||||||
if (cc->flags & CLIENT_VMAXIMIZED) {
|
if (cc->flags & CLIENT_VMAXIMIZED) {
|
||||||
cc->geom.y = cc->savegeom.y;
|
cc->geom.y = cc->savegeom.y;
|
||||||
cc->geom.height = cc->savegeom.height;
|
cc->geom.h = cc->savegeom.h;
|
||||||
cc->bwidth = Conf.bwidth;
|
cc->bwidth = Conf.bwidth;
|
||||||
if (cc->flags & CLIENT_HMAXIMIZED)
|
if (cc->flags & CLIENT_HMAXIMIZED)
|
||||||
cc->geom.width -= cc->bwidth * 2;
|
cc->geom.w -= cc->bwidth * 2;
|
||||||
cc->flags &= ~CLIENT_VMAXIMIZED;
|
cc->flags &= ~CLIENT_VMAXIMIZED;
|
||||||
goto resize;
|
goto resize;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc->savegeom.y = cc->geom.y;
|
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 this will make us fully maximized then remove boundary */
|
||||||
if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_HMAXIMIZED) {
|
if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_HMAXIMIZED) {
|
||||||
cc->geom.width += Conf.bwidth * 2;
|
cc->geom.w += Conf.bwidth * 2;
|
||||||
cc->bwidth = 0;
|
cc->bwidth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HasXinerama) {
|
if (HasXinerama) {
|
||||||
XineramaScreenInfo *xine;
|
XineramaScreenInfo *xine;
|
||||||
xine = screen_find_xinerama(sc,
|
xine = screen_find_xinerama(sc,
|
||||||
cc->geom.x + cc->geom.width / 2,
|
cc->geom.x + cc->geom.w / 2,
|
||||||
cc->geom.y + cc->geom.height / 2);
|
cc->geom.y + cc->geom.h / 2);
|
||||||
if (xine == NULL)
|
if (xine == NULL)
|
||||||
goto calc;
|
goto calc;
|
||||||
y_org = xine->y_org;
|
y_org = xine->y_org;
|
||||||
@ -348,7 +348,7 @@ client_vertmaximize(struct client_ctx *cc)
|
|||||||
}
|
}
|
||||||
calc:
|
calc:
|
||||||
cc->geom.y = y_org + sc->gap.top;
|
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);
|
sc->gap.bottom);
|
||||||
cc->flags |= CLIENT_VMAXIMIZED;
|
cc->flags |= CLIENT_VMAXIMIZED;
|
||||||
|
|
||||||
@ -367,28 +367,28 @@ client_horizmaximize(struct client_ctx *cc)
|
|||||||
|
|
||||||
if (cc->flags & CLIENT_HMAXIMIZED) {
|
if (cc->flags & CLIENT_HMAXIMIZED) {
|
||||||
cc->geom.x = cc->savegeom.x;
|
cc->geom.x = cc->savegeom.x;
|
||||||
cc->geom.width = cc->savegeom.width;
|
cc->geom.w = cc->savegeom.w;
|
||||||
cc->bwidth = Conf.bwidth;
|
cc->bwidth = Conf.bwidth;
|
||||||
if (cc->flags & CLIENT_VMAXIMIZED)
|
if (cc->flags & CLIENT_VMAXIMIZED)
|
||||||
cc->geom.height -= cc->bwidth * 2;
|
cc->geom.h -= cc->bwidth * 2;
|
||||||
cc->flags &= ~CLIENT_HMAXIMIZED;
|
cc->flags &= ~CLIENT_HMAXIMIZED;
|
||||||
goto resize;
|
goto resize;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc->savegeom.x = cc->geom.x;
|
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 this will make us fully maximized then remove boundary */
|
||||||
if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_VMAXIMIZED) {
|
if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_VMAXIMIZED) {
|
||||||
cc->geom.height += cc->bwidth * 2;
|
cc->geom.h += cc->bwidth * 2;
|
||||||
cc->bwidth = 0;
|
cc->bwidth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HasXinerama) {
|
if (HasXinerama) {
|
||||||
XineramaScreenInfo *xine;
|
XineramaScreenInfo *xine;
|
||||||
xine = screen_find_xinerama(sc,
|
xine = screen_find_xinerama(sc,
|
||||||
cc->geom.x + cc->geom.width / 2,
|
cc->geom.x + cc->geom.w / 2,
|
||||||
cc->geom.y + cc->geom.height / 2);
|
cc->geom.y + cc->geom.h / 2);
|
||||||
if (xine == NULL)
|
if (xine == NULL)
|
||||||
goto calc;
|
goto calc;
|
||||||
x_org = xine->x_org;
|
x_org = xine->x_org;
|
||||||
@ -396,7 +396,7 @@ client_horizmaximize(struct client_ctx *cc)
|
|||||||
}
|
}
|
||||||
calc:
|
calc:
|
||||||
cc->geom.x = x_org + sc->gap.left;
|
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);
|
sc->gap.right);
|
||||||
cc->flags |= CLIENT_HMAXIMIZED;
|
cc->flags |= CLIENT_HMAXIMIZED;
|
||||||
|
|
||||||
@ -410,7 +410,7 @@ client_resize(struct client_ctx *cc)
|
|||||||
client_draw_border(cc);
|
client_draw_border(cc);
|
||||||
|
|
||||||
XMoveResizeWindow(X_Dpy, cc->win, cc->geom.x,
|
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);
|
xu_configure(cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,8 +439,8 @@ client_ptrwarp(struct client_ctx *cc)
|
|||||||
int x = cc->ptr.x, y = cc->ptr.y;
|
int x = cc->ptr.x, y = cc->ptr.y;
|
||||||
|
|
||||||
if (x == -1 || y == -1) {
|
if (x == -1 || y == -1) {
|
||||||
x = cc->geom.width / 2;
|
x = cc->geom.w / 2;
|
||||||
y = cc->geom.height / 2;
|
y = cc->geom.h / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
(cc->state == IconicState) ? client_unhide(cc) : client_raise(cc);
|
(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
|
* XRandR bits mean that {x,y}max shouldn't be outside what's
|
||||||
* currently there.
|
* currently there.
|
||||||
*/
|
*/
|
||||||
xslack = sc->view.w - cc->geom.width - cc->bwidth * 2;
|
xslack = sc->view.w - cc->geom.w - cc->bwidth * 2;
|
||||||
yslack = sc->view.h - cc->geom.height - cc->bwidth * 2;
|
yslack = sc->view.h - cc->geom.h - cc->bwidth * 2;
|
||||||
if (cc->size->x > 0)
|
if (cc->size->x > 0)
|
||||||
cc->geom.x = MIN(cc->size->x, xslack);
|
cc->geom.x = MIN(cc->size->x, xslack);
|
||||||
if (cc->size->y > 0)
|
if (cc->size->y > 0)
|
||||||
@ -696,14 +696,14 @@ noxine:
|
|||||||
xmax = sc->view.w;
|
xmax = sc->view.w;
|
||||||
ymax = sc->view.h;
|
ymax = sc->view.h;
|
||||||
}
|
}
|
||||||
xmouse = MAX(xmouse, xorig) - cc->geom.width / 2;
|
xmouse = MAX(xmouse, xorig) - cc->geom.w / 2;
|
||||||
ymouse = MAX(ymouse, yorig) - cc->geom.height / 2;
|
ymouse = MAX(ymouse, yorig) - cc->geom.h / 2;
|
||||||
|
|
||||||
xmouse = MAX(xmouse, xorig);
|
xmouse = MAX(xmouse, xorig);
|
||||||
ymouse = MAX(ymouse, yorig);
|
ymouse = MAX(ymouse, yorig);
|
||||||
|
|
||||||
xslack = xmax - cc->geom.width - cc->bwidth * 2;
|
xslack = xmax - cc->geom.w - cc->bwidth * 2;
|
||||||
yslack = ymax - cc->geom.height - cc->bwidth * 2;
|
yslack = ymax - cc->geom.h - cc->bwidth * 2;
|
||||||
|
|
||||||
if (xslack >= xorig) {
|
if (xslack >= xorig) {
|
||||||
cc->geom.x = MAX(MIN(xmouse, xslack),
|
cc->geom.x = MAX(MIN(xmouse, xslack),
|
||||||
@ -712,7 +712,7 @@ noxine:
|
|||||||
cc->geom.x -= sc->gap.right;
|
cc->geom.x -= sc->gap.right;
|
||||||
} else {
|
} else {
|
||||||
cc->geom.x = xorig + sc->gap.left;
|
cc->geom.x = xorig + sc->gap.left;
|
||||||
cc->geom.width = xmax - sc->gap.left;
|
cc->geom.w = xmax - sc->gap.left;
|
||||||
}
|
}
|
||||||
if (yslack >= yorig) {
|
if (yslack >= yorig) {
|
||||||
cc->geom.y = MAX(MIN(ymouse, yslack),
|
cc->geom.y = MAX(MIN(ymouse, yslack),
|
||||||
@ -721,7 +721,7 @@ noxine:
|
|||||||
cc->geom.y -= sc->gap.bottom;
|
cc->geom.y -= sc->gap.bottom;
|
||||||
} else {
|
} else {
|
||||||
cc->geom.y = yorig + sc->gap.top;
|
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 */
|
/* temporarily remove base dimensions, ICCCM 4.1.2.3 */
|
||||||
if (!baseismin) {
|
if (!baseismin) {
|
||||||
cc->geom.width -= cc->hint.basew;
|
cc->geom.w -= cc->hint.basew;
|
||||||
cc->geom.height -= cc->hint.baseh;
|
cc->geom.h -= cc->hint.baseh;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* adjust for aspect limits */
|
/* adjust for aspect limits */
|
||||||
if (cc->hint.mina > 0 && cc->hint.maxa > 0) {
|
if (cc->hint.mina > 0 && cc->hint.maxa > 0) {
|
||||||
if (cc->hint.maxa <
|
if (cc->hint.maxa <
|
||||||
(float)cc->geom.width / cc->geom.height)
|
(float)cc->geom.w / cc->geom.h)
|
||||||
cc->geom.width = cc->geom.height * cc->hint.maxa;
|
cc->geom.w = cc->geom.h * cc->hint.maxa;
|
||||||
else if (cc->hint.mina <
|
else if (cc->hint.mina <
|
||||||
(float)cc->geom.height / cc->geom.width)
|
(float)cc->geom.h / cc->geom.w)
|
||||||
cc->geom.height = cc->geom.width * cc->hint.mina;
|
cc->geom.h = cc->geom.w * cc->hint.mina;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove base dimensions for increment */
|
/* remove base dimensions for increment */
|
||||||
if (baseismin) {
|
if (baseismin) {
|
||||||
cc->geom.width -= cc->hint.basew;
|
cc->geom.w -= cc->hint.basew;
|
||||||
cc->geom.height -= cc->hint.baseh;
|
cc->geom.h -= cc->hint.baseh;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* adjust for increment value */
|
/* adjust for increment value */
|
||||||
cc->geom.width -= cc->geom.width % cc->hint.incw;
|
cc->geom.w -= cc->geom.w % cc->hint.incw;
|
||||||
cc->geom.height -= cc->geom.height % cc->hint.inch;
|
cc->geom.h -= cc->geom.h % cc->hint.inch;
|
||||||
|
|
||||||
/* restore base dimensions */
|
/* restore base dimensions */
|
||||||
cc->geom.width += cc->hint.basew;
|
cc->geom.w += cc->hint.basew;
|
||||||
cc->geom.height += cc->hint.baseh;
|
cc->geom.h += cc->hint.baseh;
|
||||||
|
|
||||||
/* adjust for min width/height */
|
/* adjust for min width/height */
|
||||||
cc->geom.width = MAX(cc->geom.width, cc->hint.minw);
|
cc->geom.w = MAX(cc->geom.w, cc->hint.minw);
|
||||||
cc->geom.height = MAX(cc->geom.height, cc->hint.minh);
|
cc->geom.h = MAX(cc->geom.h, cc->hint.minh);
|
||||||
|
|
||||||
/* adjust for max width/height */
|
/* adjust for max width/height */
|
||||||
if (cc->hint.maxw)
|
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)
|
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
|
static void
|
||||||
@ -883,8 +883,8 @@ client_transient(struct client_ctx *cc)
|
|||||||
static int
|
static int
|
||||||
client_inbound(struct client_ctx *cc, int x, int y)
|
client_inbound(struct client_ctx *cc, int x, int y)
|
||||||
{
|
{
|
||||||
return (x < cc->geom.width && x >= 0 &&
|
return (x < cc->geom.w && x >= 0 &&
|
||||||
y < cc->geom.height && y >= 0);
|
y < cc->geom.h && y >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
28
kbfunc.c
28
kbfunc.c
@ -88,22 +88,22 @@ kbfunc_moveresize(struct client_ctx *cc, union arg *arg)
|
|||||||
switch (flags & TYPEMASK) {
|
switch (flags & TYPEMASK) {
|
||||||
case CWM_MOVE:
|
case CWM_MOVE:
|
||||||
cc->geom.y += my;
|
cc->geom.y += my;
|
||||||
if (cc->geom.y + cc->geom.height < 0)
|
if (cc->geom.y + cc->geom.h < 0)
|
||||||
cc->geom.y = -cc->geom.height;
|
cc->geom.y = -cc->geom.h;
|
||||||
if (cc->geom.y > sc->view.h - 1)
|
if (cc->geom.y > sc->view.h - 1)
|
||||||
cc->geom.y = sc->view.h - 1;
|
cc->geom.y = sc->view.h - 1;
|
||||||
|
|
||||||
cc->geom.x += mx;
|
cc->geom.x += mx;
|
||||||
if (cc->geom.x + cc->geom.width < 0)
|
if (cc->geom.x + cc->geom.w < 0)
|
||||||
cc->geom.x = -cc->geom.width;
|
cc->geom.x = -cc->geom.w;
|
||||||
if (cc->geom.x > sc->view.w - 1)
|
if (cc->geom.x > sc->view.w - 1)
|
||||||
cc->geom.x = sc->view.w - 1;
|
cc->geom.x = sc->view.w - 1;
|
||||||
|
|
||||||
cc->geom.x += client_snapcalc(cc->geom.x,
|
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->bwidth, Conf.snapdist);
|
||||||
cc->geom.y += client_snapcalc(cc->geom.y,
|
cc->geom.y += client_snapcalc(cc->geom.y,
|
||||||
cc->geom.height, sc->view.h,
|
cc->geom.h, sc->view.h,
|
||||||
cc->bwidth, Conf.snapdist);
|
cc->bwidth, Conf.snapdist);
|
||||||
|
|
||||||
client_move(cc);
|
client_move(cc);
|
||||||
@ -113,18 +113,18 @@ kbfunc_moveresize(struct client_ctx *cc, union arg *arg)
|
|||||||
client_ptrwarp(cc);
|
client_ptrwarp(cc);
|
||||||
break;
|
break;
|
||||||
case CWM_RESIZE:
|
case CWM_RESIZE:
|
||||||
if ((cc->geom.height += my) < 1)
|
if ((cc->geom.h += my) < 1)
|
||||||
cc->geom.height = 1;
|
cc->geom.h = 1;
|
||||||
if ((cc->geom.width += mx) < 1)
|
if ((cc->geom.w += mx) < 1)
|
||||||
cc->geom.width = 1;
|
cc->geom.w = 1;
|
||||||
client_resize(cc);
|
client_resize(cc);
|
||||||
|
|
||||||
/* Make sure the pointer stays within the window. */
|
/* Make sure the pointer stays within the window. */
|
||||||
xu_ptr_getpos(cc->win, &cc->ptr.x, &cc->ptr.y);
|
xu_ptr_getpos(cc->win, &cc->ptr.x, &cc->ptr.y);
|
||||||
if (cc->ptr.x > cc->geom.width)
|
if (cc->ptr.x > cc->geom.w)
|
||||||
cc->ptr.x = cc->geom.width - cc->bwidth;
|
cc->ptr.x = cc->geom.w - cc->bwidth;
|
||||||
if (cc->ptr.y > cc->geom.height)
|
if (cc->ptr.y > cc->geom.h)
|
||||||
cc->ptr.y = cc->geom.height - cc->bwidth;
|
cc->ptr.y = cc->geom.h - cc->bwidth;
|
||||||
client_ptrwarp(cc);
|
client_ptrwarp(cc);
|
||||||
break;
|
break;
|
||||||
case CWM_PTRMOVE:
|
case CWM_PTRMOVE:
|
||||||
|
30
mousefunc.c
30
mousefunc.c
@ -37,17 +37,17 @@ static void mousefunc_sweep_draw(struct client_ctx *);
|
|||||||
static int
|
static int
|
||||||
mousefunc_sweep_calc(struct client_ctx *cc, int x, int y, int mx, int my)
|
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.w = abs(x - mx) - cc->bwidth;
|
||||||
cc->geom.height = abs(y - my) - cc->bwidth;
|
cc->geom.h = abs(y - my) - cc->bwidth;
|
||||||
|
|
||||||
client_applysizehints(cc);
|
client_applysizehints(cc);
|
||||||
|
|
||||||
cc->geom.x = x <= mx ? x : x - cc->geom.width;
|
cc->geom.x = x <= mx ? x : x - cc->geom.w;
|
||||||
cc->geom.y = y <= my ? y : y - cc->geom.height;
|
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
|
static void
|
||||||
@ -58,8 +58,8 @@ mousefunc_sweep_draw(struct client_ctx *cc)
|
|||||||
int width, width_size, width_name;
|
int width, width_size, width_name;
|
||||||
|
|
||||||
(void)snprintf(asize, sizeof(asize), "%dx%d",
|
(void)snprintf(asize, sizeof(asize), "%dx%d",
|
||||||
(cc->geom.width - cc->hint.basew) / cc->hint.incw,
|
(cc->geom.w - cc->hint.basew) / cc->hint.incw,
|
||||||
(cc->geom.height - cc->hint.baseh) / cc->hint.inch);
|
(cc->geom.h - cc->hint.baseh) / cc->hint.inch);
|
||||||
width_size = font_width(sc, asize, strlen(asize)) + 4;
|
width_size = font_width(sc, asize, strlen(asize)) + 4;
|
||||||
width_name = font_width(sc, cc->name, strlen(cc->name)) + 4;
|
width_name = font_width(sc, cc->name, strlen(cc->name)) + 4;
|
||||||
width = MAX(width_size, width_name);
|
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)
|
if (xu_ptr_grab(cc->win, MOUSEMASK, Cursor_resize) < 0)
|
||||||
return;
|
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);
|
mousefunc_sweep_draw(cc);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -121,10 +121,10 @@ mousefunc_window_resize(struct client_ctx *cc, void *arg)
|
|||||||
xu_ptr_ungrab();
|
xu_ptr_ungrab();
|
||||||
|
|
||||||
/* Make sure the pointer stays within the window. */
|
/* Make sure the pointer stays within the window. */
|
||||||
if (cc->ptr.x > cc->geom.width)
|
if (cc->ptr.x > cc->geom.w)
|
||||||
cc->ptr.x = cc->geom.width - cc->bwidth;
|
cc->ptr.x = cc->geom.w - cc->bwidth;
|
||||||
if (cc->ptr.y > cc->geom.height)
|
if (cc->ptr.y > cc->geom.h)
|
||||||
cc->ptr.y = cc->geom.height - cc->bwidth;
|
cc->ptr.y = cc->geom.h - cc->bwidth;
|
||||||
client_ptrwarp(cc);
|
client_ptrwarp(cc);
|
||||||
return;
|
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.y = ev.xmotion.y_root - py - cc->bwidth;
|
||||||
|
|
||||||
cc->geom.x += client_snapcalc(cc->geom.x,
|
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->bwidth, Conf.snapdist);
|
||||||
cc->geom.y += client_snapcalc(cc->geom.y,
|
cc->geom.y += client_snapcalc(cc->geom.y,
|
||||||
cc->geom.height, sc->view.h,
|
cc->geom.h, sc->view.h,
|
||||||
cc->bwidth, Conf.snapdist);
|
cc->bwidth, Conf.snapdist);
|
||||||
|
|
||||||
/* don't move more than 60 times / second */
|
/* don't move more than 60 times / second */
|
||||||
|
12
xevents.c
12
xevents.c
@ -141,9 +141,9 @@ xev_handle_configurerequest(XEvent *ee)
|
|||||||
sc = cc->sc;
|
sc = cc->sc;
|
||||||
|
|
||||||
if (e->value_mask & CWWidth)
|
if (e->value_mask & CWWidth)
|
||||||
cc->geom.width = e->width;
|
cc->geom.w = e->width;
|
||||||
if (e->value_mask & CWHeight)
|
if (e->value_mask & CWHeight)
|
||||||
cc->geom.height = e->height;
|
cc->geom.h = e->height;
|
||||||
if (e->value_mask & CWX)
|
if (e->value_mask & CWX)
|
||||||
cc->geom.x = e->x;
|
cc->geom.x = e->x;
|
||||||
if (e->value_mask & CWY)
|
if (e->value_mask & CWY)
|
||||||
@ -151,16 +151,16 @@ xev_handle_configurerequest(XEvent *ee)
|
|||||||
if (e->value_mask & CWBorderWidth)
|
if (e->value_mask & CWBorderWidth)
|
||||||
wc.border_width = e->border_width;
|
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;
|
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;
|
cc->geom.y -= cc->bwidth;
|
||||||
|
|
||||||
wc.x = cc->geom.x;
|
wc.x = cc->geom.x;
|
||||||
wc.y = cc->geom.y;
|
wc.y = cc->geom.y;
|
||||||
wc.width = cc->geom.width;
|
wc.width = cc->geom.w;
|
||||||
wc.height = cc->geom.height;
|
wc.height = cc->geom.h;
|
||||||
wc.border_width = cc->bwidth;
|
wc.border_width = cc->bwidth;
|
||||||
|
|
||||||
XConfigureWindow(X_Dpy, cc->win, e->value_mask, &wc);
|
XConfigureWindow(X_Dpy, cc->win, e->value_mask, &wc);
|
||||||
|
4
xutil.c
4
xutil.c
@ -128,8 +128,8 @@ xu_configure(struct client_ctx *cc)
|
|||||||
ce.window = cc->win;
|
ce.window = cc->win;
|
||||||
ce.x = cc->geom.x;
|
ce.x = cc->geom.x;
|
||||||
ce.y = cc->geom.y;
|
ce.y = cc->geom.y;
|
||||||
ce.width = cc->geom.width;
|
ce.width = cc->geom.w;
|
||||||
ce.height = cc->geom.height;
|
ce.height = cc->geom.h;
|
||||||
ce.border_width = cc->bwidth;
|
ce.border_width = cc->bwidth;
|
||||||
ce.above = None;
|
ce.above = None;
|
||||||
ce.override_redirect = 0;
|
ce.override_redirect = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user