Crazy focus model.
authorMikael Magnusson <mikachu@gmail.com>
Fri, 8 Jan 2010 17:06:56 +0000 (18:06 +0100)
committerMikael Magnusson <mikachu@gmail.com>
Sat, 11 Oct 2014 00:17:20 +0000 (02:17 +0200)
openbox/event.c

index 16bc56b..9a2e844 100644 (file)
@@ -105,6 +105,8 @@ static Time event_curtime = CurrentTime;
 /*! The source time that started the current X event (user-provided, so not
   to be trusted) */
 static Time event_sourcetime = CurrentTime;
+/*! Last time the cursor moved out of the focused window */
+static Time client_left_focused = CurrentTime;
 
 /*! The serial of the current X event */
 static gulong event_curserial;
@@ -824,7 +826,7 @@ void event_enter_client(ObClient *client)
     ob_debug_type(OB_DEBUG_FOCUS, "using enter event with serial %lu "
                   "on client 0x%x", event_curserial, client->window);
 
-    if (client_enter_focusable(client) && client_can_focus(client)) {
+    if (client_enter_focusable(client) && client_can_focus(client) && (!config_focus_delay || (!client_left_focused || event_time_after(client_left_focused, event_curtime - config_focus_delay /*milliseconds here, so not *1000 */)))) {
         if (config_focus_delay) {
             ObFocusDelayData *data;
 
@@ -1092,6 +1094,8 @@ static void event_handle_client(ObClient *client, XEvent *e)
                     g_source_remove(focus_delay_timeout_id);
                 if (config_unfocus_leave)
                     event_leave_client(client);
+                else if (client == focus_client)
+                    client_left_focused = e->xcrossing.time;
             }
             break;
         default: