aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/handlers/compositor.rs20
-rw-r--r--src/handlers/mod.rs2
-rw-r--r--src/handlers/xdg_shell.rs18
-rw-r--r--src/layout/mod.rs49
-rw-r--r--src/niri.rs7
5 files changed, 60 insertions, 36 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))
});
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,
diff --git a/src/niri.rs b/src/niri.rs
index 36c56f30..37620e4c 100644
--- a/src/niri.rs
+++ b/src/niri.rs
@@ -2898,6 +2898,9 @@ impl Niri {
// Check the main layout.
let win_out = self.layout.find_window_and_output(root);
let layout_output = win_out.map(|(_, output)| output);
+ if let Some(output) = layout_output {
+ return output;
+ }
// Check layer-shell.
let has_layer_surface = |o: &&Output| {
@@ -2905,9 +2908,7 @@ impl Niri {
.layer_for_surface(root, WindowSurfaceType::TOPLEVEL)
.is_some()
};
- let layer_shell_output = || self.layout.outputs().find(has_layer_surface);
-
- layout_output.or_else(layer_shell_output)
+ self.layout.outputs().find(has_layer_surface)
}
pub fn lock_surface_focus(&self) -> Option<WlSurface> {