fix: show alt-tab own windows in the thumbnail panel
This commit is contained in:
1 parent
8962489989
commit
6018a531e8
4 files changed
+10
-9
No files matched your search
@@ -13,13 +13,15 @@ extension AXUIElement {
|
||||
return pid
|
||||
}
|
||||
|
||||
func isActualWindow(_ isAppHidden: Bool = false) -> Bool {
|
||||
func isActualWindow(_ runningApplication: NSRunningApplication) -> Bool {
|
||||
// TODO: TotalFinder and XtraFinder double-window hacks (see #84)
|
||||
// Some non-windows have subrole: nil (e.g. some OS elements), "AXUnknown" (e.g. Bartender), "AXSystemDialog" (e.g. Intellij tooltips)
|
||||
// Some non-windows have title: nil (e.g. some OS elements)
|
||||
// Minimized windows or windows of a hidden app have subrole "AXDialog"
|
||||
// Activity Monitor main window subrole is "AXDialog" for a brief moment at launch; it then becomes "AXStandardWindow"
|
||||
return title() != nil && (["AXStandardWindow", "AXDialog"].contains(subrole()) || isMinimized() || isAppHidden) && isOnNormalLevel()
|
||||
return title() != nil &&
|
||||
(["AXStandardWindow", "AXDialog"].contains(subrole()) || isMinimized() || runningApplication.isHidden) &&
|
||||
isOnNormalLevel()
|
||||
}
|
||||
|
||||
func isOnNormalLevel() -> Bool {
|
||||
|
||||
@@ -49,8 +49,7 @@ class Application: NSObject {
|
||||
|
||||
func observeNewWindows() {
|
||||
let newWindows = axUiElement!.windows()?
|
||||
.filter { $0.isActualWindow(runningApplication.isHidden) }
|
||||
.filter { Windows.list.firstIndexThatMatches($0) == nil } ?? []
|
||||
.filter { $0.isActualWindow(runningApplication) && Windows.list.firstIndexThatMatches($0) == nil } ?? []
|
||||
addWindows(newWindows)
|
||||
}
|
||||
|
||||
@@ -113,7 +112,7 @@ private func eventApplicationHiddenOrShown(_ app: App, _ element: AXUIElement, _
|
||||
}
|
||||
|
||||
private func eventWindowCreated(_ app: App, _ element: AXUIElement, _ application: Application) {
|
||||
guard element.isActualWindow() else { return }
|
||||
guard element.isActualWindow(application.runningApplication) else { return }
|
||||
// a window being un-minimized can trigger kAXWindowCreatedNotification
|
||||
guard Windows.list.firstIndexThatMatches(element) == nil else { return }
|
||||
let window = Window(element, application)
|
||||
|
||||
@@ -66,7 +66,7 @@ class Applications {
|
||||
private static func filterApplications(_ apps: [NSRunningApplication]) -> [NSRunningApplication] {
|
||||
// it would be nice to filter with $0.activationPolicy != .prohibited (see https://stackoverflow.com/a/26002033/2249756)
|
||||
// however some daemon processes can sometimes create windows, so we can't filter them out (e.g. CopyQ is .prohibited for some reason)
|
||||
return apps.filter { $0.bundleIdentifier != nil && $0.bundleIdentifier != NSRunningApplication.current.bundleIdentifier }
|
||||
return apps.filter { $0.bundleIdentifier != nil }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ class ThumbnailsPanel: NSPanel, NSCollectionViewDataSource, NSCollectionViewDele
|
||||
var backgroundView: NSVisualEffectView!
|
||||
var collectionView: NSCollectionView!
|
||||
var app: App?
|
||||
let cellId = NSUserInterfaceItemIdentifier("Cell")
|
||||
var currentScreen: NSScreen?
|
||||
static let cellId = NSUserInterfaceItemIdentifier("Cell")
|
||||
|
||||
convenience init(_ app: App) {
|
||||
self.init()
|
||||
@@ -50,7 +50,7 @@ class ThumbnailsPanel: NSPanel, NSCollectionViewDataSource, NSCollectionViewDele
|
||||
collectionView.backgroundColors = [.clear]
|
||||
collectionView.isSelectable = true
|
||||
collectionView.allowsMultipleSelection = false
|
||||
collectionView.register(CollectionViewItem.self, forItemWithIdentifier: cellId)
|
||||
collectionView.register(CollectionViewItem.self, forItemWithIdentifier: ThumbnailsPanel.cellId)
|
||||
}
|
||||
|
||||
private func makeLayout() -> CollectionViewFlowLayout {
|
||||
@@ -65,7 +65,7 @@ class ThumbnailsPanel: NSPanel, NSCollectionViewDataSource, NSCollectionViewDele
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: NSCollectionView, itemForRepresentedObjectAt indexPath: IndexPath) -> NSCollectionViewItem {
|
||||
let item = collectionView.makeItem(withIdentifier: cellId, for: indexPath) as! CollectionViewItem
|
||||
let item = collectionView.makeItem(withIdentifier: ThumbnailsPanel.cellId, for: indexPath) as! CollectionViewItem
|
||||
item.view_.updateRecycledCellWithNewContent(Windows.list[indexPath.item],
|
||||
{ self.app!.focusSelectedWindow(item.view_.window_) },
|
||||
{ self.app!.thumbnailsPanel!.highlightCell(item) },
|
||||
|
||||
Reference in new issue
Block a user