From fafd16474aee5bbf47ee37e1ba739f3b3ceb9c33 Mon Sep 17 00:00:00 2001 From: Jani Hautakangas Date: Thu, 1 Oct 2009 11:30:20 +0300 Subject: Fix for Symbian window activation/focus problem. When dialog is shown on top of a top level window, the focus does not get back to top level window when dialog is closed. This is a fix for that. Reviewed-by: Shane Kearns --- src/gui/kernel/qwidget_s60.cpp | 59 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 05db8ca..6ba693c 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -490,6 +490,65 @@ void QWidgetPrivate::setFocus_sys() static_cast(q->effectiveWinId())->setFocusSafely(true); } +void QWidgetPrivate::handleSymbianDeferredFocusChanged() +{ + Q_Q(QWidget); + WId control = q->internalWinId(); + + if (!control) { + // This could happen if the widget was reparented, while the focuschange + // was in the event queue. + return; + } + + if (control->IsFocused()) { + QApplication::setActiveWindow(q); +#ifdef Q_WS_S60 + // If widget is fullscreen, hide status pane and button container + // otherwise show them. + CEikStatusPane* statusPane = S60->statusPane(); + CEikButtonGroupContainer* buttonGroup = S60->buttonGroupContainer(); + bool isFullscreen = q->windowState() & Qt::WindowFullScreen; + if (statusPane && (statusPane->IsVisible() == isFullscreen)) + statusPane->MakeVisible(!isFullscreen); + if (buttonGroup && (buttonGroup->IsVisible() == isFullscreen)) + buttonGroup->MakeVisible(!isFullscreen); +#endif + } else { + + QWidget *nextActiveWindow = 0; + + if (q->isWindow()) { + + // Try to activate possible parent window first. + QWidget *parent = q->parentWidget(); + if(parent + && parent->isWindow() + && parent->isVisible() + && !parent->isActiveWindow()) { + + nextActiveWindow = parent; + } else { + // Activate next possible top level window. + QWidgetList topLevelWidgets = QApplication::topLevelWidgets(); + for (int i = 0; i < topLevelWidgets.size(); ++i) { + QWidget *w = topLevelWidgets.at(i); + if (w != q && w->isVisible() && !w->isActiveWindow()) { + nextActiveWindow = w; + break; + } + } + } + + if (nextActiveWindow) + nextActiveWindow->activateWindow(); + } + + QApplication::setActiveWindow(nextActiveWindow); + } +>>>>>>> Fix for Symbian window activation/focus problem.:src/gui/kernel/qwidget_s60.cpp +} + void QWidgetPrivate::raise_sys() { Q_Q(QWidget); -- cgit v0.12