From 10daa6b09e2e207fe2162940b0a9455d745c670c Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 7 Nov 2015 12:24:21 +0100 Subject: [PATCH 1/3] xkb: Don't use _checked() requests In XCB, each request has a checked and an unchecked version. The checked version can be used to check if the request caused any errors. Since the code here doesn't do this check, it shouldn't use the checked versions of the requests. Signed-off-by: Uli Schlachter --- xkb.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/xkb.c b/xkb.c index 82db23bbd..fce295cd0 100644 --- a/xkb.c +++ b/xkb.c @@ -275,14 +275,14 @@ xkb_init(void) XCB_XKB_MAP_PART_VIRTUAL_MODS | XCB_XKB_MAP_PART_VIRTUAL_MOD_MAP; - xcb_xkb_select_events_checked(globalconf.connection, - XCB_XKB_ID_USE_CORE_KBD, - map, - 0, - map, - map_parts, - map_parts, - 0); + xcb_xkb_select_events(globalconf.connection, + XCB_XKB_ID_USE_CORE_KBD, + map, + 0, + map, + map_parts, + map_parts, + 0); /* load keymap to use when resolving keypresses */ xkb_init_keymap(); @@ -294,7 +294,7 @@ void xkb_free(void) { // unsubscribe from all events - xcb_xkb_select_events_checked(globalconf.connection, + xcb_xkb_select_events(globalconf.connection, XCB_XKB_ID_USE_CORE_KBD, 0, 0, From e279d686705f7311a533f3be4c1f7bfd4d9b4973 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 7 Nov 2015 12:27:35 +0100 Subject: [PATCH 2/3] xkb.c: Remove trailing whitespace Signed-off-by: Uli Schlachter --- xkb.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xkb.c b/xkb.c index fce295cd0..c1b3b463d 100644 --- a/xkb.c +++ b/xkb.c @@ -129,7 +129,7 @@ xkb_fill_state(void) int32_t device_id = xkb_x11_get_core_keyboard_device_id(conn); if (device_id == -1) fatal("Failed while getting XKB device id"); - + struct xkb_keymap *xkb_keymap = xkb_x11_keymap_new_from_device( globalconf.xkb_ctx, conn, @@ -139,7 +139,7 @@ xkb_fill_state(void) if (!xkb_keymap) fatal("Failed while getting XKB keymap from device"); - + globalconf.xkb_state = xkb_x11_state_new_from_device(xkb_keymap, conn, device_id); @@ -160,7 +160,7 @@ xkb_init_keymap(void) globalconf.xkb_ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS); if (!globalconf.xkb_ctx) fatal("Failed while getting XKB context"); - + xkb_fill_state(); } @@ -220,7 +220,7 @@ event_handle_xkb_notify(xcb_generic_event_t* event) { xcb_xkb_state_notify_event_t *state_notify_event = (void*)event; - xkb_state_update_mask(globalconf.xkb_state, + xkb_state_update_mask(globalconf.xkb_state, state_notify_event->baseMods, state_notify_event->latchedMods, state_notify_event->lockedMods, @@ -272,7 +272,7 @@ xkb_init(void) XCB_XKB_MAP_PART_EXPLICIT_COMPONENTS | XCB_XKB_MAP_PART_KEY_ACTIONS | XCB_XKB_MAP_PART_KEY_BEHAVIORS | - XCB_XKB_MAP_PART_VIRTUAL_MODS | + XCB_XKB_MAP_PART_VIRTUAL_MODS | XCB_XKB_MAP_PART_VIRTUAL_MOD_MAP; xcb_xkb_select_events(globalconf.connection, From 6f2424e90170be4acaa1d140f966ab6bb8a4d217 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 7 Nov 2015 12:45:04 +0100 Subject: [PATCH 3/3] Enable detectable autorepeat (#550) Imagine the following snippet is run: keygrabber.run(function(mod, key, event) gears.debug.dump{mod, key, event} end) The above starts a keygrabber and prints the events that are received. Currently, when a key is pressed and held down, this prints a series of press and release, because that's what the X11 server sends us. This commit enables detectable autorepeat. This means that the X11 server only sends us a series of press events for autorepeat and a single release when the key really is released. Testing this is a bit hard, because detectable autorepeat does not seem to work with Xephyr. Instead, a "real" Xorg instance is needed. We do not check the response to the PerClientFlags request, because it doesn't really tell us anything useful. If the server does not support detectable autorepeat, we could print a warning, but so what? As I just said, this does not work in Xephyr and yet Xephyr announced to support this. Signed-off-by: Uli Schlachter --- xkb.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/xkb.c b/xkb.c index c1b3b463d..07560c9da 100644 --- a/xkb.c +++ b/xkb.c @@ -275,6 +275,17 @@ xkb_init(void) XCB_XKB_MAP_PART_VIRTUAL_MODS | XCB_XKB_MAP_PART_VIRTUAL_MOD_MAP; + /* Enable detectable auto-repeat, but ignore failures */ + xcb_discard_reply(globalconf.connection, + xcb_xkb_per_client_flags(globalconf.connection, + XCB_XKB_ID_USE_CORE_KBD, + XCB_XKB_PER_CLIENT_FLAG_DETECTABLE_AUTO_REPEAT, + XCB_XKB_PER_CLIENT_FLAG_DETECTABLE_AUTO_REPEAT, + 0, + 0, + 0) + .sequence); + xcb_xkb_select_events(globalconf.connection, XCB_XKB_ID_USE_CORE_KBD, map,