diff options
author | 2024-08-30 13:02:49 +0200 | |
---|---|---|
committer | 2024-08-30 13:02:49 +0200 | |
commit | 0dcec519be23da6d3bc409dbf7ac65407d59dc12 (patch) | |
tree | 1ba155b8948c0088db797b88ede135ff35517b61 /winit | |
parent | 043f0302142e46bf1d7ba2015f83261813280fec (diff) | |
download | iced-0dcec519be23da6d3bc409dbf7ac65407d59dc12.tar.gz iced-0dcec519be23da6d3bc409dbf7ac65407d59dc12.tar.bz2 iced-0dcec519be23da6d3bc409dbf7ac65407d59dc12.zip |
Add `get_scale_factor` task to `window` module
Diffstat (limited to 'winit')
-rw-r--r-- | winit/src/program.rs | 9 | ||||
-rw-r--r-- | winit/src/program/window_manager.rs | 4 |
2 files changed, 12 insertions, 1 deletions
diff --git a/winit/src/program.rs b/winit/src/program.rs index c5c3133d..54221c68 100644 --- a/winit/src/program.rs +++ b/winit/src/program.rs @@ -1291,7 +1291,7 @@ fn run_action<P, C>( } } window::Action::GetPosition(id, channel) => { - if let Some(window) = window_manager.get_mut(id) { + if let Some(window) = window_manager.get(id) { let position = window .raw .inner_position() @@ -1306,6 +1306,13 @@ fn run_action<P, C>( let _ = channel.send(position); } } + window::Action::GetScaleFactor(id, channel) => { + if let Some(window) = window_manager.get_mut(id) { + let scale_factor = window.raw.scale_factor(); + + let _ = channel.send(scale_factor as f32); + } + } window::Action::Move(id, position) => { if let Some(window) = window_manager.get_mut(id) { window.raw.set_outer_position( diff --git a/winit/src/program/window_manager.rs b/winit/src/program/window_manager.rs index fcbf79f6..8cd9fab7 100644 --- a/winit/src/program/window_manager.rs +++ b/winit/src/program/window_manager.rs @@ -80,6 +80,10 @@ where self.entries.iter_mut().map(|(k, v)| (*k, v)) } + pub fn get(&self, id: Id) -> Option<&Window<P, C>> { + self.entries.get(&id) + } + pub fn get_mut(&mut self, id: Id) -> Option<&mut Window<P, C>> { self.entries.get_mut(&id) } |