output_conf: Fixed scaling issues

This commit is contained in:
Victoria Brekenfeld 2022-04-20 16:06:37 +02:00
parent a8aeba8f09
commit 3ffdf58e0f
5 changed files with 16 additions and 30 deletions

2
Cargo.lock generated
View file

@ -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",

View file

@ -711,6 +711,7 @@ impl KmsState {
false
};
shell.refresh_outputs();
if recreated {
self.schedule_render(output);
}

View file

@ -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());

View file

@ -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::<RefCell<OutputConfig>>()
.unwrap()
.borrow();
let active = output
.user_data()
.get::<ActiveWorkspace>()
@ -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::<RefCell<OutputConfig>>()
.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::<RefCell<OutputConfig>>()
.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();
}
}

View file

@ -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