From 125e81c92e50e44d89ffdf143969c9c53ba6ebb2 Mon Sep 17 00:00:00 2001 From: crs Date: Tue, 25 Mar 2003 21:31:39 +0000 Subject: [PATCH] This should fix multimon support on win32. --- lib/platform/CMSWindowsSecondaryScreen.cpp | 11 +++++++---- lib/platform/CSynergyHook.cpp | 18 ++++-------------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/lib/platform/CMSWindowsSecondaryScreen.cpp b/lib/platform/CMSWindowsSecondaryScreen.cpp index 9f335e54..16e7fe9b 100644 --- a/lib/platform/CMSWindowsSecondaryScreen.cpp +++ b/lib/platform/CMSWindowsSecondaryScreen.cpp @@ -383,11 +383,14 @@ CMSWindowsSecondaryScreen::warpCursor(SInt32 x, SInt32 y) // move the mouse directly to target position if motion is simple if (simple) { - SInt32 x0, y0, w, h; - m_screen->getShape(x0, y0, w, h); + // when using absolute positioning with mouse_event(), + // the normalized device coordinates range over only + // the primary screen. + SInt32 w = GetSystemMetrics(SM_CXSCREEN); + SInt32 h = GetSystemMetrics(SM_CYSCREEN); mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, - (DWORD)((65535.99 * (x - x0)) / (w - 1)), - (DWORD)((65535.99 * (y - y0)) / (h - 1)), + (DWORD)((65536.0 * x) / w), + (DWORD)((65536.0 * y) / h), 0, 0); } diff --git a/lib/platform/CSynergyHook.cpp b/lib/platform/CSynergyHook.cpp index e0530137..079b8e30 100644 --- a/lib/platform/CSynergyHook.cpp +++ b/lib/platform/CSynergyHook.cpp @@ -217,12 +217,9 @@ mouseHook(int code, WPARAM wParam, LPARAM lParam) hideCursor(thread); } - // get position. it seems the positions are not - // in virtual desktop coordinates but in a similar - // space with 0,0 at the upper-left. translate - // into virtual desktop coordinates. - SInt32 x = (SInt32)info->pt.x + g_xScreen; - SInt32 y = (SInt32)info->pt.y + g_yScreen; + // get position + SInt32 x = (SInt32)info->pt.x; + SInt32 y = (SInt32)info->pt.y; // relay the motion PostThreadMessage(g_threadID, SYNERGY_MSG_MOUSE_MOVE, x, y); @@ -231,10 +228,7 @@ mouseHook(int code, WPARAM wParam, LPARAM lParam) } } else { - // check for mouse inside jump zone. it seems the positions - // are not in virtual desktop coordinates but in a similar - // space with 0,0 at the upper-left. translate into virtual - // desktop coordinates. + // check for mouse inside jump zone bool inside = false; const MOUSEHOOKSTRUCT* info = (const MOUSEHOOKSTRUCT*)lParam; SInt32 x = (SInt32)info->pt.x; @@ -254,15 +248,11 @@ mouseHook(int code, WPARAM wParam, LPARAM lParam) // if inside then eat event and notify our window if (inside) { - x += g_xScreen; - y += g_yScreen; restoreCursor(); PostThreadMessage(g_threadID, SYNERGY_MSG_MOUSE_MOVE, x, y); return 1; } else { - x += g_xScreen; - y += g_yScreen; PostThreadMessage(g_threadID, SYNERGY_MSG_MOUSE_MOVE, x, y); return 0; }