diff options
author | Jeremy Katz <jeremy.katz@nokia.com> | 2010-01-26 13:52:09 (GMT) |
---|---|---|
committer | Jeremy Katz <jeremy.katz@nokia.com> | 2010-01-26 13:52:09 (GMT) |
commit | 33a5ecd4908690d6a8366d8f7384ad1e8cf86f92 (patch) | |
tree | f623030733f4297b41c664c8a981aa14c385a036 /src/plugins/generic | |
parent | f0f1d8588892ba94301ecad2aa4495e9bfa364ae (diff) | |
download | Qt-33a5ecd4908690d6a8366d8f7384ad1e8cf86f92.zip Qt-33a5ecd4908690d6a8366d8f7384ad1e8cf86f92.tar.gz Qt-33a5ecd4908690d6a8366d8f7384ad1e8cf86f92.tar.bz2 |
queue user mouse, wheel, and keyboard input events
For plugins: testlite, minimaldfb, vnc, LinuxInput[Mouse|Keyboard]
Diffstat (limited to 'src/plugins/generic')
-rw-r--r-- | src/plugins/generic/linuxinput/qlinuxinput.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/plugins/generic/linuxinput/qlinuxinput.cpp b/src/plugins/generic/linuxinput/qlinuxinput.cpp index 308af6b..363e91f 100644 --- a/src/plugins/generic/linuxinput/qlinuxinput.cpp +++ b/src/plugins/generic/linuxinput/qlinuxinput.cpp @@ -46,7 +46,6 @@ #include <QSocketNotifier> #include <QStringList> #include <QPoint> -#include <QMouseEvent> #include <private/qapplication_p.h> #include <qkbd_qws.h> @@ -100,6 +99,7 @@ void QLinuxInputMouseHandler::readMouseData() { struct ::input_event buffer[32]; int n = 0; + bool posChanged = false; forever { n = QT_READ(m_fd, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n); @@ -122,28 +122,34 @@ void QLinuxInputMouseHandler::readMouseData() bool unknown = false; if (data->type == EV_ABS) { - if (data->code == ABS_X) { + if (data->code == ABS_X && m_x != data->value) { m_x = data->value; - } else if (data->code == ABS_Y) { + posChanged = true; + } else if (data->code == ABS_Y && m_y != data->value) { m_y = data->value; + posChanged = true; } else { unknown = true; } } else if (data->type == EV_REL) { if (data->code == REL_X) { m_x += data->value; + posChanged = true; } else if (data->code == REL_Y) { m_y += data->value; + posChanged = true; } else if (data->code == ABS_WHEEL) { // vertical scroll // data->value: 1 == up, -1 == down int delta = 120 * data->value; - QWheelEvent we(QPoint(m_x, m_y), QPoint(m_x, m_y), delta, m_buttons, Qt::NoModifier, Qt::Vertical); - QApplicationPrivate::handleWheelEvent(0, we); + QApplicationPrivate::handleWheelEvent(0, QPoint(m_x, m_y), + QPoint(m_x, m_y), + delta, Qt::Vertical); } else if (data->code == ABS_THROTTLE) { // horizontal scroll // data->value: 1 == right, -1 == left int delta = 120 * -data->value; - QWheelEvent we(QPoint(m_x, m_y), QPoint(m_x, m_y), delta, m_buttons, Qt::NoModifier, Qt::Horizontal); - QApplicationPrivate::handleWheelEvent(0, we); + QApplicationPrivate::handleWheelEvent(0, QPoint(m_x, m_y), + QPoint(m_x, m_y), + delta, Qt::Horizontal); } else { unknown = true; } @@ -161,17 +167,15 @@ void QLinuxInputMouseHandler::readMouseData() else m_buttons &= ~button; - Qt::KeyboardModifiers modifiers = Qt::NoModifier; //### - QMouseEvent m(data->value ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease, - QPoint(m_x, m_y), QPoint(m_x, m_y), button, m_buttons, modifiers); - QApplicationPrivate::handleMouseEvent(0, m); + QApplicationPrivate::handleMouseEvent(0, QPoint(m_x, m_y), + QPoint(m_x, m_y), m_buttons); } else if (data->type == EV_SYN && data->code == SYN_REPORT) { + if (!posChanged) + continue; + posChanged = false; QPoint pos(m_x, m_y); - Qt::KeyboardModifiers modifiers = Qt::NoModifier; //### - QMouseEvent m(QEvent::MouseMove, QPoint(m_x, m_y), QPoint(m_x, m_y), - Qt::NoButton, m_buttons, modifiers); - QApplicationPrivate::handleMouseEvent(0, m); + QApplicationPrivate::handleMouseEvent(0, pos, pos, m_buttons); // pos = m_handler->transform(pos); //m_handler->limitToScreen(pos); |