From f00aeb98d457b16ac90e98f3dd18bf4f53fefeb3 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 1 Oct 2009 15:41:28 +0100 Subject: Immediately activate native windows created by calling winId() on an already-visible widget If a widget is visible when winId() is called on it, this change means that the newly-created native window will be activated immediately. --- src/gui/kernel/qwidget_p.h | 1 + src/gui/kernel/qwidget_s60.cpp | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 2a81689..1d67b6c 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -295,6 +295,7 @@ public: #ifdef Q_OS_SYMBIAN void handleSymbianDeferredFocusChanged(); void setSoftKeys_sys(const QList &softkeys); + void activateSymbianWindow(); #endif void raise_sys(); diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index d6e0a97..c1d7262 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -405,6 +405,9 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de int x, y, w, h; data.crect.getRect(&x, &y, &w, &h); control->SetRect(TRect(TPoint(x, y), TSize(w, h))); + + if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) + activateSymbianWindow(); } if (destroyw) { @@ -436,10 +439,9 @@ void QWidgetPrivate::show_sys() if (q->internalWinId()) { WId id = q->internalWinId(); - if (!extra->activated) { - QT_TRAP_THROWING(id->ActivateL()); - extra->activated = 1; - } + if (!extra->activated) + activateSymbianWindow(); + id->MakeVisible(true); if(q->isWindow()) @@ -455,6 +457,19 @@ void QWidgetPrivate::show_sys() invalidateBuffer(q->rect()); } +void QWidgetPrivate::activateSymbianWindow() +{ + Q_Q(QWidget); + + Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); + Q_ASSERT(q->testAttribute(Qt::WA_Mapped)); + Q_ASSERT(!extra->activated); + + WId id = q->internalWinId(); + QT_TRAP_THROWING(id->ActivateL()); + extra->activated = 1; +} + void QWidgetPrivate::hide_sys() { Q_Q(QWidget); -- cgit v0.12