Unify keymap-reloading code branches

Simplify the keymap loading logic by unifying the different
branches; in the reorganization this patch fixes a bug where when
we got a MappingKeyboard event we wouldn't update virtual modifiers
correctly.

Based on a patch by Thomas Thurman <tthurman@gnome.org>

https://bugzilla.gnome.org/show_bug.cgi?id=565540
This commit is contained in:
Owen W. Taylor 2010-05-02 11:35:33 -04:00
parent cb88e0d052
commit c6be05f9d7

View File

@ -532,19 +532,17 @@ void
meta_display_process_mapping_event (MetaDisplay *display, meta_display_process_mapping_event (MetaDisplay *display,
XEvent *event) XEvent *event)
{ {
gboolean keymap_changed = FALSE;
gboolean modmap_changed = FALSE;
#ifdef HAVE_XKB #ifdef HAVE_XKB
if (event->type == display->xkb_base_event_type) if (event->type == display->xkb_base_event_type)
{ {
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"XKB mapping changed, will redo keybindings\n"); "XKB mapping changed, will redo keybindings\n");
reload_keymap (display); keymap_changed = TRUE;
reload_modmap (display); modmap_changed = TRUE;
reload_keycodes (display);
reload_modifiers (display);
regrab_key_bindings (display);
} }
else else
#endif #endif
@ -553,22 +551,33 @@ meta_display_process_mapping_event (MetaDisplay *display,
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Received MappingModifier event, will reload modmap and redo keybindings\n"); "Received MappingModifier event, will reload modmap and redo keybindings\n");
reload_modmap (display); modmap_changed = TRUE;
reload_modifiers (display);
regrab_key_bindings (display);
} }
else if (event->xmapping.request == MappingKeyboard) else if (event->xmapping.request == MappingKeyboard)
{ {
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Received MappingKeyboard event, will reload keycodes and redo keybindings\n"); "Received MappingKeyboard event, will reload keycodes and redo keybindings\n");
keymap_changed = TRUE;
}
/* Now to do the work itself */
if (keymap_changed || modmap_changed)
{
if (keymap_changed)
reload_keymap (display); reload_keymap (display);
/* Deciphering the modmap depends on the loaded keysyms to find out
* what modifiers is Super and so forth, so we need to reload it
* even when only the keymap changes */
reload_modmap (display); reload_modmap (display);
if (keymap_changed)
reload_keycodes (display); reload_keycodes (display);
reload_modifiers (display);
regrab_key_bindings (display); regrab_key_bindings (display);
} }
} }