diff --git a/Sources/AppBundle/command/format.swift b/Sources/AppBundle/command/format.swift index ad5fcee4..3191b0ff 100644 --- a/Sources/AppBundle/command/format.swift +++ b/Sources/AppBundle/command/format.swift @@ -154,7 +154,7 @@ extension String { case (_, .none): break case (.window(let w), .workspace): - return w.workspace.flatMap(AeroObj.workspace).map(expandFormatVar) ?? .success(.string("NULL-WOKRSPACE")) + return w.nodeWorkspace.flatMap(AeroObj.workspace).map(expandFormatVar) ?? .success(.string("NULL-WOKRSPACE")) case (.window(let w), .monitor): return w.nodeMonitor.flatMap(AeroObj.monitor).map(expandFormatVar) ?? .success(.string("NULL-MONITOR")) case (.window(let w), .app): diff --git a/Sources/AppBundle/command/impl/CloseAllWindowsButCurrentCommand.swift b/Sources/AppBundle/command/impl/CloseAllWindowsButCurrentCommand.swift index b905ade2..b46b6e37 100644 --- a/Sources/AppBundle/command/impl/CloseAllWindowsButCurrentCommand.swift +++ b/Sources/AppBundle/command/impl/CloseAllWindowsButCurrentCommand.swift @@ -10,7 +10,7 @@ struct CloseAllWindowsButCurrentCommand: Command { guard let focused = target.windowOrNil else { return io.err("Empty workspace") } - guard let workspace = focused.workspace else { + guard let workspace = focused.nodeWorkspace else { return io.err("Focused window '\(focused.title)' doesn't belong to workspace") } var result = true diff --git a/Sources/AppBundle/command/impl/DebugWindowsCommand.swift b/Sources/AppBundle/command/impl/DebugWindowsCommand.swift index 01c42b4a..781512a6 100644 --- a/Sources/AppBundle/command/impl/DebugWindowsCommand.swift +++ b/Sources/AppBundle/command/impl/DebugWindowsCommand.swift @@ -86,7 +86,7 @@ func debugWindowsIfRecording(_ window: Window) { var result: [String] = [] result.append("\(windowPrefix) windowId: \(window.windowId)") - result.append("\(windowPrefix) workspace: \(window.workspace?.name ?? "nil")") + result.append("\(windowPrefix) workspace: \(window.nodeWorkspace?.name ?? "nil")") result.append("\(windowPrefix) treeNodeParent: \(window.parent)") result.append("\(windowPrefix) recognizedAsDialog: \(shouldFloat(window.axWindow, app))") result.append(dumpAx(window.axWindow, windowPrefix, .window)) diff --git a/Sources/AppBundle/command/impl/MoveNodeToWorkspaceCommand.swift b/Sources/AppBundle/command/impl/MoveNodeToWorkspaceCommand.swift index 54e234f4..1a8baf78 100644 --- a/Sources/AppBundle/command/impl/MoveNodeToWorkspaceCommand.swift +++ b/Sources/AppBundle/command/impl/MoveNodeToWorkspaceCommand.swift @@ -6,7 +6,7 @@ struct MoveNodeToWorkspaceCommand: Command { func run(_ env: CmdEnv, _ io: CmdIo) -> Bool { guard let target = args.resolveTargetOrReportError(env, io) else { return false } guard let window = target.windowOrNil else { return io.err(noWindowIsFocused) } - let subjectWs = window.workspace + let subjectWs = window.nodeWorkspace let targetWorkspace: Workspace switch args.target.val { case .relative(let isNext): diff --git a/Sources/AppBundle/mouse/moveWithMouse.swift b/Sources/AppBundle/mouse/moveWithMouse.swift index 0850bc31..5ce4b8b5 100644 --- a/Sources/AppBundle/mouse/moveWithMouse.swift +++ b/Sources/AppBundle/mouse/moveWithMouse.swift @@ -40,7 +40,7 @@ private func moveTilingWindow(_ window: Window) { let mouseLocation = mouseLocation let targetWorkspace = mouseLocation.monitorApproximation.activeWorkspace let swapTarget = mouseLocation.findIn(tree: targetWorkspace.rootTilingContainer, virtual: false)?.takeIf { $0 != window } - if targetWorkspace != window.workspace { // Move window to a different monitor + if targetWorkspace != window.nodeWorkspace { // Move window to a different monitor let index: Int = if let swapTarget, let parent = swapTarget.parent as? TilingContainer, let targetRect = swapTarget.lastAppliedLayoutPhysicalRect { mouseLocation.getProjection(parent.orientation) >= targetRect.center.getProjection(parent.orientation) ? swapTarget.ownIndex + 1 diff --git a/Sources/AppBundle/tree/MacWindow.swift b/Sources/AppBundle/tree/MacWindow.swift index f6c3c123..ddb05c7c 100644 --- a/Sources/AppBundle/tree/MacWindow.swift +++ b/Sources/AppBundle/tree/MacWindow.swift @@ -68,7 +68,7 @@ final class MacWindow: Window, CustomStringConvertible { } if !skipClosedWindowsCache { cacheClosedWindowIfNeeded(window: self) } let parent = unbindFromParent().parent - let deadWindowWorkspace = parent.workspace + let deadWindowWorkspace = parent.nodeWorkspace for obs in axObservers { AXObserverRemoveNotification(obs.obs, obs.ax, obs.notif) } @@ -121,9 +121,9 @@ final class MacWindow: Window, CustomStringConvertible { // `hideEmulation` calls if !isHiddenInCorner { guard let topLeftCorner = getTopLeftCorner() else { return } - guard let workspace else { return } // hiding only makes sense for workspace windows + guard let nodeWorkspace else { return } // hiding only makes sense for workspace windows prevUnhiddenEmulationPositionRelativeToWorkspaceAssignedRect = - topLeftCorner - workspace.workspaceMonitor.rect.topLeftCorner + topLeftCorner - nodeWorkspace.workspaceMonitor.rect.topLeftCorner } let p: CGPoint switch corner { @@ -144,13 +144,13 @@ final class MacWindow: Window, CustomStringConvertible { func unhideFromCorner() { guard let prevUnhiddenEmulationPositionRelativeToWorkspaceAssignedRect else { return } - guard let workspace else { return } // hiding only makes sense for workspace windows + guard let nodeWorkspace else { return } // hiding only makes sense for workspace windows switch getChildParentRelation(child: self, parent: parent) { // Just a small optimization to avoid unnecessary AX calls for non floating windows // Tiling windows should be unhidden with layoutRecursive anyway case .floatingWindow: - _ = setTopLeftCorner(workspace.workspaceMonitor.rect.topLeftCorner + prevUnhiddenEmulationPositionRelativeToWorkspaceAssignedRect) + _ = setTopLeftCorner(nodeWorkspace.workspaceMonitor.rect.topLeftCorner + prevUnhiddenEmulationPositionRelativeToWorkspaceAssignedRect) case .macosNativeFullscreenWindow, .macosNativeHiddenAppWindow, .macosNativeMinimizedWindow, .macosPopupWindow, .tiling, .rootTilingContainer, .shimContainerRelation: break } @@ -360,7 +360,7 @@ extension WindowDetectedCallback { if let regex = matcher.appNameRegexSubstring, !(window.app.name ?? "").contains(regex) { return false } - if let workspace = matcher.workspace, workspace != window.workspace?.name { + if let workspace = matcher.workspace, workspace != window.nodeWorkspace?.name { return false } return true diff --git a/Sources/AppBundle/tree/TreeNodeEx.swift b/Sources/AppBundle/tree/TreeNodeEx.swift index f97fc7cf..f4f26ce7 100644 --- a/Sources/AppBundle/tree/TreeNodeEx.swift +++ b/Sources/AppBundle/tree/TreeNodeEx.swift @@ -25,12 +25,12 @@ extension TreeNode { var parentsWithSelf: [TreeNode] { parent.flatMap { [self] + $0.parentsWithSelf } ?? [self] } /// Also see visualWorkspace - var workspace: Workspace? { // todo rename to nodeWorkspace - self as? Workspace ?? parent?.workspace + var nodeWorkspace: Workspace? { + self as? Workspace ?? parent?.nodeWorkspace } /// Also see: workspace - var visualWorkspace: Workspace? { workspace ?? nodeMonitor?.activeWorkspace } + var visualWorkspace: Workspace? { nodeWorkspace ?? nodeMonitor?.activeWorkspace } var nodeMonitor: Monitor? { switch self.nodeCases {