rust-windowing / winit

Window handling library in pure Rust
https://docs.rs/winit/
Apache License 2.0
4.88k stars 911 forks source link

wayland: use correct rounding in logical->physical conversions #3955

Open mahkoh opened 1 month ago

mahkoh commented 1 month ago
/// A wp-fractional-scale scale.
///
/// This type implements the `physical_size = round_half_up(logical_size * scale)`
/// operation with infinite precision as required by the protocol.
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct Scale {
        scale: u64,
}
kchibisov commented 1 month ago

While I don't mind changing the algorithm is unspecified, which we brought before here https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/132

What winit does is what majority of compositors do (probably not yours since you've sent the patch), so we error the same.

Unless upstream issue progresses, I don't see why this new rounding is correct when there's no specification of what is correct.

mahkoh commented 1 month ago

See https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/309/diffs

What winit does is what majority of compositors do (probably not yours since you've sent the patch)

Actually my compositor also uses f64 just like winit. A mistake for sure.

kchibisov commented 1 month ago

See https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/309/diffs

You should've have linked it right away in the PR description.

Will wait until it merges and then I'll merge it here as well once review is done.