diff --git a/src/command/FocusCommand.swift b/src/command/FocusCommand.swift index 1daf7fb9..d4898fad 100644 --- a/src/command/FocusCommand.swift +++ b/src/command/FocusCommand.swift @@ -23,7 +23,7 @@ struct FocusCommand: Command { // todo speed up. Now it's slightly slow (probabl guard let index = topMostChild.ownIndexOrNil else { return } let mruIndexMap = currentWindow.workspace.mruWindows.mruIndexMap let windowToFocus: Window? = parent.children - .getOrNil(atIndex: index + direction.offset)? + .getOrNil(atIndex: index + direction.focusOffset)? .allLeafWindowsRecursive(snappedTo: direction.opposite) .minBy { mruIndexMap[$0] ?? Int.max } windowToFocus?.focus() diff --git a/src/command/MoveThroughCommand.swift b/src/command/MoveThroughCommand.swift index 14125d0e..4a77891c 100644 --- a/src/command/MoveThroughCommand.swift +++ b/src/command/MoveThroughCommand.swift @@ -6,7 +6,7 @@ struct MoveThroughCommand: Command { guard let currentWindow = focusedWindowOrEffectivelyFocused else { return } if let parent = currentWindow.parent as? TilingContainer { let indexOfCurrent = currentWindow.ownIndex - let indexOfSiblingTarget = indexOfCurrent + direction.offset + let indexOfSiblingTarget = indexOfCurrent + direction.focusOffset if parent.orientation == direction.orientation && parent.children.indices.contains(indexOfSiblingTarget) { switch parent.children[indexOfSiblingTarget].kind { case .tilingContainer(let topLevelSiblingTargetContainer): @@ -68,7 +68,7 @@ private func deepMoveIn(window: Window, into container: TilingContainer, moveDir .drop(while: { $0 != container }) .dropFirst() .toArray() - let deepTarget = container.findContainerWithOrientOrPreferredPath(moveDirection.orientation, preferredPath) + let deepTarget = container.findDeepMoveInTargetRecursive(moveDirection.orientation, preferredPath) switch deepTarget.kind { case .tilingContainer: window.unbindFromParent() @@ -86,7 +86,7 @@ private func deepMoveIn(window: Window, into container: TilingContainer, moveDir } private extension TreeNode { - func findContainerWithOrientOrPreferredPath(_ orientation: Orientation, _ preferredPath: [TreeNode]) -> TreeNode { + func findDeepMoveInTargetRecursive(_ orientation: Orientation, _ preferredPath: [TreeNode]) -> TreeNode { switch kind { case .window: return self @@ -96,7 +96,7 @@ private extension TreeNode { } else { assert(children.contains(preferredPath.first!)) return preferredPath.first! - .findContainerWithOrientOrPreferredPath(orientation, Array(preferredPath.dropFirst())) + .findDeepMoveInTargetRecursive(orientation, Array(preferredPath.dropFirst())) } case .workspace: error("Impossible") diff --git a/src/tree/TreeNode.swift b/src/tree/TreeNode.swift index 21fd5b54..a6e7ba6d 100644 --- a/src/tree/TreeNode.swift +++ b/src/tree/TreeNode.swift @@ -93,7 +93,7 @@ class TreeNode: Equatable { if let window = self as? Window { let newParentWorkspace = newParent.workspace newParentWorkspace.mruWindows.pushOrRaise(window) - newParentWorkspace.assignedMonitor = window.getCenter()?.monitorApproximation + newParentWorkspace.assignedMonitor = window.getCenter()?.monitorApproximation // todo here we may write nil // Update currentEmptyWorkspace since it's no longer effectively empty if newParentWorkspace == currentEmptyWorkspace { currentEmptyWorkspace = getOrCreateNextEmptyWorkspace() @@ -106,8 +106,9 @@ class TreeNode: Equatable { guard let _parent else { return nil } let workspace = workspace if let window = self as? Window { - precondition(workspace.mruWindows.remove(window)) /* todo lock screen -> false assert (for some reasons - all windows are placed into current active workspace) */ + // todo lock screen -> false assert (for some reasons all windows are placed into current active workspace) + // todo chrome close "cmd F" window with esc -> false assert + precondition(workspace.mruWindows.remove(window), "mru.remove \(window.title)") } let index = _parent._children.remove(element: self) ?? errorT("Can't find child in its parent") diff --git a/src/util/CardinalDirection.swift b/src/util/CardinalDirection.swift index 215ba201..eda300d0 100644 --- a/src/util/CardinalDirection.swift +++ b/src/util/CardinalDirection.swift @@ -17,6 +17,6 @@ extension CardinalDirection { return .left } } - var offset: Int { isPositive ? 1 : -1 } + var focusOffset: Int { isPositive ? 1 : -1 } var insertionOffset: Int { isPositive ? 1 : 0 } }