diff options
author | infirit <[email protected]> | 2014-11-12 18:35:06 +0100 |
---|---|---|
committer | infirit <[email protected]> | 2014-11-12 20:36:49 +0100 |
commit | 1de3cf470353049ee9974bd6d9a437f556931bea (patch) | |
tree | 66ee1e5424e65f54ecd5097869009672d2b6de2c /src | |
parent | ad9db61aabc2cbf743a1157ddc42ff76127f3fab (diff) | |
download | marco-1de3cf470353049ee9974bd6d9a437f556931bea.tar.bz2 marco-1de3cf470353049ee9974bd6d9a437f556931bea.tar.xz |
Update keybindings when XKB keyboard layout changes
* Select for XKB keyboard notification events explicitly; since GTK+
has selected for XKB events, delivery of old-school MappingNotify
events is disabled.
* Fix a bug where once a keycode was loaded for a key binding,
it would never be reassigned; we want to laod new keycodes for
all bindings that have a key symbol rather than a fixed
keycode.
[ With fixes from Owen W. Taylor <[email protected]> ]
Based on metacity commit: c262e3d65a37abedc507705cddfec72c901c321f
From: Derek Poon <[email protected]>
Gnome bug: https://bugzilla.gnome.org/show_bug.cgi?id=565540
Diffstat (limited to 'src')
-rw-r--r-- | src/core/display.c | 4 | ||||
-rw-r--r-- | src/core/keybindings.c | 28 |
2 files changed, 31 insertions, 1 deletions
diff --git a/src/core/display.c b/src/core/display.c index 68569f3a..8a81d8f4 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -2580,6 +2580,10 @@ static gboolean event_callback(XEvent* event, gpointer data) meta_bell_notify (display, xkb_ev); } break; + case XkbNewKeyboardNotify: + case XkbMapNotify: + meta_display_process_mapping_event (display, event); + break; } } #endif diff --git a/src/core/keybindings.c b/src/core/keybindings.c index eea49baf..9bdea53e 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -262,9 +262,11 @@ reload_keycodes (MetaDisplay *display) i = 0; while (i < display->n_key_bindings) { - if (display->key_bindings[i].keycode == 0) + if (display->key_bindings[i].keysym != 0) + { display->key_bindings[i].keycode = XKeysymToKeycode ( display->xdisplay, display->key_bindings[i].keysym); + } ++i; } @@ -504,6 +506,22 @@ void meta_display_process_mapping_event (MetaDisplay *display, XEvent *event) { +#ifdef HAVE_XKB + if (event->type == display->xkb_base_event_type) + { + meta_topic (META_DEBUG_KEYBINDINGS, + "XKB mapping changed, will redo keybindings\n"); + + reload_keymap (display); + reload_modmap (display); + + reload_keycodes (display); + reload_modifiers (display); + + regrab_key_bindings (display); + } + else +#endif if (event->xmapping.request == MappingModifier) { meta_topic (META_DEBUG_KEYBINDINGS, @@ -589,6 +607,14 @@ meta_display_init_keys (MetaDisplay *display) /* Keys are actually grabbed in meta_screen_grab_keys() */ meta_prefs_add_listener (bindings_changed_callback, display); + +#ifdef HAVE_XKB + /* meta_display_init_keys() should have already called XkbQueryExtension() */ + if (display->xkb_base_event_type != -1) + XkbSelectEvents (display->xdisplay, XkbUseCoreKbd, + XkbNewKeyboardNotifyMask | XkbMapNotifyMask, + XkbNewKeyboardNotifyMask | XkbMapNotifyMask); +#endif } void |