Skip to content

Commit

Permalink
Redraw upon starting PW stream
Browse files Browse the repository at this point in the history
Otherwise it may take a while for the first frame to arrive.
  • Loading branch information
YaLTeR committed Jan 18, 2024
1 parent 011c91c commit 3461c66
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/dbus/mutter_screen_cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ pub enum ScreenCastToNiri {
StopCast {
session_id: usize,
},
Redraw(Output),
}

#[dbus_interface(name = "org.gnome.Mutter.ScreenCast")]
Expand Down
1 change: 1 addition & 0 deletions src/niri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ impl State {
}
}
ScreenCastToNiri::StopCast { session_id } => self.niri.stop_cast(session_id),
ScreenCastToNiri::Redraw(output) => self.niri.queue_redraw(output),
}
}

Expand Down
12 changes: 11 additions & 1 deletion src/pw_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,20 @@ impl PipeWire {
) -> anyhow::Result<Cast> {
let _span = tracy_client::span!("PipeWire::start_cast");

let to_niri_ = to_niri.clone();
let stop_cast = move || {
if let Err(err) = to_niri.send(ScreenCastToNiri::StopCast { session_id }) {
if let Err(err) = to_niri_.send(ScreenCastToNiri::StopCast { session_id }) {
warn!("error sending StopCast to niri: {err:?}");
}
};
let weak = output.downgrade();
let redraw = move || {
if let Some(output) = weak.upgrade() {
if let Err(err) = to_niri.send(ScreenCastToNiri::Redraw(output)) {
warn!("error sending Redraw to niri: {err:?}");
}
}
};

let mode = output.current_mode().unwrap();
let size = mode.size;
Expand Down Expand Up @@ -158,6 +167,7 @@ impl PipeWire {
StreamState::Connecting => (),
StreamState::Streaming => {
is_active.set(true);
redraw();
}
}
}
Expand Down

0 comments on commit 3461c66

Please sign in to comment.