QWheelEvent: make NoScrollPhase opt-in
The fix for QTBUG-50199 involves adding an undocumented enum value which can be returned from QWheelEvent::phase(). This will be quite unexpected for applications that use it, which work fine with 5.6.0 and then start receiving this new phase value in 5.6.1. So it should not happen by default. Set the env variable QT_ENABLE_MOUSE_WHEEL_TRACKING to enable this functionality. In 5.7 it will be default behavior. But in 5.6 the default behavior is as it was before: if you use a conventional mouse wheel, the phase stays at ScrollUpdate continuously. [ChangeLog][QtCore] QWheelEvent::phase() returns 0 rather than Qt::ScrollUpdate when the wheel event comes from an actual non-emulated mouse wheel and the environment variable QT_ENABLE_MOUSE_WHEEL_TRACKING is set. In Qt 5.6, this is required to enable the fix for QTBUG-50199. Change-Id: Ieb2152ff767df24c42730d201235d1225aaec832 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>bb10
parent
362b977e7c
commit
d5fde51410
|
|
@ -729,6 +729,8 @@ QWheelEvent::QWheelEvent(const QPointF &pos, int delta,
|
|||
: QInputEvent(Wheel, modifiers), p(pos), qt4D(delta), qt4O(orient), mouseState(buttons),
|
||||
ph(Qt::NoScrollPhase), src(Qt::MouseEventNotSynthesized)
|
||||
{
|
||||
if (!QGuiApplicationPrivate::scrollNoPhaseAllowed)
|
||||
ph = Qt::ScrollUpdate;
|
||||
g = QCursor::pos();
|
||||
if (orient == Qt::Vertical)
|
||||
angleD = QPoint(0, delta);
|
||||
|
|
@ -764,6 +766,8 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta
|
|||
: QInputEvent(Wheel, modifiers), p(pos), g(globalPos), qt4D(delta), qt4O(orient), mouseState(buttons),
|
||||
ph(Qt::NoScrollPhase), src(Qt::MouseEventNotSynthesized)
|
||||
{
|
||||
if (!QGuiApplicationPrivate::scrollNoPhaseAllowed)
|
||||
ph = Qt::ScrollUpdate;
|
||||
if (orient == Qt::Vertical)
|
||||
angleD = QPoint(0, delta);
|
||||
else
|
||||
|
|
@ -800,7 +804,10 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
|
|||
: QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta),
|
||||
angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), ph(Qt::NoScrollPhase),
|
||||
src(Qt::MouseEventNotSynthesized)
|
||||
{}
|
||||
{
|
||||
if (!QGuiApplicationPrivate::scrollNoPhaseAllowed)
|
||||
ph = Qt::ScrollUpdate;
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a wheel event object.
|
||||
|
|
|
|||
|
|
@ -186,6 +186,9 @@ bool QGuiApplicationPrivate::obey_desktop_settings = true;
|
|||
|
||||
QInputDeviceManager *QGuiApplicationPrivate::m_inputDeviceManager = 0;
|
||||
|
||||
// enable the fix for QTBUG-50199; TODO remove this check in 5.7
|
||||
bool QGuiApplicationPrivate::scrollNoPhaseAllowed = false;
|
||||
|
||||
static qreal fontSmoothingGamma = 1.7;
|
||||
|
||||
extern void qRegisterGuiVariant();
|
||||
|
|
@ -1412,6 +1415,8 @@ void QGuiApplicationPrivate::init()
|
|||
|
||||
if (layout_direction == Qt::LayoutDirectionAuto || force_reverse)
|
||||
QGuiApplication::setLayoutDirection(qt_detectRTLLanguage() ? Qt::RightToLeft : Qt::LeftToRight);
|
||||
|
||||
scrollNoPhaseAllowed = qEnvironmentVariableIsSet("QT_ENABLE_MOUSE_WHEEL_TRACKING");
|
||||
}
|
||||
|
||||
extern void qt_cleanupFontDatabase();
|
||||
|
|
|
|||
|
|
@ -285,6 +285,9 @@ public:
|
|||
|
||||
static void setApplicationState(Qt::ApplicationState state, bool forcePropagate = false);
|
||||
|
||||
// enable the fix for QTBUG-50199; TODO remove this check in 5.7
|
||||
static bool scrollNoPhaseAllowed;
|
||||
|
||||
protected:
|
||||
virtual void notifyThemeChanged();
|
||||
bool tryCloseRemainingWindows(QWindowList processedWindows);
|
||||
|
|
|
|||
|
|
@ -311,6 +311,9 @@ void QWindowSystemInterface::handleWheelEvent(QWindow *w, const QPointF & local,
|
|||
|
||||
void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods, Qt::ScrollPhase phase, Qt::MouseEventSource source)
|
||||
{
|
||||
if (!QGuiApplicationPrivate::scrollNoPhaseAllowed && phase == Qt::NoScrollPhase)
|
||||
phase = Qt::ScrollUpdate;
|
||||
|
||||
// Qt 4 sends two separate wheel events for horizontal and vertical
|
||||
// deltas. For Qt 5 we want to send the deltas in one event, but at the
|
||||
// same time preserve source and behavior compatibility with Qt 4.
|
||||
|
|
@ -930,5 +933,13 @@ bool QWindowSystemEventHandler::sendEvent(QWindowSystemInterfacePrivate::WindowS
|
|||
return true;
|
||||
}
|
||||
|
||||
QWindowSystemInterfacePrivate::WheelEvent::WheelEvent(QWindow *w, ulong time, const QPointF &local, const QPointF &global, QPoint pixelD,
|
||||
QPoint angleD, int qt4D, Qt::Orientation qt4O, Qt::KeyboardModifiers mods, Qt::ScrollPhase phase, Qt::MouseEventSource src)
|
||||
: InputEvent(w, time, Wheel, mods), pixelDelta(pixelD), angleDelta(angleD), qt4Delta(qt4D),
|
||||
qt4Orientation(qt4O), localPos(local), globalPos(global),
|
||||
phase(!QGuiApplicationPrivate::scrollNoPhaseAllowed && phase == Qt::NoScrollPhase ? Qt::ScrollUpdate : phase),
|
||||
source(src)
|
||||
{
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -236,8 +236,7 @@ public:
|
|||
class WheelEvent : public InputEvent {
|
||||
public:
|
||||
WheelEvent(QWindow *w, ulong time, const QPointF & local, const QPointF & global, QPoint pixelD, QPoint angleD, int qt4D, Qt::Orientation qt4O,
|
||||
Qt::KeyboardModifiers mods, Qt::ScrollPhase phase = Qt::NoScrollPhase, Qt::MouseEventSource src = Qt::MouseEventNotSynthesized)
|
||||
: InputEvent(w, time, Wheel, mods), pixelDelta(pixelD), angleDelta(angleD), qt4Delta(qt4D), qt4Orientation(qt4O), localPos(local), globalPos(global), phase(phase), source(src) { }
|
||||
Qt::KeyboardModifiers mods, Qt::ScrollPhase phase = Qt::NoScrollPhase, Qt::MouseEventSource src = Qt::MouseEventNotSynthesized);
|
||||
QPoint pixelDelta;
|
||||
QPoint angleDelta;
|
||||
int qt4Delta;
|
||||
|
|
|
|||
|
|
@ -1409,6 +1409,8 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
|
|||
m_scrolling = false;
|
||||
} else if (phase == NSEventPhaseNone && momentumPhase == NSEventPhaseNone) {
|
||||
ph = Qt::NoScrollPhase;
|
||||
if (!QGuiApplicationPrivate::scrollNoPhaseAllowed)
|
||||
ph = Qt::ScrollUpdate;
|
||||
}
|
||||
|
||||
QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_screenPoint, pixelDelta, angleDelta, currentWheelModifiers, ph, source);
|
||||
|
|
|
|||
|
|
@ -3341,7 +3341,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
|
|||
res = d->notify_helper(w, &we);
|
||||
eventAccepted = we.isAccepted();
|
||||
if (res && eventAccepted) {
|
||||
if (spontaneous && phase != Qt::NoScrollPhase)
|
||||
if (spontaneous && phase != Qt::NoScrollPhase && QGuiApplicationPrivate::scrollNoPhaseAllowed)
|
||||
QApplicationPrivate::wheel_widget = w;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue