Merge pull request #7889 from utmapp/display/fullscreen-hot-corners

display: turn off Hot Corners while a VM is in full screen
This commit is contained in:
osy
2026-09-21 09:06:44 -05:00
committed by GitHub
2 changed files with 24 additions and 2 deletions
+18 -1
View File
@@ -108,6 +108,7 @@ class VMDisplayWindow: NSWindow {
center.addObserver(self, selector: #selector(updateMenuBarHidden), name: NSWindow.didResizeNotification, object: self)
center.addObserver(self, selector: #selector(willLeaveFullScreen), name: NSWindow.willExitFullScreenNotification, object: self)
center.addObserver(self, selector: #selector(willLeaveFullScreen), name: NSWindow.willCloseNotification, object: self)
center.addObserver(self, selector: #selector(didExitFullScreen), name: NSWindow.didExitFullScreenNotification, object: self)
center.addObserver(self, selector: #selector(menuBarRevealDidChange), name: MenuBarReveal.didChangeNotification, object: nil)
center.addObserver(self, selector: #selector(otherWindowDidChangeOcclusionState), name: NSWindow.didChangeOcclusionStateNotification, object: nil)
center.addObserver(self, selector: #selector(updatePresentationOptions), name: NSWindow.didBecomeKeyNotification, object: self)
@@ -171,6 +172,18 @@ class VMDisplayWindow: NSWindow {
showMenuBar()
}
@objc private func didExitFullScreen() {
guard #available(macOS 27, *) else {
return
}
// the window server keeps Hot Corners disabled after the full screen space is gone, until the options change
guard NSApp.presentationOptions.isEmpty else {
return // another full screen window is in front and still wants them disabled
}
NSApp.presentationOptions = [.autoHideDock]
NSApp.presentationOptions = []
}
/// Hides the menu bar of our full screen space if and only if we are covered by it.
@objc private func updateMenuBarHidden() {
if isInFullScreenSpace, let screen = screen, frame != screen.frame {
@@ -226,7 +239,11 @@ class VMDisplayWindow: NSWindow {
// the menu bar is only kept hidden for the space we are in, but what we did must be undone in any case
let options: NSApplication.PresentationOptions?
if !isMenuBarRevealAllowed && isKeyWindow {
options = [.fullScreen, .hideMenuBar, .hideDock]
var forcedOptions: NSApplication.PresentationOptions = [.fullScreen, .hideMenuBar, .hideDock]
if #available(macOS 27, *) {
forcedOptions.formUnion(revealableOptions.intersection(.disableScreenCornerInteractions))
}
options = forcedOptions
isPresentationOptionsForced = true
} else if isPresentationOptionsForced {
options = revealableOptions
@@ -419,7 +419,12 @@ class VMDisplayWindowController: NSWindowController, UTMVirtualMachineDelegate {
extension VMDisplayWindowController: NSWindowDelegate {
func window(_ window: NSWindow, willUseFullScreenPresentationOptions proposedOptions: NSApplication.PresentationOptions = []) -> NSApplication.PresentationOptions {
return proposedOptions.union([.autoHideToolbar])
var options = proposedOptions.union([.autoHideToolbar])
if #available(macOS 27, *) {
// the guest owns the whole screen, so its corners should not trigger Hot Corners on the host
options.insert(.disableScreenCornerInteractions)
}
return options
}
func windowShouldClose(_ sender: NSWindow) -> Bool {