[PATCH xwayland 5/7] xwayland: Emit relative motion events on both warp/confinement situations
Jonas Ã…dahl
jadahl at gmail.com
Mon Feb 20 03:44:24 UTC 2017
On Sat, Nov 12, 2016 at 05:25:20PM +0100, Carlos Garnacho wrote:
> But just as long as the cursor is hidden. In the typical pattern in
> games of "hide cursor, grab with a confineTo, warp constantly the pointer
> to the middle of the window" the last warping step is actually rather
> optional.
>
> Some games may choose to just set up a grab with confineTo argument,
> and trust that they'll get correct relative X/Y axis values despite
> the hidden cursor hitting the confinement window edge.
>
> This makes Xwayland able to handle that pattern, downside is that
> perhaps clinging further on the x_cursor == NULL heuristic. Whenever
> the cursor is made visible again, the pointer will appear at whatever
> position it was left in, and Xwayland will switch back to using abs
> coordinates.
This will mean that we might get a "jump" when the cursor is made
visible, because it is likely that the fake cursor position that is a
result of the relative motions, and the actual absolute position as seen
by the compositor, eventually will become out of sync.
And, why is this needed? The client should still get the relative
coordinates via valuator_mask_set_absolute_unaccelerated() if there
actually are any. Or do they expect to get both absolute, accelerated
and unaccelerated x/y? If so, then I suppose we can just add yet another
valuator_mask_set() function that has even more information, so that we
avoid the jump we'd now get.
Jonas
>
> Signed-off-by: Carlos Garnacho <carlosg at gnome.org>
> ---
> hw/xwayland/xwayland-input.c | 39 ++++++++++++++++-----------------------
> 1 file changed, 16 insertions(+), 23 deletions(-)
>
> diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
> index 7ec3b1a..e5dbe4f 100644
> --- a/hw/xwayland/xwayland-input.c
> +++ b/hw/xwayland/xwayland-input.c
> @@ -47,11 +47,7 @@ struct sync_pending {
> };
>
> static void
> -xwl_pointer_warp_emulator_handle_motion(struct xwl_pointer_warp_emulator *warp_emulator,
> - double dx,
> - double dy,
> - double dx_unaccel,
> - double dy_unaccel);
> +xwl_pointer_warp_emulator_update(struct xwl_pointer_warp_emulator *warp_emulator);
> static void
> xwl_pointer_warp_emulator_maybe_lock(struct xwl_pointer_warp_emulator *warp_emulator,
> struct xwl_window *xwl_window,
> @@ -375,8 +371,10 @@ dispatch_pointer_motion_event(struct xwl_seat *xwl_seat)
> {
> ValuatorMask mask;
>
> - if (xwl_seat->pointer_warp_emulator &&
> - xwl_seat->pending_pointer_event.has_relative) {
> + if (xwl_seat->pending_pointer_event.has_relative &&
> + xwl_seat->x_cursor == NULL &&
> + (xwl_seat->pointer_warp_emulator ||
> + xwl_seat->cursor_confinement_window)) {
> double dx;
> double dy;
> double dx_unaccel;
> @@ -386,9 +384,16 @@ dispatch_pointer_motion_event(struct xwl_seat *xwl_seat)
> dy = xwl_seat->pending_pointer_event.dy;
> dx_unaccel = xwl_seat->pending_pointer_event.dx_unaccel;
> dy_unaccel = xwl_seat->pending_pointer_event.dy_unaccel;
> - xwl_pointer_warp_emulator_handle_motion(xwl_seat->pointer_warp_emulator,
> - dx, dy,
> - dx_unaccel, dy_unaccel);
> +
> + valuator_mask_zero(&mask);
> + valuator_mask_set_unaccelerated(&mask, 0, dx, dx_unaccel);
> + valuator_mask_set_unaccelerated(&mask, 1, dy, dy_unaccel);
> +
> + QueuePointerEvents(xwl_seat->relative_pointer, MotionNotify, 0,
> + POINTER_RELATIVE, &mask);
> +
> + if (xwl_seat->pointer_warp_emulator)
> + xwl_pointer_warp_emulator_update(xwl_seat->pointer_warp_emulator);
> } else if (xwl_seat->pending_pointer_event.has_absolute ||
> xwl_seat->pending_pointer_event.has_relative) {
> int x;
> @@ -1414,24 +1419,12 @@ xwl_pointer_warp_emulator_warp(struct xwl_pointer_warp_emulator *warp_emulator,
> }
>
> static void
> -xwl_pointer_warp_emulator_handle_motion(struct xwl_pointer_warp_emulator *warp_emulator,
> - double dx,
> - double dy,
> - double dx_unaccel,
> - double dy_unaccel)
> +xwl_pointer_warp_emulator_update(struct xwl_pointer_warp_emulator *warp_emulator)
> {
> struct xwl_seat *xwl_seat = warp_emulator->xwl_seat;
> - ValuatorMask mask;
> WindowPtr window;
> int x, y;
>
> - valuator_mask_zero(&mask);
> - valuator_mask_set_unaccelerated(&mask, 0, dx, dx_unaccel);
> - valuator_mask_set_unaccelerated(&mask, 1, dy, dy_unaccel);
> -
> - QueuePointerEvents(xwl_seat->relative_pointer, MotionNotify, 0,
> - POINTER_RELATIVE, &mask);
> -
> window = xwl_seat->focus_window->window;
> miPointerGetPosition(xwl_seat->pointer, &x, &y);
>
> --
> 2.9.3
>
More information about the xorg-devel
mailing list