diff options
author | 2024-08-30 13:02:49 +0200 | |
---|---|---|
committer | 2024-08-30 13:02:49 +0200 | |
commit | 0dcec519be23da6d3bc409dbf7ac65407d59dc12 (patch) | |
tree | 1ba155b8948c0088db797b88ede135ff35517b61 /runtime | |
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 'runtime')
-rw-r--r-- | runtime/src/window.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/runtime/src/window.rs b/runtime/src/window.rs index cd27cdfe..ce6fd1b6 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -63,6 +63,9 @@ pub enum Action { /// Get the current logical coordinates of the window. GetPosition(Id, oneshot::Sender<Option<Point>>), + /// Get the current scale factor (DPI) of the window. + GetScaleFactor(Id, oneshot::Sender<f32>), + /// Move the window to the given logical coordinates. /// /// Unsupported on Wayland. @@ -292,6 +295,13 @@ pub fn get_position(id: Id) -> Task<Option<Point>> { }) } +/// Gets the scale factor of the window with the given [`Id`]. +pub fn get_scale_factor(id: Id) -> Task<f32> { + task::oneshot(move |channel| { + crate::Action::Window(Action::GetScaleFactor(id, channel)) + }) +} + /// Moves the window to the given logical coordinates. pub fn move_to<T>(id: Id, position: Point) -> Task<T> { task::effect(crate::Action::Window(Action::Move(id, position))) |