Simplify internal type construction
This commit is contained in:
parent
25b129362f
commit
fafdedfb7d
30 changed files with 242 additions and 285 deletions
|
|
@ -13,7 +13,6 @@ use super::{
|
|||
};
|
||||
use crate::{
|
||||
dpi::{PhysicalPosition, PhysicalSize},
|
||||
monitor::{MonitorHandle as RootMonitorHandle, VideoMode as RootVideoMode},
|
||||
platform_impl::{MonitorHandle as PlatformMonitorHandle, VideoMode as PlatformVideoMode},
|
||||
};
|
||||
|
||||
|
|
@ -53,10 +52,8 @@ impl VideoMode {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn monitor(&self) -> RootMonitorHandle {
|
||||
RootMonitorHandle {
|
||||
inner: PlatformMonitorHandle::X(self.monitor.clone().unwrap()),
|
||||
}
|
||||
pub fn monitor(&self) -> PlatformMonitorHandle {
|
||||
PlatformMonitorHandle::X(self.monitor.clone().unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -199,13 +196,11 @@ impl MonitorHandle {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn video_modes(&self) -> impl Iterator<Item = RootVideoMode> {
|
||||
pub fn video_modes(&self) -> impl Iterator<Item = PlatformVideoMode> {
|
||||
let monitor = self.clone();
|
||||
self.video_modes.clone().into_iter().map(move |mut x| {
|
||||
x.monitor = Some(monitor.clone());
|
||||
RootVideoMode {
|
||||
video_mode: PlatformVideoMode::X(x),
|
||||
}
|
||||
PlatformVideoMode::X(x)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,13 +15,12 @@ use x11_dl::xlib::TrueColor;
|
|||
use crate::{
|
||||
dpi::{PhysicalPosition, PhysicalSize, Position, Size},
|
||||
error::{ExternalError, NotSupportedError, OsError as RootOsError},
|
||||
monitor::{MonitorHandle as RootMonitorHandle, VideoMode as RootVideoMode},
|
||||
platform_impl::{
|
||||
x11::{ime::ImeContextCreationError, MonitorHandle as X11MonitorHandle},
|
||||
MonitorHandle as PlatformMonitorHandle, OsError, PlatformSpecificWindowBuilderAttributes,
|
||||
VideoMode as PlatformVideoMode,
|
||||
Fullscreen, MonitorHandle as PlatformMonitorHandle, OsError,
|
||||
PlatformSpecificWindowBuilderAttributes, VideoMode as PlatformVideoMode,
|
||||
},
|
||||
window::{CursorGrabMode, CursorIcon, Fullscreen, Icon, UserAttentionType, WindowAttributes},
|
||||
window::{CursorGrabMode, CursorIcon, Icon, UserAttentionType, WindowAttributes},
|
||||
};
|
||||
|
||||
use super::{
|
||||
|
|
@ -40,9 +39,9 @@ pub struct SharedState {
|
|||
pub is_decorated: bool,
|
||||
pub last_monitor: X11MonitorHandle,
|
||||
pub dpi_adjusted: Option<(u32, u32)>,
|
||||
pub fullscreen: Option<Fullscreen>,
|
||||
pub(crate) fullscreen: Option<Fullscreen>,
|
||||
// Set when application calls `set_fullscreen` when window is not visible
|
||||
pub desired_fullscreen: Option<Option<Fullscreen>>,
|
||||
pub(crate) desired_fullscreen: Option<Option<Fullscreen>>,
|
||||
// Used to restore position after exiting fullscreen
|
||||
pub restore_position: Option<(i32, i32)>,
|
||||
// Used to restore video mode after exiting fullscreen
|
||||
|
|
@ -638,17 +637,10 @@ impl UnownedWindow {
|
|||
// fullscreen, so we can restore it upon exit, as XRandR does not
|
||||
// provide a mechanism to set this per app-session or restore this
|
||||
// to the desktop video mode as macOS and Windows do
|
||||
(
|
||||
&None,
|
||||
&Some(Fullscreen::Exclusive(RootVideoMode {
|
||||
video_mode: PlatformVideoMode::X(ref video_mode),
|
||||
})),
|
||||
)
|
||||
(&None, &Some(Fullscreen::Exclusive(PlatformVideoMode::X(ref video_mode))))
|
||||
| (
|
||||
&Some(Fullscreen::Borderless(_)),
|
||||
&Some(Fullscreen::Exclusive(RootVideoMode {
|
||||
video_mode: PlatformVideoMode::X(ref video_mode),
|
||||
})),
|
||||
&Some(Fullscreen::Exclusive(PlatformVideoMode::X(ref video_mode))),
|
||||
) => {
|
||||
let monitor = video_mode.monitor.as_ref().unwrap();
|
||||
shared_state_lock.desktop_video_mode =
|
||||
|
|
@ -679,12 +671,12 @@ impl UnownedWindow {
|
|||
}
|
||||
Some(fullscreen) => {
|
||||
let (video_mode, monitor) = match fullscreen {
|
||||
Fullscreen::Exclusive(RootVideoMode {
|
||||
video_mode: PlatformVideoMode::X(ref video_mode),
|
||||
}) => (Some(video_mode), video_mode.monitor.clone().unwrap()),
|
||||
Fullscreen::Borderless(Some(RootMonitorHandle {
|
||||
inner: PlatformMonitorHandle::X(monitor),
|
||||
})) => (None, monitor),
|
||||
Fullscreen::Exclusive(PlatformVideoMode::X(ref video_mode)) => {
|
||||
(Some(video_mode), video_mode.monitor.clone().unwrap())
|
||||
}
|
||||
Fullscreen::Borderless(Some(PlatformMonitorHandle::X(monitor))) => {
|
||||
(None, monitor)
|
||||
}
|
||||
Fullscreen::Borderless(None) => (None, self.current_monitor()),
|
||||
#[cfg(feature = "wayland")]
|
||||
_ => unreachable!(),
|
||||
|
|
@ -737,7 +729,7 @@ impl UnownedWindow {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn fullscreen(&self) -> Option<Fullscreen> {
|
||||
pub(crate) fn fullscreen(&self) -> Option<Fullscreen> {
|
||||
let shared_state = self.shared_state_lock();
|
||||
|
||||
shared_state
|
||||
|
|
@ -747,7 +739,7 @@ impl UnownedWindow {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_fullscreen(&self, fullscreen: Option<Fullscreen>) {
|
||||
pub(crate) fn set_fullscreen(&self, fullscreen: Option<Fullscreen>) {
|
||||
if let Some(flusher) = self.set_fullscreen_inner(fullscreen) {
|
||||
flusher
|
||||
.sync()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue