diff options
author | 2022-09-20 18:40:36 +0200 | |
---|---|---|
committer | 2022-09-20 18:40:36 +0200 | |
commit | 1bfd032169f3f297c7d7fa0938991ad122d93429 (patch) | |
tree | 60cd7eaf65076db8b3df634e66ecfa7f3b836941 /winit | |
parent | b113bb8a097b9ffcb6940be3f84892f206b7132f (diff) | |
download | iced-1bfd032169f3f297c7d7fa0938991ad122d93429.tar.gz iced-1bfd032169f3f297c7d7fa0938991ad122d93429.tar.bz2 iced-1bfd032169f3f297c7d7fa0938991ad122d93429.zip |
Improve code styling in `application::State`
Diffstat (limited to 'winit')
-rw-r--r-- | winit/src/application/state.rs | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/winit/src/application/state.rs b/winit/src/application/state.rs index 5525cbd5..9c539548 100644 --- a/winit/src/application/state.rs +++ b/winit/src/application/state.rs @@ -3,7 +3,6 @@ use crate::conversion; use crate::{Application, Color, Debug, Point, Size, Viewport}; use std::marker::PhantomData; -use winit::dpi::PhysicalSize; use winit::event::{Touch, WindowEvent}; use winit::window::Window; @@ -193,18 +192,15 @@ where // Update scale factor and size let new_scale_factor = application.scale_factor(); - let Size { width, height } = self.viewport.physical_size(); - let PhysicalSize { - width: w_width, - height: w_height, - } = window.inner_size(); + let new_size = window.inner_size(); + let current_size = self.viewport.physical_size(); + if self.scale_factor != new_scale_factor - || (width, height) != (w_width, w_height) + || (current_size.width, current_size.height) + != (new_size.width, new_size.height) { - let size = window.inner_size(); - self.viewport = Viewport::with_physical_size( - Size::new(size.width, size.height), + Size::new(new_size.width, new_size.height), window.scale_factor() * new_scale_factor, ); self.viewport_version = self.viewport_version.wrapping_add(1); |