mirror of
https://github.com/neon443/DockPhobia.git
synced 2026-03-11 06:49:12 +00:00
got a pinch lollll
This commit is contained in:
BIN
DockPhobia/.DS_Store
vendored
BIN
DockPhobia/.DS_Store
vendored
Binary file not shown.
@@ -18,6 +18,15 @@ extension NSEvent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension CGPoint {
|
||||||
|
var invertedForScreen: CGPoint {
|
||||||
|
return CGPoint(
|
||||||
|
x: self.x,
|
||||||
|
y: NSScreen.mainFrameHeight - self.y
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct Screen {
|
struct Screen {
|
||||||
var width: CGFloat
|
var width: CGFloat
|
||||||
var height: CGFloat
|
var height: CGFloat
|
||||||
@@ -55,7 +64,10 @@ class MouseTracker {
|
|||||||
|
|
||||||
func checkMouse(_ event: NSEvent) {
|
func checkMouse(_ event: NSEvent) {
|
||||||
let location = event.mouseLocationCG
|
let location = event.mouseLocationCG
|
||||||
skyHigh.move(to: NSEvent.mouseLocation)
|
// var cgpointForSkyHigh = NSEvent.mouseLocation
|
||||||
|
// cgpointForSkyHigh.x -= 10
|
||||||
|
// cgpointForSkyHigh.y -= 5
|
||||||
|
// skyHigh.move(to: cgpointForSkyHigh)
|
||||||
|
|
||||||
guard settings.settings.checkFullscreen else {
|
guard settings.settings.checkFullscreen else {
|
||||||
handleDockValue(dockIsAt: currentDockSide, location: location)
|
handleDockValue(dockIsAt: currentDockSide, location: location)
|
||||||
@@ -138,14 +150,12 @@ class MouseTracker {
|
|||||||
|
|
||||||
timer?.invalidate()
|
timer?.invalidate()
|
||||||
loopIteration = 0
|
loopIteration = 0
|
||||||
skyHigh.move(to: prevPoint)
|
skyHigh.move(to: prevPoint.invertedForScreen)
|
||||||
timer = Timer(timeInterval: 0.001, repeats: true) { [weak self] _ in
|
skyHigh.show()
|
||||||
|
timer = Timer(timeInterval: 0.005, repeats: true) { [weak self] _ in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
guard NSEvent().mouseLocationCG != CGPoint(x: posX, y: posX) else {
|
guard loopIteration < 500 else {
|
||||||
timer?.invalidate()
|
skyHigh.hide()
|
||||||
return
|
|
||||||
}
|
|
||||||
guard loopIteration < 1000 else {
|
|
||||||
timer?.invalidate()
|
timer?.invalidate()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -153,9 +163,12 @@ class MouseTracker {
|
|||||||
let newPosY = (prevPoint.y > posY ? prevPoint.y-loopIteration : prevPoint.y+loopIteration)
|
let newPosY = (prevPoint.y > posY ? prevPoint.y-loopIteration : prevPoint.y+loopIteration)
|
||||||
let cgpoint = CGPoint(x: newPosX, y: newPosY)
|
let cgpoint = CGPoint(x: newPosX, y: newPosY)
|
||||||
CGWarpMouseCursorPosition(cgpoint)
|
CGWarpMouseCursorPosition(cgpoint)
|
||||||
skyHigh.move(to: cgpoint)
|
var cgpointForSkyHigh = cgpoint
|
||||||
|
cgpointForSkyHigh.x -= 10
|
||||||
|
cgpointForSkyHigh.y += 5
|
||||||
|
skyHigh.move(to: cgpointForSkyHigh.invertedForScreen)
|
||||||
|
|
||||||
self.loopIteration += 4
|
self.loopIteration += 1
|
||||||
}
|
}
|
||||||
RunLoop.main.add(timer!, forMode: .common)
|
RunLoop.main.add(timer!, forMode: .common)
|
||||||
}
|
}
|
||||||
|
|||||||
22
DockPhobia/Resources/Assets.xcassets/pinch.imageset/Contents.json
vendored
Normal file
22
DockPhobia/Resources/Assets.xcassets/pinch.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "pinch 1.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "pinch.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
DockPhobia/Resources/Assets.xcassets/pinch.imageset/pinch 1.png
vendored
Normal file
BIN
DockPhobia/Resources/Assets.xcassets/pinch.imageset/pinch 1.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.8 KiB |
BIN
DockPhobia/Resources/Assets.xcassets/pinch.imageset/pinch.png
vendored
Normal file
BIN
DockPhobia/Resources/Assets.xcassets/pinch.imageset/pinch.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.8 KiB |
@@ -21,23 +21,31 @@ class SkyHigh {
|
|||||||
contentRect: CGRect(
|
contentRect: CGRect(
|
||||||
x: NSScreen.mainFrameWidth/2,
|
x: NSScreen.mainFrameWidth/2,
|
||||||
y: NSScreen.mainFrameHeight/2,
|
y: NSScreen.mainFrameHeight/2,
|
||||||
width: 50,
|
width: 100,
|
||||||
height: 50
|
height: 100
|
||||||
),
|
),
|
||||||
styleMask: .borderless,
|
styleMask: .borderless,
|
||||||
backing: .buffered,
|
backing: .buffered,
|
||||||
defer: false
|
defer: false
|
||||||
)
|
)
|
||||||
window.backgroundColor = .init(srgbRed: 1, green: 1, blue: 1, alpha: 0.2)
|
window.backgroundColor = .init(srgbRed: 1, green: 1, blue: 1, alpha: 0)
|
||||||
|
window.contentView = NSImageView(image: NSImage(named: "pinch")!)
|
||||||
window.isOpaque = false
|
window.isOpaque = false
|
||||||
window.level = NSWindow.Level.statusBar + 1
|
window.level = NSWindow.Level.statusBar + 1
|
||||||
window.ignoresMouseEvents = true
|
window.ignoresMouseEvents = true
|
||||||
window.hasShadow = true
|
window.hasShadow = true
|
||||||
window.collectionBehavior = NSWindow.CollectionBehavior.canJoinAllSpaces.union(.stationary)
|
window.collectionBehavior = NSWindow.CollectionBehavior.canJoinAllSpaces.union(.stationary)
|
||||||
window.makeKeyAndOrderFront(nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func move(to: CGPoint) {
|
func move(to: CGPoint) {
|
||||||
self.window.setFrameOrigin(to)
|
self.window.setFrameOrigin(to)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func show() {
|
||||||
|
window.orderFront(nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func hide() {
|
||||||
|
window.orderOut(nil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user