Rework 'Fullscreen::Borderless' enum variant
This changes 'Fullscreen::Borderless' enum variant from 'Fullscreen::Borderless(MonitorHandle)' to 'Fullscreen::Borderless(Option<MonitorHandle>)'. Providing 'None' to it will result in picking the current monitor.
This commit is contained in:
parent
644dc13e00
commit
71e3d25422
14 changed files with 89 additions and 46 deletions
|
|
@ -154,11 +154,16 @@ impl Window {
|
|||
Some(Fullscreen::Exclusive(_)) => {
|
||||
panic!("Wayland doesn't support exclusive fullscreen")
|
||||
}
|
||||
Some(Fullscreen::Borderless(RootMonitorHandle {
|
||||
inner: PlatformMonitorHandle::Wayland(ref monitor_id),
|
||||
})) => frame.set_fullscreen(Some(&monitor_id.proxy)),
|
||||
#[cfg(feature = "x11")]
|
||||
Some(Fullscreen::Borderless(_)) => unreachable!(),
|
||||
Some(Fullscreen::Borderless(monitor)) => {
|
||||
let monitor =
|
||||
monitor.and_then(|RootMonitorHandle { inner: monitor }| match monitor {
|
||||
PlatformMonitorHandle::Wayland(monitor) => Some(monitor.proxy),
|
||||
#[cfg(feature = "x11")]
|
||||
PlatformMonitorHandle::X(_) => None,
|
||||
});
|
||||
|
||||
frame.set_fullscreen(monitor.as_ref())
|
||||
}
|
||||
None => {
|
||||
if attributes.maximized {
|
||||
frame.set_maximized();
|
||||
|
|
@ -333,11 +338,13 @@ impl Window {
|
|||
|
||||
pub fn fullscreen(&self) -> Option<Fullscreen> {
|
||||
if *(self.fullscreen.lock().unwrap()) {
|
||||
// If the monitor cannot be determined, we cannot report any fullscreen mode.
|
||||
let current_monitor = self.current_monitor()?;
|
||||
Some(Fullscreen::Borderless(RootMonitorHandle {
|
||||
inner: PlatformMonitorHandle::Wayland(current_monitor),
|
||||
}))
|
||||
let current_monitor = self
|
||||
.current_monitor()
|
||||
.map(|current_monitor| RootMonitorHandle {
|
||||
inner: PlatformMonitorHandle::Wayland(current_monitor),
|
||||
});
|
||||
|
||||
Some(Fullscreen::Borderless(current_monitor))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
|
@ -348,16 +355,16 @@ impl Window {
|
|||
Some(Fullscreen::Exclusive(_)) => {
|
||||
panic!("Wayland doesn't support exclusive fullscreen")
|
||||
}
|
||||
Some(Fullscreen::Borderless(RootMonitorHandle {
|
||||
inner: PlatformMonitorHandle::Wayland(ref monitor_id),
|
||||
})) => {
|
||||
self.frame
|
||||
.lock()
|
||||
.unwrap()
|
||||
.set_fullscreen(Some(&monitor_id.proxy));
|
||||
Some(Fullscreen::Borderless(monitor)) => {
|
||||
let monitor =
|
||||
monitor.and_then(|RootMonitorHandle { inner: monitor }| match monitor {
|
||||
PlatformMonitorHandle::Wayland(monitor) => Some(monitor.proxy),
|
||||
#[cfg(feature = "x11")]
|
||||
PlatformMonitorHandle::X(_) => None,
|
||||
});
|
||||
|
||||
self.frame.lock().unwrap().set_fullscreen(monitor.as_ref());
|
||||
}
|
||||
#[cfg(feature = "x11")]
|
||||
Some(Fullscreen::Borderless(_)) => unreachable!(),
|
||||
None => self.frame.lock().unwrap().unset_fullscreen(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -649,10 +649,11 @@ impl UnownedWindow {
|
|||
let (video_mode, monitor) = match fullscreen {
|
||||
Fullscreen::Exclusive(RootVideoMode {
|
||||
video_mode: PlatformVideoMode::X(ref video_mode),
|
||||
}) => (Some(video_mode), video_mode.monitor.as_ref().unwrap()),
|
||||
Fullscreen::Borderless(RootMonitorHandle {
|
||||
inner: PlatformMonitorHandle::X(ref monitor),
|
||||
}) => (None, monitor),
|
||||
}) => (Some(video_mode), video_mode.monitor.clone().unwrap()),
|
||||
Fullscreen::Borderless(Some(RootMonitorHandle {
|
||||
inner: PlatformMonitorHandle::X(monitor),
|
||||
})) => (None, monitor),
|
||||
Fullscreen::Borderless(None) => (None, self.current_monitor()),
|
||||
#[cfg(feature = "wayland")]
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue