diff --git a/DockPhobia/AppDelegate.swift b/DockPhobia/AppDelegate.swift index 847e8e9..1051736 100644 --- a/DockPhobia/AppDelegate.swift +++ b/DockPhobia/AppDelegate.swift @@ -101,13 +101,13 @@ class AppDelegate: NSObject, NSApplicationDelegate { menu.addItem(NSMenuItem.separator()) menu.addItem(NSMenuItem( - title: "Move Dock to the left", - action: #selector(moveDockObjcLeft), - keyEquivalent: "")) + title: "Move Dock to the left", + action: #selector(moveDockObjcLeft), + keyEquivalent: "")) menu.addItem(NSMenuItem( - title: "Move Dock to the bottom", - action: #selector(moveDockObjcBottom), - keyEquivalent: "")) + title: "Move Dock to the bottom", + action: #selector(moveDockObjcBottom), + keyEquivalent: "")) menu.addItem(NSMenuItem( title: "Move Dock to the right", action: #selector(moveDockObjcRight), diff --git a/DockPhobia/DPSettings.swift b/DockPhobia/DPSettings.swift index 8cb316d..4166585 100644 --- a/DockPhobia/DPSettings.swift +++ b/DockPhobia/DPSettings.swift @@ -71,14 +71,14 @@ struct DPSettings: Codable { let defaults = DPSettings() let container = try decoder.container(keyedBy: CodingKeys.self) dockMoves = try container.decodeIfPresent(Int.self, forKey: .dockMoves) - ?? defaults.dockMoves + ?? defaults.dockMoves mouseMoves = try container.decodeIfPresent(Int.self, forKey: .mouseMoves) ?? defaults.mouseMoves checkFullscreen = try container.decodeIfPresent(Bool.self, forKey: .checkFullscreen) - ?? defaults.checkFullscreen + ?? defaults.checkFullscreen moveMouseInstead = try container.decodeIfPresent(Bool.self, forKey: .moveMouseInstead) - ?? defaults.moveMouseInstead + ?? defaults.moveMouseInstead insetHorizontal = try container.decodeIfPresent(CGFloat.self, forKey: .insetHorizontal) ?? defaults.insetHorizontal diff --git a/DockPhobia/MouseTracker.swift b/DockPhobia/MouseTracker.swift index 7a86ddc..08175f6 100644 --- a/DockPhobia/MouseTracker.swift +++ b/DockPhobia/MouseTracker.swift @@ -64,12 +64,12 @@ class MouseTracker { func checkMouse(_ event: NSEvent) { let location = event.mouseLocationCG - #if DEBUG +#if DEBUG var cgpointForSkyHigh = NSEvent.mouseLocation cgpointForSkyHigh.x -= 20 cgpointForSkyHigh.y -= 5 skyHigh.move(to: cgpointForSkyHigh) - #endif +#endif guard settings.settings.checkFullscreen else { handleDockValue(dockIsAt: currentDockSide, location: location) @@ -127,12 +127,18 @@ class MouseTracker { } func start() { +#if DEBUG + skyHigh.show() +#endif self.monitor = NSEvent.addGlobalMonitorForEvents(matching: .mouseMoved, handler: checkMouse) self.running = true print("started tracking") } func stop() { +#if DEBUG + skyHigh.hide() +#endif if let monitor = monitor { NSEvent.removeMonitor(monitor) self.running = false @@ -177,26 +183,26 @@ class MouseTracker { func moveDock(_ toSide: DockSide) { guard currentDockSide != toSide else { return } -// let scriptHide = """ -// tell application "System Events" -// tell dock preferences -// set autohide to true -// end tell -// end tell -// """ -// -// let scriptShow = scriptHide.replacingOccurrences(of: "true", with: "false") + // let scriptHide = """ + // tell application "System Events" + // tell dock preferences + // set autohide to true + // end tell + // end tell + // """ + // + // let scriptShow = scriptHide.replacingOccurrences(of: "true", with: "false") let scriptMove = """ tell application "System Events" tell dock preferences - set screen edge to \(toSide) + set screen edge to \(toSide) end tell end tell """ -// applescript(scriptHide) + // applescript(scriptHide) applescript(scriptMove) -// applescript(scriptShow) + // applescript(scriptShow) currentDockSide = toSide settings.settings.dockMoves += 1 refreshMenus() diff --git a/DockPhobia/SkyHigh.swift b/DockPhobia/SkyHigh.swift index 6e09cae..d4d29a1 100644 --- a/DockPhobia/SkyHigh.swift +++ b/DockPhobia/SkyHigh.swift @@ -35,9 +35,6 @@ class SkyHigh { window.ignoresMouseEvents = true window.hasShadow = true window.collectionBehavior = NSWindow.CollectionBehavior.canJoinAllSpaces.union(.stationary) - #if DEBUG - show() - #endif } func move(to: CGPoint) {