make the menu use the new obt stuff when reading keyboard input so it can handle input from the non-base group and composed input
This commit is contained in:
parent
41dbce908a
commit
62f8a5c49b
2 changed files with 40 additions and 34 deletions
|
@ -1765,12 +1765,10 @@ static gboolean event_handle_menu_input(XEvent *ev)
|
||||||
}
|
}
|
||||||
else if (ev->type == KeyPress || ev->type == KeyRelease) {
|
else if (ev->type == KeyPress || ev->type == KeyRelease) {
|
||||||
guint mods;
|
guint mods;
|
||||||
gunichar unikey;
|
|
||||||
ObMenuFrame *frame;
|
ObMenuFrame *frame;
|
||||||
|
|
||||||
/* get the modifiers */
|
/* get the modifiers */
|
||||||
mods = obt_keyboard_only_modmasks(ev->xkey.state);
|
mods = obt_keyboard_only_modmasks(ev->xkey.state);
|
||||||
unikey = obt_keyboard_keycode_to_unichar(ev->xkey.keycode);
|
|
||||||
|
|
||||||
frame = find_active_or_last_menu();
|
frame = find_active_or_last_menu();
|
||||||
if (frame == NULL)
|
if (frame == NULL)
|
||||||
|
@ -1778,7 +1776,11 @@ static gboolean event_handle_menu_input(XEvent *ev)
|
||||||
|
|
||||||
/* Allow control while going thru the menu */
|
/* Allow control while going thru the menu */
|
||||||
else if (ev->type == KeyPress && (mods & ~ControlMask) == 0) {
|
else if (ev->type == KeyPress && (mods & ~ControlMask) == 0) {
|
||||||
|
gunichar unikey;
|
||||||
|
|
||||||
frame->got_press = TRUE;
|
frame->got_press = TRUE;
|
||||||
|
frame->press_keycode = ev->xkey.keycode;
|
||||||
|
frame->press_doexec = FALSE;
|
||||||
|
|
||||||
if (ob_keycode_match(ev->xkey.keycode, OB_KEY_ESCAPE)) {
|
if (ob_keycode_match(ev->xkey.keycode, OB_KEY_ESCAPE)) {
|
||||||
menu_frame_hide_all();
|
menu_frame_hide_all();
|
||||||
|
@ -1827,28 +1829,9 @@ static gboolean event_handle_menu_input(XEvent *ev)
|
||||||
menu_frame_select_last(frame);
|
menu_frame_select_last(frame);
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Use KeyRelease events for running things so that the key release
|
|
||||||
doesn't get sent to the focused application.
|
|
||||||
|
|
||||||
Allow ControlMask only, and don't bother if the menu is empty */
|
|
||||||
else if (ev->type == KeyRelease && (mods & ~ControlMask) == 0 &&
|
|
||||||
frame->entries && frame->got_press)
|
|
||||||
{
|
|
||||||
if (ob_keycode_match(ev->xkey.keycode, OB_KEY_RETURN)) {
|
|
||||||
/* Enter runs the active item or goes into the submenu.
|
|
||||||
Control-Enter runs it without closing the menu. */
|
|
||||||
if (frame->child)
|
|
||||||
menu_frame_select_next(frame->child);
|
|
||||||
else if (frame->selected)
|
|
||||||
menu_entry_frame_execute(frame->selected, ev->xkey.state);
|
|
||||||
|
|
||||||
ret = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* keyboard accelerator shortcuts. (if it was a valid key) */
|
/* keyboard accelerator shortcuts. (if it was a valid key) */
|
||||||
else if (unikey != 0) {
|
else if ((unikey = obt_keyboard_keypress_to_unichar(&ev->xkey))) {
|
||||||
GList *start;
|
GList *start;
|
||||||
GList *it;
|
GList *it;
|
||||||
ObMenuEntryFrame *found = NULL;
|
ObMenuEntryFrame *found = NULL;
|
||||||
|
@ -1886,23 +1869,42 @@ static gboolean event_handle_menu_input(XEvent *ev)
|
||||||
} while (it != start);
|
} while (it != start);
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
if (found->entry->type == OB_MENU_ENTRY_TYPE_NORMAL &&
|
menu_frame_select(frame, found, TRUE);
|
||||||
num_found == 1)
|
|
||||||
{
|
|
||||||
menu_frame_select(frame, found, TRUE);
|
|
||||||
usleep(50000); /* highlight the item for a short bit so
|
|
||||||
the user can see what happened */
|
|
||||||
menu_entry_frame_execute(found, ev->xkey.state);
|
|
||||||
} else {
|
|
||||||
menu_frame_select(frame, found, TRUE);
|
|
||||||
if (num_found == 1)
|
|
||||||
menu_frame_select_next(frame->child);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (num_found == 1)
|
||||||
|
frame->press_doexec = TRUE;
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Use KeyRelease events for running things so that the key release
|
||||||
|
doesn't get sent to the focused application.
|
||||||
|
|
||||||
|
Allow ControlMask only, and don't bother if the menu is empty */
|
||||||
|
else if (ev->type == KeyRelease && (mods & ~ControlMask) == 0 &&
|
||||||
|
frame->entries && frame->got_press)
|
||||||
|
{
|
||||||
|
if (ob_keycode_match(ev->xkey.keycode, OB_KEY_RETURN)) {
|
||||||
|
/* Enter runs the active item or goes into the submenu.
|
||||||
|
Control-Enter runs it without closing the menu. */
|
||||||
|
if (frame->child)
|
||||||
|
menu_frame_select_next(frame->child);
|
||||||
|
else if (frame->selected)
|
||||||
|
menu_entry_frame_execute(frame->selected, ev->xkey.state);
|
||||||
|
|
||||||
|
ret = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (frame->press_keycode == ev->xkey.keycode &&
|
||||||
|
frame->press_doexec)
|
||||||
|
{
|
||||||
|
if (frame->selected->entry->type == OB_MENU_ENTRY_TYPE_NORMAL)
|
||||||
|
menu_entry_frame_execute(frame->selected, ev->xkey.state);
|
||||||
|
else
|
||||||
|
menu_frame_select_next(frame->child);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -81,6 +81,10 @@ struct _ObMenuFrame
|
||||||
menu until it has seen a KeyPress. this is to
|
menu until it has seen a KeyPress. this is to
|
||||||
avoid having the keybinding used to show the menu
|
avoid having the keybinding used to show the menu
|
||||||
end up running something inside the menu */
|
end up running something inside the menu */
|
||||||
|
guint press_keycode; /* the KeyCode that was used in the last KeyPress */
|
||||||
|
gboolean press_doexec; /* if the upcoming KeyRelease should be used to
|
||||||
|
execute the menu item that was selected by the
|
||||||
|
KeyPress */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _ObMenuEntryFrame
|
struct _ObMenuEntryFrame
|
||||||
|
|
Loading…
Reference in a new issue