Skip to content

Commit

Permalink
refresh: drop endSession
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitabobko committed Sep 17, 2023
1 parent dbf1777 commit c9d53fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/command/WorkspaceCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 9 additions & 10 deletions src/refresh.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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?) {
Expand Down

0 comments on commit c9d53fc

Please sign in to comment.