/* * vim:ts=4:sw=4:expandtab */ #include #include #include #include #include #include #include #include int main() { printf("ohai\n"); int screen; xcb_connection_t *conn = xcb_connect(NULL, &screen); if (!conn) err(1, "cannot open display\n"); const xcb_query_extension_reply_t *extreply; extreply = xcb_get_extension_data(conn, &xcb_xkb_id); if (!extreply->present) err(1, "not present\n"); int fe = extreply->first_event; printf("first event = %d\n", fe); printf("querying xkb...\n"); xcb_xkb_use_extension_cookie_t cookie = xcb_xkb_use_extension(conn, XCB_XKB_MAJOR_VERSION, XCB_XKB_MINOR_VERSION); xcb_xkb_use_extension_reply_t *reply = xcb_xkb_use_extension_reply(conn, cookie, NULL); printf("reply = %p\n", reply); printf("supported = %d, major = %d, minor = %d\n", reply->supported, reply->serverMajor, reply->serverMinor); uint16_t selectAll = XCB_XKB_EVENT_TYPE_MAP_NOTIFY | XCB_XKB_EVENT_TYPE_STATE_NOTIFY; uint16_t affectWhich = XCB_XKB_EVENT_TYPE_MAP_NOTIFY | XCB_XKB_EVENT_TYPE_STATE_NOTIFY; uint16_t clear = affectWhich & (~selectAll); uint16_t affectMap = XCB_XKB_MAP_PART_KEY_TYPES | XCB_XKB_MAP_PART_KEY_SYMS | XCB_XKB_MAP_PART_MODIFIER_MAP | 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_MOD_MAP; uint16_t map = affectMap; xcb_xkb_select_events_details_t foo; xcb_xkb_select_events(conn, XCB_XKB_ID_USE_CORE_KBD, affectWhich, clear, selectAll, affectMap, map, &foo); xcb_flush(conn); xcb_generic_event_t *event; while ((event = xcb_wait_for_event(conn))) { if (event->response_type == 0) errx(1, "XCB: Invalid event received"); /* Strip off the highest bit (set if the event is generated) */ int type = (event->response_type & 0x7F); printf("got event of type %d\n", type); if (type != fe) { printf("skipping\n"); continue; } xcb_xkb_map_notify_event_t *e = event; printf("e->device = %d, e->time = %d, e->type = %d\n", e->deviceID, e->time, e->response_type); } }