Fix sending simulated keyboard events to popup widgets

Popup widgets steal the keyboard grab stealthily without it being
visible via QWidget::keyboardGrabber(). To more accurately simulate a
real keyboard event, prioritize sending simulated keyboard events to
the active popup widget over QGuiApplication::focusWindow().

Task-number: QTBUG-24326
Change-Id: Id7a75c613d934e24657b521f1684ce7cce92556a
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
This commit is contained in:
Miikka Heikkinen 2012-03-06 13:58:31 +02:00 committed by Qt by Nokia
parent 83d113feb0
commit 7bc576771d

View File

@ -191,18 +191,20 @@ namespace QTest
if (!widget)
widget = QWidget::keyboardGrabber();
if (!widget) {
// Popup widgets stealthily steal the keyboard grab
if (QWidget *apw = QApplication::activePopupWidget())
widget = apw->focusWidget() ? apw->focusWidget() : apw;
}
if (!widget) {
QWindow *window = QGuiApplication::focusWindow();
if (window) {
sendKeyEvent(action, window, code, text, modifier, delay);
return;
}
if (QWidget *apw = QApplication::activePopupWidget())
widget = apw->focusWidget() ? apw->focusWidget() : apw;
else
widget = QApplication::focusWidget();
}
if (!widget)
widget = QApplication::focusWidget();
if (!widget)
widget = QApplication::activeWindow();