From f44942ea04263e4137583e380ebe7ab27adf5c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 22 Jul 2016 17:54:55 +0800 Subject: [PATCH] input: Split out motion sending from default grab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We'll reuse it later. Signed-off-by: Jonas Ã…dahl Reviewed-by: Daniel Stone --- libweston/input.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/libweston/input.c b/libweston/input.c index b559656e..b774d56d 100644 --- a/libweston/input.c +++ b/libweston/input.c @@ -339,13 +339,26 @@ weston_pointer_send_relative_motion(struct weston_pointer *pointer, } } +static void +weston_pointer_send_motion(struct weston_pointer *pointer, uint32_t time, + wl_fixed_t sx, wl_fixed_t sy) +{ + struct wl_list *resource_list; + struct wl_resource *resource; + + if (!pointer->focus_client) + return; + + resource_list = &pointer->focus_client->pointer_resources; + wl_resource_for_each(resource, resource_list) + wl_pointer_send_motion(resource, time, sx, sy); +} + static void default_grab_pointer_motion(struct weston_pointer_grab *grab, uint32_t time, struct weston_pointer_motion_event *event) { struct weston_pointer *pointer = grab->pointer; - struct wl_list *resource_list; - struct wl_resource *resource; wl_fixed_t x, y; wl_fixed_t old_sx = pointer->sx; wl_fixed_t old_sy = pointer->sy; @@ -358,13 +371,9 @@ default_grab_pointer_motion(struct weston_pointer_grab *grab, uint32_t time, weston_pointer_move(pointer, event); - if (pointer->focus_client && - (old_sx != pointer->sx || old_sy != pointer->sy)) { - resource_list = &pointer->focus_client->pointer_resources; - wl_resource_for_each(resource, resource_list) { - wl_pointer_send_motion(resource, time, - pointer->sx, pointer->sy); - } + if (old_sx != pointer->sx || old_sy != pointer->sy) { + weston_pointer_send_motion(pointer, time, + pointer->sx, pointer->sy); } weston_pointer_send_relative_motion(pointer, time, event);