desktop: Prevent entering/exiting fullscreen repeatedly
This commit is contained in:
parent
b2867aa3b9
commit
55f348f014
|
@ -250,6 +250,7 @@ fn run_player(opt: Opt) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let mut time = Instant::now();
|
let mut time = Instant::now();
|
||||||
let mut next_frame_time = Instant::now();
|
let mut next_frame_time = Instant::now();
|
||||||
let mut minimized = false;
|
let mut minimized = false;
|
||||||
|
let mut fullscreen_down = false;
|
||||||
loop {
|
loop {
|
||||||
// Poll UI events
|
// Poll UI events
|
||||||
event_loop.run(move |event, _window_target, control_flow| {
|
event_loop.run(move |event, _window_target, control_flow| {
|
||||||
|
@ -361,10 +362,24 @@ fn run_player(opt: Opt) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
},
|
},
|
||||||
..
|
..
|
||||||
} if modifiers.alt() => {
|
} if modifiers.alt() => {
|
||||||
window.set_fullscreen(match window.fullscreen() {
|
if !fullscreen_down {
|
||||||
None => Some(Fullscreen::Borderless(None)),
|
window.set_fullscreen(match window.fullscreen() {
|
||||||
Some(_) => None,
|
None => Some(Fullscreen::Borderless(None)),
|
||||||
});
|
Some(_) => None,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
fullscreen_down = true;
|
||||||
|
}
|
||||||
|
WindowEvent::KeyboardInput {
|
||||||
|
input:
|
||||||
|
KeyboardInput {
|
||||||
|
state: ElementState::Released,
|
||||||
|
virtual_keycode: Some(VirtualKeyCode::Return),
|
||||||
|
..
|
||||||
|
},
|
||||||
|
..
|
||||||
|
} if fullscreen_down => {
|
||||||
|
fullscreen_down = false;
|
||||||
}
|
}
|
||||||
WindowEvent::KeyboardInput {
|
WindowEvent::KeyboardInput {
|
||||||
input:
|
input:
|
||||||
|
|
Loading…
Reference in New Issue