mirror of
https://github.com/neon443/DockPhobia.git
synced 2026-03-11 06:49:12 +00:00
add fullscreen support, fix dock moving to the right when hovering over menu bar icon
This commit is contained in:
BIN
DockPhobia/.DS_Store
vendored
BIN
DockPhobia/.DS_Store
vendored
Binary file not shown.
@@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import AppKit
|
import AppKit
|
||||||
|
import Cocoa
|
||||||
|
import ApplicationServices
|
||||||
|
|
||||||
struct Screen {
|
struct Screen {
|
||||||
var width: CGFloat
|
var width: CGFloat
|
||||||
@@ -93,12 +95,23 @@ class MouseTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func checkMouse(_ event: NSEvent) {
|
func checkMouse(_ event: NSEvent) {
|
||||||
var location = event.locationInWindow
|
var location = NSEvent.mouseLocation
|
||||||
location.y = screen.height - location.y
|
location.y = screen.height - location.y
|
||||||
#if DEBUG
|
|
||||||
print(location)
|
guard isFrontmostFullscreen() else {
|
||||||
#endif
|
if location.x < 1 ||
|
||||||
switch currentDockSide {
|
location.x < screen.width-1 ||
|
||||||
|
location.y > screen.height-1 {
|
||||||
|
handleDockValue(dockIsAt: currentDockSide, location: location)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
handleDockValue(dockIsAt: currentDockSide, location: location)
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleDockValue(dockIsAt: DockSide, location: NSPoint) {
|
||||||
|
switch dockIsAt {
|
||||||
case .left:
|
case .left:
|
||||||
guard location.x < dockHeight else { return }
|
guard location.x < dockHeight else { return }
|
||||||
if location.y < screen.height/2 {
|
if location.y < screen.height/2 {
|
||||||
@@ -187,3 +200,27 @@ class MouseTracker {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isFrontmostFullscreen() -> Bool {
|
||||||
|
guard let frontmostApp = NSWorkspace.shared.frontmostApplication,
|
||||||
|
let appPID = frontmostApp.processIdentifier as pid_t? else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
let appElement = AXUIElementCreateApplication(appPID)
|
||||||
|
var frontWindo: AnyObject?
|
||||||
|
let result = AXUIElementCopyAttributeValue(appElement, kAXFocusedWindowAttribute as CFString, &frontWindo)
|
||||||
|
|
||||||
|
guard result == .success, let windowElement = frontWindo else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
var fullscreenValue: AnyObject?
|
||||||
|
let fullscreenAttr = AXUIElementCopyAttributeValue(windowElement as! AXUIElement, "AXFullScreen" as CFString, &fullscreenValue)
|
||||||
|
|
||||||
|
if fullscreenAttr == .success,
|
||||||
|
let isFullscreen = fullscreenValue as? Bool {
|
||||||
|
return isFullscreen
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|||||||
BIN
DockPhobiaPy/.DS_Store
vendored
BIN
DockPhobiaPy/.DS_Store
vendored
Binary file not shown.
Reference in New Issue
Block a user