forge
Explore
Log in

Don't you dare go Hollow

layout/monitor: Extract workspace_under()

Browse files at this commit

40843cbda100489186a3c2737e29cf1346cb4d93Ivan MolodetskikhParent: a13b929
src/layout/monitor.rsmodified+14 -10
@@ -865,26 +865,30 @@ impl<W: LayoutElement> Monitor<W> {
865865 first.into_iter().chain(second)
866866 }
867867
868- pub fn window_under(
868+ pub fn workspace_under(
869869 &self,
870870 pos_within_output: Point<f64, Logical>,
871- ) -> Option<(&W, Option<Point<f64, Logical>>)> {
871+ ) -> Option<(&Workspace<W>, Point<f64, Logical>)> {
872872 let size = output_size(&self.output);
873873 let (ws, bounds) = self
874874 .workspaces_with_render_positions()
875875 .map(|(ws, offset)| (ws, Rectangle::from_loc_and_size(offset, size)))
876876 .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)))
879887 }
880888
881889 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)
888892 }
889893
890894 pub fn render_above_top_layer(&self) -> bool {