Skip to content

fix(v3/windows): address review issues in dark-mode menubar repaint (#5362)#5382

Merged
leaanthony merged 2 commits intowailsapp:masterfrom
taliesin-ai:agent/engineer-windows/567a2d0d
May 10, 2026
Merged

fix(v3/windows): address review issues in dark-mode menubar repaint (#5362)#5382
leaanthony merged 2 commits intowailsapp:masterfrom
taliesin-ai:agent/engineer-windows/567a2d0d

Conversation

@taliesin-ai
Copy link
Copy Markdown
Collaborator

@taliesin-ai taliesin-ai commented May 9, 2026

Addresses reviewer feedback on #5362.

Problem

The original guard used WM_ENTERSIZEMOVE/WM_EXITSIZEMOVE to suppress InvalidateRect/DrawMenuBar during live drag-resize, but keyboard snap (Win+Left/Right/Up) bypasses those messages entirely -- the menubar was not repainting after a keyboard snap-restore sequence.

Fix

Replaced the inSizeMove bool flag with a lastSizeWParam state-change tracker in both windowsWebviewWindow and MenuBarTheme:

  • Repaint fires only when the size state changes (e.g. SIZE_MAXIMIZED -> SIZE_RESTORED), not on every SIZE_RESTORED event during live drag-resize
  • Removed RDW_UPDATENOW from the SIZE_RESTORED path -- async invalidation (RDW_FRAME|RDW_INVALIDATE) is sufficient and avoids a synchronous non-client repaint on every resize step
  • The WM_ENTERSIZEMOVE/WM_EXITSIZEMOVE handlers are removed; the state-change approach handles both mouse drag and keyboard snap uniformly

Files changed

  • v3/pkg/application/webview_window_windows.go -- replace inSizeMove with lastSizeWParam; gate SIZE_RESTORED repaint on previous state being SIZE_MAXIMIZED; drop RDW_UPDATENOW
  • v3/pkg/w32/menubar.go -- add lastSizeWParam to MenuBarTheme; gate InvalidateRect/DrawMenuBar on wParam state change

Closes #5362

CC @leaanthony

Summary by CodeRabbit

  • Bug Fixes
    • Improved menubar rendering on Windows to avoid unnecessary full-window redraws when maximizing.
    • Menubar now repaints only on actual maximize/restore transitions, reducing flicker and improving performance.
    • Dark menubar theme is correctly repainted when leaving maximized state.

Review Change Stack

Review Change Stack

…cking

Address reviewer feedback on wailsapp#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 <github@multica.ai>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 9, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 874d84bc-b314-4140-93ea-b5dfba76eadb

📥 Commits

Reviewing files that changed from the base of the PR and between 8fa1606 and 220ce63.

📒 Files selected for processing (1)
  • v3/pkg/application/webview_window_windows.go

Walkthrough

Tracks the previous WM_SIZE wParam in both MenuBarTheme and windowsWebviewWindow and changes WM_SIZE handling so menubar redraws occur only when wParam transitions between SIZE_MAXIMIZED and SIZE_RESTORED; lastSizeWParam is updated after each WM_SIZE handling.

Changes

Windows Menubar Resize-Transition Gating

Layer / File(s) Summary
State Tracking Fields
v3/pkg/w32/menubar.go, v3/pkg/application/webview_window_windows.go
MenuBarTheme and windowsWebviewWindow each gain a lastSizeWParam field to remember the previous WM_SIZE wParam.
Resize Transition Logic
v3/pkg/w32/menubar.go, v3/pkg/application/webview_window_windows.go
WM_SIZE handling now triggers menubar redraw only when wParam changes to SIZE_MAXIMIZED or SIZE_RESTORED (transition gating). The webview SIZE_MAXIMIZED path no longer forces a full RDW_UPDATENOW redraw; SIZE_RESTORED now repaints the dark menubar only when leaving SIZE_MAXIMIZED. lastSizeWParam is updated after the check.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • wailsapp/wails#4478: Modifies WM_SIZE handling in windowsWebviewWindow with related state transition and resize/maximize/restore logic changes.

Suggested labels

Bug, Windows, v3, size:M

Suggested reviewers

  • leaanthony

Poem

🐰 A window snaps and settles wide,

The menubar wakes from darkened hide.
I track the sizes, one then two,
Redraw just when the state is new.
Hooray — no flicker, joy renewed!

🚥 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 concisely describes the main change: addressing review issues in the dark-mode menubar repaint logic with a state-change tracker approach.
Description check ✅ Passed The PR description includes a clear problem statement, the fix explanation, files changed, and issue reference, but the author did not complete the checklist sections from the template.
Linked Issues check ✅ Passed The PR implements the core fix from #5362: using a state-change tracker (lastSizeWParam) instead of event-based guards to handle both mouse drag and keyboard snap uniformly, ensuring menubar repaints correctly after snap-to-side and restore operations.
Out of Scope Changes check ✅ Passed All changes are focused on fixing the menubar repaint issue via the state-change tracker approach; no unrelated modifications were introduced.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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"

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
v3/pkg/w32/menubar.go (1)

188-207: 💤 Low value

Per-window state inside a theme struct.

lastSizeWParam is per-window run-time state, but MenuBarTheme is otherwise pure styling/brush data. In the current code each window builds its own MenuBarTheme, so this works, but the type’s shape no longer prevents two windows from sharing a single *MenuBarTheme. If they did, snap/restore transitions on one window would corrupt the transition gate on the other (both write to the same lastSizeWParam).

Since windowsWebviewWindow already tracks the same value (w.lastSizeWParam in webview_window_windows.go), one option is to drop the theme-side copy and pass the previous wParam in (or read it from the window) — keeping MenuBarTheme purely about appearance.

🤖 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 188 - 207, MenuBarTheme currently
contains runtime per-window state (lastSizeWParam) which can cause shared-theme
corruption; remove the lastSizeWParam field from the MenuBarTheme struct and
update all callers that used MenuBarTheme.lastSizeWParam to instead read the
previous wParam from the window instance (windowsWebviewWindow.w.lastSizeWParam)
or accept it as an explicit parameter; search for uses of
MenuBarTheme.lastSizeWParam and refactor the relevant functions/methods to take
a previousWPARAM argument or access the windowsWebviewWindow state so
MenuBarTheme remains purely styling/brush data.
🤖 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.

Nitpick comments:
In `@v3/pkg/w32/menubar.go`:
- Around line 188-207: MenuBarTheme currently contains runtime per-window state
(lastSizeWParam) which can cause shared-theme corruption; remove the
lastSizeWParam field from the MenuBarTheme struct and update all callers that
used MenuBarTheme.lastSizeWParam to instead read the previous wParam from the
window instance (windowsWebviewWindow.w.lastSizeWParam) or accept it as an
explicit parameter; search for uses of MenuBarTheme.lastSizeWParam and refactor
the relevant functions/methods to take a previousWPARAM argument or access the
windowsWebviewWindow state so MenuBarTheme remains purely styling/brush data.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0d41ce74-b277-4d87-88fb-67a929e9a3bb

📥 Commits

Reviewing files that changed from the base of the PR and between af4669e and 8fa1606.

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

@leaanthony leaanthony enabled auto-merge (squash) May 10, 2026 02:34
@leaanthony leaanthony merged commit 11d7be5 into wailsapp:master May 10, 2026
33 of 35 checks passed
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants