Skip to content

Commit 1398d78

Browse files
authored
Allow windows to maximized. (#1004)
Adds a new `set_maximized` method to allow users to maximize windows.
1 parent fcbae57 commit 1398d78

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

crates/bevy_window/src/window.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ pub enum WindowCommand {
8282
SetCursorPosition {
8383
position: Vec2,
8484
},
85+
SetMaximized {
86+
maximized: bool,
87+
},
8588
}
8689

8790
/// Defines the way a window is displayed
@@ -140,6 +143,12 @@ impl Window {
140143
self.height
141144
}
142145

146+
#[inline]
147+
pub fn set_maximized(&mut self, maximized: bool) {
148+
self.command_queue
149+
.push(WindowCommand::SetMaximized { maximized });
150+
}
151+
143152
pub fn set_resolution(&mut self, width: u32, height: u32) {
144153
self.width = width;
145154
self.height = height;

crates/bevy_winit/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ fn change_window(_: &mut World, resources: &mut Resources) {
104104
))
105105
.unwrap_or_else(|e| error!("Unable to set cursor position: {}", e));
106106
}
107+
bevy_window::WindowCommand::SetMaximized { maximized } => {
108+
let window = winit_windows.get_window(id).unwrap();
109+
window.set_maximized(maximized)
110+
}
107111
}
108112
}
109113
}

0 commit comments

Comments
 (0)