[krh/weston/next 3/8] compositor-x11: Clean up event handling.

John Kåre Alsaker john.kare.alsaker at gmail.com
Fri Oct 12 03:25:07 PDT 2012


---
 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 7ec56ff..97c6698 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#include <assert.h>
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
@@ -819,18 +820,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
@@ -855,8 +859,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++) {
@@ -868,7 +871,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
@@ -885,7 +887,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)
@@ -937,7 +939,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;
 
@@ -970,7 +971,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)
-- 
1.7.12.2



More information about the wayland-devel mailing list