diff options
| author | 2019-10-05 21:10:12 -0400 | |
|---|---|---|
| committer | 2019-10-05 21:10:12 -0400 | |
| commit | 78fb19eb26c8814cc83c649a252b7f47bdf649a0 (patch) | |
| tree | e8f38f35e404b37d4683604cb2a826ff3f4d2f1d /src/lib/platform/OSXScreen.mm | |
| parent | 226b07c35afedc28ad1a769d6bf539e6cab320d4 (diff) | |
| parent | dff8b887edf10407f22aaab9d147948cd5491f0a (diff) | |
Update upstream source from tag 'upstream/2.3.2+dfsg'
Update to upstream version '2.3.2+dfsg'
with Debian dir da6cb58f0203c792df99a475344204697ce64812
Diffstat (limited to 'src/lib/platform/OSXScreen.mm')
| -rw-r--r-- | src/lib/platform/OSXScreen.mm | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/lib/platform/OSXScreen.mm b/src/lib/platform/OSXScreen.mm index 8c7e24c..2b4594f 100644 --- a/src/lib/platform/OSXScreen.mm +++ b/src/lib/platform/OSXScreen.mm @@ -422,6 +422,7 @@ OSXScreen::constructMouseButtonEventMap() {kCGEventRightMouseUp, kCGEventRightMouseDragged, kCGEventRightMouseDown}, {kCGEventOtherMouseUp, kCGEventOtherMouseDragged, kCGEventOtherMouseDown}, {kCGEventOtherMouseUp, kCGEventOtherMouseDragged, kCGEventOtherMouseDown}, + {kCGEventOtherMouseUp, kCGEventOtherMouseDragged, kCGEventOtherMouseDown}, {kCGEventOtherMouseUp, kCGEventOtherMouseDragged, kCGEventOtherMouseDown} }; @@ -1076,20 +1077,20 @@ OSXScreen::handleSystemEvent(const Event& event, void*) } bool -OSXScreen::onMouseMove(SInt32 mx, SInt32 my) +OSXScreen::onMouseMove(CGFloat mx, CGFloat my) { - LOG((CLOG_DEBUG2 "mouse move %+d,%+d", mx, my)); + LOG((CLOG_DEBUG2 "mouse move %+f,%+f", mx, my)); - SInt32 x = mx - m_xCursor; - SInt32 y = my - m_yCursor; + CGFloat x = mx - m_xCursor; + CGFloat y = my - m_yCursor; if ((x == 0 && y == 0) || (mx == m_xCenter && mx == m_yCenter)) { return true; } // save position to compute delta of next motion - m_xCursor = mx; - m_yCursor = my; + m_xCursor = (SInt32)mx; + m_yCursor = (SInt32)my; if (m_isOnScreen) { // motion on primary screen @@ -1118,7 +1119,21 @@ OSXScreen::onMouseMove(SInt32 mx, SInt32 my) } else { // send motion - sendEvent(m_events->forIPrimaryScreen().motionOnSecondary(), MotionInfo::alloc(x, y)); + // Accumulate together the move into the running total + static CGFloat m_xFractionalMove = 0; + static CGFloat m_yFractionalMove = 0; + + m_xFractionalMove += x; + m_yFractionalMove += y; + + // Return the integer part + SInt32 intX = (SInt32)m_xFractionalMove; + SInt32 intY = (SInt32)m_yFractionalMove; + + // And keep only the fractional part + m_xFractionalMove -= intX; + m_yFractionalMove -= intY; + sendEvent(m_events->forIPrimaryScreen().motionOnSecondary(), MotionInfo::alloc(intX, intY)); } } |
