diff options
author | Olivier Fourdan <ofourdan@redhat.com> | 2021-02-11 11:42:01 +0100 |
---|---|---|
committer | Olivier Fourdan <ofourdan@redhat.com> | 2021-02-17 10:16:43 +0100 |
commit | 4d2128fd1dc2ff7293e8b95b956ddb07ddb15de9 (patch) | |
tree | 8488954c9db6001c8749aabcd7b93b52cc681c4a | |
parent | 49c479a7c352265f9173efed44a9091dd696423c (diff) | |
download | xserver-4d2128fd1dc2ff7293e8b95b956ddb07ddb15de9.tar.gz |
xwayland: Use relative device for buttons/axis/enter/leave
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.
However, routing just the buttons and axis events is not sufficient. In
Weston, clicking the window decoration of an Xwayland client gives us a
wl_pointer.button event immediately followed by a wl_pointer.leave event.
The leave event does not contain any button state information, so the button
remains logically down in the DIX.
Once the pointer button is released, a wl_pointer.enter event is sent with
the current button state (zero). This needs to trigger a ButtonRelease event
but for that we need to ensure that the device is the same as the one we send
ButtonPress events through.
Route those events along with enter/leave 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>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
Related: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1130
(cherry picked from commit a4095162ca923992a8cfae6d0f09ff9f8144762a)
(cherry picked from commit 20c78f38a0b33b88bc82a2bcd54d2e6c74a4c132)
-rw-r--r-- | hw/xwayland/xwayland-input.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c index b1413b11f..3e4fe2b91 100644 --- a/hw/xwayland/xwayland-input.c +++ b/hw/xwayland/xwayland-input.c @@ -92,6 +92,15 @@ xwl_pointer_control(DeviceIntPtr device, PtrCtrl *ctrl) /* Nothing to do, dix handles all settings */ } +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 Bool init_pointer_buttons(DeviceIntPtr device) { @@ -396,7 +405,7 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer, wl_fixed_t sx_w, wl_fixed_t sy_w) { struct xwl_seat *xwl_seat = data; - DeviceIntPtr dev = xwl_seat->pointer; + DeviceIntPtr dev = get_pointer_device(xwl_seat); DeviceIntPtr master; int i; int sx = wl_fixed_to_int(sx_w); @@ -471,7 +480,7 @@ pointer_handle_leave(void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface) { struct xwl_seat *xwl_seat = data; - DeviceIntPtr dev = xwl_seat->pointer; + DeviceIntPtr dev = get_pointer_device(xwl_seat); xwl_seat->xwl_screen->serial = serial; @@ -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 |