diff --git a/src/cli/randr.rs b/src/cli/randr.rs index 01509ecf..f459d29d 100644 --- a/src/cli/randr.rs +++ b/src/cli/randr.rs @@ -310,7 +310,7 @@ impl Randr { tc.send(jay_randr::SetScale { self_id: randr, output: &args.output, - scale: scale.0, + scale: scale.to_wl(), }); } OutputCommand::Mode(t) => { @@ -557,7 +557,7 @@ impl Randr { let mut data = data.borrow_mut(); let c = data.connectors.last_mut().unwrap(); c.output = Some(Output { - scale: Scale(msg.scale).to_f64(), + scale: Scale::from_wl(msg.scale).to_f64(), width: msg.width, height: msg.height, x: msg.x, diff --git a/src/ifs/jay_randr.rs b/src/ifs/jay_randr.rs index 24cb21a5..dffe241e 100644 --- a/src/ifs/jay_randr.rs +++ b/src/ifs/jay_randr.rs @@ -92,7 +92,7 @@ impl JayRandr { let pos = global.pos.get(); self.client.event(Output { self_id: self.id, - scale: global.preferred_scale.get().0, + scale: global.preferred_scale.get().to_wl(), width: pos.width(), height: pos.height(), x: pos.x1(), @@ -217,7 +217,7 @@ impl JayRandr { let Some(c) = self.get_output(req.output) else { return Ok(()); }; - c.node.set_preferred_scale(Scale(req.scale)); + c.node.set_preferred_scale(Scale::from_wl(req.scale)); Ok(()) } diff --git a/src/ifs/wl_surface/wp_fractional_scale_v1.rs b/src/ifs/wl_surface/wp_fractional_scale_v1.rs index cf948420..51e7f404 100644 --- a/src/ifs/wl_surface/wp_fractional_scale_v1.rs +++ b/src/ifs/wl_surface/wp_fractional_scale_v1.rs @@ -39,7 +39,14 @@ impl WpFractionalScaleV1 { pub fn send_preferred_scale(&self) { self.client.event(PreferredScale { self_id: self.id, - scale: self.surface.output.get().global.preferred_scale.get().0, + scale: self + .surface + .output + .get() + .global + .preferred_scale + .get() + .to_wl(), }); } diff --git a/src/portal/ptr_gui.rs b/src/portal/ptr_gui.rs index 668675f6..5fbb3793 100644 --- a/src/portal/ptr_gui.rs +++ b/src/portal/ptr_gui.rs @@ -852,7 +852,7 @@ impl UsrWlBufferOwner for GuiBuffer { impl UsrWpFractionalScaleOwner for WindowData { fn preferred_scale(self: Rc, ev: &PreferredScale) { let mut layout = self.first_scale.replace(false); - let scale = Scale(ev.scale); + let scale = Scale::from_wl(ev.scale); layout |= self.scale.replace(scale) != scale; if layout { self.layout(); diff --git a/src/scale.rs b/src/scale.rs index 96900ca8..d481766b 100644 --- a/src/scale.rs +++ b/src/scale.rs @@ -5,7 +5,7 @@ const BASEF: f64 = BASE as f64; #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] #[repr(transparent)] -pub struct Scale(pub u32); +pub struct Scale(u32); impl Scale { pub fn from_int(f: u32) -> Self { @@ -23,6 +23,14 @@ impl Scale { pub fn round_up(self) -> u32 { self.0.saturating_add(BASE - 1) / BASE } + + pub fn from_wl(wl: u32) -> Self { + Self(wl) + } + + pub fn to_wl(self) -> u32 { + self.0 + } } impl PartialEq for Scale {