Avoid redrawing window twice on RedrawRequested

This commit is contained in:
Héctor Ramón Jiménez 2025-10-16 17:25:04 +02:00
parent 6c93efa2a9
commit f7425db87e
No known key found for this signature in database
GPG key ID: 4C07CEC81AFA161F

View file

@ -881,16 +881,16 @@ async fn run_instance<P>(
let mut has_window_resized = false;
for action in actions {
has_window_resized = has_window_resized
|| matches!(
action,
Action::Window(
runtime::window::Action::Resize(
_,
_
)
)
);
if let Action::Window(
runtime::window::Action::Resize(
window_id,
_,
),
) = action
&& window_id == id
{
has_window_resized = true;
}
run_action(
action,
@ -909,6 +909,17 @@ async fn run_instance<P>(
);
}
for (window_id, window) in
window_manager.iter_mut()
{
// We are already redrawing this window
if window_id == id {
continue;
}
window.raw.request_redraw();
}
let Some(next_compositor) = compositor.as_mut()
else {
continue 'next_event;
@ -1202,6 +1213,10 @@ async fn run_instance<P>(
&mut system_theme,
);
}
for (_id, window) in window_manager.iter_mut() {
window.raw.request_redraw();
}
}
if let Some(redraw_at) = window_manager.redraw_at() {
@ -1731,7 +1746,6 @@ where
{
for (id, window) in window_manager.iter_mut() {
window.state.synchronize(program, id, &window.raw);
window.raw.request_redraw();
}
debug::theme_changed(|| {