Fix calling request_repaint_after every frame causing immediate repaint (#3978)

* Closes https://github.com/emilk/egui/pull/3925
* Closes #3109
This commit is contained in:
Emil Ernerfeldt 2024-02-05 14:45:49 +01:00 committed by GitHub
parent d018265587
commit 1858167296
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 3 deletions

View File

@ -148,9 +148,16 @@ impl ContextImpl {
) {
let viewport = self.viewports.entry(viewport_id).or_default();
// Each request results in two repaints, just to give some things time to settle.
// This solves some corner-cases of missing repaints on frame-delayed responses.
viewport.repaint.outstanding = 1;
if delay == Duration::ZERO {
// Each request results in two repaints, just to give some things time to settle.
// This solves some corner-cases of missing repaints on frame-delayed responses.
viewport.repaint.outstanding = 1;
} else {
// For non-zero delays, we only repaint once, because
// otherwise we would just schedule an immediate repaint _now_,
// which would then clear the delay and repaint again.
// Hovering a tooltip is a good example of a case where we want to repaint after a delay.
}
viewport.repaint.causes.push(cause);