Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Amethyst/Events/HotKeyManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,13 @@ class HotKeyManager<Application: ApplicationType>: NSObject {
appDelegate?.relaunch(self)
}

constructCommandWithCommandKey(CommandKey.toggleNewWindowsToMain.rawValue) {
self.userConfiguration.toggleNewWindowsToMain()
DispatchQueue.main.async {
windowManager.displayNewWindowsToMainHUD()
}
}

LayoutType<Application.Window>.availableLayoutStrings().forEach { (layoutKey, _) in
self.constructCommandWithCommandKey(UserConfiguration.constructLayoutKeyString(layoutKey)) {
let screenManager: ScreenManager<WindowManager<Application>>? = windowManager.focusedScreenManager()
Expand Down Expand Up @@ -405,6 +412,7 @@ class HotKeyManager<Application: ApplicationType>: 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<Application.Window>.availableLayoutStrings() {
let commandName = "Select \(layoutName) layout"
Expand Down
28 changes: 20 additions & 8 deletions Amethyst/Managers/ScreenManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,26 @@ final class ScreenManager<Delegate: ScreenManagerDelegate>: 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
}

Expand All @@ -358,23 +373,20 @@ final class ScreenManager<Delegate: ScreenManagerDelegate>: 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 {
Expand Down
19 changes: 16 additions & 3 deletions Amethyst/Managers/WindowManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
Loading
Loading