mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-08-05 18:24:08 +00:00
[host] windows: detect whether screensaver is disabled in the guest
This will allow us to add an option to disable the screensaver on the client when an application in the guest requests it. This behaviour may be useful when the guest is doing media playback.
This commit is contained in:
@@ -33,6 +33,7 @@ target_link_libraries(platform_Windows
|
||||
wtsapi32
|
||||
psapi
|
||||
shlwapi
|
||||
powrprof
|
||||
)
|
||||
|
||||
target_include_directories(platform_Windows
|
||||
|
@@ -25,6 +25,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#include <shellapi.h>
|
||||
#include <shlwapi.h>
|
||||
#include <fcntl.h>
|
||||
#include <powrprof.h>
|
||||
#include <ntstatus.h>
|
||||
|
||||
#include "interface/platform.h"
|
||||
#include "common/debug.h"
|
||||
@@ -397,3 +399,24 @@ HWND os_getMessageWnd(void)
|
||||
{
|
||||
return app.messageWnd;
|
||||
}
|
||||
|
||||
bool os_blockScreensaver()
|
||||
{
|
||||
static bool lastResult = false;
|
||||
static ULONGLONG lastCheck = 0;
|
||||
|
||||
ULONGLONG now = GetTickCount64();
|
||||
if (now - lastCheck >= 1000)
|
||||
{
|
||||
ULONG executionState;
|
||||
NTSTATUS status = CallNtPowerInformation(SystemExecutionState, NULL, 0,
|
||||
&executionState, sizeof executionState);
|
||||
|
||||
if (status == STATUS_SUCCESS)
|
||||
lastResult = executionState & ES_DISPLAY_REQUIRED;
|
||||
else
|
||||
DEBUG_ERROR("Failed to call CallNtPowerInformation(SystemExecutionState): %ld", status);
|
||||
lastCheck = now;
|
||||
}
|
||||
return lastResult;
|
||||
}
|
||||
|
Reference in New Issue
Block a user