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

Add a window swap operation #899

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

rustn00b
Copy link

Swap the active window in the active column with a neighboring column's active window.

This PR adds a swap-window-left and swap-window-right action. They are used to swap the active window
in the active column with the active window in a neighboring column. When there is no neighboring column it
behaves just like the respective expel-window-.... actions.

This is something quite simple but that I often found missing when using Niri. It was standard in Awesome and easy enough to script in Sway, but I was unable to create a decent niri-ipc based version.

@YaLTeR
Copy link
Owner

YaLTeR commented Dec 27, 2024

Interesting, what do you use this for?

@rustn00b
Copy link
Author

Interesting, what do you use this for?

I usually have a column of things I'm working on in the context of some project or other (say 3-5 windows), and to the side a column with a single window (or maybe 2). The work happens in the single "master" window, and I swap the windows into this "master" position based on what needs doing.

What I like about this approach is that it keeps a set of windows available as a palette of sorts, while also affording
decent screen real estate to the current area of focus. But there might be smarter ways of going about it ;)

Copy link
Owner

@YaLTeR YaLTeR left a comment

Choose a reason for hiding this comment

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

Also don't forget to run cargo +nightly fmt.

);

// special case when the source column disappears after removing its last tile
let adjusted_target_column_idx =
Copy link
Owner

Choose a reason for hiding this comment

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

I'd make target_column_idx mutable and -= 1 it.

Copy link
Author

Choose a reason for hiding this comment

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

ah, but I still need the original target_column_idx further along. The adjusted_target_column_idx is only meaningful during the code window where the source column may have been removed and has not yet been recreated.
I added an explicit block to make this more obvious.

src/layout/mod.rs Show resolved Hide resolved
Swap the active window with the a neighboring column's active window.
Copy link
Owner

@YaLTeR YaLTeR left a comment

Choose a reason for hiding this comment

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

Rebased and fixed two small issues. Could you address these two remaining ones?

src/layout/scrolling.rs Show resolved Hide resolved
src/layout/scrolling.rs Show resolved Hide resolved
rustn00b and others added 5 commits January 5, 2025 17:33
Swap the active window with the a neighboring column's active window.
- Added a block around the relevant use of `adjusted_target_column_idx` in attempt
  to make the logic clearer
- ran `cargo +nightly fmt`
- Added a `SwapWindowInDirection` variant to the `Op` test enum
* Set is-active-in-column to true for unmapped windows

* Update wiki/Configuration:-Window-Rules.md

---------

Co-authored-by: Ivan Molodetskikh <[email protected]>
- no longer behave like an expel when a swap is made in a direction
  where there is no column to swap with
- fix janky animation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants