From 9c9a8cbb7ec40015f3351457751f45ab51b7c7b1 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Thu, 10 Aug 2023 23:44:17 -0700 Subject: [PATCH] [RCTTouchHandler] Add a small optimization to coordinate conversion --- React/Base/RCTTouchHandler.m | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/React/Base/RCTTouchHandler.m b/React/Base/RCTTouchHandler.m index f020f0d45287d4..ee4ada17d17e66 100644 --- a/React/Base/RCTTouchHandler.m +++ b/React/Base/RCTTouchHandler.m @@ -229,11 +229,10 @@ - (void)_updateReactTouchAtIndex:(NSInteger)touchIndex NSEvent *nativeTouch = _nativeTouches[touchIndex]; CGPoint location = nativeTouch.locationInWindow; RCTAssert(_cachedRootView, @"We were unable to find a root view for the touch"); - CGPoint rootViewLocation = [_cachedRootView.window.contentView convertPoint:location toView:_cachedRootView]; + CGPoint rootViewLocation = [_cachedRootView convertPoint:location fromView:nil]; + NSView *touchView = _touchViews[touchIndex]; CGPoint touchViewLocation = [touchView convertPoint:location fromView:nil]; - // JavaScript expects coordinates to have (0,0) at top left, unlike the macOS coordinate system - rootViewLocation.y = NSHeight([[_cachedRootView window] frame]) - rootViewLocation.y; #endif // macOS] NSMutableDictionary *reactTouch = _reactTouches[touchIndex];