Index: src/core/window.c
===================================================================
--- src/core/window.c	(revision 4129)
+++ src/core/window.c	(working copy)
@@ -1884,8 +1884,17 @@ intervening_user_event_occurred (MetaWin
    * launched, and _NET_WM_USER_TIME is the value that should be
    * used in the comparison.
    */
-  compare = window->initial_timestamp_set ? window->initial_timestamp : 0;
-  compare = window->net_wm_user_time_set  ? window->net_wm_user_time  : compare;
+  compare = 0;
+  if (window->net_wm_user_time_set &&
+      window->initial_timestamp_set)
+    compare =
+      XSERVER_TIME_IS_BEFORE (window->net_wm_user_time,
+                              window->initial_timestamp) ?
+      window->initial_timestamp : window->net_wm_user_time;
+  else if (window->net_wm_user_time_set)
+    compare = window->net_wm_user_time;
+  else if (window->initial_timestamp_set)
+    compare = window->initial_timestamp;
 
   if ((focus_window != NULL) &&
       XSERVER_TIME_IS_BEFORE (compare, focus_window->net_wm_user_time))
