diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-11-09 22:51:21 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-11-10 08:21:08 +0100 |
commit | 48219c8231f7f9daf79f6c60a752b78c03e44a1f (patch) | |
tree | d6e0997a558d3bb372f2a51e42a293bd0c8ffcda /src | |
parent | 5f2b53f13c40c31da21d8352312962bb97cb8c97 (diff) |
Remove code for non-enhanced mouse events
Followup to a37785ec7638e7485112b87dd7e767881fecc114.
The mouse button that caused the event and the current state of all
mouse buttons must always be given separately in QPA mouse events.
Task-number: QTBUG-59277
Task-number: QTBUG-62329
Task-number: QTBUG-63467
Change-Id: I27209b3730baef325ce0f1c4d3778930e72d5465
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 92 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface_p.h | 7 |
2 files changed, 25 insertions, 74 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 3dcd0650e3..268f5cee1d 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2159,73 +2159,31 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo return; } - if (e->enhancedMouseEvent()) { - type = e->buttonType; - button = e->button; - - if (type == QEvent::NonClientAreaMouseMove || type == QEvent::MouseMove) - mouseMove = true; - else if (type == QEvent::NonClientAreaMouseButtonPress || type == QEvent::MouseButtonPress) - mousePress = true; - - if (!mouseMove && positionChanged) { - QWindowSystemInterfacePrivate::MouseEvent moveEvent(window, e->timestamp, - e->localPos, e->globalPos, e->buttons ^ button, e->modifiers, Qt::NoButton, - e->nonClientArea ? QEvent::NonClientAreaMouseMove : QEvent::MouseMove, - e->source, e->nonClientArea); - if (e->synthetic()) - moveEvent.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; - processMouseEvent(&moveEvent); // mouse move excluding state change - processMouseEvent(e); // the original mouse event - return; - } - if (mouseMove && !positionChanged) { - // On Windows, and possibly other platforms, a touchpad can send a mouse move - // that does not change position, between a press and a release. This may - // confuse applications, so we always filter out these mouse events for - // consistent behavior among platforms. - return; - } - } else { - Qt::MouseButtons stateChange = e->buttons ^ mouse_buttons; - if (positionChanged && (stateChange != Qt::NoButton)) { - QWindowSystemInterfacePrivate::MouseEvent moveEvent(window, e->timestamp, e->localPos, - e->globalPos, mouse_buttons, e->modifiers, Qt::NoButton, QEvent::None, e->source, - e->nonClientArea); - if (e->synthetic()) - moveEvent.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; - processMouseEvent(&moveEvent); // mouse move excluding state change - processMouseEvent(e); // the original mouse event - return; - } - - // In the compatibility path we deduce event type and button that caused the event - if (positionChanged) { - mouseMove = true; - type = e->nonClientArea ? QEvent::NonClientAreaMouseMove : QEvent::MouseMove; - } else { - // Check to see if a new button has been pressed/released. - for (uint mask = Qt::LeftButton; mask <= Qt::MaxMouseButton; mask <<= 1) { - if (stateChange & mask) { - button = Qt::MouseButton(mask); - break; - } - } - if (button == Qt::NoButton) { - // Ignore mouse events that don't change the current state. This shouldn't - // really happen, getting here can only mean that the stored button state - // is out of sync with the actual physical button state. - return; - } - if (button & e->buttons) { - mousePress = true; - type = e->nonClientArea ? QEvent::NonClientAreaMouseButtonPress - : QEvent::MouseButtonPress; - } else { - type = e->nonClientArea ? QEvent::NonClientAreaMouseButtonRelease - : QEvent::MouseButtonRelease; - } - } + type = e->buttonType; + button = e->button; + + if (type == QEvent::NonClientAreaMouseMove || type == QEvent::MouseMove) + mouseMove = true; + else if (type == QEvent::NonClientAreaMouseButtonPress || type == QEvent::MouseButtonPress) + mousePress = true; + + if (!mouseMove && positionChanged) { + QWindowSystemInterfacePrivate::MouseEvent moveEvent(window, e->timestamp, + e->localPos, e->globalPos, e->buttons ^ button, e->modifiers, Qt::NoButton, + e->nonClientArea ? QEvent::NonClientAreaMouseMove : QEvent::MouseMove, + e->source, e->nonClientArea); + if (e->synthetic()) + moveEvent.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; + processMouseEvent(&moveEvent); // mouse move excluding state change + processMouseEvent(e); // the original mouse event + return; + } + if (mouseMove && !positionChanged) { + // On Windows, and possibly other platforms, a touchpad can send a mouse move + // that does not change position, between a press and a release. This may + // confuse applications, so we always filter out these mouse events for + // consistent behavior among platforms. + return; } modifier_buttons = e->modifiers; diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h index af149cd2ab..807c34131c 100644 --- a/src/gui/kernel/qwindowsysteminterface_p.h +++ b/src/gui/kernel/qwindowsysteminterface_p.h @@ -254,13 +254,6 @@ public: : PointerEvent(w, time, Mouse, mods, device), localPos(local), globalPos(global), buttons(state), source(src), nonClientArea(frame), button(b), buttonType(type) { } - // ### In Qt6 this method can be removed as there won't be need for compatibility code path - bool enhancedMouseEvent() const - { - static const bool disableEnhanced = qEnvironmentVariableIsSet("QT_QPA_DISABLE_ENHANCED_MOUSE"); - return !disableEnhanced && buttonType != QEvent::None; - } - QPointF localPos; QPointF globalPos; Qt::MouseButtons buttons; |