react-native-windows 0.84.0-preview.1 → 0.84.0-preview.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Common/Common.vcxproj +1 -1
- package/Folly/Folly.vcxproj +1 -1
- package/Libraries/Core/ReactNativeVersion.js +2 -2
- package/Libraries/Modal/Modal.windows.js +1 -7
- package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +58 -20
- package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +5 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +285 -70
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +18 -4
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +14 -9
- package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +4 -0
- package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.h +1 -0
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +4 -6
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +101 -44
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +4 -2
- package/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.cpp +3 -3
- package/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.h +3 -1
- package/Microsoft.ReactNative/Fabric/WindowsImageManager.cpp +0 -1
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +2 -2
- package/Microsoft.ReactNative/Modules/Animated/AnimatedNode.cpp +3 -3
- package/Microsoft.ReactNative/Modules/Animated/AnimatedNode.h +3 -2
- package/Microsoft.ReactNative/Modules/Timing.h +2 -1
- package/PropertySheets/External/Microsoft.ReactNative.Composition.CppApp.targets +2 -2
- package/PropertySheets/External/Microsoft.ReactNative.Composition.CppLib.targets +2 -2
- package/PropertySheets/External/Microsoft.ReactNative.Uwp.CSharpApp.targets +1 -1
- package/PropertySheets/External/Microsoft.ReactNative.Uwp.CppApp.targets +1 -1
- package/PropertySheets/Generated/PackageVersion.g.props +2 -2
- package/PropertySheets/JSEngine.props +3 -2
- package/ReactCommon/ReactCommon.vcxproj +1 -1
- package/Scripts/Tfs/Invoke-WebRequestWithRetry.ps1 +40 -0
- package/Scripts/perf/compare-results.js +68 -12
- package/package.json +15 -15
|
@@ -250,7 +250,10 @@ void CompositionEventHandler::Initialize() noexcept {
|
|
|
250
250
|
if (strongThis->SurfaceId() == -1)
|
|
251
251
|
return;
|
|
252
252
|
|
|
253
|
-
auto
|
|
253
|
+
auto *rootView = strongThis->RootComponentView();
|
|
254
|
+
if (!rootView)
|
|
255
|
+
return;
|
|
256
|
+
auto focusedComponent = rootView->GetFocusedComponent();
|
|
254
257
|
auto keyboardSource = winrt::make<CompositionInputKeyboardSource>(source);
|
|
255
258
|
auto keyArgs =
|
|
256
259
|
winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::KeyRoutedEventArgs>(
|
|
@@ -276,7 +279,10 @@ void CompositionEventHandler::Initialize() noexcept {
|
|
|
276
279
|
if (strongThis->SurfaceId() == -1)
|
|
277
280
|
return;
|
|
278
281
|
|
|
279
|
-
auto
|
|
282
|
+
auto *rootView = strongThis->RootComponentView();
|
|
283
|
+
if (!rootView)
|
|
284
|
+
return;
|
|
285
|
+
auto focusedComponent = rootView->GetFocusedComponent();
|
|
280
286
|
auto keyboardSource = winrt::make<CompositionInputKeyboardSource>(source);
|
|
281
287
|
auto keyArgs =
|
|
282
288
|
winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::KeyRoutedEventArgs>(
|
|
@@ -303,7 +309,10 @@ void CompositionEventHandler::Initialize() noexcept {
|
|
|
303
309
|
if (strongThis->SurfaceId() == -1)
|
|
304
310
|
return;
|
|
305
311
|
|
|
306
|
-
auto
|
|
312
|
+
auto *rootView = strongThis->RootComponentView();
|
|
313
|
+
if (!rootView)
|
|
314
|
+
return;
|
|
315
|
+
auto focusedComponent = rootView->GetFocusedComponent();
|
|
307
316
|
auto keyboardSource = winrt::make<CompositionInputKeyboardSource>(source);
|
|
308
317
|
auto charArgs = winrt::make<
|
|
309
318
|
winrt::Microsoft::ReactNative::Composition::Input::implementation::CharacterReceivedRoutedEventArgs>(
|
|
@@ -330,7 +339,10 @@ void CompositionEventHandler::Initialize() noexcept {
|
|
|
330
339
|
if (strongThis->SurfaceId() == -1)
|
|
331
340
|
return;
|
|
332
341
|
|
|
333
|
-
auto
|
|
342
|
+
auto *rootView = strongThis->RootComponentView();
|
|
343
|
+
if (!rootView)
|
|
344
|
+
return;
|
|
345
|
+
auto focusedComponent = rootView->GetFocusedComponent();
|
|
334
346
|
if (focusedComponent) {
|
|
335
347
|
auto tag =
|
|
336
348
|
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(focusedComponent)
|
|
@@ -358,6 +370,7 @@ CompositionEventHandler::~CompositionEventHandler() {
|
|
|
358
370
|
pointerSource.PointerMoved(m_pointerMovedToken);
|
|
359
371
|
pointerSource.PointerCaptureLost(m_pointerCaptureLostToken);
|
|
360
372
|
pointerSource.PointerWheelChanged(m_pointerWheelChangedToken);
|
|
373
|
+
pointerSource.PointerExited(m_pointerExitedToken);
|
|
361
374
|
auto keyboardSource = winrt::Microsoft::UI::Input::InputKeyboardSource::GetForIsland(island);
|
|
362
375
|
keyboardSource.KeyDown(m_keyDownToken);
|
|
363
376
|
keyboardSource.KeyUp(m_keyUpToken);
|
|
@@ -380,10 +393,15 @@ facebook::react::SurfaceId CompositionEventHandler::SurfaceId() const noexcept {
|
|
|
380
393
|
return -1;
|
|
381
394
|
}
|
|
382
395
|
|
|
383
|
-
winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView
|
|
396
|
+
winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView *
|
|
384
397
|
CompositionEventHandler::RootComponentView() const noexcept {
|
|
385
398
|
auto island = m_wkRootView.get();
|
|
386
|
-
|
|
399
|
+
if (!island) {
|
|
400
|
+
return nullptr;
|
|
401
|
+
}
|
|
402
|
+
return winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland>(island)
|
|
403
|
+
->GetComponentView()
|
|
404
|
+
.get();
|
|
387
405
|
}
|
|
388
406
|
|
|
389
407
|
void CompositionEventHandler::onPointerWheelChanged(
|
|
@@ -398,8 +416,11 @@ void CompositionEventHandler::onPointerWheelChanged(
|
|
|
398
416
|
|
|
399
417
|
// In the case of a sub rootview, we may have a non-zero origin. hitTest takes a pt in the parent coords, so we
|
|
400
418
|
// need to apply the current origin
|
|
401
|
-
|
|
402
|
-
|
|
419
|
+
auto *rootView = RootComponentView();
|
|
420
|
+
if (!rootView)
|
|
421
|
+
return;
|
|
422
|
+
ptScaled += rootView->layoutMetrics().frame.origin;
|
|
423
|
+
auto tag = rootView->hitTest(ptScaled, ptLocal);
|
|
403
424
|
|
|
404
425
|
if (tag == -1)
|
|
405
426
|
return;
|
|
@@ -553,7 +574,10 @@ int64_t CompositionEventHandler::SendMessage(HWND hwnd, uint32_t msg, uint64_t w
|
|
|
553
574
|
case WM_CHAR:
|
|
554
575
|
case WM_SYSCHAR: {
|
|
555
576
|
if (auto strongRootView = m_wkRootView.get()) {
|
|
556
|
-
auto
|
|
577
|
+
auto *rootView = RootComponentView();
|
|
578
|
+
if (!rootView)
|
|
579
|
+
break;
|
|
580
|
+
auto focusedComponent = rootView->GetFocusedComponent();
|
|
557
581
|
auto keyboardSource = winrt::make<CompositionKeyboardSource>(this);
|
|
558
582
|
auto args = winrt::make<
|
|
559
583
|
winrt::Microsoft::ReactNative::Composition::Input::implementation::CharacterReceivedRoutedEventArgs>(
|
|
@@ -576,7 +600,10 @@ int64_t CompositionEventHandler::SendMessage(HWND hwnd, uint32_t msg, uint64_t w
|
|
|
576
600
|
case WM_SYSKEYDOWN:
|
|
577
601
|
case WM_SYSKEYUP: {
|
|
578
602
|
if (auto strongRootView = m_wkRootView.get()) {
|
|
579
|
-
auto
|
|
603
|
+
auto *rootView = RootComponentView();
|
|
604
|
+
if (!rootView)
|
|
605
|
+
break;
|
|
606
|
+
auto focusedComponent = rootView->GetFocusedComponent();
|
|
580
607
|
auto keyboardSource = winrt::make<CompositionKeyboardSource>(this);
|
|
581
608
|
auto args = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::KeyRoutedEventArgs>(
|
|
582
609
|
focusedComponent
|
|
@@ -608,9 +635,12 @@ int64_t CompositionEventHandler::SendMessage(HWND hwnd, uint32_t msg, uint64_t w
|
|
|
608
635
|
|
|
609
636
|
void CompositionEventHandler::onKeyDown(
|
|
610
637
|
const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept {
|
|
611
|
-
RootComponentView()
|
|
638
|
+
auto *rootView = RootComponentView();
|
|
639
|
+
if (!rootView)
|
|
640
|
+
return;
|
|
641
|
+
rootView->UseKeyboardForProgrammaticFocus(true);
|
|
612
642
|
|
|
613
|
-
if (auto focusedComponent =
|
|
643
|
+
if (auto focusedComponent = rootView->GetFocusedComponent()) {
|
|
614
644
|
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(focusedComponent)->OnKeyDown(args);
|
|
615
645
|
|
|
616
646
|
if (args.Handled())
|
|
@@ -633,7 +663,7 @@ void CompositionEventHandler::onKeyDown(
|
|
|
633
663
|
}
|
|
634
664
|
|
|
635
665
|
if (!fCtrl && args.Key() == winrt::Windows::System::VirtualKey::Tab) {
|
|
636
|
-
if (
|
|
666
|
+
if (rootView->TryMoveFocus(!fShift, winrt::Microsoft::ReactNative::FocusState::Keyboard)) {
|
|
637
667
|
args.Handled(true);
|
|
638
668
|
}
|
|
639
669
|
|
|
@@ -643,9 +673,12 @@ void CompositionEventHandler::onKeyDown(
|
|
|
643
673
|
|
|
644
674
|
void CompositionEventHandler::onKeyUp(
|
|
645
675
|
const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept {
|
|
646
|
-
RootComponentView()
|
|
676
|
+
auto *rootView = RootComponentView();
|
|
677
|
+
if (!rootView)
|
|
678
|
+
return;
|
|
679
|
+
rootView->UseKeyboardForProgrammaticFocus(true);
|
|
647
680
|
|
|
648
|
-
if (auto focusedComponent =
|
|
681
|
+
if (auto focusedComponent = rootView->GetFocusedComponent()) {
|
|
649
682
|
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(focusedComponent)->OnKeyUp(args);
|
|
650
683
|
|
|
651
684
|
if (args.Handled())
|
|
@@ -655,7 +688,10 @@ void CompositionEventHandler::onKeyUp(
|
|
|
655
688
|
|
|
656
689
|
void CompositionEventHandler::onCharacterReceived(
|
|
657
690
|
const winrt::Microsoft::ReactNative::Composition::Input::CharacterReceivedRoutedEventArgs &args) noexcept {
|
|
658
|
-
|
|
691
|
+
auto *rootView = RootComponentView();
|
|
692
|
+
if (!rootView)
|
|
693
|
+
return;
|
|
694
|
+
if (auto focusedComponent = rootView->GetFocusedComponent()) {
|
|
659
695
|
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(focusedComponent)
|
|
660
696
|
->OnCharacterReceived(args);
|
|
661
697
|
|
|
@@ -664,7 +700,7 @@ void CompositionEventHandler::onCharacterReceived(
|
|
|
664
700
|
}
|
|
665
701
|
}
|
|
666
702
|
|
|
667
|
-
std::vector<winrt::Microsoft::ReactNative::ComponentView> GetTouchableViewsInPathToRoot(
|
|
703
|
+
std::vector<winrt::Microsoft::ReactNative::ComponentView> CompositionEventHandler::GetTouchableViewsInPathToRoot(
|
|
668
704
|
const winrt::Microsoft::ReactNative::ComponentView &componentView) {
|
|
669
705
|
std::vector<winrt::Microsoft::ReactNative::ComponentView> results;
|
|
670
706
|
auto view = componentView;
|
|
@@ -674,6 +710,7 @@ std::vector<winrt::Microsoft::ReactNative::ComponentView> GetTouchableViewsInPat
|
|
|
674
710
|
}
|
|
675
711
|
view = view.Parent();
|
|
676
712
|
}
|
|
713
|
+
|
|
677
714
|
return results;
|
|
678
715
|
}
|
|
679
716
|
|
|
@@ -974,8 +1011,8 @@ void CompositionEventHandler::UpdateActiveTouch(
|
|
|
974
1011
|
// activeTouch.touch.isEraser = false;
|
|
975
1012
|
activeTouch.touch.pagePoint.x = ptScaled.x;
|
|
976
1013
|
activeTouch.touch.pagePoint.y = ptScaled.y;
|
|
977
|
-
activeTouch.touch.screenPoint.x =
|
|
978
|
-
activeTouch.touch.screenPoint.y =
|
|
1014
|
+
activeTouch.touch.screenPoint.x = ptScaled.x;
|
|
1015
|
+
activeTouch.touch.screenPoint.y = ptScaled.y;
|
|
979
1016
|
activeTouch.touch.offsetPoint.x = ptLocal.x;
|
|
980
1017
|
activeTouch.touch.offsetPoint.y = ptLocal.y;
|
|
981
1018
|
activeTouch.touch.timestamp = static_cast<facebook::react::Float>(
|
|
@@ -1028,9 +1065,12 @@ void CompositionEventHandler::getTargetPointerArgs(
|
|
|
1028
1065
|
|
|
1029
1066
|
// In the case of a sub rootview, we may have a non-zero origin. hitTest takes a pt in the parent coords, so we need
|
|
1030
1067
|
// to apply the current origin
|
|
1031
|
-
|
|
1068
|
+
auto *rootView = RootComponentView();
|
|
1069
|
+
if (!rootView)
|
|
1070
|
+
return;
|
|
1071
|
+
ptScaled += rootView->layoutMetrics().frame.origin;
|
|
1032
1072
|
|
|
1033
|
-
if (
|
|
1073
|
+
if (m_capturedPointers.count(pointerId)) {
|
|
1034
1074
|
assert(m_pointerCapturingComponentTag != -1);
|
|
1035
1075
|
tag = m_pointerCapturingComponentTag;
|
|
1036
1076
|
|
|
@@ -1042,7 +1082,7 @@ void CompositionEventHandler::getTargetPointerArgs(
|
|
|
1042
1082
|
ptLocal.y = ptScaled.y - (clientRect.top / strongRootView.ScaleFactor());
|
|
1043
1083
|
}
|
|
1044
1084
|
} else {
|
|
1045
|
-
tag =
|
|
1085
|
+
tag = rootView->hitTest(ptScaled, ptLocal);
|
|
1046
1086
|
}
|
|
1047
1087
|
}
|
|
1048
1088
|
|
|
@@ -1052,16 +1092,49 @@ void CompositionEventHandler::onPointerCaptureLost(
|
|
|
1052
1092
|
if (SurfaceId() == -1)
|
|
1053
1093
|
return;
|
|
1054
1094
|
|
|
1055
|
-
if (m_pointerCapturingComponentTag) {
|
|
1095
|
+
if (m_pointerCapturingComponentTag != -1) {
|
|
1056
1096
|
// copy array to avoid iterator being invalidated during deletion
|
|
1057
|
-
std::
|
|
1097
|
+
std::unordered_set<PointerId> capturedPointers = m_capturedPointers;
|
|
1058
1098
|
|
|
1059
1099
|
for (auto pointerId : capturedPointers) {
|
|
1060
1100
|
releasePointerCapture(pointerId, m_pointerCapturingComponentTag);
|
|
1101
|
+
|
|
1102
|
+
// Cancel any active touch for this pointer so React Native is notified that
|
|
1103
|
+
// the touch ended. Without this, m_activeTouches retains a zombie entry and
|
|
1104
|
+
// RN JS is never told the touch is gone — leaving Pressables stuck in a
|
|
1105
|
+
// pressed state after a system-interrupted gesture (e.g. system back swipe,
|
|
1106
|
+
// Alt+Tab, another window coming foreground).
|
|
1107
|
+
auto activeTouch = m_activeTouches.find(pointerId);
|
|
1108
|
+
if (activeTouch != m_activeTouches.end()) {
|
|
1109
|
+
ActiveTouch cancelledTouchCopy = std::move(activeTouch->second);
|
|
1110
|
+
m_activeTouches.erase(activeTouch);
|
|
1111
|
+
if (cancelledTouchCopy.eventEmitter) {
|
|
1112
|
+
DispatchSynthesizedTouchCancelForActiveTouch(cancelledTouchCopy, pointerPoint, keyModifiers);
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1061
1115
|
}
|
|
1062
1116
|
|
|
1063
1117
|
m_pointerCapturingComponentTag = -1;
|
|
1064
1118
|
}
|
|
1119
|
+
|
|
1120
|
+
// Also cancel any active touch for the specific pointer that lost capture, even
|
|
1121
|
+
// when no JS-level CapturePointer was ever issued. This handles ScrollView (and
|
|
1122
|
+
// any other VisualInteractionSource) calling TryRedirectForManipulation: the OS
|
|
1123
|
+
// reassigns the pointer to the InteractionTracker, fires PointerCaptureLost, and
|
|
1124
|
+
// then stops delivering PointerMoved/PointerReleased to us. Without this cleanup
|
|
1125
|
+
// m_activeTouches keeps a zombie entry whose target is the originally-pressed
|
|
1126
|
+
// Pressable, leaving it visually pressed and causing later taps to be attributed
|
|
1127
|
+
// to that original target. If the entry was already cleared above (for a JS-level
|
|
1128
|
+
// capture) or by onPointerReleased running first, the find() is a no-op.
|
|
1129
|
+
PointerId pointerId = pointerPoint.PointerId();
|
|
1130
|
+
auto activeTouch = m_activeTouches.find(pointerId);
|
|
1131
|
+
if (activeTouch != m_activeTouches.end()) {
|
|
1132
|
+
ActiveTouch cancelledTouchCopy = std::move(activeTouch->second);
|
|
1133
|
+
m_activeTouches.erase(activeTouch);
|
|
1134
|
+
if (cancelledTouchCopy.eventEmitter) {
|
|
1135
|
+
DispatchSynthesizedTouchCancelForActiveTouch(cancelledTouchCopy, pointerPoint, keyModifiers);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1065
1138
|
}
|
|
1066
1139
|
|
|
1067
1140
|
void CompositionEventHandler::onPointerMoved(
|
|
@@ -1101,10 +1174,11 @@ void CompositionEventHandler::onPointerMoved(
|
|
|
1101
1174
|
|
|
1102
1175
|
auto handler = [&, targetView, pointerEvent, isActiveTouch](
|
|
1103
1176
|
std::vector<winrt::Microsoft::ReactNative::ComponentView> &eventPathViews) {
|
|
1177
|
+
auto *rootViewForEmitter = RootComponentView();
|
|
1104
1178
|
const auto eventEmitter = targetView
|
|
1105
1179
|
? winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(targetView)
|
|
1106
1180
|
->eventEmitterAtPoint(pointerEvent.offsetPoint)
|
|
1107
|
-
:
|
|
1181
|
+
: (rootViewForEmitter ? rootViewForEmitter->eventEmitterAtPoint(pointerEvent.offsetPoint) : nullptr);
|
|
1108
1182
|
|
|
1109
1183
|
if (eventEmitter != nullptr) {
|
|
1110
1184
|
eventEmitter->onPointerMove(pointerEvent);
|
|
@@ -1130,7 +1204,10 @@ void CompositionEventHandler::ClearAllHoveredForPointer(const facebook::react::P
|
|
|
1130
1204
|
// events. If we get null for the targetView, that means that the mouse is no over any components, so we have no
|
|
1131
1205
|
// element to send the move event to. However we need to send something so that any previously hovered elements
|
|
1132
1206
|
// are no longer hovered.
|
|
1133
|
-
auto
|
|
1207
|
+
auto *rootView = RootComponentView();
|
|
1208
|
+
if (!rootView)
|
|
1209
|
+
return;
|
|
1210
|
+
auto children = rootView->Children();
|
|
1134
1211
|
if (auto size = children.Size()) {
|
|
1135
1212
|
auto firstChild = children.GetAt(0);
|
|
1136
1213
|
if (auto childEventEmitter =
|
|
@@ -1170,28 +1247,67 @@ void CompositionEventHandler::onPointerExited(
|
|
|
1170
1247
|
}
|
|
1171
1248
|
}
|
|
1172
1249
|
|
|
1250
|
+
// Windows touch pointer IDs can be arbitrarily large (e.g. 2233). React Native's JS
|
|
1251
|
+
// touch handler uses identifiers as array indices and warns/misbehaves for values > 20.
|
|
1252
|
+
// This function maps each live Windows pointer to a small identifier in [0, 19] by
|
|
1253
|
+
// scanning m_activeTouches for in-use slots and cycling from the last assigned index.
|
|
1254
|
+
// Identifier MOUSE_POINTER_ID (1) is permanently reserved for mouse and never returned here.
|
|
1255
|
+
int CompositionEventHandler::AllocateTouchIdentifier() noexcept {
|
|
1256
|
+
constexpr int kMaxTouchIdentifier = 20;
|
|
1257
|
+
for (int i = 0; i < kMaxTouchIdentifier; i++) {
|
|
1258
|
+
int candidate = (m_touchId + i) % kMaxTouchIdentifier;
|
|
1259
|
+
if (candidate == static_cast<int>(MOUSE_POINTER_ID)) {
|
|
1260
|
+
continue; // reserved for mouse
|
|
1261
|
+
}
|
|
1262
|
+
bool inUse = std::any_of(m_activeTouches.begin(), m_activeTouches.end(), [candidate](const auto &pair) {
|
|
1263
|
+
return pair.second.touch.identifier == candidate;
|
|
1264
|
+
});
|
|
1265
|
+
if (!inUse) {
|
|
1266
|
+
m_touchId = (candidate + 1) % kMaxTouchIdentifier;
|
|
1267
|
+
return candidate;
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
// All non-mouse slots occupied (> 19 simultaneous touch/pen points) — wrap anyway,
|
|
1271
|
+
// skipping the mouse-reserved slot.
|
|
1272
|
+
int fallback = m_touchId;
|
|
1273
|
+
m_touchId = (m_touchId + 1) % kMaxTouchIdentifier;
|
|
1274
|
+
if (fallback == static_cast<int>(MOUSE_POINTER_ID)) {
|
|
1275
|
+
fallback = m_touchId;
|
|
1276
|
+
m_touchId = (m_touchId + 1) % kMaxTouchIdentifier;
|
|
1277
|
+
}
|
|
1278
|
+
return fallback;
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1173
1281
|
void CompositionEventHandler::onPointerPressed(
|
|
1174
1282
|
const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pointerPoint,
|
|
1175
1283
|
winrt::Windows::System::VirtualKeyModifiers keyModifiers) noexcept {
|
|
1176
1284
|
namespace Composition = winrt::Microsoft::ReactNative::Composition;
|
|
1177
1285
|
|
|
1178
|
-
RootComponentView()
|
|
1286
|
+
auto *rootView = RootComponentView();
|
|
1287
|
+
if (!rootView)
|
|
1288
|
+
return;
|
|
1289
|
+
rootView->UseKeyboardForProgrammaticFocus(false);
|
|
1179
1290
|
|
|
1180
1291
|
// Clears any active text selection when left pointer is pressed
|
|
1181
1292
|
if (pointerPoint.Properties().PointerUpdateKind() != Composition::Input::PointerUpdateKind::RightButtonPressed) {
|
|
1182
|
-
|
|
1293
|
+
rootView->ClearCurrentTextSelection();
|
|
1183
1294
|
}
|
|
1184
1295
|
|
|
1185
1296
|
PointerId pointerId = pointerPoint.PointerId();
|
|
1186
1297
|
|
|
1187
|
-
auto staleTouch =
|
|
1188
|
-
return pair.second.touch.identifier == pointerId;
|
|
1189
|
-
});
|
|
1298
|
+
auto staleTouch = m_activeTouches.find(pointerId);
|
|
1190
1299
|
|
|
1191
1300
|
if (staleTouch != m_activeTouches.end()) {
|
|
1192
|
-
// A pointer with this ID
|
|
1193
|
-
//
|
|
1194
|
-
|
|
1301
|
+
// A previous pointer with this ID was never properly released (e.g., app lost focus,
|
|
1302
|
+
// pointer left window). Cancel the stale touch and clean it up so the new press can proceed.
|
|
1303
|
+
// Copy and erase before dispatching to avoid holding a reference into m_activeTouches
|
|
1304
|
+
// across DispatchSynthesizedTouchCancelForActiveTouch, which calls HandleIncomingPointerEvent
|
|
1305
|
+
// and iterates m_activeTouches internally.
|
|
1306
|
+
ActiveTouch staleTouchCopy = std::move(staleTouch->second);
|
|
1307
|
+
m_activeTouches.erase(staleTouch);
|
|
1308
|
+
if (staleTouchCopy.eventEmitter) {
|
|
1309
|
+
DispatchSynthesizedTouchCancelForActiveTouch(staleTouchCopy, pointerPoint, keyModifiers);
|
|
1310
|
+
}
|
|
1195
1311
|
}
|
|
1196
1312
|
|
|
1197
1313
|
const auto eventType = TouchEventType::Start;
|
|
@@ -1212,7 +1328,18 @@ void CompositionEventHandler::onPointerPressed(
|
|
|
1212
1328
|
->OnPointerPressed(args);
|
|
1213
1329
|
|
|
1214
1330
|
ActiveTouch activeTouch{0};
|
|
1215
|
-
|
|
1331
|
+
switch (pointerPoint.PointerDeviceType()) {
|
|
1332
|
+
case Composition::Input::PointerDeviceType::Touch:
|
|
1333
|
+
activeTouch.touchType = UITouchType::Touch;
|
|
1334
|
+
break;
|
|
1335
|
+
case Composition::Input::PointerDeviceType::Pen:
|
|
1336
|
+
activeTouch.touchType = UITouchType::Pen;
|
|
1337
|
+
break;
|
|
1338
|
+
case Composition::Input::PointerDeviceType::Mouse:
|
|
1339
|
+
default:
|
|
1340
|
+
activeTouch.touchType = UITouchType::Mouse;
|
|
1341
|
+
break;
|
|
1342
|
+
}
|
|
1216
1343
|
|
|
1217
1344
|
// Map PointerUpdateKind to W3C button value
|
|
1218
1345
|
// https://developer.mozilla.org/docs/Web/API/MouseEvent/button
|
|
@@ -1250,14 +1377,27 @@ void CompositionEventHandler::onPointerPressed(
|
|
|
1250
1377
|
targetComponentView = targetComponentView.Parent();
|
|
1251
1378
|
}
|
|
1252
1379
|
|
|
1380
|
+
// Don't register the touch if no eventEmitter was found — inserting a null-emitter entry
|
|
1381
|
+
// into m_activeTouches would block future presses with the same pointer ID.
|
|
1382
|
+
if (!activeTouch.eventEmitter) {
|
|
1383
|
+
return;
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1253
1386
|
UpdateActiveTouch(activeTouch, ptScaled, ptLocal);
|
|
1254
1387
|
|
|
1255
|
-
activeTouch.isPrimary =
|
|
1256
|
-
|
|
1388
|
+
activeTouch.isPrimary = pointerPoint.Properties().IsPrimary();
|
|
1389
|
+
// Map the Windows pointer ID to a small identifier (0–19) safe for use as a JS array index.
|
|
1390
|
+
// Windows touch IDs can be arbitrarily large (e.g. 2233), which causes React Native to warn
|
|
1391
|
+
// and corrupts touch state, leaving Pressables stuck after a scroll.
|
|
1392
|
+
// Mouse pointer ID is always 1 (MOUSE_POINTER_ID), which is already within the safe range —
|
|
1393
|
+
// use it directly to preserve stable, predictable identifier assignment for mouse input.
|
|
1394
|
+
activeTouch.touch.identifier = (pointerPoint.PointerDeviceType() == Composition::Input::PointerDeviceType::Mouse)
|
|
1395
|
+
? static_cast<int>(MOUSE_POINTER_ID)
|
|
1396
|
+
: AllocateTouchIdentifier();
|
|
1257
1397
|
|
|
1258
1398
|
// If the pointer has not been marked as hovering over views before the touch started, we register
|
|
1259
1399
|
// that the activeTouch should not maintain its hovered state once the pointer has been lifted.
|
|
1260
|
-
auto currentlyHoveredTags = m_currentlyHoveredViewsPerPointer.find(
|
|
1400
|
+
auto currentlyHoveredTags = m_currentlyHoveredViewsPerPointer.find(pointerId);
|
|
1261
1401
|
if (currentlyHoveredTags == m_currentlyHoveredViewsPerPointer.end() || currentlyHoveredTags->second.empty()) {
|
|
1262
1402
|
activeTouch.shouldLeaveWhenReleased = true;
|
|
1263
1403
|
}
|
|
@@ -1273,11 +1413,12 @@ void CompositionEventHandler::onPointerReleased(
|
|
|
1273
1413
|
winrt::Windows::System::VirtualKeyModifiers keyModifiers) noexcept {
|
|
1274
1414
|
int pointerId = pointerPoint.PointerId();
|
|
1275
1415
|
|
|
1276
|
-
RootComponentView()
|
|
1416
|
+
auto *rootView = RootComponentView();
|
|
1417
|
+
if (!rootView)
|
|
1418
|
+
return;
|
|
1419
|
+
rootView->UseKeyboardForProgrammaticFocus(false);
|
|
1277
1420
|
|
|
1278
|
-
auto activeTouch =
|
|
1279
|
-
return pair.second.touch.identifier == pointerId;
|
|
1280
|
-
});
|
|
1421
|
+
auto activeTouch = m_activeTouches.find(pointerId);
|
|
1281
1422
|
|
|
1282
1423
|
if (activeTouch == m_activeTouches.end()) {
|
|
1283
1424
|
return;
|
|
@@ -1289,8 +1430,13 @@ void CompositionEventHandler::onPointerReleased(
|
|
|
1289
1430
|
facebook::react::Point ptLocal, ptScaled;
|
|
1290
1431
|
getTargetPointerArgs(fabricuiManager, pointerPoint, tag, ptScaled, ptLocal);
|
|
1291
1432
|
|
|
1292
|
-
if (tag == -1)
|
|
1433
|
+
if (tag == -1) {
|
|
1434
|
+
if (activeTouch->second.eventEmitter) {
|
|
1435
|
+
DispatchSynthesizedTouchCancelForActiveTouch(activeTouch->second, pointerPoint, keyModifiers);
|
|
1436
|
+
}
|
|
1437
|
+
m_activeTouches.erase(pointerId);
|
|
1293
1438
|
return;
|
|
1439
|
+
}
|
|
1294
1440
|
|
|
1295
1441
|
auto targetComponentView = fabricuiManager->GetViewRegistry().componentViewDescriptorWithTag(tag).view;
|
|
1296
1442
|
auto args = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::PointerRoutedEventArgs>(
|
|
@@ -1322,7 +1468,7 @@ bool CompositionEventHandler::CapturePointer(
|
|
|
1322
1468
|
}
|
|
1323
1469
|
|
|
1324
1470
|
m_pointerCapturingComponentTag = tag;
|
|
1325
|
-
m_capturedPointers.
|
|
1471
|
+
m_capturedPointers.insert(pointer.PointerId());
|
|
1326
1472
|
return true;
|
|
1327
1473
|
}
|
|
1328
1474
|
|
|
@@ -1337,11 +1483,9 @@ bool CompositionEventHandler::releasePointerCapture(PointerId pointerId, faceboo
|
|
|
1337
1483
|
bool result = false;
|
|
1338
1484
|
|
|
1339
1485
|
if (m_pointerCapturingComponentTag == tag) {
|
|
1340
|
-
|
|
1341
|
-
if (it == m_capturedPointers.end()) {
|
|
1486
|
+
if (m_capturedPointers.erase(pointerId) == 0) {
|
|
1342
1487
|
return false;
|
|
1343
1488
|
}
|
|
1344
|
-
m_capturedPointers.erase(it);
|
|
1345
1489
|
|
|
1346
1490
|
if (std::shared_ptr<FabricUIManager> fabricuiManager =
|
|
1347
1491
|
::Microsoft::ReactNative::FabricUIManager::FromProperties(m_context.Properties())) {
|
|
@@ -1352,7 +1496,7 @@ bool CompositionEventHandler::releasePointerCapture(PointerId pointerId, faceboo
|
|
|
1352
1496
|
->OnPointerCaptureLost();
|
|
1353
1497
|
}
|
|
1354
1498
|
|
|
1355
|
-
if (m_capturedPointers.
|
|
1499
|
+
if (m_capturedPointers.empty()) {
|
|
1356
1500
|
m_pointerCapturingComponentTag = -1;
|
|
1357
1501
|
return true;
|
|
1358
1502
|
}
|
|
@@ -1467,16 +1611,73 @@ bool CompositionEventHandler::IsPointerWithinInitialTree(const ActiveTouch &acti
|
|
|
1467
1611
|
if (!initialComponentView)
|
|
1468
1612
|
return false;
|
|
1469
1613
|
|
|
1470
|
-
auto
|
|
1614
|
+
auto *rootView = RootComponentView();
|
|
1615
|
+
if (!rootView)
|
|
1616
|
+
return false;
|
|
1617
|
+
|
|
1618
|
+
facebook::react::Point ptLocal;
|
|
1619
|
+
auto currentTag = rootView->hitTest(activeTouch.touch.pagePoint, ptLocal);
|
|
1620
|
+
if (currentTag == -1)
|
|
1621
|
+
return false;
|
|
1622
|
+
|
|
1623
|
+
auto fabricuiManager = ::Microsoft::ReactNative::FabricUIManager::FromProperties(m_context.Properties());
|
|
1624
|
+
if (!fabricuiManager)
|
|
1625
|
+
return false;
|
|
1471
1626
|
|
|
1472
|
-
|
|
1473
|
-
|
|
1627
|
+
auto initialTag = initialComponentView.Tag();
|
|
1628
|
+
auto &viewRegistry = fabricuiManager->GetViewRegistry();
|
|
1629
|
+
auto currentView = viewRegistry.componentViewDescriptorWithTag(currentTag).view;
|
|
1630
|
+
while (currentView) {
|
|
1631
|
+
if (currentView.Tag() == initialTag)
|
|
1474
1632
|
return true;
|
|
1633
|
+
currentView = currentView.Parent();
|
|
1475
1634
|
}
|
|
1476
1635
|
|
|
1477
1636
|
return false;
|
|
1478
1637
|
}
|
|
1479
1638
|
|
|
1639
|
+
void CompositionEventHandler::DispatchSynthesizedTouchCancelForActiveTouch(
|
|
1640
|
+
const ActiveTouch &cancelledTouch,
|
|
1641
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pointerPoint,
|
|
1642
|
+
winrt::Windows::System::VirtualKeyModifiers keyModifiers) {
|
|
1643
|
+
if (!cancelledTouch.eventEmitter) {
|
|
1644
|
+
return;
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
facebook::react::PointerEvent pointerEvent =
|
|
1648
|
+
CreatePointerEventFromActiveTouch(cancelledTouch, TouchEventType::Cancel);
|
|
1649
|
+
winrt::Microsoft::ReactNative::ComponentView targetView{nullptr};
|
|
1650
|
+
facebook::react::SharedTouchEventEmitter emitter = cancelledTouch.eventEmitter;
|
|
1651
|
+
auto pointerHandler = [emitter, pointerEvent](std::vector<winrt::Microsoft::ReactNative::ComponentView> &) {
|
|
1652
|
+
emitter->onPointerCancel(pointerEvent);
|
|
1653
|
+
};
|
|
1654
|
+
HandleIncomingPointerEvent(pointerEvent, targetView, pointerPoint, keyModifiers, pointerHandler);
|
|
1655
|
+
|
|
1656
|
+
facebook::react::TouchEvent touchEvent;
|
|
1657
|
+
touchEvent.changedTouches.insert(cancelledTouch.touch);
|
|
1658
|
+
|
|
1659
|
+
for (const auto &pair : m_activeTouches) {
|
|
1660
|
+
if (!pair.second.eventEmitter) {
|
|
1661
|
+
continue;
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
if (touchEvent.changedTouches.find(pair.second.touch) != touchEvent.changedTouches.end()) {
|
|
1665
|
+
continue;
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
touchEvent.touches.insert(pair.second.touch);
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
for (const auto &pair : m_activeTouches) {
|
|
1672
|
+
if (pair.second.eventEmitter == cancelledTouch.eventEmitter &&
|
|
1673
|
+
touchEvent.changedTouches.find(pair.second.touch) == touchEvent.changedTouches.end()) {
|
|
1674
|
+
touchEvent.targetTouches.insert(pair.second.touch);
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
cancelledTouch.eventEmitter->onTouchCancel(touchEvent);
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1480
1681
|
// If we have events that include multiple pointer updates, we should change arg from pointerId to vector<pointerId>
|
|
1481
1682
|
void CompositionEventHandler::DispatchTouchEvent(
|
|
1482
1683
|
TouchEventType eventType,
|
|
@@ -1493,7 +1694,15 @@ void CompositionEventHandler::DispatchTouchEvent(
|
|
|
1493
1694
|
|
|
1494
1695
|
facebook::react::TouchEvent event;
|
|
1495
1696
|
|
|
1496
|
-
|
|
1697
|
+
// First pass: build changedTouches and the set of unique emitters from every active
|
|
1698
|
+
// touch. The per-pointer PointerEvent dispatch (onPointerDown/Move/Up/Cancel/Click) is
|
|
1699
|
+
// fired only for the touch whose state actually changed — non-changed touches contribute
|
|
1700
|
+
// to the W3C TouchEvent's touches/targetTouches sets in the loops below but must not
|
|
1701
|
+
// re-fire pointer events of their own. Previously we dispatched the per-pointer event
|
|
1702
|
+
// for every entry in m_activeTouches, which produced duplicated onPointerMove on
|
|
1703
|
+
// non-moving fingers and replayed onPointerUp/onClick on stale targets after the OS
|
|
1704
|
+
// reclaimed a pointer (e.g. ScrollView manipulation redirect leaving a zombie touch).
|
|
1705
|
+
const ActiveTouch *changedTouch = nullptr;
|
|
1497
1706
|
for (const auto &pair : m_activeTouches) {
|
|
1498
1707
|
const auto &activeTouch = pair.second;
|
|
1499
1708
|
|
|
@@ -1501,49 +1710,55 @@ void CompositionEventHandler::DispatchTouchEvent(
|
|
|
1501
1710
|
continue;
|
|
1502
1711
|
}
|
|
1503
1712
|
|
|
1504
|
-
if (
|
|
1713
|
+
if (pair.first == pointerId) {
|
|
1714
|
+
changedTouch = &activeTouch;
|
|
1505
1715
|
event.changedTouches.insert(activeTouch.touch);
|
|
1506
1716
|
}
|
|
1507
1717
|
uniqueEventEmitters.insert(activeTouch.eventEmitter);
|
|
1718
|
+
}
|
|
1508
1719
|
|
|
1509
|
-
|
|
1720
|
+
if (changedTouch) {
|
|
1721
|
+
facebook::react::PointerEvent pointerEvent = CreatePointerEventFromActiveTouch(*changedTouch, eventType);
|
|
1510
1722
|
|
|
1511
1723
|
winrt::Microsoft::ReactNative::ComponentView targetView{nullptr};
|
|
1512
|
-
bool shouldLeave = (eventType == TouchEventType::End &&
|
|
1724
|
+
bool shouldLeave = (eventType == TouchEventType::End && changedTouch->shouldLeaveWhenReleased) ||
|
|
1513
1725
|
eventType == TouchEventType::Cancel;
|
|
1514
1726
|
if (!shouldLeave) {
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
auto
|
|
1520
|
-
|
|
1727
|
+
auto *rootViewForHit = RootComponentView();
|
|
1728
|
+
if (rootViewForHit) {
|
|
1729
|
+
const auto &viewRegistry = fabricuiManager->GetViewRegistry();
|
|
1730
|
+
facebook::react::Point ptLocal;
|
|
1731
|
+
auto targetTag = rootViewForHit->hitTest(pointerEvent.clientPoint, ptLocal);
|
|
1732
|
+
if (targetTag != -1) {
|
|
1733
|
+
auto targetComponentViewDescriptor = viewRegistry.componentViewDescriptorWithTag(targetTag);
|
|
1734
|
+
targetView = FindClosestFabricManagedTouchableView(targetComponentViewDescriptor.view);
|
|
1735
|
+
}
|
|
1521
1736
|
}
|
|
1522
1737
|
}
|
|
1523
1738
|
|
|
1524
|
-
auto handler = [
|
|
1739
|
+
auto handler = [this, changedTouch, eventType, &pointerEvent](
|
|
1525
1740
|
std::vector<winrt::Microsoft::ReactNative::ComponentView> &eventPathViews) {
|
|
1526
1741
|
switch (eventType) {
|
|
1527
1742
|
case TouchEventType::Start:
|
|
1528
|
-
|
|
1743
|
+
changedTouch->eventEmitter->onPointerDown(pointerEvent);
|
|
1529
1744
|
break;
|
|
1530
1745
|
case TouchEventType::Move: {
|
|
1531
|
-
|
|
1746
|
+
changedTouch->eventEmitter->onPointerMove(pointerEvent);
|
|
1532
1747
|
break;
|
|
1533
1748
|
}
|
|
1534
1749
|
case TouchEventType::End:
|
|
1535
|
-
|
|
1750
|
+
changedTouch->eventEmitter->onPointerUp(pointerEvent);
|
|
1536
1751
|
if (pointerEvent.isPrimary && pointerEvent.button == 0) {
|
|
1537
|
-
if (IsPointerWithinInitialTree(
|
|
1538
|
-
|
|
1752
|
+
if (IsPointerWithinInitialTree(*changedTouch)) {
|
|
1753
|
+
changedTouch->eventEmitter->onClick(pointerEvent);
|
|
1539
1754
|
}
|
|
1540
|
-
} /* else if (IsPointerWithinInitialTree(
|
|
1541
|
-
|
|
1755
|
+
} /* else if (IsPointerWithinInitialTree(*changedTouch)) {
|
|
1756
|
+
changedTouch->eventEmitter->onAuxClick(pointerEvent);
|
|
1542
1757
|
} */
|
|
1543
1758
|
break;
|
|
1544
1759
|
case TouchEventType::Cancel:
|
|
1545
1760
|
case TouchEventType::CaptureLost:
|
|
1546
|
-
|
|
1761
|
+
changedTouch->eventEmitter->onPointerCancel(pointerEvent);
|
|
1547
1762
|
break;
|
|
1548
1763
|
}
|
|
1549
1764
|
};
|