feat: don't show glitchy windows from non-native apps (closes #562)
See #456
This commit is contained in:
1 parent
9240040ae6
commit
84dbaa06aa
3 files changed
+26
-18
No files matched your search
@@ -73,7 +73,7 @@ extension AXUIElement {
|
||||
return nil
|
||||
}
|
||||
|
||||
func isActualWindow(_ runningApp: NSRunningApplication, _ wid: CGWindowID, _ isOnNormalLevel: Bool, _ title: String?, _ subrole: String?, _ role: String?) -> Bool {
|
||||
func isActualWindow(_ runningApp: NSRunningApplication, _ wid: CGWindowID, _ isOnNormalLevel: Bool, _ title: String?, _ subrole: String?, _ role: String?, _ size: CGSize?) -> Bool {
|
||||
// Some non-windows have title: nil (e.g. some OS elements)
|
||||
// Some non-windows have subrole: nil (e.g. some OS elements), "AXUnknown" (e.g. Bartender), "AXSystemDialog" (e.g. Intellij tooltips)
|
||||
// Minimized windows or windows of a hidden app have subrole "AXDialog"
|
||||
@@ -81,20 +81,21 @@ extension AXUIElement {
|
||||
|
||||
// Some non-windows have cgWindowId == 0 (e.g. windows of apps starting at login with the checkbox "Hidden" checked)
|
||||
return wid != 0 &&
|
||||
(books(runningApp) || keynote(runningApp)) || (
|
||||
// CGWindowLevel == .normalWindow helps filter out iStats Pro and other top-level pop-overs, and floating windows
|
||||
isOnNormalLevel &&
|
||||
([kAXStandardWindowSubrole, kAXDialogSubrole].contains(subrole) ||
|
||||
openBoard(runningApp) ||
|
||||
adobeAudition(runningApp, subrole) ||
|
||||
steam(runningApp, title, role) ||
|
||||
worldOfWarcraft(runningApp, role) ||
|
||||
battleNetBootstrapper(runningApp, role) ||
|
||||
firefoxFullscreenVideo(runningApp, role) ||
|
||||
androidEmulator(runningApp, title) ||
|
||||
sanGuoShaAirWD(runningApp) ||
|
||||
dvdFab(runningApp) ||
|
||||
drBetotte(runningApp)))
|
||||
size != nil && size!.width > 100 && size!.height > 100 &&
|
||||
(books(runningApp) || keynote(runningApp) || (
|
||||
// CGWindowLevel == .normalWindow helps filter out iStats Pro and other top-level pop-overs, and floating windows
|
||||
isOnNormalLevel &&
|
||||
([kAXStandardWindowSubrole, kAXDialogSubrole].contains(subrole) ||
|
||||
openBoard(runningApp) ||
|
||||
adobeAudition(runningApp, subrole) ||
|
||||
steam(runningApp, title, role) ||
|
||||
worldOfWarcraft(runningApp, role) ||
|
||||
battleNetBootstrapper(runningApp, role) ||
|
||||
firefoxFullscreenVideo(runningApp, role) ||
|
||||
androidEmulator(runningApp, title) ||
|
||||
sanGuoShaAirWD(runningApp) ||
|
||||
dvdFab(runningApp) ||
|
||||
drBetotte(runningApp))))
|
||||
}
|
||||
|
||||
private func keynote(_ runningApp: NSRunningApplication) -> Bool {
|
||||
@@ -163,6 +164,10 @@ extension AXUIElement {
|
||||
return try value(kAXPositionAttribute, CGPoint.zero, .cgPoint)
|
||||
}
|
||||
|
||||
func size() throws -> CGSize? {
|
||||
return try value(kAXSizeAttribute, CGSize.zero, .cgSize)
|
||||
}
|
||||
|
||||
func title() throws -> String? {
|
||||
return try attribute(kAXTitleAttribute, String.self)
|
||||
}
|
||||
|
||||
@@ -83,8 +83,9 @@ class Application: NSObject {
|
||||
let title = try $0.title()
|
||||
let subrole = try $0.subrole()
|
||||
let role = try $0.role()
|
||||
let size = try $0.size()
|
||||
let isOnNormalLevel = $0.isOnNormalLevel(wid)
|
||||
if $0.isActualWindow(self.runningApplication, wid, isOnNormalLevel, title, subrole, role) {
|
||||
if $0.isActualWindow(self.runningApplication, wid, isOnNormalLevel, title, subrole, role, size) {
|
||||
return ($0, wid, title, try $0.isFullscreen(), try $0.isMinimized(), try $0.position())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,10 +85,11 @@ fileprivate func windowCreated(_ element: AXUIElement, _ pid: pid_t) throws {
|
||||
let isMinimized = try element.isMinimized()
|
||||
let isOnNormalLevel = element.isOnNormalLevel(wid)
|
||||
let position = try element.position()
|
||||
let size = try element.size()
|
||||
DispatchQueue.main.async {
|
||||
if (Windows.list.firstIndex { $0.isEqualRobust(element, wid) }) == nil,
|
||||
let runningApp = NSRunningApplication(processIdentifier: pid),
|
||||
element.isActualWindow(runningApp, wid, isOnNormalLevel, axTitle, subrole, role),
|
||||
element.isActualWindow(runningApp, wid, isOnNormalLevel, axTitle, subrole, role, size),
|
||||
let app = (Applications.list.first { $0.pid == pid }) {
|
||||
let window = Window(element, app, wid, axTitle, isFullscreen, isMinimized, position)
|
||||
Windows.appendAndUpdateFocus(window)
|
||||
@@ -112,10 +113,11 @@ fileprivate func focusedWindowChanged(_ element: AXUIElement, _ pid: pid_t) thro
|
||||
let isMinimized = try element.isMinimized()
|
||||
let isOnNormalLevel = element.isOnNormalLevel(wid)
|
||||
let position = try element.position()
|
||||
let size = try element.size()
|
||||
DispatchQueue.main.async {
|
||||
if let windows = Windows.updateLastFocus(element, wid) {
|
||||
App.app.refreshOpenUi(windows)
|
||||
} else if element.isActualWindow(runningApp, wid, isOnNormalLevel, axTitle, subrole, role),
|
||||
} else if element.isActualWindow(runningApp, wid, isOnNormalLevel, axTitle, subrole, role, size),
|
||||
let app = (Applications.list.first { $0.pid == pid }) {
|
||||
let window = Window(element, app, wid, axTitle, isFullscreen, isMinimized, position)
|
||||
Windows.appendAndUpdateFocus(window)
|
||||
|
||||
Reference in new issue
Block a user