diff --git a/DockPhobia.xcodeproj/xcshareddata/xcschemes/DockPhobia.xcscheme b/DockPhobia.xcodeproj/xcshareddata/xcschemes/DockPhobia.xcscheme index 4705372..3becac0 100644 --- a/DockPhobia.xcodeproj/xcshareddata/xcschemes/DockPhobia.xcscheme +++ b/DockPhobia.xcodeproj/xcshareddata/xcschemes/DockPhobia.xcscheme @@ -27,8 +27,13 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - shouldUseLaunchSchemeArgsEnv = "YES" - shouldAutocreateTestPlan = "YES"> + shouldUseLaunchSchemeArgsEnv = "YES"> + + + + @@ -62,8 +62,8 @@ filePath = "DockPhobia/DockPhobiaApp.swift" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "297" - endingLineNumber = "297" + startingLineNumber = "317" + endingLineNumber = "317" landmarkName = "getScreenSize()" landmarkType = "9"> @@ -78,8 +78,8 @@ filePath = "DockPhobia/DockPhobiaApp.swift" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "311" - endingLineNumber = "311" + startingLineNumber = "331" + endingLineNumber = "331" landmarkName = "getScreenSize()" landmarkType = "9"> @@ -132,22 +132,6 @@ landmarkType = "9"> - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DockPhobia/DockPhobiaApp.swift b/DockPhobia/DockPhobiaApp.swift index 965ca3c..765e584 100644 --- a/DockPhobia/DockPhobiaApp.swift +++ b/DockPhobia/DockPhobiaApp.swift @@ -165,7 +165,7 @@ func osascript(_ script: String) -> String? { process.standardError = outputErrorPipe process.launch() - process.waitUntilExit() +// process.waitUntilExit() let outputHandle = outputPipe.fileHandleForReading.readDataToEndOfFile() let outputErrorHandle = outputErrorPipe.fileHandleForReading.readDataToEndOfFile() @@ -242,7 +242,8 @@ func calcDockFromLeft() -> CGFloat { func startTrackingMouse() { let mask = CGEventMask(1 << CGEventType.mouseMoved.rawValue) - + var dockSide = getDockSide() + var lastMove = Date.now //try creating event tap eventTap = CGEvent.tapCreate( tap: .cgSessionEventTap, @@ -254,6 +255,26 @@ func startTrackingMouse() { // print("mouse at \(location)") // print("mouse at \(event.location)") //TODO: add Dock moving here + var lastDockMoveTime = Date() + let debounceInterval: TimeInterval = 0.1 + if Date().timeIntervalSince(lastDockMoveTime) > debounceInterval { + if event.location.y > 1000 { + lastDockMoveTime = Date() + Task { + moveDock("left") + } + } else if event.location.x < 100 { + lastDockMoveTime = Date() + Task { + moveDock("right") + } + } else if event.location.x > 1600 { + lastDockMoveTime = Date() + Task { + moveDock("bottom") + } + } + } return Unmanaged.passRetained(event) }, userInfo: nil @@ -271,7 +292,6 @@ func startTrackingMouse() { } } - func stopTrackingMouse() { if let eventTap = eventTap { // disable event tap @@ -312,11 +332,11 @@ func getScreenSize() -> (x: CGFloat, y: CGFloat) { } func moveDock(_ to: String) { - let validPos = ["left", "bottom", "right"] - guard validPos.contains(to) else { - print("invalid dock position") - return - } +// let validPos = ["left", "bottom", "right"] +// guard validPos.contains(to) else { +// print("invalid dock position") +// return +// } let script = """ tell application "System Events" tell dock preferences diff --git a/DockPhobia/Info.plist b/DockPhobia/Info.plist index 3d3fd2b..70a0ff6 100644 --- a/DockPhobia/Info.plist +++ b/DockPhobia/Info.plist @@ -4,16 +4,7 @@ NSAppleEventsUsageDescription allow it - NSAccessibilitysUsageDescription - allow it com.apple.security.automation.apple-events - com.apple.security.scripting-targets - - com.apple.mail - - com.apple.mail.compose - - diff --git a/DockPhobiaAppIcon.png b/DockPhobiaAppIcon.png new file mode 100644 index 0000000..d19767a Binary files /dev/null and b/DockPhobiaAppIcon.png differ