Redraw upon starting PW stream
Browse files at this commit3461c66d2ce8fb53e2a709b27868229786604256Parent: 011c91c3 changed files +13 -1
- src/dbus/mutter_screen_cast.rs +1 -0
- src/niri.rs +1 -0
- src/pw_utils.rs +11 -1
src/dbus/mutter_screen_cast.rsmodified+1 -0
| @@ -64,6 +64,7 @@ pub enum ScreenCastToNiri { | ||
| 64 | 64 | StopCast { |
| 65 | 65 | session_id: usize, |
| 66 | 66 | }, |
| 67 | + Redraw(Output), | |
| 67 | 68 | } |
| 68 | 69 | |
| 69 | 70 | #[dbus_interface(name = "org.gnome.Mutter.ScreenCast")] |
src/niri.rsmodified+1 -0
| @@ -705,6 +705,7 @@ impl State { | ||
| 705 | 705 | } |
| 706 | 706 | } |
| 707 | 707 | ScreenCastToNiri::StopCast { session_id } => self.niri.stop_cast(session_id), |
| 708 | + ScreenCastToNiri::Redraw(output) => self.niri.queue_redraw(output), | |
| 708 | 709 | } |
| 709 | 710 | } |
| 710 | 711 |
src/pw_utils.rsmodified+11 -1
| @@ -95,11 +95,20 @@ impl PipeWire { | ||
| 95 | 95 | ) -> anyhow::Result<Cast> { |
| 96 | 96 | let _span = tracy_client::span!("PipeWire::start_cast"); |
| 97 | 97 | |
| 98 | + let to_niri_ = to_niri.clone(); | |
| 98 | 99 | let stop_cast = move || { |
| 99 | - if let Err(err) = to_niri.send(ScreenCastToNiri::StopCast { session_id }) { | |
| 100 | + if let Err(err) = to_niri_.send(ScreenCastToNiri::StopCast { session_id }) { | |
| 100 | 101 | warn!("error sending StopCast to niri: {err:?}"); |
| 101 | 102 | } |
| 102 | 103 | }; |
| 104 | + let weak = output.downgrade(); | |
| 105 | + let redraw = move || { | |
| 106 | + if let Some(output) = weak.upgrade() { | |
| 107 | + if let Err(err) = to_niri.send(ScreenCastToNiri::Redraw(output)) { | |
| 108 | + warn!("error sending Redraw to niri: {err:?}"); | |
| 109 | + } | |
| 110 | + } | |
| 111 | + }; | |
| 103 | 112 | |
| 104 | 113 | let mode = output.current_mode().unwrap(); |
| 105 | 114 | let size = mode.size; |
| @@ -158,6 +167,7 @@ impl PipeWire { | ||
| 158 | 167 | StreamState::Connecting => (), |
| 159 | 168 | StreamState::Streaming => { |
| 160 | 169 | is_active.set(true); |
| 170 | + redraw(); | |
| 161 | 171 | } |
| 162 | 172 | } |
| 163 | 173 | } |