From 0dcec519be23da6d3bc409dbf7ac65407d59dc12 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 30 Aug 2024 13:02:49 +0200 Subject: Add `get_scale_factor` task to `window` module --- runtime/src/window.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'runtime') 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>), + /// Get the current scale factor (DPI) of the window. + GetScaleFactor(Id, oneshot::Sender), + /// Move the window to the given logical coordinates. /// /// Unsupported on Wayland. @@ -292,6 +295,13 @@ pub fn get_position(id: Id) -> Task> { }) } +/// Gets the scale factor of the window with the given [`Id`]. +pub fn get_scale_factor(id: Id) -> Task { + task::oneshot(move |channel| { + crate::Action::Window(Action::GetScaleFactor(id, channel)) + }) +} + /// Moves the window to the given logical coordinates. pub fn move_to(id: Id, position: Point) -> Task { task::effect(crate::Action::Window(Action::Move(id, position))) -- cgit