mirror of
https://github.com/neon443/DockPhobia.git
synced 2026-03-11 14:56:16 +00:00
impove core readability and hadnling of dock positions
This commit is contained in:
@@ -87,46 +87,42 @@ class MouseTracker {
|
|||||||
}
|
}
|
||||||
self.currentDockSide = .bottom
|
self.currentDockSide = .bottom
|
||||||
moveDock(.bottom)
|
moveDock(.bottom)
|
||||||
start()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkMouse(_ event: NSEvent) {
|
func checkMouse(_ event: NSEvent) {
|
||||||
var location = event.locationInWindow
|
var location = event.locationInWindow
|
||||||
location.y = screen.height - location.y
|
location.y = screen.height - location.y
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
print(location)
|
print(location)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
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
|
||||||
} else {
|
} else {
|
||||||
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
|
||||||
} else {
|
} else {
|
||||||
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
|
||||||
} else {
|
} else {
|
||||||
moveDock(.left)
|
moveDock(.left)
|
||||||
return
|
return
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user