Skip to content

Commit

Permalink
Allow windows to maximized. (#1004)
Browse files Browse the repository at this point in the history
Adds a new `set_maximized` method to allow users to maximize windows.
  • Loading branch information
frewsxcv authored Dec 4, 2020
1 parent fcbae57 commit 1398d78
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions crates/bevy_window/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ pub enum WindowCommand {
SetCursorPosition {
position: Vec2,
},
SetMaximized {
maximized: bool,
},
}

/// Defines the way a window is displayed
Expand Down Expand Up @@ -140,6 +143,12 @@ impl Window {
self.height
}

#[inline]
pub fn set_maximized(&mut self, maximized: bool) {
self.command_queue
.push(WindowCommand::SetMaximized { maximized });
}

pub fn set_resolution(&mut self, width: u32, height: u32) {
self.width = width;
self.height = height;
Expand Down
4 changes: 4 additions & 0 deletions crates/bevy_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ fn change_window(_: &mut World, resources: &mut Resources) {
))
.unwrap_or_else(|e| error!("Unable to set cursor position: {}", e));
}
bevy_window::WindowCommand::SetMaximized { maximized } => {
let window = winit_windows.get_window(id).unwrap();
window.set_maximized(maximized)
}
}
}
}
Expand Down

0 comments on commit 1398d78

Please sign in to comment.