forge
Explore
Log in

Don't you dare go Hollow

Stop screencasts on size changes

Browse files at this commit

7052f0129ef5d2fa5d38eef3dbb5c9296228e341Ivan MolodetskikhParent: 962e159
src/niri.rsmodified+11 -0
@@ -2434,6 +2434,7 @@ impl Niri {
2434 let scale = Scale::from(output.current_scale().fractional_scale());2434 let scale = Scale::from(output.current_scale().fractional_scale());
2435 2435
2436 let mut elements = None;2436 let mut elements = None;
2437+ let mut casts_to_stop = vec![];
2437 2438
2438 let mut casts = mem::take(&mut self.casts);2439 let mut casts = mem::take(&mut self.casts);
2439 for cast in &mut casts {2440 for cast in &mut casts {
@@ -2445,6 +2446,12 @@ impl Niri {
2445 continue;2446 continue;
2446 }2447 }
2447 2448
2449+ if cast.size != size {
2450+ debug!("stopping screencast due to output size change");
2451+ casts_to_stop.push(cast.session_id);
2452+ continue;
2453+ }
2454+
2448 let last = cast.last_frame_time;2455 let last = cast.last_frame_time;
2449 let min = cast.min_time_between_frames.get();2456 let min = cast.min_time_between_frames.get();
2450 if last.is_zero() {2457 if last.is_zero() {
@@ -2499,6 +2506,10 @@ impl Niri {
2499 cast.last_frame_time = target_presentation_time;2506 cast.last_frame_time = target_presentation_time;
2500 }2507 }
2501 self.casts = casts;2508 self.casts = casts;
2509+
2510+ for id in casts_to_stop {
2511+ self.stop_cast(id);
2512+ }
2502 }2513 }
2503 2514
2504 #[cfg(feature = "xdp-gnome-screencast")]2515 #[cfg(feature = "xdp-gnome-screencast")]
src/pw_utils.rsmodified+3 -0
@@ -27,6 +27,7 @@ use smithay::output::Output;
27 use smithay::reexports::calloop::generic::Generic;27 use smithay::reexports::calloop::generic::Generic;
28 use smithay::reexports::calloop::{self, Interest, LoopHandle, Mode, PostAction};28 use smithay::reexports::calloop::{self, Interest, LoopHandle, Mode, PostAction};
29 use smithay::reexports::gbm::Modifier;29 use smithay::reexports::gbm::Modifier;
30+use smithay::utils::{Physical, Size};
30 use zbus::SignalContext;31 use zbus::SignalContext;
31 32
32 use crate::dbus::mutter_screen_cast::{self, CursorMode, ScreenCastToNiri};33 use crate::dbus::mutter_screen_cast::{self, CursorMode, ScreenCastToNiri};
@@ -43,6 +44,7 @@ pub struct Cast {
43 _listener: StreamListener<()>,44 _listener: StreamListener<()>,
44 pub is_active: Rc<Cell<bool>>,45 pub is_active: Rc<Cell<bool>>,
45 pub output: Output,46 pub output: Output,
47+ pub size: Size<i32, Physical>,
46 pub cursor_mode: CursorMode,48 pub cursor_mode: CursorMode,
47 pub last_frame_time: Duration,49 pub last_frame_time: Duration,
48 pub min_time_between_frames: Rc<Cell<Duration>>,50 pub min_time_between_frames: Rc<Cell<Duration>>,
@@ -385,6 +387,7 @@ impl PipeWire {
385 _listener: listener,387 _listener: listener,
386 is_active,388 is_active,
387 output,389 output,
390+ size,
388 cursor_mode,391 cursor_mode,
389 last_frame_time: Duration::ZERO,392 last_frame_time: Duration::ZERO,
390 min_time_between_frames,393 min_time_between_frames,