-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: get containers mouse position
- Loading branch information
1 parent
3e988e8
commit 323ed80
Showing
3 changed files
with
48 additions
and
21 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
32 changes: 32 additions & 0 deletions
32
packages/wm/src/containers/commands/get_containers_at_pos.rs
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,32 @@ | ||
use crate::{ | ||
common::Point, | ||
containers::{ | ||
traits::{CommonGetters, PositionGetters}, | ||
Container, WindowContainer, | ||
}, | ||
wm_state::WmState, | ||
}; | ||
|
||
/// Return the window under the mouse position excluding the dragged window | ||
pub fn get_containers_at_position( | ||
state: &WmState, | ||
position: &Point, | ||
) -> Vec<WindowContainer> { | ||
state | ||
.root_container | ||
.descendants() | ||
.filter_map(|container| match container { | ||
Container::TilingWindow(tiling) => { | ||
Some(WindowContainer::TilingWindow(tiling)) | ||
} | ||
Container::NonTilingWindow(non_tiling) => { | ||
Some(WindowContainer::NonTilingWindow(non_tiling)) | ||
} | ||
_ => None, | ||
}) | ||
.filter(|c| { | ||
let frame = c.to_rect(); | ||
frame.unwrap().contains_point(&position) | ||
}) | ||
.collect() | ||
} |
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