add fullscreen support, fix dock moving to the right when hovering over menu bar icon

This commit is contained in:
neon443 committed 2025-05-27 16:34:01 +01:00
1 parent 43863d3827
commit 936f18d714
3 files changed
+42 -5

No files matched your search

BIN
View File
Binary file not shown.
+42 -5
View File
@@ -7,6 +7,8 @@
import Foundation
import AppKit
import Cocoa
import ApplicationServices
struct Screen {
var width: CGFloat
@@ -93,12 +95,23 @@ class MouseTracker {
}
func checkMouse(_ event: NSEvent) {
var location = event.locationInWindow
var location = NSEvent.mouseLocation
location.y = screen.height - location.y
#if DEBUG
print(location)
#endif
switch currentDockSide {
guard isFrontmostFullscreen() else {
if location.x < 1 ||
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:
guard location.x < dockHeight else { return }
if location.y < screen.height/2 {
@@ -187,3 +200,27 @@ class MouseTracker {
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
View File
Binary file not shown.
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.