diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-06-09 11:55:43 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-06-10 18:08:01 +0300 |
| commit | dbe810d3d8086770fa27b1b78c615f2dccd72a11 (patch) | |
| tree | dfed95cbe1556233ad91336645b05ca8bab4c76f /src/utils/mod.rs | |
| parent | a1563b9132c3ba49ed80dbb9011846ea0c825caf (diff) | |
| download | niri-dbe810d3d8086770fa27b1b78c615f2dccd72a11.tar.gz niri-dbe810d3d8086770fa27b1b78c615f2dccd72a11.tar.bz2 niri-dbe810d3d8086770fa27b1b78c615f2dccd72a11.zip | |
Move apply_scale() to utils
Diffstat (limited to 'src/utils/mod.rs')
| -rw-r--r-- | src/utils/mod.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 7d41b923..2fd1d8f8 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -90,6 +90,11 @@ pub fn center_f64(rect: Rectangle<f64, Logical>) -> Point<f64, Logical> { rect.loc + rect.size.downscale(2.0).to_point() } +/// Convert logical pixels to physical, rounding to physical pixels. +pub fn apply_scale(scale: f64, val: i32) -> i32 { + (f64::from(val) * scale).round() as i32 +} + pub fn output_size(output: &Output) -> Size<i32, Logical> { let output_scale = output.current_scale().integer_scale(); let output_transform = output.current_transform(); |
