From: Dana Jansens Date: Fri, 8 Jan 2010 14:04:25 +0000 (-0500) Subject: make Home and End keys navigate to top/bottom of the active menu X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=bafd9e9edcff0e18a03ef6f4e73d673e12a7c7ed;p=chaz%2Fopenbox make Home and End keys navigate to top/bottom of the active menu --- diff --git a/openbox/event.c b/openbox/event.c index 58e947fa..2ebea6ba 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -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 diff --git a/openbox/menuframe.c b/openbox/menuframe.c index 3d2b4302..f013bdec 100644 --- a/openbox/menuframe.c +++ b/openbox/menuframe.c @@ -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); +} diff --git a/openbox/menuframe.h b/openbox/menuframe.h index 926b844e..da796d5b 100644 --- a/openbox/menuframe.h +++ b/openbox/menuframe.h @@ -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); diff --git a/openbox/misc.h b/openbox/misc.h index c1ec4075..68403f49 100644 --- a/openbox/misc.h +++ b/openbox/misc.h @@ -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; diff --git a/openbox/openbox.c b/openbox/openbox.c index 0e339782..415c1604 100644 --- a/openbox/openbox.c +++ b/openbox/openbox.c @@ -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);