Skip to main content

MonitorHandleProvider

Trait MonitorHandleProvider 

Source
pub trait MonitorHandleProvider:
    Any
    + Debug
    + Send
    + Sync {
    // Required methods
    fn id(&self) -> u128;
    fn native_id(&self) -> u64;
    fn name(&self) -> Option<Cow<'_, str>>;
    fn position(&self) -> Option<PhysicalPosition<i32>>;
    fn scale_factor(&self) -> f64;
    fn current_video_mode(&self) -> Option<VideoMode>;
    fn video_modes(&self) -> Box<dyn Iterator<Item = VideoMode>>;
}
Expand description

Provider of the MonitorHandle.

Required Methods§

Source

fn id(&self) -> u128

Identifier for this monitor.

The representation of this modifier is not guaranteed and should be used only to compare monitors.

Source

fn native_id(&self) -> u64

Native platform identifier of this monitor.

§Platform-specific
  • Windows: This is HMONITOR.
  • macOS: This is CGDirectDisplayID.
  • iOS: This is UIScreen*.
  • Wayland: This is the ID of the wl_output device.
  • X11: This is the ID of the CRTC.
  • Web: This is an internal ID not meant for consumption.
Source

fn name(&self) -> Option<Cow<'_, str>>

Returns a human-readable name of the monitor.

Returns None if the monitor doesn’t exist anymore or the name couldn’t be obtained.

§Platform-specific

Web: Always returns None without detailed monitor permissions.

Source

fn position(&self) -> Option<PhysicalPosition<i32>>

Returns the top-left corner position of the monitor in desktop coordinates.

This position is in the same coordinate system as Window::outer_position.

§Platform-specific

Web: Always returns None without detailed monitor permissions.

Source

fn scale_factor(&self) -> f64

Returns the scale factor of the underlying monitor. To map logical pixels to physical pixels and vice versa, use Window::scale_factor.

See the dpi module for more information.

  • Wayland: May differ from Window::scale_factor.
  • Web: Always returns 0.0 without detailed_monitor_permissions.
Source

fn current_video_mode(&self) -> Option<VideoMode>

Source

fn video_modes(&self) -> Box<dyn Iterator<Item = VideoMode>>

Returns all fullscreen video modes supported by this monitor.

Implementations§

Source§

impl dyn MonitorHandleProvider + '_

Source

pub fn cast_ref<T: MonitorHandleProvider>(&self) -> Option<&T>

Downcast to the backend concrete type.

Returns None if the object was not from that backend.

Source

pub fn cast_mut<T: MonitorHandleProvider>(&mut self) -> Option<&mut T>

Mutable downcast to the backend concrete type.

Returns None if the object was not from that backend.

Source

pub fn cast<T: MonitorHandleProvider>( self: Box<Self>, ) -> Result<Box<T>, Box<Self>>

Owned downcast to the backend concrete type.

Returns Err with self if the object was not from that backend.

Trait Implementations§

Source§

impl Eq for dyn MonitorHandleProvider + '_

Source§

impl PartialEq for dyn MonitorHandleProvider + '_

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§