Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Fix CompositionHwndHost initialization order: ResizePolicy is now set before Connect and ScaleFactor before the island is connected, matching the ReactNativeWindow reference pattern, so that secondary windows render with correct DPI-aware touch coordinates.",
"packageName": "react-native-windows",
"email": "gordomacmaster@gmail.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,19 @@ void CompositionHwndHost::Initialize(uint64_t hwnd) noexcept {
ReactViewHost().ReactNativeHost().InstanceSettings().Properties());
m_compRootView = winrt::Microsoft::ReactNative::ReactNativeIsland(compositor);

auto bridge = winrt::Microsoft::UI::Content::DesktopChildSiteBridge::Create(
m_bridge = winrt::Microsoft::UI::Content::DesktopChildSiteBridge::Create(
compositor, winrt::Microsoft::UI::GetWindowIdFromWindow(m_hwnd));

auto island = m_compRootView.Island();

bridge.Connect(island);
bridge.Show();
// ResizePolicy must be set before Connect so the bridge configures the
// island's coordinate space with correct DPI awareness (matches
// ReactNativeWindow::ContentSiteBridge initialization order).
m_bridge.ResizePolicy(winrt::Microsoft::UI::Content::ContentSizePolicy::ResizeContentToParentWindow);

auto island = m_compRootView.Island();
m_compRootView.ScaleFactor(ScaleFactor());
bridge.ResizePolicy(winrt::Microsoft::UI::Content::ContentSizePolicy::ResizeContentToParentWindow);

m_bridge.Connect(island);
m_bridge.Show();

m_compRootView.ReactViewHost(std::move(m_reactViewHost));
m_compRootView.ScaleFactor(ScaleFactor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "CompositionHwndHost.g.h"

#include <windows.ui.composition.interop.h>
#include <winrt/Microsoft.UI.Content.h>
#include <winrt/Windows.UI.Composition.Desktop.h>
#include "ReactHost/React.h"

Expand Down Expand Up @@ -34,6 +35,7 @@ struct CompositionHwndHost : CompositionHwndHostT<CompositionHwndHost> {

HWND m_hwnd;
winrt::Microsoft::ReactNative::ReactNativeIsland m_compRootView{nullptr};
winrt::Microsoft::UI::Content::DesktopChildSiteBridge m_bridge{nullptr};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And now we dont need to store the DesktopChildSiteBridge...

LONG m_height{0};
LONG m_width{0};

Expand Down