mirror of
https://github.com/neon443/DockPhobia.git
synced 2026-03-11 06:49:12 +00:00
refactoring
This commit is contained in:
@@ -100,11 +100,6 @@ class MouseTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func checkMouse(_ event: NSEvent) {
|
func checkMouse(_ event: NSEvent) {
|
||||||
guard !settings.settings.moveMouseInstead else {
|
|
||||||
print("do the thing ehre")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var location = NSEvent.mouseLocation
|
var location = NSEvent.mouseLocation
|
||||||
location.y = screen.height - location.y
|
location.y = screen.height - location.y
|
||||||
|
|
||||||
@@ -128,33 +123,41 @@ class MouseTracker {
|
|||||||
case .left:
|
case .left:
|
||||||
guard location.x < dockHeight else { return }
|
guard location.x < dockHeight else { return }
|
||||||
if location.y < screen.height/2 {
|
if location.y < screen.height/2 {
|
||||||
moveDock(.bottom)
|
moveDockOrMouse(.bottom)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
moveDock(.right)
|
moveDockOrMouse(.right)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case .bottom:
|
case .bottom:
|
||||||
guard location.y > screen.height - dockHeight else { return }
|
guard location.y > screen.height - dockHeight else { return }
|
||||||
if location.x < screen.width/2 {
|
if location.x < screen.width/2 {
|
||||||
moveDock(.right)
|
moveDockOrMouse(.right)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
moveDock(.left)
|
moveDockOrMouse(.left)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case .right:
|
case .right:
|
||||||
guard location.x > screen.width - dockHeight else { return }
|
guard location.x > screen.width - dockHeight else { return }
|
||||||
if location.y < screen.height/2 {
|
if location.y < screen.height/2 {
|
||||||
moveDock(.bottom)
|
moveDockOrMouse(.bottom)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
moveDock(.left)
|
moveDockOrMouse(.left)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func moveDockOrMouse(_ dockTo: DockSide) {
|
||||||
|
if settings.settings.moveMouseInstead {
|
||||||
|
print("move mouse")
|
||||||
|
} else {
|
||||||
|
moveDock(dockTo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func start() {
|
func start() {
|
||||||
self.monitor = NSEvent.addGlobalMonitorForEvents(matching: .mouseMoved, handler: checkMouse)
|
self.monitor = NSEvent.addGlobalMonitorForEvents(matching: .mouseMoved, handler: checkMouse)
|
||||||
self.running = true
|
self.running = true
|
||||||
|
|||||||
Reference in New Issue
Block a user