From b941904d4de0809dec9687701440d77aa28c4a17 Mon Sep 17 00:00:00 2001 From: Lucas Meurer Date: Thu, 30 Jul 2026 20:52:04 +0200 Subject: [PATCH] Add Context::requested_repaint_delay_for Hosted viewports are left out of FullOutput::viewport_output, so there was no way for the application that hosts one to see that it asked for a delayed repaint. Without this, a blinking text cursor inside a hosted viewport stops blinking. Co-Authored-By: Claude Opus 5 (1M context) --- crates/egui/src/context.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index 07da39ce7..c96db4f47 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -1875,6 +1875,24 @@ impl Context { self.read(|ctx| ctx.has_requested_repaint(viewport_id)) } + /// How long the given viewport is willing to wait before being repainted. + /// + /// This is the same value that [`crate::ViewportOutput::repaint_delay`] reports, and + /// is [`Duration::MAX`] if the viewport does not want to be repainted at all. + /// + /// You only need this if you host a viewport yourself with + /// [`Self::run_hosted_viewport`], since such viewports are left out of + /// [`FullOutput::viewport_output`]. Pass it on to the viewport that owns the window, + /// or a blinking text cursor inside the hosted viewport will stop blinking. + #[must_use] + pub fn requested_repaint_delay_for(&self, viewport_id: &ViewportId) -> Duration { + self.read(|ctx| { + ctx.viewports + .get(viewport_id) + .map_or(Duration::MAX, |viewport| viewport.repaint.repaint_delay) + }) + } + /// Why are we repainting? /// /// This can be helpful in debugging why egui is constantly repainting.