bzyr
bzyr

Reputation: 457

Enable fullscreen for floating window in macOS app

I set the app windows to floating, to keep them on top:

NSApplication.shared.windows.forEach { window in
    window.level = .floating
}

However, this disables the fullscreen mode:

Can these two behaviors (floating windows & fullscreen mode) be enabled in parallel? I have checked project settings and developer docs, but didn't find anything.

Upvotes: 0

Views: 1202

Answers (1)

bzyr
bzyr

Reputation: 457

I got it to work by setting collectionBehavior:

NSApplication.shared.windows.forEach { window in
    window.collectionBehavior = [.fullScreenPrimary]
    window.level = .floating
}

I found a similar SO question, they also set some properties (not the level) of the window, and fullscreen gets disabled.

So is it that if collectionBehavior is not specified for an NSWindow, then fullscreen is enabled as long as certain NSWindow properties (e.g. level) are not explicitly set?

Upvotes: 2

Related Questions