From: Michael Stapelberg Date: Mon, 14 Mar 2011 16:20:04 +0000 (+0100) Subject: re-implement support for MappingNotifys X-Git-Tag: tree-pr3~131 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=89ef41dadf516b12f5d4c8ff09d95b425fcc1174;p=i3%2Fi3 re-implement support for MappingNotifys --- diff --git a/include/handlers.h b/include/handlers.h index 2d592e64..76ba3eea 100644 --- a/include/handlers.h +++ b/include/handlers.h @@ -41,7 +41,6 @@ int handle_enter_notify(void *ignored, xcb_connection_t *conn, int handle_motion_notify(void *ignored, xcb_connection_t *conn, xcb_motion_notify_event_t *event); -#if 0 /** * Called when the keyboard mapping changes (for example by using Xmodmap), * we need to update our key bindings then (re-translate symbols). @@ -49,6 +48,7 @@ int handle_motion_notify(void *ignored, xcb_connection_t *conn, */ int handle_mapping_notify(void *ignored, xcb_connection_t *conn, xcb_mapping_notify_event_t *event); +#if 0 /** * Checks if the button press was on a stack window, handles focus setting and diff --git a/src/handlers.c b/src/handlers.c index 9c584b8b..6e6626a9 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -251,30 +251,28 @@ int handle_motion_notify(void *ignored, xcb_connection_t *conn, xcb_motion_notif return 1; } -#if 0 /* * Called when the keyboard mapping changes (for example by using Xmodmap), * we need to update our key bindings then (re-translate symbols). * */ int handle_mapping_notify(void *ignored, xcb_connection_t *conn, xcb_mapping_notify_event_t *event) { - if (event->request != XCB_MAPPING_KEYBOARD && - event->request != XCB_MAPPING_MODIFIER) - return 0; + if (event->request != XCB_MAPPING_KEYBOARD && + event->request != XCB_MAPPING_MODIFIER) + return 0; - DLOG("Received mapping_notify for keyboard or modifier mapping, re-grabbing keys\n"); - xcb_refresh_keyboard_mapping(keysyms, event); + DLOG("Received mapping_notify for keyboard or modifier mapping, re-grabbing keys\n"); + xcb_refresh_keyboard_mapping(keysyms, event); - xcb_get_numlock_mask(conn); + xcb_get_numlock_mask(conn); - ungrab_all_keys(conn); - translate_keysyms(); - grab_all_keys(conn, false); + ungrab_all_keys(conn); + translate_keysyms(); + grab_all_keys(conn, false); - return 0; + return 0; } -#endif /* * A new window appeared on the screen (=was mapped), so let’s manage it. * diff --git a/src/main.c b/src/main.c index c497ab9e..eb173221 100644 --- a/src/main.c +++ b/src/main.c @@ -417,6 +417,9 @@ int main(int argc, char *argv[]) { /* Watch WM_TRANSIENT_FOR property (to which client this popup window belongs) */ xcb_property_set_handler(&prophs, WM_TRANSIENT_FOR, UINT_MAX, handle_transient_for, NULL); + /* Mapping notify = keyboard mapping changed (Xmodmap), re-grab bindings */ + xcb_event_set_mapping_notify_handler(&evenths, handle_mapping_notify, NULL); + /* Set up the atoms we support */ xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, atoms[_NET_SUPPORTED], ATOM, 32, 7, atoms); /* Set up the window manager’s name */