From 3ffdf58e0ff33338d512a4c5ce8250c54218cc72 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Wed, 20 Apr 2022 16:06:37 +0200 Subject: [PATCH] output_conf: Fixed scaling issues --- Cargo.lock | 2 +- src/backend/kms/mod.rs | 1 + src/backend/render/mod.rs | 2 +- src/shell/mod.rs | 35 ++++++++++------------------------- src/state.rs | 6 +++--- 5 files changed, 16 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0d3340d0..2dc2f9c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1311,7 +1311,7 @@ checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" [[package]] name = "smithay" version = "0.3.0" -source = "git+https://github.com/pop-os/smithay?branch=main#a9aea2275645cc4b2fc290103cc2072f9a2bfbb1" +source = "git+https://github.com/pop-os/smithay?branch=main#9a2273f4c8fed28d20952a5493627edf9d3cdcfc" dependencies = [ "appendlist", "bitflags", diff --git a/src/backend/kms/mod.rs b/src/backend/kms/mod.rs index 161ffc22..1bf214a9 100644 --- a/src/backend/kms/mod.rs +++ b/src/backend/kms/mod.rs @@ -711,6 +711,7 @@ impl KmsState { false }; + shell.refresh_outputs(); if recreated { self.schedule_render(output); } diff --git a/src/backend/render/mod.rs b/src/backend/render/mod.rs index 9ae94ce8..22692964 100644 --- a/src/backend/render/mod.rs +++ b/src/backend/render/mod.rs @@ -125,7 +125,7 @@ where .space .output_geometry(output) .unwrap_or(Rectangle::from_loc_and_size((0, 0), (0, 0))); - let scale = workspace.space.output_scale(output).unwrap(); + let scale = output.current_scale().fractional_scale(); let fps_overlay = fps_ui(_gpu, state, fps, output_geo, scale); custom_elements.push(fps_overlay.into()); diff --git a/src/shell/mod.rs b/src/shell/mod.rs index 741393e8..99766988 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -11,7 +11,7 @@ pub use smithay::{ utils::{Logical, Point, Rectangle, Size}, wayland::{ compositor::with_states, - output::{Mode as OutputMode, Output}, + output::{Mode as OutputMode, Output, Scale}, seat::Seat, shell::xdg::XdgToplevelSurfaceRoleAttributes, Serial, SERIAL_COUNTER, @@ -103,15 +103,10 @@ impl Shell { .borrow(); workspace .space - .map_output(output, config.scale, config.position); + .map_output(output, config.position); } } else { for output in self.outputs.iter() { - let config = output - .user_data() - .get::>() - .unwrap() - .borrow(); let active = output .user_data() .get::() @@ -119,7 +114,7 @@ impl Shell { .get() .unwrap(); let workspace = &mut self.spaces[active]; - workspace.space.map_output(output, config.scale, (0, 0)); + workspace.space.map_output(output, (0, 0)); } } } @@ -156,16 +151,16 @@ impl Shell { match self.mode { Mode::OutputBound => { let workspace = Self::assign_next_free_output(&mut self.spaces, output); - workspace.space.map_output(output, config.scale, (0, 0)); + workspace.space.map_output(output, (0, 0)); } Mode::Global { active } => { let workspace = &mut self.spaces[active]; workspace .space - .map_output(output, config.scale, config.position); + .map_output(output, config.position); } } - output.change_current_state(None, None, Some(config.scale.ceil() as i32), None); + output.change_current_state(None, None, Some(Scale::Fractional(config.scale)), None); } pub fn remove_output(&mut self, output: &Output) { @@ -271,14 +266,9 @@ impl Shell { if let Some(old_idx) = active.set(idx) { self.spaces[old_idx].space.unmap_output(output); } - let config = output - .user_data() - .get::>() - .unwrap() - .borrow(); self.spaces[idx] .space - .map_output(output, config.scale, (0, 0)); + .map_output(output, (0, 0)); self.spaces[idx].refresh(); } } @@ -294,7 +284,7 @@ impl Shell { .borrow(); self.spaces[*active] .space - .map_output(output, config.scale, config.position); + .map_output(output, config.position); } } }; @@ -353,7 +343,7 @@ impl Shell { self.spaces[old_active].space.unmap_output(output); self.spaces[active] .space - .map_output(output, config.scale, config.position); + .map_output(output, config.position); self.spaces[active].refresh(); } @@ -367,11 +357,6 @@ impl Shell { let mut active = Some(active.clone()); self.mode = new; for output in &self.outputs { - let config = output - .user_data() - .get::>() - .unwrap() - .borrow(); let workspace = if let Some(a) = active.take() { output .user_data() @@ -381,7 +366,7 @@ impl Shell { } else { Self::assign_next_free_output(&mut self.spaces, output) }; - workspace.space.map_output(output, config.scale, (0, 0)); + workspace.space.map_output(output, (0, 0)); workspace.refresh(); } } diff --git a/src/state.rs b/src/state.rs index feb4c7a8..650a1861 100644 --- a/src/state.rs +++ b/src/state.rs @@ -18,7 +18,7 @@ use smithay::{ self, init_wlr_output_configuration, ConfigurationManager, ModeConfiguration, }, xdg::init_xdg_output_manager, - Mode as OutputMode, Output, + Mode as OutputMode, Output, Scale, }, seat::Seat, shell::xdg::ToplevelSurface, @@ -145,10 +145,10 @@ impl BackendData { let transform = Some(final_config.transform.into()).filter(|x| *x != output.current_transform()); let scale = - Some(final_config.scale.ceil() as i32).filter(|x| *x != output.current_scale()); + Some(final_config.scale).filter(|x| *x != output.current_scale().fractional_scale()); let location = Some(final_config.position.into()).filter(|x| *x != output.current_location()); - output.change_current_state(mode, transform, scale, location); + output.change_current_state(mode, transform, scale.map(Scale::Fractional), location); } result