diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-06-09 13:04:01 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-06-17 09:02:22 +0300 |
| commit | 6c47bd6e80500c66273a5c14993343d70efe6c39 (patch) | |
| tree | b907fd046ac15c5042d2e062bdc2d297fde8d54c /src/utils/mod.rs | |
| parent | 02c2972e7446347d623c65bd52d45e5fa31209c8 (diff) | |
| download | niri-6c47bd6e80500c66273a5c14993343d70efe6c39.tar.gz niri-6c47bd6e80500c66273a5c14993343d70efe6c39.tar.bz2 niri-6c47bd6e80500c66273a5c14993343d70efe6c39.zip | |
Rename apply_scale to to_physical_precise_round
Consistency with Smithay.
Diffstat (limited to 'src/utils/mod.rs')
| -rw-r--r-- | src/utils/mod.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 2fd1d8f8..807244fa 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -16,7 +16,7 @@ use smithay::output::{self, Output}; use smithay::reexports::rustix::time::{clock_gettime, ClockId}; use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel; use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; -use smithay::utils::{Logical, Point, Rectangle, Size, Transform}; +use smithay::utils::{Coordinate, Logical, Point, Rectangle, Size, Transform}; use smithay::wayland::compositor::{send_surface_state, SurfaceData}; use smithay::wayland::fractional_scale::with_fractional_scale; @@ -91,8 +91,8 @@ pub fn center_f64(rect: Rectangle<f64, Logical>) -> Point<f64, Logical> { } /// 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 to_physical_precise_round<N: Coordinate>(scale: f64, logical: impl Coordinate) -> N { + N::from_f64((logical.to_f64() * scale).round()) } pub fn output_size(output: &Output) -> Size<i32, Logical> { |
