From 143a898fcc1e29a900bc2f88303a45b5f4703783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Fri, 12 Oct 2012 12:25:07 +0200 Subject: [PATCH] compositor-x11: Clean up event handling. --- src/compositor-x11.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/compositor-x11.c b/src/compositor-x11.c index c7db401d..23499366 100644 --- a/src/compositor-x11.c +++ b/src/compositor-x11.c @@ -25,6 +25,7 @@ #include #endif +#include #include #include #include @@ -823,18 +824,21 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data) xcb_atom_t atom; uint32_t *k; uint32_t i, set; + uint8_t response_type; int count; prev = NULL; count = 0; while (x11_compositor_next_event(c, &event, mask)) { + response_type = event->response_type & ~0x80; + switch (prev ? prev->response_type & ~0x80 : 0x80) { case XCB_KEY_RELEASE: /* Suppress key repeat events; this is only used if we * don't have XCB XKB support. */ key_release = (xcb_key_press_event_t *) prev; key_press = (xcb_key_press_event_t *) event; - if ((event->response_type & ~0x80) == XCB_KEY_PRESS && + if (response_type == XCB_KEY_PRESS && key_release->time == key_press->time && key_release->detail == key_press->detail) { /* Don't deliver the held key release @@ -859,8 +863,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data) } case XCB_FOCUS_IN: - /* assert event is keymap_notify */ - focus_in = (xcb_focus_in_event_t *) prev; + assert(response_type == XCB_KEYMAP_NOTIFY); keymap_notify = (xcb_keymap_notify_event_t *) event; c->keys.size = 0; for (i = 0; i < ARRAY_LENGTH(keymap_notify->keys) * 8; i++) { @@ -872,7 +875,6 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data) } } - output = x11_compositor_find_output(c, focus_in->event); /* Unfortunately the state only comes with the enter * event, rather than with the focus event. I'm not * sure of the exact semantics around it and whether @@ -889,7 +891,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data) break; } - switch (event->response_type & ~0x80) { + switch (response_type) { case XCB_KEY_PRESS: key_press = (xcb_key_press_event_t *) event; if (!c->has_xkb) @@ -941,7 +943,6 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data) break; if (!c->has_xkb) update_xkb_state_from_core(c, enter_notify->state); - output = x11_compositor_find_output(c, enter_notify->event); notify_pointer_focus(&c->core_seat, NULL, 0, 0); break; @@ -974,7 +975,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data) #ifdef HAVE_XCB_XKB if (c->has_xkb && - (event->response_type & ~0x80) == c->xkb_event_base) { + response_type == c->xkb_event_base) { xcb_xkb_state_notify_event_t *state = (xcb_xkb_state_notify_event_t *) event; if (state->xkbType == XCB_XKB_STATE_NOTIFY)