impove core readability and hadnling of dock positions

This commit is contained in:
neon443
2025-05-26 11:54:29 +01:00
parent a92c154c49
commit c858fba082

View File

@@ -87,7 +87,6 @@ class MouseTracker {
} }
self.currentDockSide = .bottom self.currentDockSide = .bottom
moveDock(.bottom) moveDock(.bottom)
start()
} }
func checkMouse(_ event: NSEvent) { func checkMouse(_ event: NSEvent) {
@@ -99,7 +98,7 @@ class MouseTracker {
switch currentDockSide { switch currentDockSide {
case .left: case .left:
if location.x < 100 { guard location.x < 100 else { return }
if location.y < screen.height/2 { if location.y < screen.height/2 {
moveDock(.bottom) moveDock(.bottom)
return return
@@ -107,9 +106,8 @@ class MouseTracker {
moveDock(.right) moveDock(.right)
return return
} }
}
case .bottom: case .bottom:
if location.y > 1000 { guard location.y > 1000 else { return }
if location.x < screen.width/2 { if location.x < screen.width/2 {
moveDock(.right) moveDock(.right)
return return
@@ -117,9 +115,8 @@ class MouseTracker {
moveDock(.left) moveDock(.left)
return return
} }
}
case .right: case .right:
if location.x > 1600 { guard location.x > 1600 else { return }
if location.y < screen.height/2 { if location.y < screen.height/2 {
moveDock(.bottom) moveDock(.bottom)
return return
@@ -129,7 +126,6 @@ class MouseTracker {
} }
} }
} }
}
func start() { func start() {
self.monitor = NSEvent.addGlobalMonitorForEvents(matching: .mouseMoved, handler: checkMouse) self.monitor = NSEvent.addGlobalMonitorForEvents(matching: .mouseMoved, handler: checkMouse)