fix: show the android emulator (closes #653)
This commit is contained in:
1 parent
d825efa1f1
commit
16c7a9319a
3 files changed
+12
-11
No files matched your search
@@ -145,14 +145,7 @@ extension AXUIElement {
|
||||
|
||||
private func androidEmulator(_ runningApp: NSRunningApplication, _ title: String?) -> Bool {
|
||||
// android emulator small vertical menu is a "window" with empty title; we exclude it
|
||||
if title != "",
|
||||
// NSRunningApplication provides no way to identify the emulator; we pattern match on its KERN_PROCARGS
|
||||
runningApp.bundleIdentifier == nil,
|
||||
let executablePath = Sysctl.run([CTL_KERN, KERN_PROCARGS, runningApp.processIdentifier]) {
|
||||
// example path: ~/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-x86_64
|
||||
return executablePath.range(of: "qemu-system[^/]*$", options: .regularExpression, range: nil, locale: nil) != nil
|
||||
}
|
||||
return false
|
||||
return title != "" && Applications.isAndroidEmulator(runningApp)
|
||||
}
|
||||
|
||||
func isOnNormalLevel(_ wid: CGWindowID) -> Bool {
|
||||
|
||||
@@ -83,7 +83,6 @@ class Application: NSObject {
|
||||
let subrole = try $0.subrole()
|
||||
let role = try $0.role()
|
||||
let isOnNormalLevel = $0.isOnNormalLevel(wid)
|
||||
debugPrint(self.runningApplication.bundleIdentifier, wid, isOnNormalLevel, title, subrole, role)
|
||||
if $0.isActualWindow(self.runningApplication, wid, isOnNormalLevel, title, subrole, role) {
|
||||
return ($0, wid, title, try $0.isFullscreen(), try $0.isMinimized(), try $0.position())
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ class Applications {
|
||||
|
||||
private static func isActualApplication(_ app: NSRunningApplication) -> Bool {
|
||||
// an app can be both activationPolicy == .accessory and XPC (e.g. com.apple.dock.etci)
|
||||
return app.activationPolicy != .prohibited && isNotXpc(app) && !app.processIdentifier.isZombie()
|
||||
return (app.activationPolicy != .prohibited || isAndroidEmulator(app)) && isNotXpc(app) && !app.processIdentifier.isZombie()
|
||||
}
|
||||
|
||||
private static func isNotXpc(_ app: NSRunningApplication) -> Bool {
|
||||
@@ -111,7 +111,6 @@ class Applications {
|
||||
GetProcessForPID(app.processIdentifier, &psn)
|
||||
var info = ProcessInfoRec()
|
||||
GetProcessInformation(&psn, &info)
|
||||
debugPrint(app.bundleIdentifier, String(info.processType))
|
||||
return String(info.processType) != "XPC!"
|
||||
}
|
||||
|
||||
@@ -120,4 +119,14 @@ class Applications {
|
||||
private static func notAltTab(_ app: NSRunningApplication) -> Bool {
|
||||
return app.processIdentifier != ProcessInfo.processInfo.processIdentifier
|
||||
}
|
||||
|
||||
static func isAndroidEmulator(_ app: NSRunningApplication) -> Bool {
|
||||
// NSRunningApplication provides no way to identify the emulator; we pattern match on its KERN_PROCARGS
|
||||
if app.bundleIdentifier == nil,
|
||||
let executablePath = Sysctl.run([CTL_KERN, KERN_PROCARGS, app.processIdentifier]) {
|
||||
// example path: ~/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-x86_64
|
||||
return executablePath.range(of: "qemu-system[^/]*$", options: .regularExpression, range: nil, locale: nil) != nil
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user