Fix first tap in touch mode not registering

This commit is contained in:
Cameron Gutman
2020-11-01 14:43:55 -06:00
parent 7270554153
commit a1f09f117f
3 changed files with 13 additions and 10 deletions

View File

@@ -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 {

View File

@@ -40,7 +40,7 @@
- (OnScreenControlsLevel) getCurrentOscState;
#if !TARGET_OS_TV
- (void) updateCursorLocation:(CGPoint)location;
- (void) updateCursorLocation:(CGPoint)location isMouse:(BOOL)isMouse;
#endif
@end

View File

@@ -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