Add config setting to turn non-native fullscreen on or off

This commit is contained in:
Thorsten Ball
2023-07-29 21:05:49 +02:00
committed by Mitchell Hashimoto
parent 850bf3e945
commit b56ffa6285
9 changed files with 45 additions and 14 deletions

View File

@@ -7,12 +7,27 @@ class FullScreenHandler {
var previousStyleMask: NSWindow.StyleMask?
var isInFullscreen: Bool = false
func toggleFullscreen(window: NSWindow) {
// We keep track of whether we entered non-native fullscreen in case
// a user goes to fullscreen, changes the config to disable non-native fullscreen
// and then wants to toggle it off
var isInNonNativeFullscreen: Bool = false
func toggleFullscreen(window: NSWindow, nonNativeFullscreen: Bool) {
if isInFullscreen {
leaveFullscreen(window: window)
if nonNativeFullscreen || isInNonNativeFullscreen {
leaveFullscreen(window: window)
isInNonNativeFullscreen = false
} else {
window.toggleFullScreen(nil)
}
isInFullscreen = false
} else {
enterFullscreen(window: window)
if nonNativeFullscreen {
enterFullscreen(window: window)
isInNonNativeFullscreen = true
} else {
window.toggleFullScreen(nil)
}
isInFullscreen = true
}
}