| 51 | } |
| 52 | |
| 53 | void GameEventsXcb::registerGameWindow(uint32_t gameWindow) |
| 54 | { |
| 55 | context->game_window = static_cast<xcb_window_t>(gameWindow); |
| 56 | if (context->game_window != 0) |
| 57 | { |
| 58 | const static uint32_t values[] = { XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_EXPOSURE }; |
| 59 | xcb_void_cookie_t cwa_cookie = xcb_change_window_attributes (context->conn, context->game_window, XCB_CW_EVENT_MASK, values); |
| 60 | xcb_generic_error_t *error = xcb_request_check(context->conn, cwa_cookie); |
| 61 | if (error) { |
| 62 | std::cerr << "error in xcb_change_window_attributes: " << error->error_code << std::endl; |
| 63 | } |
| 64 | |
| 65 | /* Also get parent window of game window for focus */ |
| 66 | xcb_query_tree_cookie_t qt_cookie = xcb_query_tree(context->conn, context->game_window); |
| 67 | xcb_query_tree_reply_t *reply = xcb_query_tree_reply(context->conn, qt_cookie, &error); |
| 68 | |
| 69 | if (error) { |
| 70 | std::cerr << "Could not get xcb_query_tree, X error" << error->error_code << std::endl; |
| 71 | return; |
| 72 | } |
| 73 | else { |
| 74 | parent_game_window = reply->parent; |
| 75 | } |
| 76 | if (reply) |
| 77 | free(reply); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | GameEventsXcb::EventType GameEventsXcb::nextEvent(struct HotKey &hk) |
| 82 | { |