From 853fc2a2dbba142105bc4010442781abb5ee0f82 Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Thu, 29 May 2025 11:21:08 +0100 Subject: [PATCH] skyhigh: shows a window above everythign else now just shows wherre the mouse can be warped --- DockPhobia.xcodeproj/project.pbxproj | 4 +++ DockPhobia/AppDelegate.swift | 2 +- DockPhobia/MouseTracker.swift | 29 +++++++++++++++- DockPhobia/SkyHigh.swift | 52 ++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 DockPhobia/SkyHigh.swift diff --git a/DockPhobia.xcodeproj/project.pbxproj b/DockPhobia.xcodeproj/project.pbxproj index 6b4e102..bb73c21 100644 --- a/DockPhobia.xcodeproj/project.pbxproj +++ b/DockPhobia.xcodeproj/project.pbxproj @@ -13,6 +13,7 @@ A966B4F82DE0852900C721A5 /* MouseTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = A966B4F72DE0852900C721A5 /* MouseTracker.swift */; }; 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 */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -25,6 +26,7 @@ A97798072DE485F200B6CB13 /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; A98C20C52DE614180008D61C /* DPSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DPSettings.swift; sourceTree = ""; }; A9C9AF802DE777530039D7A5 /* DockSide.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DockSide.swift; sourceTree = ""; }; + A9C9AF822DE77CB70039D7A5 /* SkyHigh.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SkyHigh.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -76,6 +78,7 @@ children = ( A966B4EE2DE0842400C721A5 /* AppDelegate.swift */, A966B4F72DE0852900C721A5 /* MouseTracker.swift */, + A9C9AF822DE77CB70039D7A5 /* SkyHigh.swift */, A98C20C52DE614180008D61C /* DPSettings.swift */, A9C9AF802DE777530039D7A5 /* DockSide.swift */, A94BEC102DE23ECE00D4811D /* Views */, @@ -159,6 +162,7 @@ buildActionMask = 2147483647; files = ( A98C20C62DE614180008D61C /* DPSettings.swift in Sources */, + A9C9AF832DE77CB70039D7A5 /* SkyHigh.swift in Sources */, A966B4F82DE0852900C721A5 /* MouseTracker.swift in Sources */, A966B4F42DE0842500C721A5 /* AppDelegate.swift in Sources */, A9C9AF812DE7776A0039D7A5 /* DockSide.swift in Sources */, diff --git a/DockPhobia/AppDelegate.swift b/DockPhobia/AppDelegate.swift index 534637e..3152c91 100644 --- a/DockPhobia/AppDelegate.swift +++ b/DockPhobia/AppDelegate.swift @@ -7,7 +7,7 @@ import AppKit -@main +@NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { public var statusItem: NSStatusItem! diff --git a/DockPhobia/MouseTracker.swift b/DockPhobia/MouseTracker.swift index 16efba5..612b39e 100644 --- a/DockPhobia/MouseTracker.swift +++ b/DockPhobia/MouseTracker.swift @@ -23,6 +23,7 @@ class MouseTracker { var dockHeight: CGFloat = 0 var settings: DPSettingsModel + var skyHigh = SkyHigh() init(settings: DPSettingsModel) { print(DockSide()) @@ -97,7 +98,7 @@ class MouseTracker { func moveDockOrMouse(_ dockTo: DockSide) { if settings.settings.moveMouseInstead { - print("move mouse") + moveMouse() } else { moveDock(dockTo) } @@ -107,6 +108,24 @@ class MouseTracker { self.monitor = NSEvent.addGlobalMonitorForEvents(matching: .mouseMoved, handler: checkMouse) self.running = true print("started tracking") + + + + + + + skyHigh.move() + + + + + + + + + + + } func stop() { @@ -118,6 +137,14 @@ class MouseTracker { print("stop tracking") } + func moveMouse() { + let rangeW = screen.width*0.1...screen.width*0.9 + let posX = CGFloat.random(in: rangeW) + let rangeH = screen.height*0.1...screen.height*0.9 + let posY = CGFloat.random(in: rangeH) + CGDisplayMoveCursorToPoint(0, CGPoint(x: posX, y: posY)) + } + func moveDock(_ toSide: DockSide) { guard currentDockSide != toSide else { return } // let scriptHide = """ diff --git a/DockPhobia/SkyHigh.swift b/DockPhobia/SkyHigh.swift new file mode 100644 index 0000000..9db894a --- /dev/null +++ b/DockPhobia/SkyHigh.swift @@ -0,0 +1,52 @@ +// +// SkyHigh.swift +// DockPhobia +// +// Created by neon443 on 28/05/2025. +// + +import Foundation +import Cocoa + +class SkyHigh { + private var window: NSWindow + private var x = 1 + private var timer: Timer? + + init() { + guard let screen = NSScreen.main?.frame else { fatalError() } + self.window = NSWindow( + contentRect: CGRect( + x: screen.width*0.05, + y: screen.height*0.1, + width: screen.width*0.9, + height: screen.height*0.8 + ), + styleMask: .borderless, + backing: .buffered, + defer: false + ) + window.backgroundColor = .init(srgbRed: 1, green: 1, blue: 1, alpha: 0.1) + window.isOpaque = false + window.level = NSWindow.Level.statusBar + 1 + window.ignoresMouseEvents = true + window.hasShadow = true + window.makeKeyAndOrderFront(nil) + window.setFrameOrigin(NSPoint(x: screen.width*0.05, y: screen.height*0.1)) + } + + func move() { + x = 1 + timer?.invalidate() + timer = Timer(timeInterval: 0.01, repeats: true) { [weak self] _ in + guard let self = self else { return } + guard x < 1001 else { + timer?.invalidate() + return + } + self.window.setFrameOrigin(NSPoint(x: 1000-self.x, y: 1000-self.x)) + self.x += 1 + } + RunLoop.current.add(timer!, forMode: .common) + } +}