From c9d53fc491df0722d9198631970f52b0d7c5289c Mon Sep 17 00:00:00 2001 From: Nikita Bobko Date: Sun, 17 Sep 2023 23:58:05 +0200 Subject: [PATCH] refresh: drop endSession --- src/command/WorkspaceCommand.swift | 2 +- src/refresh.swift | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) 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?) {