fix: use NULL class brush for transparent WebView2 windows#447
Conversation
The opaque dark class background brush (#020617) showed through where WebView2 had not yet painted, defeating transparent=True windows. Add set_window_class_null_background using the NULL stock brush and thread a `transparent` flag through fix_webview2_child_windows so transparent windows skip the opaque brush on both the top-level and child windows. Signed-off-by: wojzj57 <wojzj57@gmail.com>
rustfmt --check flagged the after_null binding in set_window_class_null_vs_dark_background; fits the width limit on one line. Signed-off-by: wojzj57 <wojzj57@gmail.com>
The NULL-brush transparency fix (a625b27) added four Win32 GDI unsafe blocks (one in set_window_class_null_background, three in its regression test) without updating the allowlist count, so audit_unsafe.py failed on the 27 vs 31 mismatch. All four fall under the existing GDI brush lifecycle rationale. Signed-off-by: wojzj57 <wojzj57@gmail.com>
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #447 +/- ##
==========================================
+ Coverage 49.11% 49.15% +0.04%
==========================================
Files 119 119
Lines 13388 13389 +1
Branches 24 24
==========================================
+ Hits 6576 6582 +6
+ Misses 6812 6807 -5
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
Capture `handler` as a default arg (`fn=handler`) so each lambda registered in the loop uses its own value instead of the late-bound loop variable (ruff B023). Also apply ruff import sorting and a line-length wrap surfaced by the same lint pass. Signed-off-by: wojzj57 <wojzj57@gmail.com>
Export set_window_class_null_background in crates/auroraview-core/src/builder/mod.rs to prevent a dead code warning on non-Windows platforms where its only caller is stubbed out. Signed-off-by: wojzj57 <wojzj57@gmail.com>
Fixes stale dep update PRs failing CLI Build (Windows) due to the 15-minute timeout.
Rewrap the window_style re-export so each line stays within rustfmt's width limit, fixing the cargo fmt --check failure on the import block. Signed-off-by: wojzj57 <wojzj57@gmail.com>
2bc560b to
db0045d
Compare
Summary
Transparent windows (
transparent=True) showed a solid#020617background instead of the desktop. The opaque dark class background brush — added to hide white edges before WebView2 paints — bled through wherever WebView2 hadn't yet composited, defeating transparency. Use theNULLstock brush on transparent windows so nothing is painted under the WebView2 content. Fixes #445.1 commit · 6 files · no breaking public API change (Python arg is optional, defaults to
False).Key changes
crates/auroraview-core/src/builder/window_style.rs— transparent brush pathset_window_class_null_background()settingGCLP_HBRBACKGROUNDto theNULL_BRUSHstock object so the background paints nothing.transparent: boolparam throughfix_webview2_child_windows(); transparent windows get the NULL brush, opaque ones keep the dark solid brush.src/webview/backend/native.rs,src/webview/desktop/mod.rs— call sitesconfig.transparentinto the child-window fixer.set_window_class_dark_background()entirely whentransparentis set, on both the top-level and Qt-child code paths.src/window_utils.rs,python/.../qt/embedding.py— Python bindingtransparent=Falsearg to thefix_webview2_child_windowspyfunction.self._webview._transparentand forwards it.Type
Breaking changes
None. The new
transparentparameter is optional and defaults toFalse, preserving existing behavior.Validation
cargo test -p auroraview-core— new regression testset_window_class_null_vs_dark_backgroundasserts the transparent path setsNULL_BRUSHand the opaque path keeps a non-NULL brush.cargo fmt --all·cargo clippy --all-targets -- -D warningstransparent=Truewindow now shows the desktop through unpainted regions instead of#020617.