diff --git a/common/include/common/KVMFR.h b/common/include/common/KVMFR.h index 6d8847ae..7564720e 100644 --- a/common/include/common/KVMFR.h +++ b/common/include/common/KVMFR.h @@ -28,7 +28,7 @@ #include "types.h" #define KVMFR_MAGIC "KVMFR---" -#define KVMFR_VERSION 16 +#define KVMFR_VERSION 17 #define KVMFR_MAX_DAMAGE_RECTS 64 diff --git a/host/include/interface/platform.h b/host/include/interface/platform.h index c529a9b5..23fe215f 100644 --- a/host/include/interface/platform.h +++ b/host/include/interface/platform.h @@ -44,6 +44,7 @@ const char * os_getExecutable(); const char * os_getDataPath(); void os_showMessage(const char * caption, const char * msg); +bool os_getAndClearPendingActivationRequest(void); bool os_blockScreensaver(); bool os_hasSetCursorPos(void); void os_setCursorPos(int x, int y); diff --git a/host/platform/Linux/src/platform.c b/host/platform/Linux/src/platform.c index 11051816..83fb4f89 100644 --- a/host/platform/Linux/src/platform.c +++ b/host/platform/Linux/src/platform.c @@ -81,6 +81,12 @@ const char * os_getDataPath(void) return app.dataPath; } +bool os_getAndClearPendingActivationRequest(void) +{ + // TODO + return false; +} + bool os_blockScreensaver() { return false; diff --git a/host/platform/Windows/src/platform.c b/host/platform/Windows/src/platform.c index e40c7959..adc4a90b 100644 --- a/host/platform/Windows/src/platform.c +++ b/host/platform/Windows/src/platform.c @@ -59,11 +59,14 @@ struct AppState char systemLogDir[MAX_PATH]; char * osVersion; HWND messageWnd; + UINT shellHookMsg; NOTIFYICONDATA iconData; UINT trayRestartMsg; HMENU trayMenu; HANDLE exitWait; HANDLE taskHandle; + + _Atomic(bool) hasPendingActivationRequest; }; static struct AppState app = {0}; @@ -254,6 +257,14 @@ LRESULT CALLBACK DummyWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) default: if (msg == app.trayRestartMsg) RegisterTrayIcon(); + else if (msg == app.shellHookMsg) + { + switch (LOWORD(wParam)) + { + case HSHELL_FLASH: + atomic_store(&app.hasPendingActivationRequest, true); + } + } break; } @@ -403,6 +414,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine // set the global MessageHWND = app.messageWnd; + // get shell events (e.g., for activation requests) + app.shellHookMsg = RegisterWindowMessage(TEXT("SHELLHOOK")); + RegisterShellHookWindow(app.messageWnd); + app.trayMenu = CreatePopupMenu(); AppendMenu(app.trayMenu, MF_STRING , ID_MENU_SHOW_LOG, "Open Log File"); AppendMenu(app.trayMenu, MF_SEPARATOR, 0 , NULL ); @@ -573,6 +588,11 @@ HWND os_getMessageWnd(void) return app.messageWnd; } +bool os_getAndClearPendingActivationRequest(void) +{ + return atomic_exchange(&app.hasPendingActivationRequest, false); +} + bool os_blockScreensaver() { static bool lastResult = false; diff --git a/host/src/app.c b/host/src/app.c index 2f8fc02d..6695323b 100644 --- a/host/src/app.c +++ b/host/src/app.c @@ -276,7 +276,7 @@ static bool sendFrame(void) fi->pitch = frame.pitch; fi->offset = app.pageSize - FrameBufferStructSize; fi->blockScreensaver = os_blockScreensaver(); - fi->requestActivation = true; // TODO + fi->requestActivation = os_getAndClearPendingActivationRequest(); app.frameValid = true; fi->damageRectsCount = frame.damageRectsCount;