Implement Windowed Fullscreen
There are two kinds of fullscreen. One where you take over the whole output the other where you just set the window size to the screen size and get rid of decorations. The first one already existed, implement the second which is more common for normal desktop apps. Use an enum to consolidate all the fullscreen states.
This commit is contained in:
parent
a4052b8693
commit
1d97a2a506
8 changed files with 81 additions and 14 deletions
24
src/lib.rs
24
src/lib.rs
|
|
@ -356,6 +356,24 @@ pub enum MouseCursor {
|
|||
RowResize,
|
||||
}
|
||||
|
||||
/// Describes if the Window is in one of the fullscreen modes
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub enum FullScreenState {
|
||||
None,
|
||||
Windowed,
|
||||
Exclusive(platform::MonitorId),
|
||||
}
|
||||
|
||||
impl FullScreenState {
|
||||
pub fn get_monitor(&self) -> Option<platform::MonitorId> {
|
||||
if let FullScreenState::Exclusive(ref monitor) = *self {
|
||||
Some(monitor.clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Describes how winit handles the cursor.
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
pub enum CursorState {
|
||||
|
|
@ -392,10 +410,10 @@ pub struct WindowAttributes {
|
|||
/// The default is `None`.
|
||||
pub max_dimensions: Option<(u32, u32)>,
|
||||
|
||||
/// If `Some`, the window will be in fullscreen mode with the given monitor.
|
||||
/// Whether the window should be set as fullscreen upon creation.
|
||||
///
|
||||
/// The default is `None`.
|
||||
pub monitor: Option<platform::MonitorId>,
|
||||
pub fullscreen: FullScreenState,
|
||||
|
||||
/// The title of the window in the title bar.
|
||||
///
|
||||
|
|
@ -435,9 +453,9 @@ impl Default for WindowAttributes {
|
|||
dimensions: None,
|
||||
min_dimensions: None,
|
||||
max_dimensions: None,
|
||||
monitor: None,
|
||||
title: "winit window".to_owned(),
|
||||
maximized: false,
|
||||
fullscreen: FullScreenState::None,
|
||||
visible: true,
|
||||
transparent: false,
|
||||
decorations: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue