[PATCH weston v1 1/3] compositor-x11: add assert to avoid misuse of x11_backend_deliver_button_event

Benoit Gschwind gschwind at gnu-log.net
Fri May 13 11:34:55 UTC 2016


The x11_backend_deliver_button_event can be called with any
xcb_generic_event. The assert check if the call is done with the
expected events.

Signed-off-by: Benoit Gschwind <gschwind at gnu-log.net>
---
 src/compositor-x11.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index 629b5f3..e7b09cf 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -1039,6 +1039,8 @@ static void
 x11_backend_deliver_button_event(struct x11_backend *b,
 				 xcb_generic_event_t *event, int state)
 {
+	assert(event->response_type == XCB_BUTTON_PRESS ||
+	       event->response_type == XCB_BUTTON_RELEASE);
 	xcb_button_press_event_t *button_event =
 		(xcb_button_press_event_t *) event;
 	uint32_t button;
-- 
2.7.3



More information about the wayland-devel mailing list