-
-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
send frame callbacks for active screencast windows #642
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3170,16 +3170,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); | ||
} | ||
|
||
|
@@ -3576,6 +3573,39 @@ impl Niri { | |
} | ||
} | ||
|
||
#[cfg(feature = "xdp-gnome-screencast")] | ||
fn send_frame_callbacks_for_cast(&self, output: &Output) { | ||
use smithay::wayland::seat::WaylandFocus; | ||
|
||
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 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()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think instead of being a separate function, this cast check should be integrated into |
||
); | ||
} | ||
} | ||
} | ||
|
||
pub fn take_presentation_feedbacks( | ||
&mut self, | ||
output: &Output, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, this comment should not be removed, it still stands. What this PR does is sends frame callbacks to off-screen windows, which makes them commit a new buffer. Which currently makes niri always redraw the output and hence render a new frame for a screencast. However, ideally niri shouldn't redraw the output if the window that committed a new buffer is fully off-screen. I will at some point add that optimization, which will once again stop off-screen windows from rendering for screencasts (or receiving frame callbacks from this PR for that matter), until this is fixed in a different way.