Less dumb fullscreen
This commit is contained in:
parent
77fdd19ec2
commit
299ef053f4
|
@ -238,13 +238,6 @@ impl BackendEventLoop for SDL2EventLoop {
|
||||||
let mut mutex = GAME_SUSPENDED.lock().unwrap();
|
let mut mutex = GAME_SUSPENDED.lock().unwrap();
|
||||||
*mutex = true;
|
*mutex = true;
|
||||||
|
|
||||||
let mut refs = self.refs.borrow_mut();
|
|
||||||
let window = refs.window.window_mut();
|
|
||||||
if window.fullscreen_state() == sdl2::video::FullscreenType::True {
|
|
||||||
window.set_fullscreen(sdl2::video::FullscreenType::Off);
|
|
||||||
window.subsystem().sdl().mouse().show_cursor(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
state.sound_manager.pause();
|
state.sound_manager.pause();
|
||||||
}
|
}
|
||||||
WindowEvent::SizeChanged(width, height) => {
|
WindowEvent::SizeChanged(width, height) => {
|
||||||
|
@ -257,18 +250,26 @@ impl BackendEventLoop for SDL2EventLoop {
|
||||||
}
|
}
|
||||||
state.handle_resize(ctx).unwrap();
|
state.handle_resize(ctx).unwrap();
|
||||||
}
|
}
|
||||||
WindowEvent::Maximized => {
|
|
||||||
let mut refs = self.refs.borrow_mut();
|
|
||||||
let window = refs.window.window_mut();
|
|
||||||
window.set_fullscreen(sdl2::video::FullscreenType::True);
|
|
||||||
window.subsystem().sdl().mouse().show_cursor(false);
|
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
Event::KeyDown { scancode: Some(scancode), repeat, .. } => {
|
Event::KeyDown { scancode: Some(scancode), repeat, keymod, .. } => {
|
||||||
if let Some(drs_scan) = conv_scancode(scancode) {
|
if let Some(drs_scan) = conv_scancode(scancode) {
|
||||||
if !repeat {
|
if !repeat {
|
||||||
state.process_debug_keys(drs_scan);
|
state.process_debug_keys(drs_scan);
|
||||||
|
|
||||||
|
if keymod.intersects(keyboard::Mod::RALTMOD | keyboard::Mod::LALTMOD)
|
||||||
|
&& drs_scan == ScanCode::Return
|
||||||
|
{
|
||||||
|
let mut refs = self.refs.borrow_mut();
|
||||||
|
let window = refs.window.window_mut();
|
||||||
|
if window.fullscreen_state() == sdl2::video::FullscreenType::Desktop {
|
||||||
|
window.set_fullscreen(sdl2::video::FullscreenType::Off);
|
||||||
|
window.subsystem().sdl().mouse().show_cursor(true);
|
||||||
|
} else {
|
||||||
|
window.set_fullscreen(sdl2::video::FullscreenType::Desktop);
|
||||||
|
window.subsystem().sdl().mouse().show_cursor(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ctx.keyboard_context.set_key(drs_scan, true);
|
ctx.keyboard_context.set_key(drs_scan, true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue