Fix suppression of right clicks when activating the keyboard

This commit is contained in:
Cameron Gutman
2022-12-02 22:03:42 -06:00
parent be0c071fb5
commit 02e088ddb2
2 changed files with 12 additions and 5 deletions

View File

@@ -18,6 +18,7 @@ static const int REFERENCE_HEIGHT = 720;
BOOL touchMoved;
BOOL isDragging;
NSTimer* dragTimer;
NSUInteger peakTouchCount;
#if TARGET_OS_TV
UIGestureRecognizer* remotePressRecognizer;
@@ -59,6 +60,7 @@ static const int REFERENCE_HEIGHT = 720;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
touchMoved = false;
peakTouchCount = [[event allTouches] count];
if ([[event allTouches] count] == 1) {
UITouch *touch = [[event allTouches] anyObject];
originalLocation = touchLocation = [touch locationInView:view];
@@ -126,7 +128,7 @@ static const int REFERENCE_HEIGHT = 720;
isDragging = false;
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT);
} else if (!touchMoved) {
if ([[event allTouches] count] == 2) {
if (peakTouchCount == 2) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
Log(LOG_D, @"Sending right mouse button press");
@@ -137,7 +139,7 @@ static const int REFERENCE_HEIGHT = 720;
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_RIGHT);
});
} else if ([[event allTouches] count] == 1) {
} else if (peakTouchCount == 1) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
if (!self->isDragging){
Log(LOG_D, @"Sending left mouse button press");
@@ -175,6 +177,7 @@ static const int REFERENCE_HEIGHT = 720;
isDragging = false;
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT);
}
peakTouchCount = 0;
}
#if TARGET_OS_TV

View File

@@ -179,6 +179,13 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
[self startInteractionTimer];
if (![onScreenControls handleTouchDownEvent:touches]) {
// We still inform the touch handler even if we're going trigger the
// keyboard activation gesture. This is important to ensure the touch
// handler has a consistent view of touch events to correctly suppress
// activation of one or two finger gestures when a three finger gesture
// is triggered.
[touchHandler touchesBegan:touches withEvent:event];
if ([[event allTouches] count] == 3) {
if (isInputingText) {
Log(LOG_D, @"Closing the keyboard");
@@ -198,9 +205,6 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
isInputingText = true;
}
}
else {
[touchHandler touchesBegan:touches withEvent:event];
}
}
}