summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qapplication_s60.cpp
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2009-09-30 14:22:38 (GMT)
committeraxis <qt-info@nokia.com>2009-09-30 14:22:38 (GMT)
commitd4d02daeb0bea195f3ed045cfbbfe7e604420f10 (patch)
tree270eda2164f38afcdaa485bdc4935a4ed8eea9fe /src/gui/kernel/qapplication_s60.cpp
parent68f709fb180af94af259a9afb873b9548c97c0fb (diff)
parent5dadf715a40189c94235e8445dc79f0270b0a87e (diff)
downloadQt-d4d02daeb0bea195f3ed045cfbbfe7e604420f10.zip
Qt-d4d02daeb0bea195f3ed045cfbbfe7e604420f10.tar.gz
Qt-d4d02daeb0bea195f3ed045cfbbfe7e604420f10.tar.bz2
Merge branch 'focusFixes' into 4.6
Conflicts: src/gui/kernel/qwidget_p.h src/gui/kernel/qwidget_s60.cpp
Diffstat (limited to 'src/gui/kernel/qapplication_s60.cpp')
-rw-r--r--src/gui/kernel/qapplication_s60.cpp47
1 files changed, 45 insertions, 2 deletions
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index 992e754..27c7c94 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -91,6 +91,8 @@ extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp
QWidget *qt_button_down = 0; // widget got last button-down
+QSymbianControl *QSymbianControl::lastFocusedControl = 0;
+
QS60Data* qGlobalS60Data()
{
return qt_s60Data();
@@ -350,6 +352,7 @@ QSymbianControl::~QSymbianControl()
{
if (S60->curWin == this)
S60->curWin = 0;
+ setFocusSafely(false);
S60->appUi()->RemoveFromStack(this);
delete m_longTapDetector;
}
@@ -860,8 +863,23 @@ void QSymbianControl::FocusChanged(TDrawNow /* aDrawNow */)
|| (qwidget->windowType() & Qt::Popup) == Qt::Popup)
return;
- QEvent *deferredFocusEvent = new QEvent(QEvent::SymbianDeferredFocusChanged);
- QApplication::postEvent(qwidget, deferredFocusEvent);
+ if (IsFocused() && IsVisible()) {
+ QApplication::setActiveWindow(qwidget->window());
+#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 = qwidget->windowState() & Qt::WindowFullScreen;
+ if (statusPane && (statusPane->IsVisible() == isFullscreen))
+ statusPane->MakeVisible(!isFullscreen);
+ if (buttonGroup && (buttonGroup->IsVisible() == isFullscreen))
+ buttonGroup->MakeVisible(!isFullscreen);
+#endif
+ } else if (QApplication::activeWindow() == qwidget->window()) {
+ QApplication::setActiveWindow(0);
+ }
+ // else { We don't touch the active window unless we were explicitly activated or deactivated }
}
void QSymbianControl::HandleResourceChange(int resourceType)
@@ -905,6 +923,31 @@ TTypeUid::Ptr QSymbianControl::MopSupplyObject(TTypeUid id)
return CCoeControl::MopSupplyObject(id);
}
+void QSymbianControl::setFocusSafely(bool focus)
+{
+ // The stack hack in here is very unfortunate, but it is the only way to ensure proper
+ // focus in Symbian. If this is not executed, the control which happens to be on
+ // the top of the stack may randomly be assigned focus by Symbian, for example
+ // when creating new windows (specifically in CCoeAppUi::HandleStackChanged()).
+ if (focus) {
+ S60->appUi()->RemoveFromStack(this);
+ // Symbian doesn't automatically remove focus from the last focused control, so we need to
+ // remember it and clear focus ourselves.
+ if (lastFocusedControl && lastFocusedControl != this)
+ lastFocusedControl->SetFocus(false);
+ QT_TRAP_THROWING(S60->appUi()->AddToStackL(this,
+ ECoeStackPriorityDefault + 1, ECoeStackFlagStandard)); // Note the + 1
+ lastFocusedControl = this;
+ this->SetFocus(true);
+ } else {
+ S60->appUi()->RemoveFromStack(this);
+ QT_TRAP_THROWING(S60->appUi()->AddToStackL(this,
+ ECoeStackPriorityDefault, ECoeStackFlagStandard));
+ lastFocusedControl = 0;
+ this->SetFocus(false);
+ }
+}
+
/*!
\typedef QApplication::QS60MainApplicationFactory