Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add --boundaries options to move command #864

Closed
wants to merge 8 commits into from

Conversation

EcmaXp
Copy link

@EcmaXp EcmaXp commented Dec 16, 2024

Summary

This PR introduces a new --boundaries option to the move command, allowing windows to move beyond their current workspace.

By default, window movements remain within a single workspace. With --boundaries all-monitors-outer-frame, windows can now be moved across multiple monitors for increased flexibility.

Key Changes

move Command Updates:

- aerospace move [-h|--help] [--window-id <window-id>] (left|down|up|right)
+ aerospace move [-h|--help] [--window-id <window-id>] [--focus-follows-window]
+                [--fail-if-noop] [--boundaries <boundary>] [--wrap-around] (left|down|up|right)
  • --boundaries <boundary>: Choose between staying within the workspace or all-monitors-outer-frame.
  • --wrap-around: Cycle through monitors when reaching an edge.
  • --focus-follows-window: Automatically focus the moved window.
  • --fail-if-noop: Exit with a non-zero status if the window cannot move (e.g., hitting the boundary without --boundaries all-monitors-outer-frame).

Why?

These enhancements provide more control over window movement in multi-monitor setups and improve scripting scenarios by offering fail-fast behavior, wrap-around cycling, and automatic refocusing.

Example

# aerospace.toml
ctrl-alt-left = "move left --boundaries all-monitors-outer-frame --focus-follows-window"
ctrl-alt-down = "move down --boundaries all-monitors-outer-frame --focus-follows-window"
ctrl-alt-up = "move up --boundaries all-monitors-outer-frame --focus-follows-window"
ctrl-alt-right = "move right --boundaries all-monitors-outer-frame --focus-follows-window"

@EcmaXp EcmaXp marked this pull request as ready for review December 16, 2024 10:59
@EcmaXp EcmaXp force-pushed the feature/move-with-boundaries branch from 5592a0f to b274760 Compare December 16, 2024 11:02
@dvrkoo
Copy link

dvrkoo commented Dec 16, 2024

Currently switching between linux with Hyprland and macOS with Aerospace a lot and this is one of features I was missing the most, thanks a lot

Copy link
Owner

@nikitabobko nikitabobko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the effort, but I reject the PR. Your understanding of the mental model of moving windows is incorrect. The PR is fundamentally wrong.

@@ -25,6 +26,17 @@ Deprecated name: `move-through`
include::./util/conditional-options-header.adoc[]

-h, --help:: Print help
--fail-if-noop:: Exit with a non-zero status if the window cannot move because it’s at the boundary
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't read the code yet, but move command cannot fail. Please read #183 thread

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only possible case when it can fail is --boundaries-action (stop|create-implicit-container|fail)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve reviewed #183 and your feedback.

I’m a bit unsure about how to best design the arguments, but I’ll reconsider the approach.

`<boundary>` possible values: `(workspace|all-monitors-outer-frame)`. +
The default is: `workspace`

--focus-follows-window::
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't read the code yet, but move already always follows window, I don't understand why you need this flag

@@ -25,6 +26,17 @@ Deprecated name: `move-through`
include::./util/conditional-options-header.adoc[]

-h, --help:: Print help
--fail-if-noop:: Exit with a non-zero status if the window cannot move because it’s at the boundary
--wrap-around:: Make it possible to wrap around the movement
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree on: --boundaries-action (stop|create-implicit-container|fail|wrap-around-the-workspace|wrap-around-all-monitors), but I don't think that --wrap-around on its own is the right flag

@@ -56,6 +64,10 @@ private func moveOut(_ io: CmdIo, window: Window, direction: CardinalDirection)
bindTo = parent
bindToIndex = innerMostChild.ownIndex + direction.insertionOffset
case .workspace(let parent): // create implicit container
if !canMoveOutInDirection(window: window, direction: direction) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I read in the code, you disallow creating implicit containers when the window is moved along the axis of the rootTilingNode. This is wrong approach. It should be conditional behavior of --boundaries-action

By default it should always be possible to move out window out of container. Please, read #183 thread

public var workspaceName: WorkspaceName?
public var failIfNoop: Bool = false
public var rawBoundaries: Boundaries? = nil
public var moveNodeToMonitor = MoveNodeToMonitorCmdArgs(rawArgs: [])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't think a lot about it, but it may not be the right place to reuse move-node-to-monitor

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t fully agree. MoveNodeToMonitorCommand already calls MoveNodeToWorkspaceCommand in a similar way. There might be other approaches, but I’m not sure yet.

let moveNodeToWorkspace = args.moveNodeToWorkspace.copy(\.target, .initialized(.direct(wName)))
return MoveNodeToWorkspaceCommand(args: moveNodeToWorkspace).run(env, io)

@nikitabobko nikitabobko added the pr-rejected Pull Request is rejected label Dec 17, 2024
@EcmaXp
Copy link
Author

EcmaXp commented Dec 17, 2024

Thanks for the effort, but I reject the PR. Your understanding of the mental model of moving windows is incorrect. The PR is fundamentally wrong.

Thanks for taking the time to review my PR. I appreciate your feedback and insights.

I’ll revisit the approach based on your comments and open a new PR that aligns more closely with the intended mental model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-rejected Pull Request is rejected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Add --boundaries options to move command
3 participants