diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/backend/tty.rs | 33 | ||||
| -rw-r--r-- | src/niri.rs | 17 | ||||
| -rw-r--r-- | src/utils/mod.rs | 9 |
3 files changed, 49 insertions, 10 deletions
diff --git a/src/backend/tty.rs b/src/backend/tty.rs index a53613f9..1a0e2401 100644 --- a/src/backend/tty.rs +++ b/src/backend/tty.rs @@ -49,7 +49,7 @@ use smithay::reexports::input::Libinput; use smithay::reexports::rustix::fs::OFlags; use smithay::reexports::wayland_protocols; use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; -use smithay::utils::DeviceFd; +use smithay::utils::{DeviceFd, Transform}; use smithay::wayland::dmabuf::{DmabufFeedback, DmabufFeedbackBuilder, DmabufGlobal}; use smithay::wayland::drm_lease::{ DrmLease, DrmLeaseBuilder, DrmLeaseRequest, DrmLeaseState, LeaseRejected, @@ -66,7 +66,7 @@ use crate::niri::{Niri, RedrawState, State}; use crate::render_helpers::debug::draw_damage; use crate::render_helpers::renderer::AsGlesRenderer; use crate::render_helpers::{resources, shaders, RenderTarget}; -use crate::utils::{get_monotonic_time, is_laptop_panel, logical_output}; +use crate::utils::{get_monotonic_time, is_laptop_panel, logical_output, PanelOrientation}; const SUPPORTED_COLOR_FORMATS: [Fourcc; 4] = [ Fourcc::Xrgb8888, @@ -973,6 +973,7 @@ impl Tty { debug!("picking mode: {mode:?}"); + let mut orientation = None; if let Ok(props) = ConnectorProperties::try_new(&device.drm, connector.handle()) { match reset_hdr(&props) { Ok(()) => (), @@ -987,6 +988,13 @@ impl Tty { Err(err) => debug!("couldn't set max bpc: {err:?}"), } } + + match get_panel_orientation(&props) { + Ok(x) => orientation = Some(x), + Err(err) => { + trace!("couldn't get panel orientation: {err:?}"); + } + } } else { warn!("failed to get connector properties"); }; @@ -1064,6 +1072,9 @@ impl Tty { .user_data() .insert_if_missing(|| TtyOutputState { node, crtc }); output.user_data().insert_if_missing(|| output_name.clone()); + if let Some(x) = orientation { + output.user_data().insert_if_missing(|| PanelOrientation(x)); + } let renderer = self.gpu_manager.single_renderer(&device.render_node)?; let egl_context = renderer.as_ref().egl_context(); @@ -2948,6 +2959,24 @@ fn is_vrr_capable(device: &DrmDevice, connector: connector::Handle) -> Option<bo info.value_type().convert_value(value).as_boolean() } +fn get_panel_orientation(props: &ConnectorProperties) -> anyhow::Result<Transform> { + let (info, value) = props.find(c"panel orientation")?; + match info.value_type().convert_value(*value) { + property::Value::Enum(Some(val)) => match val.value() { + // "Normal" + 0 => Ok(Transform::Normal), + // "Upside Down" + 1 => Ok(Transform::_180), + // "Left Side Up" + 2 => Ok(Transform::_90), + // "Right Side Up" + 3 => Ok(Transform::_270), + _ => bail!("panel orientation has invalid value: {:?}", val), + }, + _ => bail!("panel orientation has wrong value type"), + } +} + pub fn set_gamma_for_crtc( device: &DrmDevice, crtc: crtc::Handle, diff --git a/src/niri.rs b/src/niri.rs index 4efab5ad..423875d6 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -174,8 +174,8 @@ use crate::utils::watcher::Watcher; use crate::utils::xwayland::satellite::Satellite; use crate::utils::{ center, center_f64, expand_home, get_monotonic_time, ipc_transform_to_smithay, is_mapped, - logical_output, make_screenshot_path, output_matches_name, output_size, send_scale_transform, - write_png_rgba8, xwayland, + logical_output, make_screenshot_path, output_matches_name, output_size, panel_orientation, + send_scale_transform, write_png_rgba8, xwayland, }; use crate::window::mapped::MappedId; use crate::window::{InitialConfigureState, Mapped, ResolvedWindowRules, Unmapped, WindowRef}; @@ -1699,9 +1699,10 @@ impl State { }); let scale = closest_representable_scale(scale.clamp(0.1, 10.)); - let mut transform = config - .map(|c| ipc_transform_to_smithay(c.transform)) - .unwrap_or(Transform::Normal); + let mut transform = panel_orientation(output) + + config + .map(|c| ipc_transform_to_smithay(c.transform)) + .unwrap_or(Transform::Normal); // FIXME: fix winit damage on other transforms. if name.connector == "winit" { transform = Transform::Flipped180; @@ -3026,9 +3027,9 @@ impl Niri { }); let scale = closest_representable_scale(scale.clamp(0.1, 10.)); - let mut transform = c - .map(|c| ipc_transform_to_smithay(c.transform)) - .unwrap_or(Transform::Normal); + let mut transform = panel_orientation(&output) + + c.map(|c| ipc_transform_to_smithay(c.transform)) + .unwrap_or(Transform::Normal); let mut backdrop_color = c .and_then(|c| c.backdrop_color) diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 4a7b4b6f..9a32e60f 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -173,6 +173,15 @@ pub fn logical_output(output: &Output) -> niri_ipc::LogicalOutput { } } +pub struct PanelOrientation(pub Transform); +pub fn panel_orientation(output: &Output) -> Transform { + output + .user_data() + .get::<PanelOrientation>() + .map(|x| x.0) + .unwrap_or(Transform::Normal) +} + pub fn ipc_transform_to_smithay(transform: niri_ipc::Transform) -> Transform { match transform { niri_ipc::Transform::Normal => Transform::Normal, |
