pub struct Resolution {
pub width: u32,
pub height: u32,
}
Expand description
Contains the resolution of a display
Fields§
§width: u32
§height: u32
Implementations§
Source§impl Resolution
impl Resolution
Sourcepub fn new(width: u32, height: u32) -> Self
pub fn new(width: u32, height: u32) -> Self
Creates a new resolution
Examples found in repository?
examples/resolution.rs (line 14)
4fn main() -> Result<(), Box<dyn std::error::Error>> {
5 let display_set = query_displays()?;
6 println!("Discovered displays:\n{}", display_set);
7
8 if let Some(settings) = display_set.primary().settings() {
9 let res = (*settings).borrow().resolution;
10 println!("Current resolution: {:?}", res);
11
12 if res.height == 1080 {
13 println!("Resolution is 1080p, changing to 720p");
14 (*settings).borrow_mut().resolution = Resolution::new(1280, 720);
15 } else {
16 println!("Resolution is 720p, changing to 1080p");
17 (*settings).borrow_mut().resolution = Resolution::new(1920, 1080);
18 }
19 } else {
20 eprintln!("Primary display has no settings");
21 }
22
23 display_set.primary().apply()?;
24 refresh()?;
25
26 Ok(())
27}
Trait Implementations§
Source§impl Clone for Resolution
impl Clone for Resolution
Source§fn clone(&self) -> Resolution
fn clone(&self) -> Resolution
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for Resolution
impl Debug for Resolution
Source§impl Display for Resolution
impl Display for Resolution
Source§impl FromStr for Resolution
impl FromStr for Resolution
Source§impl Hash for Resolution
impl Hash for Resolution
Source§impl Ord for Resolution
impl Ord for Resolution
Source§fn cmp(&self, other: &Resolution) -> Ordering
fn cmp(&self, other: &Resolution) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for Resolution
impl PartialEq for Resolution
Source§impl PartialOrd for Resolution
impl PartialOrd for Resolution
impl Copy for Resolution
impl Eq for Resolution
impl StructuralPartialEq for Resolution
Auto Trait Implementations§
impl Freeze for Resolution
impl RefUnwindSafe for Resolution
impl Send for Resolution
impl Sync for Resolution
impl Unpin for Resolution
impl UnwindSafe for Resolution
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more