[0.84] fix: correct CompositionHwndHost initialization order for DPI-aware second windows#16148
Open
gmacmaster wants to merge 2 commits into
Conversation
…econd windows (#7) * fix: correct CompositionHwndHost initialization order for DPI-aware second windows CompositionHwndHost::Initialize() connected the ContentIsland to the DesktopChildSiteBridge before setting the ResizePolicy, causing the island's coordinate space to be configured without proper DPI awareness. This led to InputPointerSource delivering touch coordinates that did not account for the display's scale factor on secondary windows at non-100% zoom. Reorders initialization to match ReactNativeWindow::ContentSiteBridge(): ResizePolicy is now set before Connect, and ScaleFactor is set before the island is connected. Also adds WM_DPICHANGED handling to TranslateMessage so the island's scale factor and layout are updated if the display DPI changes at runtime. * Update CompositionHwndHost.cpp * Update CompositionHwndHost.cpp * host lost on function return * Update CompositionHwndHost.cpp * Create react-native-windows-c628c673-e01f-4887-9fcf-b1e5c468d311.json
Contributor
Author
|
Will create port to main if this looks good |
Contributor
|
Do we need the WM_DPICHANGED handler? Don't we get a RasterizationScaleChange from the ContentIsland? |
acoates-ms
reviewed
May 18, 2026
|
|
||
| HWND m_hwnd; | ||
| winrt::Microsoft::ReactNative::ReactNativeIsland m_compRootView{nullptr}; | ||
| winrt::Microsoft::UI::Content::DesktopChildSiteBridge m_bridge{nullptr}; |
Contributor
There was a problem hiding this comment.
And now we dont need to store the DesktopChildSiteBridge...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Type of Change
Why
CompositionHwndHost::Initialize()connected theContentIslandto theDesktopChildSiteBridgebefore setting theResizePolicy, causing the island's coordinate space to be configured without proper DPI awareness. This led toInputPointerSourcedelivering touch coordinates that did not account for the display's scale factor on secondary windows at non-100% zoom.What
Initialization reorder (
CompositionHwndHost.cpp/.h):DesktopChildSiteBridgefrom a local variable to a member (m_bridge) so it survives pastInitialize().Initialize()so thatResizePolicyis set beforeConnect, andScaleFactoris set before the island is connected — matching theReactNativeWindow::ContentSiteBridgereference pattern.Runtime DPI changes (e.g., moving the window between monitors with different scales) are already handled by
ReactNativeIsland'sContentIsland::StateChangedsubscription, which responds toDidRasterizationScaleChange()and callsScaleFactor()→Arrange()directly.Screenshots
N/A — this is a behavioral/layout correctness fix; the visual result is that touch input on secondary windows at non-100% DPI now aligns correctly with their visual positions.
Testing
Verified locally by:
CompositionHwndHostwindow on a 150% DPI display — touch targets now align correctly with their visual positions.ReactNativeIsland'sRasterizationScaleChangedsubscription).Changelog
Should this change be included in the release notes: yes
Fix
CompositionHwndHostinitialization order so thatResizePolicyis set beforeConnectandScaleFactorbefore the island is connected, ensuring secondary windows render with correct DPI-aware touch coordinates.