From 639434df3344261c861cb78e4c52049b8b8127c1 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 30 Sep 2024 15:01:36 -0700 Subject: [PATCH] macos: exit native fullscreen if we try to enter non-native --- macos/Sources/Helpers/Fullscreen.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/macos/Sources/Helpers/Fullscreen.swift b/macos/Sources/Helpers/Fullscreen.swift index f591915ec..b6aaa0052 100644 --- a/macos/Sources/Helpers/Fullscreen.swift +++ b/macos/Sources/Helpers/Fullscreen.swift @@ -121,6 +121,15 @@ class NonNativeFullscreen: FullscreenStyle { // If we are in fullscreen we don't do it again. guard !isFullscreen else { return } + // If we are in native fullscreen, exit native fullscreen. This is counter + // intuitive but if we entered native fullscreen (through the green max button + // or an external event) and we press the fullscreen keybind, we probably + // want to EXIT fullscreen. + if window.styleMask.contains(.fullScreen) { + window.toggleFullScreen(nil) + return + } + // This is the screen that we're going to go fullscreen on. We use the // screen the window is currently on. guard let screen = window.screen else { return }