]> Dogcows Code - chaz/openbox/blobdiff - openbox/event.c
unhilite windows correctly, forget how to break it without this :) what can i say...
[chaz/openbox] / openbox / event.c
index eff9d5907b256fe2c3597931086711cfa1fea60e..1d19a284598be92ab4ccdf097a4a1cef6eebcca4 100644 (file)
@@ -321,29 +321,52 @@ static void event_client_dest(ObClient *client, gpointer data)
         focus_in = NULL;
     if (client == focus_out)
         focus_out = NULL;
+    if (client == focus_hilite)
+        focus_hilite = NULL;
 }
 
 static void event_done(gpointer data)
 {
     static ObClient *last = NULL;
 
+    /* sometimes focus_hilite can be on an unfocused window, this make sure
+       it loses its focus hilite when focus moves */
+    if (focus_hilite &&
+        (focus_in && focus_hilite != focus_in) &&
+        (focus_out && focus_hilite != focus_out))
+    {
+        frame_adjust_focus(focus_hilite->frame, FALSE);
+    }
+
     if (focus_in) {
         if (focus_in != focus_client) {
             focus_set_client(focus_in);
             frame_adjust_focus(focus_in->frame, TRUE);
             client_calc_layer(focus_in);
         }
+
+        focus_hilite = focus_in;
     } 
     if (focus_out) {
         if (focus_out == focus_client)
             focus_set_client(NULL);
         frame_adjust_focus(focus_out->frame, FALSE);
         client_calc_layer(focus_out);
+
+        if (!focus_in)
+            focus_hilite = NULL;
     }
 
     if (focus_client != last) {
-        if (!focus_client)
-            focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS);
+        if (!focus_client) {
+            Window w;
+            int r;
+
+            /* is focus anywhere valid? */
+            XGetInputFocus(ob_display, &w, &r);
+            if (!w || w == RootWindow(ob_display, ob_screen))
+                focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS);
+        }
         last = focus_client;
     }
 
@@ -452,11 +475,9 @@ static void event_process(const XEvent *ec, gpointer data)
                     e->type == MotionNotify)
                     mouse_event(client, e);
                 else if (e->type == KeyPress)
-                    /* when in the middle of a focus cycling action, this
-                       causes the window which appears to be focused to be
-                       the one on which the actions will be executed */
-                    keyboard_event((focus_cycle_target ?
-                                    focus_cycle_target : client), e);
+                    keyboard_event((focus_cycle_target ? focus_cycle_target :
+                                    (focus_hilite ? focus_hilite : client)),
+                                   e);
             }
         }
     }
@@ -597,10 +618,10 @@ static void event_handle_client(ObClient *client, XEvent *e)
                  e->xfocus.window, client->window,
                  e->xfocus.mode, e->xfocus.detail);
 #endif
+        if (focus_hilite == client || focus_client == client)
+            focus_out = client;
         if (focus_in == client)
             focus_in = NULL;
-        if (client == focus_client)
-            focus_out = client;
         break;
     case LeaveNotify:
         con = frame_context(client, e->xcrossing.window);
@@ -626,12 +647,10 @@ static void event_handle_client(ObClient *client, XEvent *e)
             frame_adjust_state(client->frame);
             break;
         case OB_FRAME_CONTEXT_FRAME:
-            /*
-              if (config_focus_follow && config_focus_delay)
-              ob_main_loop_timeout_remove_data(ob_main_loop,
-              focus_delay_func,
-              client);
-            */
+            if (config_focus_follow && config_focus_delay)
+                ob_main_loop_timeout_remove_data(ob_main_loop,
+                                                 focus_delay_func,
+                                                 client);
             break;
         default:
             break;
@@ -1191,6 +1210,11 @@ static void focus_delay_client_dest(ObClient *client, gpointer data)
     ob_main_loop_timeout_remove_data(ob_main_loop, focus_delay_func, client);
 }
 
+void event_halt_focus_delay()
+{
+    ob_main_loop_timeout_remove(ob_main_loop, focus_delay_func);
+}
+
 void event_ignore_queued_enters()
 {
     GSList *saved = NULL, *it;
This page took 0.022391 seconds and 4 git commands to generate.