Crazy focus model.
authorMikael Magnusson <mikachu@gmail.com>
Fri, 8 Jan 2010 17:06:56 +0000 (18:06 +0100)
committerMikael Magnusson <mikachu@gmail.com>
Sun, 19 Sep 2010 15:55:23 +0000 (17:55 +0200)
openbox/event.c

index 35bbbba2ebd0cfcf1f90ae505af840df82d7f8f3..4ab0a1c59926dd11bbb98525aa9a69d3c82f222c 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;
@@ -811,7 +813,7 @@ void event_enter_client(ObClient *client)
         return;
     }
 
-    if (client_enter_focusable(client) && client_can_focus(client)) {
+    if (client_enter_focusable(client) && client_can_focus(client) && (!config_focus_delay || event_time_after(client_left_focused, event_curtime - config_focus_delay /*milliseconds here, so not *1000 */))) {
         if (config_focus_delay) {
             ObFocusDelayData *data;
 
@@ -1079,6 +1081,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: