Added relative mouse move support to win32.

This commit is contained in:
crs 2004-05-02 08:04:15 +00:00
parent 0f45face21
commit 9c35a45a2c
4 changed files with 63 additions and 27 deletions

View File

@ -72,6 +72,8 @@
#define SYNERGY_MSG_SYNC_KEYS SYNERGY_HOOK_LAST_MSG + 9
// install; <unused>
#define SYNERGY_MSG_SCREENSAVER SYNERGY_HOOK_LAST_MSG + 10
// dx; dy
#define SYNERGY_MSG_FAKE_REL_MOVE SYNERGY_HOOK_LAST_MSG + 11
//
// CMSWindowsDesks
@ -293,6 +295,14 @@ CMSWindowsDesks::fakeMouseMove(SInt32 x, SInt32 y) const
static_cast<LPARAM>(y));
}
void
CMSWindowsDesks::fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const
{
sendMessage(SYNERGY_MSG_FAKE_REL_MOVE,
static_cast<WPARAM>(dx),
static_cast<LPARAM>(dy));
}
void
CMSWindowsDesks::fakeMouseWheel(SInt32 delta) const
{
@ -492,16 +502,26 @@ CMSWindowsDesks::deskMouseMove(SInt32 x, SInt32 y) const
// the right place, the effect is disconcerting.
//
// instead we'll get the cursor's current position and do just a
// relative move from there to the desired position. relative
// moves are subject to cursor acceleration which we don't want.
// so we disable acceleration, do the relative move, then restore
// acceleration. there's a slight chance we'll end up in the
// wrong place if the user moves the cursor using this system's
// relative move from there to the desired position.
else {
POINT pos;
GetCursorPos(&pos);
deskMouseRelativeMove(x - pos.x, y - pos.y);
}
}
void
CMSWindowsDesks::deskMouseRelativeMove(SInt32 dx, SInt32 dy) const
{
// relative moves are subject to cursor acceleration which we don't
// want.so we disable acceleration, do the relative move, then
// restore acceleration. there's a slight chance we'll end up in
// the wrong place if the user moves the cursor using this system's
// mouse while simultaneously moving the mouse on the server
// system. that defeats the purpose of synergy so we'll assume
// that won't happen. even if it does, the next mouse move will
// correct the position.
else {
// save mouse speed & acceleration
int oldSpeed[4];
bool accelChanged =
@ -517,9 +537,7 @@ CMSWindowsDesks::deskMouseMove(SInt32 x, SInt32 y) const
}
// move relative to mouse position
POINT pos;
GetCursorPos(&pos);
mouse_event(MOUSEEVENTF_MOVE, x - pos.x, y - pos.y, 0, 0);
mouse_event(MOUSEEVENTF_MOVE, dx, dy, 0, 0);
// restore mouse speed & acceleration
if (accelChanged) {
@ -527,7 +545,6 @@ CMSWindowsDesks::deskMouseMove(SInt32 x, SInt32 y) const
SystemParametersInfo(SPI_SETMOUSESPEED, 0, oldSpeed + 3, 0);
}
}
}
void
CMSWindowsDesks::deskEnter(CDesk* desk)
@ -693,6 +710,11 @@ CMSWindowsDesks::deskThread(void* vdesk)
static_cast<SInt32>(msg.lParam));
break;
case SYNERGY_MSG_FAKE_REL_MOVE:
deskMouseRelativeMove(static_cast<SInt32>(msg.wParam),
static_cast<SInt32>(msg.lParam));
break;
case SYNERGY_MSG_FAKE_WHEEL:
mouse_event(MOUSEEVENTF_WHEEL, 0, 0, msg.wParam, 0);
break;

View File

@ -144,6 +144,12 @@ public:
*/
void fakeMouseMove(SInt32 x, SInt32 y) const;
//! Fake mouse move
/*!
Synthesize a mouse move to the relative coordinates \c dx,dy.
*/
void fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const;
//! Fake mouse wheel
/*!
Synthesize a mouse wheel event of amount \c delta.
@ -176,6 +182,7 @@ private:
// message handlers
void deskMouseMove(SInt32 x, SInt32 y) const;
void deskMouseRelativeMove(SInt32 dx, SInt32 dy) const;
void deskEnter(CDesk* desk);
void deskLeave(CDesk* desk, HKL keyLayout);
void deskThread(void* vdesk);

View File

@ -507,6 +507,12 @@ CMSWindowsScreen::fakeMouseMove(SInt32 x, SInt32 y) const
m_desks->fakeMouseMove(x, y);
}
void
CMSWindowsScreen::fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const
{
m_desks->fakeMouseRelativeMove(dx, dy);
}
void
CMSWindowsScreen::fakeMouseWheel(SInt32 delta) const
{

View File

@ -75,6 +75,7 @@ public:
// ISecondaryScreen overrides
virtual void fakeMouseButton(ButtonID id, bool press) const;
virtual void fakeMouseMove(SInt32 x, SInt32 y) const;
virtual void fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const;
virtual void fakeMouseWheel(SInt32 delta) const;
// IKeyState overrides