summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-01-03 17:38:55 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-01-10 23:24:57 +0000
commit6f504a1cdd1c076365e7916f0851c5d35a8f7ad1 (patch)
treea2ea38146f6430d9e7c21cb0476c9075b27d55de /src
parent166f23eb929d71f8a1239e0854516020b3fbc8ee (diff)
Widgets: report focus object change to QtGui before sending widget events
Updating the focus child means the focus object of the window has changed. We need to report this to QtGui immediately so that it can e.g. inform the input context of the new focus object, before widgets reacting to the focus events start calling update() on the input method. Change-Id: Ie3f7b835591e71519e3f384c2abdad53242c9736 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/kernel/qwidget.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 0729c7b74e..61956b3fa4 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -6595,11 +6595,6 @@ void QWidget::setFocus(Qt::FocusReason reason)
} else {
f->d_func()->updateFocusChild();
}
-
- if (QTLWExtra *extra = f->window()->d_func()->maybeTopData()) {
- if (extra->window)
- emit extra->window->focusObjectChanged(f);
- }
}
void QWidgetPrivate::setFocus_sys()
@@ -6634,6 +6629,11 @@ void QWidgetPrivate::updateFocusChild()
w = w->isWindow() ? 0 : w->parentWidget();
}
}
+
+ if (QTLWExtra *extra = q->window()->d_func()->maybeTopData()) {
+ if (extra->window)
+ emit extra->window->focusObjectChanged(q);
+ }
}
/*!
@@ -6675,9 +6675,15 @@ void QWidget::clearFocus()
w->d_func()->focus_child = 0;
w = w->parentWidget();
}
- // Since focus_child is the basis for the top level QWidgetWindow's focusObject()
- // we need to report this change to the rest of Qt, but we match setFocus() and
- // do it at the end of the function.
+
+ // Since we've unconditionally cleared the focus_child of our parents, we need
+ // to report this to the rest of Qt. Note that the focus_child is not the same
+ // thing as the application's focusWidget, which is why this piece of code is
+ // not inside the hasFocus() block below.
+ if (QTLWExtra *extra = window()->d_func()->maybeTopData()) {
+ if (extra->window)
+ emit extra->window->focusObjectChanged(extra->window->focusObject());
+ }
#ifndef QT_NO_GRAPHICSVIEW
QWExtra *topData = d_func()->extra;
@@ -6700,15 +6706,6 @@ void QWidget::clearFocus()
#endif
}
}
-
- // Since we've unconditionally cleared the focus_child of our parents, we need
- // to report this to the rest of Qt. Note that the focus_child is not the same
- // thing as the application's focusWidget, which is why this piece of code is
- // not inside the hasFocus() block above.
- if (QTLWExtra *extra = window()->d_func()->maybeTopData()) {
- if (extra->window)
- emit extra->window->focusObjectChanged(extra->window->focusObject());
- }
}