fix: issue when selecting windowless app from fullscreen window

This commit is contained in:
Louis Pontoise authored and lwouis committed 2020-09-05 04:01:32 +09:00
1 parent 58e902600a
commit 657c9e5e8b
2 files changed
+11 -28

No files matched your search

-15
View File
@@ -40,10 +40,8 @@ class Window {
self.spaceIndex = Spaces.currentSpaceIndex
self.isFullscreen = isFullscreen
self.isMinimized = isMinimized
self.isOnAllSpaces = false
self.position = position
self.title = bestEffortTitle(axTitle)
self.isTabbed = false
if !Preferences.hideThumbnails {
refreshThumbnail()
}
@@ -81,19 +79,6 @@ class Window {
thumbnailFullSize = thumbnail!.size
}
func refreshIsTabbed(_ currentWindows: [AXUIElement]) {
if (currentWindows.first { $0 == axUiElement } != nil) {
isTabbed = false
}
// we can only detect tabs for windows on the current space, as AXUIElement.windows() only reports current space windows
// also, windows that start in fullscreen will have the wrong spaceID at that point in time, so we check if they are fullscreen too
else if spaceId == Spaces.currentSpaceId &&
// quirk with AltTab listing no windows at first; we force it to false
application.runningApplication.bundleIdentifier != App.id {
isTabbed = true
}
}
func close() {
if isWindowlessApp { return }
BackgroundWork.accessibilityCommandsQueue.asyncWithCap { [weak self] in
+11 -13
View File
@@ -52,20 +52,18 @@ func handleEvent(_ type: String, _ element: AXUIElement) throws {
}
private func focusedUiElementChanged(_ element: AXUIElement, _ pid: pid_t) throws {
let appAxUiElement = AXUIElementCreateApplication(pid)
if let currentWindows = try appAxUiElement.windows() {
DispatchQueue.main.async {
let windows = Windows.list.filter { w in
// for AXUIElement of apps, CFEqual or == don't work; looks like a Cocoa bug
let isFromApp = w.application.pid == pid
if isFromApp {
// this event is the only opportunity we have to check if a window became a tab, or a tab became a window
let oldIsTabbed = w.isTabbed
w.refreshIsTabbed(currentWindows)
return oldIsTabbed != w.isTabbed
}
return false
if let app = NSRunningApplication(processIdentifier: pid) {
let currentWindows = try AXUIElementCreateApplication(pid).windows()
let windows = Windows.list.filter { w in
if w.application.pid == pid && pid != ProcessInfo.processInfo.processIdentifier &&
w.spaceId == Spaces.currentSpaceId {
let oldIsTabbed = w.isTabbed
w.isTabbed = (currentWindows?.first { $0 == w.axUiElement } == nil) ?? true
return oldIsTabbed != w.isTabbed
}
return false
}
DispatchQueue.main.async {
App.app.refreshOpenUi(windows)
}
}