else if (ob_keycode_match(keycode, OB_KEY_LEFT)) {
/* Left goes to the parent menu */
- if (frame->parent)
+ if (frame->parent) {
+ /* remove focus from the child */
menu_frame_select(frame, NULL, TRUE);
+ /* and put it in the parent */
+ menu_frame_select(frame->parent, frame->parent->selected,
+ TRUE);
+ }
ret = TRUE;
}
else if (ob_keycode_match(keycode, OB_KEY_RIGHT)) {
/* Right goes to the selected submenu */
- if (frame->child) menu_frame_select_next(frame->child);
+ if (frame->selected->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU) {
+ /* make sure it is visible */
+ menu_frame_select(frame, frame->selected, TRUE);
+ menu_frame_select_next(frame->child);
+ }
ret = TRUE;
}
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
return ret;
}
+static Bool event_look_for_menu_enter(Display *d, XEvent *ev, XPointer arg)
+{
+ ObMenuFrame *f = (ObMenuFrame*)arg;
+ ObMenuEntryFrame *e;
+ return ev->type == EnterNotify &&
+ (e = g_hash_table_lookup(menu_frame_map, &ev->xcrossing.window)) &&
+ !e->ignore_enters && e->frame == f;
+}
+
static gboolean event_handle_menu(XEvent *ev)
{
ObMenuFrame *f;
if (ev->xcrossing.detail == NotifyInferior)
break;
- if ((e = g_hash_table_lookup(menu_frame_map, &ev->xcrossing.window)) &&
- (f = find_active_menu()) && f->selected == e)
+ if ((e = g_hash_table_lookup(menu_frame_map, &ev->xcrossing.window)))
{
- ObMenuEntryFrame *u = menu_entry_frame_under(ev->xcrossing.x_root,
- ev->xcrossing.y_root);
- /* if we're just going from one entry in the menu to the next,
- don't unselect stuff first */
- if (!u || e->frame != u->frame)
+ XEvent ce;
+
+ /* check if an EnterNotify event is coming, and if not, then select
+ nothing in the menu */
+ if (XCheckIfEvent(ob_display, &ce, event_look_for_menu_enter,
+ (XPointer)e->frame))
+ XPutBackEvent(ob_display, &ce);
+ else
menu_frame_select(e->frame, NULL, FALSE);
}
break;