mirror of
https://github.com/neon443/DockPhobia.git
synced 2026-03-11 06:49:12 +00:00
impove core readability and hadnling of dock positions
This commit is contained in:
@@ -87,19 +87,18 @@ 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 {
|
||||
guard location.x < 100 else { return }
|
||||
if location.y < screen.height/2 {
|
||||
moveDock(.bottom)
|
||||
return
|
||||
@@ -107,9 +106,8 @@ class MouseTracker {
|
||||
moveDock(.right)
|
||||
return
|
||||
}
|
||||
}
|
||||
case .bottom:
|
||||
if location.y > 1000 {
|
||||
guard location.y > 1000 else { return }
|
||||
if location.x < screen.width/2 {
|
||||
moveDock(.right)
|
||||
return
|
||||
@@ -117,9 +115,8 @@ class MouseTracker {
|
||||
moveDock(.left)
|
||||
return
|
||||
}
|
||||
}
|
||||
case .right:
|
||||
if location.x > 1600 {
|
||||
guard location.x > 1600 else { return }
|
||||
if location.y < screen.height/2 {
|
||||
moveDock(.bottom)
|
||||
return
|
||||
@@ -129,7 +126,6 @@ class MouseTracker {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func start() {
|
||||
self.monitor = NSEvent.addGlobalMonitorForEvents(matching: .mouseMoved, handler: checkMouse)
|
||||
|
||||
Reference in New Issue
Block a user