break;
case KeyRelease:
e->xkey.state = modkeys_only_modifier_masks(e->xkey.state);
-#ifdef XKB
- if (XkbGetState(ob_display, XkbUseCoreKbd, &xkb_state) == Success) {
- e->xkey.state = xkb_state.compat_state;
- break;
- }
-#endif
/* remove from the state the mask of the modifier key being released,
if it is a modifier key being released that is */
e->xkey.state &= ~modkeys_keycode_to_mask(e->xkey.keycode);
guint keycode, state;
gunichar unikey;
ObMenuFrame *frame;
- gboolean ret = TRUE;
+ gboolean ret = FALSE;
keycode = ev->xkey.keycode;
state = ev->xkey.state;
frame = find_active_or_last_menu();
if (frame == NULL)
- ret = FALSE;
+ g_assert_not_reached(); /* there is no active menu */
- else if (keycode == ob_keycode(OB_KEY_ESCAPE) && state == 0)
- menu_frame_hide_all();
+ /* Allow control while going thru the menu */
+ else if (ev->type == KeyPress && (state & ~ControlMask) == 0) {
+ if (keycode == ob_keycode(OB_KEY_ESCAPE)) {
+ menu_frame_hide_all();
+ ret = TRUE;
+ }
- else if (keycode == ob_keycode(OB_KEY_RETURN) && (state == 0 ||
- state == ControlMask))
- {
- /* 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, state);
- }
+ else if (keycode == ob_keycode(OB_KEY_LEFT)) {
+ /* Left goes to the parent menu */
+ menu_frame_select(frame, NULL, TRUE);
+ ret = TRUE;
+ }
- else if (keycode == ob_keycode(OB_KEY_LEFT) && ev->xkey.state == 0) {
- /* Left goes to the parent menu */
- menu_frame_select(frame, NULL, TRUE);
- }
+ else if (keycode == ob_keycode(OB_KEY_RIGHT)) {
+ /* Right goes to the selected submenu */
+ if (frame->child) menu_frame_select_next(frame->child);
+ ret = TRUE;
+ }
- else if (keycode == ob_keycode(OB_KEY_RIGHT) && ev->xkey.state == 0) {
- /* Right goes to the selected submenu */
- if (frame->child) menu_frame_select_next(frame->child);
- }
+ else if (keycode == ob_keycode(OB_KEY_UP)) {
+ menu_frame_select_previous(frame);
+ ret = TRUE;
+ }
- else if (keycode == ob_keycode(OB_KEY_UP) && state == 0) {
- menu_frame_select_previous(frame);
+ else if (keycode == ob_keycode(OB_KEY_DOWN)) {
+ menu_frame_select_next(frame);
+ ret = TRUE;
+ }
}
- else if (keycode == ob_keycode(OB_KEY_DOWN) && state == 0) {
- menu_frame_select_next(frame);
- }
+ /* Use KeyRelease events for running things so that the key release doesn't
+ get sent to the focused application.
- /* keyboard accelerator shortcuts. (allow controlmask) */
- else if ((ev->xkey.state & ~ControlMask) == 0 &&
- /* was it a valid key? */
- unikey != 0 &&
- /* don't bother if the menu is empty. */
+ Allow ControlMask only, and don't bother if the menu is empty */
+ else if (ev->type == KeyRelease && (state & ~ControlMask) == 0 &&
frame->entries)
{
- GList *start;
- GList *it;
- ObMenuEntryFrame *found = NULL;
- guint num_found = 0;
-
- /* start after the selected one */
- start = frame->entries;
- if (frame->selected) {
- for (it = start; frame->selected != it->data; it = g_list_next(it))
- g_assert(it != NULL); /* nothing was selected? */
- /* next with wraparound */
- start = g_list_next(it);
- if (start == NULL) start = frame->entries;
+ if (keycode == ob_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, state);
+
+ ret = TRUE;
}
- it = start;
- do {
- ObMenuEntryFrame *e = it->data;
- gunichar entrykey = 0;
+ /* keyboard accelerator shortcuts. (if it was a valid key) */
+ else if (unikey != 0) {
+ GList *start;
+ GList *it;
+ ObMenuEntryFrame *found = NULL;
+ guint num_found = 0;
+
+ /* start after the selected one */
+ start = frame->entries;
+ if (frame->selected) {
+ for (it = start; frame->selected != it->data;
+ it = g_list_next(it))
+ g_assert(it != NULL); /* nothing was selected? */
+ /* next with wraparound */
+ start = g_list_next(it);
+ if (start == NULL) start = frame->entries;
+ }
+
+ it = start;
+ do {
+ ObMenuEntryFrame *e = it->data;
+ gunichar entrykey = 0;
- if (e->entry->type == OB_MENU_ENTRY_TYPE_NORMAL)
- entrykey = e->entry->data.normal.shortcut;
- else if (e->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU)
- entrykey = e->entry->data.submenu.submenu->shortcut;
+ if (e->entry->type == OB_MENU_ENTRY_TYPE_NORMAL)
+ entrykey = e->entry->data.normal.shortcut;
+ else if (e->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU)
+ entrykey = e->entry->data.submenu.submenu->shortcut;
- if (unikey == entrykey) {
- if (found == NULL) found = e;
- ++num_found;
- }
+ if (unikey == entrykey) {
+ if (found == NULL) found = e;
+ ++num_found;
+ }
- /* next with wraparound */
- it = g_list_next(it);
- if (it == NULL) it = frame->entries;
- } while (it != start);
+ /* next with wraparound */
+ it = g_list_next(it);
+ if (it == NULL) it = frame->entries;
+ } while (it != start);
- if (found) {
- if (found->entry->type == OB_MENU_ENTRY_TYPE_NORMAL &&
- 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, state);
- } else {
- menu_frame_select(frame, found, TRUE);
- if (num_found == 1)
- menu_frame_select_next(frame->child);
+ if (found) {
+ if (found->entry->type == OB_MENU_ENTRY_TYPE_NORMAL &&
+ 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, state);
+ } else {
+ menu_frame_select(frame, found, TRUE);
+ if (num_found == 1)
+ menu_frame_select_next(frame->child);
+ }
+
+ ret = TRUE;
}
- } else
- ret = FALSE;
+ }
}
- else
- ret = FALSE;
return ret;
}
menu_frame_select(e->frame, e, FALSE);
break;
case KeyPress:
+ case KeyRelease:
ret = event_handle_menu_keyboard(ev);
break;
}
menu_frame_hide_all();
ob_debug("KILLED open menus\n");
}
+ else if (moveresize_in_progress) {
+ moveresize_end(TRUE);
+ ob_debug("KILLED interactive moveresize\n");
+ }
else if (grab_on_keyboard()) {
ungrab_keyboard();
ob_debug("KILLED active grab on keyboard\n");