layout/monitor: Extract workspace_under()
Browse files at this commit40843cbda100489186a3c2737e29cf1346cb4d93Parent: a13b9291 changed file +14 -10
- src/layout/monitor.rs +14 -10
src/layout/monitor.rsmodified+14 -10
| @@ -865,26 +865,30 @@ impl<W: LayoutElement> Monitor<W> { | ||
| 865 | 865 | first.into_iter().chain(second) |
| 866 | 866 | } |
| 867 | 867 | |
| 868 | - pub fn window_under( | |
| 868 | + pub fn workspace_under( | |
| 869 | 869 | &self, |
| 870 | 870 | pos_within_output: Point<f64, Logical>, |
| 871 | - ) -> Option<(&W, Option<Point<f64, Logical>>)> { | |
| 871 | + ) -> Option<(&Workspace<W>, Point<f64, Logical>)> { | |
| 872 | 872 | let size = output_size(&self.output); |
| 873 | 873 | let (ws, bounds) = self |
| 874 | 874 | .workspaces_with_render_positions() |
| 875 | 875 | .map(|(ws, offset)| (ws, Rectangle::from_loc_and_size(offset, size))) |
| 876 | 876 | .find(|(_, bounds)| bounds.contains(pos_within_output))?; |
| 877 | - let (win, win_pos) = ws.window_under(pos_within_output - bounds.loc)?; | |
| 878 | - Some((win, win_pos.map(|p| p + bounds.loc))) | |
| 877 | + Some((ws, bounds.loc)) | |
| 878 | + } | |
| 879 | + | |
| 880 | + pub fn window_under( | |
| 881 | + &self, | |
| 882 | + pos_within_output: Point<f64, Logical>, | |
| 883 | + ) -> Option<(&W, Option<Point<f64, Logical>>)> { | |
| 884 | + let (ws, offset) = self.workspace_under(pos_within_output)?; | |
| 885 | + let (win, win_pos) = ws.window_under(pos_within_output - offset)?; | |
| 886 | + Some((win, win_pos.map(|p| p + offset))) | |
| 879 | 887 | } |
| 880 | 888 | |
| 881 | 889 | pub fn resize_edges_under(&self, pos_within_output: Point<f64, Logical>) -> Option<ResizeEdge> { |
| 882 | - let size = output_size(&self.output); | |
| 883 | - let (ws, bounds) = self | |
| 884 | - .workspaces_with_render_positions() | |
| 885 | - .map(|(ws, offset)| (ws, Rectangle::from_loc_and_size(offset, size))) | |
| 886 | - .find(|(_, bounds)| bounds.contains(pos_within_output))?; | |
| 887 | - ws.resize_edges_under(pos_within_output - bounds.loc) | |
| 890 | + let (ws, offset) = self.workspace_under(pos_within_output)?; | |
| 891 | + ws.resize_edges_under(pos_within_output - offset) | |
| 888 | 892 | } |
| 889 | 893 | |
| 890 | 894 | pub fn render_above_top_layer(&self) -> bool { |