[weston,v2,11/21] input: Don't send wl_pointer.motion if position didn't change

Submitted by Jonas Ådahl on May 13, 2015, 10:26 a.m.

Details

Message ID 1431512802-6194-12-git-send-email-jadahl@gmail.com
State Accepted
Commit 8283c343ec0b21c88edc7dbfaafbc2ed53d78d61
Delegated to: Daniel Stone
Headers show

Not browsing as part of any series.

Commit Message

Jonas Ådahl May 13, 2015, 10:26 a.m.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
---
 src/input.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/input.c b/src/input.c
index cd24067..059ab03 100644
--- a/src/input.c
+++ b/src/input.c
@@ -169,6 +169,8 @@  default_grab_pointer_motion(struct weston_pointer_grab *grab, uint32_t time,
 	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;
 
 	if (pointer->focus) {
 		weston_pointer_motion_to_abs(pointer, event, &x, &y);
@@ -178,10 +180,12 @@  default_grab_pointer_motion(struct weston_pointer_grab *grab, uint32_t time,
 
 	weston_pointer_move(pointer, event);
 
-	resource_list = &pointer->focus_resource_list;
-	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) {
+		resource_list = &pointer->focus_resource_list;
+		wl_resource_for_each(resource, resource_list) {
+			wl_pointer_send_motion(resource, time,
+					       pointer->sx, pointer->sy);
+		}
 	}
 }