summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Fourdan <ofourdan@redhat.com>2021-02-11 11:42:01 +0100
committerOlivier Fourdan <ofourdan@redhat.com>2021-02-15 09:42:00 +0100
commita4095162ca923992a8cfae6d0f09ff9f8144762a (patch)
treece18aaafa9725cfdf890766db5faaa56c198301b
parent1abab61dc23d585860bc847bcecb1b0315977c27 (diff)
xwayland: Use relative device for buttons/axis
We are using the relative pointer for motion events, but buttons and axis events still go through the absolute pointer device. That means additional DeviceChanged events that could be avoided if the buttons and axis events were coming from the same device as motion events. Route those events to the relative pointer if available so that motion, buttons and axis events come from the same device (most of the time). Suggested-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Related: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1130
-rw-r--r--hw/xwayland/xwayland-input.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index b1413b11f..c69636d7d 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -591,6 +591,15 @@ pointer_handle_motion(void *data, struct wl_pointer *pointer,
dispatch_pointer_motion_event(xwl_seat);
}
+static DeviceIntPtr
+get_pointer_device(struct xwl_seat *xwl_seat)
+{
+ if (xwl_seat->relative_pointer)
+ return xwl_seat->relative_pointer;
+ else
+ return xwl_seat->pointer;
+}
+
static void
pointer_handle_button(void *data, struct wl_pointer *pointer, uint32_t serial,
uint32_t time, uint32_t button, uint32_t state)
@@ -619,7 +628,7 @@ pointer_handle_button(void *data, struct wl_pointer *pointer, uint32_t serial,
}
valuator_mask_zero(&mask);
- QueuePointerEvents(xwl_seat->pointer,
+ QueuePointerEvents(get_pointer_device(xwl_seat),
state ? ButtonPress : ButtonRelease, index, 0, &mask);
}
@@ -661,7 +670,9 @@ pointer_handle_axis(void *data, struct wl_pointer *pointer,
} else {
valuator_mask_set_double(&mask, index, wl_fixed_to_double(value) / divisor);
}
- QueuePointerEvents(xwl_seat->pointer, MotionNotify, 0, POINTER_RELATIVE, &mask);
+
+ QueuePointerEvents(get_pointer_device(xwl_seat),
+ MotionNotify, 0, POINTER_RELATIVE, &mask);
}
static void