This should fix multimon support on win32.

This commit is contained in:
crs 2003-03-25 21:31:39 +00:00
parent 380369d331
commit 125e81c92e
2 changed files with 11 additions and 18 deletions

View File

@ -383,11 +383,14 @@ CMSWindowsSecondaryScreen::warpCursor(SInt32 x, SInt32 y)
// move the mouse directly to target position if motion is simple // move the mouse directly to target position if motion is simple
if (simple) { if (simple) {
SInt32 x0, y0, w, h; // when using absolute positioning with mouse_event(),
m_screen->getShape(x0, y0, w, h); // 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, mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE,
(DWORD)((65535.99 * (x - x0)) / (w - 1)), (DWORD)((65536.0 * x) / w),
(DWORD)((65535.99 * (y - y0)) / (h - 1)), (DWORD)((65536.0 * y) / h),
0, 0); 0, 0);
} }

View File

@ -217,12 +217,9 @@ mouseHook(int code, WPARAM wParam, LPARAM lParam)
hideCursor(thread); hideCursor(thread);
} }
// get position. it seems the positions are not // get position
// in virtual desktop coordinates but in a similar SInt32 x = (SInt32)info->pt.x;
// space with 0,0 at the upper-left. translate SInt32 y = (SInt32)info->pt.y;
// into virtual desktop coordinates.
SInt32 x = (SInt32)info->pt.x + g_xScreen;
SInt32 y = (SInt32)info->pt.y + g_yScreen;
// relay the motion // relay the motion
PostThreadMessage(g_threadID, SYNERGY_MSG_MOUSE_MOVE, x, y); PostThreadMessage(g_threadID, SYNERGY_MSG_MOUSE_MOVE, x, y);
@ -231,10 +228,7 @@ mouseHook(int code, WPARAM wParam, LPARAM lParam)
} }
} }
else { else {
// check for mouse inside jump zone. it seems the positions // check for mouse inside jump zone
// are not in virtual desktop coordinates but in a similar
// space with 0,0 at the upper-left. translate into virtual
// desktop coordinates.
bool inside = false; bool inside = false;
const MOUSEHOOKSTRUCT* info = (const MOUSEHOOKSTRUCT*)lParam; const MOUSEHOOKSTRUCT* info = (const MOUSEHOOKSTRUCT*)lParam;
SInt32 x = (SInt32)info->pt.x; 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 then eat event and notify our window
if (inside) { if (inside) {
x += g_xScreen;
y += g_yScreen;
restoreCursor(); restoreCursor();
PostThreadMessage(g_threadID, SYNERGY_MSG_MOUSE_MOVE, x, y); PostThreadMessage(g_threadID, SYNERGY_MSG_MOUSE_MOVE, x, y);
return 1; return 1;
} }
else { else {
x += g_xScreen;
y += g_yScreen;
PostThreadMessage(g_threadID, SYNERGY_MSG_MOUSE_MOVE, x, y); PostThreadMessage(g_threadID, SYNERGY_MSG_MOUSE_MOVE, x, y);
return 0; return 0;
} }