diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-02-05 09:32:47 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-02-05 09:35:10 +0300 |
| commit | 734e3a6d3cea277e56baf4531695e989b2d1bdda (patch) | |
| tree | 71d6e8e9ceb01e8d9f4acaa6b04514bad1ef3142 /src/layout | |
| parent | f18b1a70434755b92a8f0a59e8aa0302309e8b3a (diff) | |
| download | niri-734e3a6d3cea277e56baf4531695e989b2d1bdda.tar.gz niri-734e3a6d3cea277e56baf4531695e989b2d1bdda.tar.bz2 niri-734e3a6d3cea277e56baf4531695e989b2d1bdda.zip | |
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?
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/mod.rs | 49 |
1 files changed, 29 insertions, 20 deletions
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<W: LayoutElement> Layout<W> { } } - 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<W>)> { match &self.monitor_set { MonitorSet::Normal { ref monitors, .. } => { @@ -1278,6 +1258,35 @@ impl<W: LayoutElement> Layout<W> { } } + 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, |
