react-native-windows 0.0.0-canary.714 → 0.0.0-canary.715
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/Microsoft.ReactNative/Composition.Input.idl +75 -0
- package/Microsoft.ReactNative/CompositionRootView.idl +0 -4
- package/Microsoft.ReactNative/Fabric/ComponentView.h +8 -1
- package/Microsoft.ReactNative/Fabric/Composition/AbiCompositionViewComponentView.cpp +24 -0
- package/Microsoft.ReactNative/Fabric/Composition/AbiCompositionViewComponentView.h +8 -0
- package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.cpp +359 -0
- package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h +124 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +3 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +87 -174
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +12 -7
- package/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.cpp +0 -17
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView.cpp +0 -9
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView.h +0 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView_emptyimpl.cpp +0 -2
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +28 -9
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +9 -1
- package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +44 -0
- package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +15 -0
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +45 -26
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +4 -2
- package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.cpp +10 -15
- package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.h +3 -2
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +189 -0
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +7 -0
- package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +8 -0
- package/PropertySheets/Generated/PackageVersion.g.props +2 -2
- package/package.json +1 -1
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
#include <Views/ShadowNodeBase.h>
|
|
13
13
|
#include <windows.h>
|
|
14
14
|
#include <windowsx.h>
|
|
15
|
+
#include <winrt/Windows.UI.Input.h>
|
|
15
16
|
#include "Composition.Input.h"
|
|
16
17
|
#include "CompositionRootView.h"
|
|
17
18
|
#include "CompositionViewComponentView.h"
|
|
@@ -19,7 +20,7 @@
|
|
|
19
20
|
|
|
20
21
|
namespace Microsoft::ReactNative {
|
|
21
22
|
|
|
22
|
-
const PointerId MOUSE_POINTER_ID = 1;
|
|
23
|
+
const PointerId MOUSE_POINTER_ID = 1;
|
|
23
24
|
|
|
24
25
|
bool IsMousePointerEvent(const facebook::react::PointerEvent &pointerEvent) {
|
|
25
26
|
return pointerEvent.pointerId == MOUSE_POINTER_ID;
|
|
@@ -124,49 +125,28 @@ facebook::react::SurfaceId CompositionEventHandler::SurfaceId() noexcept {
|
|
|
124
125
|
return static_cast<::Microsoft::ReactNative::RootComponentView &>(*(rootComponentViewDescriptor.view));
|
|
125
126
|
}
|
|
126
127
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (std::shared_ptr<FabricUIManager> fabricuiManager = ::Microsoft::ReactNative::FabricUIManager::FromProperties(
|
|
131
|
-
winrt::Microsoft::ReactNative::ReactPropertyBag(m_context->Properties()))) {
|
|
132
|
-
facebook::react::Point ptLocal;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
auto pp = winrt::Windows::UI::Input::PointerPoint::GetCurrentPoint(pointerId);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
auto rootComponentViewDescriptor = fabricuiManager->GetViewRegistry().componentViewDescriptorWithTag(surfaceId);
|
|
139
|
-
auto tag = rootComponentViewDescriptor.view->hitTest({pp.Position().X, pp.Position().Y}, ptLocal);
|
|
140
|
-
|
|
141
|
-
if (tag != -1) {
|
|
142
|
-
auto hitComponentViewDescriptor = fabricuiManager->GetViewRegistry().componentViewDescriptorWithTag(tag);
|
|
143
|
-
static_cast<CompositionBaseComponentView &>(*hitComponentViewDescriptor.view).OnPointerDown(pp);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
//fabricuiManager
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
*/
|
|
152
|
-
|
|
153
|
-
void CompositionEventHandler::ScrollWheel(facebook::react::Point pt, uint32_t delta) {
|
|
128
|
+
void CompositionEventHandler::onPointerWheelChanged(
|
|
129
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pointerPoint,
|
|
130
|
+
winrt::Windows::System::VirtualKeyModifiers keyModifiers) noexcept {
|
|
154
131
|
if (std::shared_ptr<FabricUIManager> fabricuiManager =
|
|
155
132
|
::Microsoft::ReactNative::FabricUIManager::FromProperties(m_context.Properties())) {
|
|
156
|
-
|
|
133
|
+
auto position = pointerPoint.Position();
|
|
157
134
|
|
|
135
|
+
facebook::react::Point ptLocal;
|
|
158
136
|
facebook::react::Point ptScaled = {
|
|
159
|
-
static_cast<float>(
|
|
160
|
-
static_cast<float>(
|
|
137
|
+
static_cast<float>(position.X / m_compRootView.ScaleFactor()),
|
|
138
|
+
static_cast<float>(position.Y / m_compRootView.ScaleFactor())};
|
|
139
|
+
|
|
161
140
|
auto tag = RootComponentView().hitTest(ptScaled, ptLocal);
|
|
162
141
|
|
|
163
|
-
if (tag == -1)
|
|
142
|
+
if (tag == -1)
|
|
164
143
|
return;
|
|
165
|
-
}
|
|
166
144
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
145
|
+
auto targetComponentView = fabricuiManager->GetViewRegistry().componentViewDescriptorWithTag(tag).view;
|
|
146
|
+
auto args = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::PointerRoutedEventArgs>(
|
|
147
|
+
tag, pointerPoint, keyModifiers);
|
|
148
|
+
|
|
149
|
+
std::static_pointer_cast<CompositionBaseComponentView>(targetComponentView)->onPointerWheelChanged(args);
|
|
170
150
|
}
|
|
171
151
|
}
|
|
172
152
|
|
|
@@ -185,28 +165,60 @@ winrt::Windows::UI::Core::CoreVirtualKeyStates CompositionEventHandler::GetKeySt
|
|
|
185
165
|
return coreKeyState;
|
|
186
166
|
}
|
|
187
167
|
|
|
168
|
+
winrt::Windows::System::VirtualKeyModifiers GetKeyModifiers(uint64_t wParam) {
|
|
169
|
+
auto keyModifiers = winrt::Windows::System::VirtualKeyModifiers::None;
|
|
170
|
+
if ((wParam & MK_CONTROL) == MK_CONTROL) {
|
|
171
|
+
keyModifiers |= winrt::Windows::System::VirtualKeyModifiers::Control;
|
|
172
|
+
}
|
|
173
|
+
if ((wParam & MK_SHIFT) == MK_SHIFT) {
|
|
174
|
+
keyModifiers |= winrt::Windows::System::VirtualKeyModifiers::Shift;
|
|
175
|
+
}
|
|
176
|
+
if (::GetKeyState(VK_MENU) < 0) {
|
|
177
|
+
keyModifiers |= winrt::Windows::System::VirtualKeyModifiers::Menu;
|
|
178
|
+
}
|
|
179
|
+
if (::GetKeyState(VK_LWIN) < 0 || ::GetKeyState(VK_RWIN) < 0) {
|
|
180
|
+
keyModifiers |= winrt::Windows::System::VirtualKeyModifiers::Windows;
|
|
181
|
+
}
|
|
182
|
+
return keyModifiers;
|
|
183
|
+
}
|
|
184
|
+
|
|
188
185
|
int64_t CompositionEventHandler::SendMessage(uint32_t msg, uint64_t wParam, int64_t lParam) noexcept {
|
|
189
186
|
switch (msg) {
|
|
190
187
|
case WM_LBUTTONDOWN: {
|
|
191
|
-
|
|
188
|
+
auto pp = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::PointerPoint>(
|
|
189
|
+
msg, wParam, lParam);
|
|
190
|
+
onPointerPressed(pp, GetKeyModifiers(wParam));
|
|
192
191
|
return 0;
|
|
193
192
|
}
|
|
194
193
|
case WM_POINTERDOWN: {
|
|
195
|
-
|
|
194
|
+
auto pp = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::PointerPoint>(
|
|
195
|
+
msg, wParam, lParam);
|
|
196
|
+
onPointerPressed(pp, GetKeyModifiers(wParam));
|
|
196
197
|
return 0;
|
|
197
198
|
}
|
|
198
199
|
case WM_LBUTTONUP: {
|
|
199
|
-
|
|
200
|
+
auto pp = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::PointerPoint>(
|
|
201
|
+
msg, wParam, lParam);
|
|
202
|
+
onPointerReleased(pp, GetKeyModifiers(wParam));
|
|
200
203
|
return 0;
|
|
201
204
|
}
|
|
202
205
|
case WM_POINTERUP: {
|
|
203
|
-
|
|
206
|
+
auto pp = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::PointerPoint>(
|
|
207
|
+
msg, wParam, lParam);
|
|
208
|
+
onPointerReleased(pp, GetKeyModifiers(wParam));
|
|
204
209
|
return 0;
|
|
205
210
|
}
|
|
206
211
|
case WM_MOUSEMOVE: {
|
|
207
|
-
|
|
212
|
+
auto pp = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::PointerPoint>(
|
|
213
|
+
msg, wParam, lParam);
|
|
214
|
+
onPointerMoved(pp, GetKeyModifiers(wParam));
|
|
208
215
|
return 0;
|
|
209
216
|
}
|
|
217
|
+
case WM_MOUSEWHEEL: {
|
|
218
|
+
auto pp = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::PointerPoint>(
|
|
219
|
+
msg, wParam, lParam);
|
|
220
|
+
onPointerWheelChanged(pp, GetKeyModifiers(wParam));
|
|
221
|
+
}
|
|
210
222
|
case WM_CHAR:
|
|
211
223
|
case WM_SYSCHAR: {
|
|
212
224
|
// TODO full bubbling of events
|
|
@@ -496,23 +508,32 @@ facebook::react::PointerEvent CreatePointerEventFromIncompleteHoverData(
|
|
|
496
508
|
return pointerEvent;
|
|
497
509
|
}
|
|
498
510
|
|
|
499
|
-
void CompositionEventHandler::
|
|
500
|
-
|
|
511
|
+
void CompositionEventHandler::onPointerMoved(
|
|
512
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pointerPoint,
|
|
513
|
+
winrt::Windows::System::VirtualKeyModifiers keyModifiers) noexcept {
|
|
514
|
+
int pointerId = pointerPoint.PointerId();
|
|
501
515
|
|
|
502
|
-
auto
|
|
503
|
-
auto y = GET_Y_LPARAM(lParam);
|
|
516
|
+
auto position = pointerPoint.Position();
|
|
504
517
|
|
|
505
518
|
if (std::shared_ptr<FabricUIManager> fabricuiManager =
|
|
506
519
|
::Microsoft::ReactNative::FabricUIManager::FromProperties(m_context.Properties())) {
|
|
507
520
|
facebook::react::Point ptLocal;
|
|
508
521
|
|
|
509
522
|
facebook::react::Point ptScaled = {
|
|
510
|
-
static_cast<float>(
|
|
523
|
+
static_cast<float>(position.X / m_compRootView.ScaleFactor()),
|
|
524
|
+
static_cast<float>(position.Y / m_compRootView.ScaleFactor())};
|
|
511
525
|
auto tag = RootComponentView().hitTest(ptScaled, ptLocal);
|
|
512
526
|
|
|
513
527
|
if (tag == -1)
|
|
514
528
|
return;
|
|
515
529
|
|
|
530
|
+
auto args = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::PointerRoutedEventArgs>(
|
|
531
|
+
tag, pointerPoint, keyModifiers);
|
|
532
|
+
IComponentView *targetComponentView =
|
|
533
|
+
fabricuiManager->GetViewRegistry().componentViewDescriptorWithTag(tag).view.get();
|
|
534
|
+
|
|
535
|
+
static_cast<CompositionBaseComponentView *>(targetComponentView)->onPointerMoved(args);
|
|
536
|
+
|
|
516
537
|
auto targetView = FindClosestFabricManagedTouchableView(
|
|
517
538
|
fabricuiManager->GetViewRegistry().componentViewDescriptorWithTag(tag).view.get());
|
|
518
539
|
|
|
@@ -532,87 +553,10 @@ void CompositionEventHandler::MouseMove(uint32_t msg, uint64_t wParam, int64_t l
|
|
|
532
553
|
}
|
|
533
554
|
}
|
|
534
555
|
|
|
535
|
-
void CompositionEventHandler::
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
POINT pt = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
|
|
540
|
-
::ScreenToClient(pi.hwndTarget, &pt);
|
|
541
|
-
|
|
542
|
-
auto staleTouch = std::find_if(m_activeTouches.begin(), m_activeTouches.end(), [pointerId](const auto &pair) {
|
|
543
|
-
return pair.second.touch.identifier == pointerId;
|
|
544
|
-
});
|
|
545
|
-
|
|
546
|
-
if (staleTouch != m_activeTouches.end()) {
|
|
547
|
-
// A pointer with this ID already exists - Should we fire a button cancel or something?
|
|
548
|
-
assert(false);
|
|
549
|
-
return;
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
const auto eventType = TouchEventType::Start;
|
|
553
|
-
|
|
554
|
-
if (std::shared_ptr<FabricUIManager> fabricuiManager =
|
|
555
|
-
::Microsoft::ReactNative::FabricUIManager::FromProperties(m_context.Properties())) {
|
|
556
|
-
facebook::react::Point ptLocal;
|
|
557
|
-
|
|
558
|
-
facebook::react::Point ptScaled = {
|
|
559
|
-
static_cast<float>(pt.x / m_compRootView.ScaleFactor()),
|
|
560
|
-
static_cast<float>(pt.y / m_compRootView.ScaleFactor())};
|
|
561
|
-
auto tag = RootComponentView().hitTest(ptScaled, ptLocal);
|
|
562
|
-
|
|
563
|
-
if (tag == -1)
|
|
564
|
-
return;
|
|
565
|
-
|
|
566
|
-
IComponentView *targetComponentView =
|
|
567
|
-
fabricuiManager->GetViewRegistry().componentViewDescriptorWithTag(tag).view.get();
|
|
568
|
-
static_cast<CompositionBaseComponentView *>(targetComponentView)->sendMessage(msg, wParam, lParam);
|
|
569
|
-
|
|
570
|
-
ActiveTouch activeTouch{0};
|
|
571
|
-
switch (pi.pointerType) {
|
|
572
|
-
case PT_POINTER:
|
|
573
|
-
case PT_TOUCH:
|
|
574
|
-
activeTouch.touchType = UITouchType::Touch;
|
|
575
|
-
break;
|
|
576
|
-
case PT_PEN:
|
|
577
|
-
activeTouch.touchType = UITouchType::Pen;
|
|
578
|
-
break;
|
|
579
|
-
case PT_TOUCHPAD:
|
|
580
|
-
case PT_MOUSE:
|
|
581
|
-
activeTouch.touchType = UITouchType::Mouse;
|
|
582
|
-
break;
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
auto componentView = targetComponentView;
|
|
586
|
-
while (componentView) {
|
|
587
|
-
if (auto eventEmitter = componentView->eventEmitter()) {
|
|
588
|
-
activeTouch.eventEmitter = eventEmitter;
|
|
589
|
-
activeTouch.touch.target = componentView->tag();
|
|
590
|
-
// activeTouch.componentView = componentView;
|
|
591
|
-
break;
|
|
592
|
-
}
|
|
593
|
-
componentView = componentView->parent();
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
UpdateActiveTouch(activeTouch, ptScaled, ptLocal);
|
|
597
|
-
|
|
598
|
-
// activeTouch.touch.isPrimary = true;
|
|
599
|
-
activeTouch.touch.identifier = pointerId;
|
|
600
|
-
|
|
601
|
-
// If the pointer has not been marked as hovering over views before the touch started, we register
|
|
602
|
-
// that the activeTouch should not maintain its hovered state once the pointer has been lifted.
|
|
603
|
-
auto currentlyHoveredTags = m_currentlyHoveredViewsPerPointer.find(activeTouch.touch.identifier);
|
|
604
|
-
if (currentlyHoveredTags == m_currentlyHoveredViewsPerPointer.end() || currentlyHoveredTags->second.empty()) {
|
|
605
|
-
activeTouch.shouldLeaveWhenReleased = true;
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
m_activeTouches.emplace(pointerId, activeTouch);
|
|
609
|
-
|
|
610
|
-
DispatchTouchEvent(eventType, pointerId);
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
void CompositionEventHandler::ButtonDown(uint32_t msg, uint64_t wParam, int64_t lParam) {
|
|
615
|
-
PointerId pointerId = MOUSE_POINTER_ID;
|
|
556
|
+
void CompositionEventHandler::onPointerPressed(
|
|
557
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pointerPoint,
|
|
558
|
+
winrt::Windows::System::VirtualKeyModifiers keyModifiers) noexcept {
|
|
559
|
+
PointerId pointerId = pointerPoint.PointerId();
|
|
616
560
|
|
|
617
561
|
auto staleTouch = std::find_if(m_activeTouches.begin(), m_activeTouches.end(), [pointerId](const auto &pair) {
|
|
618
562
|
return pair.second.touch.identifier == pointerId;
|
|
@@ -624,8 +568,7 @@ void CompositionEventHandler::ButtonDown(uint32_t msg, uint64_t wParam, int64_t
|
|
|
624
568
|
return;
|
|
625
569
|
}
|
|
626
570
|
|
|
627
|
-
auto
|
|
628
|
-
auto y = GET_Y_LPARAM(lParam);
|
|
571
|
+
auto position = pointerPoint.Position();
|
|
629
572
|
const auto eventType = TouchEventType::Start;
|
|
630
573
|
|
|
631
574
|
if (std::shared_ptr<FabricUIManager> fabricuiManager =
|
|
@@ -633,7 +576,8 @@ void CompositionEventHandler::ButtonDown(uint32_t msg, uint64_t wParam, int64_t
|
|
|
633
576
|
facebook::react::Point ptLocal;
|
|
634
577
|
|
|
635
578
|
facebook::react::Point ptScaled = {
|
|
636
|
-
static_cast<float>(
|
|
579
|
+
static_cast<float>(position.X / m_compRootView.ScaleFactor()),
|
|
580
|
+
static_cast<float>(position.Y / m_compRootView.ScaleFactor())};
|
|
637
581
|
auto tag = RootComponentView().hitTest(ptScaled, ptLocal);
|
|
638
582
|
|
|
639
583
|
if (tag == -1)
|
|
@@ -641,7 +585,9 @@ void CompositionEventHandler::ButtonDown(uint32_t msg, uint64_t wParam, int64_t
|
|
|
641
585
|
|
|
642
586
|
IComponentView *targetComponentView =
|
|
643
587
|
fabricuiManager->GetViewRegistry().componentViewDescriptorWithTag(tag).view.get();
|
|
644
|
-
|
|
588
|
+
auto args = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::PointerRoutedEventArgs>(
|
|
589
|
+
tag, pointerPoint, keyModifiers);
|
|
590
|
+
static_cast<CompositionBaseComponentView *>(targetComponentView)->onPointerPressed(args);
|
|
645
591
|
|
|
646
592
|
ActiveTouch activeTouch{0};
|
|
647
593
|
activeTouch.touchType = UITouchType::Mouse;
|
|
@@ -675,12 +621,10 @@ void CompositionEventHandler::ButtonDown(uint32_t msg, uint64_t wParam, int64_t
|
|
|
675
621
|
}
|
|
676
622
|
}
|
|
677
623
|
|
|
678
|
-
void CompositionEventHandler::
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
POINT pt = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
|
|
683
|
-
::ScreenToClient(pi.hwndTarget, &pt);
|
|
624
|
+
void CompositionEventHandler::onPointerReleased(
|
|
625
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pointerPoint,
|
|
626
|
+
winrt::Windows::System::VirtualKeyModifiers keyModifiers) noexcept {
|
|
627
|
+
int pointerId = pointerPoint.PointerId();
|
|
684
628
|
|
|
685
629
|
auto activeTouch = std::find_if(m_activeTouches.begin(), m_activeTouches.end(), [pointerId](const auto &pair) {
|
|
686
630
|
return pair.second.touch.identifier == pointerId;
|
|
@@ -690,56 +634,25 @@ void CompositionEventHandler::PointerUp(uint32_t msg, uint64_t wParam, int64_t l
|
|
|
690
634
|
return;
|
|
691
635
|
}
|
|
692
636
|
|
|
693
|
-
|
|
637
|
+
auto position = pointerPoint.Position();
|
|
694
638
|
|
|
695
639
|
if (std::shared_ptr<FabricUIManager> fabricuiManager =
|
|
696
640
|
::Microsoft::ReactNative::FabricUIManager::FromProperties(m_context.Properties())) {
|
|
697
641
|
facebook::react::Point ptLocal;
|
|
698
642
|
|
|
699
643
|
facebook::react::Point ptScaled = {
|
|
700
|
-
static_cast<float>(
|
|
701
|
-
static_cast<float>(
|
|
644
|
+
static_cast<float>(position.X / m_compRootView.ScaleFactor()),
|
|
645
|
+
static_cast<float>(position.Y / m_compRootView.ScaleFactor())};
|
|
702
646
|
auto tag = RootComponentView().hitTest(ptScaled, ptLocal);
|
|
703
647
|
|
|
704
648
|
if (tag == -1)
|
|
705
649
|
return;
|
|
706
650
|
|
|
707
651
|
auto targetComponentView = fabricuiManager->GetViewRegistry().componentViewDescriptorWithTag(tag).view;
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
UpdateActiveTouch(activeTouch->second, ptScaled, ptLocal);
|
|
711
|
-
DispatchTouchEvent(TouchEventType::End, pointerId);
|
|
712
|
-
m_activeTouches.erase(pointerId);
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
void CompositionEventHandler::ButtonUp(uint32_t msg, uint64_t wParam, int64_t lParam) {
|
|
717
|
-
int pointerId = MOUSE_POINTER_ID;
|
|
718
|
-
|
|
719
|
-
auto activeTouch = std::find_if(m_activeTouches.begin(), m_activeTouches.end(), [pointerId](const auto &pair) {
|
|
720
|
-
return pair.second.touch.identifier == pointerId;
|
|
721
|
-
});
|
|
722
|
-
|
|
723
|
-
if (activeTouch == m_activeTouches.end()) {
|
|
724
|
-
return;
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
auto x = GET_X_LPARAM(lParam);
|
|
728
|
-
auto y = GET_Y_LPARAM(lParam);
|
|
729
|
-
|
|
730
|
-
if (std::shared_ptr<FabricUIManager> fabricuiManager =
|
|
731
|
-
::Microsoft::ReactNative::FabricUIManager::FromProperties(m_context.Properties())) {
|
|
732
|
-
facebook::react::Point ptLocal;
|
|
652
|
+
auto args = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::PointerRoutedEventArgs>(
|
|
653
|
+
tag, pointerPoint, keyModifiers);
|
|
733
654
|
|
|
734
|
-
|
|
735
|
-
static_cast<float>(x / m_compRootView.ScaleFactor()), static_cast<float>(y / m_compRootView.ScaleFactor())};
|
|
736
|
-
auto tag = RootComponentView().hitTest(ptScaled, ptLocal);
|
|
737
|
-
|
|
738
|
-
if (tag == -1)
|
|
739
|
-
return;
|
|
740
|
-
|
|
741
|
-
auto targetComponentView = fabricuiManager->GetViewRegistry().componentViewDescriptorWithTag(tag).view;
|
|
742
|
-
std::static_pointer_cast<CompositionBaseComponentView>(targetComponentView)->sendMessage(msg, wParam, lParam);
|
|
655
|
+
std::static_pointer_cast<CompositionBaseComponentView>(targetComponentView)->onPointerReleased(args);
|
|
743
656
|
|
|
744
657
|
UpdateActiveTouch(activeTouch->second, ptScaled, ptLocal);
|
|
745
658
|
DispatchTouchEvent(TouchEventType::End, pointerId);
|
|
@@ -35,17 +35,22 @@ class CompositionEventHandler {
|
|
|
35
35
|
virtual ~CompositionEventHandler();
|
|
36
36
|
|
|
37
37
|
int64_t SendMessage(uint32_t msg, uint64_t wParam, int64_t lParam) noexcept;
|
|
38
|
-
void ScrollWheel(facebook::react::Point pt, uint32_t delta);
|
|
39
38
|
void RemoveTouchHandlers();
|
|
40
39
|
winrt::Windows::UI::Core::CoreVirtualKeyStates GetKeyState(winrt::Windows::System::VirtualKey key) noexcept;
|
|
41
40
|
|
|
42
41
|
private:
|
|
43
|
-
void
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
void
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
void onPointerPressed(
|
|
43
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pointerPoint,
|
|
44
|
+
winrt::Windows::System::VirtualKeyModifiers keyModifiers) noexcept;
|
|
45
|
+
void onPointerReleased(
|
|
46
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pointerPoint,
|
|
47
|
+
winrt::Windows::System::VirtualKeyModifiers keyModifiers) noexcept;
|
|
48
|
+
void onPointerMoved(
|
|
49
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pointerPoint,
|
|
50
|
+
winrt::Windows::System::VirtualKeyModifiers keyModifiers) noexcept;
|
|
51
|
+
void onPointerWheelChanged(
|
|
52
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pointerPoint,
|
|
53
|
+
winrt::Windows::System::VirtualKeyModifiers keyModifiers) noexcept;
|
|
49
54
|
void onKeyDown(
|
|
50
55
|
const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
|
|
51
56
|
const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept;
|
|
@@ -91,23 +91,6 @@ LRESULT CompositionHwndHost::TranslateMessage(int msg, uint64_t wParam, int64_t
|
|
|
91
91
|
return 0;
|
|
92
92
|
|
|
93
93
|
switch (msg) {
|
|
94
|
-
case WM_MOUSEWHEEL: {
|
|
95
|
-
POINT pt = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
|
|
96
|
-
::ScreenToClient(m_hwnd, &pt);
|
|
97
|
-
int32_t delta = GET_WHEEL_DELTA_WPARAM(wParam);
|
|
98
|
-
m_compRootView.OnScrollWheel({static_cast<float>(pt.x), static_cast<float>(pt.y)}, delta);
|
|
99
|
-
return 0;
|
|
100
|
-
}
|
|
101
|
-
/*
|
|
102
|
-
case WM_POINTERDOWN: {
|
|
103
|
-
m_compRootView.OnPointerPressed({GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)});
|
|
104
|
-
return 0;
|
|
105
|
-
}
|
|
106
|
-
case WM_LBUTTONUP: {
|
|
107
|
-
m_compRootView.OnMouseUp({static_cast<float>(GET_X_LPARAM(lParam)), static_cast<float>(GET_Y_LPARAM(lParam))});
|
|
108
|
-
return 0;
|
|
109
|
-
}
|
|
110
|
-
*/
|
|
111
94
|
case WM_WINDOWPOSCHANGED: {
|
|
112
95
|
UpdateSize();
|
|
113
96
|
/*
|
|
@@ -191,15 +191,6 @@ int64_t CompositionRootView::SendMessage(uint32_t msg, uint64_t wParam, int64_t
|
|
|
191
191
|
return 0;
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
-
void CompositionRootView::OnScrollWheel(winrt::Windows::Foundation::Point point, int32_t delta) noexcept {
|
|
195
|
-
if (m_rootTag == -1)
|
|
196
|
-
return;
|
|
197
|
-
|
|
198
|
-
if (m_CompositionEventHandler) {
|
|
199
|
-
m_CompositionEventHandler->ScrollWheel({point.X, point.Y}, delta);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
194
|
void CompositionRootView::InitRootView(
|
|
204
195
|
winrt::Microsoft::ReactNative::IReactContext &&context,
|
|
205
196
|
winrt::Microsoft::ReactNative::ReactViewOptions &&viewOptions) noexcept {
|
|
@@ -70,7 +70,6 @@ struct CompositionRootView : CompositionRootViewT<CompositionRootView>, ::Micros
|
|
|
70
70
|
IInspectable GetUiaProvider() noexcept;
|
|
71
71
|
|
|
72
72
|
int64_t SendMessage(uint32_t msg, uint64_t wParam, int64_t lParam) noexcept;
|
|
73
|
-
void OnScrollWheel(winrt::Windows::Foundation::Point point, int32_t delta) noexcept;
|
|
74
73
|
|
|
75
74
|
public: // ICompositionRootView
|
|
76
75
|
winrt::Microsoft::ReactNative::Composition::IVisual GetVisual() const noexcept override;
|
|
@@ -83,8 +83,6 @@ int64_t CompositionRootView::SendMessage(uint32_t, uint64_t, int64_t) noexcept {
|
|
|
83
83
|
return 0;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
void CompositionRootView::OnScrollWheel(Windows::Foundation::Point, int32_t) noexcept {}
|
|
87
|
-
|
|
88
86
|
void CompositionRootView::InitRootView(
|
|
89
87
|
winrt::Microsoft::ReactNative::IReactContext &&,
|
|
90
88
|
winrt::Microsoft::ReactNative::ReactViewOptions &&) noexcept {}
|
|
@@ -158,6 +158,34 @@ void CompositionBaseComponentView::onKeyUp(
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
void CompositionBaseComponentView::onPointerPressed(
|
|
162
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept {
|
|
163
|
+
if (m_parent && !args.Handled()) {
|
|
164
|
+
m_parent->onPointerPressed(args);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
void CompositionBaseComponentView::onPointerReleased(
|
|
169
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept {
|
|
170
|
+
if (m_parent && !args.Handled()) {
|
|
171
|
+
m_parent->onPointerReleased(args);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
void CompositionBaseComponentView::onPointerMoved(
|
|
176
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept {
|
|
177
|
+
if (m_parent && !args.Handled()) {
|
|
178
|
+
m_parent->onPointerMoved(args);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
void CompositionBaseComponentView::onPointerWheelChanged(
|
|
183
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept {
|
|
184
|
+
if (m_parent && !args.Handled()) {
|
|
185
|
+
m_parent->onPointerWheelChanged(args);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
161
189
|
RECT CompositionBaseComponentView::getClientRect() const noexcept {
|
|
162
190
|
RECT rc{0};
|
|
163
191
|
if (m_parent) {
|
|
@@ -175,15 +203,6 @@ const facebook::react::SharedViewEventEmitter &CompositionBaseComponentView::Get
|
|
|
175
203
|
return m_eventEmitter;
|
|
176
204
|
}
|
|
177
205
|
|
|
178
|
-
bool CompositionBaseComponentView::ScrollWheel(facebook::react::Point pt, int32_t delta) noexcept {
|
|
179
|
-
if (m_parent) {
|
|
180
|
-
pt.x += m_layoutMetrics.frame.origin.x * m_layoutMetrics.pointScaleFactor;
|
|
181
|
-
pt.y += m_layoutMetrics.frame.origin.y * m_layoutMetrics.pointScaleFactor;
|
|
182
|
-
return m_parent->ScrollWheel(pt, delta);
|
|
183
|
-
}
|
|
184
|
-
return false;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
206
|
std::array<
|
|
188
207
|
winrt::Microsoft::ReactNative::Composition::ISpriteVisual,
|
|
189
208
|
CompositionBaseComponentView::SpecialBorderLayerCount>
|
|
@@ -35,6 +35,15 @@ struct CompositionBaseComponentView : public IComponentView,
|
|
|
35
35
|
bool runOnChildren(bool forward, Mso::Functor<bool(IComponentView &)> &fn) noexcept override;
|
|
36
36
|
void onFocusLost() noexcept override;
|
|
37
37
|
void onFocusGained() noexcept override;
|
|
38
|
+
void onPointerPressed(
|
|
39
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept override;
|
|
40
|
+
void onPointerReleased(
|
|
41
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept override;
|
|
42
|
+
void onPointerMoved(
|
|
43
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept override;
|
|
44
|
+
void onPointerWheelChanged(
|
|
45
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept override;
|
|
46
|
+
|
|
38
47
|
void onKeyDown(
|
|
39
48
|
const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
|
|
40
49
|
const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept override;
|
|
@@ -49,7 +58,6 @@ struct CompositionBaseComponentView : public IComponentView,
|
|
|
49
58
|
facebook::react::Tag tag() const noexcept override;
|
|
50
59
|
int64_t sendMessage(uint32_t msg, uint64_t wParam, int64_t lParam) noexcept override;
|
|
51
60
|
|
|
52
|
-
bool ScrollWheel(facebook::react::Point pt, int32_t delta) noexcept override;
|
|
53
61
|
RECT getClientRect() const noexcept override;
|
|
54
62
|
|
|
55
63
|
void indexOffsetForBorder(uint32_t &index) const noexcept;
|
|
@@ -59,6 +59,22 @@ void ReactCompositionViewComponentBuilder::SetKeyUpHandler(KeyHandler impl) noex
|
|
|
59
59
|
m_keyUp = impl;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
void ReactCompositionViewComponentBuilder::SetPointerReleasedHandler(PointerHandler impl) noexcept {
|
|
63
|
+
m_pointerReleased = impl;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
void ReactCompositionViewComponentBuilder::SetPointerPressedHandler(PointerHandler impl) noexcept {
|
|
67
|
+
m_pointerPressed = impl;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
void ReactCompositionViewComponentBuilder::SetPointerMovedHandler(PointerHandler impl) noexcept {
|
|
71
|
+
m_pointerMoved = impl;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
void ReactCompositionViewComponentBuilder::SetPointerWheelChangedHandler(PointerHandler impl) noexcept {
|
|
75
|
+
m_pointerWheelChanged = impl;
|
|
76
|
+
}
|
|
77
|
+
|
|
62
78
|
winrt::Windows::Foundation::IInspectable ReactCompositionViewComponentBuilder::CreateView(
|
|
63
79
|
IReactContext reactContext,
|
|
64
80
|
ICompositionContext context) noexcept {
|
|
@@ -128,4 +144,32 @@ void ReactCompositionViewComponentBuilder::OnKeyUp(
|
|
|
128
144
|
}
|
|
129
145
|
}
|
|
130
146
|
|
|
147
|
+
void ReactCompositionViewComponentBuilder::OnPointerPressed(
|
|
148
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept {
|
|
149
|
+
if (m_pointerPressed) {
|
|
150
|
+
m_pointerPressed(args);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
void ReactCompositionViewComponentBuilder::OnPointerReleased(
|
|
155
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept {
|
|
156
|
+
if (m_pointerReleased) {
|
|
157
|
+
m_pointerReleased(args);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
void ReactCompositionViewComponentBuilder::OnPointerMoved(
|
|
162
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept {
|
|
163
|
+
if (m_pointerMoved) {
|
|
164
|
+
m_pointerMoved(args);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
void ReactCompositionViewComponentBuilder::OnPointerWheelChanged(
|
|
169
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept {
|
|
170
|
+
if (m_pointerWheelChanged) {
|
|
171
|
+
m_pointerWheelChanged(args);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
131
175
|
} // namespace winrt::Microsoft::ReactNative::Composition
|
|
@@ -36,6 +36,11 @@ struct ReactCompositionViewComponentBuilder : winrt::implements<
|
|
|
36
36
|
void SetKeyDownHandler(KeyHandler impl) noexcept;
|
|
37
37
|
void SetKeyUpHandler(KeyHandler impl) noexcept;
|
|
38
38
|
|
|
39
|
+
void SetPointerReleasedHandler(PointerHandler impl) noexcept;
|
|
40
|
+
void SetPointerPressedHandler(PointerHandler impl) noexcept;
|
|
41
|
+
void SetPointerMovedHandler(PointerHandler impl) noexcept;
|
|
42
|
+
void SetPointerWheelChangedHandler(PointerHandler impl) noexcept;
|
|
43
|
+
|
|
39
44
|
public:
|
|
40
45
|
IComponentProps CreateProps(ViewProps props) noexcept;
|
|
41
46
|
|
|
@@ -56,6 +61,12 @@ struct ReactCompositionViewComponentBuilder : winrt::implements<
|
|
|
56
61
|
void OnKeyUp(
|
|
57
62
|
const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
|
|
58
63
|
const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept;
|
|
64
|
+
void OnPointerPressed(const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept;
|
|
65
|
+
void OnPointerReleased(
|
|
66
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept;
|
|
67
|
+
void OnPointerMoved(const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept;
|
|
68
|
+
void OnPointerWheelChanged(
|
|
69
|
+
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept;
|
|
59
70
|
|
|
60
71
|
private:
|
|
61
72
|
ViewPropsFactory m_propsFactory;
|
|
@@ -69,6 +80,10 @@ struct ReactCompositionViewComponentBuilder : winrt::implements<
|
|
|
69
80
|
MessageHandler m_messageHandler;
|
|
70
81
|
KeyHandler m_keyUp;
|
|
71
82
|
KeyHandler m_keyDown;
|
|
83
|
+
PointerHandler m_pointerReleased;
|
|
84
|
+
PointerHandler m_pointerPressed;
|
|
85
|
+
PointerHandler m_pointerMoved;
|
|
86
|
+
PointerHandler m_pointerWheelChanged;
|
|
72
87
|
};
|
|
73
88
|
|
|
74
89
|
} // namespace winrt::Microsoft::ReactNative::Composition
|