]> Dogcows Code - chaz/openbox/blobdiff - openbox/event.c
only fallback when nothing is focused, provide comment explaining why
[chaz/openbox] / openbox / event.c
index 14afeabaf8c8df7252714632a54ca1425298f324..918024969f4cda9387894703c7b82e2594fef37c 100644 (file)
@@ -1166,14 +1166,25 @@ static void event_handle_dockapp(ObDockApp *app, XEvent *e)
 ObMenuFrame* find_active_menu()
 {
     GList *it;
-    ObMenuFrame *f;
+    ObMenuFrame *ret = NULL;
 
     for (it = menu_frame_visible; it; it = g_list_next(it)) {
-        f = it->data;
-        if (f->selected)
+        ret = it->data;
+        if (ret->selected)
             break;
+        ret = NULL;
     }
-    return it ? it->data : NULL;
+    return ret;
+}
+
+ObMenuFrame* find_active_or_last_menu()
+{
+    ObMenuFrame *ret = NULL;
+
+    ret = find_active_menu();
+    if (!ret && menu_frame_visible)
+        ret = menu_frame_visible->data;
+    return ret;
 }
 
 static void event_handle_menu(XEvent *ev)
@@ -1219,19 +1230,19 @@ static void event_handle_menu(XEvent *ev)
                 menu_entry_frame_execute(f->selected, ev->xkey.state);
         } else if (ev->xkey.keycode == ob_keycode(OB_KEY_LEFT)) {
             ObMenuFrame *f;
-            if ((f = find_active_menu()) && f->parent)
+            if ((f = find_active_or_last_menu()) && f->parent)
                 menu_frame_select(f, NULL);
         } else if (ev->xkey.keycode == ob_keycode(OB_KEY_RIGHT)) {
             ObMenuFrame *f;
-            if ((f = find_active_menu()) && f->child)
+            if ((f = find_active_or_last_menu()) && f->child)
                 menu_frame_select_next(f->child);
         } else if (ev->xkey.keycode == ob_keycode(OB_KEY_UP)) {
             ObMenuFrame *f;
-            if ((f = find_active_menu()))
+            if ((f = find_active_or_last_menu()))
                 menu_frame_select_previous(f);
         } else if (ev->xkey.keycode == ob_keycode(OB_KEY_DOWN)) {
             ObMenuFrame *f;
-            if ((f = find_active_menu()))
+            if ((f = find_active_or_last_menu()))
                 menu_frame_select_next(f);
         }
         break;
@@ -1248,9 +1259,11 @@ static gboolean focus_delay_func(gpointer data)
 {
     ObClient *c = data;
 
-    client_focus(c);
-    if (config_focus_raise)
-        client_raise(c);
+    if (focus_client != c) {
+        client_focus(c);
+        if (config_focus_raise)
+            client_raise(c);
+    }
     return FALSE; /* no repeat */
 }
 
This page took 0.024178 seconds and 4 git commands to generate.