diff options
author | David Schulz <david.schulz@qt.io> | 2021-11-16 06:31:37 +0100 |
---|---|---|
committer | David Schulz <david.schulz@qt.io> | 2021-11-18 06:44:26 +0100 |
commit | 35263fffeaf6085907009e1fca3fba56be1acdb7 (patch) | |
tree | 7a0411b14b04e37ffdecc0abed3605b4c8edd9b6 /src/widgets | |
parent | 16aa4eaa8294b555ead4bd3d6166b6f2c6ee5e3c (diff) |
Always check keyboard modifiers when generating mouse events
This is basically a revert of: 634ce491e8e943519593140b858eb2e67253c13e
The cached keyboard modifier can get out of sync when switching to
another application while a modifier is pressed. In this case we get a
key press event but we might not get the key release event, which is
expected to reset the cached modifier. Switching back to the Qt
application after the modifier was released now still has the old
modifier cached.
Most prominent example is triggering alt + tab to switch to another
application and use the mouse to get back to it. In this case the alt
modifier is still cached.
Task-number: QTCREATORBUG-26581
Pick-to: 6.2
Change-Id: I9d64b7d730af089778bd1a4b3f1296bcccd5d16d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/widgets/qplaintextedit.cpp | 4 | ||||
-rw-r--r-- | src/widgets/widgets/qplaintextedit_p.h | 1 |
2 files changed, 1 insertions, 4 deletions
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index daa81512e2..9ca5bff827 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -1616,7 +1616,7 @@ void QPlainTextEdit::timerEvent(QTimerEvent *e) const QPoint globalPos = QCursor::pos(); pos = d->viewport->mapFromGlobal(globalPos); QMouseEvent ev(QEvent::MouseMove, pos, d->viewport->mapTo(d->viewport->topLevelWidget(), pos), globalPos, - Qt::LeftButton, Qt::LeftButton, d->keyboardModifiers); + Qt::LeftButton, Qt::LeftButton, QGuiApplication::keyboardModifiers()); mouseMoveEvent(&ev); } int deltaY = qMax(pos.y() - visible.top(), visible.bottom() - pos.y()) - visible.height(); @@ -1681,7 +1681,6 @@ void QPlainTextEdit::setPlainText(const QString &text) void QPlainTextEdit::keyPressEvent(QKeyEvent *e) { Q_D(QPlainTextEdit); - d->keyboardModifiers = e->modifiers(); #ifdef QT_KEYPAD_NAVIGATION switch (e->key()) { @@ -1832,7 +1831,6 @@ void QPlainTextEdit::keyReleaseEvent(QKeyEvent *e) Q_D(QPlainTextEdit); if (!isReadOnly()) d->handleSoftwareInputPanel(); - d->keyboardModifiers = e->modifiers(); #ifdef QT_KEYPAD_NAVIGATION if (QApplicationPrivate::keypadNavigationEnabled()) { diff --git a/src/widgets/widgets/qplaintextedit_p.h b/src/widgets/widgets/qplaintextedit_p.h index 112eb2e4f6..114db01574 100644 --- a/src/widgets/widgets/qplaintextedit_p.h +++ b/src/widgets/widgets/qplaintextedit_p.h @@ -155,7 +155,6 @@ public: qreal pageUpDownLastCursorY = 0; QPlainTextEdit::LineWrapMode lineWrap = QPlainTextEdit::WidgetWidth; QTextOption::WrapMode wordWrap = QTextOption::WrapAtWordBoundaryOrAnywhere; - Qt::KeyboardModifiers keyboardModifiers = {}; int originalOffsetY = 0; int topLine = 0; |