From 5125337b42170ee4a5eb43adfdf2d82e20d993a2 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Tue, 1 Aug 2023 16:50:50 +0200 Subject: [PATCH] loop: Schedule rendering for running animations on idle --- src/main.rs | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index c53275d9..74f514a1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,10 @@ use anyhow::{Context, Result}; use std::{ffi::OsString, os::unix::prelude::AsRawFd, sync::Arc}; use tracing::{error, info, warn}; -use crate::wayland::handlers::compositor::client_compositor_state; +use crate::wayland::{ + handlers::{compositor::client_compositor_state, screencopy::PendingScreencopyBuffers}, + protocols::screencopy::SessionType, +}; pub mod backend; pub mod config; @@ -76,6 +79,35 @@ fn main() -> Result<()> { } } data.state.common.shell.refresh(); + if data.state.common.shell.animations_going() { + for output in data.state.common.shell.outputs() { + let mut scheduled_sessions = None; + if let Some(sessions) = output.user_data().get::() { + scheduled_sessions + .get_or_insert_with(Vec::new) + .extend(sessions.borrow_mut().drain(..)); + } + + data.state.backend.schedule_render( + &data.state.common.event_loop_handle, + &output, + scheduled_sessions.as_ref().map(|sessions| { + sessions + .iter() + .filter(|(s, _)| match s.session_type() { + SessionType::Output(o) | SessionType::Workspace(o, _) + if &o == output => + { + true + } + _ => false, + }) + .cloned() + .collect::>() + }), + ); + } + } state::Common::refresh_focus(&mut data.state); // send out events