Repository navigation
fix(skia-win32): re-apply SetWindowPos after SW_SHOWNORMAL on first show - #23196
Merged
Merged
Conversation
SW_SHOWNORMAL restores the window's saved WINDOWPLACEMENT.rcNormalPosition, which still holds the old screen coordinates from before SetParent. Once the window is a child, those coordinates are reinterpreted as parent-relative offsets, placing the native element at the wrong position. Re-applying SetWindowPos immediately after ShowWindow overrides the restored placement so the element appears at the correct location. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a Win32 Skia regression in native element hosting where a re-parented child HWND could appear at stale screen coordinates on its first show. It does so within Win32NativeElementHostingExtension, which is the Win32-specific bridge between Uno layout/clip updates and hosted native windows.
Changes:
- Keeps the existing deferred first-show flow, but now re-applies
SetWindowPosimmediately afterSW_SHOWNORMAL. - Documents why
SW_SHOWNORMALrestores staleWINDOWPLACEMENT.rcNormalPositionvalues afterSetParent. - Preserves the existing logging path if the corrective
SetWindowPoscall fails.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23196/wasm-skia-net9/index.html |
ramezgerges
approved these changes
May 5, 2026
pull Bot
pushed a commit
to Stars1233/uno
that referenced
this pull request
May 8, 2026
…/dev/xygu/20260504/win32-native-element-coords"" This reverts commit bfc23e2.
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.
GitHub Issue: closes unoplatform/kahua-private#467
PR Type:
🐞 Bugfix
What is the current behavior? 🤔
Since #23126, native elements hosted in a Win32 Skia window are placed at the wrong position on first show. The element appears at its original screen coordinates (e.g. 268,291 / 1440×759) rather than at the correct parent-relative position (e.g. 0,141 / 991×500). Resizing the element by even 1 pixel corrects it.
What is the new behavior? 🚀
Native elements appear at the correct position immediately on first show, without requiring a resize.
Root cause
SW_SHOWNORMALrestores the window using its savedWINDOWPLACEMENT.rcNormalPosition, which still holds the old screen coordinates from beforeSetParentwas called. Once the window is a child, those screen coordinates are reinterpreted as parent-relative offsets, placing the element at the wrong location.The pre-#23126 code accidentally masked this:
ShowWindowwas called inArrangeNativeElement, and a second arrange immediately followed with anotherSetWindowPosthat corrected the position. After #23126 deferred show to the render handler, there was no subsequentSetWindowPosto fix it — hence the resize workaround worked (it triggered anotherSetWindowPosafter the window was already visible).Fix: re-apply
SetWindowPoswith the correct rect immediately afterSW_SHOWNORMAL.PR Checklist ✅
Screenshots Compare Test Runresults.