aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tty.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-09-21 13:48:32 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-09-21 13:48:50 +0400
commit109668fa30bf65e56a2723ff29bcadc3e9a6e4ca (patch)
treed95fbf3bdb3c2c14683a34d8bb7203b7dae4820d /src/backend/tty.rs
parentcfa73c153cc6ae2f1c21dcbbc8e755b265babbd2 (diff)
downloadniri-109668fa30bf65e56a2723ff29bcadc3e9a6e4ca.tar.gz
niri-109668fa30bf65e56a2723ff29bcadc3e9a6e4ca.tar.bz2
niri-109668fa30bf65e56a2723ff29bcadc3e9a6e4ca.zip
Add output configuration & integer scaling support
Diffstat (limited to 'src/backend/tty.rs')
-rw-r--r--src/backend/tty.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/backend/tty.rs b/src/backend/tty.rs
index 9f126507..bce16ff0 100644
--- a/src/backend/tty.rs
+++ b/src/backend/tty.rs
@@ -21,7 +21,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, Subpixel};
+use smithay::output::{Mode, Output, OutputModeSource, PhysicalProperties, Subpixel, Scale};
use smithay::reexports::calloop::{Dispatcher, LoopHandle, RegistrationToken};
use smithay::reexports::drm::control::{
connector, crtc, Mode as DrmMode, ModeFlags, ModeTypeFlags,
@@ -500,6 +500,15 @@ impl Tty {
);
debug!("connecting connector: {output_name}");
+ let config = self
+ .config
+ .borrow()
+ .outputs
+ .iter()
+ .find(|o| o.name == output_name)
+ .cloned()
+ .unwrap_or_default();
+
let device = self.output_device.as_mut().unwrap();
let mut mode = connector.modes().get(0);
@@ -534,6 +543,9 @@ impl Tty {
.map(|info| (info.manufacturer, info.model))
.unwrap_or_else(|| ("Unknown".into(), "Unknown".into()));
+ let scale = config.scale.clamp(0.1, 10.);
+ let scale = scale.max(1.).round() as i32;
+
let output = Output::new(
output_name.clone(),
PhysicalProperties {
@@ -544,7 +556,7 @@ impl Tty {
},
);
let wl_mode = Mode::from(*mode);
- output.change_current_state(Some(wl_mode), None, None, Some((0, 0).into()));
+ output.change_current_state(Some(wl_mode), None, Some(Scale::Integer(scale)), None);
output.set_preferred(wl_mode);
output.user_data().insert_if_missing(|| TtyOutputState {