From 3963f537a4182dbcd8e1e2f262ee105473facc56 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Tue, 19 Mar 2024 14:41:17 +0400 Subject: Wrap mapped windows in a Mapped --- src/input.rs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src/input.rs') diff --git a/src/input.rs b/src/input.rs index 35a612bc..11a84878 100644 --- a/src/input.rs +++ b/src/input.rs @@ -379,21 +379,24 @@ impl State { } Action::ScreenshotWindow => { let active = self.niri.layout.active_window(); - if let Some((window, output)) = active { + if let Some((mapped, output)) = active { self.backend.with_primary_renderer(|renderer| { - if let Err(err) = self.niri.screenshot_window(renderer, output, window) { + if let Err(err) = + self.niri + .screenshot_window(renderer, output, &mapped.window) + { warn!("error taking screenshot: {err:?}"); } }); } } Action::CloseWindow => { - if let Some(window) = self.niri.layout.focus() { - window.toplevel().expect("no x11 support").send_close(); + if let Some(mapped) = self.niri.layout.focus() { + mapped.toplevel().send_close(); } } Action::FullscreenWindow => { - let focus = self.niri.layout.focus().cloned(); + let focus = self.niri.layout.focus().map(|m| m.window.clone()); if let Some(window) = focus { self.niri.layout.toggle_fullscreen(&window); // FIXME: granular @@ -1017,8 +1020,8 @@ impl State { let button_state = event.state(); if ButtonState::Pressed == button_state { - if let Some(window) = self.niri.window_under_cursor() { - let window = window.clone(); + if let Some(mapped) = self.niri.window_under_cursor() { + let window = mapped.window.clone(); self.niri.layout.activate_window(&window); // FIXME: granular. @@ -1177,8 +1180,8 @@ impl State { tool.tip_down(serial, event.time_msec()); if let Some(pos) = self.niri.tablet_cursor_location { - if let Some(window) = self.niri.window_under(pos) { - let window = window.clone(); + if let Some(mapped) = self.niri.window_under(pos) { + let window = mapped.window.clone(); self.niri.layout.activate_window(&window); // FIXME: granular. @@ -1535,8 +1538,8 @@ impl State { .output_under(touch_location) .next() .cloned(); - if let Some(window) = self.niri.window_under(touch_location) { - let window = window.clone(); + if let Some(mapped) = self.niri.window_under(touch_location) { + let window = mapped.window.clone(); self.niri.layout.activate_window(&window); // FIXME: granular. -- cgit