From a98fc92b81f52a61ce94774bfc9271778b86f189 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 23 Jan 2016 17:03:29 +0100 Subject: [PATCH] Move handling of MappingNotify to xkb.c A quote from the XKeyboard specification: The server notifies interested clients of keyboard map changes in one of two ways. It sends XkbMapNotify to clients that have explicitly selected them and core protocol MappingNotify events to clients that have not. Once a client requests XkbMapNotify events, the server stops sending it MappingNotify events to inform it of keyboard changes. This commit moves the code that we had for handling MappingNotify events to the place where we handle XkbMapNotify events. This might even fix some bugs where parts of awesome continued to use old key binding "stuff"! Signed-off-by: Uli Schlachter --- event.c | 19 ++----------------- xkb.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/event.c b/event.c index 570f37c8..d096bb10 100644 --- a/event.c +++ b/event.c @@ -840,23 +840,8 @@ event_handle_clientmessage(xcb_client_message_event_t *ev) static void event_handle_mappingnotify(xcb_mapping_notify_event_t *ev) { - if(ev->request == XCB_MAPPING_MODIFIER - || ev->request == XCB_MAPPING_KEYBOARD) - { - /* Free and then allocate the key symbols */ - xcb_key_symbols_free(globalconf.keysyms); - globalconf.keysyms = xcb_key_symbols_alloc(globalconf.connection); - - /* regrab everything TODO: Move this to xkb.c suitably */ - xcb_screen_t *s = globalconf.screen; - xwindow_grabkeys(s->root, &globalconf.keys); - - foreach(_c, globalconf.clients) - { - client_t *c = *_c; - xwindow_grabkeys(c->window, &c->keys); - } - } + /* Since we use XKB, we shouldn't get this event */ + warn("Unexpected MappingNotify of type %d", ev->request); } static void diff --git a/xkb.c b/xkb.c index 95b78884..faa80e48 100644 --- a/xkb.c +++ b/xkb.c @@ -25,6 +25,8 @@ #include "xkb.h" #include "globalconf.h" +#include "xwindow.h" +#include "objects/client.h" #include #include #include @@ -183,6 +185,21 @@ xkb_reload_keymap(void) { xkb_state_unref(globalconf.xkb_state); xkb_fill_state(); + + /* Free and then allocate the key symbols */ + xcb_key_symbols_free(globalconf.keysyms); + globalconf.keysyms = xcb_key_symbols_alloc(globalconf.connection); + + /* Regrab key bindings on the root window */ + xcb_screen_t *s = globalconf.screen; + xwindow_grabkeys(s->root, &globalconf.keys); + + /* Regrab key bindings on clients */ + foreach(_c, globalconf.clients) + { + client_t *c = *_c; + xwindow_grabkeys(c->window, &c->keys); + } } /** The xkb notify event handler.