fix: show windows which are opened in fullscreen (closes #335)
This commit is contained in:
1 parent
408b800a23
commit
2674c8f8db
6 files changed
+18
-17
No files matched your search
@@ -49,8 +49,11 @@ extension AXUIElement {
|
||||
return attribute(kAXWindowsAttribute, [AXUIElement].self)
|
||||
}
|
||||
|
||||
func isTabbed(_ window: AXUIElement) -> Bool {
|
||||
return windows()?.first { $0 == window } == nil
|
||||
func isTabbed(_ app: AXUIElement, _ spaceId: CGSSpaceID) -> Bool {
|
||||
// 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
|
||||
return spaceId == Spaces.currentSpaceId && !isFullScreen() &&
|
||||
app.windows()?.first { $0 == self } == nil
|
||||
}
|
||||
|
||||
func isMinimized() -> Bool {
|
||||
|
||||
@@ -81,8 +81,8 @@ class DebugProfile {
|
||||
("isMinimized", String(window.isMinimized)),
|
||||
("isHidden", String(window.isHidden)),
|
||||
("isOnAllSpaces", String(window.isOnAllSpaces)),
|
||||
("spaceId", window.spaceId.flatMap { String($0) } ?? "nil"),
|
||||
("spaceIndex", window.spaceIndex.flatMap { String($0) } ?? "nil"),
|
||||
("spaceId", String(window.spaceId)),
|
||||
("spaceIndex", String(window.spaceIndex)),
|
||||
])
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ class Window {
|
||||
var isHidden: Bool
|
||||
var isMinimized: Bool
|
||||
var isOnAllSpaces: Bool
|
||||
var spaceId: CGSSpaceID?
|
||||
var spaceIndex: SpaceIndex?
|
||||
var spaceId: CGSSpaceID
|
||||
var spaceIndex: SpaceIndex
|
||||
var axUiElement: AXUIElement
|
||||
var application: Application
|
||||
var axObserver: AXObserver?
|
||||
@@ -30,12 +30,12 @@ class Window {
|
||||
self.axUiElement = axUiElement
|
||||
self.application = application
|
||||
self.cgWindowId = axUiElement.cgWindowId()
|
||||
self.icon = application.runningApplication.icon
|
||||
self.isTabbed = application.axUiElement!.isTabbed(axUiElement)
|
||||
self.isHidden = application.runningApplication.isHidden
|
||||
self.isMinimized = axUiElement.isMinimized()
|
||||
self.spaceId = Spaces.currentSpaceId
|
||||
self.spaceIndex = Spaces.currentSpaceIndex
|
||||
self.icon = application.runningApplication.icon
|
||||
self.isTabbed = axUiElement.isTabbed(application.axUiElement!, spaceId)
|
||||
self.isHidden = application.runningApplication.isHidden
|
||||
self.isMinimized = axUiElement.isMinimized()
|
||||
self.isOnAllSpaces = false
|
||||
self.title = Window.bestEffortTitle(axUiElement, cgWindowId, application)
|
||||
debugPrint("Adding window", cgWindowId, title, application.runningApplication.bundleIdentifier ?? "nil", Spaces.currentSpaceId, Spaces.currentSpaceIndex)
|
||||
|
||||
@@ -21,11 +21,10 @@ func axObserverCallback(observer: AXObserver, element: AXUIElement, notification
|
||||
|
||||
private func focusedUiElementChanged(_ element: AXUIElement, _ applicationPointer: UnsafeMutableRawPointer?) {
|
||||
// this event is the only opportunity we have to check if a window became a tab, or a tab became a window
|
||||
// we can only detect tabs for windows on the current space, as AXUIElement.windows() only reports current space windows
|
||||
let application = Unmanaged<Application>.fromOpaque(applicationPointer!).takeUnretainedValue()
|
||||
Windows.list.forEach {
|
||||
if $0.spaceId == Spaces.currentSpaceId && $0.application == application {
|
||||
$0.isTabbed = application.axUiElement!.isTabbed($0.axUiElement)
|
||||
if $0.application == application {
|
||||
$0.isTabbed = $0.axUiElement.isTabbed(application.axUiElement!, $0.spaceId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -189,9 +189,8 @@ class App: NSApplication, NSApplicationDelegate {
|
||||
debugPrint("showUiOrCycleSelection: isFirstSummon")
|
||||
isFirstSummon = false
|
||||
if Windows.list.count == 0 || CGWindow.isMissionControlActive() { hideUi(); return }
|
||||
// TODO: find a way to update isSingleSpace by listening to space creation, instead of on every trigger
|
||||
// TODO: find a way to update space info when spaces are changed, instead of on every trigger
|
||||
Spaces.idsAndIndexes = Spaces.allIdsAndIndexes()
|
||||
// TODO: find a way to update space index when windows are moved to another space, instead of on every trigger
|
||||
Windows.updateSpaces()
|
||||
let screen = Screen.preferred()
|
||||
Windows.refreshWhichWindowsToShowTheUser(screen)
|
||||
|
||||
@@ -79,12 +79,12 @@ class ThumbnailView: NSStackView {
|
||||
}
|
||||
assignIfDifferent(&hiddenIcon.isHidden, !element.isHidden)
|
||||
assignIfDifferent(&minimizedIcon.isHidden, !element.isMinimized)
|
||||
assignIfDifferent(&spaceIcon.isHidden, element.spaceIndex == nil || Spaces.isSingleSpace || Preferences.hideSpaceNumberLabels)
|
||||
assignIfDifferent(&spaceIcon.isHidden, Spaces.isSingleSpace || Preferences.hideSpaceNumberLabels)
|
||||
if !spaceIcon.isHidden {
|
||||
if element.isOnAllSpaces {
|
||||
spaceIcon.setStar()
|
||||
} else {
|
||||
spaceIcon.setNumber(UInt32(element.spaceIndex!))
|
||||
spaceIcon.setNumber(UInt32(element.spaceIndex))
|
||||
}
|
||||
}
|
||||
assignIfDifferent(&frame.size.width, max(thumbnail.frame.size.width + Preferences.intraCellPadding * 2, ThumbnailView.widthMin(screen)))
|
||||
|
||||
Reference in new issue
Block a user