monitor: refactor MonitorHandle to store dyn object
This also alters `VideoMode` to be a regular object and not reference the `MonitorHandle`, since it's a static data. Given that `VideoMode` set may change during runtime keeping the reference as a some sort of validity may not be idea and propagating errors when changing video mode could be more reliable.
This commit is contained in:
parent
be1baf164c
commit
f1c5afd84e
43 changed files with 726 additions and 826 deletions
|
|
@ -10,7 +10,7 @@ pub use crate::cursor::{BadImage, Cursor, CustomCursor, CustomCursorSource, MAX_
|
|||
use crate::dpi::{PhysicalInsets, PhysicalPosition, PhysicalSize, Position, Size};
|
||||
use crate::error::RequestError;
|
||||
pub use crate::icon::{BadIcon, Icon};
|
||||
use crate::monitor::{MonitorHandle, VideoMode};
|
||||
use crate::monitor::{Fullscreen, MonitorHandle};
|
||||
use crate::platform_impl::PlatformSpecificWindowAttributes;
|
||||
use crate::utils::AsAny;
|
||||
|
||||
|
|
@ -442,7 +442,7 @@ pub trait Window: AsAny + Send + Sync + fmt::Debug {
|
|||
/// moved to another screen); as such, tracking [`WindowEvent::ScaleFactorChanged`] events is
|
||||
/// the most robust way to track the DPI you need to use to draw.
|
||||
///
|
||||
/// This value may differ from [`MonitorHandle::scale_factor`].
|
||||
/// This value may differ from [`MonitorHandleProvider::scale_factor`].
|
||||
///
|
||||
/// See the [`dpi`] crate for more information.
|
||||
///
|
||||
|
|
@ -496,6 +496,7 @@ pub trait Window: AsAny + Send + Sync + fmt::Debug {
|
|||
/// [android_1]: https://developer.android.com/training/multiscreen/screendensities
|
||||
/// [web_1]: https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
|
||||
/// [`contentScaleFactor`]: https://developer.apple.com/documentation/uikit/uiview/1622657-contentscalefactor?language=objc
|
||||
/// [`MonitorHandleProvider::scale_factor`]: crate::monitor::MonitorHandleProvider::scale_factor.
|
||||
fn scale_factor(&self) -> f64;
|
||||
|
||||
/// Queues a [`WindowEvent::RedrawRequested`] event to be emitted that aligns with the windowing
|
||||
|
|
@ -972,6 +973,7 @@ pub trait Window: AsAny + Send + Sync + fmt::Debug {
|
|||
/// or calling without a [transient activation] does nothing.
|
||||
///
|
||||
/// [transient activation]: https://developer.mozilla.org/en-US/docs/Glossary/Transient_activation
|
||||
/// [`VideoMode`]: crate::monitor::VideoMode
|
||||
fn set_fullscreen(&self, fullscreen: Option<Fullscreen>);
|
||||
|
||||
/// Gets the window's current fullscreen state.
|
||||
|
|
@ -1430,18 +1432,6 @@ impl From<ResizeDirection> for CursorIcon {
|
|||
}
|
||||
}
|
||||
|
||||
/// Fullscreen modes.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum Fullscreen {
|
||||
/// This changes the video mode of the monitor for fullscreen windows and,
|
||||
/// if applicable, captures the monitor for exclusive use by this
|
||||
/// application.
|
||||
Exclusive(MonitorHandle, VideoMode),
|
||||
|
||||
/// Providing `None` to `Borderless` will fullscreen on the current monitor.
|
||||
Borderless(Option<MonitorHandle>),
|
||||
}
|
||||
|
||||
/// The theme variant to use.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue