From 88f48424bcb6cd8281639ada1ff1c0718b7eb5a4 Mon Sep 17 00:00:00 2001 From: Ben Widawsky Date: Wed, 17 Apr 2024 09:44:14 -0700 Subject: [PATCH 1/2] Add Display impl for connectors --- src/control/connector.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/control/connector.rs b/src/control/connector.rs index 9fc4755..1eaae00 100644 --- a/src/control/connector.rs +++ b/src/control/connector.rs @@ -60,6 +60,12 @@ pub struct Info { pub(crate) subpixel: SubPixel, } +impl std::fmt::Display for Info { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}-{}", self.interface.as_str(), self.interface_id) + } +} + impl Info { /// Returns the handle to this connector. pub fn handle(&self) -> Handle { From d81847693d5521a6e5e195211b0cac709b20928c Mon Sep 17 00:00:00 2001 From: Ben Widawsky Date: Wed, 17 Apr 2024 09:53:24 -0700 Subject: [PATCH 2/2] Add Display impl for few more KMS objects --- src/control/crtc.rs | 6 ++++++ src/control/encoder.rs | 6 ++++++ src/control/framebuffer.rs | 6 ++++++ src/control/plane.rs | 6 ++++++ 4 files changed, 24 insertions(+) diff --git a/src/control/crtc.rs b/src/control/crtc.rs index 0827043..cfaf9b3 100644 --- a/src/control/crtc.rs +++ b/src/control/crtc.rs @@ -62,6 +62,12 @@ pub struct Info { pub(crate) gamma_length: u32, } +impl std::fmt::Display for Info { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "CRTC {}", self.handle.0) + } +} + impl Info { /// Returns the handle to this CRTC. pub fn handle(&self) -> Handle { diff --git a/src/control/encoder.rs b/src/control/encoder.rs index fd194b1..e5def40 100644 --- a/src/control/encoder.rs +++ b/src/control/encoder.rs @@ -53,6 +53,12 @@ pub struct Info { pub(crate) pos_clones: u32, } +impl std::fmt::Display for Info { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "Encoder {}", self.handle.0) + } +} + impl Info { /// Returns the handle to this encoder. pub fn handle(&self) -> Handle { diff --git a/src/control/framebuffer.rs b/src/control/framebuffer.rs index 1e80ceb..91517fb 100644 --- a/src/control/framebuffer.rs +++ b/src/control/framebuffer.rs @@ -55,6 +55,12 @@ pub struct Info { pub(crate) buffer: Option, } +impl std::fmt::Display for Info { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "Framebuffer {}", self.handle.0) + } +} + impl Info { /// Returns the handle to this framebuffer. pub fn handle(&self) -> Handle { diff --git a/src/control/plane.rs b/src/control/plane.rs index c287935..3637d94 100644 --- a/src/control/plane.rs +++ b/src/control/plane.rs @@ -65,6 +65,12 @@ pub struct Info { pub(crate) formats: Vec, } +impl std::fmt::Display for Info { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "Plane {}", self.handle.0) + } +} + impl Info { /// Returns the handle to this plane. pub fn handle(&self) -> Handle {