summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qwidget_s60.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/kernel/qwidget_s60.cpp')
-rw-r--r--src/gui/kernel/qwidget_s60.cpp118
1 files changed, 60 insertions, 58 deletions
diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp
index d6e0a97..b0d405a 100644
--- a/src/gui/kernel/qwidget_s60.cpp
+++ b/src/gui/kernel/qwidget_s60.cpp
@@ -194,8 +194,8 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &)
}
if (jump && data.winid) {
- RWindow *const window = static_cast<RWindow *>(data.winid->DrawableWindow());
- window->Invalidate(TRect(0, 0, wrect.width(), wrect.height()));
+ RWindow *const window = static_cast<RWindow *>(data.winid->DrawableWindow());
+ window->Invalidate(TRect(0, 0, wrect.width(), wrect.height()));
}
}
@@ -367,7 +367,10 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de
} else {
stackingFlags = ECoeStackFlagStandard;
}
+ control->MakeVisible(false);
QT_TRAP_THROWING(control->ControlEnv()->AppUi()->AddToStackL(control, ECoeStackPriorityDefault, stackingFlags));
+ // Avoid keyboard focus to a hidden window.
+ control->setFocusSafely(false);
RDrawableWindow *const drawableWindow = control->DrawableWindow();
// Request mouse move events.
@@ -399,12 +402,23 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de
} else {
stackingFlags = ECoeStackFlagStandard;
}
+ control->MakeVisible(false);
QT_TRAP_THROWING(control->ControlEnv()->AppUi()->AddToStackL(control, ECoeStackPriorityDefault, stackingFlags));
+ // Avoid keyboard focus to a hidden window.
+ control->setFocusSafely(false);
q->setAttribute(Qt::WA_WState_Created);
int x, y, w, h;
data.crect.getRect(&x, &y, &w, &h);
control->SetRect(TRect(TPoint(x, y), TSize(w, h)));
+
+ RDrawableWindow *const drawableWindow = control->DrawableWindow();
+ // Request mouse move events.
+ drawableWindow->PointerFilter(EPointerFilterEnterExit
+ | EPointerFilterMove | EPointerFilterDrag, 0);
+
+ if (q->isVisible() && q->testAttribute(Qt::WA_Mapped))
+ activateSymbianWindow();
}
if (destroyw) {
@@ -420,7 +434,7 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de
void QWidgetPrivate::show_sys()
{
Q_Q(QWidget);
-
+
if (q->testAttribute(Qt::WA_OutsideWSRange))
return;
@@ -434,16 +448,15 @@ 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();
+
+ QSymbianControl *id = static_cast<QSymbianControl *>(q->internalWinId());
+
id->MakeVisible(true);
-
+
if(q->isWindow())
- id->SetFocus(true);
+ id->setFocusSafely(true);
// Force setting of the icon after window is made visible,
// this is needed even WA_SetWindowIcon is not set, as in that case we need
@@ -455,17 +468,35 @@ 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);
Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
deactivateWidgetCleanup();
- WId id = q->internalWinId();
+ QSymbianControl *id = static_cast<QSymbianControl *>(q->internalWinId());
if (id) {
- if(id->IsFocused()) // Avoid unnecessary calls to FocusChanged()
- id->SetFocus(false);
+ //Incorrect optimisation - for popup windows, Qt's focus is moved before
+ //hide_sys is called, resulting in the popup window keeping its elevated
+ //position in the CONE control stack.
+ //This can result in keyboard focus being in an invisible widget in some
+ //conditions - e.g. QTBUG-4733
+ //if(id->IsFocused()) // Avoid unnecessary calls to FocusChanged()
+ id->setFocusSafely(false);
id->MakeVisible(false);
if (QWidgetBackingStore *bs = maybeBackingStore())
bs->releaseBuffer();
@@ -481,36 +512,7 @@ void QWidgetPrivate::setFocus_sys()
Q_Q(QWidget);
if (q->testAttribute(Qt::WA_WState_Created) && q->window()->windowType() != Qt::Popup)
if (!q->effectiveWinId()->IsFocused()) // Avoid unnecessry calls to FocusChanged()
- q->effectiveWinId()->SetFocus(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 {
- QApplication::setActiveWindow(0);
- }
+ static_cast<QSymbianControl *>(q->effectiveWinId())->setFocusSafely(true);
}
void QWidgetPrivate::raise_sys()
@@ -597,7 +599,7 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
if (q->testAttribute(Qt::WA_DropSiteRegistered))
q->setAttribute(Qt::WA_DropSiteRegistered, false);
- WId old_winid = wasCreated ? data.winid : 0;
+ QSymbianControl *old_winid = static_cast<QSymbianControl *>(wasCreated ? data.winid : 0);
if ((q->windowType() == Qt::Desktop))
old_winid = 0;
setWinId(0);
@@ -607,7 +609,7 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
if (wasCreated && old_winid) {
old_winid->MakeVisible(false);
if (old_winid->IsFocused()) // Avoid unnecessary calls to FocusChanged()
- old_winid->SetFocus(false);
+ old_winid->setFocusSafely(false);
old_winid->SetParent(0);
}
@@ -1039,9 +1041,9 @@ QPoint QWidget::mapFromGlobal(const QPoint &pos) const
}
// Native window case
- const TPoint widgetScreenOffset = internalWinId()->PositionRelativeToScreen();
- const QPoint widgetPos = pos - QPoint(widgetScreenOffset.iX, widgetScreenOffset.iY);
- return widgetPos;
+ const TPoint widgetScreenOffset = internalWinId()->PositionRelativeToScreen();
+ const QPoint widgetPos = pos - QPoint(widgetScreenOffset.iX, widgetScreenOffset.iY);
+ return widgetPos;
}
void QWidget::setWindowState(Qt::WindowStates newstate)
@@ -1124,17 +1126,17 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
if ((oldstate & Qt::WindowMinimized) != (newstate & Qt::WindowMinimized)) {
if (newstate & Qt::WindowMinimized) {
if (isVisible()) {
- WId id = effectiveWinId();
+ QSymbianControl *id = static_cast<QSymbianControl *>(effectiveWinId());
if (id->IsFocused()) // Avoid unnecessary calls to FocusChanged()
- id->SetFocus(false);
+ id->setFocusSafely(false);
id->MakeVisible(false);
}
} else {
if (isVisible()) {
- WId id = effectiveWinId();
+ QSymbianControl *id = static_cast<QSymbianControl *>(effectiveWinId());
id->MakeVisible(true);
if (!id->IsFocused()) // Avoid unnecessary calls to FocusChanged()
- id->SetFocus(true);
+ id->setFocusSafely(true);
}
const QRect normalGeometry = geometry();
const QRect r = top->normalGeometry;
@@ -1161,7 +1163,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
if (!isWindow() && parentWidget())
parentWidget()->d_func()->invalidateBuffer(geometry());
d->deactivateWidgetCleanup();
- WId id = internalWinId();
+ QSymbianControl *id = static_cast<QSymbianControl *>(internalWinId());
if (testAttribute(Qt::WA_WState_Created)) {
#ifndef QT_NO_IM
@@ -1189,7 +1191,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
}
if (destroyWindow && !(windowType() == Qt::Desktop) && id) {
if (id->IsFocused()) // Avoid unnecessry calls to FocusChanged()
- id->SetFocus(false);
+ id->setFocusSafely(false);
id->ControlEnv()->AppUi()->RemoveFromStack(id);
// Hack to activate window under destroyed one. With this activation
@@ -1256,7 +1258,7 @@ void QWidget::grabMouse()
WId id = effectiveWinId();
id->SetPointerCapture(true);
QWidgetPrivate::mouseGrabber = this;
-
+
#ifndef QT_NO_CURSOR
QApplication::setOverrideCursor(cursor());
#endif
@@ -1299,8 +1301,8 @@ void QWidget::activateWindow()
QWidget *tlw = window();
if (tlw->isVisible()) {
window()->createWinId();
- WId id = tlw->internalWinId();
- id->SetFocus(true);
+ QSymbianControl *id = static_cast<QSymbianControl *>(tlw->internalWinId());
+ id->setFocusSafely(true);
}
}