Add transform to Rust output setup

This commit is contained in:
Ottatop 2024-04-17 21:31:39 -05:00
parent d28f520b07
commit b77e9fa9b1
2 changed files with 21 additions and 1 deletions

View file

@ -422,6 +422,7 @@ pub struct OutputSetup {
mode: Option<Mode>,
scale: Option<f32>,
tag_names: Option<Vec<String>>,
transform: Option<Transform>,
}
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);
}
}
}

View file

@ -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
);
});
})
}