Skip to content

Commit f23103d

Browse files
committed
Dont run update on resizes
1 parent 69bb3e6 commit f23103d

File tree

2 files changed

+1
-17
lines changed

2 files changed

+1
-17
lines changed

src/glass.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ impl ApplicationHandler for Glass {
9999
} = self;
100100
app.window_input(context, event_loop, window_id, &event);
101101

102-
let mut is_extra_update = false;
103-
104102
if let Some(window) = context.windows.get_mut(&window_id) {
105103
match event {
106104
WindowEvent::Resized(physical_size) => {
@@ -110,15 +108,13 @@ impl ApplicationHandler for Glass {
110108
context.device_context.device(),
111109
physical_size,
112110
);
113-
is_extra_update = true;
114111
}
115112
}
116113
WindowEvent::ScaleFactorChanged {
117114
..
118115
} => {
119116
let size = window.window().inner_size();
120117
window.configure_surface_with_size(context.device_context.device(), size);
121-
is_extra_update = true;
122118
}
123119
WindowEvent::KeyboardInput {
124120
event,
@@ -145,19 +141,6 @@ impl ApplicationHandler for Glass {
145141
_ => (),
146142
}
147143
}
148-
// Update immediately, because about_to_wait isn't triggered during resize. If it did,
149-
// this would not be needed.
150-
151-
// Winit recommends running rendering inside `RequestRedraw`, but that doesn't really
152-
// seem good to me, because I want render to take place immediately after update, and
153-
// running entire app's update within one window's `RequestRedraw` doesn't make sense
154-
// to me.
155-
156-
// This ensures resizing's effect is instant. Kinda ugly on performance, but that doesn't
157-
// matter, because resize is a rare event.
158-
if is_extra_update {
159-
run_update(event_loop, app, context, runner_state);
160-
}
161144
}
162145

163146
fn device_event(

src/window.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ impl GlassWindow {
267267
.unwrap_or_default();
268268
commands.push(encoder.finish());
269269
queue.submit(commands);
270+
self.window().pre_present_notify();
270271
frame.present();
271272
}
272273
Err(error) => {

0 commit comments

Comments
 (0)