poc: it works fully, but its hardcoded, need to get dock height programmatically

This commit is contained in:
neon443
2025-05-25 10:15:49 +01:00
parent 8a8a1331d4
commit d1ce8d4293
3 changed files with 34 additions and 8 deletions

View File

@@ -301,7 +301,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 10.10; MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.neon443.DockPhobia; PRODUCT_BUNDLE_IDENTIFIER = com.neon443.DockPhobia;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
@@ -334,7 +334,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 10.10; MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.neon443.DockPhobia; PRODUCT_BUNDLE_IDENTIFIER = com.neon443.DockPhobia;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";

View File

@@ -18,7 +18,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ aNotification: Notification) { func applicationDidFinishLaunching(_ aNotification: Notification) {
statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
if let button = statusItem.button { if let button = statusItem.button {
button.image = NSImage(named: "cursor") button.image = NSImage(named: "cursor.slash")
} }
setupMenus() setupMenus()
} }
@@ -41,8 +41,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
} }
func changeMenuIcon(running: Bool) { func changeMenuIcon(running: Bool) {
if let button = statusItem.button { guard let button = statusItem.button else { return }
button.image = NSImage(named: "cursor\(running ? ".motion" : "")") switch running {
case true:
button.image = NSImage(named: "cursor.motion")
case false:
button.image = NSImage(named: "cursor.slash")
} }
} }

View File

@@ -37,8 +37,6 @@ class MouseTracker {
} else { } else {
fatalError("no screen wtf???") fatalError("no screen wtf???")
} }
moveDock(.left)
moveDock(.bottom)
} }
func checkMouse(_ event: NSEvent) { func checkMouse(_ event: NSEvent) {
@@ -48,7 +46,31 @@ class MouseTracker {
print(location) print(location)
#endif #endif
if location.y > 1000 { if location.y > 1000 {
if location.x < screen.width/2 {
moveDock(.right)
return
} else {
moveDock(.left)
return
}
}
if location.x < 100 {
if location.y < screen.height/2 {
moveDock(.bottom)
return
} else {
moveDock(.right)
return
}
}
if location.x > 1600 {
if location.y < screen.height/2 {
moveDock(.bottom)
return
} else {
moveDock(.left)
return
}
} }
} }