From b15116b2921bf69d6dfd9bbc4a820c7e8121453e Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Wed, 28 May 2025 17:54:01 +0100 Subject: [PATCH] refactoring --- DockPhobia/MouseTracker.swift | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/DockPhobia/MouseTracker.swift b/DockPhobia/MouseTracker.swift index abe5f2d..a3151b3 100644 --- a/DockPhobia/MouseTracker.swift +++ b/DockPhobia/MouseTracker.swift @@ -100,11 +100,6 @@ class MouseTracker { } func checkMouse(_ event: NSEvent) { - guard !settings.settings.moveMouseInstead else { - print("do the thing ehre") - return - } - var location = NSEvent.mouseLocation location.y = screen.height - location.y @@ -128,33 +123,41 @@ class MouseTracker { case .left: guard location.x < dockHeight else { return } if location.y < screen.height/2 { - moveDock(.bottom) + moveDockOrMouse(.bottom) return } else { - moveDock(.right) + moveDockOrMouse(.right) return } case .bottom: guard location.y > screen.height - dockHeight else { return } if location.x < screen.width/2 { - moveDock(.right) + moveDockOrMouse(.right) return } else { - moveDock(.left) + moveDockOrMouse(.left) return } case .right: guard location.x > screen.width - dockHeight else { return } if location.y < screen.height/2 { - moveDock(.bottom) + moveDockOrMouse(.bottom) return } else { - moveDock(.left) + moveDockOrMouse(.left) return } } } + func moveDockOrMouse(_ dockTo: DockSide) { + if settings.settings.moveMouseInstead { + print("move mouse") + } else { + moveDock(dockTo) + } + } + func start() { self.monitor = NSEvent.addGlobalMonitorForEvents(matching: .mouseMoved, handler: checkMouse) self.running = true