react-native-windows 0.0.0-canary.714 → 0.0.0-canary.716

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.
Files changed (31) hide show
  1. package/Microsoft.ReactNative/Composition.Input.idl +75 -0
  2. package/Microsoft.ReactNative/CompositionRootView.idl +0 -4
  3. package/Microsoft.ReactNative/CompositionSwitcher.idl +12 -0
  4. package/Microsoft.ReactNative/Fabric/ComponentView.h +8 -1
  5. package/Microsoft.ReactNative/Fabric/Composition/AbiCompositionViewComponentView.cpp +24 -0
  6. package/Microsoft.ReactNative/Fabric/Composition/AbiCompositionViewComponentView.h +8 -0
  7. package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.cpp +359 -0
  8. package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h +124 -0
  9. package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +98 -0
  10. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +87 -174
  11. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +12 -7
  12. package/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.cpp +0 -17
  13. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView.cpp +0 -9
  14. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView.h +0 -1
  15. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView_emptyimpl.cpp +0 -2
  16. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +28 -9
  17. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +9 -1
  18. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +44 -0
  19. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +15 -0
  20. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +45 -26
  21. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +4 -2
  22. package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.cpp +30 -30
  23. package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.h +4 -2
  24. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +189 -0
  25. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +7 -0
  26. package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +8 -0
  27. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +3 -0
  28. package/PropertySheets/Generated/PackageVersion.g.props +2 -2
  29. package/Shared/DevSettings.h +3 -0
  30. package/Shared/OInstance.cpp +6 -2
  31. package/package.json +1 -1
@@ -25,4 +25,79 @@ namespace Microsoft.ReactNative.Composition.Input
25
25
  Windows.System.VirtualKey OriginalKey { get; };
26
26
  }
27
27
 
28
+ interface IPointerPointTransform
29
+ {
30
+ IPointerPointTransform Inverse { get; };
31
+ Boolean TryTransform(Windows.Foundation.Point inPoint, out Windows.Foundation.Point outPoint);
32
+ Boolean TryTransformBounds(Windows.Foundation.Rect inRect, out Windows.Foundation.Rect outRect);
33
+ };
34
+
35
+ enum PointerDeviceType
36
+ {
37
+ Touch = 0,
38
+ Pen,
39
+ Mouse,
40
+ Touchpad,
41
+ };
42
+
43
+ enum PointerUpdateKind
44
+ {
45
+ Other = 0,
46
+ LeftButtonPressed,
47
+ LeftButtonReleased,
48
+ RightButtonPressed,
49
+ RightButtonReleased,
50
+ MiddleButtonPressed,
51
+ MiddleButtonReleased,
52
+ XButton1Pressed,
53
+ XButton1Released,
54
+ XButton2Pressed,
55
+ XButton2Released,
56
+ };
57
+
58
+ runtimeclass PointerPointProperties
59
+ {
60
+ Windows.Foundation.Rect ContactRect { get; };
61
+ Boolean IsBarrelButtonPressed { get; };
62
+ Boolean IsCanceled { get; };
63
+ Boolean IsEraser { get; };
64
+ Boolean IsHorizontalMouseWheel { get; };
65
+ Boolean IsInRange { get; };
66
+ Boolean IsInverted { get; };
67
+ Boolean IsLeftButtonPressed { get; };
68
+ Boolean IsMiddleButtonPressed { get; };
69
+ Boolean IsPrimary { get; };
70
+ Boolean IsRightButtonPressed { get; };
71
+ Boolean IsXButton1Pressed { get; };
72
+ Boolean IsXButton2Pressed { get; };
73
+ Int32 MouseWheelDelta { get; };
74
+ Single Orientation { get; };
75
+ PointerUpdateKind PointerUpdateKind{ get; };
76
+ Single Pressure { get; };
77
+ Boolean TouchConfidence { get; };
78
+ Single Twist { get; };
79
+ Single XTilt { get; };
80
+ Single YTilt { get; };
81
+ };
82
+
83
+ runtimeclass PointerPoint
84
+ {
85
+ UInt32 FrameId { get; };
86
+ Boolean IsInContact{ get; };
87
+ PointerDeviceType PointerDeviceType { get; };
88
+ UInt32 PointerId{ get; };
89
+ Windows.Foundation.Point Position { get; };
90
+ PointerPointProperties Properties{ get; };
91
+ UInt64 Timestamp { get; };
92
+ PointerPoint GetTransformedPoint(
93
+ IPointerPointTransform transform);
94
+ };
95
+
96
+ runtimeclass PointerRoutedEventArgs : RoutedEventArgs
97
+ {
98
+ PointerPoint GetCurrentPoint(Int32 tag);
99
+ Boolean Handled;
100
+ Windows.System.VirtualKeyModifiers KeyModifiers { get; };
101
+ };
102
+
28
103
  } // namespace Microsoft.ReactNative.Composition.Input
