summaryrefslogtreecommitdiff
path: root/vcl/win
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-10-13 13:43:29 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-10-13 16:21:15 +0200
commitba42683fada2abafa18a49cd50ce8298b92851c8 (patch)
treeb8031e465c03b034a0b8e4bc757ce323b0ff819f /vcl/win
parent17f5c8ef18202355189f8b1b11f67b4e106fd31e (diff)
tdf#120326: properly prevent Windows from entering power saving
The previous call to SystemParametersInfoW with SPI_SETSCREENSAVEACTIVE only prevented screen saver from running (which is not often used these days), but screen was still turned off (and power saving was started). Despite SetThreadExecutionState documentation [1] claims that it does not stop the screen saver from executing, my experiments show that it does (on my Windows 10). So just use it, because it is designed exactly for this task (documentation discusses the presentation applications). [1] https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate Change-Id: I6eced8f0a7c17211a0b68851a40227eed9a22b1a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141289 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl/win')
-rw-r--r--vcl/win/app/salinst.cxx1
-rw-r--r--vcl/win/window/salframe.cxx13
2 files changed, 4 insertions, 10 deletions
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 24c4c508fe9a..56773808fea5 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -291,7 +291,6 @@ SalData::SalData()
mbObjClassInit = false; // is SALOBJECTCLASS initialised
mbInPalChange = false; // is in WM_QUERYNEWPALETTE
mnAppThreadId = 0; // Id from Application-Thread
- mbScrSvrEnabled = FALSE; // ScreenSaver enabled
mpFirstIcon = nullptr; // icon cache, points to first icon, NULL if none
mpSharedTempFontItem = nullptr;
mpOtherTempFontItem = nullptr;
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index d2d2f697aeb3..9871eba67edd 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -1887,20 +1887,15 @@ void WinSalFrame::StartPresentation( bool bStart )
mbPresentation = bStart;
- SalData* pSalData = GetSalData();
if ( bStart )
{
- // turn off screen-saver when in Presentation mode
- SystemParametersInfoW( SPI_GETSCREENSAVEACTIVE, 0,
- &(pSalData->mbScrSvrEnabled), 0 );
- if ( pSalData->mbScrSvrEnabled )
- SystemParametersInfoW( SPI_SETSCREENSAVEACTIVE, FALSE, nullptr, 0 );
+ // turn off screen-saver / power saving when in Presentation mode
+ SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
}
else
{
- // turn on screen-saver
- if ( pSalData->mbScrSvrEnabled )
- SystemParametersInfoW( SPI_SETSCREENSAVEACTIVE, pSalData->mbScrSvrEnabled, nullptr, 0 );
+ // turn on screen-saver / power saving back
+ SetThreadExecutionState(ES_CONTINUOUS);
}
}