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 a4095162ca)
(cherry picked from commit 20c78f38a0)
This commit is contained in:
Olivier Fourdan 2021-02-11 11:42:01 +01:00
parent 49c479a7c3
commit 4d2128fd1d
1 changed files with 15 additions and 4 deletions

View File

@ -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