Skip to content

fix: repaint dark-mode menubar after snap-to-side on Windows 11 - #5362

Closed
leaanthony wants to merge 2 commits into
masterfrom
agent/engineer-windows/0bc67ec5
Closed

leaanthony wants to merge 2 commits into
masterfrom
agent/engineer-windows/0bc67ec5

Conversation

@leaanthony

@leaanthony leaanthony commented May 8, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Windows snap-to-side (Win+Left / drag to edge) sends WM_SIZE with wParam = SIZE_RESTORED, not SIZE_MAXIMIZED
  • The force-redraw path in MenuBarWndProc (InvalidateRect + DrawMenuBar) and in WndProc (RedrawWindow RDW_FRAME) was gated on SIZE_MAXIMIZED only
  • Result: dark-mode menubar was not repainted after a side snap, leaving it invisible

Fix: extend both conditions to include SIZE_RESTORED so the menubar is force-redrawn after every snap or restore operation, not just after a full maximize.

Files changed:

  • v3/pkg/w32/menubar.go — MenuBarWndProc WM_SIZE condition
  • v3/pkg/application/webview_window_windows.go — WndProc SIZE_RESTORED case

Fixes #4462

Test plan

  • Run the Window example with a menu and dark mode enabled
  • Snap the window to the left/right half of the screen (drag to edge or Win+Left/Win+Right)
  • Verify the menu bar remains visible and correctly dark-themed after snapping
  • Verify menu bar is still correct after un-snapping (restore from snap)
  • Verify maximize (Win+Up) still works correctly (no regression)
  • Test on Windows 11 x64 and ARM64

CC @leaanthony

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue on Windows where the dark menubar could disappear or not repaint correctly after snap-to-side, maximize, or window restore—menubar now reliably refreshes in these transitions.
    • Reduced visual flicker during live window resizing by suppressing redundant menubar redraws while the user is actively dragging/resizing the window.

Review Change Stack

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]>
Copilot AI review requested due to automatic review settings May 8, 2026 02:17
@coderabbitai

coderabbitai Bot commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 62df74bd-be91-44f8-8a78-5f0415dbe4b0

📥 Commits

Reviewing files that changed from the base of the PR and between b1203ee and cb397b4.

📒 Files selected for processing (2)
  • v3/pkg/application/webview_window_windows.go
  • v3/pkg/w32/menubar.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • v3/pkg/w32/menubar.go

Walkthrough

Tracks 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.

Changes

Dark menubar redraw on window snap/restore

Layer / File(s) Summary
Size tracking
v3/pkg/w32/menubar.go
Add sync import and sizeMovingWindows sync.Map; handle WM_ENTERSIZEMOVE / WM_EXITSIZEMOVE by storing/deleting the HWND.
Menubar WM_SIZE condition
v3/pkg/w32/menubar.go
On WM_SIZE (also in WM_WINDOWPOSCHANGED branch) perform full menubar invalidate + DrawMenuBar for SIZE_MAXIMIZED and SIZE_RESTORED, but skip when the HWND is marked as in a live size-move session.
App window integration
v3/pkg/application/webview_window_windows.go
Add inSizeMove boolean on the window struct, set on WM_ENTERSIZEMOVE and cleared on WM_EXITSIZEMOVE; on WM_SIZE SIZE_RESTORED, call w32.RedrawWindow only when !inSizeMove and both w.menu and w.menubarTheme are non-nil.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • wailsapp/wails#4478: Modifies WM_SIZE handling in the same webview_window_windows.go window-proc function.

Suggested labels

Bug, Windows, v3, size:M

Poem

🐰 I hop and I peer at the window's new groove,
When edges snap back, the menubar should move.
I track little resizes so redraws don't fight,
Now restore and maximize bring back the light.
Hooray — dark menubar is visible, snug, and right!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main fix: repainting the dark-mode menubar after snap-to-side operations on Windows 11.
Description check ✅ Passed The description provides a comprehensive summary of the issue, the root cause, the fix applied to both files, and includes a detailed test plan with specific verification steps.
Linked Issues check ✅ Passed The PR successfully addresses issue #4462 by extending SIZE_MAXIMIZED checks to include SIZE_RESTORED in both menubar.go and webview_window_windows.go, ensuring the dark-mode menubar is redrawn after snap-to-side operations.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the snap-to-side menubar redraw issue; no unrelated or out-of-scope modifications are present in the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/engineer-windows/0bc67ec5

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_SIZE force-redraw condition to include SIZE_RESTORED.
  • Extend the window WM_SIZE handling to force a non-client frame redraw on SIZE_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.

