Simplify internal type construction

This commit is contained in:
Mads Marquart 2022-09-21 10:04:28 +02:00 committed by GitHub
parent 25b129362f
commit fafdedfb7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 242 additions and 285 deletions

View file

@ -15,7 +15,6 @@ use crate::event::{
WindowEvent,
};
use crate::event_loop::ControlFlow;
use crate::monitor::MonitorHandle as RootMH;
use crate::window::{Theme, WindowId as RootWindowId};
pub struct EventLoopWindowTarget<T: 'static> {
@ -283,10 +282,8 @@ impl<T> EventLoopWindowTarget<T> {
VecDeque::new().into_iter()
}
pub fn primary_monitor(&self) -> Option<RootMH> {
Some(RootMH {
inner: MonitorHandle,
})
pub fn primary_monitor(&self) -> Option<MonitorHandle> {
Some(MonitorHandle)
}
pub fn raw_display_handle(&self) -> RawDisplayHandle {

View file

@ -35,6 +35,7 @@ pub use self::monitor::{MonitorHandle, VideoMode};
pub use self::window::{PlatformSpecificWindowBuilderAttributes, Window, WindowId};
pub(crate) use crate::icon::NoIcon as PlatformIcon;
pub(self) use crate::platform_impl::Fullscreen;
#[derive(Clone, Copy)]
pub(crate) struct ScaleChangeArgs {

View file

@ -1,5 +1,4 @@
use crate::dpi::{PhysicalPosition, PhysicalSize};
use crate::monitor::{MonitorHandle as RootMonitorHandle, VideoMode as RootVideoMode};
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct MonitorHandle;
@ -28,7 +27,7 @@ impl MonitorHandle {
}
}
pub fn video_modes(&self) -> impl Iterator<Item = RootVideoMode> {
pub fn video_modes(&self) -> impl Iterator<Item = VideoMode> {
std::iter::empty()
}
}
@ -49,9 +48,7 @@ impl VideoMode {
32000
}
pub fn monitor(&self) -> RootMonitorHandle {
RootMonitorHandle {
inner: MonitorHandle,
}
pub fn monitor(&self) -> MonitorHandle {
MonitorHandle
}
}

View file

@ -2,14 +2,13 @@ use crate::dpi::{LogicalSize, PhysicalPosition, PhysicalSize, Position, Size};
use crate::error::{ExternalError, NotSupportedError, OsError as RootOE};
use crate::event;
use crate::icon::Icon;
use crate::monitor::MonitorHandle as RootMH;
use crate::window::{
CursorGrabMode, CursorIcon, Fullscreen, UserAttentionType, WindowAttributes, WindowId as RootWI,
CursorGrabMode, CursorIcon, UserAttentionType, WindowAttributes, WindowId as RootWI,
};
use raw_window_handle::{RawDisplayHandle, RawWindowHandle, WebDisplayHandle, WebWindowHandle};
use super::{backend, monitor::MonitorHandle, EventLoopWindowTarget};
use super::{backend, monitor::MonitorHandle, EventLoopWindowTarget, Fullscreen};
use std::cell::{Ref, RefCell};
use std::collections::vec_deque::IntoIter as VecDequeIter;
@ -281,7 +280,7 @@ impl Window {
}
#[inline]
pub fn fullscreen(&self) -> Option<Fullscreen> {
pub(crate) fn fullscreen(&self) -> Option<Fullscreen> {
if self.canvas.borrow().is_fullscreen() {
Some(Fullscreen::Borderless(Some(self.current_monitor_inner())))
} else {
@ -290,8 +289,8 @@ impl Window {
}
#[inline]
pub fn set_fullscreen(&self, monitor: Option<Fullscreen>) {
if monitor.is_some() {
pub(crate) fn set_fullscreen(&self, fullscreen: Option<Fullscreen>) {
if fullscreen.is_some() {
self.canvas.borrow().request_fullscreen();
} else if self.canvas.borrow().is_fullscreen() {
backend::exit_fullscreen();
@ -339,14 +338,12 @@ impl Window {
#[inline]
// Allow directly accessing the current monitor internally without unwrapping.
fn current_monitor_inner(&self) -> RootMH {
RootMH {
inner: MonitorHandle,
}
fn current_monitor_inner(&self) -> MonitorHandle {
MonitorHandle
}
#[inline]
pub fn current_monitor(&self) -> Option<RootMH> {
pub fn current_monitor(&self) -> Option<MonitorHandle> {
Some(self.current_monitor_inner())
}
@ -356,10 +353,8 @@ impl Window {
}
#[inline]
pub fn primary_monitor(&self) -> Option<RootMH> {
Some(RootMH {
inner: MonitorHandle,
})
pub fn primary_monitor(&self) -> Option<MonitorHandle> {
Some(MonitorHandle)
}
#[inline]