summary refs log tree commit diff
path: root/client.c
diff options
context:
space:
mode:
authorokan <okan>2016-09-30 20:55:54 +0000
committerokan <okan>2016-09-30 20:55:54 +0000
commit1c54fc079dab7dcc56d057f40be01fb1f3a21c2a (patch)
treeafe86343169e91e6f3e9a75ee366f4752582232a /client.c
parent2d8f621b8d285b1cf8e29feb383fa2268e57ee5a (diff)
downloadcwm-1c54fc079dab7dcc56d057f40be01fb1f3a21c2a.tar.gz
cwm-1c54fc079dab7dcc56d057f40be01fb1f3a21c2a.tar.xz
cwm-1c54fc079dab7dcc56d057f40be01fb1f3a21c2a.zip
Set the initial ptr position during client init, instead of waiting
until (maybe) a ptrwarp call. Likewise, explicitly ensure an inbounds ptr
position (same as initial) when saving.
Diffstat (limited to 'client.c')
-rw-r--r--client.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/client.c b/client.c
index 9fb097a..6e91ea5 100644
--- a/client.c
+++ b/client.c
@@ -75,8 +75,6 @@ client_init(Window win, struct screen_ctx *sc, int active)
 	cc->stackingorder = 0;
 	memset(&cc->hint, 0, sizeof(cc->hint));
 	memset(&cc->ch, 0, sizeof(cc->ch));
-	cc->ptr.x = -1;
-	cc->ptr.y = -1;
 
 	TAILQ_INIT(&cc->nameq);
 	client_setname(cc);
@@ -93,6 +91,9 @@ client_init(Window win, struct screen_ctx *sc, int active)
 	cc->geom.y = wattr.y;
 	cc->geom.w = wattr.width;
 	cc->geom.h = wattr.height;
+	cc->ptr.x = cc->geom.w / 2;
+	cc->ptr.y = cc->geom.h / 2;
+
 	cc->colormap = wattr.colormap;
 
 	if (wattr.map_state != IsViewable) {
@@ -468,18 +469,12 @@ client_config(struct client_ctx *cc)
 void
 client_ptrwarp(struct client_ctx *cc)
 {
-	int	 x = cc->ptr.x, y = cc->ptr.y;
-
-	if (x == -1 || y == -1) {
-		x = cc->geom.w / 2;
-		y = cc->geom.h / 2;
-	}
-
 	if (cc->flags & CLIENT_HIDDEN)
 		client_unhide(cc);
 	else
 		client_raise(cc);
-	xu_ptr_setpos(cc->win, x, y);
+
+	xu_ptr_setpos(cc->win, cc->ptr.x, cc->ptr.y);
 }
 
 void
@@ -492,8 +487,8 @@ client_ptrsave(struct client_ctx *cc)
 		cc->ptr.x = x;
 		cc->ptr.y = y;
 	} else {
-		cc->ptr.x = -1;
-		cc->ptr.y = -1;
+		cc->ptr.x = cc->geom.w / 2;
+		cc->ptr.y = cc->geom.h / 2;
 	}
 }