From a1f09f117fde5f8de9a111965beda5140d5ff937 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 1 Nov 2020 14:43:55 -0600 Subject: [PATCH] Fix first tap in touch mode not registering --- Limelight/Input/AbsoluteTouchHandler.m | 4 ++-- Limelight/Input/StreamView.h | 2 +- Limelight/Input/StreamView.m | 17 ++++++++++------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Limelight/Input/AbsoluteTouchHandler.m b/Limelight/Input/AbsoluteTouchHandler.m index 0e41ba3..b9b8c59 100644 --- a/Limelight/Input/AbsoluteTouchHandler.m +++ b/Limelight/Input/AbsoluteTouchHandler.m @@ -57,7 +57,7 @@ if (touch.timestamp - lastTouchUp.timestamp > DOUBLE_TAP_DEAD_ZONE_DELAY || sqrt(pow((touchLocation.x / view.bounds.size.width) - (lastTouchUpLocation.x / view.bounds.size.width), 2) + pow((touchLocation.y / view.bounds.size.height) - (lastTouchUpLocation.y / view.bounds.size.height), 2)) > DOUBLE_TAP_DEAD_ZONE_DELTA) { - [view updateCursorLocation:touchLocation]; + [view updateCursorLocation:touchLocation isMouse:NO]; } // Press the left button down @@ -90,7 +90,7 @@ longPressTimer = nil; } - [view updateCursorLocation:[[touches anyObject] locationInView:view]]; + [view updateCursorLocation:[[touches anyObject] locationInView:view] isMouse:NO]; } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { diff --git a/Limelight/Input/StreamView.h b/Limelight/Input/StreamView.h index 426d50a..d34d836 100644 --- a/Limelight/Input/StreamView.h +++ b/Limelight/Input/StreamView.h @@ -40,7 +40,7 @@ - (OnScreenControlsLevel) getCurrentOscState; #if !TARGET_OS_TV -- (void) updateCursorLocation:(CGPoint)location; +- (void) updateCursorLocation:(CGPoint)location isMouse:(BOOL)isMouse; #endif @end diff --git a/Limelight/Input/StreamView.m b/Limelight/Input/StreamView.m index 025c5a3..c7c9518 100644 --- a/Limelight/Input/StreamView.m +++ b/Limelight/Input/StreamView.m @@ -265,7 +265,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; // don't require this, but we do it anyway for them too. // Cursor movement without a button held down is handled // in pointerInteraction:regionForRequest:defaultRegion. - [self updateCursorLocation:[touch locationInView:self]]; + [self updateCursorLocation:[touch locationInView:self] isMouse:YES]; return; } } @@ -341,7 +341,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; } #if !TARGET_OS_TV -- (void) updateCursorLocation:(CGPoint)location { +- (void) updateCursorLocation:(CGPoint)location isMouse:(BOOL)isMouse { // These are now relative to the StreamView, however we need to scale them // further to make them relative to the actual video portion. float x = location.x - self.bounds.origin.x; @@ -382,19 +382,22 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; y = MIN(MAX(y, videoOrigin.y), videoOrigin.y + videoSize.height); // Send the mouse position relative to the video region if it has changed + // if we're receiving coordinates from a real mouse. // // NB: It is important for functionality (not just optimization) to only // send it if the value has changed. We will receive one of these events // any time the user presses a modifier key, which can result in errant // mouse motion when using a Citrix X1 mouse. - if (x != lastMouseX || y != lastMouseY) { - if (lastMouseX != 0 || lastMouseY != 0) { + if (x != lastMouseX || y != lastMouseY || !isMouse) { + if (lastMouseX != 0 || lastMouseY != 0 || !isMouse) { LiSendMousePositionEvent(x - videoOrigin.x, y - videoOrigin.y, videoSize.width, videoSize.height); } - lastMouseX = x; - lastMouseY = y; + if (isMouse) { + lastMouseX = x; + lastMouseY = y; + } } } @@ -422,7 +425,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; // Move the cursor on the host if no buttons are pressed. // Motion with buttons pressed in handled in touchesMoved: if (lastMouseButtonMask == 0) { - [self updateCursorLocation:request.location]; + [self updateCursorLocation:request.location isMouse:YES]; } // The pointer interaction should cover the video region only