diff options
author | Janne Anttila <janne.anttila@digia.com> | 2010-04-08 05:29:21 (GMT) |
---|---|---|
committer | Janne Anttila <janne.anttila@digia.com> | 2010-04-08 06:20:11 (GMT) |
commit | 5ae2cbe99d06e1f1d037cd9a7868f2e1fd3f4c4c (patch) | |
tree | 0fa86f2a1b754ad8b03588bc310ca64cff26a9b4 | |
parent | a113de78774cebb53d0571b9e567ddee10acee78 (diff) | |
download | Qt-5ae2cbe99d06e1f1d037cd9a7868f2e1fd3f4c4c.zip Qt-5ae2cbe99d06e1f1d037cd9a7868f2e1fd3f4c4c.tar.gz Qt-5ae2cbe99d06e1f1d037cd9a7868f2e1fd3f4c4c.tar.bz2 |
Fixed focus and window activation events on Symbian when opening menu.
As described in QTBUG-8698, Qt for Symbian has been generating
incorrect focus and window activation events. This has happened since
launching menu from QSoftkeyManager with TryDisplayMenuBarL, invokes
eventually QSymbianControl::FocusChanged. But when the FocusChanged is
called menu being launched is not yet set to visible, meaning that
IsDisplayingMenuOrDialog returns false.
Because there is no way in platform to detect that menu is being
launhced, the fix is to add a new flag QS60Data, which can be used to
detect if FocusChanged event is received due to the fact that menu
is being constructed/launched.
Task-number: QTBUG-8698
* Fixes issues 2, 3 and 4
Reviewed-by: Sami Merila
-rw-r--r-- | src/gui/kernel/qapplication_s60.cpp | 3 | ||||
-rw-r--r-- | src/gui/kernel/qsoftkeymanager_s60.cpp | 19 | ||||
-rw-r--r-- | src/gui/kernel/qsoftkeymanager_s60_p.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qt_s60_p.h | 1 |
4 files changed, 20 insertions, 4 deletions
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index e986ce9..61beb4f 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -994,7 +994,7 @@ void QSymbianControl::FocusChanged(TDrawNow /* aDrawNow */) } #endif } else if (QApplication::activeWindow() == qwidget->window()) { - if (CCoeEnv::Static()->AppUi()->IsDisplayingMenuOrDialog()) { + if (CCoeEnv::Static()->AppUi()->IsDisplayingMenuOrDialog() || S60->menuBeingConstructed) { QWidget *fw = QApplication::focusWidget(); if (fw) { QFocusEvent event(QEvent::FocusOut, Qt::PopupFocusReason); @@ -1244,6 +1244,7 @@ void qt_init(QApplicationPrivate * /* priv */, int) } S60->avkonComponentsSupportTransparency = false; + S60->menuBeingConstructed = false; #ifdef Q_WS_S60 TUid KCRUidAvkon = { 0x101F876E }; diff --git a/src/gui/kernel/qsoftkeymanager_s60.cpp b/src/gui/kernel/qsoftkeymanager_s60.cpp index 7d643c2..2a9ac42 100644 --- a/src/gui/kernel/qsoftkeymanager_s60.cpp +++ b/src/gui/kernel/qsoftkeymanager_s60.cpp @@ -365,17 +365,30 @@ void QSoftKeyManagerPrivateS60::updateSoftKeys_sys() nativeContainer->DrawDeferred(); // 3.1 needs an extra invitation } +static void resetMenuBeingConstructed(TAny* /*aAny*/) +{ + S60->menuBeingConstructed = false; +} + +void QSoftKeyManagerPrivateS60::tryDisplayMenuBarL() +{ + CleanupStack::PushL(TCleanupItem(resetMenuBeingConstructed, NULL)); + S60->menuBeingConstructed = true; + S60->menuBar()->TryDisplayMenuBarL(); + CleanupStack::PopAndDestroy(); // Reset menuBeingConstructed to false in all cases +} + bool QSoftKeyManagerPrivateS60::handleCommand(int command) { QAction *action = realSoftKeyActions.value(command); if (action) { QVariant property = action->property(MENU_ACTION_PROPERTY); if (property.isValid() && property.toBool()) { - QT_TRAP_THROWING(S60->menuBar()->TryDisplayMenuBarL()); + QT_TRAP_THROWING(tryDisplayMenuBarL()); } else if (action->menu()) { // TODO: This is hack, in order to use exising QMenuBar implementation for Symbian // menubar needs to have widget to which it is associated. Since we want to associate - // menubar to action (which is inherited from QObejct), we create and associate QWidget + // menubar to action (which is inherited from QObject), we create and associate QWidget // to action and pass that for QMenuBar. This associates the menubar to action, and we // can have own menubar for each action. QWidget *actionContainer = action->property("_q_action_widget").value<QWidget*>(); @@ -394,7 +407,7 @@ bool QSoftKeyManagerPrivateS60::handleCommand(int command) action->setProperty("_q_action_widget", v); } qt_symbian_next_menu_from_action(actionContainer); - QT_TRAP_THROWING(S60->menuBar()->TryDisplayMenuBarL()); + QT_TRAP_THROWING(tryDisplayMenuBarL()); } else { Q_ASSERT(action->softKeyRole() != QAction::NoSoftKey); QWidget *actionParent = action->parentWidget(); diff --git a/src/gui/kernel/qsoftkeymanager_s60_p.h b/src/gui/kernel/qsoftkeymanager_s60_p.h index a5e5016..d14993c 100644 --- a/src/gui/kernel/qsoftkeymanager_s60_p.h +++ b/src/gui/kernel/qsoftkeymanager_s60_p.h @@ -78,6 +78,7 @@ public: bool handleCommand(int command); private: + void tryDisplayMenuBarL(); bool skipCbaUpdate(); void ensureCbaVisibilityAndResponsiviness(CEikButtonGroupContainer &cba); void clearSoftkeys(CEikButtonGroupContainer &cba); diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index 7c6b754..a714221 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -122,6 +122,7 @@ public: int qtOwnsS60Environment : 1; int supportsPremultipliedAlpha : 1; int avkonComponentsSupportTransparency : 1; + int menuBeingConstructed : 1; QApplication::QS60MainApplicationFactory s60ApplicationFactory; // typedef'ed pointer type static inline void updateScreenSize(); static inline RWsSession& wsSession(); |