1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-16 00:03:45 +00:00

Updated Windows KVM so when remote cursor is rendered, local cursor is hidden

This commit is contained in:
Bryan Roe
2020-03-05 17:21:34 -08:00
parent d983addf1c
commit ea31471245
3 changed files with 35 additions and 5 deletions

View File

@@ -29,6 +29,7 @@ extern ILibQueue gPendingPackets;
extern int gRemoteMouseRenderDefault;
extern int gRemoteMouseMoved;
uint64_t gMouseInputTime = 0;
int gCurrentCursor = KVM_MouseCursor_HELP;
HWINEVENTHOOK CUR_HOOK = NULL;
WNDCLASSEXA CUR_WNDCLASS;
@@ -194,7 +195,6 @@ void CALLBACK KVMWinEventProc(
{
char *buffer;
CURSORINFO info = { 0 };
int i;
if (hwnd == NULL && idObject == OBJID_CURSOR)
{
@@ -219,12 +219,12 @@ void CALLBACK KVMWinEventProc(
// Mouse Cursor has changed
info.cbSize = sizeof(info);
GetCursorInfo(&info);
i = KVM_CursorHashToMSG(KVM_GetCursorHash(info.hCursor, NULL, 0));
gCurrentCursor = KVM_CursorHashToMSG(KVM_GetCursorHash(info.hCursor, NULL, 0));
buffer = (char*)ILibMemory_SmartAllocate(5);
((unsigned short*)buffer)[0] = (unsigned short)htons((unsigned short)MNG_KVM_MOUSE_CURSOR); // Write the type
((unsigned short*)buffer)[1] = (unsigned short)htons((unsigned short)5); // Write the size
buffer[4] = (char)i; // Cursor Type
buffer[4] = (char)gCurrentCursor; // Cursor Type
QueueUserAPC((PAPCFUNC)KVM_APCSink, CUR_APCTHREAD, (ULONG_PTR)buffer);
break;
default:

View File

@@ -18,6 +18,7 @@ limitations under the License.
typedef enum KVM_MouseCursors
{
KVM_MouseCursor_NONE = 255,
KVM_MouseCursor_NOCHANGE = -1,
KVM_MouseCursor_ARROW = 0,
KVM_MouseCursor_APPSTARTING = 1,

View File

@@ -40,6 +40,7 @@ ILibProcessPipe_SpawnTypes gProcessSpawnType = ILibProcessPipe_SpawnTypes_USER;
int gProcessTSID = -1;
extern int gRemoteMouseRenderDefault;
int gRemoteMouseMoved = 0;
extern int gCurrentCursor;
#pragma pack(push, 1)
typedef struct KVMDebugLog
@@ -819,6 +820,7 @@ DWORD WINAPI kvm_server_mainloop_ex(LPVOID parm)
void *reserved = ((void**)parm)[1];
char *tmoBuffer;
long mouseMove[3] = { 0,0,0 };
int sentHideCursor = 0;
gPendingPackets = ILibQueue_Create();
KVM_InitMouseCursors();
@@ -934,9 +936,12 @@ DWORD WINAPI kvm_server_mainloop_ex(LPVOID parm)
}
}
else
{
if (ntohs(((unsigned short*)tmoBuffer)[0]) != MNG_KVM_MOUSE_CURSOR || sentHideCursor==0)
{
writeHandler(tmoBuffer, (int)ILibMemory_Size(tmoBuffer), reserved);
}
}
ILibMemory_Free(tmoBuffer);
}
if (mouseMove[0] == 0 && (gRemoteMouseRenderDefault != 0 || gRemoteMouseMoved == 0))
@@ -957,6 +962,30 @@ DWORD WINAPI kvm_server_mainloop_ex(LPVOID parm)
mouseMove[2] = info.ptScreenPos.y - SCREEN_Y;
}
}
if (mouseMove[0] != 0)
{
if (sentHideCursor == 0)
{
sentHideCursor = 1;
char tmpBuffer[5];
((unsigned short*)tmpBuffer)[0] = (unsigned short)htons((unsigned short)MNG_KVM_MOUSE_CURSOR); // Write the type
((unsigned short*)tmpBuffer)[1] = (unsigned short)htons((unsigned short)5); // Write the size
tmpBuffer[4] = (char)KVM_MouseCursor_NONE; // Cursor Type
writeHandler(tmpBuffer, 5, reserved);
}
}
else
{
if (sentHideCursor != 0)
{
sentHideCursor = 0;
char tmpBuffer[5];
((unsigned short*)tmpBuffer)[0] = (unsigned short)htons((unsigned short)MNG_KVM_MOUSE_CURSOR); // Write the type
((unsigned short*)tmpBuffer)[1] = (unsigned short)htons((unsigned short)5); // Write the size
tmpBuffer[4] = (char)gCurrentCursor; // Cursor Type
writeHandler(tmpBuffer, 5, reserved);
}
}
// Scan the desktop
if (get_desktop_buffer(&desktop, &desktopsize, mouseMove) == 1 || desktop == NULL)