This commit fixes an issue where when trying to move floating windows or windows on a floating workspace across boundaries to another monitor using the move_container_in_direction it wouldn't move the floating windows physically, although it moved them internally on komorebi, resulting in weird and wrong behavior.
This commit creates a new method on Monitor to add_container_with_direction which takes a move direction and then uses the same logic that was previously on the move_container_in_direction function.
It changes the move_container_to_monitor function to take an optional move direction which if it is some will have this function call the new method add_container_with_direction instead of just add_container.
Lastly the move_container_in_direction function now when it realizes the move will be across monitors simply calls the move_container_to_monitor with the direction that was initially given to it.
These changes require that all callers of move_container_to_monitor add an direction option, instead of passing None on all of them, a new helper function was created, named direction_from_monitor_idx which calculates the direction a move will have from the currently focused monitor and the target monitor return None if they are the same or returning Some(direction) if not. This way now all commands that call a move across monitor will use the logic to check from the direction if it should add the container on front or end.
With these changes now all the code related to moving a window across monitors using a command should be on one place only making sure that in the future any change required only needs to be done on one place, instead of having to do it on move_container_to_monitor and move_container_in_direction as before!
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/LGUG2Z/komorebi/pull/1154
**Author:** [@alex-ds13](https://github.com/alex-ds13)
**Created:** 11/28/2024
**Status:** ✅ Merged
**Merged:** 11/30/2024
**Merged by:** [@LGUG2Z](https://github.com/LGUG2Z)
**Base:** `master` ← **Head:** `fix/move-in-direction-across-monitors`
---
### 📝 Commits (2)
- [`8f4bc10`](https://github.com/LGUG2Z/komorebi/commit/8f4bc101bc746e50348ac109780636be0eb7355a) fix(wm): move floats in direction across monitors
- [`3b20e4b`](https://github.com/LGUG2Z/komorebi/commit/3b20e4b2fe99f6c7db52dec6f13f8fd89039daa3) refacor(wm): use helper function on move to workspace
### 📊 Changes
**3 files changed** (+161 additions, -138 deletions)
<details>
<summary>View changed files</summary>
📝 `komorebi/src/monitor.rs` (+88 -48)
📝 `komorebi/src/process_command.rs` (+31 -7)
📝 `komorebi/src/window_manager.rs` (+42 -83)
</details>
### 📄 Description
This commit fixes an issue where when trying to move floating windows or windows on a floating workspace across boundaries to another monitor using the `move_container_in_direction` it wouldn't move the floating windows physically, although it moved them internally on komorebi, resulting in weird and wrong behavior.
This commit creates a new method on `Monitor` to `add_container_with_direction` which takes a move direction and then uses the same logic that was previously on the `move_container_in_direction` function.
It changes the `move_container_to_monitor` function to take an optional move direction which if it is some will have this function call the new method `add_container_with_direction` instead of just `add_container`.
Lastly the `move_container_in_direction` function now when it realizes the move will be across monitors simply calls the `move_container_to_monitor` with the direction that was initially given to it.
These changes require that all callers of `move_container_to_monitor` add an direction option, instead of passing `None` on all of them, a new helper function was created, named `direction_from_monitor_idx` which calculates the direction a move will have from the currently focused monitor and the target monitor return `None` if they are the same or returning `Some(direction)` if not. This way now all commands that call a move across monitor will use the logic to check from the direction if it should add the container on front or end.
With these changes now all the code related to moving a window across monitors using a command should be on one place only making sure that in the future any change required only needs to be done on one place, instead of having to do it on `move_container_to_monitor` and `move_container_in_direction` as before!
<!--
Please follow the Conventional Commits specification.
If you need to update your PR with changes from `master`, please run `git rebase master`.
By opening this PR, you confirm that you have read and understood this project's `CONTRIBUTING.md`.
-->
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/LGUG2Z/komorebi/pull/1154
Author: @alex-ds13
Created: 11/28/2024
Status: ✅ Merged
Merged: 11/30/2024
Merged by: @LGUG2Z
Base:
master← Head:fix/move-in-direction-across-monitors📝 Commits (2)
8f4bc10fix(wm): move floats in direction across monitors3b20e4brefacor(wm): use helper function on move to workspace📊 Changes
3 files changed (+161 additions, -138 deletions)
View changed files
📝
komorebi/src/monitor.rs(+88 -48)📝
komorebi/src/process_command.rs(+31 -7)📝
komorebi/src/window_manager.rs(+42 -83)📄 Description
This commit fixes an issue where when trying to move floating windows or windows on a floating workspace across boundaries to another monitor using the
move_container_in_directionit wouldn't move the floating windows physically, although it moved them internally on komorebi, resulting in weird and wrong behavior.This commit creates a new method on
Monitortoadd_container_with_directionwhich takes a move direction and then uses the same logic that was previously on themove_container_in_directionfunction.It changes the
move_container_to_monitorfunction to take an optional move direction which if it is some will have this function call the new methodadd_container_with_directioninstead of justadd_container.Lastly the
move_container_in_directionfunction now when it realizes the move will be across monitors simply calls themove_container_to_monitorwith the direction that was initially given to it.These changes require that all callers of
move_container_to_monitoradd an direction option, instead of passingNoneon all of them, a new helper function was created, nameddirection_from_monitor_idxwhich calculates the direction a move will have from the currently focused monitor and the target monitor returnNoneif they are the same or returningSome(direction)if not. This way now all commands that call a move across monitor will use the logic to check from the direction if it should add the container on front or end.With these changes now all the code related to moving a window across monitors using a command should be on one place only making sure that in the future any change required only needs to be done on one place, instead of having to do it on
move_container_to_monitorandmove_container_in_directionas before!🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.