summaryrefslogtreecommitdiffstats
path: root/winit
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-10-29 20:53:29 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-11-05 23:52:58 +0100
commitc6af79a1d06013343f9caf2de80597d627254084 (patch)
tree123d5752eb3ee6c3ada00776eafded5428994482 /winit
parent4e47450c336a235fe26090665aca1cc7b4d23384 (diff)
downloadiced-c6af79a1d06013343f9caf2de80597d627254084.tar.gz
iced-c6af79a1d06013343f9caf2de80597d627254084.tar.bz2
iced-c6af79a1d06013343f9caf2de80597d627254084.zip
Fix deferred layout on resize after drawing
Diffstat (limited to 'winit')
-rw-r--r--winit/src/program.rs92
1 files changed, 33 insertions, 59 deletions
diff --git a/winit/src/program.rs b/winit/src/program.rs
index fb30ccd9..d7afb969 100644
--- a/winit/src/program.rs
+++ b/winit/src/program.rs
@@ -818,6 +818,39 @@ async fn run_instance<P, C>(
continue;
};
+ let physical_size = window.state.physical_size();
+
+ if physical_size.width == 0 || physical_size.height == 0
+ {
+ continue;
+ }
+
+ if window.viewport_version
+ != window.state.viewport_version()
+ {
+ let logical_size = window.state.logical_size();
+
+ debug.layout_started();
+ let ui = user_interfaces
+ .remove(&id)
+ .expect("Remove user interface");
+
+ let _ = user_interfaces.insert(
+ id,
+ ui.relayout(logical_size, &mut window.renderer),
+ );
+ debug.layout_finished();
+
+ compositor.configure_surface(
+ &mut window.surface,
+ physical_size.width,
+ physical_size.height,
+ );
+
+ window.viewport_version =
+ window.state.viewport_version();
+ }
+
let redraw_event = core::Event::Window(
window::Event::RedrawRequested(Instant::now()),
);
@@ -877,65 +910,6 @@ async fn run_instance<P, C>(
}
}
- let physical_size = window.state.physical_size();
-
- if physical_size.width == 0 || physical_size.height == 0
- {
- continue;
- }
-
- if window.viewport_version
- != window.state.viewport_version()
- {
- let logical_size = window.state.logical_size();
-
- debug.layout_started();
- let ui = user_interfaces
- .remove(&id)
- .expect("Remove user interface");
-
- let _ = user_interfaces.insert(
- id,
- ui.relayout(logical_size, &mut window.renderer),
- );
- debug.layout_finished();
-
- debug.draw_started();
- let new_mouse_interaction = user_interfaces
- .get_mut(&id)
- .expect("Get user interface")
- .draw(
- &mut window.renderer,
- window.state.theme(),
- &renderer::Style {
- text_color: window.state.text_color(),
- },
- window.state.cursor(),
- );
- debug.draw_finished();
-
- if new_mouse_interaction != window.mouse_interaction
- {
- window.raw.set_cursor(
- conversion::mouse_interaction(
- new_mouse_interaction,
- ),
- );
-
- window.mouse_interaction =
- new_mouse_interaction;
- }
-
- compositor.configure_surface(
- &mut window.surface,
- physical_size.width,
- physical_size.height,
- );
-
- window.viewport_version =
- window.state.viewport_version();
- }
-
debug.render_started();
match compositor.present(
&mut window.renderer,