From c858fba0826056462a4629cba0211b7d5eb31896 Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Mon, 26 May 2025 11:54:29 +0100 Subject: [PATCH] impove core readability and hadnling of dock positions --- DockPhobia/MouseTracker.swift | 50 ++++++++++++++++------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/DockPhobia/MouseTracker.swift b/DockPhobia/MouseTracker.swift index 909df4a..8b49683 100644 --- a/DockPhobia/MouseTracker.swift +++ b/DockPhobia/MouseTracker.swift @@ -87,46 +87,42 @@ class MouseTracker { } self.currentDockSide = .bottom moveDock(.bottom) - start() } func checkMouse(_ event: NSEvent) { var location = event.locationInWindow location.y = screen.height - location.y - #if DEBUG +#if DEBUG print(location) - #endif +#endif switch currentDockSide { case .left: - if location.x < 100 { - if location.y < screen.height/2 { - moveDock(.bottom) - return - } else { - moveDock(.right) - return - } + guard location.x < 100 else { return } + if location.y < screen.height/2 { + moveDock(.bottom) + return + } else { + moveDock(.right) + return } case .bottom: - if location.y > 1000 { - if location.x < screen.width/2 { - moveDock(.right) - return - } else { - moveDock(.left) - return - } + guard location.y > 1000 else { return } + if location.x < screen.width/2 { + moveDock(.right) + return + } else { + moveDock(.left) + return } case .right: - if location.x > 1600 { - if location.y < screen.height/2 { - moveDock(.bottom) - return - } else { - moveDock(.left) - return - } + guard location.x > 1600 else { return } + if location.y < screen.height/2 { + moveDock(.bottom) + return + } else { + moveDock(.left) + return } } }