-
-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b0cfc80
commit acc507e
Showing
7 changed files
with
72 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
struct MoveInCommand: Command { | ||
let direction: CardinalDirection | ||
|
||
func runWithoutRefresh() { | ||
precondition(Thread.current.isMainThread) | ||
guard let currentWindow = focusedWindowOrEffectivelyFocused else { return } | ||
guard let (parent, ownIndex) = currentWindow.closestParent(hasChildrenInDirection: direction, withLayout: nil) else { return } | ||
let moveInTarget = parent.children[ownIndex + direction.focusOffset] | ||
let prevBinding = moveInTarget.unbindFromParent() | ||
let newParent = TilingContainer( | ||
parent: parent, | ||
adaptiveWeight: prevBinding.adaptiveWeight, | ||
parent.orientation.opposite, | ||
.List, | ||
index: prevBinding.index | ||
) | ||
currentWindow.unbindFromParent() | ||
|
||
moveInTarget.bindTo(parent: newParent, adaptiveWeight: WEIGHT_AUTO, index: 0) | ||
currentWindow.bindTo(parent: newParent, adaptiveWeight: WEIGHT_AUTO, index: direction.isPositive ? 0 : INDEX_BIND_LAST) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import XCTest | ||
@testable import AeroSpace_Debug | ||
|
||
final class MoveInCommandTest: XCTestCase { | ||
override func setUpWithError() throws { setUpWorkspacesForTests() } | ||
|
||
func testMoveIn() async { | ||
let root = Workspace.get(byName: name).rootTilingContainer.apply { | ||
TestWindow(id: 0, parent: $0) | ||
TestWindow(id: 1, parent: $0).focus() | ||
TestWindow(id: 2, parent: $0) | ||
} | ||
|
||
await MoveInCommand(direction: .right).runWithoutRefresh() | ||
XCTAssertEqual(root.layoutDescription, .h_list([ | ||
.window(0), | ||
.v_list([ | ||
.window(1), | ||
.window(2) | ||
]) | ||
])) | ||
} | ||
} |