fix: tab detection got broken in v6.41.0 (#1656)

This commit is contained in:
Louis Pontoise committed 2022-06-05 12:00:14 +09:00
1 parent 1243de8010
commit 95f97d33af
4 files changed
+7 -8

No files matched your search

+1 -1
View File
@@ -112,7 +112,7 @@ func CGSCopyManagedDisplaySpaces(_ cid: CGSConnectionID) -> CFArray
struct CGSCopyWindowsOptions: OptionSet {
let rawValue: Int
static let minimized = CGSCopyWindowsOptions(rawValue: 1 << 0)
static let minimizedAndTabbed = CGSCopyWindowsOptions(rawValue: 1 << 0)
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
@@ -27,8 +27,8 @@ class Applications {
static func addInitialRunningApplicationsWindows() {
let otherSpaces = Spaces.otherSpaces()
if otherSpaces.count > 0 {
let windowsOnCurrentSpace = Spaces.windowsInSpaces([Spaces.currentSpaceId])
let windowsOnOtherSpaces = Spaces.windowsInSpaces(otherSpaces)
let windowsOnCurrentSpace = Spaces.windowsInSpaces([Spaces.currentSpaceId], [.minimizedAndTabbed])
let windowsOnOtherSpaces = Spaces.windowsInSpaces(otherSpaces, [.minimizedAndTabbed])
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
+2 -3
View File
@@ -67,11 +67,10 @@ class Spaces {
return idsAndIndexes.filter { $0.0 != currentSpaceId }.map { $0.0 }
}
static func windowsInSpaces(_ spaceIds: [CGSSpaceID]) -> [CGWindowID] {
let options = ([.minimized] as CGSCopyWindowsOptions).rawValue
static func windowsInSpaces(_ spaceIds: [CGSSpaceID], _ options: CGSCopyWindowsOptions) -> [CGWindowID] {
var set_tags = ([] as CGSCopyWindowsTags).rawValue
var clear_tags = ([] as CGSCopyWindowsTags).rawValue
return CGSCopyWindowsWithOptionsAndTags(cgsMainConnectionId, 0, spaceIds as CFArray, options, &set_tags, &clear_tags) as! [CGWindowID]
return CGSCopyWindowsWithOptionsAndTags(cgsMainConnectionId, 0, spaceIds as CFArray, options.rawValue, &set_tags, &clear_tags) as! [CGWindowID]
}
static func isSingleSpace() -> Bool {
+2 -2
View File
@@ -160,7 +160,7 @@ class Windows {
}
static func detectTabbedWindows() {
let cgsWindowIds = Spaces.windowsInSpaces(Spaces.idsAndIndexes.map { $0.0 })
let cgsWindowIds = Spaces.windowsInSpaces(Spaces.idsAndIndexes.map { $0.0 }, [])
list.forEach {
$0.isTabbed = !$0.isMinimized && !$0.isHidden && !cgsWindowIds.contains($0.cgWindowId)
}
@@ -168,7 +168,7 @@ class Windows {
static func sortByLevel() {
var windowLevelMap = [CGWindowID: Int]()
for (index, cgWindowId) in Spaces.windowsInSpaces([Spaces.currentSpaceId]).enumerated() {
for (index, cgWindowId) in Spaces.windowsInSpaces([Spaces.currentSpaceId], [.minimizedAndTabbed]).enumerated() {
windowLevelMap[cgWindowId] = index
}
var sortedTuples = Windows.list.map { (windowLevelMap[$0.cgWindowId], $0) }