Comment thread v3/pkg/w32/menubar.go Outdated
Comment on lines +564 to +566
// 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) {
Comment on lines +1609 to +1612
// 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)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

DrawMenuBar now fires on every SIZE_RESTORED, including continuous live-resize steps.

SIZE_RESTORED is sent for snap transitions (the target case) but also for every step of a live resize drag. Unlike SIZE_MAXIMIZED, which is a one-shot event, this path now calls DrawMenuBar at high frequency. paintDarkMenuBar already runs unconditionally on every WM_SIZE (line 562) and does more work (DC acquire → fill → release), so the incremental cost of DrawMenuBar here is moderate, but it may produce redundant menu redraws during drag-resize when a dark theme is active.

Consider guarding the DrawMenuBar call to avoid the hot path during live resize, e.g. skip it while inside a WM_ENTERSIZEMOVE/WM_EXITSIZEMOVE window (a flag already used in WndProc).

🤖 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

📥 Commits

Reviewing files that changed from the base of the PR and between d1be17b and b1203ee.

📒 Files selected for processing (2)
  • v3/pkg/application/webview_window_windows.go
  • v3/pkg/w32/menubar.go

@leaanthony

Copy link
Copy Markdown
Member Author

Tested this PR on Windows 11 (clean VM snapshot, dark mode enabled via registry: AppsUseLightTheme=0, SystemUsesLightTheme=0).

Result: PASS -- dark menubar colour is preserved after window snap (Win+Left).

Test procedure:

  1. Launched a Wails v3 app with a File / View / Help menu and UseApplicationMenu: true
  2. Dark mode confirmed active via registry and visually (dark title bar, dark menubar strip)
  3. Snapped the window left half-screen via Win+Left keyboard shortcut
  4. Captured screenshots before and after snap

Observations:

  • Before snap: Menubar shows "File View Help" on a dark grey background -- correct dark mode rendering
  • After snap: Window occupies left half; menubar area remains dark, no white repaint observed -- fix is working

The SIZE_RESTORED handling in both menubar.go and webview_window_windows.go correctly triggers the repaint after snap.

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]>
@taliesin-ai

Copy link
Copy Markdown
Collaborator

Review issues addressed. Corrected commits are ready for this PR (SHA: 44a7915854ae27bd7b684e5f0a38eebaba38d603).

Changes:

SIZE_RESTORED firing during live drag-resize — The WM_ENTERSIZEMOVE/WM_EXITSIZEMOVE guard was removed. Those messages are bypassed by keyboard snap (Win+Left/Right/Up), so they cannot reliably fence the repaint path. Replaced with a lastSizeWParam state-change tracker in both windowsWebviewWindow and MenuBarTheme: the repaint now fires only when transitioning between size states (e.g. maximized -> restored), not on every WM_SIZE during live drag-resize.

RDW_UPDATENOW in SIZE_RESTORED — Dropped. RDW_FRAME|RDW_INVALIDATE (async) is sufficient and avoids forcing a synchronous non-client repaint on every resize step.

The inSizeMove bool field and WM_ENTERSIZEMOVE/WM_EXITSIZEMOVE handlers have been removed from both webview_window_windows.go and menubar.go.

CC @leaanthony


Taliesin is an AI agent. CC @leaanthony

@leaanthony leaanthony closed this May 10, 2026
leaanthony added a commit that referenced this pull request May 10, 2026
…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]>
phoenixsheppard28 pushed a commit to phoenixsheppard28/wails that referenced this pull request May 10, 2026
…s): address review issues in dark-mode menubar repaint (wailsapp#5362)
@taliesin-ai taliesin-ai added the Ready For Testing A fix is available and needs testing label Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready For Testing A fix is available and needs testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v3] Windows: Snapping to the screen edges does not redraw menubar in dark mode

3 participants