diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-03-15 11:23:01 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-03-15 09:55:46 -0700 |
| commit | 31891e6642481c018357354583db804657c09c53 (patch) | |
| tree | f52ffe3fe28ebee0a7b93112285ed3a09e4c90b6 /src/input/mod.rs | |
| parent | 392fc27de110d3548095e465d5cb38bd8d5730ea (diff) | |
| download | niri-31891e6642481c018357354583db804657c09c53.tar.gz niri-31891e6642481c018357354583db804657c09c53.tar.bz2 niri-31891e6642481c018357354583db804657c09c53.zip | |
Implement dynamic screencast target
Diffstat (limited to 'src/input/mod.rs')
| -rw-r--r-- | src/input/mod.rs | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/input/mod.rs b/src/input/mod.rs index 95d30457..08bebe40 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -41,7 +41,7 @@ use self::resize_grab::ResizeGrab; use self::spatial_movement_grab::SpatialMovementGrab; use crate::layout::scrolling::ScrollDirection; use crate::layout::LayoutElement as _; -use crate::niri::State; +use crate::niri::{CastTarget, State}; use crate::ui::screenshot_ui::ScreenshotUi; use crate::utils::spawning::spawn; use crate::utils::{center, get_monotonic_time, ResizeEdge}; @@ -1786,6 +1786,36 @@ impl State { } } } + Action::SetDynamicCastWindow => { + let id = self + .niri + .layout + .active_workspace() + .and_then(|ws| ws.active_window()) + .map(|mapped| mapped.id().get()); + if let Some(id) = id { + self.set_dynamic_cast_target(CastTarget::Window { id }); + } + } + Action::SetDynamicCastWindowById(id) => { + let layout = &self.niri.layout; + if layout.windows().any(|(_, mapped)| mapped.id().get() == id) { + self.set_dynamic_cast_target(CastTarget::Window { id }); + } + } + Action::SetDynamicCastMonitor(output) => { + let output = match output { + None => self.niri.layout.active_output(), + Some(name) => self.niri.output_by_name_match(&name), + }; + if let Some(output) = output { + let output = output.downgrade(); + self.set_dynamic_cast_target(CastTarget::Output(output)); + } + } + Action::ClearDynamicCastTarget => { + self.set_dynamic_cast_target(CastTarget::Nothing); + } } } |
