mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 02:01:55 +07:00
Move output scale setting into niri
This commit is contained in:
+2
-3
@@ -28,7 +28,7 @@ use smithay::backend::session::libseat::LibSeatSession;
|
||||
use smithay::backend::session::{Event as SessionEvent, Session};
|
||||
use smithay::backend::udev::{self, UdevBackend, UdevEvent};
|
||||
use smithay::desktop::utils::OutputPresentationFeedback;
|
||||
use smithay::output::{Mode, Output, OutputModeSource, PhysicalProperties, Scale, Subpixel};
|
||||
use smithay::output::{Mode, Output, OutputModeSource, PhysicalProperties, Subpixel};
|
||||
use smithay::reexports::calloop::timer::{TimeoutAction, Timer};
|
||||
use smithay::reexports::calloop::{Dispatcher, LoopHandle, RegistrationToken};
|
||||
use smithay::reexports::drm::control::{
|
||||
@@ -712,8 +712,7 @@ impl Tty {
|
||||
);
|
||||
|
||||
let wl_mode = Mode::from(*mode);
|
||||
let scale = config.scale.clamp(1., 10.).ceil() as i32;
|
||||
output.change_current_state(Some(wl_mode), None, Some(Scale::Integer(scale)), None);
|
||||
output.change_current_state(Some(wl_mode), None, None, None);
|
||||
output.set_preferred(wl_mode);
|
||||
|
||||
output
|
||||
|
||||
+2
-16
@@ -11,7 +11,7 @@ use smithay::backend::renderer::damage::OutputDamageTracker;
|
||||
use smithay::backend::renderer::gles::GlesRenderer;
|
||||
use smithay::backend::renderer::{DebugFlags, ImportDma, ImportEgl, Renderer};
|
||||
use smithay::backend::winit::{self, WinitEvent, WinitGraphicsBackend};
|
||||
use smithay::output::{Mode, Output, PhysicalProperties, Scale, Subpixel};
|
||||
use smithay::output::{Mode, Output, PhysicalProperties, Subpixel};
|
||||
use smithay::reexports::calloop::LoopHandle;
|
||||
use smithay::reexports::wayland_protocols::wp::presentation_time::server::wp_presentation_feedback;
|
||||
use smithay::reexports::winit::dpi::LogicalSize;
|
||||
@@ -39,14 +39,6 @@ impl Winit {
|
||||
.with_title("niri");
|
||||
let (backend, winit) = winit::init_from_builder(builder).unwrap();
|
||||
|
||||
let output_config = config
|
||||
.borrow()
|
||||
.outputs
|
||||
.iter()
|
||||
.find(|o| o.name == "winit")
|
||||
.cloned()
|
||||
.unwrap_or_default();
|
||||
|
||||
let output = Output::new(
|
||||
"winit".to_string(),
|
||||
PhysicalProperties {
|
||||
@@ -61,13 +53,7 @@ impl Winit {
|
||||
size: backend.window_size(),
|
||||
refresh: 60_000,
|
||||
};
|
||||
let scale = output_config.scale.clamp(1., 10.).ceil() as i32;
|
||||
output.change_current_state(
|
||||
Some(mode),
|
||||
Some(Transform::Flipped180),
|
||||
Some(Scale::Integer(scale)),
|
||||
None,
|
||||
);
|
||||
output.change_current_state(Some(mode), Some(Transform::Flipped180), None, None);
|
||||
output.set_preferred(mode);
|
||||
|
||||
let connectors = Arc::new(Mutex::new(HashMap::from([(
|
||||
|
||||
+15
-1
@@ -1043,6 +1043,20 @@ impl Niri {
|
||||
pub fn add_output(&mut self, output: Output, refresh_interval: Option<Duration>) {
|
||||
let global = output.create_global::<State>(&self.display_handle);
|
||||
|
||||
let name = output.name();
|
||||
let scale = self
|
||||
.config
|
||||
.borrow()
|
||||
.outputs
|
||||
.iter()
|
||||
.find(|o| o.name == name)
|
||||
.map(|c| c.scale)
|
||||
.unwrap_or(1.);
|
||||
let scale = scale.clamp(1., 10.).ceil() as i32;
|
||||
|
||||
// Set scale before adding to the layout since that will read the output size.
|
||||
output.change_current_state(None, None, Some(output::Scale::Integer(scale)), None);
|
||||
|
||||
self.layout.add_output(output.clone());
|
||||
|
||||
let lock_render_state = if self.is_locked() {
|
||||
@@ -1066,7 +1080,7 @@ impl Niri {
|
||||
};
|
||||
let rv = self.output_state.insert(output.clone(), state);
|
||||
assert!(rv.is_none(), "output was already tracked");
|
||||
let rv = self.output_by_name.insert(output.name(), output.clone());
|
||||
let rv = self.output_by_name.insert(name, output.clone());
|
||||
assert!(rv.is_none(), "output was already tracked");
|
||||
|
||||
// Must be last since it will call queue_redraw(output) which needs things to be filled-in.
|
||||
|
||||
Reference in New Issue
Block a user