]> Dogcows Code - chaz/openbox/blobdiff - openbox/event.c
Keyboard navigatable menus
[chaz/openbox] / openbox / event.c
index d80f755c11212fca6420ecbbcbda987dc204c738..35d3472d7faac7994dc310fcf976018c4f2f1646 100644 (file)
@@ -449,7 +449,7 @@ static void event_process(XEvent *e)
     ObClient *client = NULL;
     ObDock *dock = NULL;
     ObDockApp *dockapp = NULL;
-    Menu *menu = NULL;
+    ObMenu *menu = NULL;
     ObWindow *obwin = NULL;
 
     window = event_get_window(e);
@@ -650,7 +650,7 @@ static void event_handle_client(ObClient *client, XEvent *e)
        break;
     case EnterNotify:
         if (client_normal(client)) {
-            if (ob_state == OB_STATE_STARTING) {
+            if (ob_state() == OB_STATE_STARTING) {
                 /* move it to the top of the focus order */
                 guint desktop = client->desktop;
                 if (desktop == DESKTOP_ALL) desktop = screen_desktop;
@@ -963,30 +963,40 @@ static void event_handle_client(ObClient *client, XEvent *e)
 
 static void event_handle_menu(ObClient *client, XEvent *e)
 {
-    static MenuEntry *over = NULL;
-    MenuEntry *entry;
-    Menu *top;
-    GSList *it;
+    static ObMenuEntry *over = NULL;
+    ObMenuEntry *entry;
+    ObMenu *top;
+    GList *it = NULL;
 
-    top = g_slist_nth_data(menu_visible, 0);
+    top = g_list_nth_data(menu_visible, 0);
 
     g_message("EVENT %d", e->type);
     switch (e->type) {
     case KeyPress:
-        if (over) {
-            if (over->parent->mouseover)
-                over->parent->mouseover(over, FALSE);
-            else
-                menu_control_mouseover(over, FALSE);
-            menu_entry_render(over);
-            over = NULL;
-        }
+        if (e->xkey.keycode == ob_keycode(OB_KEY_DOWN))
+            over = menu_control_keyboard_nav(over, OB_KEY_DOWN);
+        else if (e->xkey.keycode == ob_keycode(OB_KEY_UP))
+            over = menu_control_keyboard_nav(over, OB_KEY_UP);
+        else if (e->xkey.keycode == ob_keycode(OB_KEY_RETURN))
+            over = menu_control_keyboard_nav(over, OB_KEY_RETURN);
+        else if (e->xkey.keycode == ob_keycode(OB_KEY_ESCAPE))
+            over = menu_control_keyboard_nav(over, OB_KEY_ESCAPE);
+        else {
+            if (over) {
+                if (over->parent->mouseover)
+                    over->parent->mouseover(over, FALSE);
+                else
+                    menu_control_mouseover(over, FALSE);
+                menu_entry_render(over);
+                over = NULL;
+            }
 /*
-        if (top->hide)
-            top->hide(top);
-        else
+  if (top->hide)
+  top->hide(top);
+  else
 */
             menu_hide(top);
+        }
         break;
     case ButtonPress:
         if (e->xbutton.button > 3) break;
@@ -998,8 +1008,8 @@ static void event_handle_menu(ObClient *client, XEvent *e)
 
        g_message("BUTTON RELEASED");
 
-        for (it = menu_visible; it; it = g_slist_next(it)) {
-            Menu *m = it->data;
+        for (it = menu_visible; it; it = g_list_next(it)) {
+            ObMenu *m = it->data;
             if (e->xbutton.x_root >= m->location.x - ob_rr_theme->bwidth &&
                 e->xbutton.y_root >= m->location.y - ob_rr_theme->bwidth &&
                 e->xbutton.x_root < m->location.x + m->size.width +
@@ -1045,8 +1055,8 @@ static void event_handle_menu(ObClient *client, XEvent *e)
         break;
     case MotionNotify:
         g_message("motion");
-        for (it = menu_visible; it; it = g_slist_next(it)) {
-            Menu *m = it->data;
+        for (it = menu_visible; it; it = g_list_next(it)) {
+            ObMenu *m = it->data;
             if ((entry = menu_find_entry_by_pos(it->data,
                                                 e->xmotion.x_root -
                                                 m->location.x,
This page took 0.025507 seconds and 4 git commands to generate.