Add get_scale_factor task to window module

This commit is contained in:
Héctor Ramón Jiménez 2024-08-30 13:02:49 +02:00
parent 043f030214
commit 0dcec519be
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
3 changed files with 22 additions and 1 deletions

View file

@ -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)))