3 Commits
1.2.1 ... 1.3.1

Author SHA1 Message Date
neon443
8a4b0f0f65 we now have preferences
use it to:
 - move the dock/mouse
 - smaller deathzone
 - check for updates (sparkle yayyy)
 - quit
this took way too long
2025-05-30 18:42:50 +01:00
neon443
6c9d65f026 formatting, debug stuff 2025-05-30 16:07:07 +01:00
neon443
4b0e0db186 FINALLY
created settings window that actually shows up
2025-05-30 16:05:35 +01:00
11 changed files with 258 additions and 63 deletions

View File

@@ -5,7 +5,7 @@
// Created by neon443 on 26/05/2025.
//
VERSION = 1.2.1
VERSION = 1.3
BUILD_ID = 3
TEAM_ID = 8JGND254B7
BUNDLE_ID = com.neon443.DockPhobia

View File

@@ -14,8 +14,9 @@
A98C20C62DE614180008D61C /* DPSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = A98C20C52DE614180008D61C /* DPSettings.swift */; };
A9C9AF812DE7776A0039D7A5 /* DockSide.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C9AF802DE777530039D7A5 /* DockSide.swift */; };
A9C9AF832DE77CB70039D7A5 /* SkyHigh.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C9AF822DE77CB70039D7A5 /* SkyHigh.swift */; };
A9C9B0682DE888B20039D7A5 /* Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C9B0672DE888B20039D7A5 /* Preferences.swift */; };
A9C9B06D2DE99E5F0039D7A5 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = A9C9B06C2DE99E5F0039D7A5 /* Sparkle */; };
A9C9B0712DE9F6E60039D7A5 /* Preferences.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9C9B0702DE9F6E60039D7A5 /* Preferences.xib */; };
A9C9B0732DE9F7020039D7A5 /* SettingsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C9B0722DE9F7020039D7A5 /* SettingsController.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -29,8 +30,9 @@
A98C20C52DE614180008D61C /* DPSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DPSettings.swift; sourceTree = "<group>"; };
A9C9AF802DE777530039D7A5 /* DockSide.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DockSide.swift; sourceTree = "<group>"; };
A9C9AF822DE77CB70039D7A5 /* SkyHigh.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SkyHigh.swift; sourceTree = "<group>"; };
A9C9B0672DE888B20039D7A5 /* Preferences.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Preferences.swift; sourceTree = "<group>"; };
A9C9B06E2DE9B55F0039D7A5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
A9C9B0702DE9F6E60039D7A5 /* Preferences.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = Preferences.xib; sourceTree = "<group>"; };
A9C9B0722DE9F7020039D7A5 /* SettingsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -56,8 +58,8 @@
A94BEC102DE23ECE00D4811D /* Views */ = {
isa = PBXGroup;
children = (
A9C9B0702DE9F6E60039D7A5 /* Preferences.xib */,
A94BEC0E2DE23E8500D4811D /* MainMenu.xib */,
A9C9B0672DE888B20039D7A5 /* Preferences.swift */,
);
path = Views;
sourceTree = "<group>";
@@ -88,6 +90,7 @@
A9C9AF822DE77CB70039D7A5 /* SkyHigh.swift */,
A98C20C52DE614180008D61C /* DPSettings.swift */,
A9C9AF802DE777530039D7A5 /* DockSide.swift */,
A9C9B0722DE9F7020039D7A5 /* SettingsController.swift */,
A94BEC102DE23ECE00D4811D /* Views */,
A94BEC0A2DE21F8100D4811D /* Resources */,
A966B4F02DE0842400C721A5 /* DockPhobia.entitlements */,
@@ -160,6 +163,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A9C9B0712DE9F6E60039D7A5 /* Preferences.xib in Resources */,
A94BEC0F2DE23E8500D4811D /* MainMenu.xib in Resources */,
A966B4F52DE0842500C721A5 /* Assets.xcassets in Resources */,
);
@@ -174,7 +178,7 @@
files = (
A98C20C62DE614180008D61C /* DPSettings.swift in Sources */,
A9C9AF832DE77CB70039D7A5 /* SkyHigh.swift in Sources */,
A9C9B0682DE888B20039D7A5 /* Preferences.swift in Sources */,
A9C9B0732DE9F7020039D7A5 /* SettingsController.swift in Sources */,
A966B4F82DE0852900C721A5 /* MouseTracker.swift in Sources */,
A966B4F42DE0842500C721A5 /* AppDelegate.swift in Sources */,
A9C9AF812DE7776A0039D7A5 /* DockSide.swift in Sources */,

BIN
DockPhobia/.DS_Store vendored
View File

Binary file not shown.

View File

@@ -12,6 +12,7 @@ import Sparkle
class AppDelegate: NSObject, NSApplicationDelegate {
public var statusItem: NSStatusItem!
public var prefsWindow: NSWindowController?
var settings = DPSettingsModel()
var mouseTracker: MouseTracker
@@ -50,21 +51,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
let start = NSMenuItem(title: describeStartButton(), action: #selector(didTapStart), keyEquivalent: "")
menu.addItem(start)
let checkforUpdatesMenuItem = NSMenuItem(
title: "Check for Updates...",
action: #selector(SPUStandardUpdaterController.checkForUpdates(_:)),
keyEquivalent: ""
)
checkforUpdatesMenuItem.target = updateController
menu.addItem(checkforUpdatesMenuItem)
let screen = NSMenuItem(
title: "\(mouseTracker.screen.width)x\(mouseTracker.screen.height)",
action: nil,
keyEquivalent: ""
)
menu.addItem(screen)
let dockMoves = NSMenuItem(
title: "Moved the Dock \(settings.settings.dockMoves) time\(settings.settings.dockMoves.plural)",
action: nil,
@@ -90,29 +76,35 @@ class AppDelegate: NSObject, NSApplicationDelegate {
menu.addItem(NSMenuItem.separator())
let checkfullscreenButton = NSMenuItem(
title: "Smaller deathzone in fullscreen",
action: #selector(checkFullscreenToggle),
keyEquivalent: ""
)
checkfullscreenButton.state = NSControl.StateValue(rawValue: settings.settings.checkFullscreen ? 1 : 0)
menu.addItem(checkfullscreenButton)
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: "1"))
menu.addItem(NSMenuItem(
title: "Move Dock to the bottom",
action: #selector(moveDockObjcBottom),
keyEquivalent: ""))
title: "Move Dock to the bottom",
action: #selector(moveDockObjcBottom),
keyEquivalent: "2"))
menu.addItem(NSMenuItem(
title: "Move Dock to the right",
action: #selector(moveDockObjcRight),
keyEquivalent: ""))
keyEquivalent: "3"))
menu.addItem(NSMenuItem.separator())
let checkforUpdatesMenuItem = NSMenuItem(
title: "Check for Updates...",
action: #selector(SPUStandardUpdaterController.checkForUpdates(_:)),
keyEquivalent: ""
)
checkforUpdatesMenuItem.target = updateController
menu.addItem(checkforUpdatesMenuItem)
let prefs = NSMenuItem(
title: "Preferences",
action: #selector(tappedPrefs),
keyEquivalent: ","
)
menu.addItem(prefs)
let quit = NSMenuItem(title: "Quit", action: #selector(quit), keyEquivalent: "q")
menu.addItem(quit)
statusItem.menu = menu
@@ -126,6 +118,17 @@ class AppDelegate: NSObject, NSApplicationDelegate {
button.image = NSImage(named: "cursor.slash")
}
}
@objc func tappedPrefs() {
if prefsWindow == nil {
prefsWindow = DPPreferencesWindowController(
mouseTracker: mouseTracker,
settings: settings,
updater: updateController
)
}
prefsWindow!.window?.orderFront(nil)
}
@objc func didTapStart() {
if mouseTracker.running {
mouseTracker.stop()

View File

@@ -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

View File

@@ -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,15 +183,15 @@ 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"
@@ -194,9 +200,9 @@ class MouseTracker {
end tell
end tell
"""
// applescript(scriptHide)
// applescript(scriptHide)
applescript(scriptMove)
// applescript(scriptShow)
// applescript(scriptShow)
currentDockSide = toSide
settings.settings.dockMoves += 1
refreshMenus()

View File

@@ -0,0 +1,71 @@
//
// Preferences.swift
// DockPhobia
//
// Created by neon443 on 29/05/2025.
//
import Foundation
import AppKit
import Sparkle
class DPPreferencesWindowController: NSWindowController {
var mouseTracker: MouseTracker?
var settings: DPSettingsModel?
var updater: SPUStandardUpdaterController?
@IBOutlet weak var mouseRadio: NSButton!
@IBOutlet weak var dockRadio: NSButton!
@IBOutlet weak var updateCheckButton: NSButton!
@IBOutlet weak var smallDeathzoneToggle: NSButton!
@IBOutlet weak var quitbutton: NSButton!
override init(window: NSWindow?) {
super.init(window: window)
}
required init?(coder: NSCoder) {
super.init(coder: coder)
}
convenience init(mouseTracker: MouseTracker, settings: DPSettingsModel, updater: SPUStandardUpdaterController) {
self.init(windowNibName: "Preferences")
self.mouseTracker = mouseTracker
self.settings = settings
self.updater = updater
}
override func windowDidLoad() {
smallDeathzoneToggle.state = NSControl.StateValue(
settings!.settings.checkFullscreen ? 1 : 0
)
dockRadio.state = NSControl.StateValue(
settings!.settings.moveMouseInstead ? 0 : 1
)
mouseRadio.state = NSControl.StateValue(
settings!.settings.moveMouseInstead ? 1 : 0
)
}
@IBAction func checkUpdates(_ sender: Any) {
updater?.checkForUpdates(nil)
}
@IBAction func MoveTypeSelect(_ sender: Any) {
if dockRadio.state.rawValue == 1 {
settings?.settings.moveMouseInstead = false
} else {
settings?.settings.moveMouseInstead = true
}
refreshMenus()
}
@IBAction func quit(_ sender: Any) {
NSApplication.shared.terminate(nil)
}
@IBAction func smallDeathzoneToggle(_ sender: Any) {
settings?.settings.checkFullscreen.toggle()
}
}

View File

@@ -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) {

View File

@@ -1,8 +0,0 @@
//
// Preferences.swift
// DockPhobia
//
// Created by neon443 on 29/05/2025.
//
import Foundation

View File

@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="23727" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23727"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="DPPreferencesWindowController" customModule="DockPhobia" customModuleProvider="target">
<connections>
<outlet property="dockRadio" destination="SML-7D-HqD" id="4QO-vf-9ma"/>
<outlet property="mouseRadio" destination="xQV-F8-e5K" id="2cJ-W4-uYY"/>
<outlet property="quitbutton" destination="7DK-yJ-I42" id="fDP-cd-88f"/>
<outlet property="smallDeathzoneToggle" destination="TNA-PK-KGC" id="rTv-BF-hv6"/>
<outlet property="updateCheckButton" destination="bnA-Vz-L4F" id="16N-mV-Agw"/>
<outlet property="window" destination="85c-fa-xeM" id="B5X-4l-mcR"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="DockPhobia Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="85c-fa-xeM">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" texturedBackground="YES"/>
<rect key="contentRect" x="683" y="389" width="423" height="186"/>
<rect key="screenRect" x="0.0" y="0.0" width="1710" height="1069"/>
<view key="contentView" wantsLayer="YES" id="wEz-dE-A27">
<rect key="frame" x="0.0" y="0.0" width="423" height="186"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="bnA-Vz-L4F">
<rect key="frame" x="13" y="8" width="159" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<buttonCell key="cell" type="push" title="Check for Updates..." bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="XBJ-UK-x73">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="checkUpdates:" target="-2" id="AX2-PR-jPb"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="SML-7D-HqD">
<rect key="frame" x="87" y="149" width="67" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
<buttonCell key="cell" type="radio" title="Dock" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="Lxi-8n-jY3">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="MoveTypeSelect:" target="-2" id="PP9-SC-6xN"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xQV-F8-e5K">
<rect key="frame" x="87" y="121" width="67" height="24"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
<buttonCell key="cell" type="radio" title="Mouse" bezelStyle="regularSquare" imagePosition="left" inset="2" id="86E-Km-LZ7">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="MoveTypeSelect:" target="-2" id="dfh-6B-58k"/>
</connections>
</button>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="U5P-YK-hTs">
<rect key="frame" x="18" y="150" width="60" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Move the" id="4wN-vE-QCE">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="vyh-vP-oAh">
<rect key="frame" x="160" y="150" width="245" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="when the cursor gets close to the Dock." id="y3x-vy-qbu">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="TNA-PK-KGC">
<rect key="frame" x="18" y="81" width="216" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Smaller deathzone in fullscreen" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="28Y-O4-oAQ">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="smallDeathzoneToggle:" target="-2" id="zlu-Ca-p04"/>
</connections>
</button>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3Pd-Xt-fTA">
<rect key="frame" x="18" y="60" width="136" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="May reduce performance" id="Orh-5m-Me2">
<font key="font" metaFont="system" size="11"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7DK-yJ-I42">
<rect key="frame" x="343" y="14" width="60" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<buttonCell key="cell" type="roundRect" title="Quit" bezelStyle="roundedRect" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="jbc-01-FBx">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="quit:" target="-2" id="483-Pc-QoS"/>
</connections>
</button>
</subviews>
</view>
<toolbar key="toolbar" implicitIdentifier="3DBA283D-9272-4F9B-8799-AA8355F2BE79" autosavesConfiguration="NO" showsBaselineSeparator="NO" displayMode="iconAndLabel" sizeMode="regular" id="MWN-PM-U77">
<allowedToolbarItems/>
<defaultToolbarItems/>
</toolbar>
<contentBorderThickness minY="0.0" maxY="0.0"/>
<point key="canvasLocation" x="-213.5" y="-103"/>
</window>
<userDefaultsController representsSharedInstance="YES" id="zYZ-vc-iso"/>
</objects>
</document>

BIN
DockPhobiaPy/.DS_Store vendored
View File

Binary file not shown.