diff options
| author | Pekka Vuorela <pekka.ta.vuorela@nokia.com> | 2012-03-01 16:54:50 +0200 |
|---|---|---|
| committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-22 16:13:21 +0100 |
| commit | 7e90df7bf5aafd09ea5ed8bcc370db6a8912d173 (patch) | |
| tree | af527348997c94a4b7362e99a0a4aecfaf144489 /src/widgets/kernel/qapplication.cpp | |
| parent | 045c79f5ed6960109f9ebf76775fa1289c5080b0 (diff) | |
FocusAboutToChange event to be send before focus changes
Focus change happen as: FocusAboutToChange event -> focus change
-> FocusOut event -> FocusIn event.
Input method need to have focus when calling commit(). Notification
on focus about to be lost allows QWindow implementations to commit in
time.
Also changes QWidget documentation to match code reality.
Change-Id: I17a8a374a33dd700909f79e370b42348869261a6
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Diffstat (limited to 'src/widgets/kernel/qapplication.cpp')
| -rw-r--r-- | src/widgets/kernel/qapplication.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 7441d55865b..ce57e2868d9 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1760,16 +1760,6 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason) } QWidget *prev = focus_widget; focus_widget = focus; -#ifndef QT_NO_IM - if (prev && ((reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason - && prev->testAttribute(Qt::WA_InputMethodEnabled)) - // Do reset the input context, in case the new focus widget won't accept keyboard input - // or it is not created fully yet. - || (focus_widget && (!focus_widget->testAttribute(Qt::WA_InputMethodEnabled) - || !focus_widget->testAttribute(Qt::WA_WState_Created))))) { - qApp->inputMethod()->reset(); - } -#endif //QT_NO_IM if(focus_widget) focus_widget->d_func()->setFocus_sys(); @@ -1798,7 +1788,6 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason) QApplication::sendEvent(that->style(), &in); } emit qApp->focusChanged(prev, focus_widget); - emit qApp->focusObjectChanged(focus_widget); } } } @@ -2051,6 +2040,14 @@ void QApplication::setActiveWindow(QWidget* act) } } + if (QApplicationPrivate::focus_widget) { + if (QApplicationPrivate::focus_widget->testAttribute(Qt::WA_InputMethodEnabled)) + qApp->inputMethod()->reset(); + + QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange, Qt::ActiveWindowFocusReason); + QApplication::sendEvent(QApplicationPrivate::focus_widget, &focusAboutToChange); + } + QApplicationPrivate::active_window = window; if (QApplicationPrivate::active_window) { |
