Skip to content

Commit

Permalink
Rename workspace to nodeWorkspace to make separation between nodeWork…
Browse files Browse the repository at this point in the history
…space and visualWorkspace more clear

Fixes todo in the code
  • Loading branch information
nikitabobko committed Nov 29, 2024
1 parent 1f7c8f1 commit 43428fd
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Sources/AppBundle/command/format.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/AppBundle/command/impl/DebugWindowsCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion Sources/AppBundle/mouse/moveWithMouse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions Sources/AppBundle/tree/MacWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Sources/AppBundle/tree/TreeNodeEx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 43428fd

Please sign in to comment.