summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/input
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-04-21 01:00:10 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2020-04-22 15:28:01 +0200
commitefd7757154e1fb946a51c7d90b8cbf56b4df8b6d (patch)
treef757e14770d82ee8376fa10006973c0e750b1e16 /src/platformsupport/input
parent1c80d056e4f45b4ee7c4863cd792e83c889513c5 (diff)
parente10e5318bc02a48a866b76b6f0b7f268d16af642 (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts: src/widgets/widgets/qabstractbutton.cpp src/widgets/widgets/qbuttongroup.cpp src/widgets/widgets/qbuttongroup.h src/widgets/widgets/qsplashscreen.cpp tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp tests/benchmarks/opengl/main.cpp Needed update: src/plugins/platforms/cocoa/CMakeLists.txt Change-Id: I7be4baebb63844ec2b3e0de859ca9de1bc730bb5
Diffstat (limited to 'src/platformsupport/input')
-rw-r--r--src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp35
-rw-r--r--src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h3
2 files changed, 36 insertions, 2 deletions
diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp
index a729eeb851..0b1c5548c7 100644
--- a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp
+++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp
@@ -113,6 +113,8 @@ QEvdevMouseHandler::QEvdevMouseHandler(const QString &device, int fd, bool abs,
if (m_abs)
m_abs = getHardwareMaximum();
+ detectHiResWheelSupport();
+
// socket notifier for events on the mouse device
m_notify = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
connect(m_notify, &QSocketNotifier::activated,
@@ -125,6 +127,25 @@ QEvdevMouseHandler::~QEvdevMouseHandler()
qt_safe_close(m_fd);
}
+void QEvdevMouseHandler::detectHiResWheelSupport()
+{
+#if defined(REL_WHEEL_HI_RES) || defined(REL_HWHEEL_HI_RES)
+ // Check if we can expect hires events as we will get both
+ // legacy and hires event and needs to know if we should
+ // ignore the legacy events.
+ unsigned char relFeatures[(REL_MAX / 8) + 1]{};
+ if (ioctl(m_fd, EVIOCGBIT(EV_REL, sizeof (relFeatures)), relFeatures) == -1)
+ return;
+
+#if defined(REL_WHEEL_HI_RES)
+ m_hiResWheel = TEST_BIT(relFeatures, REL_WHEEL_HI_RES);
+#endif
+#if defined(REL_HWHEEL_HI_RES)
+ m_hiResHWheel = TEST_BIT(relFeatures, REL_HWHEEL_HI_RES);
+#endif
+#endif
+}
+
// Ask touch screen hardware for information on coordinate maximums
// If any ioctls fail, revert to non abs mode
bool QEvdevMouseHandler::getHardwareMaximum()
@@ -243,14 +264,24 @@ void QEvdevMouseHandler::readMouseData()
} else if (data->code == REL_Y) {
m_y += data->value;
posChanged = true;
- } else if (data->code == ABS_WHEEL) { // vertical scroll
+ } else if (!m_hiResWheel && data->code == REL_WHEEL) {
// data->value: positive == up, negative == down
delta.setY(120 * data->value);
emit handleWheelEvent(delta);
- } else if (data->code == ABS_THROTTLE) { // horizontal scroll
+#ifdef REL_WHEEL_HI_RES
+ } else if (data->code == REL_WHEEL_HI_RES) {
+ delta.setY(data->value);
+ emit handleWheelEvent(delta);
+#endif
+ } else if (!m_hiResHWheel && data->code == REL_HWHEEL) {
// data->value: positive == right, negative == left
delta.setX(-120 * data->value);
emit handleWheelEvent(delta);
+#ifdef REL_HWHEEL_HI_RES
+ } else if (data->code == REL_HWHEEL_HI_RES) {
+ delta.setX(-data->value);
+ emit handleWheelEvent(delta);
+#endif
}
} else if (data->type == EV_KEY && data->code == BTN_TOUCH) {
// We care about touchpads only, not touchscreens -> don't map to button press.
diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h
index 93314e885f..8fcf49200b 100644
--- a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h
+++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h
@@ -81,6 +81,7 @@ private:
void sendMouseEvent();
bool getHardwareMaximum();
+ void detectHiResWheelSupport();
QString m_device;
int m_fd;
@@ -89,6 +90,8 @@ private:
int m_prevx = 0, m_prevy = 0;
bool m_abs;
bool m_compression;
+ bool m_hiResWheel = false;
+ bool m_hiResHWheel = false;
Qt::MouseButtons m_buttons;
Qt::MouseButton m_button;
QEvent::Type m_eventType;