@@ -71,10 +71,6 @@ namespace Microsoft.ReactNative
71
71
  Int64 SendMessage(UInt32 Msg, UInt64 WParam, Int64 LParam);
72
72
 
73
73
  Object GetUiaProvider();
74
-
75
- //void OnPointerPressed(PointerPressedArgs args);
76
- //void OnMouseUp(Windows.Foundation.Point point);
77
- void OnScrollWheel(Windows.Foundation.Point point, Int32 delta);
78
74
  }
79
75
 
80
76
  } // namespace Microsoft.ReactNative
@@ -110,6 +110,17 @@ namespace Microsoft.ReactNative.Composition
110
110
  void Color(Windows.UI.Color color);
111
111
  }
112
112
 
113
+ [webhosthidden]
114
+ [experimental]
115
+ interface ISwitchThumbVisual
116
+ {
117
+ IVisual InnerVisual { get; };
118
+ void Size(Windows.Foundation.Numerics.Vector2 size);
119
+ void Position(Windows.Foundation.Numerics.Vector2 position);
120
+ Boolean IsVisible { get; set; };
121
+ void Color(Windows.UI.Color color);
122
+ }
123
+
113
124
  [webhosthidden]
114
125
  [experimental]
115
126
  interface IFocusVisual
@@ -127,6 +138,7 @@ namespace Microsoft.ReactNative.Composition
127
138
  IScrollVisual CreateScrollerVisual();
128
139
  IActivityVisual CreateActivityVisual();
129
140
  ICaretVisual CreateCaretVisual();
141
+ ISwitchThumbVisual CreateSwitchThumbVisual();
130
142
  IFocusVisual CreateFocusVisual();
131
143
  IDropShadow CreateDropShadow();
132
144
  IBrush CreateColorBrush(Windows.UI.Color color);
