Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions crates/egui/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ impl ContextImpl {
pixels_per_point,
self.memory.options.input_options,
);
let repaint_after = viewport.input.wants_repaint_after();

let screen_rect = viewport.input.screen_rect;

Expand Down Expand Up @@ -553,6 +554,10 @@ impl ContextImpl {
}

self.update_fonts_mut();

if let Some(delay) = repaint_after {
self.request_repaint_after(delay, viewport_id, RepaintCause::new());
}
}

/// Load fonts unless already loaded.
Expand Down Expand Up @@ -2398,10 +2403,7 @@ impl ContextImpl {

if repaint_needed {
self.request_repaint(ended_viewport_id, RepaintCause::new());
} else if let Some(delay) = viewport.input.wants_repaint_after() {
self.request_repaint_after(delay, ended_viewport_id, RepaintCause::new());
}

// -------------------

let all_viewport_ids = self.all_viewport_ids();
Expand Down
8 changes: 6 additions & 2 deletions crates/egui/src/input_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,10 +597,14 @@ impl InputState {
(self.time - self.last_scroll_time) as f32
}

/// The [`crate::Context`] will call this at the end of each frame to see if we need a repaint.
/// The [`crate::Context`] will call this at the beginning of each frame to see if we need a repaint.
///
/// Returns how long to wait for a repaint.
pub fn wants_repaint_after(&self) -> Option<Duration> {
///
/// NOTE: It's important to call this immediately after [`Self::begin_pass`] since calls to
/// [`Self::consume_key`] will remove events from the vec, meaning those key presses wouldn't
/// cause a repaint.
pub(crate) fn wants_repaint_after(&self) -> Option<Duration> {
if self.pointer.wants_repaint()
|| self.unprocessed_scroll_delta.abs().max_elem() > 0.2
|| self.unprocessed_scroll_delta_for_zoom.abs() > 0.2
Expand Down