Skip to content

Commit

Permalink
Prioritize redraws over processing updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmoulton committed Feb 5, 2025
1 parent 03a9582 commit 1982733
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/window_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ pub(crate) struct WindowHandle {
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
pub(crate) context_menu: RwSignal<Option<(Menu, Point, bool)>>,
dropper_file: Option<PathBuf>,
has_pending_redraw: bool,
}

impl WindowHandle {
Expand Down Expand Up @@ -172,6 +173,7 @@ impl WindowHandle {
context_menu,
last_pointer_down: None,
dropper_file: None,
has_pending_redraw: false,
};
window_handle.app_state.set_root_size(size.get_untracked());
if let Some(theme) = theme.get_untracked() {
Expand Down Expand Up @@ -407,7 +409,7 @@ impl WindowHandle {
}
}

self.process_update();
self.process_update()
}

pub(crate) fn scale(&mut self, scale: f64) {
Expand Down Expand Up @@ -632,6 +634,7 @@ impl WindowHandle {
}

pub fn paint(&mut self) -> Option<peniko::Image> {
self.has_pending_redraw = false;
let mut cx = PaintCx {
app_state: &mut self.app_state,
paint_state: &mut self.paint_state,
Expand Down Expand Up @@ -743,8 +746,11 @@ impl WindowHandle {
}

pub(crate) fn process_update(&mut self) {
if self.process_update_no_paint() {
self.schedule_repaint();
if !self.has_pending_redraw {
if self.process_update_no_paint() {
self.has_pending_redraw = true;
self.schedule_repaint();
}
}
}

Expand Down

0 comments on commit 1982733

Please sign in to comment.