react-native-windows 0.74.0-preview.4 → 0.74.0
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/Fabric/Composition/CompositionContextHelper.cpp +8 -2
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView.cpp +12 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView.h +1 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +79 -77
- package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +7 -14
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +2 -5
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +2 -1
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +5 -1
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +2 -8
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +20 -15
- package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.cpp +2 -5
- package/Microsoft.ReactNative/Utils/KeyboardUtils.cpp +10 -2
- package/Microsoft.ReactNative/Utils/KeyboardUtils.h +4 -1
- package/Microsoft.ReactNative.Cxx/AutoDraw.h +3 -1
- package/Microsoft.ReactNative.Cxx/CompositionSwitcher.Experimental.interop.h +1 -1
- package/PropertySheets/Generated/PackageVersion.g.props +2 -2
- package/Scripts/OfficeReact.Win32.nuspec +2 -0
- package/package.json +8 -5
|
@@ -256,13 +256,19 @@ struct CompDrawingSurfaceBrush : public winrt::implements<
|
|
|
256
256
|
drawingSurface.as(m_drawingSurfaceInterop);
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
HRESULT BeginDraw(ID2D1DeviceContext **deviceContextOut, POINT *offset) noexcept {
|
|
259
|
+
HRESULT BeginDraw(ID2D1DeviceContext **deviceContextOut, float xDpi, float yDpi, POINT *offset) noexcept {
|
|
260
260
|
#ifdef DEBUG
|
|
261
261
|
// Drawing to a zero sized surface is a waste of time
|
|
262
262
|
auto size = m_drawingSurfaceInterop.as<typename TTypeRedirects::CompositionDrawingSurface>().Size();
|
|
263
263
|
assert(size.Width != 0 && size.Height != 0);
|
|
264
264
|
#endif
|
|
265
|
-
|
|
265
|
+
|
|
266
|
+
auto hr =
|
|
267
|
+
m_drawingSurfaceInterop->BeginDraw(nullptr, __uuidof(ID2D1DeviceContext), (void **)deviceContextOut, offset);
|
|
268
|
+
if (SUCCEEDED(hr)) {
|
|
269
|
+
(*deviceContextOut)->SetDpi(xDpi, yDpi);
|
|
270
|
+
}
|
|
271
|
+
return hr;
|
|
266
272
|
}
|
|
267
273
|
|
|
268
274
|
HRESULT EndDraw() noexcept {
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
|
|
34
34
|
#ifdef USE_WINUI3
|
|
35
35
|
#include <winrt/Microsoft.UI.Content.h>
|
|
36
|
+
#include <winrt/Microsoft.UI.Input.h>
|
|
36
37
|
#endif
|
|
37
38
|
|
|
38
39
|
namespace winrt::Microsoft::ReactNative::implementation {
|
|
@@ -183,6 +184,16 @@ void CompositionRootView::RemoveRenderedVisual(
|
|
|
183
184
|
m_hasRenderedVisual = false;
|
|
184
185
|
}
|
|
185
186
|
|
|
187
|
+
bool CompositionRootView::TrySetFocus() noexcept {
|
|
188
|
+
#ifdef USE_WINUI3
|
|
189
|
+
if (m_island) {
|
|
190
|
+
auto focusController = winrt::Microsoft::UI::Input::InputFocusController::GetForIsland(m_island);
|
|
191
|
+
return focusController.TrySetFocus();
|
|
192
|
+
}
|
|
193
|
+
#endif
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
|
|
186
197
|
winrt::Windows::Foundation::Size CompositionRootView::Size() noexcept {
|
|
187
198
|
return m_size;
|
|
188
199
|
}
|
|
@@ -487,7 +498,7 @@ Composition::Experimental::IDrawingSurfaceBrush CompositionRootView::CreateLoadi
|
|
|
487
498
|
|
|
488
499
|
POINT offset;
|
|
489
500
|
{
|
|
490
|
-
::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(drawingSurface, &offset);
|
|
501
|
+
::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(drawingSurface, m_scaleFactor, &offset);
|
|
491
502
|
if (auto d2dDeviceContext = autoDraw.GetRenderTarget()) {
|
|
492
503
|
d2dDeviceContext->Clear(D2D1::ColorF(D2D1::ColorF::Green));
|
|
493
504
|
|
|
@@ -71,6 +71,7 @@ struct CompositionRootView
|
|
|
71
71
|
|
|
72
72
|
void AddRenderedVisual(const winrt::Microsoft::ReactNative::Composition::Experimental::IVisual &visual) noexcept;
|
|
73
73
|
void RemoveRenderedVisual(const winrt::Microsoft::ReactNative::Composition::Experimental::IVisual &visual) noexcept;
|
|
74
|
+
bool TrySetFocus() noexcept;
|
|
74
75
|
|
|
75
76
|
winrt::Microsoft::ReactNative::Composition::Theme Theme() noexcept;
|
|
76
77
|
void Theme(const winrt::Microsoft::ReactNative::Composition::Theme &value) noexcept;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
#include "CompositionViewComponentView.h"
|
|
8
8
|
|
|
9
|
+
#include <AutoDraw.h>
|
|
9
10
|
#include <Fabric/AbiState.h>
|
|
10
11
|
#include <Fabric/AbiViewProps.h>
|
|
11
12
|
#include <Fabric/Composition/CompositionRootView.h>
|
|
@@ -568,31 +569,6 @@ void DrawShape(
|
|
|
568
569
|
pRT->DrawGeometry(&geometry, brush, strokeWidth, strokeStyle);
|
|
569
570
|
}
|
|
570
571
|
|
|
571
|
-
struct AutoDrawHelper {
|
|
572
|
-
AutoDrawHelper(
|
|
573
|
-
winrt::com_ptr<::Microsoft::ReactNative::Composition::Experimental::ICompositionDrawingSurfaceInterop> &surface) {
|
|
574
|
-
m_surface = surface;
|
|
575
|
-
m_surface->BeginDraw(m_pRT.put(), &m_offset);
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
~AutoDrawHelper() {
|
|
579
|
-
m_surface->EndDraw();
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
const winrt::com_ptr<ID2D1DeviceContext> &GetRenderTarget() const noexcept {
|
|
583
|
-
return m_pRT;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
POINT Offset() const noexcept {
|
|
587
|
-
return m_offset;
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
private:
|
|
591
|
-
winrt::com_ptr<::Microsoft::ReactNative::Composition::Experimental::ICompositionDrawingSurfaceInterop> m_surface;
|
|
592
|
-
POINT m_offset;
|
|
593
|
-
winrt::com_ptr<ID2D1DeviceContext> m_pRT;
|
|
594
|
-
};
|
|
595
|
-
|
|
596
572
|
template <typename TShape>
|
|
597
573
|
void SetBorderLayerPropertiesCommon(
|
|
598
574
|
winrt::Microsoft::ReactNative::Composition::implementation::Theme *theme,
|
|
@@ -622,66 +598,59 @@ void SetBorderLayerPropertiesCommon(
|
|
|
622
598
|
|
|
623
599
|
layer.Brush(surface);
|
|
624
600
|
|
|
625
|
-
|
|
601
|
+
POINT offset;
|
|
602
|
+
::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(
|
|
603
|
+
surface, 1.0f /* We have already done the dpi scaling */, &offset);
|
|
604
|
+
if (auto pRT = autoDraw.GetRenderTarget()) {
|
|
605
|
+
// Clear with transparency
|
|
606
|
+
pRT->Clear();
|
|
626
607
|
|
|
627
|
-
|
|
608
|
+
if (!facebook::react::isColorMeaningful(borderColor)) {
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
628
611
|
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
612
|
+
winrt::com_ptr<ID2D1Factory> spFactory;
|
|
613
|
+
pRT->GetFactory(spFactory.put());
|
|
614
|
+
assert(spFactory);
|
|
615
|
+
if (spFactory == nullptr)
|
|
616
|
+
return;
|
|
632
617
|
|
|
633
|
-
|
|
634
|
-
|
|
618
|
+
winrt::com_ptr<ID2D1SolidColorBrush> spBorderBrush;
|
|
619
|
+
pRT->CreateSolidColorBrush(theme->D2DColor(*borderColor), spBorderBrush.put());
|
|
620
|
+
assert(spBorderBrush);
|
|
621
|
+
if (spBorderBrush == nullptr)
|
|
622
|
+
return;
|
|
635
623
|
|
|
636
|
-
|
|
637
|
-
return;
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
winrt::com_ptr<ID2D1Factory> spFactory;
|
|
641
|
-
pRT->GetFactory(spFactory.put());
|
|
642
|
-
assert(spFactory);
|
|
643
|
-
if (spFactory == nullptr)
|
|
644
|
-
return;
|
|
624
|
+
winrt::com_ptr<ID2D1StrokeStyle> spStrokeStyle;
|
|
645
625
|
|
|
646
|
-
|
|
647
|
-
pRT->CreateSolidColorBrush(theme->D2DColor(*borderColor), spBorderBrush.put());
|
|
648
|
-
assert(spBorderBrush);
|
|
649
|
-
if (spBorderBrush == nullptr)
|
|
650
|
-
return;
|
|
626
|
+
enum class BorderStyle { Solid, Dotted, Dashed };
|
|
651
627
|
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
}
|
|
669
|
-
D2D1::Matrix3x2F originalTransform;
|
|
670
|
-
D2D1::Matrix3x2F translationTransform =
|
|
671
|
-
D2D1::Matrix3x2F::Translation(-textureRect.left + autoDraw.Offset().x, -textureRect.top + autoDraw.Offset().y);
|
|
628
|
+
if (borderStyle == facebook::react::BorderStyle::Dotted || borderStyle == facebook::react::BorderStyle::Dashed) {
|
|
629
|
+
const auto capStyle =
|
|
630
|
+
borderStyle == facebook::react::BorderStyle::Dashed ? D2D1_CAP_STYLE_FLAT : D2D1_CAP_STYLE_ROUND;
|
|
631
|
+
const auto strokeStyleProps = D2D1::StrokeStyleProperties(
|
|
632
|
+
capStyle,
|
|
633
|
+
capStyle,
|
|
634
|
+
capStyle,
|
|
635
|
+
D2D1_LINE_JOIN_MITER,
|
|
636
|
+
10.0f,
|
|
637
|
+
borderStyle == facebook::react::BorderStyle::Dashed ? D2D1_DASH_STYLE_DASH : D2D1_DASH_STYLE_DOT,
|
|
638
|
+
0.0f);
|
|
639
|
+
spFactory->CreateStrokeStyle(&strokeStyleProps, nullptr, 0, spStrokeStyle.put());
|
|
640
|
+
}
|
|
641
|
+
D2D1::Matrix3x2F originalTransform;
|
|
642
|
+
D2D1::Matrix3x2F translationTransform =
|
|
643
|
+
D2D1::Matrix3x2F::Translation(-textureRect.left + offset.x, -textureRect.top + offset.y);
|
|
672
644
|
|
|
673
|
-
|
|
674
|
-
|
|
645
|
+
pRT->GetTransform(&originalTransform);
|
|
646
|
+
translationTransform = originalTransform * translationTransform;
|
|
675
647
|
|
|
676
|
-
|
|
677
|
-
pRT->SetTransform(translationTransform);
|
|
678
|
-
pRT->GetDpi(&oldDpiX, &oldDpiY);
|
|
679
|
-
pRT->SetDpi(96.0f, 96.0f); // We have already done the dpi scaling...
|
|
648
|
+
pRT->SetTransform(translationTransform);
|
|
680
649
|
|
|
681
|
-
|
|
650
|
+
DrawShape(pRT, shape, spBorderBrush.get(), strokeWidth, spStrokeStyle.get());
|
|
682
651
|
|
|
683
|
-
|
|
684
|
-
|
|
652
|
+
pRT->SetTransform(originalTransform);
|
|
653
|
+
}
|
|
685
654
|
}
|
|
686
655
|
|
|
687
656
|
template <typename TShape>
|
|
@@ -1620,10 +1589,43 @@ facebook::react::Tag ViewComponentView::hitTest(
|
|
|
1620
1589
|
return -1;
|
|
1621
1590
|
}
|
|
1622
1591
|
|
|
1592
|
+
inline winrt::Windows::System::VirtualKey GetLeftOrRightModifiedKey(
|
|
1593
|
+
const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
|
|
1594
|
+
winrt::Windows::System::VirtualKey leftKey,
|
|
1595
|
+
winrt::Windows::System::VirtualKey rightKey) {
|
|
1596
|
+
return (source.GetKeyState(leftKey) == winrt::Windows::UI::Core::CoreVirtualKeyStates::Down) ? leftKey : rightKey;
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
std::string CodeFromVirtualKey(
|
|
1600
|
+
const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
|
|
1601
|
+
winrt::Windows::System::VirtualKey virtualKey) {
|
|
1602
|
+
int key = static_cast<int>(virtualKey);
|
|
1603
|
+
|
|
1604
|
+
if (isdigit(key)) {
|
|
1605
|
+
return "Digit" + std::string(1, static_cast<char>(key));
|
|
1606
|
+
} else if (isupper(key)) {
|
|
1607
|
+
return "Key" + std::string(1, static_cast<char>(key));
|
|
1608
|
+
} else {
|
|
1609
|
+
// Override the virtual key if it's modified key of Control, Shift or Menu
|
|
1610
|
+
if (virtualKey == winrt::Windows::System::VirtualKey::Control) {
|
|
1611
|
+
virtualKey = GetLeftOrRightModifiedKey(
|
|
1612
|
+
source, winrt::Windows::System::VirtualKey::LeftControl, winrt::Windows::System::VirtualKey::RightControl);
|
|
1613
|
+
} else if (virtualKey == winrt::Windows::System::VirtualKey::Shift) {
|
|
1614
|
+
virtualKey = GetLeftOrRightModifiedKey(
|
|
1615
|
+
source, winrt::Windows::System::VirtualKey::LeftShift, winrt::Windows::System::VirtualKey::RightShift);
|
|
1616
|
+
} else if (virtualKey == winrt::Windows::System::VirtualKey::Menu) {
|
|
1617
|
+
virtualKey = GetLeftOrRightModifiedKey(
|
|
1618
|
+
source, winrt::Windows::System::VirtualKey::LeftMenu, winrt::Windows::System::VirtualKey::RightMenu);
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
return ::Microsoft::ReactNative::GetOrUnidentifiedCode(virtualKey);
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1623
1625
|
void ViewComponentView::OnKeyDown(
|
|
1624
1626
|
const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
|
|
1625
1627
|
const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept {
|
|
1626
|
-
auto eventCode =
|
|
1628
|
+
auto eventCode = CodeFromVirtualKey(source, args.Key());
|
|
1627
1629
|
bool fShift = source.GetKeyState(winrt::Windows::System::VirtualKey::Shift) !=
|
|
1628
1630
|
winrt::Windows::UI::Core::CoreVirtualKeyStates::None;
|
|
1629
1631
|
bool fAlt = source.GetKeyState(winrt::Windows::System::VirtualKey::Menu) !=
|
|
@@ -1662,7 +1664,7 @@ void ViewComponentView::OnKeyDown(
|
|
|
1662
1664
|
void ViewComponentView::OnKeyUp(
|
|
1663
1665
|
const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
|
|
1664
1666
|
const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept {
|
|
1665
|
-
auto eventCode =
|
|
1667
|
+
auto eventCode = CodeFromVirtualKey(source, args.Key());
|
|
1666
1668
|
bool fShift = source.GetKeyState(winrt::Windows::System::VirtualKey::Shift) !=
|
|
1667
1669
|
winrt::Windows::UI::Core::CoreVirtualKeyStates::None;
|
|
1668
1670
|
bool fAlt = source.GetKeyState(winrt::Windows::System::VirtualKey::Menu) !=
|
|
@@ -225,7 +225,8 @@ void ImageComponentView::ensureDrawingSurface() noexcept {
|
|
|
225
225
|
const auto frame{m_layoutMetrics.getContentFrame().size};
|
|
226
226
|
|
|
227
227
|
if (imageProps->resizeMode == facebook::react::ImageResizeMode::Repeat) {
|
|
228
|
-
drawingSurfaceSize = {
|
|
228
|
+
drawingSurfaceSize = {
|
|
229
|
+
frame.width * m_layoutMetrics.pointScaleFactor, frame.height * m_layoutMetrics.pointScaleFactor};
|
|
229
230
|
} else if (imageProps->blurRadius > 0) {
|
|
230
231
|
// https://learn.microsoft.com/en-us/windows/win32/direct2d/gaussian-blur#output-bitmap
|
|
231
232
|
// The following equation that can be used to compute the output bitmap:
|
|
@@ -291,7 +292,7 @@ void ImageComponentView::DrawImage() noexcept {
|
|
|
291
292
|
|
|
292
293
|
assert(m_reactContext.UIDispatcher().HasThreadAccess());
|
|
293
294
|
|
|
294
|
-
::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(m_drawingSurface, &offset);
|
|
295
|
+
::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(m_drawingSurface, 1.0f, &offset);
|
|
295
296
|
if (auto d2dDeviceContext = autoDraw.GetRenderTarget()) {
|
|
296
297
|
winrt::com_ptr<ID2D1Bitmap1> bitmap;
|
|
297
298
|
winrt::check_hresult(d2dDeviceContext->CreateBitmapFromWicBitmap(m_wicbmp.get(), nullptr, bitmap.put()));
|
|
@@ -362,20 +363,12 @@ void ImageComponentView::DrawImage() noexcept {
|
|
|
362
363
|
winrt::check_hresult(m_wicbmp->GetSize(&width, &height));
|
|
363
364
|
|
|
364
365
|
D2D1_RECT_F rect = D2D1::RectF(
|
|
365
|
-
static_cast<float>(offset.x
|
|
366
|
-
static_cast<float>(offset.y
|
|
367
|
-
static_cast<float>(
|
|
368
|
-
static_cast<float>(
|
|
369
|
-
|
|
370
|
-
const auto dpi = m_layoutMetrics.pointScaleFactor * 96.0f;
|
|
371
|
-
float oldDpiX, oldDpiY;
|
|
372
|
-
d2dDeviceContext->GetDpi(&oldDpiX, &oldDpiY);
|
|
373
|
-
d2dDeviceContext->SetDpi(dpi, dpi);
|
|
366
|
+
static_cast<float>(offset.x),
|
|
367
|
+
static_cast<float>(offset.y),
|
|
368
|
+
static_cast<float>(offset.x + width),
|
|
369
|
+
static_cast<float>(offset.y + height));
|
|
374
370
|
|
|
375
371
|
d2dDeviceContext->DrawBitmap(bitmap.get(), rect);
|
|
376
|
-
|
|
377
|
-
// Restore old dpi setting
|
|
378
|
-
d2dDeviceContext->SetDpi(oldDpiX, oldDpiY);
|
|
379
372
|
}
|
|
380
373
|
}
|
|
381
374
|
}
|
package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp
CHANGED
|
@@ -251,14 +251,11 @@ void WindowsModalHostComponentView::updateLayoutMetrics(
|
|
|
251
251
|
|
|
252
252
|
POINT offset;
|
|
253
253
|
{
|
|
254
|
-
::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(
|
|
254
|
+
::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(
|
|
255
|
+
drawingSurface, m_layoutMetrics.pointScaleFactor, &offset);
|
|
255
256
|
if (auto d2dDeviceContext = autoDraw.GetRenderTarget()) {
|
|
256
257
|
d2dDeviceContext->Clear(D2D1::ColorF(D2D1::ColorF::Blue, 0.3f));
|
|
257
258
|
assert(d2dDeviceContext->GetUnitMode() == D2D1_UNIT_MODE_DIPS);
|
|
258
|
-
const auto dpi = m_layoutMetrics.pointScaleFactor * 96.0f;
|
|
259
|
-
float oldDpiX, oldDpiY;
|
|
260
|
-
d2dDeviceContext->GetDpi(&oldDpiX, &oldDpiY);
|
|
261
|
-
d2dDeviceContext->SetDpi(dpi, dpi);
|
|
262
259
|
|
|
263
260
|
float offsetX = static_cast<float>(offset.x / m_layoutMetrics.pointScaleFactor);
|
|
264
261
|
float offsetY = static_cast<float>(offset.y / m_layoutMetrics.pointScaleFactor);
|
|
@@ -312,7 +312,8 @@ void ParagraphComponentView::DrawText() noexcept {
|
|
|
312
312
|
|
|
313
313
|
POINT offset;
|
|
314
314
|
{
|
|
315
|
-
::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(
|
|
315
|
+
::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(
|
|
316
|
+
m_drawingSurface, m_layoutMetrics.pointScaleFactor, &offset);
|
|
316
317
|
if (auto d2dDeviceContext = autoDraw.GetRenderTarget()) {
|
|
317
318
|
d2dDeviceContext->Clear(
|
|
318
319
|
m_props->backgroundColor ? theme()->D2DColor(*m_props->backgroundColor)
|
|
@@ -55,8 +55,12 @@ void RootComponentView::SetFocusedComponent(const winrt::Microsoft::ReactNative:
|
|
|
55
55
|
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(m_focusedComponent)->onFocusLost();
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
if (value)
|
|
58
|
+
if (value) {
|
|
59
|
+
if (auto rootView = m_wkRootView.get()) {
|
|
60
|
+
winrt::get_self<winrt::Microsoft::ReactNative::implementation::CompositionRootView>(rootView)->TrySetFocus();
|
|
61
|
+
}
|
|
59
62
|
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(value)->onFocusGained();
|
|
63
|
+
}
|
|
60
64
|
|
|
61
65
|
m_focusedComponent = value;
|
|
62
66
|
}
|
|
@@ -465,14 +465,10 @@ struct ScrollBarComponent {
|
|
|
465
465
|
|
|
466
466
|
POINT offset;
|
|
467
467
|
{
|
|
468
|
-
::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(drawingSurface, &offset);
|
|
468
|
+
::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(drawingSurface, m_scaleFactor, &offset);
|
|
469
469
|
if (auto d2dDeviceContext = autoDraw.GetRenderTarget()) {
|
|
470
470
|
d2dDeviceContext->Clear(D2D1::ColorF(D2D1::ColorF::Black, 0.0f));
|
|
471
471
|
assert(d2dDeviceContext->GetUnitMode() == D2D1_UNIT_MODE_DIPS);
|
|
472
|
-
const auto dpi = m_scaleFactor * 96.0f;
|
|
473
|
-
float oldDpiX, oldDpiY;
|
|
474
|
-
d2dDeviceContext->GetDpi(&oldDpiX, &oldDpiY);
|
|
475
|
-
d2dDeviceContext->SetDpi(dpi, dpi);
|
|
476
472
|
|
|
477
473
|
// Create a solid color brush for the text. A more sophisticated application might want
|
|
478
474
|
// to cache and reuse a brush across all text elements instead, taking care to recreate
|
|
@@ -507,9 +503,6 @@ struct ScrollBarComponent {
|
|
|
507
503
|
spTextLayout.get(),
|
|
508
504
|
brush.get(),
|
|
509
505
|
D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT);
|
|
510
|
-
|
|
511
|
-
// restore dpi to old state
|
|
512
|
-
d2dDeviceContext->SetDpi(oldDpiX, oldDpiY);
|
|
513
506
|
}
|
|
514
507
|
}
|
|
515
508
|
if (drawingSurface) {
|
|
@@ -873,6 +866,7 @@ void ScrollViewComponentView::OnPointerWheelChanged(
|
|
|
873
866
|
}
|
|
874
867
|
}
|
|
875
868
|
}
|
|
869
|
+
Super::OnPointerWheelChanged(args);
|
|
876
870
|
}
|
|
877
871
|
|
|
878
872
|
void ScrollViewComponentView::OnPointerPressed(
|
package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp
CHANGED
|
@@ -635,7 +635,9 @@ void WindowsTextInputComponentView::OnPointerPressed(
|
|
|
635
635
|
|
|
636
636
|
auto pp = args.GetCurrentPoint(-1); // TODO use local coords?
|
|
637
637
|
auto position = pp.Position();
|
|
638
|
-
POINT ptContainer = {
|
|
638
|
+
POINT ptContainer = {
|
|
639
|
+
static_cast<LONG>(position.X * m_layoutMetrics.pointScaleFactor),
|
|
640
|
+
static_cast<LONG>(position.Y * m_layoutMetrics.pointScaleFactor)};
|
|
639
641
|
lParam = static_cast<LPARAM>(POINTTOPOINTS(ptContainer));
|
|
640
642
|
|
|
641
643
|
if (pp.PointerDeviceType() == winrt::Microsoft::ReactNative::Composition::Input::PointerDeviceType::Mouse) {
|
|
@@ -680,7 +682,9 @@ void WindowsTextInputComponentView::OnPointerReleased(
|
|
|
680
682
|
|
|
681
683
|
auto pp = args.GetCurrentPoint(-1);
|
|
682
684
|
auto position = pp.Position();
|
|
683
|
-
POINT ptContainer = {
|
|
685
|
+
POINT ptContainer = {
|
|
686
|
+
static_cast<LONG>(position.X * m_layoutMetrics.pointScaleFactor),
|
|
687
|
+
static_cast<LONG>(position.Y * m_layoutMetrics.pointScaleFactor)};
|
|
684
688
|
lParam = static_cast<LPARAM>(POINTTOPOINTS(ptContainer));
|
|
685
689
|
|
|
686
690
|
if (pp.PointerDeviceType() == winrt::Microsoft::ReactNative::Composition::Input::PointerDeviceType::Mouse) {
|
|
@@ -725,7 +729,9 @@ void WindowsTextInputComponentView::OnPointerMoved(
|
|
|
725
729
|
|
|
726
730
|
auto pp = args.GetCurrentPoint(-1);
|
|
727
731
|
auto position = pp.Position();
|
|
728
|
-
POINT ptContainer = {
|
|
732
|
+
POINT ptContainer = {
|
|
733
|
+
static_cast<LONG>(position.X * m_layoutMetrics.pointScaleFactor),
|
|
734
|
+
static_cast<LONG>(position.Y * m_layoutMetrics.pointScaleFactor)};
|
|
729
735
|
lParam = static_cast<LPARAM>(POINTTOPOINTS(ptContainer));
|
|
730
736
|
|
|
731
737
|
if (pp.PointerDeviceType() == winrt::Microsoft::ReactNative::Composition::Input::PointerDeviceType::Mouse) {
|
|
@@ -766,7 +772,7 @@ void WindowsTextInputComponentView::OnKeyDown(
|
|
|
766
772
|
DrawBlock db(*this);
|
|
767
773
|
auto hr = m_textServices->TxSendMessage(
|
|
768
774
|
args.KeyStatus().IsMenuKeyDown ? WM_SYSKEYDOWN : WM_KEYDOWN, wParam, lParam, &lresult);
|
|
769
|
-
if (hr
|
|
775
|
+
if (hr == S_OK) { // S_FALSE or S_MSG_KEY_IGNORED means RichEdit didn't handle the key
|
|
770
776
|
args.Handled(true);
|
|
771
777
|
}
|
|
772
778
|
}
|
|
@@ -797,12 +803,12 @@ void WindowsTextInputComponentView::OnKeyUp(
|
|
|
797
803
|
DrawBlock db(*this);
|
|
798
804
|
auto hr = m_textServices->TxSendMessage(
|
|
799
805
|
args.KeyStatus().IsMenuKeyDown ? WM_SYSKEYUP : WM_KEYUP, wParam, lParam, &lresult);
|
|
800
|
-
if (hr
|
|
806
|
+
if (hr == S_OK) { // S_FALSE or S_MSG_KEY_IGNORED means RichEdit didn't handle the key
|
|
801
807
|
args.Handled(true);
|
|
802
808
|
}
|
|
803
809
|
}
|
|
804
810
|
|
|
805
|
-
Super::
|
|
811
|
+
Super::OnKeyUp(source, args);
|
|
806
812
|
}
|
|
807
813
|
|
|
808
814
|
bool WindowsTextInputComponentView::ShouldSubmit(
|
|
@@ -906,7 +912,7 @@ void WindowsTextInputComponentView::OnCharacterReceived(
|
|
|
906
912
|
LRESULT lresult;
|
|
907
913
|
DrawBlock db(*this);
|
|
908
914
|
auto hr = m_textServices->TxSendMessage(WM_CHAR, wParam, lParam, &lresult);
|
|
909
|
-
if (hr >= 0
|
|
915
|
+
if (hr >= 0) {
|
|
910
916
|
args.Handled(true);
|
|
911
917
|
}
|
|
912
918
|
}
|
|
@@ -1036,6 +1042,11 @@ void WindowsTextInputComponentView::updateProps(
|
|
|
1036
1042
|
m_clearTextOnSubmit = newTextInputProps.clearTextOnSubmit;
|
|
1037
1043
|
}
|
|
1038
1044
|
|
|
1045
|
+
if (oldTextInputProps.maxLength != newTextInputProps.maxLength) {
|
|
1046
|
+
LRESULT res;
|
|
1047
|
+
winrt::check_hresult(m_textServices->TxSendMessage(EM_LIMITTEXT, newTextInputProps.maxLength, 0, &res));
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1039
1050
|
if ((!newTextInputProps.submitKeyEvents.empty())) {
|
|
1040
1051
|
m_submitKeyEvents = newTextInputProps.submitKeyEvents;
|
|
1041
1052
|
} else {
|
|
@@ -1430,14 +1441,11 @@ void WindowsTextInputComponentView::DrawText() noexcept {
|
|
|
1430
1441
|
|
|
1431
1442
|
m_drawing = true;
|
|
1432
1443
|
{
|
|
1433
|
-
::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(
|
|
1444
|
+
::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(
|
|
1445
|
+
m_drawingSurface, m_layoutMetrics.pointScaleFactor, &offset);
|
|
1434
1446
|
if (auto d2dDeviceContext = autoDraw.GetRenderTarget()) {
|
|
1435
1447
|
d2dDeviceContext->Clear(D2D1::ColorF(D2D1::ColorF::Black, 0.0f));
|
|
1436
1448
|
assert(d2dDeviceContext->GetUnitMode() == D2D1_UNIT_MODE_DIPS);
|
|
1437
|
-
const auto dpi = m_layoutMetrics.pointScaleFactor * 96.0f;
|
|
1438
|
-
float oldDpiX, oldDpiY;
|
|
1439
|
-
d2dDeviceContext->GetDpi(&oldDpiX, &oldDpiY);
|
|
1440
|
-
d2dDeviceContext->SetDpi(dpi, dpi);
|
|
1441
1449
|
|
|
1442
1450
|
RECTL rc{
|
|
1443
1451
|
static_cast<LONG>(offset.x),
|
|
@@ -1493,9 +1501,6 @@ void WindowsTextInputComponentView::DrawText() noexcept {
|
|
|
1493
1501
|
brush.get(),
|
|
1494
1502
|
D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT);
|
|
1495
1503
|
}
|
|
1496
|
-
|
|
1497
|
-
// restore dpi state
|
|
1498
|
-
d2dDeviceContext->SetDpi(oldDpiX, oldDpiY);
|
|
1499
1504
|
}
|
|
1500
1505
|
}
|
|
1501
1506
|
m_drawing = false;
|
|
@@ -76,14 +76,11 @@ void UnimplementedNativeViewComponentView::updateLayoutMetrics(
|
|
|
76
76
|
|
|
77
77
|
POINT offset;
|
|
78
78
|
{
|
|
79
|
-
::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(
|
|
79
|
+
::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(
|
|
80
|
+
drawingSurface, m_layoutMetrics.pointScaleFactor, &offset);
|
|
80
81
|
if (auto d2dDeviceContext = autoDraw.GetRenderTarget()) {
|
|
81
82
|
d2dDeviceContext->Clear(D2D1::ColorF(D2D1::ColorF::Red, 0.3f));
|
|
82
83
|
assert(d2dDeviceContext->GetUnitMode() == D2D1_UNIT_MODE_DIPS);
|
|
83
|
-
const auto dpi = m_layoutMetrics.pointScaleFactor * 96.0f;
|
|
84
|
-
float oldDpiX, oldDpiY;
|
|
85
|
-
d2dDeviceContext->GetDpi(&oldDpiX, &oldDpiY);
|
|
86
|
-
d2dDeviceContext->SetDpi(dpi, dpi);
|
|
87
84
|
|
|
88
85
|
float offsetX = static_cast<float>(offset.x / m_layoutMetrics.pointScaleFactor);
|
|
89
86
|
float offsetY = static_cast<float>(offset.y / m_layoutMetrics.pointScaleFactor);
|
|
@@ -348,6 +348,14 @@ static const std::string GetOrUnidentified(
|
|
|
348
348
|
return "Unidentified";
|
|
349
349
|
}
|
|
350
350
|
|
|
351
|
+
const std::string GetOrUnidentifiedCode(winrt::Windows::System::VirtualKey virtualKey) {
|
|
352
|
+
return GetOrUnidentified(virtualKey, g_virtualKeyToCode);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
const std::string GetOrUnidentifiedKey(winrt::Windows::System::VirtualKey virtualKey) {
|
|
356
|
+
return GetOrUnidentified(virtualKey, g_virtualKeyToKey);
|
|
357
|
+
}
|
|
358
|
+
|
|
351
359
|
std::string FromVirtualKey(winrt::Windows::System::VirtualKey virtualKey, bool fShift, bool fCaps) {
|
|
352
360
|
int vk = static_cast<int>(virtualKey);
|
|
353
361
|
|
|
@@ -362,7 +370,7 @@ std::string FromVirtualKey(winrt::Windows::System::VirtualKey virtualKey, bool f
|
|
|
362
370
|
return std::string{c};
|
|
363
371
|
}
|
|
364
372
|
|
|
365
|
-
return
|
|
373
|
+
return GetOrUnidentifiedKey(virtualKey);
|
|
366
374
|
}
|
|
367
375
|
|
|
368
376
|
bool IsModifiedKeyPressed(winrt::CoreWindow const &coreWindow, winrt::Windows::System::VirtualKey virtualKey) {
|
|
@@ -410,7 +418,7 @@ std::string CodeFromVirtualKey(winrt::Windows::System::VirtualKey virtualKey) {
|
|
|
410
418
|
}
|
|
411
419
|
}
|
|
412
420
|
|
|
413
|
-
return
|
|
421
|
+
return GetOrUnidentifiedCode(virtualKey);
|
|
414
422
|
}
|
|
415
423
|
|
|
416
424
|
} // namespace Microsoft::ReactNative
|
|
@@ -12,4 +12,7 @@ bool IsModifiedKeyPressed(winrt::CoreWindow const &coreWindow, winrt::Windows::S
|
|
|
12
12
|
std::string FromVirtualKey(winrt::Windows::System::VirtualKey virtualKey, bool fShift, bool fCaps);
|
|
13
13
|
std::string CodeFromVirtualKey(winrt::Windows::System::VirtualKey virtualKey);
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const std::string GetOrUnidentifiedCode(winrt::Windows::System::VirtualKey virtualKey);
|
|
16
|
+
const std::string GetOrUnidentifiedKey(winrt::Windows::System::VirtualKey virtualKey);
|
|
17
|
+
|
|
18
|
+
} // namespace Microsoft::ReactNative
|
|
@@ -11,9 +11,11 @@ class AutoDrawDrawingSurface {
|
|
|
11
11
|
public:
|
|
12
12
|
AutoDrawDrawingSurface(
|
|
13
13
|
winrt::Microsoft::ReactNative::Composition::Experimental::IDrawingSurfaceBrush &drawingSurface,
|
|
14
|
+
float scaleFactor,
|
|
14
15
|
POINT *offset) noexcept {
|
|
15
16
|
drawingSurface.as(m_drawingSurfaceInterop);
|
|
16
|
-
|
|
17
|
+
auto dpi = scaleFactor * 96.0f;
|
|
18
|
+
m_drawingSurfaceInterop->BeginDraw(m_d2dDeviceContext.put(), dpi, dpi, offset);
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
~AutoDrawDrawingSurface() noexcept {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
namespace Microsoft::ReactNative::Composition::Experimental {
|
|
16
16
|
|
|
17
17
|
struct __declspec(uuid("941FDD90-ED27-49CE-A1CD-86ECB2D4A0FA")) ICompositionDrawingSurfaceInterop : public IUnknown {
|
|
18
|
-
virtual HRESULT BeginDraw(ID2D1DeviceContext **deviceContextOut, POINT *offset) noexcept = 0;
|
|
18
|
+
virtual HRESULT BeginDraw(ID2D1DeviceContext **deviceContextOut, float xDpi, float yDpi, POINT *offset) noexcept = 0;
|
|
19
19
|
virtual HRESULT EndDraw() noexcept = 0;
|
|
20
20
|
};
|
|
21
21
|
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
-->
|
|
11
11
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
12
12
|
<PropertyGroup>
|
|
13
|
-
<ReactNativeWindowsVersion>0.74.0
|
|
13
|
+
<ReactNativeWindowsVersion>0.74.0</ReactNativeWindowsVersion>
|
|
14
14
|
<ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
|
|
15
15
|
<ReactNativeWindowsMinor>74</ReactNativeWindowsMinor>
|
|
16
16
|
<ReactNativeWindowsPatch>0</ReactNativeWindowsPatch>
|
|
17
17
|
<ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
|
|
18
|
-
<ReactNativeWindowsCommitId>
|
|
18
|
+
<ReactNativeWindowsCommitId>388cdbb68bde9713f67c0e64e33ef62ea23d892f</ReactNativeWindowsCommitId>
|
|
19
19
|
</PropertyGroup>
|
|
20
20
|
</Project>
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
<file src="$nugetroot$\inc\runtimeexecutor\ReactCommon\RuntimeExecutor.h" target="inc\ReactCommon"/>
|
|
41
41
|
<file src="$nugetroot$\inc\cxxreact\*" target="inc\cxxreact"/>
|
|
42
42
|
<file src="$nugetroot$\inc\jsi\**\*.*" target="inc\jsi"/>
|
|
43
|
+
<file src="$nugetroot$\inc\jsinspector-modern\*" target="inc\jsinspector-modern"/>
|
|
43
44
|
<file src="$nugetroot$\inc\Yoga\*.*" target="inc\Yoga"/>
|
|
44
45
|
<file src="$nugetroot$\inc\folly\**\*.*" target="inc" />
|
|
45
46
|
<file src="$nugetroot$\inc\fmt\**\*.*" target="inc\fmt" />
|
|
@@ -62,6 +63,7 @@
|
|
|
62
63
|
<file src="$nugetroot$\inc\Shared\Networking\OriginPolicy.h" target="inc"/>
|
|
63
64
|
<file src="$nugetroot$\inc\Shared\RuntimeOptions.h" target="inc"/>
|
|
64
65
|
<file src="$nugetroot$\inc\Shared\Tracing.h" target="inc"/>
|
|
66
|
+
<file src="$nugetroot$\inc\Shared\JSI\JSExecutorFactoryDelegate.h" target="inc\JSI"/>
|
|
65
67
|
|
|
66
68
|
<!-- Test DLL -->
|
|
67
69
|
<file src="$nugetroot$\inc\Test\WebSocketServer.h" target="inc\Test" />
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-windows",
|
|
3
|
-
"version": "0.74.0
|
|
3
|
+
"version": "0.74.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@react-native-community/cli": "13.6.4",
|
|
27
27
|
"@react-native-community/cli-platform-android": "13.6.4",
|
|
28
28
|
"@react-native-community/cli-platform-ios": "13.6.4",
|
|
29
|
-
"@react-native-windows/cli": "0.74.0
|
|
29
|
+
"@react-native-windows/cli": "0.74.0",
|
|
30
30
|
"@react-native/assets": "1.0.0",
|
|
31
31
|
"@react-native/assets-registry": "0.74.80",
|
|
32
32
|
"@react-native/codegen": "0.74.80",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"yargs": "^17.6.2"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@react-native-windows/codegen": "0.74.0
|
|
67
|
+
"@react-native-windows/codegen": "0.74.0",
|
|
68
68
|
"@react-native/metro-config": "0.74.80",
|
|
69
69
|
"@rnw-scripts/babel-react-native-config": "0.0.0",
|
|
70
70
|
"@rnw-scripts/eslint-config": "1.2.9",
|
|
@@ -92,11 +92,14 @@
|
|
|
92
92
|
"react-native": "0.74.0-rc.9"
|
|
93
93
|
},
|
|
94
94
|
"beachball": {
|
|
95
|
-
"defaultNpmTag": "
|
|
95
|
+
"defaultNpmTag": "latest",
|
|
96
96
|
"disallowedChangeTypes": [
|
|
97
97
|
"major",
|
|
98
98
|
"minor",
|
|
99
|
-
"
|
|
99
|
+
"prerelease",
|
|
100
|
+
"premajor",
|
|
101
|
+
"preminor",
|
|
102
|
+
"prepatch"
|
|
100
103
|
],
|
|
101
104
|
"gitTags": true
|
|
102
105
|
},
|