From b77e9fa9b12e68156500ee1481ad396ac8fde17a Mon Sep 17 00:00:00 2001 From: Ottatop Date: Wed, 17 Apr 2024 21:31:39 -0500 Subject: [PATCH] Add transform to Rust output setup --- api/rust/src/output.rs | 14 ++++++++++++++ tests/rust_api.rs | 8 +++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/api/rust/src/output.rs b/api/rust/src/output.rs index e3e7a41..e22590a 100644 --- a/api/rust/src/output.rs +++ b/api/rust/src/output.rs @@ -422,6 +422,7 @@ pub struct OutputSetup { mode: Option, scale: Option, tag_names: Option>, + transform: Option, } impl OutputSetup { @@ -432,6 +433,7 @@ impl OutputSetup { mode: None, scale: None, tag_names: None, + transform: None, } } @@ -444,6 +446,7 @@ impl OutputSetup { mode: None, scale: None, tag_names: None, + transform: None, } } @@ -471,6 +474,14 @@ impl OutputSetup { } } + /// Makes this setup apply the given transform to its outputs. + pub fn with_transform(self, transform: Transform) -> Self { + Self { + transform: Some(transform), + ..self + } + } + fn apply(&self, output: &OutputHandle, tag: &Tag) { if let Some(mode) = &self.mode { output.set_mode( @@ -485,6 +496,9 @@ impl OutputSetup { if let Some(tag_names) = &self.tag_names { tag.add(output, tag_names); } + if let Some(transform) = self.transform { + output.set_transform(transform); + } } } diff --git a/tests/rust_api.rs b/tests/rust_api.rs index b17e8ca..b656266 100644 --- a/tests/rust_api.rs +++ b/tests/rust_api.rs @@ -60,7 +60,8 @@ mod output { pixel_width: 6900, pixel_height: 420, refresh_rate_millihertz: 69420, - }), + }) + .with_transform(pinnacle_api::output::Transform::_90), ]); }); @@ -108,6 +109,11 @@ mod output { assert_eq!(second_mode.size.w, 6900); assert_eq!(second_mode.size.h, 420); assert_eq!(second_mode.refresh, 69420); + + assert_eq!( + second_op.current_transform(), + smithay::utils::Transform::_90 + ); }); }) }