@@ -69,13 +69,20 @@ struct IComponentView {
69
69
  virtual RECT getClientRect() const noexcept = 0;
70
70
  virtual void onFocusLost() noexcept = 0;
71
71
  virtual void onFocusGained() noexcept = 0;
72
+ virtual void onPointerPressed(
73
+ const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept = 0;
74
+ virtual void onPointerReleased(
75
+ const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept = 0;
76
+ virtual void onPointerMoved(
77
+ const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept = 0;
78
+ virtual void onPointerWheelChanged(
79
+ const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept = 0;
72
80
  virtual void onKeyDown(
73
81
  const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
74
82
  const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept = 0;
75
83
  virtual void onKeyUp(
76
84
  const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
77
85
  const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept = 0;
78
- virtual bool ScrollWheel(facebook::react::Point pt, int32_t delta) noexcept = 0;
79
86
  virtual bool focusable() const noexcept = 0;
80
87
  virtual facebook::react::SharedViewEventEmitter eventEmitterAtPoint(facebook::react::Point pt) noexcept = 0;
81
88
  virtual facebook::react::SharedViewEventEmitter eventEmitter() noexcept = 0;
@@ -119,6 +119,30 @@ void AbiCompositionViewComponentView::onKeyUp(
119
119
  Super::onKeyUp(source, args);
120
120
  }
121
121
 
122
+ void AbiCompositionViewComponentView::onPointerPressed(
123
+ const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept {
124
+ Builder().OnPointerPressed(args);
125
+ Super::onPointerPressed(args);
126
+ }
127
+
128
+ void AbiCompositionViewComponentView::onPointerReleased(
129
+ const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept {
130
+ Builder().OnPointerReleased(args);
131
+ Super::onPointerReleased(args);
132
+ }
133
+
134
+ void AbiCompositionViewComponentView::onPointerMoved(
135
+ const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept {
136
+ Builder().OnPointerMoved(args);
137
+ Super::onPointerMoved(args);
138
+ }
139
+
140
+ void AbiCompositionViewComponentView::onPointerWheelChanged(
141
+ const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept {
142
+ Builder().OnPointerWheelChanged(args);
143
+ Super::onPointerWheelChanged(args);
144
+ }
145
+
122
146
  std::vector<facebook::react::ComponentDescriptorProvider>
123
147
  AbiCompositionViewComponentView::supplementalComponentDescriptorProviders() noexcept {
124
148
  return {};
@@ -47,6 +47,14 @@ struct AbiCompositionViewComponentView : CompositionBaseComponentView {
47
47
  void onKeyUp(
48
48
  const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
49
49
  const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept override;
50
+ void onPointerPressed(
51
+ const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept override;
52
+ void onPointerReleased(
53
+ const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept override;
54
+ void onPointerMoved(
55
+ const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept override;
56
+ void onPointerWheelChanged(
57
+ const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept override;
50
58
  std::vector<facebook::react::ComponentDescriptorProvider> supplementalComponentDescriptorProviders() noexcept
51
59
  override;
52
60
  facebook::react::Props::Shared props() noexcept override;
@@ -3,6 +3,9 @@
3
3
 
4
4
  #pragma once
5
5
  #include "Composition.Input.h"
6
+ #include <windowsx.h>
7
+ #include <winrt/Windows.Devices.Input.h>
8
+ #include <winrt/Windows.UI.Input.h>
6
9
 
7
10
  namespace winrt::Microsoft::ReactNative::Composition::Input::implementation {
8
11
 
@@ -58,4 +61,360 @@ winrt::Windows::System::VirtualKey KeyRoutedEventArgs::OriginalKey() noexcept {
58
61
  return m_key;
59
62
  }
60
63
 
64
+ PointerPointProperties::PointerPointProperties(const winrt::Windows::UI::Input::PointerPointProperties &ppp)
65
+ : m_sysPointerPointProps(ppp) {}
66
+
67
+ PointerPointProperties::PointerPointProperties(
68
+ bool isBarrelButtonPressed,
69
+ bool isCanceled,
70
+ bool isEraser,
71
+ bool isHorizontalMouseWheel,
72
+ bool isInRange,
73
+ bool isInverted,
74
+ bool isLeftButtonPressed,
75
+ bool isMiddleButtonPressed,
76
+ bool isPrimary,
77
+ bool isRightButtonPressed,
78
+ bool isXButton1Pressed,
79
+ bool isXButton2Pressed,
80
+ bool touchConfidence,
81
+ int32_t mouseWheelDelta,
82
+ float orientation,
83
+ winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind pointerUpdateKind,
84
+ float pressure,
85
+ float twist,
86
+ float xTilt,
87
+ float yTilt)
88
+ : m_isBarrelButtonPressed(isBarrelButtonPressed),
89
+ m_isCanceled(isCanceled),
90
+ m_isEraser(isEraser),
91
+ m_isHorizontalMouseWheel(isHorizontalMouseWheel),
92
+ m_isInRange(isInRange),
93
+ m_isInverted(isInverted),
94
+ m_isLeftButtonPressed(isLeftButtonPressed),
95
+ m_isMiddleButtonPressed(isMiddleButtonPressed),
96
+ m_isPrimary(isPrimary),
97
+ m_isRightButtonPressed(isRightButtonPressed),
98
+ m_isXButton1Pressed(isXButton1Pressed),
99
+ m_isXButton2Pressed(isXButton2Pressed),
100
+ m_touchConfidence(touchConfidence),
101
+ m_mouseWheelDelta(mouseWheelDelta),
102
+ m_orientation(orientation),
103
+ m_pointerUpdateKind(pointerUpdateKind),
104
+ m_pressure(pressure),
105
+ m_twist(twist),
106
+ m_xTilt(xTilt),
107
+ m_yTilt(yTilt) {}
108
+
109
+ winrt::Windows::Foundation::Rect PointerPointProperties::ContactRect() noexcept {
110
+ return m_sysPointerPointProps.ContactRect();
111
+ }
112
+
113
+ bool PointerPointProperties::IsBarrelButtonPressed() noexcept {
114
+ return m_sysPointerPointProps ? m_sysPointerPointProps.IsBarrelButtonPressed() : m_isBarrelButtonPressed;
115
+ }
116
+
117
+ bool PointerPointProperties::IsCanceled() noexcept {
118
+ return m_sysPointerPointProps ? m_sysPointerPointProps.IsCanceled() : m_isCanceled;
119
+ }
120
+
121
+ bool PointerPointProperties::IsEraser() noexcept {
122
+ return m_sysPointerPointProps ? m_sysPointerPointProps.IsEraser() : m_isEraser;
123
+ }
124
+
125
+ bool PointerPointProperties::IsHorizontalMouseWheel() noexcept {
126
+ return m_sysPointerPointProps ? m_sysPointerPointProps.IsHorizontalMouseWheel() : m_isHorizontalMouseWheel;
127
+ }
128
+
129
+ bool PointerPointProperties::IsInRange() noexcept {
130
+ return m_sysPointerPointProps ? m_sysPointerPointProps.IsInRange() : m_isInRange;
131
+ }
132
+
133
+ bool PointerPointProperties::IsInverted() noexcept {
134
+ return m_sysPointerPointProps ? m_sysPointerPointProps.IsInverted() : m_isInverted;
135
+ }
136
+
137
+ bool PointerPointProperties::IsLeftButtonPressed() noexcept {
138
+ return m_sysPointerPointProps ? m_sysPointerPointProps.IsLeftButtonPressed() : m_isLeftButtonPressed;
139
+ }
140
+
141
+ bool PointerPointProperties::IsMiddleButtonPressed() noexcept {
142
+ return m_sysPointerPointProps ? m_sysPointerPointProps.IsMiddleButtonPressed() : m_isMiddleButtonPressed;
143
+ }
144
+
145
+ bool PointerPointProperties::IsPrimary() noexcept {
146
+ return m_sysPointerPointProps ? m_sysPointerPointProps.IsPrimary() : m_isPrimary;
147
+ }
148
+
149
+ bool PointerPointProperties::IsRightButtonPressed() noexcept {
150
+ return m_sysPointerPointProps ? m_sysPointerPointProps.IsRightButtonPressed() : m_isRightButtonPressed;
151
+ }
152
+
153
+ bool PointerPointProperties::IsXButton1Pressed() noexcept {
154
+ return m_sysPointerPointProps ? m_sysPointerPointProps.IsXButton1Pressed() : m_isXButton1Pressed;
155
+ }
156
+
157
+ bool PointerPointProperties::IsXButton2Pressed() noexcept {
158
+ return m_sysPointerPointProps ? m_sysPointerPointProps.IsXButton2Pressed() : m_isXButton2Pressed;
159
+ }
160
+
161
+ int32_t PointerPointProperties::MouseWheelDelta() noexcept {
162
+ return m_sysPointerPointProps ? m_sysPointerPointProps.MouseWheelDelta() : m_mouseWheelDelta;
163
+ }
164
+
165
+ float PointerPointProperties::Orientation() noexcept {
166
+ return m_sysPointerPointProps ? m_sysPointerPointProps.Orientation() : m_orientation;
167
+ }
168
+
169
+ PointerUpdateKind PointerPointProperties::PointerUpdateKind() noexcept {
170
+ return m_sysPointerPointProps ? static_cast<winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind>(
171
+ m_sysPointerPointProps.PointerUpdateKind())
172
+ : m_pointerUpdateKind;
173
+ }
174
+
175
+ float PointerPointProperties::Pressure() noexcept {
176
+ return m_sysPointerPointProps ? m_sysPointerPointProps.Pressure() : m_pressure;
177
+ }
178
+
179
+ bool PointerPointProperties::TouchConfidence() noexcept {
180
+ return m_sysPointerPointProps ? m_sysPointerPointProps.TouchConfidence() : m_touchConfidence;
181
+ }
182
+
183
+ float PointerPointProperties::Twist() noexcept {
184
+ return m_sysPointerPointProps ? m_sysPointerPointProps.Twist() : m_twist;
185
+ }
186
+
187
+ float PointerPointProperties::XTilt() noexcept {
188
+ return m_sysPointerPointProps ? m_sysPointerPointProps.XTilt() : m_xTilt;
189
+ }
190
+
191
+ float PointerPointProperties::YTilt() noexcept {
192
+ return m_sysPointerPointProps ? m_sysPointerPointProps.YTilt() : m_yTilt;
193
+ }
194
+
195
+ PointerPoint::PointerPoint(const winrt::Windows::UI::Input::PointerPoint &pp) : m_sysPointerPoint(pp) {}
196
+
197
+ PointerPoint::PointerPoint(uint32_t msg, uint64_t wParam, int64_t lParam) {
198
+ m_msg = msg;
199
+ m_wParam = wParam;
200
+ m_lParam = lParam;
201
+ if (IsPointerMessage(msg)) {
202
+ const unsigned int pointerId = GET_POINTERID_WPARAM(wParam);
203
+ bool result = ::GetPointerInfo(pointerId, &m_pi);
204
+ assert(result);
205
+ }
206
+ }
207
+
208
+ uint32_t PointerPoint::FrameId() noexcept {
209
+ return m_sysPointerPoint ? m_sysPointerPoint.FrameId() : m_pi.frameId;
210
+ }
211
+
212
+ bool PointerPoint::IsInContact() noexcept {
213
+ return m_sysPointerPoint ? m_sysPointerPoint.IsInContact()
214
+ : ((m_pi.pointerFlags & POINTER_FLAG_INCONTACT) == POINTER_FLAG_INCONTACT);
215
+ }
216
+
217
+ winrt::Microsoft::ReactNative::Composition::Input::PointerDeviceType PointerPoint::PointerDeviceType() noexcept {
218
+ if (m_sysPointerPoint) {
219
+ return static_cast<winrt::Microsoft::ReactNative::Composition::Input::PointerDeviceType>(
220
+ m_sysPointerPoint.PointerDevice().PointerDeviceType());
221
+ }
222
+
223
+ if (m_pi.pointerId) {
224
+ switch (m_pi.pointerType) {
225
+ case PT_MOUSE:
226
+ return winrt::Microsoft::ReactNative::Composition::Input::PointerDeviceType::Mouse;
227
+ case PT_PEN:
228
+ return winrt::Microsoft::ReactNative::Composition::Input::PointerDeviceType::Pen;
229
+ case PT_TOUCHPAD:
230
+ return winrt::Microsoft::ReactNative::Composition::Input::PointerDeviceType::Touchpad;
231
+ case PT_TOUCH:
232
+ case PT_POINTER:
233
+ default:
234
+ return winrt::Microsoft::ReactNative::Composition::Input::PointerDeviceType::Touchpad;
235
+ }
236
+ }
237
+
238
+ return winrt::Microsoft::ReactNative::Composition::Input::PointerDeviceType::Mouse;
239
+ }
240
+
241
+ uint32_t PointerPoint::PointerId() noexcept {
242
+ return m_sysPointerPoint ? m_sysPointerPoint.PointerId() : (m_pi.pointerId ? m_pi.pointerId : 1 /* MOUSE */);
243
+ }
244
+
245
+ winrt::Windows::Foundation::Point PointerPoint::Position() noexcept {
246
+ return m_sysPointerPoint
247
+ ? m_sysPointerPoint.Position()
248
+ : (m_pi.pointerId
249
+ ? winrt::Windows::Foundation::
250
+ Point{static_cast<float>(m_pi.ptPixelLocation.x), static_cast<float>(m_pi.ptPixelLocation.y)}
251
+ : winrt::Windows::Foundation::Point{
252
+ static_cast<float>(GET_X_LPARAM(m_lParam)), static_cast<float>(GET_Y_LPARAM(m_lParam))});
253
+ }
254
+
255
+ winrt::Microsoft::ReactNative::Composition::Input::PointerPointProperties PointerPoint::Properties() noexcept {
256
+ if (m_sysPointerPoint) {
257
+ return winrt::make<PointerPointProperties>(m_sysPointerPoint.Properties());
258
+ }
259
+
260
+ if (m_pi.pointerId) {
261
+ auto pointerUpdateKind = winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::Other;
262
+ switch (m_pi.ButtonChangeType) {
263
+ case POINTER_CHANGE_FIRSTBUTTON_DOWN:
264
+ pointerUpdateKind = winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::LeftButtonPressed;
265
+ break;
266
+ case POINTER_CHANGE_FIRSTBUTTON_UP:
267
+ pointerUpdateKind = winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::LeftButtonReleased;
268
+ break;
269
+ case POINTER_CHANGE_SECONDBUTTON_DOWN:
270
+ pointerUpdateKind = winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::RightButtonPressed;
271
+ break;
272
+ case POINTER_CHANGE_SECONDBUTTON_UP:
273
+ pointerUpdateKind = winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::RightButtonReleased;
274
+ break;
275
+ case POINTER_CHANGE_THIRDBUTTON_DOWN:
276
+ pointerUpdateKind = winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::MiddleButtonPressed;
277
+ break;
278
+ case POINTER_CHANGE_THIRDBUTTON_UP:
279
+ pointerUpdateKind = winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::MiddleButtonReleased;
280
+ break;
281
+ case POINTER_CHANGE_FOURTHBUTTON_DOWN:
282
+ pointerUpdateKind = winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::XButton1Pressed;
283
+ break;
284
+ case POINTER_CHANGE_FOURTHBUTTON_UP:
285
+ pointerUpdateKind = winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::XButton1Released;
286
+ break;
287
+ case POINTER_CHANGE_FIFTHBUTTON_DOWN:
288
+ pointerUpdateKind = winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::XButton2Pressed;
289
+ break;
290
+ case POINTER_CHANGE_FIFTHBUTTON_UP:
291
+ pointerUpdateKind = winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::XButton2Released;
292
+ break;
293
+ }
294
+
295
+ return winrt::make<PointerPointProperties>(
296
+ false, // TODO isBarrelButtonPressed,
297
+ (m_pi.pointerFlags & POINTER_FLAG_CANCELED) == POINTER_FLAG_CANCELED, // isCanceled
298
+ false, // TODO isEraser,
299
+ (m_pi.pointerFlags & POINTER_FLAG_HWHEEL) == POINTER_FLAG_HWHEEL, // isHorizontalMouseWheel
300
+ (m_pi.pointerFlags & POINTER_FLAG_INRANGE) == POINTER_FLAG_INRANGE, // isInRange
301
+ false, // TODO isInverted,
302
+ (m_pi.pointerFlags & POINTER_FLAG_FIRSTBUTTON) == POINTER_FLAG_FIRSTBUTTON, // isLeftButtonPressed
303
+ (m_pi.pointerFlags & POINTER_FLAG_THIRDBUTTON) == POINTER_FLAG_THIRDBUTTON, // isMiddleButtonPressed
304
+ (m_pi.pointerFlags & POINTER_FLAG_PRIMARY) == POINTER_FLAG_PRIMARY, // isPrimary
305
+ (m_pi.pointerFlags & POINTER_FLAG_SECONDBUTTON) == POINTER_FLAG_SECONDBUTTON, // isRightButtonPressed
306
+ (m_pi.pointerFlags & POINTER_FLAG_FOURTHBUTTON) == POINTER_FLAG_FOURTHBUTTON, // isXButton1Pressed
307
+ (m_pi.pointerFlags & POINTER_FLAG_FIFTHBUTTON) == POINTER_FLAG_FIFTHBUTTON, // isXButton2Pressed
308
+ (m_pi.pointerFlags & POINTER_FLAG_CONFIDENCE) == POINTER_FLAG_CONFIDENCE, // touchConfidence
309
+ 0, // mouseWheelDelta would come through a WM_(H)MOUSEWHEEL message, which wont have a POINTER_INFO struct,
310
+ 0.0f, // TODO orientation,
311
+ pointerUpdateKind,
312
+ 0.0f, // TODO pressure,
313
+ 0.0f, // TODO twist,
314
+ 0.0f, // TODO xTilt,
315
+ 0.0f // TODO yTilt
316
+ );
317
+ }
318
+
319
+ auto pointerUpdateKind = winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::Other;
320
+ switch (m_msg) {
321
+ case WM_LBUTTONDOWN:
322
+ pointerUpdateKind = winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::LeftButtonPressed;
323
+ break;
324
+ case WM_LBUTTONUP:
325
+ pointerUpdateKind = winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::LeftButtonReleased;
326
+ break;
327
+ case WM_RBUTTONDOWN:
328
+ pointerUpdateKind = winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::RightButtonPressed;
329
+ break;
330
+ case WM_RBUTTONUP:
331
+ pointerUpdateKind = winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::RightButtonReleased;
332
+ break;
333
+ case WM_MBUTTONDOWN:
334
+ pointerUpdateKind = winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::MiddleButtonPressed;
335
+ break;
336
+ case WM_MBUTTONUP:
337
+ pointerUpdateKind = winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::MiddleButtonReleased;
338
+ break;
339
+ case WM_XBUTTONDOWN:
340
+ pointerUpdateKind = (GET_XBUTTON_WPARAM(m_wParam) == XBUTTON1)
341
+ ? winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::XButton1Pressed
342
+ : winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::XButton2Pressed;
343
+ break;
344
+ case WM_XBUTTONUP:
345
+ pointerUpdateKind = (GET_XBUTTON_WPARAM(m_wParam) == XBUTTON1)
346
+ ? winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::XButton1Released
347
+ : winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::XButton2Released;
348
+ break;
349
+ }
350
+
351
+ return winrt::make<PointerPointProperties>(
352
+ false, // isBarrelButtonPressed,
353
+ false, // isCanceled,
354
+ false, // isEraser,
355
+ m_msg == WM_MOUSEHWHEEL, // isHorizontalMouseWheel,
356
+ false, // isInRange,
357
+ false, // isInverted,
358
+ (m_wParam & MK_LBUTTON) == MK_LBUTTON,
359
+ (m_wParam & MK_MBUTTON) == MK_MBUTTON,
360
+ true, // isPrimary,
361
+ (m_wParam & MK_RBUTTON) == MK_RBUTTON,
362
+ (m_wParam & MK_XBUTTON1) == MK_XBUTTON1,
363
+ (m_wParam & MK_XBUTTON2) == MK_XBUTTON2,
364
+ true, // touchConfidence,
365
+ (m_msg == WM_MOUSEWHEEL || m_msg == WM_MOUSEHWHEEL) ? GET_WHEEL_DELTA_WPARAM(m_wParam) : 0, // mouseWheelDelta,
366
+ 0.0f, // orientation,
367
+ pointerUpdateKind,
368
+ 0.0f, // pressure,
369
+ 0.0f, // twist,
370
+ 0.0f, // xTilt,
371
+ 0.0f // yTilt
372
+ );
373
+ }
374
+
375
+ uint64_t PointerPoint::Timestamp() noexcept {
376
+ return m_sysPointerPoint ? m_sysPointerPoint.Timestamp() : m_pi.dwTime;
377
+ }
378
+
379
+ winrt::Microsoft::ReactNative::Composition::Input::PointerPoint PointerPoint::GetTransformedPoint(
380
+ const IPointerPointTransform &transform) noexcept {
381
+ return winrt::make<PointerPoint>(m_sysPointerPoint);
382
+ }
383
+
384
+ bool PointerPoint::IsPointerMessage(uint32_t message) noexcept {
385
+ constexpr uint32_t WM_POINTERFIRST = 0x0245;
386
+ constexpr uint32_t WM_POINTERLAST = 0x0257;
387
+ return (message >= WM_POINTERFIRST && message <= WM_POINTERLAST);
388
+ }
389
+
390
+ PointerRoutedEventArgs::PointerRoutedEventArgs(
391
+ facebook::react::Tag tag,
392
+ const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pp,
393
+ const winrt::Windows::System::VirtualKeyModifiers &virtualKeyModifiers)
394
+ : m_tag(tag), m_virtualKeyModifiers(virtualKeyModifiers) {
395
+ m_pointerPoint = pp;
396
+ }
397
+
398
+ int32_t PointerRoutedEventArgs::OriginalSource() noexcept {
399
+ return m_tag;
400
+ }
401
+
402
+ winrt::Microsoft::ReactNative::Composition::Input::PointerPoint PointerRoutedEventArgs::GetCurrentPoint(
403
+ int32_t tag) noexcept {
404
+ assert(tag == -1); // TODO: Non-null tags need to apply a transform
405
+ return m_pointerPoint;
406
+ }
407
+
408
+ bool PointerRoutedEventArgs::Handled() noexcept {
409
+ return m_handled;
410
+ }
411
+
412
+ void PointerRoutedEventArgs::Handled(bool value) noexcept {
413
+ m_handled = value;
414
+ }
415
+
416
+ winrt::Windows::System::VirtualKeyModifiers PointerRoutedEventArgs::KeyModifiers() noexcept {
417
+ return m_virtualKeyModifiers;
418
+ }
419
+
61
420
  } // namespace winrt::Microsoft::ReactNative::Composition::Input::implementation
@@ -2,8 +2,13 @@
2
2
  // Licensed under the MIT License.
3
3
 
4
4
  #pragma once
5
+ #include "Composition.Input.PointerPoint.g.h"
6
+ #include "Composition.Input.PointerPointProperties.g.h"
7
+ #include "Composition.Input.PointerRoutedEventArgs.g.h"
5
8
  #include <react/renderer/core/ReactPrimitives.h>
6
9
  #include <winrt/Microsoft.ReactNative.Composition.Input.h>
10
+ #include <winrt/Windows.System.h>
11
+ #include <winrt/Windows.UI.Input.h>
7
12
 
8
13
  namespace winrt::Microsoft::ReactNative::Composition::Input::implementation {
9
14
 
@@ -28,4 +33,123 @@ struct KeyRoutedEventArgs : winrt::implements<
28
33
  winrt::Windows::UI::Core::CorePhysicalKeyStatus m_keyStatus;
29
34
  };
30
35
 
36
+ struct PointerPointProperties : PointerPointPropertiesT<PointerPointProperties> {
37
+ PointerPointProperties(const winrt::Windows::UI::Input::PointerPointProperties &ppp);
38
+
39
+ PointerPointProperties(
40
+ bool isBarrelButtonPressed,
41
+ bool isCanceled,
42
+ bool isEraser,
43
+ bool isHorizontalMouseWheel,
44
+ bool isInRange,
45
+ bool isInverted,
46
+ bool isLeftButtonPressed,
47
+ bool isMiddleButtonPressed,
48
+ bool isPrimary,
49
+ bool isRightButtonPressed,
50
+ bool isXButton1Pressed,
51
+ bool isXButton2Pressed,
52
+ bool touchConfidence,
53
+ int32_t mouseWheelDelta,
54
+ float orientation,
55
+ PointerUpdateKind pointerUpdateKind,
56
+ float pressure,
57
+ float twist,
58
+ float xTilt,
59
+ float yTilt);
60
+
61
+ winrt::Windows::Foundation::Rect ContactRect() noexcept;
62
+ bool IsBarrelButtonPressed() noexcept;
63
+ bool IsCanceled() noexcept;
64
+ bool IsEraser() noexcept;
65
+ bool IsHorizontalMouseWheel() noexcept;
66
+ bool IsInRange() noexcept;
67
+ bool IsInverted() noexcept;
68
+ bool IsLeftButtonPressed() noexcept;
69
+ bool IsMiddleButtonPressed() noexcept;
70
+ bool IsPrimary() noexcept;
71
+ bool IsRightButtonPressed() noexcept;
72
+ bool IsXButton1Pressed() noexcept;
73
+ bool IsXButton2Pressed() noexcept;
74
+ int32_t MouseWheelDelta() noexcept;
75
+ float Orientation() noexcept;
76
+ PointerUpdateKind PointerUpdateKind() noexcept;
77
+ float Pressure() noexcept;
78
+ bool TouchConfidence() noexcept;
79
+ float Twist() noexcept;
80
+ float XTilt() noexcept;
81
+ float YTilt() noexcept;
82
+
83
+ private:
84
+ winrt::Windows::UI::Input::PointerPointProperties m_sysPointerPointProps{nullptr};
85
+
86
+ // When not using m_sysPointerPointProps
87
+ bool m_isBarrelButtonPressed : 1;
88
+ bool m_isCanceled : 1;
89
+ bool m_isEraser : 1;
90
+ bool m_isHorizontalMouseWheel : 1;
91
+ bool m_isInRange : 1;
92
+ bool m_isInverted : 1;
93
+ bool m_isLeftButtonPressed : 1;
94
+ bool m_isMiddleButtonPressed : 1;
95
+ bool m_isPrimary : 1;
96
+ bool m_isRightButtonPressed : 1;
97
+ bool m_isXButton1Pressed : 1;
98
+ bool m_isXButton2Pressed : 1;
99
+ bool m_touchConfidence : 1;
100
+ int32_t m_mouseWheelDelta;
101
+ float m_orientation;
102
+ winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind m_pointerUpdateKind;
103
+ float m_pressure;
104
+ float m_twist;
105
+ float m_xTilt;
106
+ float m_yTilt;
107
+ };
108
+
109
+ struct PointerPoint : PointerPointT<PointerPoint> {
110
+ PointerPoint(const winrt::Windows::UI::Input::PointerPoint &pp);
111
+ PointerPoint(uint32_t msg, uint64_t wParam, int64_t lParam);
112
+
113
+ uint32_t FrameId() noexcept;
114
+ bool IsInContact() noexcept;
115
+ PointerDeviceType PointerDeviceType() noexcept;
116
+ uint32_t PointerId() noexcept;
117
+ winrt::Windows::Foundation::Point Position() noexcept;
118
+ winrt::Microsoft::ReactNative::Composition::Input::PointerPointProperties Properties() noexcept;
119
+ uint64_t Timestamp() noexcept;
120
+ winrt::Microsoft::ReactNative::Composition::Input::PointerPoint GetTransformedPoint(
121
+ const IPointerPointTransform &transform) noexcept;
122
+
123
+ private:
124
+ bool IsPointerMessage(uint32_t message) noexcept;
125
+
126
+ // Windows::Input
127
+ winrt::Windows::UI::Input::PointerPoint m_sysPointerPoint{nullptr};
128
+ // WM_POINTER*
129
+ POINTER_INFO m_pi = {0};
130
+ // WM_*MOUSE
131
+ uint32_t m_msg;
132
+ uint64_t m_wParam;
133
+ int64_t m_lParam;
134
+ };
135
+
136
+ struct PointerRoutedEventArgs : PointerRoutedEventArgsT<PointerRoutedEventArgs> {
137
+ PointerRoutedEventArgs(
138
+ facebook::react::Tag tag,
139
+ const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pp,
140
+ const winrt::Windows::System::VirtualKeyModifiers &virtualKeyModifiers);
141
+
142
+ int32_t OriginalSource() noexcept;
143
+ winrt::Microsoft::ReactNative::Composition::Input::PointerPoint GetCurrentPoint(int32_t tag) noexcept;
144
+ bool Handled() noexcept;
145
+ void Handled(bool value) noexcept;
146
+ winrt::Windows::System::VirtualKeyModifiers KeyModifiers() noexcept;
147
+
148
+ private:
149
+ facebook::react::Tag m_tag{-1};
150
+ bool m_handled{false};
151
+ winrt::Microsoft::ReactNative::Composition::Input::PointerPoint m_pointerPoint{nullptr};
152
+ winrt::Windows::System::VirtualKeyModifiers m_virtualKeyModifiers;
153
+ };
154
+
31
155
  } // namespace winrt::Microsoft::ReactNative::Composition::Input::implementation