From 9f5df396e8e9737c67bef1f49c36937656726406 Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Tue, 3 Mar 2020 13:57:07 -0800 Subject: [PATCH] Updated Windows KVM Cursor rendering, to always remote render the cursor, if the remote user was not the one that last moved the mouse. --- meshcore/KVM/Windows/input.c | 2 ++ meshcore/KVM/Windows/kvm.c | 20 ++++++++++++++++++++ meshcore/agentcore.h | 1 + 3 files changed, 23 insertions(+) diff --git a/meshcore/KVM/Windows/input.c b/meshcore/KVM/Windows/input.c index 324b983..0d2715d 100644 --- a/meshcore/KVM/Windows/input.c +++ b/meshcore/KVM/Windows/input.c @@ -27,6 +27,7 @@ limitations under the License. extern void ILibAppendStringToDiskEx(char *FileName, char *data, int dataLen); extern ILibQueue gPendingPackets; extern int gRemoteMouseRenderDefault; +extern int gRemoteMouseMoved; uint64_t gMouseInputTime = 0; HWINEVENTHOOK CUR_HOOK = NULL; @@ -179,6 +180,7 @@ int KVM_GetCursorHash(HCURSOR hc, char *buffer, size_t bufferLen) void __stdcall KVM_APCSink(ULONG_PTR user) { + if (ntohs(((unsigned short*)user)[0]) == MNG_KVM_MOUSE_MOVE) { gRemoteMouseMoved = 0; } ILibQueue_EnQueue(gPendingPackets, (char*)user); } void CALLBACK KVMWinEventProc( diff --git a/meshcore/KVM/Windows/kvm.c b/meshcore/KVM/Windows/kvm.c index 64ef86f..0072634 100644 --- a/meshcore/KVM/Windows/kvm.c +++ b/meshcore/KVM/Windows/kvm.c @@ -39,6 +39,7 @@ limitations under the License. ILibProcessPipe_SpawnTypes gProcessSpawnType = ILibProcessPipe_SpawnTypes_USER; int gProcessTSID = -1; extern int gRemoteMouseRenderDefault; +int gRemoteMouseMoved = 0; #pragma pack(push, 1) typedef struct KVMDebugLog @@ -498,6 +499,8 @@ int kvm_server_inputdata(char* block, int blocklen, ILibKVM_WriteHandler writeHa if (size == 10 || size == 12) { + gRemoteMouseMoved = 1; + // Get positions and scale correctly x = (double)ntohs(((short*)(block))[3]) * 1024 / SCALING_FACTOR; y = (double)ntohs(((short*)(block))[4]) * 1024 / SCALING_FACTOR; @@ -936,7 +939,24 @@ DWORD WINAPI kvm_server_mainloop_ex(LPVOID parm) } ILibMemory_Free(tmoBuffer); } + if (mouseMove[0] == 0 && (gRemoteMouseRenderDefault != 0 || gRemoteMouseMoved == 0)) + { + mouseMove[0] = 1; + CURSORINFO info = { 0 }; + info.cbSize = sizeof(info); + GetCursorInfo(&info); + if (SCREEN_SEL_TARGET == 0) + { + mouseMove[1] = info.ptScreenPos.x - VSCREEN_X; + mouseMove[2] = info.ptScreenPos.y - VSCREEN_Y; + } + else + { + mouseMove[1] = info.ptScreenPos.x - SCREEN_X; + mouseMove[2] = info.ptScreenPos.y - SCREEN_Y; + } + } // Scan the desktop if (get_desktop_buffer(&desktop, &desktopsize, mouseMove) == 1 || desktop == NULL) diff --git a/meshcore/agentcore.h b/meshcore/agentcore.h index 0a70da2..4aae25a 100644 --- a/meshcore/agentcore.h +++ b/meshcore/agentcore.h @@ -260,6 +260,7 @@ forceUpdate: If set, will cause the agent to perform a self-update on next st ignoreProxyFile: If set, will cause the agent to ignore any proxy settings logUpdate: If set, will cause the agent to log self-update status jsDebugPort: Specify a JS Debugger Port +remoteMouseRender: If set, will always render the remote mouse cursor for KVM showModuleNames: If set, will display the name of modules when they are loaded for the first time slaveKvmLog: [Linux] If set, will enable logging inside the Child KVM Process. WebProxy: Manually specify proxy configuration