cvsimport

* refs/heads/master:
  drop obsolete comment
  Alter callbacks to take a struct instead of a growing number of arguments; greatly simplifies upcoming work.
  Ensure clients stay within the viewable bounds on placement, even with empty borders; based on a patch from Vadim Vygonets.
  Clean up, unify and accurately calculate edge distance with client move/resize actions, so as to not lose windows off the edge.
  Switch bwidth type; unfortunately X11 is inconsistent.
This commit is contained in:
okan
2017-05-09 18:43:40 +00:00
7 changed files with 272 additions and 294 deletions

View File

@@ -470,6 +470,24 @@ client_config(struct client_ctx *cc)
XSendEvent(X_Dpy, cc->win, False, StructureNotifyMask, (XEvent *)&cn);
}
void
client_ptr_inbound(struct client_ctx *cc, int getpos)
{
if (getpos)
xu_ptr_getpos(cc->win, &cc->ptr.x, &cc->ptr.y);
if (cc->ptr.x < 0)
cc->ptr.x = 0;
else if (cc->ptr.x > cc->geom.w - 1)
cc->ptr.x = cc->geom.w - 1;
if (cc->ptr.y < 0)
cc->ptr.y = 0;
else if (cc->ptr.y > cc->geom.h - 1)
cc->ptr.y = cc->geom.h - 1;
client_ptrwarp(cc);
}
void
client_ptrwarp(struct client_ctx *cc)
{
@@ -545,7 +563,7 @@ client_draw_border(struct client_ctx *cc)
if (cc->flags & CLIENT_URGENCY)
pixel = sc->xftcolor[CWM_COLOR_BORDER_URGENCY].pixel;
XSetWindowBorderWidth(X_Dpy, cc->win, cc->bwidth);
XSetWindowBorderWidth(X_Dpy, cc->win, (unsigned int)cc->bwidth);
XSetWindowBorder(X_Dpy, cc->win, pixel);
}
@@ -743,14 +761,14 @@ client_placecalc(struct client_ctx *cc)
wmax = DisplayWidth(X_Dpy, sc->which);
hmax = DisplayHeight(X_Dpy, sc->which);
if (cc->geom.x + ((int)cc->bwidth * 2) >= wmax)
cc->geom.x = wmax - (cc->bwidth * 2);
if (cc->geom.x + cc->geom.w - ((int)cc->bwidth * 2) < 0)
cc->geom.x = -cc->geom.w;
if (cc->geom.y + ((int)cc->bwidth * 2) >= hmax)
cc->geom.y = hmax - (cc->bwidth * 2);
if (cc->geom.y + cc->geom.h - ((int)cc->bwidth * 2) < 0)
cc->geom.y = -cc->geom.h;
if (cc->geom.x >= wmax)
cc->geom.x = wmax - cc->bwidth - 1;
if (cc->geom.x + cc->geom.w + cc->bwidth <= 0)
cc->geom.x = -(cc->geom.w + cc->bwidth - 1);
if (cc->geom.y >= hmax)
cc->geom.x = hmax - cc->bwidth - 1;
if (cc->geom.y + cc->geom.h + cc->bwidth <= 0)
cc->geom.y = -(cc->geom.h + cc->bwidth - 1);
} else {
struct geom area;
int xmouse, ymouse;