From 66b0a1c0c36b9eb1cc5c71cdd078d8a86c0fe392 Mon Sep 17 00:00:00 2001 From: Henri Nurmi Date: Wed, 10 Nov 2021 19:01:01 +0200 Subject: [PATCH] Fix the layout HUD when multiple screen are arranged vertically (#1162) --- Amethyst/Managers/ScreenManager.swift | 2 +- Amethyst/Model/Screen.swift | 7 +++++++ AmethystTests/Model/TestScreen.swift | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Amethyst/Managers/ScreenManager.swift b/Amethyst/Managers/ScreenManager.swift index 9f08b661..7e90e0b9 100644 --- a/Amethyst/Managers/ScreenManager.swift +++ b/Amethyst/Managers/ScreenManager.swift @@ -313,7 +313,7 @@ final class ScreenManager: NSObject, Codable { return } - let screenFrame = screen.frameIncludingDockAndMenu() + let screenFrame = screen.frame() let screenCenter = CGPoint(x: screenFrame.midX, y: screenFrame.midY) let windowOrigin = CGPoint( x: screenCenter.x - layoutNameWindow.frame.width / 2.0, diff --git a/Amethyst/Model/Screen.swift b/Amethyst/Model/Screen.swift index 7c450b46..856344e1 100644 --- a/Amethyst/Model/Screen.swift +++ b/Amethyst/Model/Screen.swift @@ -40,6 +40,9 @@ protocol ScreenType: Equatable { /// The frame adjusted such that the dock and menu are not included. func frameWithoutDockOrMenu() -> CGRect + /// The frame without adjustment. + func frame() -> CGRect + /// The opaque idenfitifer for the screen in the underlying graphics system. func screenID() -> String? @@ -119,6 +122,10 @@ struct AMScreen: ScreenType { return screen.frameWithoutDockOrMenu() } + func frame() -> CGRect { + return screen.frame + } + func screenID() -> String? { guard let managedDisplay = CGSCopyBestManagedDisplayForRect(CGSMainConnectionID(), frameIncludingDockAndMenu()) else { return nil diff --git a/AmethystTests/Model/TestScreen.swift b/AmethystTests/Model/TestScreen.swift index d4d25e84..25f844c5 100644 --- a/AmethystTests/Model/TestScreen.swift +++ b/AmethystTests/Model/TestScreen.swift @@ -42,6 +42,10 @@ final class TestScreen: ScreenType { return internalFrame } + func frame() -> CGRect { + return internalFrame + } + func screenID() -> String? { return id }