From 0f2fd847241ed008ce46d340c40b2ead5580551e Mon Sep 17 00:00:00 2001 From: Quantum Date: Tue, 4 May 2021 04:53:31 -0400 Subject: [PATCH] [client] ds: avoid util_cursorToInt when warping pointer Using util_cursorToInt messes with the error tracking for normal movements, and is not necessary since we are computing an absolute position on the client window. Instead, we should pass doubles directly to display servers and let them decide how to best handle them. For example, XIWarpPointer accepts doubles directly. --- client/displayservers/Wayland/input.c | 4 ++-- client/displayservers/Wayland/wayland.h | 2 +- client/displayservers/X11/x11.c | 2 +- client/include/interface/displayserver.h | 2 +- client/src/core.c | 10 +++++----- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/client/displayservers/Wayland/input.c b/client/displayservers/Wayland/input.c index 30cd36c8..3e6fc77c 100644 --- a/client/displayservers/Wayland/input.c +++ b/client/displayservers/Wayland/input.c @@ -459,10 +459,10 @@ void waylandRealignPointer(void) app_resyncMouseBasic(); } -void waylandGuestPointerUpdated(double x, double y, int localX, int localY) +void waylandGuestPointerUpdated(double x, double y, double localX, double localY) { if (!wlWm.warpSupport || !wlWm.pointerInSurface || wlWm.lockedPointer) return; - waylandWarpPointer(localX, localY, false); + waylandWarpPointer((int) localX, (int) localY, false); } diff --git a/client/displayservers/Wayland/wayland.h b/client/displayservers/Wayland/wayland.h index 7ff02426..93c8a6c0 100644 --- a/client/displayservers/Wayland/wayland.h +++ b/client/displayservers/Wayland/wayland.h @@ -230,7 +230,7 @@ void waylandCapturePointer(void); void waylandUncapturePointer(void); void waylandRealignPointer(void); void waylandWarpPointer(int x, int y, bool exiting); -void waylandGuestPointerUpdated(double x, double y, int localX, int localY); +void waylandGuestPointerUpdated(double x, double y, double localX, double localY); // output module bool waylandOutputInit(void); diff --git a/client/displayservers/X11/x11.c b/client/displayservers/X11/x11.c index 7792c7f2..33e529d1 100644 --- a/client/displayservers/X11/x11.c +++ b/client/displayservers/X11/x11.c @@ -963,7 +963,7 @@ static void x11GLSwapBuffers(void) } #endif -static void x11GuestPointerUpdated(double x, double y, int localX, int localY) +static void x11GuestPointerUpdated(double x, double y, double localX, double localY) { if (app_isCaptureMode() || !x11.entered) return; diff --git a/client/include/interface/displayserver.h b/client/include/interface/displayserver.h index bc7b5119..8c2e72d5 100644 --- a/client/include/interface/displayserver.h +++ b/client/include/interface/displayserver.h @@ -129,7 +129,7 @@ struct LG_DisplayServerOps #endif /* dm specific cursor implementations */ - void (*guestPointerUpdated)(double x, double y, int localX, int localY); + void (*guestPointerUpdated)(double x, double y, double localX, double localY); void (*showPointer)(bool show); void (*grabKeyboard)(); void (*ungrabKeyboard)(); diff --git a/client/src/core.c b/client/src/core.c index 247029d2..cc7b5376 100644 --- a/client/src/core.c +++ b/client/src/core.c @@ -318,13 +318,13 @@ void core_stopFrameThread(void) void core_handleGuestMouseUpdate(void) { - int x, y; struct DoublePoint localPos; util_guestCurToLocal(&localPos); - localPos.x = util_clamp(localPos.x, 0.0, g_state.dstRect.w); - localPos.y = util_clamp(localPos.y, 0.0, g_state.dstRect.h); - util_cursorToInt(localPos.x, localPos.y, &x, &y); - g_state.ds->guestPointerUpdated(g_cursor.guest.x, g_cursor.guest.y, x, y); + g_state.ds->guestPointerUpdated( + g_cursor.guest.x, g_cursor.guest.y, + util_clamp(localPos.x, 0.0, g_state.dstRect.w), + util_clamp(localPos.y, 0.0, g_state.dstRect.h) + ); } void core_handleMouseGrabbed(double ex, double ey)