From 9bdac884fa2edfc0166b6ce775fac56dd7cd4d4d Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Fri, 26 Feb 2016 12:47:10 +0000 Subject: [PATCH] Windows Disable ScreenSaver Train View .. previously it was disabled via VLC, but if you're not running with video then the screensaver will kick in on Windows. .. we now disable it via the Windows API too Fixes #1859 --- src/Train/TrainSidebar.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Train/TrainSidebar.cpp b/src/Train/TrainSidebar.cpp index 631964fa9..5e4ed2a53 100644 --- a/src/Train/TrainSidebar.cpp +++ b/src/Train/TrainSidebar.cpp @@ -64,6 +64,10 @@ #include #endif +#ifdef WIN32 +#include "Windows.h" +#endif + #include // isnan and isinf #include "TrainDB.h" #include "Library.h" @@ -1075,9 +1079,13 @@ void TrainSidebar::Start() // when start button is pressed qDebug() << "start..."; +#ifdef WIN32 + // disable the screen saver on Windows + SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_CONTINUOUS); +#endif + // Stop users from selecting different devices // media or workouts whilst a workout is in progress - #if !defined GC_VIDEO_NONE mediaTree->setEnabled(false); #ifdef GC_HAVE_VLC // RLV currently only support for VLC @@ -1211,6 +1219,11 @@ void TrainSidebar::Stop(int deviceStatus) // when stop button is pressed { if ((status&RT_RUNNING) == 0) return; + // re-enable the screen saver on Windows +#ifdef WIN32 + SetThreadExecutionState(ES_CONTINUOUS); +#endif + clearStatusFlags(RT_RUNNING|RT_PAUSED); // Stop users from selecting different devices