fix: windows assigned to all spaces were not shown (closes #2123)

This commit is contained in:
Louis Pontoise committed 2022-11-16 22:19:24 +01:00
1 parent ebf445e3e1
commit 82cfb62804
4 files changed
+8 -6

No files matched your search

+1
View File
@@ -113,6 +113,7 @@ func CGSCopyManagedDisplaySpaces(_ cid: CGSConnectionID) -> CFArray
struct CGSCopyWindowsOptions: OptionSet {
let rawValue: Int
static let minimizedAndTabbed = CGSCopyWindowsOptions(rawValue: 1 << 0)
// retrieves windows when their app is assigned to All Spaces, and windows at ScreenSaver level 1000
static let screenSaverLevel1000 = CGSCopyWindowsOptions(rawValue: 1 << 1)
static let minimized2 = CGSCopyWindowsOptions(rawValue: 1 << 2)
static let unknown1 = CGSCopyWindowsOptions(rawValue: 1 << 3)
+2 -2
View File
@@ -31,8 +31,8 @@ class Applications {
static func addInitialRunningApplicationsWindows() {
let otherSpaces = Spaces.otherSpaces()
if otherSpaces.count > 0 {
let windowsOnCurrentSpace = Spaces.windowsInSpaces([Spaces.currentSpaceId], [.minimizedAndTabbed])
let windowsOnOtherSpaces = Spaces.windowsInSpaces(otherSpaces, [.minimizedAndTabbed])
let windowsOnCurrentSpace = Spaces.windowsInSpaces([Spaces.currentSpaceId])
let windowsOnOtherSpaces = Spaces.windowsInSpaces(otherSpaces)
let windowsOnlyOnOtherSpaces = Array(Set(windowsOnOtherSpaces).subtracting(windowsOnCurrentSpace))
if windowsOnlyOnOtherSpaces.count > 0 {
// on initial launch, we use private APIs to bring windows from other spaces into the current space, observe them, then remove them from the current space
+3 -2
View File
@@ -69,10 +69,11 @@ class Spaces {
return idsAndIndexes.filter { $0.0 != currentSpaceId }.map { $0.0 }
}
static func windowsInSpaces(_ spaceIds: [CGSSpaceID], _ options: CGSCopyWindowsOptions) -> [CGWindowID] {
static func windowsInSpaces(_ spaceIds: [CGSSpaceID]) -> [CGWindowID] {
var set_tags = ([] as CGSCopyWindowsTags).rawValue
var clear_tags = ([] as CGSCopyWindowsTags).rawValue
return CGSCopyWindowsWithOptionsAndTags(cgsMainConnectionId, 0, spaceIds as CFArray, options.rawValue, &set_tags, &clear_tags) as! [CGWindowID]
let options = ([.minimizedAndTabbed, .screenSaverLevel1000] as CGSCopyWindowsOptions).rawValue
return CGSCopyWindowsWithOptionsAndTags(cgsMainConnectionId, 0, spaceIds as CFArray, options, &set_tags, &clear_tags) as! [CGWindowID]
}
static func isSingleSpace() -> Bool {
+2 -2
View File
@@ -161,7 +161,7 @@ class Windows {
/// tabs detection is a flaky work-around the lack of public API to observe OS tabs
/// see: https://github.com/lwouis/alt-tab-macos/issues/1540
static func detectTabbedWindows() {
let cgsWindowIds = Spaces.windowsInSpaces(Spaces.idsAndIndexes.map { $0.0 }, [.minimizedAndTabbed])
let cgsWindowIds = Spaces.windowsInSpaces(Spaces.idsAndIndexes.map { $0.0 })
list.forEach {
if let cgWindowId = $0.cgWindowId {
$0.isTabbed = !cgsWindowIds.contains(cgWindowId)
@@ -171,7 +171,7 @@ class Windows {
static func sortByLevel() {
var windowLevelMap = [CGWindowID: Int]()
for (index, cgWindowId) in Spaces.windowsInSpaces([Spaces.currentSpaceId], [.minimizedAndTabbed]).enumerated() {
for (index, cgWindowId) in Spaces.windowsInSpaces([Spaces.currentSpaceId]).enumerated() {
windowLevelMap[cgWindowId] = index
}
var sortedTuples = Windows.list