Skip to content

Commit 3a274c3

Browse files
fix(workspaces): display assignment when moving window in dynamic mode (#554)
1 parent 2fab66e commit 3a274c3

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

.swiftformat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
--selfrequired expectation,wait
2929
--patternlet inline
3030

31-
--disable wrapMultilineStatementBraces, blankLinesAroundMark, trailingClosures, wrapPropertyBodies, wrapFunctionBodies
31+
--disable wrapMultilineStatementBraces, blankLinesAroundMark, trailingClosures, wrapPropertyBodies, wrapFunctionBodies, preferForLoop
3232

3333
--exclude Dangerfile.swift
3434

FlashSpace/Features/FocusManager/FocusedWindowTracker.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ final class FocusedWindowTracker {
8282
// Skip if the app is floating
8383
guard !settingsRepository.floatingAppsSettings.floatingApps.containsApp(app) else { return }
8484

85+
workspaceManager.invalidateInactiveWorkspaces()
86+
8587
// Find the workspace that contains the app.
8688
// The same app can be in multiple workspaces, the highest priority has the one
8789
// from the active workspace.

FlashSpace/Features/Workspaces/WorkspaceManager.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ final class WorkspaceManager: ObservableObject {
100100
.compactMap { $0.userInfo?[NSWorkspace.applicationUserInfoKey] as? NSRunningApplication }
101101
.filter { $0.activationPolicy == .regular }
102102
.sink { [weak self] application in
103+
self?.invalidateInactiveWorkspaces()
103104
self?.rememberLastFocusedApp(application, retry: true)
104105
}
105106
}
@@ -576,6 +577,18 @@ extension WorkspaceManager {
576577
lastFocusedApp[profilesRepository.selectedProfile.id, default: [:]][workspace.id] = app
577578
}
578579

580+
func invalidateInactiveWorkspaces() {
581+
guard workspaceSettings.displayMode == .dynamic else { return }
582+
583+
activeWorkspace = activeWorkspace.filter { display, workspace in
584+
let isValid = workspace.displays.contains(display)
585+
if !isValid {
586+
Logger.log("Invalidating workspace: \(workspace.name) on display: \(display)")
587+
}
588+
return isValid
589+
}
590+
}
591+
579592
func pauseWorkspaceManagement() {
580593
guard !workspaceSettings.isPaused else { return }
581594

0 commit comments

Comments
 (0)