about summary refs log tree commit diff
path: root/client.c
diff options
context:
space:
mode:
authorokan <okan>2017-05-09 18:43:40 +0000
committerokan <okan>2017-05-09 18:43:40 +0000
commit4040f112e11c844e1226ac5c66c4da6e8ae72cc6 (patch)
tree76fd974d7eecc253a91f330b4fccbe457d27281b /client.c
parenta8527b56612b69f32906ea4547f08b99ae57e4d9 (diff)
parent16a2ccc225dc002e87f8f88481cbb8dc669a3d3e (diff)
downloadcwm-4040f112e11c844e1226ac5c66c4da6e8ae72cc6.tar.gz
cwm-4040f112e11c844e1226ac5c66c4da6e8ae72cc6.tar.xz
cwm-4040f112e11c844e1226ac5c66c4da6e8ae72cc6.zip
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.
Diffstat (limited to 'client.c')
-rw-r--r--client.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/client.c b/client.c
index ae522e3..6a66847 100644
--- a/client.c
+++ b/client.c
@@ -471,6 +471,24 @@ client_config(struct client_ctx *cc)
 }
 
 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)
 {
 	xu_ptr_setpos(cc->win, cc->ptr.x, cc->ptr.y);
@@ -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;