mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 06:47:19 +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:
parent
cc2104c699
commit
8e98f863b6
@ -23,10 +23,11 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
#define KVMFR_MAGIC "KVMFR---"
|
#define KVMFR_MAGIC "KVMFR---"
|
||||||
#define KVMFR_VERSION 8
|
#define KVMFR_VERSION 9
|
||||||
|
|
||||||
#define LGMP_Q_POINTER 1
|
#define LGMP_Q_POINTER 1
|
||||||
#define LGMP_Q_FRAME 2
|
#define LGMP_Q_FRAME 2
|
||||||
@ -73,6 +74,7 @@ typedef struct KVMFRFrame
|
|||||||
uint32_t pitch; // the row pitch (stride in bytes or the compressed frame size)
|
uint32_t pitch; // the row pitch (stride in bytes or the compressed frame size)
|
||||||
uint32_t offset; // offset from the start of this header to the FrameBuffer header
|
uint32_t offset; // offset from the start of this header to the FrameBuffer header
|
||||||
uint32_t mouseScalePercent; // movement scale factor of the mouse (relates to DPI of display, 100 = no scale)
|
uint32_t mouseScalePercent; // movement scale factor of the mouse (relates to DPI of display, 100 = no scale)
|
||||||
|
bool blockScreensaver; // whether the guest has requested to block screensavers
|
||||||
}
|
}
|
||||||
KVMFRFrame;
|
KVMFRFrame;
|
||||||
|
|
||||||
|
@ -38,3 +38,5 @@ void app_quit();
|
|||||||
// these must be implemented for each OS
|
// these must be implemented for each OS
|
||||||
const char * os_getExecutable();
|
const char * os_getExecutable();
|
||||||
const char * os_getDataPath();
|
const char * os_getDataPath();
|
||||||
|
|
||||||
|
bool os_blockScreensaver();
|
||||||
|
@ -72,3 +72,8 @@ const char * os_getDataPath(void)
|
|||||||
{
|
{
|
||||||
return app.dataPath;
|
return app.dataPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool os_blockScreensaver()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -33,6 +33,7 @@ target_link_libraries(platform_Windows
|
|||||||
wtsapi32
|
wtsapi32
|
||||||
psapi
|
psapi
|
||||||
shlwapi
|
shlwapi
|
||||||
|
powrprof
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(platform_Windows
|
target_include_directories(platform_Windows
|
||||||
|
@ -25,6 +25,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
#include <shlwapi.h>
|
#include <shlwapi.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <powrprof.h>
|
||||||
|
#include <ntstatus.h>
|
||||||
|
|
||||||
#include "interface/platform.h"
|
#include "interface/platform.h"
|
||||||
#include "common/debug.h"
|
#include "common/debug.h"
|
||||||
@ -397,3 +399,24 @@ HWND os_getMessageWnd(void)
|
|||||||
{
|
{
|
||||||
return app.messageWnd;
|
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;
|
||||||
|
}
|
||||||
|
@ -206,6 +206,7 @@ static int frameThread(void * opaque)
|
|||||||
fi->pitch = frame.pitch;
|
fi->pitch = frame.pitch;
|
||||||
fi->offset = pageSize - FrameBufferStructSize;
|
fi->offset = pageSize - FrameBufferStructSize;
|
||||||
fi->mouseScalePercent = app.iface->getMouseScale();
|
fi->mouseScalePercent = app.iface->getMouseScale();
|
||||||
|
fi->blockScreensaver = os_blockScreensaver();
|
||||||
frameValid = true;
|
frameValid = true;
|
||||||
|
|
||||||
// put the framebuffer on the border of the next page
|
// put the framebuffer on the border of the next page
|
||||||
|
Loading…
Reference in New Issue
Block a user