From 18cba38914545be79e577638444849c99d8b8948 Mon Sep 17 00:00:00 2001 From: Kai Azim <68963405+MrKai77@users.noreply.github.com> Date: Thu, 31 Aug 2023 16:59:17 -0600 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20Windows=20now=20don't=20resi?= =?UTF-8?q?ze=20over=20the=20dock;=20fixes=20#17?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Loop/Helpers/WindowEngine.swift | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Loop/Helpers/WindowEngine.swift b/Loop/Helpers/WindowEngine.swift index 3b144932..590c0fad 100644 --- a/Loop/Helpers/WindowEngine.swift +++ b/Loop/Helpers/WindowEngine.swift @@ -124,13 +124,21 @@ struct WindowEngine { private func getScreenFrame(screen: NSScreen) -> CGRect? { guard let displayID = screen.displayID else { return nil } - let menubarHeight = screen.frame.size.height - screen.visibleFrame.size.height - var screenFrame = CGDisplayBounds(displayID) - screenFrame.size.height -= menubarHeight - screenFrame.origin.y += menubarHeight + let screenFrameOrigin = CGDisplayBounds(displayID).origin + var screenFrame: CGRect = screen.visibleFrame + + // Set position of the screenFrame (useful for multiple displays) + screenFrame.origin = screenFrameOrigin + + // Move screenFrame's y origin to compensate for menubar & dock, if it's on the bottom + screenFrame.origin.y += (screen.frame.size.height - screen.visibleFrame.size.height) + + // Move screenFrame's x origin when dock is shown on left/right + screenFrame.origin.x += (screen.frame.size.width - screen.visibleFrame.size.width) return screenFrame } + private func generateWindowFrame(_ windowFrame: CGRect, _ screenFrame: CGRect, _ direction: WindowDirection) -> CGRect? { let screenWidth = screenFrame.size.width let screenHeight = screenFrame.size.height From 77e73ee4a1bb989830ade6c2d5f0d817b99fe79d Mon Sep 17 00:00:00 2001 From: Kai Azim <68963405+MrKai77@users.noreply.github.com> Date: Thu, 31 Aug 2023 16:59:59 -0600 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20Make=20preview=20window=20no?= =?UTF-8?q?t=20show=20over=20the=20dock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Loop/Helpers/LoopManager.swift | 2 +- Loop/Preview Window/PreviewController.swift | 15 ++------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/Loop/Helpers/LoopManager.swift b/Loop/Helpers/LoopManager.swift index e13a9376..5c8eed0b 100644 --- a/Loop/Helpers/LoopManager.swift +++ b/Loop/Helpers/LoopManager.swift @@ -86,7 +86,7 @@ class LoopManager { self.screenWithMouse = NSScreen.screenWithMouse if Defaults[.previewVisibility] == true && frontmostWindow != nil { - previewController.show() + previewController.show(screen: self.screenWithMouse!) } radialMenuController.show(frontmostWindow: frontmostWindow) keybindMonitor.start() diff --git a/Loop/Preview Window/PreviewController.swift b/Loop/Preview Window/PreviewController.swift index 98d142c1..46220b4d 100644 --- a/Loop/Preview Window/PreviewController.swift +++ b/Loop/Preview Window/PreviewController.swift @@ -11,7 +11,7 @@ class PreviewController { var loopPreviewWindowController: NSWindowController? - func show() { + func show(screen: NSScreen) { if let windowController = loopPreviewWindowController { windowController.window?.orderFrontRegardless() return @@ -30,18 +30,7 @@ class PreviewController { panel.alphaValue = 0 panel.orderFrontRegardless() - guard let screen = NSScreen.screenWithMouse else { return } - let menubarHeight = screen.frame.size.height - screen.visibleFrame.size.height - - let screenWidth = screen.frame.size.width - let screenHeight = screen.frame.size.height - menubarHeight - let screenOriginX = screen.frame.origin.x - let screenOriginY = screen.frame.origin.y - - panel.setFrame(NSRect(x: screenOriginX, - y: screenOriginY, - width: screenWidth, - height: screenHeight), display: false) + panel.setFrame(screen.visibleFrame, display: false) loopPreviewWindowController = .init(window: panel)