Repository navigation
fix: repaint dark-mode menubar after snap-to-side on Windows 11 - #5362
leaanthony wants to merge 2 commits into
Conversation
Snap-to-side on Windows 11 sends WM_SIZE with SIZE_RESTORED, not SIZE_MAXIMIZED. The force-redraw path (InvalidateRect + DrawMenuBar in MenuBarWndProc, RedrawWindow in WndProc) was gated on SIZE_MAXIMIZED only, so the dark menubar was not repainted after a side snap and became invisible. Extend both conditions to include SIZE_RESTORED. Fixes #4462 Co-Authored-By: Claude Sonnet 4.6 <[email protected]> Co-authored-by: multica-agent <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughTracks live resize sessions to suppress menubar redraws during interactive resizes, expands menubar redraw triggers on WM_SIZE to include SIZE_RESTORED, and updates the application window handler to skip redraw while resizing and only redraw the frame/menubar when appropriate. ChangesDark menubar redraw on window snap/restore
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.1)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" 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 |
There was a problem hiding this comment.
Pull request overview
Fixes a Windows 11 dark-mode menubar redraw issue where snap-to-side operations (Win+Left/Right or drag-to-edge) do not repaint the menubar because they dispatch WM_SIZE with SIZE_RESTORED rather than SIZE_MAXIMIZED.
Changes:
- Extend the menubar’s
WM_SIZEforce-redraw condition to includeSIZE_RESTORED. - Extend the window
WM_SIZEhandling to force a non-client frame redraw onSIZE_RESTORED(when a dark-mode menubar is present).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| v3/pkg/w32/menubar.go | Expands the menubar force-redraw trigger to also run on SIZE_RESTORED to cover snap-to-side. |
| v3/pkg/application/webview_window_windows.go | Forces a frame redraw on SIZE_RESTORED to ensure the dark menubar repaints after snapping/restoring. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Snap-to-side produces SIZE_RESTORED, not SIZE_MAXIMIZED; include both so the | ||
| // dark menubar is repainted after every snap or maximize operation. | ||
| if msg == WM_SIZE && (wParam == SIZE_MAXIMIZED || wParam == SIZE_RESTORED) { |
| // Snap-to-side sends SIZE_RESTORED; repaint the frame so the dark menubar | ||
| // is not left invisible after a snap operation. | ||
| if w.menu != nil && w.menubarTheme != nil { | ||
| w32.RedrawWindow(w.hwnd, nil, 0, w32.RDW_FRAME|w32.RDW_INVALIDATE|w32.RDW_UPDATENOW) |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
v3/pkg/w32/menubar.go (1)
564-574:⚠️ Potential issue | 🟡 Minor | ⚡ Quick win
DrawMenuBarnow fires on everySIZE_RESTORED, including continuous live-resize steps.
SIZE_RESTOREDis sent for snap transitions (the target case) but also for every step of a live resize drag. UnlikeSIZE_MAXIMIZED, which is a one-shot event, this path now callsDrawMenuBarat high frequency.paintDarkMenuBaralready runs unconditionally on everyWM_SIZE(line 562) and does more work (DC acquire → fill → release), so the incremental cost ofDrawMenuBarhere is moderate, but it may produce redundant menu redraws during drag-resize when a dark theme is active.Consider guarding the
DrawMenuBarcall to avoid the hot path during live resize, e.g. skip it while inside aWM_ENTERSIZEMOVE/WM_EXITSIZEMOVEwindow (a flag already used inWndProc).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@v3/pkg/w32/menubar.go` around lines 564 - 574, The DrawMenuBar call is currently invoked for WM_SIZE with SIZE_RESTORED (which also occurs during live-resize), causing redundant redraws; guard the DrawMenuBar invocation by checking the existing "in size-move" flag used in WndProc (the flag set/cleared on WM_ENTERSIZEMOVE/WM_EXITSIZEMOVE) and only call DrawMenuBar when not inside a size-move operation, leaving the paintDarkMenuBar behavior unchanged; locate the WM_SIZE handler that uses WM_SIZE, SIZE_RESTORED, SIZE_MAXIMIZED, DrawMenuBar, paintDarkMenuBar and modify it to skip DrawMenuBar while the WndProc resize flag indicates an active size-move.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@v3/pkg/application/webview_window_windows.go`:
- Around line 1609-1613: The synchronous RDW_UPDATENOW flag is causing redundant
blocking repaints during continuous SIZE_RESTORED (resize-drag); in the
SIZE_RESTORED branch where you call w32.RedrawWindow when w.menu != nil &&
w.menubarTheme != nil, remove RDW_UPDATENOW and leave only
RDW_FRAME|RDW_INVALIDATE so the repaint is queued asynchronously; keep the
earlier SIZE_MAXIMIZED path unchanged (it can retain RDW_UPDATENOW if desired),
and note that MenuBarWndProc/paintDarkMenuBar/DrawMenuBar already perform
non-client repaints so this change prevents double synchronous repaints.
---
Outside diff comments:
In `@v3/pkg/w32/menubar.go`:
- Around line 564-574: The DrawMenuBar call is currently invoked for WM_SIZE
with SIZE_RESTORED (which also occurs during live-resize), causing redundant
redraws; guard the DrawMenuBar invocation by checking the existing "in
size-move" flag used in WndProc (the flag set/cleared on
WM_ENTERSIZEMOVE/WM_EXITSIZEMOVE) and only call DrawMenuBar when not inside a
size-move operation, leaving the paintDarkMenuBar behavior unchanged; locate the
WM_SIZE handler that uses WM_SIZE, SIZE_RESTORED, SIZE_MAXIMIZED, DrawMenuBar,
paintDarkMenuBar and modify it to skip DrawMenuBar while the WndProc resize flag
indicates an active size-move.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 82b56126-2b80-4778-8a29-daea79caaa9d
📒 Files selected for processing (2)
v3/pkg/application/webview_window_windows.gov3/pkg/w32/menubar.go
|
Tested this PR on Windows 11 (clean VM snapshot, dark mode enabled via registry: Result: PASS -- dark menubar colour is preserved after window snap (Win+Left). Test procedure:
Observations:
The CC @leaanthony |
…from SIZE_RESTORED Addresses reviewer feedback on PR #5362: - menubar.go: track WM_ENTERSIZEMOVE/WM_EXITSIZEMOVE in a sync.Map; skip DrawMenuBar+InvalidateRect during live drag-resize so only snap/restore completions trigger the menubar repaint. - webview_window_windows.go: add inSizeMove bool to the window struct, set/clear it in WM_ENTERSIZEMOVE/WM_EXITSIZEMOVE, and guard the SIZE_RESTORED RedrawWindow call so it skips during live resize. Drop RDW_UPDATENOW from SIZE_RESTORED (async queued invalidation is sufficient; synchronous paint on every resize step caused flicker). Co-Authored-By: Claude Sonnet 4.6 <[email protected]> Co-authored-by: multica-agent <[email protected]>
|
Review issues addressed. Corrected commits are ready for this PR (SHA: Changes:
The CC @leaanthony Taliesin is an AI agent. CC @leaanthony |
…5362) (#5382) fix(v3/windows): replace WM_ENTERSIZEMOVE guard with state-change tracking Address reviewer feedback on #5362: - Replace inSizeMove bool + WM_ENTERSIZEMOVE/WM_EXITSIZEMOVE with a lastSizeWParam field that tracks WM_SIZE wParam transitions. This correctly handles keyboard snap (Win+Left/Right/Up) which bypasses WM_ENTERSIZEMOVE entirely. - Repaint fires only when the size STATE changes (SIZE_MAXIMIZED -> SIZE_RESTORED), not on every SIZE_RESTORED during live drag-resize. - Remove RDW_UPDATENOW from SIZE_RESTORED path; async invalidation (RDW_FRAME|RDW_INVALIDATE) is sufficient and avoids a synchronous non-client repaint on every resize step. - Apply the same lastSizeWParam approach in MenuBarTheme/MenuBarWndProc. Co-authored-by: multica-agent <[email protected]> Co-authored-by: Lea Anthony <[email protected]>
…s): address review issues in dark-mode menubar repaint (wailsapp#5362)
Summary
Win+Left/ drag to edge) sendsWM_SIZEwithwParam = SIZE_RESTORED, notSIZE_MAXIMIZEDMenuBarWndProc(InvalidateRect+DrawMenuBar) and inWndProc(RedrawWindow RDW_FRAME) was gated onSIZE_MAXIMIZEDonlyFix: extend both conditions to include
SIZE_RESTOREDso the menubar is force-redrawn after every snap or restore operation, not just after a full maximize.Files changed:
v3/pkg/w32/menubar.go—MenuBarWndProcWM_SIZE conditionv3/pkg/application/webview_window_windows.go—WndProcSIZE_RESTORED caseFixes #4462
Test plan
Win+Left/Win+Right)Win+Up) still works correctly (no regression)CC @leaanthony
🤖 Generated with Claude Code
Summary by CodeRabbit