scale: make wl representation private
This commit is contained in:
parent
355a9eb240
commit
bc9b1c3638
5 changed files with 22 additions and 7 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -852,7 +852,7 @@ impl UsrWlBufferOwner for GuiBuffer {
|
|||
impl UsrWpFractionalScaleOwner for WindowData {
|
||||
fn preferred_scale(self: Rc<Self>, 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();
|
||||
|
|
|
|||
10
src/scale.rs
10
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<u32> for Scale {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue