impove core readability and hadnling of dock positions

This commit is contained in:
neon443 committed 2025-05-26 11:54:29 +01:00
1 parent a92c154c49
commit c858fba082
1 file changed
+5 -9
+5 -9
View File
@@ -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
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.