I'm making a menu bar app that has a timer, and when a timer expires I wanna show a fullscreen popup / window that goes above all other windows, and stays on top even if the user changes desktop via the "three finger swipe" gesture for example.
This is my current code:
class ZbBreakWindowController: NSWindowController {
convenience init() {
guard let screenFrame = NSScreen.main?.frame else {
fatalError("Failed to obtain the main screen's frame")
}
let window = ZbBreakWindow(
contentRect: screenFrame,
styleMask: [.borderless],
backing: .buffered,
defer: false
)
window.collectionBehavior = [.fullScreenPrimary]
window.contentView = NSHostingView(rootView: ZbBreakWindowView())
window.level = .floating
window.center()
self.init(window: window)
}
}
struct ZbBreakWindowView: View {
var body: some View {
Text("It works!")
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
This has two issues right now:
- the window or content view height is not fullscreen, it's missing the menu bar height
- I can use the swipe gesture to change desktop and the window does not stay on top
How should I go about this? The window will have buttons to dismiss it of course, I'm just making a break timer kinda like (<https://breaktimer.app/#download>)