diff --git a/Platform/macOS/Display/VMDisplayAppleDisplayWindowController.swift b/Platform/macOS/Display/VMDisplayAppleDisplayWindowController.swift index cae3ac24..4f12abd7 100644 --- a/Platform/macOS/Display/VMDisplayAppleDisplayWindowController.swift +++ b/Platform/macOS/Display/VMDisplayAppleDisplayWindowController.swift @@ -35,6 +35,8 @@ class VMDisplayAppleDisplayWindowController: VMDisplayAppleWindowController { private var aspectRatioLocked: Bool = false + @Setting("FullScreenAutoCapture") private var isFullScreenAutoCapture: Bool = false + override func windowDidLoad() { mainView = VZVirtualMachineView() captureMouseToolbarButton.image = captureMouseToolbarButton.alternateImage // show capture keyboard image @@ -89,13 +91,17 @@ class VMDisplayAppleDisplayWindowController: VMDisplayAppleWindowController { } func windowDidEnterFullScreen(_ notification: Notification) { - captureMouseToolbarButton.state = .on - captureMouseButtonPressed(self) + if isFullScreenAutoCapture { + captureMouseToolbarButton.state = .on + captureMouseButtonPressed(self) + } } func windowDidExitFullScreen(_ notification: Notification) { - captureMouseToolbarButton.state = .off - captureMouseButtonPressed(self) + if isFullScreenAutoCapture { + captureMouseToolbarButton.state = .off + captureMouseButtonPressed(self) + } } func windowDidResize(_ notification: Notification) { diff --git a/Platform/macOS/Display/VMDisplayQemuMetalWindowController.swift b/Platform/macOS/Display/VMDisplayQemuMetalWindowController.swift index 38201219..06e8f41a 100644 --- a/Platform/macOS/Display/VMDisplayQemuMetalWindowController.swift +++ b/Platform/macOS/Display/VMDisplayQemuMetalWindowController.swift @@ -61,6 +61,7 @@ class VMDisplayQemuMetalWindowController: VMDisplayQemuWindowController { @Setting("NoCursorCaptureAlert") private var isCursorCaptureAlertShown: Bool = false @Setting("NoFullscreenCursorCaptureAlert") private var isFullscreenCursorCaptureAlertShown: Bool = false @Setting("DisplayFixed") private var isDisplayFixed: Bool = false + @Setting("FullScreenAutoCapture") private var isFullScreenAutoCapture: Bool = false @Setting("CtrlRightClick") private var isCtrlRightClick: Bool = false @Setting("AlternativeCaptureKey") private var isAlternativeCaptureKey: Bool = false @Setting("IsCapsLockKey") private var isCapsLockKey: Bool = false @@ -379,14 +380,18 @@ extension VMDisplayQemuMetalWindowController { func windowDidEnterFullScreen(_ notification: Notification) { isFullScreen = true - captureMouseToolbarButton.state = .on - captureMouse() + if isFullScreenAutoCapture { + captureMouseToolbarButton.state = .on + captureMouse() + } } func windowDidExitFullScreen(_ notification: Notification) { isFullScreen = false - captureMouseToolbarButton.state = .off - releaseMouse() + if isFullScreenAutoCapture { + captureMouseToolbarButton.state = .off + releaseMouse() + } } override func windowDidResignKey(_ notification: Notification) { diff --git a/Platform/macOS/SettingsView.swift b/Platform/macOS/SettingsView.swift index 2abc0503..f015eaf1 100644 --- a/Platform/macOS/SettingsView.swift +++ b/Platform/macOS/SettingsView.swift @@ -37,7 +37,7 @@ struct SettingsView: View { .tabItem { Label("Input", systemImage: "keyboard") } - }.frame(minWidth: 600, minHeight: 300, alignment: .topLeading) + }.frame(minWidth: 600, minHeight: 350, alignment: .topLeading) } } @@ -128,6 +128,7 @@ struct SoundSettingsView: View { } struct InputSettingsView: View { + @AppStorage("FullScreenAutoCapture") var isFullScreenAutoCapture = false @AppStorage("OptionAsMetaKey") var isOptionAsMetaKey = false @AppStorage("CtrlRightClick") var isCtrlRightClick = false @AppStorage("AlternativeCaptureKey") var isAlternativeCaptureKey = false @@ -138,6 +139,12 @@ struct InputSettingsView: View { var body: some View { Form { + Section(header: Text("Mouse/Keyboard")) { + Toggle(isOn: $isFullScreenAutoCapture) { + Text("Capture input automatically when entering full screen") + }.help("If enabled, input capture will toggle automatically when entering and exiting full screen mode.") + } + Section(header: Text("Console")) { Toggle(isOn: $isOptionAsMetaKey, label: { Text("Option (⌥) is Meta key") @@ -182,6 +189,7 @@ extension UserDefaults { @objc dynamic var NoQuitConfirmation: Bool { false } @objc dynamic var NoCursorCaptureAlert: Bool { false } @objc dynamic var DisplayFixed: Bool { false } + @objc dynamic var FullScreenAutoCapture: Bool { false } @objc dynamic var OptionAsMetaKey: Bool { false } @objc dynamic var CtrlRightClick: Bool { false } @objc dynamic var NoUsbPrompt: Bool { false }