Process WM_SYSCOMMAND to forbid screen savers in fullscreen mode (#1065)

* Process WM_SYSCOMMAND to forbid screen savers in fullscreen mode

Fixes #1047

* Update CHANGELOG.md and documentation to reflect changes from issue #1065

* Updated documentation of window.Window.set_fullscreen to match the documentation of window.WindowBuilder.with_fullscreen.
This commit is contained in:
dam4rus 2019-07-29 11:18:23 +02:00 committed by Hal Gentz
parent f4e9bf51db
commit e5ba79db04
3 changed files with 17 additions and 0 deletions

View file

@ -3,6 +3,7 @@
- On Windows, location of `WindowEvent::Touch` are window client coordinates instead of screen coordinates.
- On X11, fix delayed events after window redraw.
- On macOS, add `WindowBuilderExt::with_disallow_hidpi` to have the option to turn off best resolution openGL surface.
- On Windows, screen saver won't start if the window is in fullscreen mode.
# 0.20.0 Alpha 2 (2019-07-09)

View file

@ -1020,6 +1020,17 @@ unsafe extern "system" fn public_window_callback<T>(
// other unwanted default hotkeys as well.
winuser::WM_SYSCHAR => 0,
winuser::WM_SYSCOMMAND => {
if wparam == winuser::SC_SCREENSAVE {
let window_state = subclass_input.window_state.lock();
if window_state.fullscreen.is_some() {
return 0;
}
}
winuser::DefWindowProcW(window, msg, wparam, lparam)
}
winuser::WM_MOUSEMOVE => {
use crate::event::WindowEvent::{CursorEntered, CursorMoved};
let mouse_was_outside_window = {

View file

@ -224,6 +224,10 @@ impl WindowBuilder {
/// Sets the window fullscreen state. None means a normal window, Some(MonitorHandle)
/// means a fullscreen window on that specific monitor
///
/// ## Platform-specific
///
/// - **Windows:** Screen saver is disabled in fullscreen mode.
#[inline]
pub fn with_fullscreen(mut self, monitor: Option<MonitorHandle>) -> WindowBuilder {
self.window.fullscreen = monitor;
@ -534,6 +538,7 @@ impl Window {
/// ## Platform-specific
///
/// - **iOS:** Can only be called on the main thread.
/// - **Windows:** Screen saver is disabled in fullscreen mode.
#[inline]
pub fn set_fullscreen(&self, monitor: Option<MonitorHandle>) {
self.window.set_fullscreen(monitor)