Commit 4d2128fd authored by Olivier Fourdan's avatar Olivier Fourdan
Browse files

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

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's avatarPeter Hutterer <>
Signed-off-by: default avatarOlivier Fourdan <>
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <>
Reviewed-by: Peter Hutterer's avatarPeter Hutterer <>
Reviewed-by: default avatarOlivier Fourdan <>
Related: #1130
(cherry picked from commit a4095162)
(cherry picked from commit 20c78f38)
parent 49c479a7
Pipeline #272057 passed with stages
in 2 minutes and 42 seconds
......@@ -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;
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,
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);
MotionNotify, 0, POINTER_RELATIVE, &mask);
static void
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment