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/handlers | |
| 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/handlers')
| -rw-r--r-- | src/handlers/compositor.rs | 20 | ||||
| -rw-r--r-- | src/handlers/mod.rs | 2 | ||||
| -rw-r--r-- | src/handlers/xdg_shell.rs | 18 |
3 files changed, 27 insertions, 13 deletions
diff --git a/src/handlers/compositor.rs b/src/handlers/compositor.rs index 4b080cd8..012f6af3 100644 --- a/src/handlers/compositor.rs +++ b/src/handlers/compositor.rs @@ -166,7 +166,9 @@ impl CompositorHandler for State { // None. If the configured output is set, that means it was set explicitly // by a window rule or a fullscreen request. .filter(|(_, parent_output)| { - output.is_none() || output.as_ref() == Some(*parent_output) + parent_output.is_none() + || output.is_none() + || output.as_ref() == *parent_output }) .map(|(mapped, _)| mapped.window.clone()); @@ -223,7 +225,7 @@ impl CompositorHandler for State { // This is a commit of a previously-mapped root or a non-toplevel root. if let Some((mapped, output)) = self.niri.layout.find_window_and_output(surface) { let window = mapped.window.clone(); - let output = output.clone(); + let output = output.cloned(); #[cfg(feature = "xdp-gnome-screencast")] let id = mapped.id(); @@ -280,7 +282,9 @@ impl CompositorHandler for State { let unmapped = Unmapped::new(window); self.niri.unmapped_windows.insert(surface.clone(), unmapped); - self.niri.queue_redraw(&output); + if let Some(output) = output { + self.niri.queue_redraw(&output); + } return; } @@ -323,7 +327,9 @@ impl CompositorHandler for State { // Popup placement depends on window size which might have changed. self.update_reactive_popups(&window); - self.niri.queue_redraw(&output); + if let Some(output) = output { + self.niri.queue_redraw(&output); + } return; } @@ -334,10 +340,12 @@ impl CompositorHandler for State { let root_window_output = self.niri.layout.find_window_and_output(&root_surface); if let Some((mapped, output)) = root_window_output { let window = mapped.window.clone(); - let output = output.clone(); + let output = output.cloned(); window.on_commit(); self.niri.layout.update_window(&window, None); - self.niri.queue_redraw(&output); + if let Some(output) = output { + self.niri.queue_redraw(&output); + } return; } diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index 9cd2f794..4734b2ba 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -536,7 +536,7 @@ impl ForeignToplevelHandler for State { let window = mapped.window.clone(); if let Some(requested_output) = wl_output.as_ref().and_then(Output::from_resource) { - if &requested_output != current_output { + if Some(&requested_output) != current_output { self.niri .layout .move_to_output(Some(&window), &requested_output, None); diff --git a/src/handlers/xdg_shell.rs b/src/handlers/xdg_shell.rs index 65d45310..5cac5d29 100644 --- a/src/handlers/xdg_shell.rs +++ b/src/handlers/xdg_shell.rs @@ -123,6 +123,10 @@ impl XdgShellHandler for State { return; }; + let Some(output) = output else { + return; + }; + let window = mapped.window.clone(); let output = output.clone(); @@ -434,7 +438,7 @@ impl XdgShellHandler for State { let window = mapped.window.clone(); if let Some(requested_output) = requested_output { - if &requested_output != current_output { + if Some(&requested_output) != current_output { self.niri .layout .move_to_output(Some(&window), &requested_output, None); @@ -467,7 +471,7 @@ impl XdgShellHandler for State { toplevel .parent() .and_then(|parent| self.niri.layout.find_window_and_output(&parent)) - .map(|(_win, output)| output) + .and_then(|(_win, output)| output) .and_then(|o| self.niri.layout.monitor_for_output(o)) .map(|mon| (mon, true)) }) @@ -556,7 +560,7 @@ impl XdgShellHandler for State { .and_then(|parent| { self.niri.layout.find_window_and_output(&parent) }) - .map(|(_win, output)| output) + .and_then(|(_win, output)| output) .and_then(|o| self.niri.layout.monitor_for_output(o)) .map(|mon| (mon, true)) }) @@ -642,7 +646,7 @@ impl XdgShellHandler for State { return; }; let window = mapped.window.clone(); - let output = output.clone(); + let output = output.cloned(); #[cfg(feature = "xdp-gnome-screencast")] self.niri @@ -678,7 +682,9 @@ impl XdgShellHandler for State { self.maybe_warp_cursor_to_focus(); } - self.niri.queue_redraw(&output); + if let Some(output) = output { + self.niri.queue_redraw(&output); + } } fn popup_destroyed(&mut self, surface: PopupSurface) { @@ -862,7 +868,7 @@ impl State { toplevel .parent() .and_then(|parent| self.niri.layout.find_window_and_output(&parent)) - .map(|(_win, output)| output) + .and_then(|(_win, output)| output) .and_then(|o| self.niri.layout.monitor_for_output(o)) .map(|mon| (mon, true)) }); |
