TextEdit: Avoid scrolling to cursor during app switch on GNOME

GNOME sends empty InputMethod event when switching applications
with Alt-Tab. As long as this event is empty, we don't need to
scroll to cursor, because we're not adding any input text to it.

This also fixes "out of scope" bug QTCREATORBUG-26628

Fixes: QTBUG-100039
Task-number: QTCREATORBUG-26628
Pick-to: 6.2 6.3
Change-Id: I3ccfea50ae52f6f0cbf82c29f07944894050e7dd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Volodymyr Zibarov 2022-04-11 21:22:23 +03:00
parent 41a7546789
commit 8b3f2dd994
2 changed files with 8 additions and 0 deletions

View File

@ -2214,6 +2214,10 @@ void QPlainTextEdit::inputMethodEvent(QInputMethodEvent *e)
}
#endif
d->sendControlEvent(e);
const bool emptyEvent = e->preeditString().isEmpty() && e->commitString().isEmpty()
&& e->attributes().isEmpty();
if (emptyEvent)
return;
ensureCursorVisible();
}

View File

@ -1808,6 +1808,10 @@ void QTextEdit::inputMethodEvent(QInputMethodEvent *e)
setEditFocus(true);
#endif
d->sendControlEvent(e);
const bool emptyEvent = e->preeditString().isEmpty() && e->commitString().isEmpty()
&& e->attributes().isEmpty();
if (emptyEvent)
return;
ensureCursorVisible();
}