From 7052f0129ef5d2fa5d38eef3dbb5c9296228e341 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Mon, 29 Jan 2024 10:13:59 +0400 Subject: Stop screencasts on size changes --- src/niri.rs | 11 +++++++++++ src/pw_utils.rs | 3 +++ 2 files changed, 14 insertions(+) (limited to 'src') diff --git a/src/niri.rs b/src/niri.rs index 2ed62c99..424fa712 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -2434,6 +2434,7 @@ impl Niri { let scale = Scale::from(output.current_scale().fractional_scale()); let mut elements = None; + let mut casts_to_stop = vec![]; let mut casts = mem::take(&mut self.casts); for cast in &mut casts { @@ -2445,6 +2446,12 @@ impl Niri { continue; } + if cast.size != size { + debug!("stopping screencast due to output size change"); + casts_to_stop.push(cast.session_id); + continue; + } + let last = cast.last_frame_time; let min = cast.min_time_between_frames.get(); if last.is_zero() { @@ -2499,6 +2506,10 @@ impl Niri { cast.last_frame_time = target_presentation_time; } self.casts = casts; + + for id in casts_to_stop { + self.stop_cast(id); + } } #[cfg(feature = "xdp-gnome-screencast")] diff --git a/src/pw_utils.rs b/src/pw_utils.rs index 45ccc559..7ae14f61 100644 --- a/src/pw_utils.rs +++ b/src/pw_utils.rs @@ -27,6 +27,7 @@ use smithay::output::Output; use smithay::reexports::calloop::generic::Generic; use smithay::reexports::calloop::{self, Interest, LoopHandle, Mode, PostAction}; use smithay::reexports::gbm::Modifier; +use smithay::utils::{Physical, Size}; use zbus::SignalContext; use crate::dbus::mutter_screen_cast::{self, CursorMode, ScreenCastToNiri}; @@ -43,6 +44,7 @@ pub struct Cast { _listener: StreamListener<()>, pub is_active: Rc>, pub output: Output, + pub size: Size, pub cursor_mode: CursorMode, pub last_frame_time: Duration, pub min_time_between_frames: Rc>, @@ -385,6 +387,7 @@ impl PipeWire { _listener: listener, is_active, output, + size, cursor_mode, last_frame_time: Duration::ZERO, min_time_between_frames, -- cgit