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
18 changes: 18 additions & 0 deletions Amethyst/Events/HotKeyManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,22 @@ class HotKeyManager<Application: ApplicationType>: NSObject {
appDelegate?.relaunch(self)
}

constructCommandWithCommandKey(CommandKey.increaseWindowMaxCount.rawValue) {
self.userConfiguration.increaseWindowMaxCount()
windowManager.markAllScreensForReflow(withChange: .unknown)
DispatchQueue.main.async {
windowManager.displayWindowCountHUD()
}
}

constructCommandWithCommandKey(CommandKey.decreaseWindowMaxCount.rawValue) {
self.userConfiguration.decreaseWindowMaxCount()
windowManager.markAllScreensForReflow(withChange: .unknown)
DispatchQueue.main.async {
windowManager.displayWindowCountHUD()
}
}

LayoutType<Application.Window>.availableLayoutStrings().forEach { (layoutKey, _) in
self.constructCommandWithCommandKey(UserConfiguration.constructLayoutKeyString(layoutKey)) {
let screenManager: ScreenManager<WindowManager<Application>>? = windowManager.focusedScreenManager()
Expand Down Expand Up @@ -367,6 +383,8 @@ class HotKeyManager<Application: ApplicationType>: NSObject {
hotKeyNameToDefaultsKey.append(["Expand main pane", CommandKey.expandMain.rawValue])
hotKeyNameToDefaultsKey.append(["Increase main pane count", CommandKey.increaseMain.rawValue])
hotKeyNameToDefaultsKey.append(["Decrease main pane count", CommandKey.decreaseMain.rawValue])
hotKeyNameToDefaultsKey.append(["Increase window max count", CommandKey.increaseWindowMaxCount.rawValue])
hotKeyNameToDefaultsKey.append(["Decrease window max count", CommandKey.decreaseWindowMaxCount.rawValue])
hotKeyNameToDefaultsKey.append(["Custom layout command 1", CommandKey.command1.rawValue])
hotKeyNameToDefaultsKey.append(["Custom layout command 2", CommandKey.command2.rawValue])
hotKeyNameToDefaultsKey.append(["Custom layout command 3", CommandKey.command3.rawValue])
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
13 changes: 13 additions & 0 deletions Amethyst/Managers/WindowManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,19 @@ extension WindowManager {
}
}

func displayWindowCountHUD() {
guard userConfiguration.enablesWindowCountHUD() else {
return
}

for screenManager in screens.screenManagers {
let currentCount = userConfiguration.windowMaxCount() ?? 0
let countText = currentCount == 0 ? "Unlimited" : "\(currentCount)"
let title = "Window Max Count: \(countText)"
screenManager.displayCustomHUD(title: title)
}
}

func add(runningApplication: NSRunningApplication) {
switch runningApplication.isManageable {
case .manageable:
Expand Down
Loading
Loading