summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--calmwm.c1
-rw-r--r--calmwm.h3
-rw-r--r--client.c11
-rw-r--r--kbfunc.c4
-rw-r--r--mousefunc.c4
-rw-r--r--xevents.c2
6 files changed, 16 insertions, 9 deletions
diff --git a/calmwm.c b/calmwm.c
index d1e4c1d..c20c018 100644
--- a/calmwm.c
+++ b/calmwm.c
@@ -37,6 +37,7 @@
 
 char				**cwm_argv;
 Display				*X_Dpy;
+Time				 Last_Event_Time = CurrentTime;
 Atom				 cwmh[CWMH_NITEMS];
 Atom				 ewmh[EWMH_NITEMS];
 
diff --git a/calmwm.h b/calmwm.h
index e79f522..f2294a9 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -328,6 +328,7 @@ struct mwm_hints {
 #define	MWM_DECOR_BORDER	(1<<1)
 
 extern Display				*X_Dpy;
+extern Time				 Last_Event_Time;
 extern struct screen_ctx_q		 Screenq;
 extern struct client_ctx_q		 Clientq;
 extern struct conf			 Conf;
@@ -393,7 +394,7 @@ void 			 client_htile(struct client_ctx *);
 void			 client_lower(struct client_ctx *);
 void			 client_map(struct client_ctx *);
 void			 client_maximize(struct client_ctx *);
-void			 client_msg(struct client_ctx *, Atom);
+void			 client_msg(struct client_ctx *, Atom, Time);
 void			 client_move(struct client_ctx *);
 struct client_ctx	*client_init(Window, struct screen_ctx *, int);
 void			 client_ptrsave(struct client_ctx *);
diff --git a/client.c b/client.c
index 71a03f2..5b59fd2 100644
--- a/client.c
+++ b/client.c
@@ -168,6 +168,9 @@ client_setactive(struct client_ctx *cc)
 	struct screen_ctx	*sc = cc->sc;
 	struct client_ctx	*oldcc;
 
+	if (cc->flags & CLIENT_HIDDEN)
+		return;
+
 	XInstallColormap(X_Dpy, cc->colormap);
 
 	if ((cc->flags & CLIENT_INPUT) ||
@@ -176,7 +179,7 @@ client_setactive(struct client_ctx *cc)
 		    RevertToPointerRoot, CurrentTime);
 	}
 	if (cc->flags & CLIENT_WM_TAKE_FOCUS)
-		client_msg(cc, cwmh[WM_TAKE_FOCUS]);
+		client_msg(cc, cwmh[WM_TAKE_FOCUS], Last_Event_Time);
 
 	if ((oldcc = client_current())) {
 		oldcc->active = 0;
@@ -511,7 +514,7 @@ client_wm_hints(struct client_ctx *cc)
 }
 
 void
-client_msg(struct client_ctx *cc, Atom proto)
+client_msg(struct client_ctx *cc, Atom proto, Time ts)
 {
 	XClientMessageEvent	 cm;
 
@@ -521,7 +524,7 @@ client_msg(struct client_ctx *cc, Atom proto)
 	cm.message_type = cwmh[WM_PROTOCOLS];
 	cm.format = 32;
 	cm.data.l[0] = proto;
-	cm.data.l[1] = CurrentTime;
+	cm.data.l[1] = ts;
 
 	XSendEvent(X_Dpy, cc->win, False, NoEventMask, (XEvent *)&cm);
 }
@@ -530,7 +533,7 @@ void
 client_send_delete(struct client_ctx *cc)
 {
 	if (cc->flags & CLIENT_WM_DELETE_WINDOW)
-		client_msg(cc, cwmh[WM_DELETE_WINDOW]);
+		client_msg(cc, cwmh[WM_DELETE_WINDOW], CurrentTime);
 	else
 		XKillClient(X_Dpy, cc->win);
 }
diff --git a/kbfunc.c b/kbfunc.c
index 22b6a68..cac97fe 100644
--- a/kbfunc.c
+++ b/kbfunc.c
@@ -101,10 +101,10 @@ kbfunc_client_moveresize(struct client_ctx *cc, union arg *arg)
 
 		cc->geom.x += client_snapcalc(cc->geom.x,
 		    cc->geom.x + cc->geom.w + (cc->bwidth * 2),
-		    sc->work.x, sc->work.w, sc->snapdist);
+		    sc->work.x, sc->work.x + sc->work.w, sc->snapdist);
 		cc->geom.y += client_snapcalc(cc->geom.y,
 		    cc->geom.y + cc->geom.h + (cc->bwidth * 2),
-		    sc->work.y, sc->work.h, sc->snapdist);
+		    sc->work.y, sc->work.y + sc->work.h, sc->snapdist);
 
 		client_move(cc);
 		xu_ptr_getpos(cc->win, &x, &y);
diff --git a/mousefunc.c b/mousefunc.c
index 65efa35..f4bbae1 100644
--- a/mousefunc.c
+++ b/mousefunc.c
@@ -147,10 +147,10 @@ mousefunc_client_move(struct client_ctx *cc, void *arg)
 
 			cc->geom.x += client_snapcalc(cc->geom.x,
 			    cc->geom.x + cc->geom.w + (cc->bwidth * 2),
-			    sc->work.x, sc->work.w, sc->snapdist);
+			    sc->work.x, sc->work.x + sc->work.w, sc->snapdist);
 			cc->geom.y += client_snapcalc(cc->geom.y,
 			    cc->geom.y + cc->geom.h + (cc->bwidth * 2),
-			    sc->work.y, sc->work.h, sc->snapdist);
+			    sc->work.y, sc->work.y + sc->work.h, sc->snapdist);
 
 			/* don't move more than 60 times / second */
 			if ((ev.xmotion.time - ltime) > (1000 / 60)) {
diff --git a/xevents.c b/xevents.c
index fe6192d..e7eca18 100644
--- a/xevents.c
+++ b/xevents.c
@@ -212,6 +212,8 @@ xev_handle_enternotify(XEvent *ee)
 	XCrossingEvent		*e = &ee->xcrossing;
 	struct client_ctx	*cc;
 
+	Last_Event_Time = e->time;
+
 	if ((cc = client_find(e->window)) != NULL)
 		client_setactive(cc);
 }