From 40843cbda100489186a3c2737e29cf1346cb4d93 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Wed, 16 Oct 2024 09:33:07 +0300 Subject: layout/monitor: Extract workspace_under() --- src/layout/monitor.rs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src/layout') 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 Monitor { first.into_iter().chain(second) } - pub fn window_under( + pub fn workspace_under( &self, pos_within_output: Point, - ) -> Option<(&W, Option>)> { + ) -> Option<(&Workspace, Point)> { 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, + ) -> Option<(&W, Option>)> { + 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) -> Option { - 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 { -- cgit