fix(macOS): Use visibleFrame for window centering to exclude menu bar - #4516
Conversation
The windowCenter() function was using [screen frame] which includes the menu bar and dock areas, causing windows to appear positioned too high on the screen when centered. This change uses [screen visibleFrame] instead, which excludes the menu bar and dock areas, resulting in proper visual centering. Fixes vertical centering issue on macOS in Wails v3 alpha.
WalkthroughmacOS window-centering now uses the screen's visibleFrame (excluding menu bar and dock) when calculating the centered window position; changelog updated with concrete entries. No exported APIs changed. Changes
Sequence Diagram(s)sequenceDiagram
participant App
participant Window
participant Screen
App->>Window: windowCenter()
Window->>Screen: get visibleFrame (usable area)
Screen-->>Window: visibleFrame
Window->>Window: compute centered rect using visibleFrame and window size
Window->>Window: setFrame(centeredRect)
Window-->>App: done
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
v3/pkg/application/webview_window_darwin.go (2)
320-333: Optional: Consider whether relative positioning should also use visibleFramewindowSetRelativePosition() still bases coordinates on [screen frame]. If the intended semantics are “relative to the usable area,” you may want to switch to visibleFrame here as well for consistency with centering. If “relative to the physical screen” is desired, keep as-is.
525-539: Sanity‐check window centering and unify frame usagePlease verify that
windowCenterbehaves correctly across:
- Dock positions (bottom/left/right) and “Automatically hide and show Dock”
- Primary vs. secondary monitors
- Very large windows (larger than the visible work area)
Also, we’ve spotted other manual centering logic still using the full screen frame (which includes the menu bar and dock) rather than the visible frame. Consider updating these to
[screen visibleFrame]for consistency:• v3/pkg/application/webview_window_darwin.go:326–330
• v3/pkg/application/webview_window_darwin.go:568–572
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
v3/pkg/application/webview_window_darwin.go(1 hunks)
⏰ 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). (1)
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
v3/pkg/application/webview_window_darwin.go (1)
532-538: Use visibleFrame for centering — LGTMThis correctly centers the window within the usable display area, excluding the menu bar and dock. Matches macOS conventions and resolves the “window too high” issue without impacting APIs. Safe for the 10.13 min target.
|
Thanks 🙏 Please could you add an entry to the changelog located at |
|
@leaanthony Just pushed the changelog commit! Thanks for reviewing :) |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
v3/UNRELEASED_CHANGELOG.md (1)
47-47: Fix markdownlint MD026: remove trailing punctuation from heading.Minor style polish.
Apply this diff:
-### Example Entries: +### Example entries
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
v3/UNRELEASED_CHANGELOG.md(2 hunks)
🧰 Additional context used
🪛 LanguageTool
v3/UNRELEASED_CHANGELOG.md
[grammar] ~22-~22: There might be a mistake here.
Context: ...reen is not fully visible (mostly due to dock or menu bar). ## Changed - Chang...
(QB_NEW_EN)
[grammar] ~26-~26: There might be a mistake here.
Context: ... NSRect screenFrame = [screen frame]; to - Changed the NSRect screenFrame = [screen...
(QB_NEW_EN)
🪛 markdownlint-cli2 (0.17.2)
v3/UNRELEASED_CHANGELOG.md
47-47: Trailing punctuation in heading
Punctuation: ':'
(MD026, no-trailing-punctuation)
🔇 Additional comments (4)
v3/UNRELEASED_CHANGELOG.md (4)
3-16: Header guidance block looks good.Clear instructions, Keep a Changelog link included. No action needed.
34-35: Deprecated: N/A is appropriate.No related deprecations for this change.
38-39: Removed: N/A is appropriate.No removals tied to this fix.
42-43: Security: N/A is appropriate.No security impact from this change.
| - Updated the configuration for detecting the screenFrame to use the | ||
| visibleFrame instead of the frame to handle cases where the screen is not | ||
| fully visible (mostly due to dock or menu bar). |
There was a problem hiding this comment.
Misclassified entry under “Added”; this is a behavioral fix. Move to “Fixed” and tighten wording.
This change corrects window centering on macOS; it’s not a new feature. Also, capitalize “Dock”.
Apply this diff to remove the entry from “Added”:
-- Updated the configuration for detecting the screenFrame to use the
- visibleFrame instead of the frame to handle cases where the screen is not
- fully visible (mostly due to dock or menu bar).Follow up by adding a single, scoped bullet under “Fixed” (see separate comment on Lines 30-31).
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - Updated the configuration for detecting the screenFrame to use the | |
| visibleFrame instead of the frame to handle cases where the screen is not | |
| fully visible (mostly due to dock or menu bar). |
🧰 Tools
🪛 LanguageTool
[grammar] ~22-~22: There might be a mistake here.
Context: ...reen is not fully visible (mostly due to dock or menu bar). ## Changed - Chang...
(QB_NEW_EN)
🤖 Prompt for AI Agents
In v3/UNRELEASED_CHANGELOG.md around lines 20-22, remove the current bullet
under "Added" that describes switching from frame to visibleFrame and then add a
single, scoped bullet under the "Fixed" section (around lines 30-31) that reads
concisely: "Fix window centering on macOS when parts of the screen are obscured
by the Dock or menu bar by using visibleFrame for screen detection." Ensure
"Dock" is capitalized and the wording frames this as a behavioral fix, not a new
feature.
| - Changed the NSRect screenFrame = [screen frame]; to | ||
| - Changed the NSRect screenFrame = [screen visibleFrame]; |
There was a problem hiding this comment.
Consolidate and de-duplicate the “Changed” bullets or remove them.
These two bullets read as an unfinished sentence split across two lines and duplicate the behavioral note that belongs under “Fixed”. Prefer a single “Fixed” entry; remove these.
Apply this diff to delete both lines:
-- Changed the NSRect screenFrame = [screen frame]; to
-- Changed the NSRect screenFrame = [screen visibleFrame];If you do want a “Changed” entry instead, replace both with one clear line (but avoid duplicating the “Fixed” section):
+- macOS: Use `[screen visibleFrame]` instead of `[screen frame]` when centering windows. (#4516)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - Changed the NSRect screenFrame = [screen frame]; to | |
| - Changed the NSRect screenFrame = [screen visibleFrame]; |
🧰 Tools
🪛 LanguageTool
[grammar] ~26-~26: There might be a mistake here.
Context: ... NSRect screenFrame = [screen frame]; to - Changed the NSRect screenFrame = [screen...
(QB_NEW_EN)
🤖 Prompt for AI Agents
In v3/UNRELEASED_CHANGELOG.md around lines 26-27, two "Changed" bullets
duplicate an unfinished sentence about NSRect screenFrame and should be removed
or consolidated; delete both lines as requested (removing the duplicate
"Changed" bullets entirely) or alternatively replace them with a single, clear
entry under the "Fixed" section that succinctly states the behavioral change
(e.g., switched from using [screen frame] to [screen visibleFrame]) without
duplicating existing notes.
|
|
||
| N/A |
There was a problem hiding this comment.
Add the macOS window-centering fix here; replace “N/A”.
Place the user-impactful note under “Fixed” with scope, file, and PR reference.
Apply this diff:
- N/A
+ - macOS: Center windows using `[screen visibleFrame]` instead of `[screen frame]` to exclude the menu bar and Dock in `Window.Center()` (v3/pkg/application/webview_window_darwin.go, #4516).📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| N/A | |
| - macOS: Center windows using `[screen visibleFrame]` instead of `[screen frame]` to exclude the menu bar and Dock in `Window.Center()` (v3/pkg/application/webview_window_darwin.go, #4516). |
🤖 Prompt for AI Agents
In v3/UNRELEASED_CHANGELOG.md around lines 30–31, replace the current "N/A"
entry with a user-facing "Fixed" bullet that documents the macOS
window-centering fix: add scope (e.g., "Desktop / macOS"), the affected
file/path, and the PR number in parentheses (e.g., "Fixed macOS window-centering
issue when opening new windows — Desktop / macOS: src/ui/window.ts (PR #1234)").
Ensure the entry is placed under the "Fixed" section and follows existing
changelog formatting and punctuation conventions.
leaanthony
left a comment
There was a problem hiding this comment.
Thanks. Could you please leave the comments in the template and move your changeling entry to "Changed"? Thank you!
Head branch was pushed to by a user without write access
done! (I think) 🙏 |
|
…wailsapp#4516) * fix(macOS): Use visibleFrame for window centering to exclude menu bar The windowCenter() function was using [screen frame] which includes the menu bar and dock areas, causing windows to appear positioned too high on the screen when centered. This change uses [screen visibleFrame] instead, which excludes the menu bar and dock areas, resulting in proper visual centering. Fixes vertical centering issue on macOS in Wails v3 alpha. * Update v3/UNRELEASED_CHANGELOG.md * Update changelog entry format --------- Co-authored-by: Atterpac <89053530+atterpac@users.noreply.github.com> Co-authored-by: Lea Anthony <lea.anthony@gmail.com>



Summary
Fixes the vertical window centering issue on macOS in Wails v3 alpha where windows appear positioned too high on the screen.
Problem
The
windowCenter()function inwebview_window_darwin.gowas using[screen frame]which includes the menu bar and dock areas when calculating the center position. This caused windows to be positioned including the menu bar area, making them appear visually off-center (too high) on the screen.Solution
Changed line 532 from:
To:
The
visibleFramemethod returns the screen area excluding the menu bar and dock, which results in proper visual centering.Testing
This fix has been tested locally and resolves the vertical centering issue. Windows now appear properly centered both horizontally and vertically on macOS.
Technical Details
v3/pkg/application/webview_window_darwin.goWindow.Center()methodFixes vertical centering on macOS for Wails v3 alpha applications.
Summary by CodeRabbit
Bug Fixes
Documentation