[V3] Fix Window Affinity weirdness - #4600
Conversation
WalkthroughReplaces a Wayland changelog entry with a Windows fix entry and implements stateful Windows content-protection handling: tracks whether protection is applied, defers applying SetWindowDisplayAffinity until the window is visible, exposes applyDisplayAffinity wrapper with logging, and updates protection on show() and WM_SHOWWINDOW. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor App
participant WW as WindowsWebviewWindow
participant Wnd as WndProc
participant CP as updateContentProtection()
participant SDA as applyDisplayAffinity()
participant OS as Windows API
App->>WW: show()
WW->>WW: mark shown/requested
WW->>CP: updateContentProtection()
CP->>CP: ensure hwnd!=0 && visible?
alt Visible
CP->>SDA: applyDisplayAffinity(ON/OFF)
SDA->>OS: SetWindowDisplayAffinity(affinity)
OS-->>SDA: success/failure
SDA-->>CP: success bool
CP->>WW: set contentProtectionApplied
else Not visible
CP-->>WW: defer (do not change affinity)
end
Note over Wnd,CP: runtime show event
OS-->>Wnd: WM_SHOWWINDOW (shown)
Wnd->>CP: updateContentProtection()
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Related Documentation Checked 1 published document(s). No updates required. You have 2 draft document(s). Publish docs to keep them always up-to-date |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
v3/pkg/application/webview_window_windows.go (1)
2455-2477: UsecontentProtectionAppliedto short-circuit redundant affinity updates.Right now we call
SetWindowDisplayAffinityon everyshow()and everyWM_SHOWWINDOW, even if we already have the correct state. That’s unnecessary work and can emit duplicate warnings when the native call fails. Since we’re now tracking the applied state, we can bail out early once the desired and applied states match.Apply this tweak inside
updateContentProtection():func (w *windowsWebviewWindow) updateContentProtection() { if w.hwnd == 0 { return } if !w.isVisible() { // Defer updates until the window is visible to avoid affinity glitches. return } desired := w.parent.options.ContentProtectionEnabled + + if desired == w.contentProtectionApplied { + return + } if desired { if w.applyDisplayAffinity(w32.WDA_EXCLUDEFROMCAPTURE) { w.contentProtectionApplied = true } return
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
v3/UNRELEASED_CHANGELOG.md(1 hunks)v3/pkg/application/webview_window_windows.go(4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
v3/pkg/application/webview_window_windows.go (1)
v3/pkg/w32/wda.go (3)
WDA_EXCLUDEFROMCAPTURE(8-8)WDA_NONE(6-6)SetWindowDisplayAffinity(11-21)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Run Go Tests v3 (windows-latest, 1.24)
- GitHub Check: Run Go Tests v3 (macos-latest, 1.24)
- GitHub Check: Run Go Tests v3 (ubuntu-latest, 1.24)
🔇 Additional comments (3)
v3/UNRELEASED_CHANGELOG.md (1)
24-26: Changelog entry LGTM.Thanks for documenting the Windows startup flicker fix so clearly.
v3/pkg/application/webview_window_windows.go (2)
1093-1096: Good call reapplying after showing.Triggering the affinity update immediately after
ShowWindowensures the window is already visible before we touch display affinity, which is exactly what the flicker fix needs.
1438-1442: WM_SHOWWINDOW hook makes sense.Catching the show message guarantees that any external visibility changes re-run the content-protection sync, so the native state can’t drift.
|
Semgrep found 1 Risk: Affected versions of rollup are vulnerable to Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'). Manual Review Advice: A vulnerability from this advisory is reachable if you use Rollup to bundle JavaScript with Fix: Upgrade this library to at least version 3.29.5 at wails/v3/examples/dev/frontend/package-lock.json:569. Reference(s): GHSA-gcx4-mw62-g8wm, CVE-2024-47068 |
|
* Fix window affinity weirdness * Update changelog



Description
Fixes multiple issues introduced from the Content protection PR.
Fixes #4574 & #4498
Type of change
Please select the option that is relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration using
wails doctor.If you checked Linux, please specify the distro and version.
Test Configuration
Please paste the output of
wails doctor. If you are unable to run this command, please describe your environment in as much detail as possible.Checklist:
website/src/pages/changelog.mdxwith details of this PRSummary by CodeRabbit
Bug Fixes
Documentation