add mouse moves count

tweak the aligment of the pinch
added mouse move count to menu bar,
grammar fix
This commit is contained in:
neon443
2025-05-29 16:11:41 +01:00
parent 83efb14bd5
commit d943415b98
4 changed files with 27 additions and 10 deletions

View File

@@ -55,6 +55,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {
keyEquivalent: ""
)
menu.addItem(dockMoves)
let mouseMoves = NSMenuItem(
title: "Moved the cursor \(settings.settings.mouseMoves) time\(settings.settings.mouseMoves.plural)",
action: nil,
keyEquivalent: ""
)
menu.addItem(mouseMoves)
menu.addItem(NSMenuItem.separator())
let moveMouseButton = NSMenuItem(
@@ -77,15 +84,15 @@ class AppDelegate: NSObject, NSApplicationDelegate {
menu.addItem(NSMenuItem.separator())
menu.addItem(NSMenuItem(
title: "Move Dock to left",
title: "Move Dock to the left",
action: #selector(moveDockObjcLeft),
keyEquivalent: ""))
menu.addItem(NSMenuItem(
title: "Move Dock to bottom",
title: "Move Dock to the bottom",
action: #selector(moveDockObjcBottom),
keyEquivalent: ""))
menu.addItem(NSMenuItem(
title: "Move Dock to right",
title: "Move Dock to the right",
action: #selector(moveDockObjcRight),
keyEquivalent: ""))
menu.addItem(NSMenuItem.separator())

View File

@@ -22,6 +22,7 @@ extension NSScreen {
struct DPSettings: Codable {
var dockMoves: Int
var mouseMoves: Int
var checkFullscreen: Bool
var moveMouseInstead: Bool
@@ -52,12 +53,14 @@ struct DPSettings: Codable {
init(
dockMoves: Int = 0,
mouseMoves: Int = 0,
checkFullscreen: Bool = false,
moveMouseInstead: Bool = false,
insetHorizontal: CGFloat = 0.05,
insetVertical: CGFloat = 0.1
) {
self.dockMoves = dockMoves
self.mouseMoves = mouseMoves
self.checkFullscreen = checkFullscreen
self.moveMouseInstead = moveMouseInstead
self.insetHorizontal = insetHorizontal
@@ -69,6 +72,8 @@ struct DPSettings: Codable {
let container = try decoder.container(keyedBy: CodingKeys.self)
dockMoves = try container.decodeIfPresent(Int.self, forKey: .dockMoves)
?? defaults.dockMoves
mouseMoves = try container.decodeIfPresent(Int.self, forKey: .mouseMoves)
?? defaults.mouseMoves
checkFullscreen = try container.decodeIfPresent(Bool.self, forKey: .checkFullscreen)
?? defaults.checkFullscreen

View File

@@ -64,10 +64,12 @@ class MouseTracker {
func checkMouse(_ event: NSEvent) {
let location = event.mouseLocationCG
// var cgpointForSkyHigh = NSEvent.mouseLocation
// cgpointForSkyHigh.x -= 10
// cgpointForSkyHigh.y -= 5
// skyHigh.move(to: cgpointForSkyHigh)
#if DEBUG
var cgpointForSkyHigh = NSEvent.mouseLocation
cgpointForSkyHigh.x -= 20
cgpointForSkyHigh.y -= 5
skyHigh.move(to: cgpointForSkyHigh)
#endif
guard settings.settings.checkFullscreen else {
handleDockValue(dockIsAt: currentDockSide, location: location)
@@ -145,8 +147,6 @@ class MouseTracker {
let posX = CGFloat.random(in: rangeW)
let rangeH = settings.settings.mouseInsetBottom...settings.settings.mouseInsetTop
let posY = CGFloat.random(in: rangeH)
print(prevPoint)
print(posX, posY)
timer?.invalidate()
loopIteration = 0
@@ -156,6 +156,8 @@ class MouseTracker {
guard let self = self else { return }
guard loopIteration < 500 else {
skyHigh.hide()
settings.settings.mouseMoves += 1
refreshMenus()
timer?.invalidate()
return
}
@@ -164,7 +166,7 @@ class MouseTracker {
let cgpoint = CGPoint(x: newPosX, y: newPosY)
CGWarpMouseCursorPosition(cgpoint)
var cgpointForSkyHigh = cgpoint
cgpointForSkyHigh.x -= 10
cgpointForSkyHigh.x -= 20
cgpointForSkyHigh.y += 5
skyHigh.move(to: cgpointForSkyHigh.invertedForScreen)

View File

@@ -35,6 +35,9 @@ class SkyHigh {
window.ignoresMouseEvents = true
window.hasShadow = true
window.collectionBehavior = NSWindow.CollectionBehavior.canJoinAllSpaces.union(.stationary)
#if DEBUG
show()
#endif
}
func move(to: CGPoint) {