1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-27 21:53:20 +00:00

Fixed Windows KVM bug when you have multiple displays with differing DPI settings

This commit is contained in:
Bryan Roe
2019-04-24 13:01:31 -07:00
parent b5d2d39860
commit bc3e970b5c
6 changed files with 82 additions and 63 deletions

View File

@@ -131,64 +131,6 @@ void kvm_slave_OnRawForwardLog(ILibRemoteLogging sender, ILibRemoteLogging_Modul
}
#endif
void kvm_inspect_displays(RECT* r, int rLen)
{
MONITORINFOEX minfo;
HMONITOR hmon;
POINT p;
int deviceid;
int vx = GetSystemMetrics(SM_XVIRTUALSCREEN);
int vy = GetSystemMetrics(SM_YVIRTUALSCREEN);
int vw = GetSystemMetrics(SM_CXVIRTUALSCREEN);
int vh = GetSystemMetrics(SM_CYVIRTUALSCREEN);
memset(r, 0, sizeof(RECT)*rLen);
for (p.y = vy; p.y < (vy + vh); ++p.y)
{
for (p.x = vx; p.x < (vx + vw); ++p.x)
{
hmon = MonitorFromPoint(p, MONITOR_DEFAULTTONULL);
if (hmon != NULL)
{
memset(&minfo, 0, sizeof(minfo));
minfo.cbSize = sizeof(minfo);
GetMonitorInfoA(hmon, &minfo);
sscanf_s(minfo.szDevice, "\\\\.\\DISPLAY%d", &deviceid);
if (r[deviceid].left == r[deviceid].right)
{
// Not set yet
r[deviceid].left = p.x;
r[deviceid].right = p.x - 1;
}
else if (r[deviceid].right < p.x)
{
// Determining Width
r[deviceid].right = p.x;
}
else
{
// Already determined width, so we can FFWD
p.x = r[deviceid].right;
}
if (r[deviceid].top == r[deviceid].bottom)
{
// Not set yet
r[deviceid].top = p.y;
r[deviceid].bottom = p.y - 1;
}
else if (r[deviceid].bottom < p.y)
{
// Determining Heigth
r[deviceid].bottom = p.y;
}
}
}
}
}
void kvm_setupSasPermissions()
{
DWORD dw = 3;
@@ -844,6 +786,7 @@ DWORD WINAPI kvm_server_mainloop(LPVOID parm)
ILibKVM_WriteHandler writeHandler = (ILibKVM_WriteHandler)((void**)parm)[0];
void *reserved = ((void**)parm)[1];
#ifdef _WINSERVICE
if (!kvmConsoleMode)
{