fix: may crash when changing space or screen
This commit is contained in:
1 parent
a474660498
commit
b62cec0cdc
2 files changed
+4
-3
No files matched your search
@@ -308,7 +308,7 @@ class Windows {
|
||||
if let cgWindowId = window.cgWindowId {
|
||||
let spaceIds = cgWindowId.spaces()
|
||||
window.spaceIds = spaceIds
|
||||
window.spaceIndexes = spaceIds.map { spaceId in Spaces.idsAndIndexes.first { $0.0 == spaceId }!.1 }
|
||||
window.spaceIndexes = spaceIds.compactMap { spaceId in Spaces.idsAndIndexes.first { $0.0 == spaceId }?.1 }
|
||||
window.isOnAllSpaces = spaceIds.count > 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,13 @@ class ScreensEvents {
|
||||
|
||||
@objc private static func handleEvent(_ notification: Notification) {
|
||||
Logger.debug(notification.name.rawValue)
|
||||
Spaces.refresh()
|
||||
// a screen added or removed, or screen resolution change can mess up layout; we reset components
|
||||
App.app.resetPreferencesDependentComponents()
|
||||
// a screen added or removed can shuffle windows around Spaces; we refresh them
|
||||
App.app.refreshOpenUi(Windows.list, .refreshUiAfterExternalEvent)
|
||||
Logger.info("screens", NSScreen.screens.map { ($0.uuid() ?? "nil" as CFString, $0.frame) })
|
||||
Logger.info("spaces", Spaces.screenSpacesMap)
|
||||
Logger.info("current space", Spaces.currentSpaceIndex, Spaces.currentSpaceId)
|
||||
// a screen added or removed, or screen resolution change can mess up layout; we reset components
|
||||
App.app.resetPreferencesDependentComponents()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user