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 Change-Id: I9d64b7d730af089778bd1a4b3f1296bcccd5d16d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 35263fffeaf6085907009e1fca3fba56be1acdb7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
09af4d9e8e
commit
84756a3015
@ -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()) {
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user