From 1758ea6f9f5e3ceef70e59b4c28aaffd7acc38f0 Mon Sep 17 00:00:00 2001 From: crs Date: Sat, 11 Jan 2003 14:01:44 +0000 Subject: [PATCH] Attempt to fix problems with multimon windows. The mouse position reported by the synergy hook dll is in a space with 0,0 in the upper-left which is not necessarily the same as the virtual desktop space. So the windows primary screen now accounts for that. On the secondary screen, mouse_event() doesn't seem to accept negative coordinates even on the windows NT family, making monitors with negative coordinates inaccessible via absolute moves. So if the move will be to negative coordinates, use the windows 95 family fallback of absolute moving to 0,0 then relative moving to the final position. --- lib/platform/CMSWindowsPrimaryScreen.cpp | 9 ++++++++- lib/platform/CMSWindowsSecondaryScreen.cpp | 23 +++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lib/platform/CMSWindowsPrimaryScreen.cpp b/lib/platform/CMSWindowsPrimaryScreen.cpp index a955f882..990120d4 100644 --- a/lib/platform/CMSWindowsPrimaryScreen.cpp +++ b/lib/platform/CMSWindowsPrimaryScreen.cpp @@ -310,8 +310,15 @@ CMSWindowsPrimaryScreen::onPreDispatch(const CEvent* event) m_y = static_cast(msg->lParam); if (!isActive()) { + // shift by origin of virtual screen. the synergy + // hook DLL does not account for + SInt32 w, h; + m_screen->getShape(x, y, w, h); + x += m_x; + y += m_y; + // motion on primary screen - m_receiver->onMouseMovePrimary(m_x, m_y); + m_receiver->onMouseMovePrimary(x, y); } else { // motion on secondary screen. warp mouse back to diff --git a/lib/platform/CMSWindowsSecondaryScreen.cpp b/lib/platform/CMSWindowsSecondaryScreen.cpp index 7f858323..e680b9ba 100644 --- a/lib/platform/CMSWindowsSecondaryScreen.cpp +++ b/lib/platform/CMSWindowsSecondaryScreen.cpp @@ -354,9 +354,30 @@ CMSWindowsSecondaryScreen::warpCursor(SInt32 x, SInt32 y) static bool gotSendInput = false; static SendInput_t SendInput = NULL; + // motion is simple (i.e. it's on the primary monitor) if there + // is only one monitor. + bool simple = !m_screen->isMultimon(); + if (!simple) { + // also simple if motion is within the primary monitor + simple = (x >= 0 && x < GetSystemMetrics(SM_CXSCREEN) && + y >= 0 && y < GetSystemMetrics(SM_CYSCREEN)); + if (!simple && !m_is95Family) { + // also simple if not on windows 95 family since the + // NT family mouse_event() allows absolute moves to + // any monitor. + // + // note -- this is possibly untrue if the primary + // monitor isn't upper-left most so limit it to that + // situation. + SInt32 x0, y0, w, h; + m_screen->getShape(x0, y0, w, h); + simple = (x0 == 0 && y0 == 0); + } + } + // move the mouse directly to target position on NT family or if // not using multiple monitors. - if (!m_screen->isMultimon() || !m_is95Family) { + if (simple) { SInt32 x0, y0, w, h; m_screen->getShape(x0, y0, w, h); mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE,