1
0
Fork 0
forked from wry/wry

scale: make wl representation private

This commit is contained in:
Julian Orth 2024-03-16 01:28:57 +01:00
parent 355a9eb240
commit bc9b1c3638
5 changed files with 22 additions and 7 deletions

View file

@ -310,7 +310,7 @@ impl Randr {
tc.send(jay_randr::SetScale { tc.send(jay_randr::SetScale {
self_id: randr, self_id: randr,
output: &args.output, output: &args.output,
scale: scale.0, scale: scale.to_wl(),
}); });
} }
OutputCommand::Mode(t) => { OutputCommand::Mode(t) => {
@ -557,7 +557,7 @@ impl Randr {
let mut data = data.borrow_mut(); let mut data = data.borrow_mut();
let c = data.connectors.last_mut().unwrap(); let c = data.connectors.last_mut().unwrap();
c.output = Some(Output { c.output = Some(Output {
scale: Scale(msg.scale).to_f64(), scale: Scale::from_wl(msg.scale).to_f64(),
width: msg.width, width: msg.width,
height: msg.height, height: msg.height,
x: msg.x, x: msg.x,

View file

@ -92,7 +92,7 @@ impl JayRandr {
let pos = global.pos.get(); let pos = global.pos.get();
self.client.event(Output { self.client.event(Output {
self_id: self.id, self_id: self.id,
scale: global.preferred_scale.get().0, scale: global.preferred_scale.get().to_wl(),
width: pos.width(), width: pos.width(),
height: pos.height(), height: pos.height(),
x: pos.x1(), x: pos.x1(),
@ -217,7 +217,7 @@ impl JayRandr {
let Some(c) = self.get_output(req.output) else { let Some(c) = self.get_output(req.output) else {
return Ok(()); return Ok(());
}; };
c.node.set_preferred_scale(Scale(req.scale)); c.node.set_preferred_scale(Scale::from_wl(req.scale));
Ok(()) Ok(())
} }

View file

@ -39,7 +39,14 @@ impl WpFractionalScaleV1 {
pub fn send_preferred_scale(&self) { pub fn send_preferred_scale(&self) {
self.client.event(PreferredScale { self.client.event(PreferredScale {
self_id: self.id, 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(),
}); });
} }

View file

@ -852,7 +852,7 @@ impl UsrWlBufferOwner for GuiBuffer {
impl UsrWpFractionalScaleOwner for WindowData { impl UsrWpFractionalScaleOwner for WindowData {
fn preferred_scale(self: Rc<Self>, ev: &PreferredScale) { fn preferred_scale(self: Rc<Self>, ev: &PreferredScale) {
let mut layout = self.first_scale.replace(false); 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; layout |= self.scale.replace(scale) != scale;
if layout { if layout {
self.layout(); self.layout();

View file

@ -5,7 +5,7 @@ const BASEF: f64 = BASE as f64;
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(transparent)] #[repr(transparent)]
pub struct Scale(pub u32); pub struct Scale(u32);
impl Scale { impl Scale {
pub fn from_int(f: u32) -> Self { pub fn from_int(f: u32) -> Self {
@ -23,6 +23,14 @@ impl Scale {
pub fn round_up(self) -> u32 { pub fn round_up(self) -> u32 {
self.0.saturating_add(BASE - 1) / BASE 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<u32> for Scale { impl PartialEq<u32> for Scale {