Skip to content

fix: keep macOS status bar visible when switching Spaces - #30

Open
jcbl1 wants to merge 3 commits into
GUI-for-Cores:mainfrom
jcbl1:fix/macos-statusbar-space-switch
Open

jcbl1 wants to merge 3 commits into
GUI-for-Cores:mainfrom
jcbl1:fix/macos-statusbar-space-switch

Conversation

@jcbl1

@jcbl1 jcbl1 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Problem

On macOS, the app runs as a tray-resident agent. After the main window is shown, switching to another desktop (Space) and back makes the entire system top menu bar / status bar (Apple menu, clock, battery, etc.) disappear, leaving blank space until the app loses focus.

Root cause

  • The app runs as an ActivationPolicy.Accessory agent (LSUIElement=true): no Dock icon, no menu bar.
  • The main window is a normal focusable window. When it lives on a Space that is switched away and back, macOS tries to draw a menu bar for the frontmost app. Since the app is accessory and has no menu bar, WindowServer fails to render it, and the whole status bar goes blank until another app is clicked.
  • This is a systemic issue for LSUIElement/accessory apps + normal windows (same origin as Apple Feedback FB13544993).

Fix

Keep the app's activation policy consistent with main-window visibility, so the app is .regular whenever its window is shown:

Event ActivationPolicy
Show main window (ShowMainWindow / tray Show / Cmd+S / second-instance launch) .regular
Hide main window (HideMainWindow / Cmd+H / close button) .accessory (back to tray-resident)
Startup .regular or .accessory depending on StartHidden
  • The fix follows the same approach used by DockDoor.
  • As a side benefit, the app now also appears in and can be switched to via Cmd+Tab while its main window is visible.

Known tradeoff

A Dock icon is visible while the main window is shown and disappears when the window is hidden to the tray. So if it was a designed behaviour, this fix may not be proper.

jcbl1 added 2 commits August 12, 2026 07:41
Toggle NSApp activation policy based on main window visibility so the
app draws a proper menu bar while its window is shown, preventing the
system status bar from disappearing after switching between Spaces in
an LSUIElement (accessory) app. Show/hide now switches between .regular
and .accessory on macOS.
@jcbl1
jcbl1 marked this pull request as ready for review August 12, 2026 08:06
@jcbl1
jcbl1 marked this pull request as draft August 12, 2026 13:04
@jcbl1

jcbl1 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Converted to draft as there are still some issue on Windows due to this fix.

@jcbl1
jcbl1 marked this pull request as ready for review August 13, 2026 01:53
@jcbl1

jcbl1 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Actually the fix has no effect on other OSs except extra emty bundles.

Meanwhile I found that in workflow config release.yml, there is an explicit command making the app . accessory, which was introduced in commit aa432e7 with message ci: Hide the Dock icon on macOS.. So it may be intentional to hide the Dock icon, which is reasonable as this app is a VPN app. However, the fix by this PR kind of respect the idea as it only shows Dock icon when the main window's open and thus introduces benefits such as Cmd+Tab switch when apps open and Cmd+W to close the main window. The Dock icon will disappear after closing/hiding the main window (yeah it's gone from the Dock), leaving an icon only on the menu bar.

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.

1 participant