1
0
Fork 0
forked from wry/wry

tree: update to latest version of wp_fractional_scale

This commit is contained in:
Julian Orth 2022-11-12 15:05:58 +01:00
parent e61d6ab074
commit 5b2eb5855a
22 changed files with 104 additions and 54 deletions

View file

@ -14,7 +14,6 @@ use {
clientmem::{self, ClientMemError}, clientmem::{self, ClientMemError},
config::ConfigProxy, config::ConfigProxy,
dbus::Dbus, dbus::Dbus,
fixed::Fixed,
forker, forker,
globals::Globals, globals::Globals,
ifs::{wl_output::WlOutputGlobal, wl_surface::NoneSurfaceExt}, ifs::{wl_output::WlOutputGlobal, wl_surface::NoneSurfaceExt},
@ -22,6 +21,7 @@ use {
leaks, leaks,
logger::Logger, logger::Logger,
render::{self, RenderError}, render::{self, RenderError},
scale::Scale,
sighand::{self, SighandError}, sighand::{self, SighandError},
state::{ConnectorData, IdleState, ScreenlockState, State, XWaylandState}, state::{ConnectorData, IdleState, ScreenlockState, State, XWaylandState},
tasks::{self, idle}, tasks::{self, idle},
@ -123,7 +123,7 @@ fn start_compositor2(
let (_run_toplevel_future, run_toplevel) = RunToplevel::install(&engine); let (_run_toplevel_future, run_toplevel) = RunToplevel::install(&engine);
let node_ids = NodeIds::default(); let node_ids = NodeIds::default();
let scales = RefCounted::default(); let scales = RefCounted::default();
scales.add(Fixed::from_int(1)); scales.add(Scale::from_int(1));
let state = Rc::new(State { let state = Rc::new(State {
xkb_ctx, xkb_ctx,
backend: CloneCell::new(Rc::new(DummyBackend)), backend: CloneCell::new(Rc::new(DummyBackend)),
@ -389,7 +389,7 @@ fn create_dummy_output(state: &Rc<State>) {
scroll: Default::default(), scroll: Default::default(),
pointer_positions: Default::default(), pointer_positions: Default::default(),
lock_surface: Default::default(), lock_surface: Default::default(),
preferred_scale: Cell::new(Fixed::from_int(1)), preferred_scale: Cell::new(Scale::from_int(1)),
hardware_cursor: Default::default(), hardware_cursor: Default::default(),
update_render_data_scheduled: Cell::new(false), update_render_data_scheduled: Cell::new(false),
screencasts: Default::default(), screencasts: Default::default(),

View file

@ -7,8 +7,8 @@ use {
}, },
compositor::MAX_EXTENTS, compositor::MAX_EXTENTS,
config::ConfigProxy, config::ConfigProxy,
fixed::Fixed,
ifs::wl_seat::{SeatId, WlSeatGlobal}, ifs::wl_seat::{SeatId, WlSeatGlobal},
scale::Scale,
state::{ConnectorData, DeviceHandlerData, DrmDevData, OutputData, State}, state::{ConnectorData, DeviceHandlerData, DrmDevData, OutputData, State},
theme::{Color, ThemeSized, DEFAULT_FONT}, theme::{Color, ThemeSized, DEFAULT_FONT},
tree::{ContainerNode, ContainerSplit, FloatNode, Node, NodeVisitorBase, OutputNode}, tree::{ContainerNode, ContainerSplit, FloatNode, Node, NodeVisitorBase, OutputNode},
@ -654,7 +654,7 @@ impl ConfigProxyHandler {
if scale > 1000.0 { if scale > 1000.0 {
return Err(CphError::ScaleTooLarge(scale)); return Err(CphError::ScaleTooLarge(scale));
} }
let scale = Fixed::from_f64(scale); let scale = Scale::from_f64(scale);
let connector = self.get_output(connector)?; let connector = self.get_output(connector)?;
connector.node.set_preferred_scale(scale); connector.node.set_preferred_scale(scale);
self.state.damage(); self.state.damage();

View file

@ -4,6 +4,7 @@ use {
format::ARGB8888, format::ARGB8888,
rect::Rect, rect::Rect,
render::{RenderContext, RenderError, Renderer, Texture}, render::{RenderContext, RenderError, Renderer, Texture},
scale::Scale,
state::State, state::State,
time::Time, time::Time,
tree::OutputNode, tree::OutputNode,
@ -41,7 +42,7 @@ const HEADER_SIZE: u32 = 16;
pub trait Cursor { pub trait Cursor {
fn render(&self, renderer: &mut Renderer, x: Fixed, y: Fixed); fn render(&self, renderer: &mut Renderer, x: Fixed, y: Fixed);
fn render_hardware_cursor(&self, renderer: &mut Renderer); fn render_hardware_cursor(&self, renderer: &mut Renderer);
fn extents_at_scale(&self, scale: Fixed) -> Rect; fn extents_at_scale(&self, scale: Scale) -> Rect;
fn set_output(&self, output: &Rc<OutputNode>) { fn set_output(&self, output: &Rc<OutputNode>) {
let _ = output; let _ = output;
} }
@ -113,7 +114,7 @@ impl ServerCursors {
pub struct ServerCursorTemplate { pub struct ServerCursorTemplate {
var: ServerCursorTemplateVariant, var: ServerCursorTemplateVariant,
pub xcursor: Vec<AHashMap<(Fixed, u32), Rc<XCursorImage>>>, pub xcursor: Vec<AHashMap<(Scale, u32), Rc<XCursorImage>>>,
} }
enum ServerCursorTemplateVariant { enum ServerCursorTemplateVariant {
@ -125,7 +126,7 @@ impl ServerCursorTemplate {
fn load( fn load(
name: &str, name: &str,
theme: Option<&BStr>, theme: Option<&BStr>,
scales: &[Fixed], scales: &[Scale],
sizes: &[u32], sizes: &[u32],
paths: &[BString], paths: &[BString],
ctx: &Rc<RenderContext>, ctx: &Rc<RenderContext>,
@ -213,12 +214,12 @@ struct CursorImageScaled {
struct CursorImage { struct CursorImage {
delay_ns: u64, delay_ns: u64,
sizes: SmallMapMut<(Fixed, u32), Rc<CursorImageScaled>, 2>, sizes: SmallMapMut<(Scale, u32), Rc<CursorImageScaled>, 2>,
} }
struct InstantiatedCursorImage { struct InstantiatedCursorImage {
delay_ns: u64, delay_ns: u64,
scales: SmallMapMut<Fixed, Rc<CursorImageScaled>, 2>, scales: SmallMapMut<Scale, Rc<CursorImageScaled>, 2>,
} }
impl CursorImageScaled { impl CursorImageScaled {
@ -240,7 +241,7 @@ impl CursorImageScaled {
impl CursorImage { impl CursorImage {
fn from_sizes( fn from_sizes(
delay_ms: u64, delay_ms: u64,
sizes: SmallMapMut<(Fixed, u32), Rc<CursorImageScaled>, 2>, sizes: SmallMapMut<(Scale, u32), Rc<CursorImageScaled>, 2>,
) -> Result<Self, CursorError> { ) -> Result<Self, CursorError> {
Ok(Self { Ok(Self {
delay_ns: delay_ms.max(1) * 1_000_000, delay_ns: delay_ms.max(1) * 1_000_000,
@ -306,7 +307,7 @@ impl Cursor for StaticCursor {
} }
} }
fn extents_at_scale(&self, scale: Fixed) -> Rect { fn extents_at_scale(&self, scale: Scale) -> Rect {
match self.image.scales.get(&scale) { match self.image.scales.get(&scale) {
None => Rect::new_empty(0, 0), None => Rect::new_empty(0, 0),
Some(i) => i.extents, Some(i) => i.extents,
@ -336,7 +337,7 @@ impl Cursor for AnimatedCursor {
} }
} }
fn extents_at_scale(&self, scale: Fixed) -> Rect { fn extents_at_scale(&self, scale: Scale) -> Rect {
let img = &self.images[self.idx.get()]; let img = &self.images[self.idx.get()];
match img.scales.get(&scale) { match img.scales.get(&scale) {
None => Rect::new_empty(0, 0), None => Rect::new_empty(0, 0),
@ -368,13 +369,13 @@ impl Cursor for AnimatedCursor {
} }
struct OpenCursorResult { struct OpenCursorResult {
images: Vec<AHashMap<(Fixed, u32), Rc<XCursorImage>>>, images: Vec<AHashMap<(Scale, u32), Rc<XCursorImage>>>,
} }
fn open_cursor( fn open_cursor(
name: &str, name: &str,
theme: Option<&BStr>, theme: Option<&BStr>,
scales: &[Fixed], scales: &[Scale],
sizes: &[u32], sizes: &[u32],
paths: &[BString], paths: &[BString],
) -> Result<OpenCursorResult, CursorError> { ) -> Result<OpenCursorResult, CursorError> {
@ -538,7 +539,7 @@ impl Debug for XCursorImage {
fn parser_cursor_file<R: BufRead + Seek>( fn parser_cursor_file<R: BufRead + Seek>(
r: &mut R, r: &mut R,
scales: &[Fixed], scales: &[Scale],
sizes: &[u32], sizes: &[u32],
) -> Result<OpenCursorResult, CursorError> { ) -> Result<OpenCursorResult, CursorError> {
let [magic, header] = read_u32_n(r)?; let [magic, header] = read_u32_n(r)?;
@ -554,7 +555,7 @@ fn parser_cursor_file<R: BufRead + Seek>(
positions: Vec<u32>, positions: Vec<u32>,
effective_size: u32, effective_size: u32,
size: u32, size: u32,
scale: Fixed, scale: Scale,
best_fit: i64, best_fit: i64,
} }
let mut targets = Vec::new(); let mut targets = Vec::new();

View file

@ -39,10 +39,6 @@ impl Fixed {
self.0 >> 8 self.0 >> 8
} }
pub fn round_up(self) -> i32 {
(self.0 + 255) >> 8
}
pub fn apply_fract(self, i: i32) -> Self { pub fn apply_fract(self, i: i32) -> Self {
Self((i << 8) | (self.0 & 255)) Self((i << 8) | (self.0 & 255))
} }

View file

@ -72,7 +72,7 @@ pub struct WlOutputGlobal {
pub unused_captures: LinkedList<Rc<ZwlrScreencopyFrameV1>>, pub unused_captures: LinkedList<Rc<ZwlrScreencopyFrameV1>>,
pub pending_captures: LinkedList<Rc<ZwlrScreencopyFrameV1>>, pub pending_captures: LinkedList<Rc<ZwlrScreencopyFrameV1>>,
pub destroyed: Cell<bool>, pub destroyed: Cell<bool>,
pub legacy_scale: Cell<i32>, pub legacy_scale: Cell<u32>,
} }
#[derive(Eq, PartialEq)] #[derive(Eq, PartialEq)]
@ -316,7 +316,7 @@ impl WlOutput {
fn send_scale(self: &Rc<Self>) { fn send_scale(self: &Rc<Self>) {
let event = Scale { let event = Scale {
self_id: self.id, self_id: self.id,
factor: self.global.legacy_scale.get(), factor: self.global.legacy_scale.get() as _,
}; };
self.client.event(event); self.client.event(event);
} }

View file

@ -217,7 +217,7 @@ impl SurfaceRole {
} }
} }
pub struct SurfaceSendPreferredScaleVisitor(pub Fixed); pub struct SurfaceSendPreferredScaleVisitor;
impl NodeVisitorBase for SurfaceSendPreferredScaleVisitor { impl NodeVisitorBase for SurfaceSendPreferredScaleVisitor {
fn visit_surface(&mut self, node: &Rc<WlSurface>) { fn visit_surface(&mut self, node: &Rc<WlSurface>) {
node.send_preferred_scale(); node.send_preferred_scale();

View file

@ -6,6 +6,7 @@ use {
leaks::Tracker, leaks::Tracker,
rect::Rect, rect::Rect,
render::Renderer, render::Renderer,
scale::Scale,
tree::{Node, NodeVisitorBase, OutputNode}, tree::{Node, NodeVisitorBase, OutputNode},
}, },
std::{cell::Cell, ops::Deref, rc::Rc}, std::{cell::Cell, ops::Deref, rc::Rc},
@ -103,7 +104,7 @@ impl Cursor for CursorSurface {
FrameRequests.visit_surface(&self.surface); FrameRequests.visit_surface(&self.surface);
} }
fn extents_at_scale(&self, scale: Fixed) -> Rect { fn extents_at_scale(&self, scale: Scale) -> Rect {
let rect = self.extents.get(); let rect = self.extents.get();
if scale == 1 { if scale == 1 {
return rect; return rect;

View file

@ -39,7 +39,7 @@ 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().preferred_scale.get(), scale: self.surface.output.get().preferred_scale.get().0,
}); });
} }

View file

@ -72,6 +72,7 @@ mod pipewire;
mod portal; mod portal;
mod rect; mod rect;
mod render; mod render;
mod scale;
mod screenshoter; mod screenshoter;
mod sighand; mod sighand;
mod state; mod state;

View file

@ -7,6 +7,7 @@ use {
ifs::zwlr_layer_shell_v1::OVERLAY, ifs::zwlr_layer_shell_v1::OVERLAY,
portal::ptl_display::{PortalDisplay, PortalOutput, PortalSeat}, portal::ptl_display::{PortalDisplay, PortalOutput, PortalSeat},
render::{Framebuffer, RenderContext, RendererBase, Texture}, render::{Framebuffer, RenderContext, RendererBase, Texture},
scale::Scale,
text::{self, TextMeasurement}, text::{self, TextMeasurement},
theme::Color, theme::Color,
utils::{ utils::{
@ -467,7 +468,7 @@ pub struct WindowData {
pub frame_missed: Cell<bool>, pub frame_missed: Cell<bool>,
pub first_scale: Cell<bool>, pub first_scale: Cell<bool>,
pub have_frame: Cell<bool>, pub have_frame: Cell<bool>,
pub scale: Cell<Fixed>, pub scale: Cell<Scale>,
pub render_trigger: AsyncEvent, pub render_trigger: AsyncEvent,
pub render_task: Cell<Option<SpawnedFuture<()>>>, pub render_task: Cell<Option<SpawnedFuture<()>>>,
pub dpy: Rc<PortalDisplay>, pub dpy: Rc<PortalDisplay>,
@ -560,7 +561,7 @@ impl WindowData {
content: Default::default(), content: Default::default(),
surface, surface,
viewport, viewport,
scale: Cell::new(Fixed::from_int(1)), scale: Cell::new(Scale::from_int(1)),
fractional_scale, fractional_scale,
seats: Default::default(), seats: Default::default(),
}); });
@ -833,7 +834,8 @@ 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);
layout |= self.scale.replace(ev.scale) != ev.scale; let scale = Scale(ev.scale);
layout |= self.scale.replace(scale) != scale;
if layout { if layout {
self.layout(); self.layout();
self.allocate_buffers(); self.allocate_buffers();

View file

@ -16,6 +16,7 @@ use {
sys::{glBlendFunc, glFlush, glReadnPixels, GL_ONE, GL_ONE_MINUS_SRC_ALPHA}, sys::{glBlendFunc, glFlush, glReadnPixels, GL_ONE, GL_ONE_MINUS_SRC_ALPHA},
RenderResult, Texture, RenderResult, Texture,
}, },
scale::Scale,
state::State, state::State,
tree::Node, tree::Node,
}, },
@ -61,7 +62,7 @@ impl Framebuffer {
glViewport(0, 0, self.gl.width, self.gl.height); glViewport(0, 0, self.gl.width, self.gl.height);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
} }
let scale = Fixed::from_int(1); let scale = Scale::from_int(1);
let mut renderer = Renderer { let mut renderer = Renderer {
base: RendererBase { base: RendererBase {
ctx: &self.ctx, ctx: &self.ctx,
@ -114,7 +115,7 @@ impl Framebuffer {
}); });
} }
pub fn render_custom(&self, scale: Fixed, f: impl FnOnce(&mut RendererBase)) { pub fn render_custom(&self, scale: Scale, f: impl FnOnce(&mut RendererBase)) {
let _ = self.ctx.ctx.with_current(|| { let _ = self.ctx.ctx.with_current(|| {
unsafe { unsafe {
glBindFramebuffer(GL_FRAMEBUFFER, self.gl.fbo); glBindFramebuffer(GL_FRAMEBUFFER, self.gl.fbo);
@ -143,7 +144,7 @@ impl Framebuffer {
cursor_rect: Option<Rect>, cursor_rect: Option<Rect>,
on_output: bool, on_output: bool,
result: &mut RenderResult, result: &mut RenderResult,
scale: Fixed, scale: Scale,
render_hardware_cursor: bool, render_hardware_cursor: bool,
) { ) {
let _ = self.ctx.ctx.with_current(|| { let _ = self.ctx.ctx.with_current(|| {
@ -201,7 +202,7 @@ impl Framebuffer {
}); });
} }
pub fn render_hardware_cursor(&self, cursor: &dyn Cursor, state: &State, scale: Fixed) { pub fn render_hardware_cursor(&self, cursor: &dyn Cursor, state: &State, scale: Scale) {
let _ = self.ctx.ctx.with_current(|| { let _ = self.ctx.ctx.with_current(|| {
unsafe { unsafe {
glBindFramebuffer(GL_FRAMEBUFFER, self.gl.fbo); glBindFramebuffer(GL_FRAMEBUFFER, self.gl.fbo);

View file

@ -1,6 +1,5 @@
use { use {
crate::{ crate::{
fixed::Fixed,
format::ARGB8888, format::ARGB8888,
ifs::{ ifs::{
wl_buffer::WlBuffer, wl_buffer::WlBuffer,
@ -12,6 +11,7 @@ use {
}, },
rect::Rect, rect::Rect,
render::{gl::frame_buffer::with_scissor, renderer::renderer_base::RendererBase}, render::{gl::frame_buffer::with_scissor, renderer::renderer_base::RendererBase},
scale::Scale,
state::State, state::State,
theme::Color, theme::Color,
tree::{ tree::{
@ -48,7 +48,7 @@ pub struct Renderer<'a> {
} }
impl Renderer<'_> { impl Renderer<'_> {
pub fn scale(&self) -> Fixed { pub fn scale(&self) -> Scale {
self.base.scale self.base.scale
} }

View file

@ -1,6 +1,5 @@
use { use {
crate::{ crate::{
fixed::Fixed,
format::Format, format::Format,
rect::Rect, rect::Rect,
render::{ render::{
@ -18,6 +17,7 @@ use {
sys::{glClear, glClearColor, glDisable, glEnable, GL_BLEND, GL_COLOR_BUFFER_BIT}, sys::{glClear, glClearColor, glDisable, glEnable, GL_BLEND, GL_COLOR_BUFFER_BIT},
Texture, Texture,
}, },
scale::Scale,
theme::Color, theme::Color,
utils::rc_eq::rc_eq, utils::rc_eq::rc_eq,
}, },
@ -28,12 +28,12 @@ pub struct RendererBase<'a> {
pub(super) ctx: &'a Rc<RenderContext>, pub(super) ctx: &'a Rc<RenderContext>,
pub(super) fb: &'a GlFrameBuffer, pub(super) fb: &'a GlFrameBuffer,
pub(super) scaled: bool, pub(super) scaled: bool,
pub(super) scale: Fixed, pub(super) scale: Scale,
pub(super) scalef: f64, pub(super) scalef: f64,
} }
impl RendererBase<'_> { impl RendererBase<'_> {
pub fn scale(&self) -> Fixed { pub fn scale(&self) -> Scale {
self.scale self.scale
} }
@ -188,7 +188,7 @@ impl RendererBase<'_> {
format: &Format, format: &Format,
tpoints: Option<&[f32; 8]>, tpoints: Option<&[f32; 8]>,
tsize: Option<(i32, i32)>, tsize: Option<(i32, i32)>,
tscale: Fixed, tscale: Scale,
) { ) {
assert!(rc_eq(&self.ctx.ctx, &texture.ctx.ctx)); assert!(rc_eq(&self.ctx.ctx, &texture.ctx.ctx));
unsafe { unsafe {

44
src/scale.rs Normal file
View file

@ -0,0 +1,44 @@
use std::fmt::{Debug, Display, Formatter};
const BASE: u32 = 120;
const BASEF: f64 = BASE as f64;
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(transparent)]
pub struct Scale(pub u32);
impl Scale {
pub fn from_int(f: u32) -> Self {
Self(f.saturating_mul(BASE))
}
pub fn from_f64(f: f64) -> Self {
Self((f * BASEF).round() as u32)
}
pub fn to_f64(self) -> f64 {
self.0 as f64 / BASEF
}
pub fn round_up(self) -> u32 {
self.0.saturating_add(BASE - 1) / BASE
}
}
impl PartialEq<u32> for Scale {
fn eq(&self, other: &u32) -> bool {
self.0 == other * BASE
}
}
impl Debug for Scale {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
Debug::fmt(&self.to_f64(), f)
}
}
impl Display for Scale {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
Display::fmt(&self.to_f64(), f)
}
}

View file

@ -1,8 +1,8 @@
use { use {
crate::{ crate::{
fixed::Fixed,
format::XRGB8888, format::XRGB8888,
render::RenderError, render::RenderError,
scale::Scale,
state::State, state::State,
video::{ video::{
drm::DrmError, drm::DrmError,
@ -60,7 +60,7 @@ pub fn take_screenshot(state: &State) -> Result<Screenshot, ScreenshooterError>
Some(state.root.extents.get()), Some(state.root.extents.get()),
false, false,
&mut Default::default(), &mut Default::default(),
Fixed::from_int(1), Scale::from_int(1),
true, true,
); );
let drm = ctx.gbm.drm.dup_render()?.fd().clone(); let drm = ctx.gbm.drm.dup_render()?.fd().clone();

View file

@ -12,7 +12,6 @@ use {
config::ConfigProxy, config::ConfigProxy,
cursor::{Cursor, ServerCursors}, cursor::{Cursor, ServerCursors},
dbus::Dbus, dbus::Dbus,
fixed::Fixed,
forker::ForkerProxy, forker::ForkerProxy,
globals::{Globals, GlobalsError, WaylandGlobal}, globals::{Globals, GlobalsError, WaylandGlobal},
ifs::{ ifs::{
@ -33,6 +32,7 @@ use {
logger::Logger, logger::Logger,
rect::Rect, rect::Rect,
render::RenderContext, render::RenderContext,
scale::Scale,
theme::Theme, theme::Theme,
tree::{ tree::{
ContainerNode, ContainerSplit, Direction, DisplayNode, FloatNode, Node, NodeIds, ContainerNode, ContainerSplit, Direction, DisplayNode, FloatNode, Node, NodeIds,
@ -116,7 +116,7 @@ pub struct State {
pub data_offer_ids: NumCell<u64>, pub data_offer_ids: NumCell<u64>,
pub ring: Rc<IoUring>, pub ring: Rc<IoUring>,
pub lock: ScreenlockState, pub lock: ScreenlockState,
pub scales: RefCounted<Fixed>, pub scales: RefCounted<Scale>,
pub cursor_sizes: RefCounted<u32>, pub cursor_sizes: RefCounted<u32>,
pub hardware_tick_cursor: AsyncQueue<Option<Rc<dyn Cursor>>>, pub hardware_tick_cursor: AsyncQueue<Option<Rc<dyn Cursor>>>,
pub testers: RefCell<AHashMap<(ClientId, JaySeatEventsId), Rc<JaySeatEvents>>>, pub testers: RefCell<AHashMap<(ClientId, JaySeatEventsId), Rc<JaySeatEvents>>>,
@ -235,13 +235,13 @@ impl NodeVisitorBase for UpdateTextTexturesVisitor {
} }
impl State { impl State {
pub fn add_output_scale(&self, scale: Fixed) { pub fn add_output_scale(&self, scale: Scale) {
if self.scales.add(scale) { if self.scales.add(scale) {
self.output_scales_changed(); self.output_scales_changed();
} }
} }
pub fn remove_output_scale(&self, scale: Fixed) { pub fn remove_output_scale(&self, scale: Scale) {
if self.scales.remove(&scale) { if self.scales.remove(&scale) {
self.output_scales_changed(); self.output_scales_changed();
} }

View file

@ -1,8 +1,8 @@
use { use {
crate::{ crate::{
backend::{Connector, ConnectorEvent, ConnectorId, MonitorInfo}, backend::{Connector, ConnectorEvent, ConnectorId, MonitorInfo},
fixed::Fixed,
ifs::wl_output::WlOutputGlobal, ifs::wl_output::WlOutputGlobal,
scale::Scale,
state::{ConnectorData, OutputData, State}, state::{ConnectorData, OutputData, State},
tree::{OutputNode, OutputRenderData}, tree::{OutputNode, OutputRenderData},
utils::{asyncevent::AsyncEvent, clonecell::CloneCell}, utils::{asyncevent::AsyncEvent, clonecell::CloneCell},
@ -122,7 +122,7 @@ impl ConnectorHandler {
scroll: Default::default(), scroll: Default::default(),
pointer_positions: Default::default(), pointer_positions: Default::default(),
lock_surface: Default::default(), lock_surface: Default::default(),
preferred_scale: Cell::new(Fixed::from_int(1)), preferred_scale: Cell::new(Scale::from_int(1)),
hardware_cursor: Default::default(), hardware_cursor: Default::default(),
jay_outputs: Default::default(), jay_outputs: Default::default(),
screencasts: Default::default(), screencasts: Default::default(),

View file

@ -9,6 +9,7 @@ use {
}, },
rect::Rect, rect::Rect,
render::{Renderer, Texture}, render::{Renderer, Texture},
scale::Scale,
state::State, state::State,
text, text,
tree::{ tree::{
@ -85,7 +86,7 @@ pub struct ContainerRenderData {
pub last_active_rect: Option<Rect>, pub last_active_rect: Option<Rect>,
pub border_rects: Vec<Rect>, pub border_rects: Vec<Rect>,
pub underline_rects: Vec<Rect>, pub underline_rects: Vec<Rect>,
pub titles: SmallMapMut<Fixed, Vec<ContainerTitle>, 2>, pub titles: SmallMapMut<Scale, Vec<ContainerTitle>, 2>,
} }
pub struct ContainerNode { pub struct ContainerNode {

View file

@ -6,6 +6,7 @@ use {
ifs::wl_seat::{NodeSeatState, SeatId, WlSeatGlobal, BTN_LEFT}, ifs::wl_seat::{NodeSeatState, SeatId, WlSeatGlobal, BTN_LEFT},
rect::Rect, rect::Rect,
render::{Renderer, Texture}, render::{Renderer, Texture},
scale::Scale,
state::State, state::State,
text, text,
tree::{ tree::{
@ -42,7 +43,7 @@ pub struct FloatNode {
pub layout_scheduled: Cell<bool>, pub layout_scheduled: Cell<bool>,
pub render_titles_scheduled: Cell<bool>, pub render_titles_scheduled: Cell<bool>,
pub title: RefCell<String>, pub title: RefCell<String>,
pub title_textures: CopyHashMap<Fixed, Rc<Texture>>, pub title_textures: CopyHashMap<Scale, Rc<Texture>>,
seats: RefCell<AHashMap<SeatId, SeatState>>, seats: RefCell<AHashMap<SeatId, SeatState>>,
} }

View file

@ -20,6 +20,7 @@ use {
}, },
rect::Rect, rect::Rect,
render::{Framebuffer, Renderer, Texture}, render::{Framebuffer, Renderer, Texture},
scale::Scale,
state::State, state::State,
text, text,
tree::{ tree::{
@ -57,7 +58,7 @@ pub struct OutputNode {
pub scroll: Scroller, pub scroll: Scroller,
pub pointer_positions: CopyHashMap<SeatId, (i32, i32)>, pub pointer_positions: CopyHashMap<SeatId, (i32, i32)>,
pub lock_surface: CloneCell<Option<Rc<ExtSessionLockSurfaceV1>>>, pub lock_surface: CloneCell<Option<Rc<ExtSessionLockSurfaceV1>>>,
pub preferred_scale: Cell<Fixed>, pub preferred_scale: Cell<Scale>,
pub hardware_cursor: CloneCell<Option<Rc<dyn HardwareCursor>>>, pub hardware_cursor: CloneCell<Option<Rc<dyn HardwareCursor>>>,
pub update_render_data_scheduled: Cell<bool>, pub update_render_data_scheduled: Cell<bool>,
pub screencasts: CopyHashMap<(ClientId, JayScreencastId), Rc<JayScreencast>>, pub screencasts: CopyHashMap<(ClientId, JayScreencastId), Rc<JayScreencast>>,
@ -102,7 +103,7 @@ impl OutputNode {
} }
} }
pub fn set_preferred_scale(self: &Rc<Self>, scale: Fixed) { pub fn set_preferred_scale(self: &Rc<Self>, scale: Scale) {
let old_scale = self.preferred_scale.replace(scale); let old_scale = self.preferred_scale.replace(scale);
if scale == old_scale { if scale == old_scale {
return; return;
@ -115,7 +116,7 @@ impl OutputNode {
self.state.add_output_scale(scale); self.state.add_output_scale(scale);
let rect = self.calculate_extents(); let rect = self.calculate_extents();
self.change_extents_(&rect); self.change_extents_(&rect);
let mut visitor = SurfaceSendPreferredScaleVisitor(scale); let mut visitor = SurfaceSendPreferredScaleVisitor;
self.node_visit_children(&mut visitor); self.node_visit_children(&mut visitor);
for ws in self.workspaces.iter() { for ws in self.workspaces.iter() {
for stacked in ws.stacked.iter() { for stacked in ws.stacked.iter() {

View file

@ -6,6 +6,7 @@ use {
ifs::wl_seat::{NodeSeatState, WlSeatGlobal}, ifs::wl_seat::{NodeSeatState, WlSeatGlobal},
rect::Rect, rect::Rect,
render::{Renderer, Texture}, render::{Renderer, Texture},
scale::Scale,
state::State, state::State,
text, text,
tree::{ tree::{
@ -23,7 +24,7 @@ pub struct PlaceholderNode {
id: PlaceholderNodeId, id: PlaceholderNodeId,
toplevel: ToplevelData, toplevel: ToplevelData,
destroyed: Cell<bool>, destroyed: Cell<bool>,
pub textures: SmallMap<Fixed, Rc<Texture>, 2>, pub textures: SmallMap<Scale, Rc<Texture>, 2>,
} }
impl PlaceholderNode { impl PlaceholderNode {

View file

@ -7,5 +7,5 @@ msg destroy = 0 {
# events # events
msg preferred_scale = 0 { msg preferred_scale = 0 {
scale: fixed, scale: u32,
} }