I'm attempting to grab a keyboard with the XCB XInput2 extension. This is to support the use of virtual keyboards in a window manager I'm developing. Here's the relevant code:
static const uint32_t event_mask =
XCB_INPUT_XI_EVENT_MASK_KEY_PRESS | XCB_INPUT_XI_EVENT_MASK_KEY_RELEASE;
static const uint16_t mask_len = sizeof(event_mask) / sizeof(char);
auto cookie =
xcb_input_xi_grab_device(
conn,
window,
XCB_CURRENT_TIME,
XCB_CURSOR_NONE,
device_id,
XCB_INPUT_GRAB_MODE_22_SYNC,
XCB_INPUT_GRAB_MODE_22_SYNC,
XCB_INPUT_GRAB_OWNER_OWNER,
mask_len,
&event_mask);
xcb_generic_error_t *e;
xcb_input_xi_grab_device_reply(conn->conn, cookie, &e);
if (e)
{
const auto code = e->error_code;
TRACE << "[KEYBOARD] Error during grab [code:" << std::to_string(code) << "]";
const auto label = xcb_event_get_error_label(code);
if (label)
{
TRACE << "[KEYBOARD] Grab error: " << label;
}
free(e);
}
This code is giving the following output in the logs:
[KEYBOARD] Error during grab [code:2]
[KEYBOARD] Grab error: BadValue
Running it under xtrace offers the following:
000:<:127f: 40: XInputExtension-Request(131,51): XIGrabDevice grab_window=0x00800001 time=0x00000000 cursor=0x00000000 device=14 grab_mode=Synchronous(0x00) paired_device_mode=Synchronous(0x00) owner_events=true(0x01) masks=0x0000000c,0x00000000,0x00000000,0x39317453;
000:>:127f:Error 2=Value: major=131, minor=51, bad=96
Both the device id and the window id look correct. I'm just puzzled as to which parameter is producing the bad value, unless I'm somehow messing up the event mask. Any ideas?
User contributions licensed under CC BY-SA 3.0