[host] windows: plumb guest activation request to host

This commit is contained in:
Tudor Brindus 2022-02-06 22:39:42 -05:00 committed by Geoffrey McRae
parent fd28d0604e
commit 809e1095bd
5 changed files with 29 additions and 2 deletions

View file

@ -28,7 +28,7 @@
#include "types.h" #include "types.h"
#define KVMFR_MAGIC "KVMFR---" #define KVMFR_MAGIC "KVMFR---"
#define KVMFR_VERSION 16 #define KVMFR_VERSION 17
#define KVMFR_MAX_DAMAGE_RECTS 64 #define KVMFR_MAX_DAMAGE_RECTS 64

View file

@ -44,6 +44,7 @@ const char * os_getExecutable();
const char * os_getDataPath(); const char * os_getDataPath();
void os_showMessage(const char * caption, const char * msg); void os_showMessage(const char * caption, const char * msg);
bool os_getAndClearPendingActivationRequest(void);
bool os_blockScreensaver(); bool os_blockScreensaver();
bool os_hasSetCursorPos(void); bool os_hasSetCursorPos(void);
void os_setCursorPos(int x, int y); void os_setCursorPos(int x, int y);

View file

@ -81,6 +81,12 @@ const char * os_getDataPath(void)
return app.dataPath; return app.dataPath;
} }
bool os_getAndClearPendingActivationRequest(void)
{
// TODO
return false;
}
bool os_blockScreensaver() bool os_blockScreensaver()
{ {
return false; return false;

View file

@ -59,11 +59,14 @@ struct AppState
char systemLogDir[MAX_PATH]; char systemLogDir[MAX_PATH];
char * osVersion; char * osVersion;
HWND messageWnd; HWND messageWnd;
UINT shellHookMsg;
NOTIFYICONDATA iconData; NOTIFYICONDATA iconData;
UINT trayRestartMsg; UINT trayRestartMsg;
HMENU trayMenu; HMENU trayMenu;
HANDLE exitWait; HANDLE exitWait;
HANDLE taskHandle; HANDLE taskHandle;
_Atomic(bool) hasPendingActivationRequest;
}; };
static struct AppState app = {0}; static struct AppState app = {0};
@ -254,6 +257,14 @@ LRESULT CALLBACK DummyWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
default: default:
if (msg == app.trayRestartMsg) if (msg == app.trayRestartMsg)
RegisterTrayIcon(); RegisterTrayIcon();
else if (msg == app.shellHookMsg)
{
switch (LOWORD(wParam))
{
case HSHELL_FLASH:
atomic_store(&app.hasPendingActivationRequest, true);
}
}
break; break;
} }
@ -403,6 +414,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
// set the global // set the global
MessageHWND = app.messageWnd; MessageHWND = app.messageWnd;
// get shell events (e.g., for activation requests)
app.shellHookMsg = RegisterWindowMessage(TEXT("SHELLHOOK"));
RegisterShellHookWindow(app.messageWnd);
app.trayMenu = CreatePopupMenu(); app.trayMenu = CreatePopupMenu();
AppendMenu(app.trayMenu, MF_STRING , ID_MENU_SHOW_LOG, "Open Log File"); AppendMenu(app.trayMenu, MF_STRING , ID_MENU_SHOW_LOG, "Open Log File");
AppendMenu(app.trayMenu, MF_SEPARATOR, 0 , NULL ); AppendMenu(app.trayMenu, MF_SEPARATOR, 0 , NULL );
@ -573,6 +588,11 @@ HWND os_getMessageWnd(void)
return app.messageWnd; return app.messageWnd;
} }
bool os_getAndClearPendingActivationRequest(void)
{
return atomic_exchange(&app.hasPendingActivationRequest, false);
}
bool os_blockScreensaver() bool os_blockScreensaver()
{ {
static bool lastResult = false; static bool lastResult = false;

View file

@ -276,7 +276,7 @@ static bool sendFrame(void)
fi->pitch = frame.pitch; fi->pitch = frame.pitch;
fi->offset = app.pageSize - FrameBufferStructSize; fi->offset = app.pageSize - FrameBufferStructSize;
fi->blockScreensaver = os_blockScreensaver(); fi->blockScreensaver = os_blockScreensaver();
fi->requestActivation = true; // TODO fi->requestActivation = os_getAndClearPendingActivationRequest();
app.frameValid = true; app.frameValid = true;
fi->damageRectsCount = frame.damageRectsCount; fi->damageRectsCount = frame.damageRectsCount;