diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-10-16 09:33:07 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-10-16 09:39:34 +0300 |
| commit | 40843cbda100489186a3c2737e29cf1346cb4d93 (patch) | |
| tree | 9a1871541d77bc52e7f505cd47de694071d1a759 /src/layout | |
| parent | a13b9298c66f45e571533731e2a690a23534df01 (diff) | |
| download | niri-40843cbda100489186a3c2737e29cf1346cb4d93.tar.gz niri-40843cbda100489186a3c2737e29cf1346cb4d93.tar.bz2 niri-40843cbda100489186a3c2737e29cf1346cb4d93.zip | |
layout/monitor: Extract workspace_under()
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/monitor.rs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/layout/monitor.rs b/src/layout/monitor.rs index 9d665bee..f43c91b3 100644 --- a/src/layout/monitor.rs +++ b/src/layout/monitor.rs @@ -865,26 +865,30 @@ impl<W: LayoutElement> Monitor<W> { first.into_iter().chain(second) } - pub fn window_under( + pub fn workspace_under( &self, pos_within_output: Point<f64, Logical>, - ) -> Option<(&W, Option<Point<f64, Logical>>)> { + ) -> Option<(&Workspace<W>, Point<f64, Logical>)> { let size = output_size(&self.output); let (ws, bounds) = self .workspaces_with_render_positions() .map(|(ws, offset)| (ws, Rectangle::from_loc_and_size(offset, size))) .find(|(_, bounds)| bounds.contains(pos_within_output))?; - let (win, win_pos) = ws.window_under(pos_within_output - bounds.loc)?; - Some((win, win_pos.map(|p| p + bounds.loc))) + Some((ws, bounds.loc)) + } + + pub fn window_under( + &self, + pos_within_output: Point<f64, Logical>, + ) -> Option<(&W, Option<Point<f64, Logical>>)> { + let (ws, offset) = self.workspace_under(pos_within_output)?; + let (win, win_pos) = ws.window_under(pos_within_output - offset)?; + Some((win, win_pos.map(|p| p + offset))) } pub fn resize_edges_under(&self, pos_within_output: Point<f64, Logical>) -> Option<ResizeEdge> { - let size = output_size(&self.output); - let (ws, bounds) = self - .workspaces_with_render_positions() - .map(|(ws, offset)| (ws, Rectangle::from_loc_and_size(offset, size))) - .find(|(_, bounds)| bounds.contains(pos_within_output))?; - ws.resize_edges_under(pos_within_output - bounds.loc) + let (ws, offset) = self.workspace_under(pos_within_output)?; + ws.resize_edges_under(pos_within_output - offset) } pub fn render_above_top_layer(&self) -> bool { |
