From 734e3a6d3cea277e56baf4531695e989b2d1bdda Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Wed, 5 Feb 2025 09:32:47 +0300 Subject: Fix find_window_and_output() returning None with no outputs As far as I can tell, this would mess up a ton of the logic. Not sure how anything worked with no outputs before? --- src/layout/mod.rs | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) (limited to 'src/layout') diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 5351ccf1..f60e3192 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -1142,26 +1142,6 @@ impl Layout { } } - pub fn find_window_and_output(&self, wl_surface: &WlSurface) -> Option<(&W, &Output)> { - if let Some(InteractiveMoveState::Moving(move_)) = &self.interactive_move { - if move_.tile.window().is_wl_surface(wl_surface) { - return Some((move_.tile.window(), &move_.output)); - } - } - - if let MonitorSet::Normal { monitors, .. } = &self.monitor_set { - for mon in monitors { - for ws in &mon.workspaces { - if let Some(window) = ws.find_wl_surface(wl_surface) { - return Some((window, &mon.output)); - } - } - } - } - - None - } - pub fn find_workspace_by_id(&self, id: WorkspaceId) -> Option<(usize, &Workspace)> { match &self.monitor_set { MonitorSet::Normal { ref monitors, .. } => { @@ -1278,6 +1258,35 @@ impl Layout { } } + pub fn find_window_and_output(&self, wl_surface: &WlSurface) -> Option<(&W, Option<&Output>)> { + if let Some(InteractiveMoveState::Moving(move_)) = &self.interactive_move { + if move_.tile.window().is_wl_surface(wl_surface) { + return Some((move_.tile.window(), Some(&move_.output))); + } + } + + match &self.monitor_set { + MonitorSet::Normal { monitors, .. } => { + for mon in monitors { + for ws in &mon.workspaces { + if let Some(window) = ws.find_wl_surface(wl_surface) { + return Some((window, Some(&mon.output))); + } + } + } + } + MonitorSet::NoOutputs { workspaces } => { + for ws in workspaces { + if let Some(window) = ws.find_wl_surface(wl_surface) { + return Some((window, None)); + } + } + } + } + + None + } + pub fn find_window_and_output_mut( &mut self, wl_surface: &WlSurface, -- cgit