forge
Explore
Log in

Don't you dare go Hollow

Move output scale setting into niri

Browse files at this commit

6ca3b6ddb564d34e50881faefec6e06e11b9fcb9Ivan MolodetskikhParent: fc5a080
src/backend/tty.rsmodified+2 -3
@@ -28,7 +28,7 @@ use smithay::backend::session::libseat::LibSeatSession;
28 use smithay::backend::session::{Event as SessionEvent, Session};28 use smithay::backend::session::{Event as SessionEvent, Session};
29 use smithay::backend::udev::{self, UdevBackend, UdevEvent};29 use smithay::backend::udev::{self, UdevBackend, UdevEvent};
30 use smithay::desktop::utils::OutputPresentationFeedback;30 use smithay::desktop::utils::OutputPresentationFeedback;
31-use smithay::output::{Mode, Output, OutputModeSource, PhysicalProperties, Scale, Subpixel};31+use smithay::output::{Mode, Output, OutputModeSource, PhysicalProperties, Subpixel};
32 use smithay::reexports::calloop::timer::{TimeoutAction, Timer};32 use smithay::reexports::calloop::timer::{TimeoutAction, Timer};
33 use smithay::reexports::calloop::{Dispatcher, LoopHandle, RegistrationToken};33 use smithay::reexports::calloop::{Dispatcher, LoopHandle, RegistrationToken};
34 use smithay::reexports::drm::control::{34 use smithay::reexports::drm::control::{
@@ -712,8 +712,7 @@ impl Tty {
712 );712 );
713 713
714 let wl_mode = Mode::from(*mode);714 let wl_mode = Mode::from(*mode);
715- let scale = config.scale.clamp(1., 10.).ceil() as i32;715+ output.change_current_state(Some(wl_mode), None, None, None);
716- output.change_current_state(Some(wl_mode), None, Some(Scale::Integer(scale)), None);
717 output.set_preferred(wl_mode);716 output.set_preferred(wl_mode);
718 717
719 output718 output
src/backend/winit.rsmodified+2 -16
@@ -11,7 +11,7 @@ use smithay::backend::renderer::damage::OutputDamageTracker;
11 use smithay::backend::renderer::gles::GlesRenderer;11 use smithay::backend::renderer::gles::GlesRenderer;
12 use smithay::backend::renderer::{DebugFlags, ImportDma, ImportEgl, Renderer};12 use smithay::backend::renderer::{DebugFlags, ImportDma, ImportEgl, Renderer};
13 use smithay::backend::winit::{self, WinitEvent, WinitGraphicsBackend};13 use smithay::backend::winit::{self, WinitEvent, WinitGraphicsBackend};
14-use smithay::output::{Mode, Output, PhysicalProperties, Scale, Subpixel};14+use smithay::output::{Mode, Output, PhysicalProperties, Subpixel};
15 use smithay::reexports::calloop::LoopHandle;15 use smithay::reexports::calloop::LoopHandle;
16 use smithay::reexports::wayland_protocols::wp::presentation_time::server::wp_presentation_feedback;16 use smithay::reexports::wayland_protocols::wp::presentation_time::server::wp_presentation_feedback;
17 use smithay::reexports::winit::dpi::LogicalSize;17 use smithay::reexports::winit::dpi::LogicalSize;
@@ -39,14 +39,6 @@ impl Winit {
39 .with_title("niri");39 .with_title("niri");
40 let (backend, winit) = winit::init_from_builder(builder).unwrap();40 let (backend, winit) = winit::init_from_builder(builder).unwrap();
41 41
42- let output_config = config
43- .borrow()
44- .outputs
45- .iter()
46- .find(|o| o.name == "winit")
47- .cloned()
48- .unwrap_or_default();
49-
50 let output = Output::new(42 let output = Output::new(
51 "winit".to_string(),43 "winit".to_string(),
52 PhysicalProperties {44 PhysicalProperties {
@@ -61,13 +53,7 @@ impl Winit {
61 size: backend.window_size(),53 size: backend.window_size(),
62 refresh: 60_000,54 refresh: 60_000,
63 };55 };
64- let scale = output_config.scale.clamp(1., 10.).ceil() as i32;56+ output.change_current_state(Some(mode), Some(Transform::Flipped180), None, None);
65- output.change_current_state(
66- Some(mode),
67- Some(Transform::Flipped180),
68- Some(Scale::Integer(scale)),
69- None,
70- );
71 output.set_preferred(mode);57 output.set_preferred(mode);
72 58
73 let connectors = Arc::new(Mutex::new(HashMap::from([(59 let connectors = Arc::new(Mutex::new(HashMap::from([(
src/niri.rsmodified+15 -1
@@ -1043,6 +1043,20 @@ impl Niri {
1043 pub fn add_output(&mut self, output: Output, refresh_interval: Option<Duration>) {1043 pub fn add_output(&mut self, output: Output, refresh_interval: Option<Duration>) {
1044 let global = output.create_global::<State>(&self.display_handle);1044 let global = output.create_global::<State>(&self.display_handle);
1045 1045
1046+ let name = output.name();
1047+ let scale = self
1048+ .config
1049+ .borrow()
1050+ .outputs
1051+ .iter()
1052+ .find(|o| o.name == name)
1053+ .map(|c| c.scale)
1054+ .unwrap_or(1.);
1055+ let scale = scale.clamp(1., 10.).ceil() as i32;
1056+
1057+ // Set scale before adding to the layout since that will read the output size.
1058+ output.change_current_state(None, None, Some(output::Scale::Integer(scale)), None);
1059+
1046 self.layout.add_output(output.clone());1060 self.layout.add_output(output.clone());
1047 1061
1048 let lock_render_state = if self.is_locked() {1062 let lock_render_state = if self.is_locked() {
@@ -1066,7 +1080,7 @@ impl Niri {
1066 };1080 };
1067 let rv = self.output_state.insert(output.clone(), state);1081 let rv = self.output_state.insert(output.clone(), state);
1068 assert!(rv.is_none(), "output was already tracked");1082 assert!(rv.is_none(), "output was already tracked");
1069- let rv = self.output_by_name.insert(output.name(), output.clone());1083+ let rv = self.output_by_name.insert(name, output.clone());
1070 assert!(rv.is_none(), "output was already tracked");1084 assert!(rv.is_none(), "output was already tracked");
1071 1085
1072 // Must be last since it will call queue_redraw(output) which needs things to be filled-in.1086 // Must be last since it will call queue_redraw(output) which needs things to be filled-in.