Fixed stupid errors introduced by last attempt to fix broken
mouse behavior on multimonitor windows systems. Those errors broke synergy on all windows systems running as a server. Also added an attempt to reduce the occasional jump that can occur when switching screens when windows is the server.
This commit is contained in:
parent
68a591210b
commit
e86e552ac8
|
@ -46,6 +46,9 @@ CArchSleepWindows::sleep(double timeout)
|
||||||
if (mt != NULL) {
|
if (mt != NULL) {
|
||||||
HANDLE cancelEvent = mt->getCancelEventForCurrentThread();
|
HANDLE cancelEvent = mt->getCancelEventForCurrentThread();
|
||||||
WaitForSingleObject(cancelEvent, (DWORD)(1000.0 * timeout));
|
WaitForSingleObject(cancelEvent, (DWORD)(1000.0 * timeout));
|
||||||
|
if (timeout == 0.0) {
|
||||||
|
Sleep(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Sleep((DWORD)(1000.0 * timeout));
|
Sleep((DWORD)(1000.0 * timeout));
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "IPrimaryScreenReceiver.h"
|
#include "IPrimaryScreenReceiver.h"
|
||||||
#include "XScreen.h"
|
#include "XScreen.h"
|
||||||
#include "CLog.h"
|
#include "CLog.h"
|
||||||
|
#include "CArch.h"
|
||||||
#include "CArchMiscWindows.h"
|
#include "CArchMiscWindows.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
@ -311,7 +312,7 @@ CMSWindowsPrimaryScreen::onPreDispatch(const CEvent* event)
|
||||||
|
|
||||||
if (!isActive()) {
|
if (!isActive()) {
|
||||||
// motion on primary screen
|
// motion on primary screen
|
||||||
m_receiver->onMouseMovePrimary(x, y);
|
m_receiver->onMouseMovePrimary(m_x, m_y);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// motion on secondary screen. warp mouse back to
|
// motion on secondary screen. warp mouse back to
|
||||||
|
@ -641,6 +642,22 @@ CMSWindowsPrimaryScreen::warpCursorNoFlush(SInt32 x, SInt32 y)
|
||||||
// between the previous message and the following message.
|
// between the previous message and the following message.
|
||||||
SetCursorPos(x, y);
|
SetCursorPos(x, y);
|
||||||
|
|
||||||
|
// yield the CPU. there's a race condition when warping:
|
||||||
|
// a hardware mouse event occurs
|
||||||
|
// the mouse hook is not called because that process doesn't have the CPU
|
||||||
|
// we send PRE_WARP, SetCursorPos(), send POST_WARP
|
||||||
|
// we process all of those events and update m_x, m_y
|
||||||
|
// we finish our time slice
|
||||||
|
// the hook is called
|
||||||
|
// the hook sends us a mouse event from the pre-warp position
|
||||||
|
// we get the CPU
|
||||||
|
// we compute a bogus warp
|
||||||
|
// we need the hook to process all mouse events that occur
|
||||||
|
// before we warp before we do the warp but i'm not sure how
|
||||||
|
// to guarantee that. yielding the CPU here may reduce the
|
||||||
|
// chance of undesired behavior.
|
||||||
|
ARCH->sleep(0.0);
|
||||||
|
|
||||||
// send an event that we can recognize after the mouse warp
|
// send an event that we can recognize after the mouse warp
|
||||||
PostThreadMessage(m_threadID, SYNERGY_MSG_POST_WARP, 0, 0);
|
PostThreadMessage(m_threadID, SYNERGY_MSG_POST_WARP, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,8 +229,8 @@ mouseHook(int code, WPARAM wParam, LPARAM lParam)
|
||||||
// desktop coordinates.
|
// 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 + g_xScreen;
|
SInt32 x = (SInt32)info->pt.x;
|
||||||
SInt32 y = (SInt32)info->pt.y + g_yScreen;
|
SInt32 y = (SInt32)info->pt.y;
|
||||||
if (!inside && (g_zoneSides & kLeftMask) != 0) {
|
if (!inside && (g_zoneSides & kLeftMask) != 0) {
|
||||||
inside = (x < g_xScreen + g_zoneSize);
|
inside = (x < g_xScreen + g_zoneSize);
|
||||||
}
|
}
|
||||||
|
@ -246,6 +246,8 @@ 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;
|
||||||
|
|
Loading…
Reference in New Issue