mirror of
https://github.com/lwouis/alt-tab-macos.git
synced 2026-05-24 11:20:36 +00:00
feat: improve support for scrcpy always-on-top windows
This commit is contained in:
committed by
Louis Pontoise
parent
f9f1c19b84
commit
06733812e6
@@ -89,7 +89,8 @@ extension AXUIElement {
|
||||
keynote(runningApp) ||
|
||||
iina(runningApp) ||
|
||||
openFlStudio(runningApp, title) ||
|
||||
crossoverWindow(runningApp, role, subrole, level)
|
||||
crossoverWindow(runningApp, role, subrole, level) ||
|
||||
isAlwaysOnTopScrcpy(runningApp, level, role, subrole)
|
||||
) || (
|
||||
// CGWindowLevel == .normalWindow helps filter out iStats Pro and other top-level pop-overs, and floating windows
|
||||
level == CGWindow.normalLevel && (
|
||||
@@ -218,6 +219,12 @@ extension AXUIElement {
|
||||
&& (runningApp.localizedName == "wine64-preloader" || runningApp.executableURL?.absoluteString.contains("/winetemp-") ?? false)
|
||||
}
|
||||
|
||||
private static func isAlwaysOnTopScrcpy(_ runningApp: NSRunningApplication, _ level: CGWindowLevel, _ role: String?, _ subrole: String?) -> Bool {
|
||||
// scrcpy presents as a floating window when "Always on top" is enabled, so it doesn't get picked up normally.
|
||||
// It also doesn't have a bundle ID, so we need to match using the localized name, which should always be the same.
|
||||
return runningApp.localizedName == "scrcpy" && level == CGWindow.floatingWindow && role == kAXWindowRole && subrole == kAXStandardWindowSubrole
|
||||
}
|
||||
|
||||
func position() throws -> CGPoint? {
|
||||
return try value(kAXPositionAttribute, CGPoint.zero, .cgPoint)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ typealias CGWindow = [CFString: Any]
|
||||
extension CGWindow {
|
||||
static let normalLevel = CGWindowLevelForKey(.normalWindow)
|
||||
static let baseLevel = CGWindowLevelForKey(.baseWindow)
|
||||
static let floatingWindow = CGWindowLevelForKey(.floatingWindow)
|
||||
|
||||
static func windows(_ option: CGWindowListOption) -> [CGWindow] {
|
||||
return CGWindowListCopyWindowInfo([.excludeDesktopElements, option], kCGNullWindowID) as! [CGWindow]
|
||||
|
||||
Reference in New Issue
Block a user