Skip to content

Commit 43428fd

Browse files
committed
Rename workspace to nodeWorkspace to make separation between nodeWorkspace and visualWorkspace more clear
Fixes todo in the code
1 parent 1f7c8f1 commit 43428fd

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

Sources/AppBundle/command/format.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ extension String {
154154
case (_, .none): break
155155

156156
case (.window(let w), .workspace):
157-
return w.workspace.flatMap(AeroObj.workspace).map(expandFormatVar) ?? .success(.string("NULL-WOKRSPACE"))
157+
return w.nodeWorkspace.flatMap(AeroObj.workspace).map(expandFormatVar) ?? .success(.string("NULL-WOKRSPACE"))
158158
case (.window(let w), .monitor):
159159
return w.nodeMonitor.flatMap(AeroObj.monitor).map(expandFormatVar) ?? .success(.string("NULL-MONITOR"))
160160
case (.window(let w), .app):

Sources/AppBundle/command/impl/CloseAllWindowsButCurrentCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct CloseAllWindowsButCurrentCommand: Command {
1010
guard let focused = target.windowOrNil else {
1111
return io.err("Empty workspace")
1212
}
13-
guard let workspace = focused.workspace else {
13+
guard let workspace = focused.nodeWorkspace else {
1414
return io.err("Focused window '\(focused.title)' doesn't belong to workspace")
1515
}
1616
var result = true

Sources/AppBundle/command/impl/DebugWindowsCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func debugWindowsIfRecording(_ window: Window) {
8686
var result: [String] = []
8787

8888
result.append("\(windowPrefix) windowId: \(window.windowId)")
89-
result.append("\(windowPrefix) workspace: \(window.workspace?.name ?? "nil")")
89+
result.append("\(windowPrefix) workspace: \(window.nodeWorkspace?.name ?? "nil")")
9090
result.append("\(windowPrefix) treeNodeParent: \(window.parent)")
9191
result.append("\(windowPrefix) recognizedAsDialog: \(shouldFloat(window.axWindow, app))")
9292
result.append(dumpAx(window.axWindow, windowPrefix, .window))

Sources/AppBundle/command/impl/MoveNodeToWorkspaceCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ struct MoveNodeToWorkspaceCommand: Command {
66
func run(_ env: CmdEnv, _ io: CmdIo) -> Bool {
77
guard let target = args.resolveTargetOrReportError(env, io) else { return false }
88
guard let window = target.windowOrNil else { return io.err(noWindowIsFocused) }
9-
let subjectWs = window.workspace
9+
let subjectWs = window.nodeWorkspace
1010
let targetWorkspace: Workspace
1111
switch args.target.val {
1212
case .relative(let isNext):

Sources/AppBundle/mouse/moveWithMouse.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private func moveTilingWindow(_ window: Window) {
4040
let mouseLocation = mouseLocation
4141
let targetWorkspace = mouseLocation.monitorApproximation.activeWorkspace
4242
let swapTarget = mouseLocation.findIn(tree: targetWorkspace.rootTilingContainer, virtual: false)?.takeIf { $0 != window }
43-
if targetWorkspace != window.workspace { // Move window to a different monitor
43+
if targetWorkspace != window.nodeWorkspace { // Move window to a different monitor
4444
let index: Int = if let swapTarget, let parent = swapTarget.parent as? TilingContainer, let targetRect = swapTarget.lastAppliedLayoutPhysicalRect {
4545
mouseLocation.getProjection(parent.orientation) >= targetRect.center.getProjection(parent.orientation)
4646
? swapTarget.ownIndex + 1

Sources/AppBundle/tree/MacWindow.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ final class MacWindow: Window, CustomStringConvertible {
6868
}
6969
if !skipClosedWindowsCache { cacheClosedWindowIfNeeded(window: self) }
7070
let parent = unbindFromParent().parent
71-
let deadWindowWorkspace = parent.workspace
71+
let deadWindowWorkspace = parent.nodeWorkspace
7272
for obs in axObservers {
7373
AXObserverRemoveNotification(obs.obs, obs.ax, obs.notif)
7474
}
@@ -121,9 +121,9 @@ final class MacWindow: Window, CustomStringConvertible {
121121
// `hideEmulation` calls
122122
if !isHiddenInCorner {
123123
guard let topLeftCorner = getTopLeftCorner() else { return }
124-
guard let workspace else { return } // hiding only makes sense for workspace windows
124+
guard let nodeWorkspace else { return } // hiding only makes sense for workspace windows
125125
prevUnhiddenEmulationPositionRelativeToWorkspaceAssignedRect =
126-
topLeftCorner - workspace.workspaceMonitor.rect.topLeftCorner
126+
topLeftCorner - nodeWorkspace.workspaceMonitor.rect.topLeftCorner
127127
}
128128
let p: CGPoint
129129
switch corner {
@@ -144,13 +144,13 @@ final class MacWindow: Window, CustomStringConvertible {
144144

145145
func unhideFromCorner() {
146146
guard let prevUnhiddenEmulationPositionRelativeToWorkspaceAssignedRect else { return }
147-
guard let workspace else { return } // hiding only makes sense for workspace windows
147+
guard let nodeWorkspace else { return } // hiding only makes sense for workspace windows
148148

149149
switch getChildParentRelation(child: self, parent: parent) {
150150
// Just a small optimization to avoid unnecessary AX calls for non floating windows
151151
// Tiling windows should be unhidden with layoutRecursive anyway
152152
case .floatingWindow:
153-
_ = setTopLeftCorner(workspace.workspaceMonitor.rect.topLeftCorner + prevUnhiddenEmulationPositionRelativeToWorkspaceAssignedRect)
153+
_ = setTopLeftCorner(nodeWorkspace.workspaceMonitor.rect.topLeftCorner + prevUnhiddenEmulationPositionRelativeToWorkspaceAssignedRect)
154154
case .macosNativeFullscreenWindow, .macosNativeHiddenAppWindow, .macosNativeMinimizedWindow,
155155
.macosPopupWindow, .tiling, .rootTilingContainer, .shimContainerRelation: break
156156
}
@@ -360,7 +360,7 @@ extension WindowDetectedCallback {
360360
if let regex = matcher.appNameRegexSubstring, !(window.app.name ?? "").contains(regex) {
361361
return false
362362
}
363-
if let workspace = matcher.workspace, workspace != window.workspace?.name {
363+
if let workspace = matcher.workspace, workspace != window.nodeWorkspace?.name {
364364
return false
365365
}
366366
return true

Sources/AppBundle/tree/TreeNodeEx.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ extension TreeNode {
2525
var parentsWithSelf: [TreeNode] { parent.flatMap { [self] + $0.parentsWithSelf } ?? [self] }
2626

2727
/// Also see visualWorkspace
28-
var workspace: Workspace? { // todo rename to nodeWorkspace
29-
self as? Workspace ?? parent?.workspace
28+
var nodeWorkspace: Workspace? {
29+
self as? Workspace ?? parent?.nodeWorkspace
3030
}
3131

3232
/// Also see: workspace
33-
var visualWorkspace: Workspace? { workspace ?? nodeMonitor?.activeWorkspace }
33+
var visualWorkspace: Workspace? { nodeWorkspace ?? nodeMonitor?.activeWorkspace }
3434

3535
var nodeMonitor: Monitor? {
3636
switch self.nodeCases {

0 commit comments

Comments
 (0)