Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial refactoring of displayz #3

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7fdb09d
Initial refactoring of `displayz`
shymega Jun 6, 2023
db83787
Improve documentation on `common` module
shymega Jun 6, 2023
e30d6e1
Fix #[cfg] attributes on Linux platform
shymega Jun 6, 2023
c5bb350
Fix self-referencing import on Windows platform
shymega Jun 6, 2023
b01cc7c
Remove `deny` lint - as per review
shymega Jun 6, 2023
1760fb0
Rename `get_resolutions` to be more clear
shymega Jun 6, 2023
25cc00b
Change Resolution/Position types to struct
shymega Jun 6, 2023
5c1da8f
Add Linux Wayland/X11 feature flags and optional deps
shymega Jun 6, 2023
d688514
Clarify `get_resolution` method in `DisplayOutput` trait
shymega Jun 6, 2023
5a00d20
Bump Cargo.lock
shymega Jun 6, 2023
9c880e2
Rename `linux` to `unix` to support BSDs/Linux
shymega Jun 6, 2023
2c5924b
Change Wayland dep target to `unix` target_family
shymega Jun 6, 2023
a867064
Add initial struct for `WaylandBackend`
shymega Jun 6, 2023
62ef1c2
Add note to `Resolutions` type about future use
shymega Jun 7, 2023
bffb266
Remove `is_focused` - move to platform-specific extensions
shymega Jun 7, 2023
97acc1d
Wrap `get_edid` in an `Option<T>`
shymega Jun 7, 2023
56aa7b5
Run `cargo-fmt` on codebase
shymega Jun 7, 2023
a01a9b0
Revert "Add note to `Resolutions` type about future use"
shymega Jun 23, 2023
9a19c3d
Add Wayland protocols for Plasma/KDE
shymega Sep 24, 2023
ad544fa
refactor: Refactor types into structs, impl Debug/Display
shymega Jun 5, 2024
7680298
refactor: Change `Display` type into `dyn` trait, for generics
shymega Jun 5, 2024
d537eb1
chore: Remove Windows CLI
shymega Jun 5, 2024
61d42e0
chore: bump Cargo.lock
shymega Jun 5, 2024
12ec155
fix: Fix Derives in `common/mod.rs`
shymega Jun 5, 2024
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
Prev Previous commit
Next Next commit
Improve documentation on common module
Signed-off-by: Dom Rodriguez <shymega@shymega.org.uk>
  • Loading branch information
shymega committed Jan 11, 2025
commit db837871dbeac5c7c8f727ff6cd33778dd05489e
27 changes: 26 additions & 1 deletion src/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,38 @@
//! Common helpers for `displayz`

/// Height and Width of a Display (`usize`)
pub type Resolution = (usize, usize);

/// X/Y positions of a display.
pub type Position = (usize, usize);

pub type Displays = Vec<dyn DisplayOutput>;
/// `Vec` type of the `Display` struct, exposed on a platform-dependent basis.
pub type Displays = Vec<crate::Display>;

/// `Vec` type of the `Resolution` type, generally exposing a collection of available resolutions.
pub type Resolutions = Vec<Resolution>;

/// `DisplayOutput` defines the Trait specification of a platform's `Display`.
/// A `Display` may contain:
/// - An EDID.
/// - State, including if the `Display` is active, primary, or has a fault.
/// - Other helper methods, returning data stored in-memory state.
pub trait DisplayOutput {
/// Returns a boolean result, if the `Display` is the 'primary display' or not.
fn is_primary(&self) -> bool;
/// Returns a boolean result, if the `Display` is currently active or not.
fn is_active(&self) -> bool;
/// Returns a boolean result, if the `Display` is currently focused or not.
/// This is not available on all platforms, in the event it's not, it will *always* return `false`.
fn is_focused(&self) -> bool {
false
}
/// Returns the `Position` custom type of the `Display`.
fn get_position(&self) -> Position;
/// Returns the `Resolution` custom type of the `Display`.
fn get_resolution(&self) -> Resolution;
/// Returns the `Resolutions` custom type of the `Display`.
fn get_resolutions(&self) -> Resolutions;
/// Returns the EDID `&str` of the `Display.
fn get_edid(&self) -> &str;
}