Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion libwayshot/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ use crate::region::{LogicalRegion, Position, Size};

/// Represents an accessible wayland output.
///
/// Do not instantiate, instead use [`crate::WayshotConnection::get_all_outputs`].
/// Record the useful information of a WlOutput
/// The most important part is wl_output and transform
/// The two part will influence the output of the image
/// If you are using [crate::WayshotConnection::screenshot_single_output], you can do not care about
/// the physical_size and logical_region
/// But with region screenshot, they are needed
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct OutputInfo {
pub wl_output: WlOutput,
Expand All @@ -17,6 +22,25 @@ pub struct OutputInfo {
pub logical_region: LogicalRegion,
}

impl OutputInfo {
/// create a [OutputInfo] with new
pub fn new(wl_output: WlOutput) -> Self {
Self {
wl_output,
name: "".to_owned(),
description: "".to_owned(),
transform: wl_output::Transform::Normal,
physical_size: Size::default(),
logical_region: LogicalRegion::default(),
}
}
/// set the transform of [OutputInfo]
pub fn transform(mut self, transform: wl_output::Transform) -> Self {
self.transform = transform;
self
}
}

impl AsRef<WlOutput> for OutputInfo {
fn as_ref(&self) -> &WlOutput {
&self.wl_output
Expand Down