aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/platform
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@ubuntu.com>2018-09-19 18:24:12 -0400
committerLibravatarUnit 193 <unit193@ubuntu.com>2018-09-19 18:24:12 -0400
commita12f59bc78d8eab79d24e2e625a9a85b81c20a54 (patch)
treef9d4bceac647f7f9ce335881f40be31169435349 /src/lib/platform
parent7a723cbbf3b9ba1cf23ca67a08058b41e56831e8 (diff)
parent68a36b3b67ec82cdd3f77e88e40d1043cbab5000 (diff)
Update upstream source from tag 'upstream/2.1.2+dfsg'
Update to upstream version '2.1.2+dfsg' with Debian dir a655df7e32df947a70958a6a26869e4705733064
Diffstat (limited to 'src/lib/platform')
-rw-r--r--src/lib/platform/OSXScreen.h4
-rw-r--r--src/lib/platform/OSXScreen.mm8
-rw-r--r--src/lib/platform/XWindowsScreen.cpp30
-rw-r--r--src/lib/platform/XWindowsScreen.h11
4 files changed, 35 insertions, 18 deletions
diff --git a/src/lib/platform/OSXScreen.h b/src/lib/platform/OSXScreen.h
index 27cb7df..6178529 100644
--- a/src/lib/platform/OSXScreen.h
+++ b/src/lib/platform/OSXScreen.h
@@ -144,10 +144,10 @@ private:
ButtonID mapMacButtonToBarrier(UInt16) const;
// map mac scroll wheel value to a barrier scroll wheel value
- SInt32 mapScrollWheelToBarrier(SInt32) const;
+ SInt32 mapScrollWheelToBarrier(float) const;
// map barrier scroll wheel value to a mac scroll wheel value
- SInt32 mapScrollWheelFromBarrier(SInt32) const;
+ SInt32 mapScrollWheelFromBarrier(float) const;
// get the current scroll wheel speed
double getScrollSpeed() const;
diff --git a/src/lib/platform/OSXScreen.mm b/src/lib/platform/OSXScreen.mm
index 1d80521..1e0268e 100644
--- a/src/lib/platform/OSXScreen.mm
+++ b/src/lib/platform/OSXScreen.mm
@@ -1421,7 +1421,7 @@ OSXScreen::mapMacButtonToBarrier(UInt16 macButton) const
}
SInt32
-OSXScreen::mapScrollWheelToBarrier(SInt32 x) const
+OSXScreen::mapScrollWheelToBarrier(float x) const
{
// return accelerated scrolling but not exponentially scaled as it is
// on the mac.
@@ -1430,7 +1430,7 @@ OSXScreen::mapScrollWheelToBarrier(SInt32 x) const
}
SInt32
-OSXScreen::mapScrollWheelFromBarrier(SInt32 x) const
+OSXScreen::mapScrollWheelFromBarrier(float x) const
{
// use server's acceleration with a little boost since other platforms
// take one wheel step as a larger step than the mac does.
@@ -1948,9 +1948,9 @@ OSXScreen::handleCGInputEvent(CGEventTapProxy proxy,
break;
case kCGEventScrollWheel:
screen->onMouseWheel(screen->mapScrollWheelToBarrier(
- CGEventGetIntegerValueField(event, kCGScrollWheelEventDeltaAxis2)),
+ CGEventGetIntegerValueField(event, kCGScrollWheelEventFixedPtDeltaAxis2) / 65536.0f),
screen->mapScrollWheelToBarrier(
- CGEventGetIntegerValueField(event, kCGScrollWheelEventDeltaAxis1)));
+ CGEventGetIntegerValueField(event, kCGScrollWheelEventFixedPtDeltaAxis1) / 65536.0f));
break;
case kCGEventKeyDown:
case kCGEventKeyUp:
diff --git a/src/lib/platform/XWindowsScreen.cpp b/src/lib/platform/XWindowsScreen.cpp
index 581c911..2846412 100644
--- a/src/lib/platform/XWindowsScreen.cpp
+++ b/src/lib/platform/XWindowsScreen.cpp
@@ -99,6 +99,7 @@ XWindowsScreen::XWindowsScreen(
IEventQueue* events) :
m_isPrimary(isPrimary),
m_mouseScrollDelta(mouseScrollDelta),
+ m_accumulatedScroll(0),
m_display(NULL),
m_root(None),
m_window(None),
@@ -865,9 +866,11 @@ XWindowsScreen::fakeMouseWheel(SInt32, SInt32 yDelta) const
return;
}
- // choose button depending on rotation direction
- const unsigned int xButton = mapButtonToX(static_cast<ButtonID>(
- (yDelta >= 0) ? -1 : -2));
+ int numEvents = accumulateMouseScroll(yDelta);
+
+ // choose button depending on rotation direction
+ const unsigned int xButton = mapButtonToX(static_cast<ButtonID>(
+ (numEvents >= 0) ? -1 : -2));
if (xButton == 0) {
// If we get here, then the XServer does not support the scroll
// wheel buttons, so send PageUp/PageDown keystrokes instead.
@@ -886,20 +889,14 @@ XWindowsScreen::fakeMouseWheel(SInt32, SInt32 yDelta) const
return;
}
- // now use absolute value of delta
- if (yDelta < 0) {
- yDelta = -yDelta;
- }
-
- if (yDelta < m_mouseScrollDelta) {
- LOG((CLOG_WARN "Wheel scroll delta (%d) smaller than threshold (%d)", yDelta, m_mouseScrollDelta));
- }
+ numEvents = std::abs(numEvents);
// send as many clicks as necessary
- for (; yDelta >= m_mouseScrollDelta; yDelta -= m_mouseScrollDelta) {
+ for (; numEvents > 0; numEvents--) {
XTestFakeButtonEvent(m_display, xButton, True, CurrentTime);
XTestFakeButtonEvent(m_display, xButton, False, CurrentTime);
}
+
XFlush(m_display);
}
@@ -1643,6 +1640,15 @@ XWindowsScreen::onMouseMove(const XMotionEvent& xmotion)
}
}
+int
+XWindowsScreen::accumulateMouseScroll(SInt32 yDelta) const
+{
+ m_accumulatedScroll += yDelta;
+ int numEvents = m_accumulatedScroll / m_mouseScrollDelta;
+ m_accumulatedScroll -= numEvents * m_mouseScrollDelta;
+ return numEvents;
+}
+
Cursor
XWindowsScreen::createBlankCursor() const
{
diff --git a/src/lib/platform/XWindowsScreen.h b/src/lib/platform/XWindowsScreen.h
index 35f9368..a2e3495 100644
--- a/src/lib/platform/XWindowsScreen.h
+++ b/src/lib/platform/XWindowsScreen.h
@@ -136,6 +136,10 @@ private:
void onMouseRelease(const XButtonEvent&);
void onMouseMove(const XMotionEvent&);
+ // Returns the number of scroll events needed after the current delta has
+ // been taken into account
+ int accumulateMouseScroll(SInt32 yDelta) const;
+
bool detectXI2();
#ifdef HAVE_XI2
void selectXIRawMotion();
@@ -172,8 +176,15 @@ private:
// true if screen is being used as a primary screen, false otherwise
bool m_isPrimary;
+
+ // The size of a smallest supported scroll event, in points
int m_mouseScrollDelta;
+ // Accumulates scrolls of less than m_mouseScrollDelta across multiple
+ // scroll events. We dispatch a scroll event whenever the accumulated scroll
+ // becomes larger than m_mouseScrollDelta
+ mutable int m_accumulatedScroll;
+
Display* m_display;
Window m_root;
Window m_window;