diff --git a/src/command/WorkspaceCommand.swift b/src/command/WorkspaceCommand.swift index 9ab64556..284d4b11 100644 --- a/src/command/WorkspaceCommand.swift +++ b/src/command/WorkspaceCommand.swift @@ -8,7 +8,7 @@ struct WorkspaceCommand : Command { static func switchToWorkspace(_ workspace: Workspace) { debug("Switch to workspace: \(workspace.name)") - refresh(endSession: false) + refresh() if let window = workspace.mruWindows.mostRecent ?? workspace.anyLeafWindowRecursive { // switch to not empty workspace window.focus() // The switching itself will be done by refreshWorkspaces and layoutWorkspaces later in refresh diff --git a/src/refresh.swift b/src/refresh.swift index 0b8536e5..ca223f48 100644 --- a/src/refresh.swift +++ b/src/refresh.swift @@ -2,18 +2,19 @@ import Foundation /// It's one of the most important function of the whole application. /// The function is called as a feedback response on every user input -func refresh(startSession: Bool = true, endSession: Bool = true) { +func refresh(startSession: Bool = true) { precondition(Thread.current.isMainThread) - debug("refresh (startSession=\(startSession), endSession=\(endSession)) \(Date.now.formatted(date: .abbreviated, time: .standard))") + debug("refresh (startSession=\(startSession)) \(Date.now.formatted(date: .abbreviated, time: .standard))") if startSession { focusedApp = nil - MacWindow.garbageCollectClosedWindows() - // Garbage collect terminated apps and windows before working with all windows - MacApp.garbageCollectTerminatedApps() - // Garbage collect workspaces after apps, because workspaces contain apps. - Workspace.garbageCollectUnusedWorkspaces() } + MacWindow.garbageCollectClosedWindows() + // Garbage collect terminated apps and windows before working with all windows + MacApp.garbageCollectTerminatedApps() + // Garbage collect workspaces after apps, because workspaces contain apps. + Workspace.garbageCollectUnusedWorkspaces() + refreshWorkspaces() detectNewWindowsAndAttachThemToWorkspaces() @@ -22,9 +23,7 @@ func refresh(startSession: Bool = true, endSession: Bool = true) { layoutWorkspaces() layoutWindows() - if endSession { - updateLastActiveWindow() - } + updateLastActiveWindow() } func refreshObs(_ obs: AXObserver, ax: AXUIElement, notif: CFString, data: UnsafeMutableRawPointer?) {