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> {
865 first.into_iter().chain(second)865 first.into_iter().chain(second)
866 }866 }
867 867
868- pub fn window_under(868+ pub fn workspace_under(
869 &self,869 &self,
870 pos_within_output: Point<f64, Logical>,870 pos_within_output: Point<f64, Logical>,
871- ) -> Option<(&W, Option<Point<f64, Logical>>)> {871+ ) -> Option<(&Workspace<W>, Point<f64, Logical>)> {
872 let size = output_size(&self.output);872 let size = output_size(&self.output);
873 let (ws, bounds) = self873 let (ws, bounds) = self
874 .workspaces_with_render_positions()874 .workspaces_with_render_positions()
875 .map(|(ws, offset)| (ws, Rectangle::from_loc_and_size(offset, size)))875 .map(|(ws, offset)| (ws, Rectangle::from_loc_and_size(offset, size)))
876 .find(|(_, bounds)| bounds.contains(pos_within_output))?;876 .find(|(_, bounds)| bounds.contains(pos_within_output))?;
877- let (win, win_pos) = ws.window_under(pos_within_output - bounds.loc)?;877+ Some((ws, bounds.loc))
878- Some((win, win_pos.map(|p| p + 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 pub fn resize_edges_under(&self, pos_within_output: Point<f64, Logical>) -> Option<ResizeEdge> {889 pub fn resize_edges_under(&self, pos_within_output: Point<f64, Logical>) -> Option<ResizeEdge> {
882- let size = output_size(&self.output);890+ let (ws, offset) = self.workspace_under(pos_within_output)?;
883- let (ws, bounds) = self891+ ws.resize_edges_under(pos_within_output - offset)
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)
888 }892 }
889 893
890 pub fn render_above_top_layer(&self) -> bool {894 pub fn render_above_top_layer(&self) -> bool {