@@ -156,8 +156,10 @@ static void UpdateActiveTouchWithUITouch(
156156 CGPoint rootViewOriginOffset)
157157{
158158 CGPoint offsetPoint = [uiTouch locationInView: activeTouch.componentView];
159- CGPoint screenPoint = [uiTouch locationInView: uiTouch.window];
160159 CGPoint pagePoint = [uiTouch locationInView: rootComponentView];
160+ CGPoint screenPoint = [rootComponentView convertPoint: pagePoint
161+ toCoordinateSpace: rootComponentView.window.screen.coordinateSpace];
162+
161163 pagePoint = CGPointMake (pagePoint.x + rootViewOriginOffset.x , pagePoint.y + rootViewOriginOffset.y );
162164
163165 activeTouch.touch .offsetPoint = RCTPointFromCGPoint (offsetPoint);
@@ -255,6 +257,7 @@ static PointerEvent CreatePointerEventFromActiveTouch(ActiveTouch activeTouch, R
255257 event.pressure = touch.force ;
256258 event.pointerType = PointerTypeCStringFromUITouchType (activeTouch.touchType );
257259 event.clientPoint = touch.pagePoint ;
260+ event.screenPoint = touch.screenPoint ;
258261
259262 CGFloat pointerSize = activeTouch.majorRadius * 2.0 ;
260263 if (@available (iOS 13.4 , *)) {
@@ -285,8 +288,11 @@ static PointerEvent CreatePointerEventFromActiveTouch(ActiveTouch activeTouch, R
285288 return event;
286289}
287290
288- static PointerEvent
289- CreatePointerEventFromIncompleteHoverData (UIView *view, CGPoint clientLocation, NSTimeInterval timestamp)
291+ static PointerEvent CreatePointerEventFromIncompleteHoverData (
292+ UIView *view,
293+ CGPoint clientLocation,
294+ CGPoint screenLocation,
295+ NSTimeInterval timestamp)
290296{
291297 PointerEvent event = {};
292298 // "touch" events produced from a mouse cursor on iOS always have the ID 0 so
@@ -296,6 +302,7 @@ static PointerEvent CreatePointerEventFromActiveTouch(ActiveTouch activeTouch, R
296302 event.pressure = 0.0 ;
297303 event.pointerType = " mouse" ;
298304 event.clientPoint = RCTPointFromCGPoint (clientLocation);
305+ event.screenPoint = RCTPointFromCGPoint (screenLocation);
299306 event.width = 1.0 ;
300307 event.height = 1.0 ;
301308 event.tiltX = 0 ;
@@ -676,6 +683,8 @@ - (void)hovering:(UIHoverGestureRecognizer *)recognizer API_AVAILABLE(ios(13.0))
676683{
677684 UIView *listenerView = recognizer.view ;
678685 CGPoint clientLocation = [recognizer locationInView: listenerView];
686+ CGPoint screenLocation = [listenerView convertPoint: clientLocation
687+ toCoordinateSpace: listenerView.window.screen.coordinateSpace];
679688
680689 UIView *targetView = [listenerView hitTest: clientLocation withEvent: nil ];
681690 targetView = FindClosestFabricManagedTouchableView (targetView);
@@ -692,7 +701,8 @@ - (void)hovering:(UIHoverGestureRecognizer *)recognizer API_AVAILABLE(ios(13.0))
692701 BOOL shouldEmitOverEvent = IsAnyViewInPathListeningToEvent (eventPathViews, ViewEvents::Offset::PointerOver);
693702 SharedTouchEventEmitter eventEmitter = GetTouchEmitterFromView (targetView, [recognizer locationInView: targetView]);
694703 if (shouldEmitOverEvent && eventEmitter != nil ) {
695- PointerEvent event = CreatePointerEventFromIncompleteHoverData (targetView, clientLocation, timestamp);
704+ PointerEvent event =
705+ CreatePointerEventFromIncompleteHoverData (targetView, clientLocation, screenLocation, timestamp);
696706 eventEmitter->onPointerOver (event);
697707 }
698708 }
@@ -714,7 +724,8 @@ - (void)hovering:(UIHoverGestureRecognizer *)recognizer API_AVAILABLE(ios(13.0))
714724 SharedTouchEventEmitter eventEmitter =
715725 GetTouchEmitterFromView (componentView, [recognizer locationInView: componentView]);
716726 if (eventEmitter != nil ) {
717- PointerEvent event = CreatePointerEventFromIncompleteHoverData (componentView, clientLocation, timestamp);
727+ PointerEvent event =
728+ CreatePointerEventFromIncompleteHoverData (componentView, clientLocation, screenLocation, timestamp);
718729 eventEmitter->onPointerEnter (event);
719730 }
720731 }
@@ -732,7 +743,8 @@ - (void)hovering:(UIHoverGestureRecognizer *)recognizer API_AVAILABLE(ios(13.0))
732743 if (hasMoveListenerInEventPath) {
733744 SharedTouchEventEmitter eventEmitter = GetTouchEmitterFromView (targetView, [recognizer locationInView: targetView]);
734745 if (eventEmitter != nil ) {
735- PointerEvent event = CreatePointerEventFromIncompleteHoverData (targetView, clientLocation, timestamp);
746+ PointerEvent event =
747+ CreatePointerEventFromIncompleteHoverData (targetView, clientLocation, screenLocation, timestamp);
736748 eventEmitter->onPointerMove (event);
737749 }
738750 }
@@ -743,7 +755,8 @@ - (void)hovering:(UIHoverGestureRecognizer *)recognizer API_AVAILABLE(ios(13.0))
743755 SharedTouchEventEmitter eventEmitter =
744756 GetTouchEmitterFromView (prevTargetView, [recognizer locationInView: prevTargetView]);
745757 if (shouldEmitOutEvent && eventEmitter != nil ) {
746- PointerEvent event = CreatePointerEventFromIncompleteHoverData (prevTargetView, clientLocation, timestamp);
758+ PointerEvent event =
759+ CreatePointerEventFromIncompleteHoverData (prevTargetView, clientLocation, screenLocation, timestamp);
747760 eventEmitter->onPointerOut (event);
748761 }
749762 }
@@ -774,7 +787,8 @@ - (void)hovering:(UIHoverGestureRecognizer *)recognizer API_AVAILABLE(ios(13.0))
774787 SharedTouchEventEmitter eventEmitter =
775788 GetTouchEmitterFromView (componentView, [recognizer locationInView: componentView]);
776789 if (eventEmitter != nil ) {
777- PointerEvent event = CreatePointerEventFromIncompleteHoverData (componentView, clientLocation, timestamp);
790+ PointerEvent event =
791+ CreatePointerEventFromIncompleteHoverData (componentView, clientLocation, screenLocation, timestamp);
778792 eventEmitter->onPointerLeave (event);
779793 }
780794 }
0 commit comments