diff --git a/Amethyst/Events/HotKeyManager.swift b/Amethyst/Events/HotKeyManager.swift index 5e4bf6ee..e865d65e 100644 --- a/Amethyst/Events/HotKeyManager.swift +++ b/Amethyst/Events/HotKeyManager.swift @@ -247,6 +247,13 @@ class HotKeyManager: NSObject { appDelegate?.relaunch(self) } + constructCommandWithCommandKey(CommandKey.toggleNewWindowsToMain.rawValue) { + self.userConfiguration.toggleNewWindowsToMain() + DispatchQueue.main.async { + windowManager.displayNewWindowsToMainHUD() + } + } + LayoutType.availableLayoutStrings().forEach { (layoutKey, _) in self.constructCommandWithCommandKey(UserConfiguration.constructLayoutKeyString(layoutKey)) { let screenManager: ScreenManager>? = windowManager.focusedScreenManager() @@ -405,6 +412,7 @@ class HotKeyManager: NSObject { hotKeyNameToDefaultsKey.append(["Display current layout", CommandKey.displayCurrentLayout.rawValue]) hotKeyNameToDefaultsKey.append(["Toggle focus follows mouse", CommandKey.toggleFocusFollowsMouse.rawValue]) hotKeyNameToDefaultsKey.append(["Toggle global tiling", CommandKey.toggleTiling.rawValue]) + hotKeyNameToDefaultsKey.append(["Toggle new windows to main pane sending", CommandKey.toggleNewWindowsToMain.rawValue]) for (layoutKey, layoutName) in LayoutType.availableLayoutStrings() { let commandName = "Select \(layoutName) layout" diff --git a/Amethyst/Managers/ScreenManager.swift b/Amethyst/Managers/ScreenManager.swift index bbf4f6d9..1a5bfdb9 100644 --- a/Amethyst/Managers/ScreenManager.swift +++ b/Amethyst/Managers/ScreenManager.swift @@ -341,11 +341,26 @@ final class ScreenManager: NSObject, Codable { } func displayLayoutHUD() { + guard userConfiguration.enablesLayoutHUD(), space?.type == CGSSpaceTypeUser else { + return + } + + let currentLayoutName = currentLayout.flatMap({ $0.layoutName }) ?? "None" + let currentLayoutDescription = currentLayout?.layoutDescription ?? "" + + displayCustomHUD(title: currentLayoutName, description: currentLayoutDescription) + } + + @objc func hideLayoutHUD(_ sender: AnyObject) { + layoutNameWindowController.close() + } + + func displayCustomHUD(title: String, description: String = "") { guard let screen = screen else { return } - guard userConfiguration.enablesLayoutHUD(), space?.type == CGSSpaceTypeUser else { + guard space?.type == CGSSpaceTypeUser else { return } @@ -358,23 +373,20 @@ final class ScreenManager: NSObject, Codable { return } + // Use new displayNotification method with dynamic sizing + layoutNameWindow.displayNotification(title: title, description: description) + + // Center the window after resizing let screenFrame = screen.frame() let screenCenter = CGPoint(x: screenFrame.midX, y: screenFrame.midY) let windowOrigin = CGPoint( x: screenCenter.x - layoutNameWindow.frame.width / 2.0, y: screenCenter.y - layoutNameWindow.frame.height / 2.0 ) - - layoutNameWindow.layoutNameField?.stringValue = currentLayout.flatMap({ $0.layoutName }) ?? "None" - layoutNameWindow.layoutDescriptionLabel?.stringValue = currentLayout?.layoutDescription ?? "" layoutNameWindow.setFrameOrigin(NSPointFromCGPoint(windowOrigin)) layoutNameWindowController.showWindow(self) } - - @objc func hideLayoutHUD(_ sender: AnyObject) { - layoutNameWindowController.close() - } } extension ScreenManager: Comparable { diff --git a/Amethyst/Managers/WindowManager.swift b/Amethyst/Managers/WindowManager.swift index a2dfb187..50047717 100644 --- a/Amethyst/Managers/WindowManager.swift +++ b/Amethyst/Managers/WindowManager.swift @@ -15,11 +15,11 @@ import SwiftyJSON /** The tolerant interval between the click and the application of a mouse move from focus. - + - Note: - + At the time of the check we confirm that the mouse is not _currently_ clicked. However, it is possible that the click happened faster than the focus notification could be processed so that when we process the focus the mouse is no longer clicked. In this case we could incorrectly move the mouse to the center of the focused window. - + This value is an approximation of the time between a fast click and the focus event being processed. For values larger than this we would expect the mouse to still be clicked. */ private let mouseMoveClickSpeedTolerance: TimeInterval = 0.3 @@ -322,6 +322,19 @@ extension WindowManager { } } + func displayNewWindowsToMainHUD() { + guard userConfiguration.enablesNewWindowsToMainHUD() else { + return + } + + for screenManager in screens.screenManagers { + let isEnabled = userConfiguration.sendNewWindowsToMainPane() + let statusText = isEnabled ? "On" : "Off" + let title = "New Windows to Main Pane: \(statusText)" + screenManager.displayCustomHUD(title: title) + } + } + func add(runningApplication: NSRunningApplication) { switch runningApplication.isManageable { case .manageable: diff --git a/Amethyst/Preferences/GeneralPreferencesViewController.xib b/Amethyst/Preferences/GeneralPreferencesViewController.xib index 32aa189c..702fe132 100644 --- a/Amethyst/Preferences/GeneralPreferencesViewController.xib +++ b/Amethyst/Preferences/GeneralPreferencesViewController.xib @@ -13,11 +13,11 @@ - + - + @@ -26,7 +26,7 @@ - + @@ -56,7 +56,7 @@ - + @@ -77,7 +77,7 @@ - + @@ -86,7 +86,7 @@ - + @@ -95,7 +95,7 @@ - + @@ -110,7 +110,7 @@ - + @@ -119,7 +119,7 @@ - + @@ -127,7 +127,7 @@ - + @@ -136,7 +136,7 @@ - + @@ -151,7 +151,7 @@ - + @@ -160,7 +160,7 @@ - + @@ -168,7 +168,7 @@ - + @@ -176,7 +176,7 @@ - + @@ -185,7 +185,7 @@ - + @@ -194,7 +194,7 @@ - + @@ -207,7 +207,7 @@ - + @@ -215,7 +215,7 @@ - + @@ -224,7 +224,7 @@ - + @@ -237,7 +237,7 @@ - + @@ -245,7 +245,7 @@ - + @@ -254,7 +254,7 @@ - + @@ -267,7 +267,7 @@ - + @@ -275,7 +275,7 @@ - + @@ -284,7 +284,7 @@ - + @@ -297,7 +297,7 @@ - + @@ -305,7 +305,7 @@ - + @@ -314,7 +314,7 @@ - + @@ -323,15 +323,15 @@ - + - + + - + @@ -362,7 +373,7 @@ - + @@ -404,7 +415,7 @@ - + @@ -419,7 +430,7 @@