Skip to content

Commit

Permalink
Stop screencasts on size changes
Browse files Browse the repository at this point in the history
  • Loading branch information
YaLTeR committed Jan 31, 2024
1 parent 6bfea24 commit 9f75235
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/niri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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() {
Expand Down Expand Up @@ -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")]
Expand Down
3 changes: 3 additions & 0 deletions src/pw_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -43,6 +44,7 @@ pub struct Cast {
_listener: StreamListener<()>,
pub is_active: Rc<Cell<bool>>,
pub output: Output,
pub size: Size<i32, Physical>,
pub cursor_mode: CursorMode,
pub last_frame_time: Duration,
pub min_time_between_frames: Rc<Cell<Duration>>,
Expand Down Expand Up @@ -385,6 +387,7 @@ impl PipeWire {
_listener: listener,
is_active,
output,
size,
cursor_mode,
last_frame_time: Duration::ZERO,
min_time_between_frames,
Expand Down

0 comments on commit 9f75235

Please sign in to comment.