]> Dogcows Code - chaz/openbox/commitdiff
make Home and End keys navigate to top/bottom of the active menu
authorDana Jansens <danakj@orodu.net>
Fri, 8 Jan 2010 14:04:25 +0000 (09:04 -0500)
committerDana Jansens <danakj@orodu.net>
Fri, 8 Jan 2010 14:04:25 +0000 (09:04 -0500)
openbox/event.c
openbox/menuframe.c
openbox/menuframe.h
openbox/misc.h
openbox/openbox.c

index 58e947fa1385fb152622d2be38f71112dfc91f1e..2ebea6bacd7ceea6b02ae7db4a9fde50d2875acf 100644 (file)
@@ -1729,6 +1729,16 @@ static gboolean event_handle_menu_keyboard(XEvent *ev)
             menu_frame_select_next(frame);
             ret = TRUE;
         }
+
+        else if (ob_keycode_match(keycode, OB_KEY_HOME)) {
+            menu_frame_select_first(frame);
+            ret = TRUE;
+        }
+
+        else if (ob_keycode_match(keycode, OB_KEY_END)) {
+            menu_frame_select_last(frame);
+            ret = TRUE;
+        }
     }
 
     /* Use KeyRelease events for running things so that the key release doesn't
index 3d2b4302c67efbec266bbe35202dcb890218d255..f013bdec345dae4fbf0338eefd3d06686d0883f4 100644 (file)
@@ -1316,3 +1316,35 @@ void menu_frame_select_next(ObMenuFrame *self)
     }
     menu_frame_select(self, it ? it->data : NULL, FALSE);
 }
+
+void menu_frame_select_first(ObMenuFrame *self)
+{
+    GList *it = NULL;
+
+    if (self->entries) {
+        for (it = self->entries; it; it = g_list_next(it)) {
+            ObMenuEntryFrame *e = it->data;
+            if (e->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU)
+                break;
+            if (e->entry->type == OB_MENU_ENTRY_TYPE_NORMAL)
+                break;
+        }
+    }
+    menu_frame_select(self, it ? it->data : NULL, FALSE);
+}
+
+void menu_frame_select_last(ObMenuFrame *self)
+{
+    GList *it = NULL;
+
+    if (self->entries) {
+        for (it = g_list_last(self->entries); it; it = g_list_previous(it)) {
+            ObMenuEntryFrame *e = it->data;
+            if (e->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU)
+                break;
+            if (e->entry->type == OB_MENU_ENTRY_TYPE_NORMAL)
+                break;
+        }
+    }
+    menu_frame_select(self, it ? it->data : NULL, FALSE);
+}
index 926b844e815414c4784e61f7031e5fe8f5f114a2..da796d5bfed5db11ab80a378eeb29c984bf524ec 100644 (file)
@@ -127,6 +127,8 @@ void menu_frame_select(ObMenuFrame *self, ObMenuEntryFrame *entry,
                        gboolean immediate);
 void menu_frame_select_previous(ObMenuFrame *self);
 void menu_frame_select_next(ObMenuFrame *self);
+void menu_frame_select_first(ObMenuFrame *self);
+void menu_frame_select_last(ObMenuFrame *self);
 
 ObMenuFrame* menu_frame_under(gint x, gint y);
 ObMenuEntryFrame* menu_entry_frame_under(gint x, gint y);
index c1ec4075f1c76a00577edf555425dc673a1add37..68403f49c727e3d79196249d660dfeb35be0e642 100644 (file)
@@ -53,6 +53,8 @@ typedef enum
     OB_KEY_DOWN,
     OB_KEY_TAB,
     OB_KEY_SPACE,
+    OB_KEY_HOME,
+    OB_KEY_END,
     OB_NUM_KEYS
 } ObKey;
 
index 0e3397827f1fbac79206ffd41abeda4de12d2487..415c16040028eb2f0476b2b0063080725d81bc13 100644 (file)
@@ -239,6 +239,8 @@ gint main(gint argc, gchar **argv)
             keys[OB_KEY_DOWN] = modkeys_sym_to_code(XK_Down);
             keys[OB_KEY_TAB] = modkeys_sym_to_code(XK_Tab);
             keys[OB_KEY_SPACE] = modkeys_sym_to_code(XK_space);
+            keys[OB_KEY_HOME] = modkeys_sym_to_code(XK_Home);
+            keys[OB_KEY_END] = modkeys_sym_to_code(XK_End);
 
             {
                 ObParseInst *i;
@@ -427,6 +429,8 @@ gint main(gint argc, gchar **argv)
             g_free(keys[OB_KEY_DOWN]);
             g_free(keys[OB_KEY_TAB]);
             g_free(keys[OB_KEY_SPACE]);
+            g_free(keys[OB_KEY_HOME]);
+            g_free(keys[OB_KEY_END]);
 
             modkeys_shutdown(reconfigure);
         } while (reconfigure);
This page took 0.033194 seconds and 4 git commands to generate.