diff options
Diffstat (limited to 'winit/src')
| -rw-r--r-- | winit/src/application.rs | 18 | ||||
| -rw-r--r-- | winit/src/debug/basic.rs | 2 | 
2 files changed, 13 insertions, 7 deletions
diff --git a/winit/src/application.rs b/winit/src/application.rs index 00625052..3772a667 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -124,7 +124,7 @@ pub trait Application: Sized {          let dpi = window.hidpi_factor();          let mut size = window.inner_size(); -        let mut new_size: Option<winit::dpi::LogicalSize> = None; +        let mut resized = false;          let mut renderer = Self::Renderer::new(); @@ -157,6 +157,11 @@ pub trait Application: Sized {          event_loop.run(move |event, _, control_flow| match event {              event::Event::MainEventsCleared => { +                if events.is_empty() && external_messages.is_empty() && !resized +                { +                    return; +                } +                  // TODO: We should be able to keep a user interface alive                  // between events once we remove state references.                  // @@ -231,9 +236,9 @@ pub trait Application: Sized {              event::Event::RedrawRequested(_) => {                  debug.render_started(); -                if let Some(new_size) = new_size.take() { +                if resized {                      let dpi = window.hidpi_factor(); -                    let (width, height) = to_physical(new_size, dpi); +                    let (width, height) = to_physical(size, dpi);                      target.resize(                          width, @@ -242,7 +247,7 @@ pub trait Application: Sized {                          &renderer,                      ); -                    size = new_size; +                    resized = false;                  }                  let new_mouse_cursor = @@ -334,8 +339,9 @@ pub trait Application: Sized {                  WindowEvent::CloseRequested => {                      *control_flow = ControlFlow::Exit;                  } -                WindowEvent::Resized(size) => { -                    new_size = Some(size.into()); +                WindowEvent::Resized(new_size) => { +                    size = new_size; +                    resized = true;                      log::debug!("Resized: {:?}", new_size);                  } diff --git a/winit/src/debug/basic.rs b/winit/src/debug/basic.rs index 67c6d8a2..c9da392c 100644 --- a/winit/src/debug/basic.rs +++ b/winit/src/debug/basic.rs @@ -146,7 +146,7 @@ impl Debug {          let mut lines = Vec::new();          fn key_value<T: std::fmt::Debug>(key: &str, value: T) -> String { -            format!("{: <30} {:?}", key, value) +            format!("{} {:?}", key, value)          }          lines.push(format!(  | 
