react-native-windows 0.76.2 → 0.76.3
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/Libraries/Components/View/View.windows.js +76 -52
- package/Libraries/Modal/Modal.windows.js +352 -0
- package/Libraries/Text/Text.windows.js +1 -1
- package/Microsoft.ReactNative/CompositionComponentView.idl +2 -1
- package/Microsoft.ReactNative/Fabric/AbiComponentDescriptor.cpp +4 -1
- package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/AbiViewProps.cpp +7 -0
- package/Microsoft.ReactNative/Fabric/AbiViewProps.h +2 -0
- package/Microsoft.ReactNative/Fabric/ComponentView.cpp +45 -50
- package/Microsoft.ReactNative/Fabric/ComponentView.h +14 -22
- package/Microsoft.ReactNative/Fabric/Composition/BorderPrimitive.cpp +943 -0
- package/Microsoft.ReactNative/Fabric/Composition/BorderPrimitive.h +80 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +26 -3
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +187 -6
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +10 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.cpp +8 -32
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +336 -929
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +32 -29
- package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +9 -2
- package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h +2 -1
- package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +181 -123
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +16 -8
- package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +99 -37
- package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +25 -3
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +63 -2
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +12 -0
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +51 -3
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +3 -0
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +18 -8
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +3 -0
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +54 -5
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +8 -0
- package/Microsoft.ReactNative/Fabric/Composition/Theme.cpp +9 -3
- package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +11 -0
- package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +2 -0
- package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewTraitsInitializer.h +1 -5
- package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +26 -0
- package/Microsoft.ReactNative/IReactViewComponentBuilder.idl +1 -1
- package/Microsoft.ReactNative/ReactNativeIsland.idl +3 -2
- package/Microsoft.ReactNative/ViewProps.idl +2 -0
- package/Microsoft.ReactNative.Cxx/ComponentView.Experimental.interop.h +14 -0
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/Shared/Shared.vcxitems +3 -0
- package/Shared/Shared.vcxitems.filters +1 -0
- package/codegen/NativeAccessibilityInfoSpec.g.h +1 -0
- package/codegen/NativeAccessibilityManagerSpec.g.h +1 -0
- package/codegen/NativeActionSheetManagerSpec.g.h +1 -0
- package/codegen/NativeAlertManagerSpec.g.h +1 -0
- package/codegen/NativeAnimatedModuleSpec.g.h +1 -0
- package/codegen/NativeAnimatedTurboModuleSpec.g.h +1 -0
- package/codegen/NativeAppStateSpec.g.h +1 -0
- package/codegen/NativeAppThemeSpec.g.h +1 -0
- package/codegen/NativeAppearanceSpec.g.h +1 -0
- package/codegen/NativeBlobModuleSpec.g.h +1 -0
- package/codegen/NativeBugReportingSpec.g.h +1 -0
- package/codegen/NativeClipboardSpec.g.h +1 -0
- package/codegen/NativeDOMSpec.g.h +1 -0
- package/codegen/NativeDevLoadingViewSpec.g.h +1 -0
- package/codegen/NativeDevMenuSpec.g.h +1 -0
- package/codegen/NativeDevSettingsSpec.g.h +1 -0
- package/codegen/NativeDevToolsSettingsManagerSpec.g.h +1 -0
- package/codegen/NativeDeviceEventManagerSpec.g.h +1 -0
- package/codegen/NativeDeviceInfoSpec.g.h +1 -0
- package/codegen/NativeDialogManagerAndroidSpec.g.h +1 -0
- package/codegen/NativeDialogManagerWindowsSpec.g.h +1 -0
- package/codegen/NativeExceptionsManagerSpec.g.h +1 -0
- package/codegen/NativeFileReaderModuleSpec.g.h +1 -0
- package/codegen/NativeFrameRateLoggerSpec.g.h +1 -0
- package/codegen/NativeHeadlessJsTaskSupportSpec.g.h +1 -0
- package/codegen/NativeI18nManagerSpec.g.h +1 -0
- package/codegen/NativeIdleCallbacksSpec.g.h +1 -0
- package/codegen/NativeImageEditorSpec.g.h +1 -0
- package/codegen/NativeImageLoaderAndroidSpec.g.h +1 -0
- package/codegen/NativeImageLoaderIOSSpec.g.h +1 -0
- package/codegen/NativeImageStoreAndroidSpec.g.h +1 -0
- package/codegen/NativeImageStoreIOSSpec.g.h +1 -0
- package/codegen/NativeIntentAndroidSpec.g.h +1 -0
- package/codegen/NativeIntersectionObserverSpec.g.h +1 -0
- package/codegen/NativeJSCHeapCaptureSpec.g.h +1 -0
- package/codegen/NativeJSCSamplingProfilerSpec.g.h +1 -0
- package/codegen/NativeKeyboardObserverSpec.g.h +1 -0
- package/codegen/NativeLinkingManagerSpec.g.h +1 -0
- package/codegen/NativeLogBoxSpec.g.h +1 -0
- package/codegen/NativeMicrotasksSpec.g.h +1 -0
- package/codegen/NativeModalManagerSpec.g.h +1 -0
- package/codegen/NativeMutationObserverSpec.g.h +1 -0
- package/codegen/NativeNetworkingAndroidSpec.g.h +1 -0
- package/codegen/NativeNetworkingIOSSpec.g.h +1 -0
- package/codegen/NativePerformanceObserverSpec.g.h +1 -0
- package/codegen/NativePerformanceSpec.g.h +1 -0
- package/codegen/NativePermissionsAndroidSpec.g.h +1 -0
- package/codegen/NativePlatformConstantsAndroidSpec.g.h +1 -0
- package/codegen/NativePlatformConstantsIOSSpec.g.h +1 -0
- package/codegen/NativePlatformConstantsWindowsSpec.g.h +1 -0
- package/codegen/NativePushNotificationManagerIOSSpec.g.h +1 -0
- package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +1 -0
- package/codegen/NativeRedBoxSpec.g.h +1 -0
- package/codegen/NativeSampleTurboModuleSpec.g.h +1 -0
- package/codegen/NativeSegmentFetcherSpec.g.h +1 -0
- package/codegen/NativeSettingsManagerSpec.g.h +1 -0
- package/codegen/NativeShareModuleSpec.g.h +1 -0
- package/codegen/NativeSoundManagerSpec.g.h +1 -0
- package/codegen/NativeSourceCodeSpec.g.h +1 -0
- package/codegen/NativeStatusBarManagerAndroidSpec.g.h +1 -0
- package/codegen/NativeStatusBarManagerIOSSpec.g.h +1 -0
- package/codegen/NativeTimingSpec.g.h +1 -0
- package/codegen/NativeToastAndroidSpec.g.h +1 -0
- package/codegen/NativeUIManagerSpec.g.h +1 -0
- package/codegen/NativeVibrationSpec.g.h +1 -0
- package/codegen/NativeWebSocketModuleSpec.g.h +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include <Fabric/ComponentView.h>
|
|
8
|
+
#include <Microsoft.ReactNative.Cxx/ReactContext.h>
|
|
9
|
+
#include <react/renderer/components/view/ViewEventEmitter.h>
|
|
10
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
11
|
+
#include "CompositionHelpers.h"
|
|
12
|
+
|
|
13
|
+
namespace winrt::Microsoft::ReactNative::Composition::implementation {
|
|
14
|
+
|
|
15
|
+
struct ComponentView;
|
|
16
|
+
|
|
17
|
+
// Controls adding/removing appropriate visuals to a parent to render a specific border without requiring
|
|
18
|
+
struct BorderPrimitive {
|
|
19
|
+
static constexpr size_t SpecialBorderLayerCount = 8;
|
|
20
|
+
|
|
21
|
+
// Use when attaching to an existing visual - We do this for View's border properties, to optimize the number of
|
|
22
|
+
// visuals for each view.
|
|
23
|
+
BorderPrimitive(
|
|
24
|
+
winrt::Microsoft::ReactNative::Composition::implementation::ComponentView &outer,
|
|
25
|
+
const winrt::Microsoft::ReactNative::Composition::Experimental::IVisual &rootVisual);
|
|
26
|
+
|
|
27
|
+
// This ctor creates a new root visual that can then be added to the visual tree
|
|
28
|
+
BorderPrimitive(winrt::Microsoft::ReactNative::Composition::implementation::ComponentView &outer);
|
|
29
|
+
|
|
30
|
+
void markNeedsUpdate() noexcept;
|
|
31
|
+
|
|
32
|
+
// We hoist focus visuals up the tree to allow them to be higher in the z-order.
|
|
33
|
+
// This means a single BorderPrimitive may change the owning ComponentView as focus moves around
|
|
34
|
+
void setOuter(winrt::Microsoft::ReactNative::Composition::implementation::ComponentView *outer) noexcept;
|
|
35
|
+
|
|
36
|
+
void updateProps(
|
|
37
|
+
const facebook::react::ViewProps &oldViewProps,
|
|
38
|
+
const facebook::react::ViewProps &newViewProps) noexcept;
|
|
39
|
+
void finalize(
|
|
40
|
+
facebook::react::LayoutMetrics const &layoutMetrics,
|
|
41
|
+
const facebook::react::BorderMetrics &borderMetrics) noexcept;
|
|
42
|
+
void onThemeChanged(
|
|
43
|
+
facebook::react::LayoutMetrics const &layoutMetrics,
|
|
44
|
+
const facebook::react::BorderMetrics &borderMetrics) noexcept;
|
|
45
|
+
|
|
46
|
+
uint8_t numberOfVisuals() const noexcept;
|
|
47
|
+
winrt::Microsoft::ReactNative::Composition::Experimental::IVisual RootVisual() const noexcept;
|
|
48
|
+
|
|
49
|
+
static facebook::react::BorderMetrics resolveAndAlignBorderMetrics(
|
|
50
|
+
facebook::react::LayoutMetrics const &layoutMetrics,
|
|
51
|
+
const facebook::react::ViewProps &viewProps) noexcept;
|
|
52
|
+
|
|
53
|
+
static bool requiresBorder(
|
|
54
|
+
const facebook::react::BorderMetrics &borderMetrics,
|
|
55
|
+
winrt::Microsoft::ReactNative::Composition::implementation::Theme *theme) noexcept;
|
|
56
|
+
|
|
57
|
+
static winrt::com_ptr<ID2D1PathGeometry> GenerateRoundedRectPathGeometry(
|
|
58
|
+
winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
|
|
59
|
+
const facebook::react::RectangleCorners<facebook::react::CornerRadii> &baseRadius,
|
|
60
|
+
const facebook::react::RectangleEdges<float> &inset,
|
|
61
|
+
const facebook::react::RectangleEdges<float> &rectPathGeometry) noexcept;
|
|
62
|
+
|
|
63
|
+
private:
|
|
64
|
+
std::array<winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual, SpecialBorderLayerCount>
|
|
65
|
+
FindSpecialBorderLayers() const noexcept;
|
|
66
|
+
|
|
67
|
+
bool TryUpdateSpecialBorderLayers(
|
|
68
|
+
winrt::Microsoft::ReactNative::Composition::implementation::Theme *theme,
|
|
69
|
+
std::array<winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual, SpecialBorderLayerCount>
|
|
70
|
+
&spBorderVisuals,
|
|
71
|
+
facebook::react::LayoutMetrics const &layoutMetrics,
|
|
72
|
+
const facebook::react::BorderMetrics &borderMetrics) noexcept;
|
|
73
|
+
|
|
74
|
+
uint8_t m_numBorderVisuals{0};
|
|
75
|
+
winrt::Microsoft::ReactNative::Composition::implementation::ComponentView *m_outer;
|
|
76
|
+
winrt::Microsoft::ReactNative::Composition::Experimental::IVisual m_rootVisual{nullptr};
|
|
77
|
+
bool m_needsUpdate{true};
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace winrt::Microsoft::ReactNative::Composition::implementation
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#include "pch.h"
|
|
2
2
|
#include "CompositionDynamicAutomationProvider.h"
|
|
3
3
|
#include <Fabric/ComponentView.h>
|
|
4
|
+
#include <Fabric/Composition/SwitchComponentView.h>
|
|
5
|
+
#include <Fabric/Composition/TextInput/WindowsTextInputComponentView.h>
|
|
4
6
|
#include <Unicode.h>
|
|
5
7
|
#include "RootComponentView.h"
|
|
6
8
|
#include "UiaHelpers.h"
|
|
@@ -141,6 +143,20 @@ bool expandableControl(const facebook::react::SharedViewProps props) {
|
|
|
141
143
|
return false;
|
|
142
144
|
}
|
|
143
145
|
|
|
146
|
+
bool togglableControl(const facebook::react::SharedViewProps props) {
|
|
147
|
+
if (props->accessibilityState.has_value() &&
|
|
148
|
+
props->accessibilityState->checked != facebook::react::AccessibilityState::None) {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
auto accessibilityActions = props->accessibilityActions;
|
|
152
|
+
for (size_t i = 0; i < accessibilityActions.size(); i++) {
|
|
153
|
+
if (accessibilityActions[i].name == "toggle") {
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
|
|
144
160
|
HRESULT __stdcall CompositionDynamicAutomationProvider::GetPatternProvider(PATTERNID patternId, IUnknown **pRetVal) {
|
|
145
161
|
if (pRetVal == nullptr)
|
|
146
162
|
return E_POINTER;
|
|
@@ -188,7 +204,9 @@ HRESULT __stdcall CompositionDynamicAutomationProvider::GetPatternProvider(PATTE
|
|
|
188
204
|
AddRef();
|
|
189
205
|
}
|
|
190
206
|
|
|
191
|
-
if (patternId == UIA_TogglePatternId &&
|
|
207
|
+
if (patternId == UIA_TogglePatternId &&
|
|
208
|
+
(strongView.try_as<winrt::Microsoft::ReactNative::Composition::implementation::SwitchComponentView>() ||
|
|
209
|
+
togglableControl(props))) {
|
|
192
210
|
*pRetVal = static_cast<IToggleProvider *>(this);
|
|
193
211
|
AddRef();
|
|
194
212
|
}
|
|
@@ -508,8 +526,13 @@ HRESULT __stdcall CompositionDynamicAutomationProvider::get_ToggleState(ToggleSt
|
|
|
508
526
|
if (!strongView)
|
|
509
527
|
return UIA_E_ELEMENTNOTAVAILABLE;
|
|
510
528
|
|
|
511
|
-
|
|
512
|
-
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(strongView)->
|
|
529
|
+
auto props = std::static_pointer_cast<const facebook::react::ViewProps>(
|
|
530
|
+
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(strongView)->props());
|
|
531
|
+
|
|
532
|
+
*pRetVal = (props->accessibilityState.has_value() &&
|
|
533
|
+
props->accessibilityState->checked != facebook::react::AccessibilityState::None)
|
|
534
|
+
? GetToggleState(props->accessibilityState)
|
|
535
|
+
: winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(strongView)->getToggleState();
|
|
513
536
|
return S_OK;
|
|
514
537
|
}
|
|
515
538
|
|
|
@@ -12,15 +12,18 @@
|
|
|
12
12
|
#include <Views/ShadowNodeBase.h>
|
|
13
13
|
#include <windows.h>
|
|
14
14
|
#include <windowsx.h>
|
|
15
|
+
#include <winrt/Windows.UI.Core.h>
|
|
15
16
|
#include <winrt/Windows.UI.Input.h>
|
|
16
17
|
#include "Composition.Input.h"
|
|
17
18
|
#include "CompositionViewComponentView.h"
|
|
18
19
|
#include "ReactNativeIsland.h"
|
|
19
20
|
#include "RootComponentView.h"
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
namespace ABI::Microsoft::UI::Input {
|
|
23
|
+
struct IInputCursor;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#include <Microsoft.UI.Input.InputCursor.Interop.h>
|
|
24
27
|
|
|
25
28
|
namespace Microsoft::ReactNative {
|
|
26
29
|
|
|
@@ -139,8 +142,9 @@ struct CompositionInputKeyboardSource : winrt::implements<
|
|
|
139
142
|
|
|
140
143
|
CompositionEventHandler::CompositionEventHandler(
|
|
141
144
|
const winrt::Microsoft::ReactNative::ReactContext &context,
|
|
142
|
-
const winrt::Microsoft::ReactNative::ReactNativeIsland &reactNativeIsland
|
|
143
|
-
|
|
145
|
+
const winrt::Microsoft::ReactNative::ReactNativeIsland &reactNativeIsland,
|
|
146
|
+
const int fragmentTag)
|
|
147
|
+
: m_fragmentTag(fragmentTag), m_context(context), m_wkRootView(reactNativeIsland) {}
|
|
144
148
|
|
|
145
149
|
void CompositionEventHandler::Initialize() noexcept {
|
|
146
150
|
#ifdef USE_WINUI3
|
|
@@ -327,6 +331,11 @@ CompositionEventHandler::~CompositionEventHandler() {
|
|
|
327
331
|
}
|
|
328
332
|
}
|
|
329
333
|
#endif
|
|
334
|
+
|
|
335
|
+
if (m_hcursorOwned) {
|
|
336
|
+
::DestroyCursor(m_hcursor);
|
|
337
|
+
m_hcursor = nullptr;
|
|
338
|
+
}
|
|
330
339
|
}
|
|
331
340
|
|
|
332
341
|
facebook::react::SurfaceId CompositionEventHandler::SurfaceId() const noexcept {
|
|
@@ -506,6 +515,10 @@ int64_t CompositionEventHandler::SendMessage(HWND hwnd, uint32_t msg, uint64_t w
|
|
|
506
515
|
}
|
|
507
516
|
break;
|
|
508
517
|
}
|
|
518
|
+
case WM_SETCURSOR: {
|
|
519
|
+
UpdateCursor();
|
|
520
|
+
return 1;
|
|
521
|
+
}
|
|
509
522
|
}
|
|
510
523
|
|
|
511
524
|
return 0;
|
|
@@ -752,6 +765,151 @@ void CompositionEventHandler::HandleIncomingPointerEvent(
|
|
|
752
765
|
hoveredViews.emplace_back(ReactTaggedView(componentViewDescriptor.view));
|
|
753
766
|
}
|
|
754
767
|
m_currentlyHoveredViewsPerPointer[pointerId] = std::move(hoveredViews);
|
|
768
|
+
|
|
769
|
+
if (IsMousePointerEvent(event)) {
|
|
770
|
+
UpdateCursor();
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
void CompositionEventHandler::UpdateCursor() noexcept {
|
|
775
|
+
for (auto &taggedView : m_currentlyHoveredViewsPerPointer[MOUSE_POINTER_ID]) {
|
|
776
|
+
if (auto view = taggedView.view()) {
|
|
777
|
+
if (auto viewcomponent =
|
|
778
|
+
view.try_as<winrt::Microsoft::ReactNative::Composition::implementation::ComponentView>()) {
|
|
779
|
+
auto cursorInfo = viewcomponent->cursor();
|
|
780
|
+
if (cursorInfo.first != facebook::react::Cursor::Auto || cursorInfo.second != nullptr) {
|
|
781
|
+
SetCursor(cursorInfo.first, cursorInfo.second);
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
SetCursor(facebook::react::Cursor::Auto, nullptr);
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
void CompositionEventHandler::SetCursor(facebook::react::Cursor cursor, HCURSOR hcur) noexcept {
|
|
792
|
+
if (m_currentCursor == cursor && m_hcursor == hcur)
|
|
793
|
+
return;
|
|
794
|
+
|
|
795
|
+
if (auto strongRootView = m_wkRootView.get()) {
|
|
796
|
+
if (auto island = strongRootView.Island()) {
|
|
797
|
+
auto pointerSource = winrt::Microsoft::UI::Input::InputPointerSource::GetForIsland(island);
|
|
798
|
+
|
|
799
|
+
if (!hcur) {
|
|
800
|
+
winrt::Windows::UI::Core::CoreCursorType type = winrt::Windows::UI::Core::CoreCursorType::Arrow;
|
|
801
|
+
switch (cursor) {
|
|
802
|
+
case facebook::react::Cursor::Pointer:
|
|
803
|
+
type = winrt::Windows::UI::Core::CoreCursorType::Hand;
|
|
804
|
+
break;
|
|
805
|
+
case facebook::react::Cursor::Help:
|
|
806
|
+
type = winrt::Windows::UI::Core::CoreCursorType::Help;
|
|
807
|
+
break;
|
|
808
|
+
case facebook::react::Cursor::NotAllowed:
|
|
809
|
+
type = winrt::Windows::UI::Core::CoreCursorType::UniversalNo;
|
|
810
|
+
break;
|
|
811
|
+
case facebook::react::Cursor::Wait:
|
|
812
|
+
type = winrt::Windows::UI::Core::CoreCursorType::Wait;
|
|
813
|
+
break;
|
|
814
|
+
case facebook::react::Cursor::Move:
|
|
815
|
+
type = winrt::Windows::UI::Core::CoreCursorType::SizeAll;
|
|
816
|
+
break;
|
|
817
|
+
case facebook::react::Cursor::NESWResize:
|
|
818
|
+
type = winrt::Windows::UI::Core::CoreCursorType::SizeNortheastSouthwest;
|
|
819
|
+
break;
|
|
820
|
+
case facebook::react::Cursor::NSResize:
|
|
821
|
+
type = winrt::Windows::UI::Core::CoreCursorType::SizeNorthSouth;
|
|
822
|
+
break;
|
|
823
|
+
case facebook::react::Cursor::NWSEResize:
|
|
824
|
+
type = winrt::Windows::UI::Core::CoreCursorType::SizeNorthwestSoutheast;
|
|
825
|
+
break;
|
|
826
|
+
case facebook::react::Cursor::EWResize:
|
|
827
|
+
type = winrt::Windows::UI::Core::CoreCursorType::SizeWestEast;
|
|
828
|
+
break;
|
|
829
|
+
case facebook::react::Cursor::Text:
|
|
830
|
+
type = winrt::Windows::UI::Core::CoreCursorType::IBeam;
|
|
831
|
+
break;
|
|
832
|
+
case facebook::react::Cursor::Progress:
|
|
833
|
+
type = winrt::Windows::UI::Core::CoreCursorType::Wait; // IDC_APPSTARTING not mapped to CoreCursor?
|
|
834
|
+
break;
|
|
835
|
+
case facebook::react::Cursor::Crosshair:
|
|
836
|
+
type = winrt::Windows::UI::Core::CoreCursorType::Cross;
|
|
837
|
+
break;
|
|
838
|
+
default:
|
|
839
|
+
break;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
m_inputCursor = winrt::Microsoft::UI::Input::InputCursor::CreateFromCoreCursor(
|
|
843
|
+
winrt::Windows::UI::Core::CoreCursor(type, 0));
|
|
844
|
+
m_hcursor = hcur;
|
|
845
|
+
} else {
|
|
846
|
+
auto cursorInterop = winrt::get_activation_factory<
|
|
847
|
+
winrt::Microsoft::UI::Input::InputCursor,
|
|
848
|
+
ABI::Microsoft::UI::Input::IInputCursorStaticsInterop>();
|
|
849
|
+
winrt::com_ptr<IUnknown> spunk;
|
|
850
|
+
winrt::check_hresult(cursorInterop->CreateFromHCursor(
|
|
851
|
+
hcur, reinterpret_cast<ABI::Microsoft::UI::Input::IInputCursor **>(spunk.put_void())));
|
|
852
|
+
m_hcursor = hcur;
|
|
853
|
+
m_inputCursor = spunk.as<winrt::Microsoft::UI::Input::InputCursor>();
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
pointerSource.Cursor(m_inputCursor);
|
|
857
|
+
} else {
|
|
858
|
+
if (m_hcursorOwned) {
|
|
859
|
+
::DestroyCursor(m_hcursor);
|
|
860
|
+
m_hcursorOwned = false;
|
|
861
|
+
}
|
|
862
|
+
if (hcur == nullptr) {
|
|
863
|
+
const WCHAR *idc = IDC_ARROW;
|
|
864
|
+
switch (cursor) {
|
|
865
|
+
case facebook::react::Cursor::Pointer:
|
|
866
|
+
idc = IDC_HAND;
|
|
867
|
+
break;
|
|
868
|
+
case facebook::react::Cursor::Help:
|
|
869
|
+
idc = IDC_HELP;
|
|
870
|
+
break;
|
|
871
|
+
case facebook::react::Cursor::NotAllowed:
|
|
872
|
+
idc = IDC_NO;
|
|
873
|
+
break;
|
|
874
|
+
case facebook::react::Cursor::Wait:
|
|
875
|
+
idc = IDC_WAIT;
|
|
876
|
+
break;
|
|
877
|
+
case facebook::react::Cursor::Move:
|
|
878
|
+
idc = IDC_SIZEALL;
|
|
879
|
+
break;
|
|
880
|
+
case facebook::react::Cursor::NESWResize:
|
|
881
|
+
idc = IDC_SIZENESW;
|
|
882
|
+
break;
|
|
883
|
+
case facebook::react::Cursor::NSResize:
|
|
884
|
+
idc = IDC_SIZENS;
|
|
885
|
+
break;
|
|
886
|
+
case facebook::react::Cursor::NWSEResize:
|
|
887
|
+
idc = IDC_SIZENWSE;
|
|
888
|
+
break;
|
|
889
|
+
case facebook::react::Cursor::EWResize:
|
|
890
|
+
idc = IDC_SIZEWE;
|
|
891
|
+
break;
|
|
892
|
+
case facebook::react::Cursor::Text:
|
|
893
|
+
idc = IDC_IBEAM;
|
|
894
|
+
break;
|
|
895
|
+
case facebook::react::Cursor::Progress:
|
|
896
|
+
idc = IDC_APPSTARTING;
|
|
897
|
+
break;
|
|
898
|
+
case facebook::react::Cursor::Crosshair:
|
|
899
|
+
idc = IDC_CROSS;
|
|
900
|
+
break;
|
|
901
|
+
default:
|
|
902
|
+
break;
|
|
903
|
+
}
|
|
904
|
+
m_hcursor = ::LoadCursor(nullptr, idc);
|
|
905
|
+
m_hcursorOwned = true;
|
|
906
|
+
} else {
|
|
907
|
+
m_hcursor = hcur;
|
|
908
|
+
}
|
|
909
|
+
::SetCursor(m_hcursor);
|
|
910
|
+
}
|
|
911
|
+
m_currentCursor = cursor;
|
|
912
|
+
}
|
|
755
913
|
}
|
|
756
914
|
|
|
757
915
|
void CompositionEventHandler::UpdateActiveTouch(
|
|
@@ -831,7 +989,30 @@ void CompositionEventHandler::getTargetPointerArgs(
|
|
|
831
989
|
ptLocal.y = ptScaled.y - (clientRect.top / strongRootView.ScaleFactor());
|
|
832
990
|
}
|
|
833
991
|
} else {
|
|
834
|
-
|
|
992
|
+
if (m_fragmentTag == -1) {
|
|
993
|
+
tag = RootComponentView().hitTest(ptScaled, ptLocal);
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
// check if the fragment tag exists
|
|
998
|
+
if (!fabricuiManager->GetViewRegistry().findComponentViewWithTag(m_fragmentTag)) {
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
auto fagmentView = fabricuiManager->GetViewRegistry().componentViewDescriptorWithTag(m_fragmentTag).view;
|
|
1003
|
+
auto fagmentchildren = fagmentView.Children();
|
|
1004
|
+
|
|
1005
|
+
// call the hitTest with the fargment as the RootComponent
|
|
1006
|
+
for (auto index = fagmentchildren.Size(); index > 0; index--) {
|
|
1007
|
+
auto childView = fagmentchildren.GetAt(index - 1);
|
|
1008
|
+
auto targetTag =
|
|
1009
|
+
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(childView)->hitTest(
|
|
1010
|
+
ptScaled, ptLocal);
|
|
1011
|
+
if (targetTag != -1) {
|
|
1012
|
+
tag = targetTag;
|
|
1013
|
+
break;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
835
1016
|
}
|
|
836
1017
|
}
|
|
837
1018
|
|
|
@@ -31,7 +31,8 @@ class CompositionEventHandler : public std::enable_shared_from_this<CompositionE
|
|
|
31
31
|
public:
|
|
32
32
|
CompositionEventHandler(
|
|
33
33
|
const winrt::Microsoft::ReactNative::ReactContext &context,
|
|
34
|
-
const winrt::Microsoft::ReactNative::ReactNativeIsland &ReactNativeIsland
|
|
34
|
+
const winrt::Microsoft::ReactNative::ReactNativeIsland &ReactNativeIsland,
|
|
35
|
+
const int fragmentTag);
|
|
35
36
|
virtual ~CompositionEventHandler();
|
|
36
37
|
|
|
37
38
|
void Initialize() noexcept;
|
|
@@ -146,8 +147,12 @@ class CompositionEventHandler : public std::enable_shared_from_this<CompositionE
|
|
|
146
147
|
static void
|
|
147
148
|
UpdateActiveTouch(ActiveTouch &activeTouch, facebook::react::Point ptScaled, facebook::react::Point ptLocal) noexcept;
|
|
148
149
|
|
|
150
|
+
void UpdateCursor() noexcept;
|
|
151
|
+
void SetCursor(facebook::react::Cursor cursor, HCURSOR hcur) noexcept;
|
|
152
|
+
|
|
149
153
|
std::map<PointerId, ActiveTouch> m_activeTouches; // iOS is map of touch event args to ActiveTouch..?
|
|
150
154
|
PointerId m_touchId = 0;
|
|
155
|
+
int m_fragmentTag = -1;
|
|
151
156
|
|
|
152
157
|
std::map<PointerId, std::vector<ReactTaggedView>> m_currentlyHoveredViewsPerPointer;
|
|
153
158
|
winrt::weak_ref<winrt::Microsoft::ReactNative::ReactNativeIsland> m_wkRootView;
|
|
@@ -155,6 +160,10 @@ class CompositionEventHandler : public std::enable_shared_from_this<CompositionE
|
|
|
155
160
|
|
|
156
161
|
facebook::react::Tag m_pointerCapturingComponentTag{-1}; // Component that has captured input
|
|
157
162
|
std::vector<PointerId> m_capturedPointers;
|
|
163
|
+
HCURSOR m_hcursor{nullptr};
|
|
164
|
+
bool m_hcursorOwned{false}; // If we create the cursor, so we need to destroy it
|
|
165
|
+
facebook::react::Cursor m_currentCursor{facebook::react::Cursor::Auto};
|
|
166
|
+
winrt::Microsoft::UI::Input::InputCursor m_inputCursor{nullptr};
|
|
158
167
|
|
|
159
168
|
#ifdef USE_WINUI3
|
|
160
169
|
winrt::event_token m_pointerPressedToken;
|
|
@@ -189,40 +189,16 @@ HRESULT __stdcall CompositionRootAutomationProvider::ElementProviderFromPoint(
|
|
|
189
189
|
*pRetVal = nullptr;
|
|
190
190
|
|
|
191
191
|
if (auto rootView = rootComponentView()) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
static_cast<LONG>(local.Y * m_island.RasterizationScale())});
|
|
200
|
-
auto spFragment = provider.try_as<IRawElementProviderFragment>();
|
|
201
|
-
if (spFragment) {
|
|
202
|
-
*pRetVal = spFragment.detach();
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return S_OK;
|
|
192
|
+
auto local = rootView->ConvertScreenToLocal({static_cast<float>(x), static_cast<float>(y)});
|
|
193
|
+
auto provider = rootView->UiaProviderFromPoint(
|
|
194
|
+
{static_cast<LONG>(local.X * rootView->LayoutMetrics().PointScaleFactor),
|
|
195
|
+
static_cast<LONG>(local.Y * rootView->LayoutMetrics().PointScaleFactor)});
|
|
196
|
+
auto spFragment = provider.try_as<IRawElementProviderFragment>();
|
|
197
|
+
if (spFragment) {
|
|
198
|
+
*pRetVal = spFragment.detach();
|
|
206
199
|
}
|
|
207
|
-
#endif
|
|
208
200
|
|
|
209
|
-
|
|
210
|
-
if (!IsWindow(m_hwnd)) {
|
|
211
|
-
// TODO: Add support for non-HWND based hosting
|
|
212
|
-
assert(false);
|
|
213
|
-
return E_FAIL;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
POINT clientPoint{static_cast<LONG>(x), static_cast<LONG>(y)};
|
|
217
|
-
ScreenToClient(m_hwnd, &clientPoint);
|
|
218
|
-
|
|
219
|
-
auto provider = rootView->UiaProviderFromPoint(clientPoint);
|
|
220
|
-
auto spFragment = provider.try_as<IRawElementProviderFragment>();
|
|
221
|
-
if (spFragment) {
|
|
222
|
-
*pRetVal = spFragment.detach();
|
|
223
|
-
return S_OK;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
201
|
+
return S_OK;
|
|
226
202
|
}
|
|
227
203
|
|
|
228
204
|
AddRef();
|