summary refs log tree commit diff
path: root/xevents.c
diff options
context:
space:
mode:
authorokan <okan>2013-11-27 00:01:23 +0000
committerokan <okan>2013-11-27 00:01:23 +0000
commitfa25915a75551c36495c8a0fa2754ac3091c529e (patch)
tree33848b2566de918ee7f1165f662918359811d3fc /xevents.c
parent03b19f1487135d8e8a80e0aad5aef447776c7c11 (diff)
downloadcwm-fa25915a75551c36495c8a0fa2754ac3091c529e.tar.gz
cwm-fa25915a75551c36495c8a0fa2754ac3091c529e.tar.xz
cwm-fa25915a75551c36495c8a0fa2754ac3091c529e.zip
Rewrite active/inactive client handling in client_setactive();
client_leave() served no real purpose, likewise no reason to handle
LeaveNotify events since an EnterNotify will process the next active
client (and we don't have anything important to process anyway), so
xev_handle_leavenotify() goes as well.  Allows a simplification of
client_mtf() and client_cycle_leave() for clarity.  While here, unify a
few client_current() checks.

No intended behaviour change.
Diffstat (limited to 'xevents.c')
-rw-r--r--xevents.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/xevents.c b/xevents.c
index 8c07f39..a1fe019 100644
--- a/xevents.c
+++ b/xevents.c
@@ -43,7 +43,6 @@ static void	 xev_handle_destroynotify(XEvent *);
 static void	 xev_handle_configurerequest(XEvent *);
 static void	 xev_handle_propertynotify(XEvent *);
 static void	 xev_handle_enternotify(XEvent *);
-static void	 xev_handle_leavenotify(XEvent *);
 static void	 xev_handle_buttonpress(XEvent *);
 static void	 xev_handle_buttonrelease(XEvent *);
 static void	 xev_handle_keypress(XEvent *);
@@ -60,7 +59,6 @@ void		(*xev_handlers[LASTEvent])(XEvent *) = {
 			[ConfigureRequest] = xev_handle_configurerequest,
 			[PropertyNotify] = xev_handle_propertynotify,
 			[EnterNotify] = xev_handle_enternotify,
-			[LeaveNotify] = xev_handle_leavenotify,
 			[ButtonPress] = xev_handle_buttonpress,
 			[ButtonRelease] = xev_handle_buttonrelease,
 			[KeyPress] = xev_handle_keypress,
@@ -81,7 +79,7 @@ xev_handle_maprequest(XEvent *ee)
 	struct client_ctx	*cc = NULL, *old_cc;
 	XWindowAttributes	 xattr;
 
-	if ((old_cc = client_current()) != NULL)
+	if ((old_cc = client_current()))
 		client_ptrsave(old_cc);
 
 	if ((cc = client_find(e->window)) == NULL) {
@@ -211,13 +209,7 @@ xev_handle_enternotify(XEvent *ee)
 	struct client_ctx	*cc;
 
 	if ((cc = client_find(e->window)) != NULL)
-		client_setactive(cc, 1);
-}
-
-static void
-xev_handle_leavenotify(XEvent *ee)
-{
-	client_leave(NULL);
+		client_setactive(cc);
 }
 
 /* We can split this into two event handlers. */
@@ -256,7 +248,7 @@ xev_handle_buttonrelease(XEvent *ee)
 {
 	struct client_ctx *cc;
 
-	if ((cc = client_current()) != NULL)
+	if ((cc = client_current()))
 		group_sticky_toggle_exit(cc);
 }
 
@@ -311,17 +303,15 @@ xev_handle_keyrelease(XEvent *ee)
 {
 	XKeyEvent		*e = &ee->xkey;
 	struct screen_ctx	*sc;
-	struct client_ctx	*cc;
 	KeySym			 keysym;
 	u_int			 i;
 
 	sc = screen_fromroot(e->root);
-	cc = client_current();
 
 	keysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 0);
 	for (i = 0; i < nitems(modkeys); i++) {
 		if (keysym == modkeys[i]) {
-			client_cycle_leave(sc, cc);
+			client_cycle_leave(sc);
 			break;
 		}
 	}
@@ -344,8 +334,7 @@ xev_handle_clientmessage(XEvent *ee)
 		client_send_delete(cc);
 
 	if (e->message_type == ewmh[_NET_ACTIVE_WINDOW] && e->format == 32) {
-		old_cc = client_current();
-		if (old_cc)
+		if ((old_cc = client_current()))
 			client_ptrsave(old_cc);
 		client_ptrwarp(cc);
 	}