Repository navigation
fix(x11): Fix WebView2 native element embedding on WSLg (Weston/XWayland) - #23736
ramezgerges merged 5 commits into
Conversation
AttachSubWindow marshalled an XWindowAttributes buffer into XChangeWindowAttributes, which expects the differently-laid-out XSetWindowAttributes. The override_redirect value actually applied came from whatever bytes were at offset 88 (map_installed), so the intended override-redirect was never reliably set. Without it, Weston's XWM (WSLg) reparents the WebView2 GTK toplevel into its own frame window and never lets it go, leaving the webview invisible. - Pass a properly-constructed XSetWindowAttributes. - Set override-redirect on the GTK window right after realization, before it is first mapped, so the WM never starts managing it (once Weston's XWM manages a window, reparenting it away is not reliably possible). - Warn when the reparent doesn't stick instead of failing silently. Validated at runtime on WSLg (Ubuntu 24.04): WebView2 samples now render embedded in the app window; previously the webview window was held under the "Weston WM" window and never displayed. Co-Authored-By: Claude Fable 5 <[email protected]>
RunOnGtkThread now propagates exceptions from the GTK idle callback through the TaskCompletionSource instead of leaving the calling thread blocked forever, and the post-reparent diagnostic checks XQueryTree's status (avoiding a spurious warning and XFree on garbage when the window dies mid-attach) and names the window that kept the native element. Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
Pull request overview
Fixes X11 Skia WebView2 native window embedding under WSLg/Weston by ensuring the embedded/native subwindows are treated as override-redirect early enough to prevent WM reparenting, and by improving diagnostics/robustness around GTK-thread execution.
Changes:
- Correctly applies
override_redirectviaXSetWindowAttributesinX11XamlRootHost.AttachSubWindowand adds a post-reparent diagnostic warning when the WM keeps ownership. - Sets
OverrideRedirecton the realized GTK window before its first map to prevent Weston's XWM from ever managing the WebKitGTK toplevel. - Ensures exceptions thrown on the GTK idle callback complete the waiting
TaskCompletionSourceinstead of leaving callers blocked indefinitely.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Uno.UI.Runtime.Skia.X11/Hosting/X11XamlRootHost.cs | Fixes X11 attribute-setting interop and adds a best-effort verification/warning after reparenting native subwindows. |
| src/AddIns/Uno.UI.WebView.Skia.X11/X11NativeWebView.cs | Prevents WM management by setting override-redirect before mapping and propagates GTK-thread exceptions back to callers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Use SetWindowValuemask.OverrideRedirect for XChangeWindowAttributes and GetAwaiter().GetResult() to rethrow original GTK-thread exceptions. Co-Authored-By: Claude Fable 5 <[email protected]>
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23736/wasm-skia-net9/index.html |
|
|
Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23736/wasm-skia-net9/index.html |
|
CI note: the |
|
|
…#23736, unoplatform#23844 Restores unoplatform#23736 (WSLg's XWM re-detaches subwindows without override-redirect set via XSetWindowAttributes, plus a best-effort post-reparent ownership check) and unoplatform#23844 (frame pacer created before the DPI read that spins up DisplayInformation; icon decoding offloaded per-icon instead of racing DisplayInformation creation off the UI thread). unoplatform#23895's Compositor.IsSoftwareRenderer line was already covered by the branch's own GraphicsContextKind-based assignment - the duplicate line from the merge was dropped. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XsQppKuZgijApgJxaTZt81
GitHub Issue: closes #23735, closes unoplatform/quadient-private#2
PR Type:
🐞 Bugfix
What changed? 🚀
On the X11 Skia target under WSLg (Weston/XWayland), a
WebView2was never displayed: the WebKitGTK window ended up held under Weston's XWM frame window instead of being embedded in the app's window.Two layered fixes:
X11XamlRootHost.AttachSubWindow: the code passed anXWindowAttributesbuffer toXChangeWindowAttributes, which expects the differently-laid-outXSetWindowAttributes. Theoverride_redirectvalue actually applied came from whatever bytes sat at offset 88 (map_installed) —1for plain default-colormap windows,0for GTK windows — so the intended override-redirect was never reliably set. Now a properly-constructedXSetWindowAttributesis passed (this also drops aMarshal.AllocHGlobaland anXGetWindowAttributesround-trip). A best-effort post-reparent check now logs a warning naming the window that kept the native element, instead of failing silently.X11NativeWebView: sets override-redirect on the GTK window right after realization, before it is first mapped, so the WM never starts managing it. This matters because once Weston's XWM manages a toplevel, reparenting it away is not reliably possible (it re-reparents the client under its own window even afterXWithdrawWindow); mainstream WMs (mutter/KWin) release the window, which is why this only broke under Weston/WSLg. Additionally,RunOnGtkThreadnow propagates exceptions from the GTK thread through theTaskCompletionSourceinstead of leaving the calling thread blocked forever.The MediaPlayer add-in needs no equivalent change: its X window stays unmapped until
AttachNativeElementreparents it (with the now-correct override-redirect) before mapping, so the WM never gets a chance to manage it.Validation (runtime, WSLg Ubuntu 24.04):
xwininfo -root -treeshows theUno WebViewwindow under the"Weston WM"window (10x10 at origin) → invisible.WebView2_Staticrenders web content, and keyboard input into an HTML<input>inside an embedded override-redirect WebKitGTK window was verified (typed text round-tripped via JavaScript).PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code