Added relative mouse move support to win32.
This commit is contained in:
parent
0f45face21
commit
9c35a45a2c
|
@ -72,6 +72,8 @@
|
||||||
#define SYNERGY_MSG_SYNC_KEYS SYNERGY_HOOK_LAST_MSG + 9
|
#define SYNERGY_MSG_SYNC_KEYS SYNERGY_HOOK_LAST_MSG + 9
|
||||||
// install; <unused>
|
// install; <unused>
|
||||||
#define SYNERGY_MSG_SCREENSAVER SYNERGY_HOOK_LAST_MSG + 10
|
#define SYNERGY_MSG_SCREENSAVER SYNERGY_HOOK_LAST_MSG + 10
|
||||||
|
// dx; dy
|
||||||
|
#define SYNERGY_MSG_FAKE_REL_MOVE SYNERGY_HOOK_LAST_MSG + 11
|
||||||
|
|
||||||
//
|
//
|
||||||
// CMSWindowsDesks
|
// CMSWindowsDesks
|
||||||
|
@ -293,6 +295,14 @@ CMSWindowsDesks::fakeMouseMove(SInt32 x, SInt32 y) const
|
||||||
static_cast<LPARAM>(y));
|
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
|
void
|
||||||
CMSWindowsDesks::fakeMouseWheel(SInt32 delta) const
|
CMSWindowsDesks::fakeMouseWheel(SInt32 delta) const
|
||||||
{
|
{
|
||||||
|
@ -492,16 +502,26 @@ CMSWindowsDesks::deskMouseMove(SInt32 x, SInt32 y) const
|
||||||
// the right place, the effect is disconcerting.
|
// the right place, the effect is disconcerting.
|
||||||
//
|
//
|
||||||
// instead we'll get the cursor's current position and do just a
|
// instead we'll get the cursor's current position and do just a
|
||||||
// relative move from there to the desired position. relative
|
// relative move from there to the desired position.
|
||||||
// moves are subject to cursor acceleration which we don't want.
|
else {
|
||||||
// so we disable acceleration, do the relative move, then restore
|
POINT pos;
|
||||||
// acceleration. there's a slight chance we'll end up in the
|
GetCursorPos(&pos);
|
||||||
// wrong place if the user moves the cursor using this system's
|
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
|
// mouse while simultaneously moving the mouse on the server
|
||||||
// system. that defeats the purpose of synergy so we'll assume
|
// system. that defeats the purpose of synergy so we'll assume
|
||||||
// that won't happen. even if it does, the next mouse move will
|
// that won't happen. even if it does, the next mouse move will
|
||||||
// correct the position.
|
// correct the position.
|
||||||
else {
|
|
||||||
// save mouse speed & acceleration
|
// save mouse speed & acceleration
|
||||||
int oldSpeed[4];
|
int oldSpeed[4];
|
||||||
bool accelChanged =
|
bool accelChanged =
|
||||||
|
@ -517,9 +537,7 @@ CMSWindowsDesks::deskMouseMove(SInt32 x, SInt32 y) const
|
||||||
}
|
}
|
||||||
|
|
||||||
// move relative to mouse position
|
// move relative to mouse position
|
||||||
POINT pos;
|
mouse_event(MOUSEEVENTF_MOVE, dx, dy, 0, 0);
|
||||||
GetCursorPos(&pos);
|
|
||||||
mouse_event(MOUSEEVENTF_MOVE, x - pos.x, y - pos.y, 0, 0);
|
|
||||||
|
|
||||||
// restore mouse speed & acceleration
|
// restore mouse speed & acceleration
|
||||||
if (accelChanged) {
|
if (accelChanged) {
|
||||||
|
@ -527,7 +545,6 @@ CMSWindowsDesks::deskMouseMove(SInt32 x, SInt32 y) const
|
||||||
SystemParametersInfo(SPI_SETMOUSESPEED, 0, oldSpeed + 3, 0);
|
SystemParametersInfo(SPI_SETMOUSESPEED, 0, oldSpeed + 3, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsDesks::deskEnter(CDesk* desk)
|
CMSWindowsDesks::deskEnter(CDesk* desk)
|
||||||
|
@ -693,6 +710,11 @@ CMSWindowsDesks::deskThread(void* vdesk)
|
||||||
static_cast<SInt32>(msg.lParam));
|
static_cast<SInt32>(msg.lParam));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SYNERGY_MSG_FAKE_REL_MOVE:
|
||||||
|
deskMouseRelativeMove(static_cast<SInt32>(msg.wParam),
|
||||||
|
static_cast<SInt32>(msg.lParam));
|
||||||
|
break;
|
||||||
|
|
||||||
case SYNERGY_MSG_FAKE_WHEEL:
|
case SYNERGY_MSG_FAKE_WHEEL:
|
||||||
mouse_event(MOUSEEVENTF_WHEEL, 0, 0, msg.wParam, 0);
|
mouse_event(MOUSEEVENTF_WHEEL, 0, 0, msg.wParam, 0);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -144,6 +144,12 @@ public:
|
||||||
*/
|
*/
|
||||||
void fakeMouseMove(SInt32 x, SInt32 y) const;
|
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
|
//! Fake mouse wheel
|
||||||
/*!
|
/*!
|
||||||
Synthesize a mouse wheel event of amount \c delta.
|
Synthesize a mouse wheel event of amount \c delta.
|
||||||
|
@ -176,6 +182,7 @@ private:
|
||||||
|
|
||||||
// message handlers
|
// message handlers
|
||||||
void deskMouseMove(SInt32 x, SInt32 y) const;
|
void deskMouseMove(SInt32 x, SInt32 y) const;
|
||||||
|
void deskMouseRelativeMove(SInt32 dx, SInt32 dy) const;
|
||||||
void deskEnter(CDesk* desk);
|
void deskEnter(CDesk* desk);
|
||||||
void deskLeave(CDesk* desk, HKL keyLayout);
|
void deskLeave(CDesk* desk, HKL keyLayout);
|
||||||
void deskThread(void* vdesk);
|
void deskThread(void* vdesk);
|
||||||
|
|
|
@ -507,6 +507,12 @@ CMSWindowsScreen::fakeMouseMove(SInt32 x, SInt32 y) const
|
||||||
m_desks->fakeMouseMove(x, y);
|
m_desks->fakeMouseMove(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CMSWindowsScreen::fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const
|
||||||
|
{
|
||||||
|
m_desks->fakeMouseRelativeMove(dx, dy);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsScreen::fakeMouseWheel(SInt32 delta) const
|
CMSWindowsScreen::fakeMouseWheel(SInt32 delta) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -75,6 +75,7 @@ public:
|
||||||
// ISecondaryScreen overrides
|
// ISecondaryScreen overrides
|
||||||
virtual void fakeMouseButton(ButtonID id, bool press) const;
|
virtual void fakeMouseButton(ButtonID id, bool press) const;
|
||||||
virtual void fakeMouseMove(SInt32 x, SInt32 y) const;
|
virtual void fakeMouseMove(SInt32 x, SInt32 y) const;
|
||||||
|
virtual void fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const;
|
||||||
virtual void fakeMouseWheel(SInt32 delta) const;
|
virtual void fakeMouseWheel(SInt32 delta) const;
|
||||||
|
|
||||||
// IKeyState overrides
|
// IKeyState overrides
|
||||||
|
|
Loading…
Reference in New Issue