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 <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2016-01-23 17:03:29 +01:00
parent dc432eb7a6
commit a98fc92b81
2 changed files with 19 additions and 17 deletions

19
event.c
View File

@ -840,23 +840,8 @@ event_handle_clientmessage(xcb_client_message_event_t *ev)
static void static void
event_handle_mappingnotify(xcb_mapping_notify_event_t *ev) event_handle_mappingnotify(xcb_mapping_notify_event_t *ev)
{ {
if(ev->request == XCB_MAPPING_MODIFIER /* Since we use XKB, we shouldn't get this event */
|| ev->request == XCB_MAPPING_KEYBOARD) warn("Unexpected MappingNotify of type %d", ev->request);
{
/* 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);
}
}
} }
static void static void

17
xkb.c
View File

@ -25,6 +25,8 @@
#include "xkb.h" #include "xkb.h"
#include "globalconf.h" #include "globalconf.h"
#include "xwindow.h"
#include "objects/client.h"
#include <xcb/xkb.h> #include <xcb/xkb.h>
#include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon.h>
#include <xkbcommon/xkbcommon-x11.h> #include <xkbcommon/xkbcommon-x11.h>
@ -183,6 +185,21 @@ xkb_reload_keymap(void)
{ {
xkb_state_unref(globalconf.xkb_state); xkb_state_unref(globalconf.xkb_state);
xkb_fill_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. /** The xkb notify event handler.