fix: enable fullscreen support for all titleBarStyle options#358
Open
raymondreaming wants to merge 1 commit intoblackboardsh:mainfrom
Open
fix: enable fullscreen support for all titleBarStyle options#358raymondreaming wants to merge 1 commit intoblackboardsh:mainfrom
raymondreaming wants to merge 1 commit intoblackboardsh:mainfrom
Conversation
setFullScreen() silently fails when titleBarStyle is "hidden" because createNSWindowWithFrameAndStyle never sets collectionBehavior on the window. macOS requires NSWindowCollectionBehaviorFullScreenPrimary for toggleFullScreen: to work — without it, the call is silently ignored. Add setCollectionBehavior with fullScreenPrimary after window creation so setFullScreen() works regardless of titleBarStyle. Fixes: setFullScreen() no-op with titleBarStyle "hidden"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
BrowserWindow.setFullScreen(true)silently fails whentitleBarStyleis"hidden". The call completes without error, but the window does not enter fullscreen andisFullScreen()returnsfalse.This prevents apps using custom window chrome from offering native macOS fullscreen.
Root Cause
Traced through
package/src/native/macos/nativeWrapper.mm. Three factors combine:1.
createNSWindowWithFrameAndStylenever setscollectionBehaviorThe window is allocated with
initWithContentRect:styleMask:backing:defer:screen:butsetCollectionBehavior:is never called. macOS requiresNSWindowCollectionBehaviorFullScreenPrimaryfor[window toggleFullScreen:nil]to be honored. Without it, AppKit silently drops the call.2.
titleBarStyle: "hidden"removesNSWindowStyleMaskTitledBrowserWindow.tsmaps"hidden"toTitled: false, FullSizeContentView: true. Untitled windows cannot enter fullscreen without explicitcollectionBehaviorconfiguration.3.
setWindowFullScreenlogic is correct but ineffectiveThe state check and toggle logic are correct. The call is simply ignored at the AppKit level because the window lacks the required collection behavior.
Approaches Investigated
setFullScreen(true)withtitleBarStyle: "hidden"styleMask: { FullScreen: true }at creationNSWindowStyleMaskFullScreen(bit 14) is a read-only state flag, not a configuration option. Setting it at creation produces a corrupted window state with a gray title bar remnant.role: "toggleFullScreen"toggleFullScreen:is ignored regardless of invocation method.titleBarStyle: "hiddenInset"Titled, which allows fullscreen. Serves as a viable workaround but forces native traffic light visibility.Fix
Set
collectionBehaviorafter window allocation increateNSWindowWithFrameAndStyle:[window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary | NSWindowCollectionBehaviorMoveToActiveSpace];Applied at creation time rather than lazily in
setWindowFullScreenso behavior is consistent across all fullscreen triggers (programmatic API, application menu, native window button).No API changes. No new configuration. Enables fullscreen for all
titleBarStylevalues.Verification
Tested on macOS Sequoia (Darwin 25.3.0, arm64), Electrobun v1.16.0:
"hidden"+setFullScreen(true)"hidden"+setFullScreen(false)"hidden"+isFullScreen()false"hiddenInset""default"