Skip to content

Commit

Permalink
send frame callbacks for active screencast windows
Browse files Browse the repository at this point in the history
  • Loading branch information
sodiboo committed Sep 7, 2024
1 parent 370fd4e commit 37dadf9
Showing 1 changed file with 34 additions and 5 deletions.
39 changes: 34 additions & 5 deletions src/niri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ use smithay::wayland::pointer_constraints::{with_pointer_constraint, PointerCons
use smithay::wayland::pointer_gestures::PointerGesturesState;
use smithay::wayland::presentation::PresentationState;
use smithay::wayland::relative_pointer::RelativePointerManagerState;
use smithay::wayland::seat::WaylandFocus;
use smithay::wayland::security_context::SecurityContextState;
use smithay::wayland::selection::data_device::{set_data_device_selection, DataDeviceState};
use smithay::wayland::selection::primary_selection::PrimarySelectionState;
Expand Down Expand Up @@ -3170,16 +3171,13 @@ impl Niri {
// However, this should probably be restricted to sending frame callbacks to more surfaces,
// to err on the safe side.
self.send_frame_callbacks(output);
#[cfg(feature = "xdp-gnome-screencast")]
self.send_frame_callbacks_for_cast(output);
backend.with_primary_renderer(|renderer| {
#[cfg(feature = "xdp-gnome-screencast")]
{
// Render and send to PipeWire screencast streams.
self.render_for_screen_cast(renderer, output, target_presentation_time);

// FIXME: when a window is hidden, it should probably still receive frame callbacks
// and get rendered for screen cast. This is currently
// unimplemented, but happens to work by chance, since output
// redrawing is more eager than it should be.
self.render_windows_for_screen_cast(renderer, output, target_presentation_time);
}

Expand Down Expand Up @@ -3576,6 +3574,37 @@ impl Niri {
}
}

#[cfg(feature = "xdp-gnome-screencast")]
fn send_frame_callbacks_for_cast(&self, output: &Output) {
let _span = tracy_client::span!("Niri::send_frame_callbacks_for_cast");
let frame_callback_time = get_monotonic_time();

for mapped in self.layout.windows_for_output(output) {
for cast in &self.casts {
if !cast.is_active.get() {
continue;
}
let CastTarget::Window { id } = cast.target else {
continue;
};
if u64::from(mapped.id().get()) != id {
continue;
};
let Some(surface) = mapped.window.wl_surface() else {
continue;
};

send_frames_surface_tree(
surface.as_ref(),
output,
frame_callback_time,
FRAME_CALLBACK_THROTTLE,
|_, _| Some(output.clone()),
);
}
}
}

pub fn take_presentation_feedbacks(
&mut self,
output: &Output,
Expand Down

0 comments on commit 37dadf9

Please sign in to comment.