From 59f4fb1861f6d87ce7342d8f2aafbd5feb2fd26d Mon Sep 17 00:00:00 2001 From: Michael Russo Date: Sun, 17 Jul 2022 23:08:13 -0400 Subject: [PATCH] Grid-based nav: jump to correct coordinates when Dock not auto-hidden. See #29: https://github.com/mjrusso/scoot/issues/29 --- Scoot/KeyboardInputWindow+UI.swift | 7 ++++--- Scoot/KeyboardInputWindow.swift | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Scoot/KeyboardInputWindow+UI.swift b/Scoot/KeyboardInputWindow+UI.swift index abb7ee5..7000a3c 100644 --- a/Scoot/KeyboardInputWindow+UI.swift +++ b/Scoot/KeyboardInputWindow+UI.swift @@ -59,9 +59,10 @@ extension KeyboardInputWindow { for windowController in jumpWindowControllers { if let screen = windowController.assignedScreen { if screen.frame.contains(screenRect) { - let rect = NSRect( // Convert from screen coordinates to window coordinates. - x: screenRect.origin.x - screen.frame.origin.x, - y: screenRect.origin.y - screen.frame.origin.y, + // Convert from screen coordinates to window coordinates, accounting the system Dock (when visible). + let rect = NSRect( + x: screenRect.origin.x - screen.frame.origin.x - (screen.visibleFrame.origin.x - screen.frame.origin.x), + y: screenRect.origin.y - screen.frame.origin.y - (screen.visibleFrame.origin.y - screen.frame.origin.y), width: screenRect.width, height: screenRect.height ) diff --git a/Scoot/KeyboardInputWindow.swift b/Scoot/KeyboardInputWindow.swift index ede98dc..619a96a 100644 --- a/Scoot/KeyboardInputWindow.swift +++ b/Scoot/KeyboardInputWindow.swift @@ -125,8 +125,8 @@ class KeyboardInputWindow: TransparentWindow { // screens are connected.) let screenRects = grid.rects.map { CGRect( - x: $0.origin.x + screen.frame.origin.x, - y: $0.origin.y + screen.frame.origin.y, + x: $0.origin.x + screen.visibleFrame.origin.x, + y: $0.origin.y + screen.visibleFrame.origin.y, width: $0.width, height: $0.height )