[weston,2/3] compositor-x11: Cleanup XCB_LEAVE_NOTIFY handling

Submitted by Marie Stephanie Alesna on Oct. 9, 2017, 10:12 p.m.

Details

Message ID 20171009221234.18237-2-istephielicious@gmail.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Wayland

Not browsing as part of any series.

Commit Message

Marie Stephanie Alesna Oct. 9, 2017, 10:12 p.m.
Create new x11_backend_deliver_leave_event function.  Fix XCB_LEAVE_NOTIFY to
really use xcb_leave_notify_event_t.

Signed-off-by: Marie Stephanie Alesna <istephielicious@gmail.com>
---
 libweston/compositor-x11.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libweston/compositor-x11.c b/libweston/compositor-x11.c
index 60843ac1..f9c9500d 100644
--- a/libweston/compositor-x11.c
+++ b/libweston/compositor-x11.c
@@ -1295,6 +1295,19 @@  x11_backend_deliver_enter_event(struct x11_backend *b,
 	b->prev_y = y;
 }
 
+static void
+x11_backend_deliver_leave_event(struct x11_backend *b,
+				xcb_generic_event_t *event)
+{
+	xcb_leave_notify_event_t *leave_notify =
+			(xcb_leave_notify_event_t *) event;
+	if (leave_notify->state >= Button1Mask)
+		return;
+	if (!b->has_xkb)
+		update_xkb_state_from_core(b, leave_notify->state);
+	notify_pointer_focus(&b->core_seat, NULL, 0, 0);
+}
+
 static int
 x11_backend_next_event(struct x11_backend *b,
 		       xcb_generic_event_t **event, uint32_t mask)
@@ -1314,7 +1327,6 @@  x11_backend_handle_event(int fd, uint32_t mask, void *data)
 	struct x11_output *output;
 	xcb_generic_event_t *event, *prev;
 	xcb_client_message_event_t *client_message;
-	xcb_enter_notify_event_t *enter_notify;
 	xcb_key_press_event_t *key_press, *key_release;
 	xcb_keymap_notify_event_t *keymap_notify;
 	xcb_focus_in_event_t *focus_in;
@@ -1439,12 +1451,7 @@  x11_backend_handle_event(int fd, uint32_t mask, void *data)
 			break;
 
 		case XCB_LEAVE_NOTIFY:
-			enter_notify = (xcb_enter_notify_event_t *) event;
-			if (enter_notify->state >= Button1Mask)
-				break;
-			if (!b->has_xkb)
-				update_xkb_state_from_core(b, enter_notify->state);
-			notify_pointer_focus(&b->core_seat, NULL, 0, 0);
+			x11_backend_deliver_leave_event(b, event);
 			break;
 
 		case XCB_CLIENT_MESSAGE: