Skip to content

Commit 26f5c46

Browse files
committed
send frame callbacks for active screencast windows
1 parent 598b27f commit 26f5c46

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

src/niri.rs

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ use smithay::wayland::pointer_constraints::{with_pointer_constraint, PointerCons
8282
use smithay::wayland::pointer_gestures::PointerGesturesState;
8383
use smithay::wayland::presentation::PresentationState;
8484
use smithay::wayland::relative_pointer::RelativePointerManagerState;
85+
use smithay::wayland::seat::WaylandFocus;
8586
use smithay::wayland::security_context::SecurityContextState;
8687
use smithay::wayland::selection::data_device::{set_data_device_selection, DataDeviceState};
8788
use smithay::wayland::selection::primary_selection::PrimarySelectionState;
@@ -3154,16 +3155,13 @@ impl Niri {
31543155
// However, this should probably be restricted to sending frame callbacks to more surfaces,
31553156
// to err on the safe side.
31563157
self.send_frame_callbacks(output);
3158+
#[cfg(feature = "xdp-gnome-screencast")]
3159+
self.send_frame_callbacks_for_cast(output);
31573160
backend.with_primary_renderer(|renderer| {
31583161
#[cfg(feature = "xdp-gnome-screencast")]
31593162
{
31603163
// Render and send to PipeWire screencast streams.
31613164
self.render_for_screen_cast(renderer, output, target_presentation_time);
3162-
3163-
// FIXME: when a window is hidden, it should probably still receive frame callbacks
3164-
// and get rendered for screen cast. This is currently
3165-
// unimplemented, but happens to work by chance, since output
3166-
// redrawing is more eager than it should be.
31673165
self.render_windows_for_screen_cast(renderer, output, target_presentation_time);
31683166
}
31693167

@@ -3562,6 +3560,37 @@ impl Niri {
35623560
}
35633561
}
35643562

3563+
#[cfg(feature = "xdp-gnome-screencast")]
3564+
fn send_frame_callbacks_for_cast(&self, output: &Output) {
3565+
let _span = tracy_client::span!("Niri::send_frame_callbacks_for_cast");
3566+
let frame_callback_time = get_monotonic_time();
3567+
3568+
for mapped in self.layout.windows_for_output(output) {
3569+
for cast in &self.casts {
3570+
if !cast.is_active.get() {
3571+
continue;
3572+
}
3573+
let CastTarget::Window { id } = cast.target else {
3574+
continue;
3575+
};
3576+
if u64::from(mapped.id().get()) != id {
3577+
continue;
3578+
};
3579+
let Some(surface) = mapped.window.wl_surface() else {
3580+
continue;
3581+
};
3582+
3583+
send_frames_surface_tree(
3584+
surface.as_ref(),
3585+
output,
3586+
frame_callback_time,
3587+
FRAME_CALLBACK_THROTTLE,
3588+
|_, _| Some(output.clone()),
3589+
);
3590+
}
3591+
}
3592+
}
3593+
35653594
pub fn take_presentation_feedbacks(
35663595
&mut self,
35673596
output: &Output,

0 commit comments

Comments
 (0)