From 8c5c55f9e193be8a195b885799ba84377c413cc5 Mon Sep 17 00:00:00 2001 From: Simon Chan <1330321+yume-chan@users.noreply.github.com> Date: Sun, 29 Jan 2023 22:23:11 +0100 Subject: [PATCH] Fix mouse pointer state update If the pointer is a mouse, the pointer is UP only when no buttons are pressed (not when a button is released, because there might be other buttons still pressed). Refs #3635 Signed-off-by: Romain Vimont --- server/src/main/java/com/genymobile/scrcpy/Controller.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/com/genymobile/scrcpy/Controller.java b/server/src/main/java/com/genymobile/scrcpy/Controller.java index 3dc609f1..bff01d9f 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Controller.java +++ b/server/src/main/java/com/genymobile/scrcpy/Controller.java @@ -196,22 +196,23 @@ public class Controller { Pointer pointer = pointersState.get(pointerIndex); pointer.setPoint(point); pointer.setPressure(pressure); - pointer.setUp(action == MotionEvent.ACTION_UP); int source; - int pointerCount = pointersState.update(pointerProperties, pointerCoords); if (pointerId == POINTER_ID_MOUSE || pointerId == POINTER_ID_VIRTUAL_MOUSE) { // real mouse event (forced by the client when --forward-on-click) pointerProperties[pointerIndex].toolType = MotionEvent.TOOL_TYPE_MOUSE; source = InputDevice.SOURCE_MOUSE; + pointer.setUp(buttons == 0); } else { // POINTER_ID_GENERIC_FINGER, POINTER_ID_VIRTUAL_FINGER or real touch from device pointerProperties[pointerIndex].toolType = MotionEvent.TOOL_TYPE_FINGER; source = InputDevice.SOURCE_TOUCHSCREEN; // Buttons must not be set for touch events buttons = 0; + pointer.setUp(action == MotionEvent.ACTION_UP); } + int pointerCount = pointersState.update(pointerProperties, pointerCoords); if (pointerCount == 1) { if (action == MotionEvent.ACTION_DOWN) { lastTouchDown = now;