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:
@@ -29,6 +29,7 @@ extern ILibQueue gPendingPackets;
|
|||||||
extern int gRemoteMouseRenderDefault;
|
extern int gRemoteMouseRenderDefault;
|
||||||
extern int gRemoteMouseMoved;
|
extern int gRemoteMouseMoved;
|
||||||
uint64_t gMouseInputTime = 0;
|
uint64_t gMouseInputTime = 0;
|
||||||
|
int gCurrentCursor = KVM_MouseCursor_HELP;
|
||||||
|
|
||||||
HWINEVENTHOOK CUR_HOOK = NULL;
|
HWINEVENTHOOK CUR_HOOK = NULL;
|
||||||
WNDCLASSEXA CUR_WNDCLASS;
|
WNDCLASSEXA CUR_WNDCLASS;
|
||||||
@@ -194,7 +195,6 @@ void CALLBACK KVMWinEventProc(
|
|||||||
{
|
{
|
||||||
char *buffer;
|
char *buffer;
|
||||||
CURSORINFO info = { 0 };
|
CURSORINFO info = { 0 };
|
||||||
int i;
|
|
||||||
|
|
||||||
if (hwnd == NULL && idObject == OBJID_CURSOR)
|
if (hwnd == NULL && idObject == OBJID_CURSOR)
|
||||||
{
|
{
|
||||||
@@ -219,12 +219,12 @@ void CALLBACK KVMWinEventProc(
|
|||||||
// Mouse Cursor has changed
|
// Mouse Cursor has changed
|
||||||
info.cbSize = sizeof(info);
|
info.cbSize = sizeof(info);
|
||||||
GetCursorInfo(&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);
|
buffer = (char*)ILibMemory_SmartAllocate(5);
|
||||||
((unsigned short*)buffer)[0] = (unsigned short)htons((unsigned short)MNG_KVM_MOUSE_CURSOR); // Write the type
|
((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
|
((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);
|
QueueUserAPC((PAPCFUNC)KVM_APCSink, CUR_APCTHREAD, (ULONG_PTR)buffer);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ limitations under the License.
|
|||||||
|
|
||||||
typedef enum KVM_MouseCursors
|
typedef enum KVM_MouseCursors
|
||||||
{
|
{
|
||||||
|
KVM_MouseCursor_NONE = 255,
|
||||||
KVM_MouseCursor_NOCHANGE = -1,
|
KVM_MouseCursor_NOCHANGE = -1,
|
||||||
KVM_MouseCursor_ARROW = 0,
|
KVM_MouseCursor_ARROW = 0,
|
||||||
KVM_MouseCursor_APPSTARTING = 1,
|
KVM_MouseCursor_APPSTARTING = 1,
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ ILibProcessPipe_SpawnTypes gProcessSpawnType = ILibProcessPipe_SpawnTypes_USER;
|
|||||||
int gProcessTSID = -1;
|
int gProcessTSID = -1;
|
||||||
extern int gRemoteMouseRenderDefault;
|
extern int gRemoteMouseRenderDefault;
|
||||||
int gRemoteMouseMoved = 0;
|
int gRemoteMouseMoved = 0;
|
||||||
|
extern int gCurrentCursor;
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
typedef struct KVMDebugLog
|
typedef struct KVMDebugLog
|
||||||
@@ -819,7 +820,8 @@ DWORD WINAPI kvm_server_mainloop_ex(LPVOID parm)
|
|||||||
void *reserved = ((void**)parm)[1];
|
void *reserved = ((void**)parm)[1];
|
||||||
char *tmoBuffer;
|
char *tmoBuffer;
|
||||||
long mouseMove[3] = { 0,0,0 };
|
long mouseMove[3] = { 0,0,0 };
|
||||||
|
int sentHideCursor = 0;
|
||||||
|
|
||||||
gPendingPackets = ILibQueue_Create();
|
gPendingPackets = ILibQueue_Create();
|
||||||
KVM_InitMouseCursors();
|
KVM_InitMouseCursors();
|
||||||
|
|
||||||
@@ -935,7 +937,10 @@ DWORD WINAPI kvm_server_mainloop_ex(LPVOID parm)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
writeHandler(tmoBuffer, (int)ILibMemory_Size(tmoBuffer), reserved);
|
if (ntohs(((unsigned short*)tmoBuffer)[0]) != MNG_KVM_MOUSE_CURSOR || sentHideCursor==0)
|
||||||
|
{
|
||||||
|
writeHandler(tmoBuffer, (int)ILibMemory_Size(tmoBuffer), reserved);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ILibMemory_Free(tmoBuffer);
|
ILibMemory_Free(tmoBuffer);
|
||||||
}
|
}
|
||||||
@@ -957,6 +962,30 @@ DWORD WINAPI kvm_server_mainloop_ex(LPVOID parm)
|
|||||||
mouseMove[2] = info.ptScreenPos.y - SCREEN_Y;
|
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
|
// Scan the desktop
|
||||||
if (get_desktop_buffer(&desktop, &desktopsize, mouseMove) == 1 || desktop == NULL)
|
if (get_desktop_buffer(&desktop, &desktopsize, mouseMove) == 1 || desktop == NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user