From 21a71b753d6da2233bce913f4e623ee14859ec23 Mon Sep 17 00:00:00 2001 From: Yiğit Özdemir Date: Wed, 21 Jun 2023 19:43:20 +0300 Subject: Add command to retrieve window size --- winit/src/application.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'winit/src') diff --git a/winit/src/application.rs b/winit/src/application.rs index be416ac8..ff5afa69 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -3,6 +3,7 @@ mod profiler; mod state; +use iced_graphics::core::window::SizeType; pub use state::State; use crate::conversion; @@ -747,6 +748,21 @@ pub fn run_command( height, }); } + window::Action::FetchSize { + size_type, + callback, + } => { + let width_height = match size_type { + SizeType::Inner => window.inner_size(), + SizeType::Outer => window.outer_size(), + }; + let width_height = + (width_height.width, width_height.height); + + proxy + .send_event(callback(width_height)) + .expect("Send message to event loop") + } window::Action::Maximize(maximized) => { window.set_maximized(maximized); } -- cgit From b394c84b37eacb266d45663d5d6626f1b616af7e Mon Sep 17 00:00:00 2001 From: Yiğit Özdemir Date: Thu, 22 Jun 2023 18:28:32 +0300 Subject: Add FetchSize command - apply the changes discussed at #water-cooler --- winit/src/application.rs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'winit/src') diff --git a/winit/src/application.rs b/winit/src/application.rs index ff5afa69..b0824e0e 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -3,7 +3,6 @@ mod profiler; mod state; -use iced_graphics::core::window::SizeType; pub use state::State; use crate::conversion; @@ -748,19 +747,11 @@ pub fn run_command( height, }); } - window::Action::FetchSize { - size_type, - callback, - } => { - let width_height = match size_type { - SizeType::Inner => window.inner_size(), - SizeType::Outer => window.outer_size(), - }; - let width_height = - (width_height.width, width_height.height); + window::Action::FetchSize(callback) => { + let size = window.inner_size(); proxy - .send_event(callback(width_height)) + .send_event(callback((size.width, size.height))) .expect("Send message to event loop") } window::Action::Maximize(maximized) => { -- cgit From cc32bd4de09ee58c15d1b3f2cec4a79dc65dd035 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 6 Jul 2023 06:41:28 +0200 Subject: Use `Size` in both `Resize` and `FetchSize` window actions --- winit/src/application.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'winit/src') diff --git a/winit/src/application.rs b/winit/src/application.rs index b0824e0e..afc523b6 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -741,17 +741,20 @@ pub fn run_command( window::Action::Drag => { let _res = window.drag_window(); } - window::Action::Resize { width, height } => { + window::Action::Resize(size) => { window.set_inner_size(winit::dpi::LogicalSize { - width, - height, + width: size.width, + height: size.height, }); } window::Action::FetchSize(callback) => { let size = window.inner_size(); proxy - .send_event(callback((size.width, size.height))) + .send_event(callback(Size::new( + size.width, + size.height, + ))) .expect("Send message to event loop") } window::Action::Maximize(maximized) => { -- cgit