diff options
author | Jarno Malmari <ext-jarno.malmari@nokia.com> | 2010-08-25 13:06:28 +0300 |
---|---|---|
committer | Daniel d'Andrada <daniel.dandrada@nokia.com> | 2010-09-06 14:02:14 +0300 |
commit | 9b38b94757b174c66917b27e61fbafe470465090 (patch) | |
tree | 8492ec16469975a7cab668e01bc487bd875f5a28 | |
parent | 047ab0f06f4728af359d57e2dad4b599446c4952 (diff) |
Fixes: Workaround for bug NB#186278.
RevBy: Michael Hasselmann, Dominik Kapusta, Daniel d'Andrada
Details: Can be reverted when the bug is fixed.
-rw-r--r-- | src/corelib/scene/mscenemanager.cpp | 31 | ||||
-rw-r--r-- | src/corelib/widgets/core/mwidget.cpp | 11 |
2 files changed, 33 insertions, 9 deletions
diff --git a/src/corelib/scene/mscenemanager.cpp b/src/corelib/scene/mscenemanager.cpp index 92e7ad39..5ff7ea90 100644 --- a/src/corelib/scene/mscenemanager.cpp +++ b/src/corelib/scene/mscenemanager.cpp @@ -75,8 +75,21 @@ namespace { //! This is a guess for the SIP close timeout since there is no general way of getting it. const int SoftwareInputPanelHideTimer = 500; -} + void setParentItemWithoutIncorrectRefocusing(QGraphicsItem *item, QGraphicsItem *parent) + { + // FIXME: Workaround for bug NB#186278. + QGraphicsItem *focused = item->focusItem(); + if (focused && !focused->hasFocus()) { + focused->setFlag(QGraphicsItem::ItemIsFocusable, false); + item->setParentItem(parent); + focused->setFlag(QGraphicsItem::ItemIsFocusable, true); + } else { + // This alone should suffice. + item->setParentItem(parent); + } + } +} void MSceneManagerPrivate::init(MScene *scene) { @@ -467,8 +480,9 @@ void MSceneManagerPrivate::_q_dislocateSceneWindow(MSceneWindow *sceneWindow, QGraphicsItem *childOfDisplacementItem = sceneWindow->d_func()->effect ? sceneWindow->d_func()->effect : sceneWindow; - di->setParentItem(childOfDisplacementItem->parentItem()); - childOfDisplacementItem->setParentItem(displacementItem); + + setParentItemWithoutIncorrectRefocusing(displacementItem, childOfDisplacementItem->parentItem()); + setParentItemWithoutIncorrectRefocusing(childOfDisplacementItem, displacementItem); // Don't change the z value. displacementItem->setZValue(childOfDisplacementItem->zValue()); @@ -488,7 +502,7 @@ void MSceneManagerPrivate::_q_undoSceneWindowDislocation(MSceneWindow *sceneWind QGraphicsItem *childOfDisplacementItem = sceneWindow->d_func()->effect ? sceneWindow->d_func()->effect : sceneWindow; - childOfDisplacementItem->setParentItem(displacementItem->parentItem()); + setParentItemWithoutIncorrectRefocusing(childOfDisplacementItem, displacementItem->parentItem()); delete displacementItem; displacementItem = 0; @@ -522,7 +536,8 @@ void MSceneManagerPrivate::addUnmanagedSceneWindow(MSceneWindow *sceneWindow) // add scene window to the scene // Now its sceneManager() method will return the correct result. // It will also transfer the ownership of the scene window to the scene. - sceneWindow->setParentItem(rootElementForSceneWindowType(sceneWindow->windowType())); + + setParentItemWithoutIncorrectRefocusing(sceneWindow, rootElementForSceneWindowType(sceneWindow->windowType())); sceneWindow->setZValue(zForWindowType(sceneWindow->windowType())); @@ -610,11 +625,11 @@ MSceneLayerEffect *MSceneManagerPrivate::createLayerEffectForWindow(MSceneWindow QGraphicsItem *effectParent = window->parentItem() ? window->parentItem() : rootElementForSceneWindowType(window->windowType()); - effect->setParentItem(effectParent); + setParentItemWithoutIncorrectRefocusing(effect, effectParent); effect->setZValue(zForWindowType(window->windowType())); // Add window as child of the effect - window->setParentItem(effect); + setParentItemWithoutIncorrectRefocusing(window, effect); window->d_func()->effect = effect; return effect; @@ -625,7 +640,7 @@ void MSceneManagerPrivate::destroyLayerEffectForWindow(MSceneWindow *sceneWindow MSceneLayerEffect *&effect = sceneWindow->d_func()->effect; if (effect) { - sceneWindow->setParentItem(effect->parentItem()); + setParentItemWithoutIncorrectRefocusing(sceneWindow, effect->parentItem()); delete effect; effect = 0; diff --git a/src/corelib/widgets/core/mwidget.cpp b/src/corelib/widgets/core/mwidget.cpp index 9e545597..917d7365 100644 --- a/src/corelib/widgets/core/mwidget.cpp +++ b/src/corelib/widgets/core/mwidget.cpp @@ -485,7 +485,16 @@ void MWidget::setVisible(bool visible) // Only show if the layout is not hiding this if (!d->layoutHidden) { - QGraphicsWidget::setVisible(visible); + + // FIXME: Workaround for bug NB#186278. + QGraphicsItem *focused = focusItem(); + if (visible && focused && !focused->hasFocus()) { + focused->setFlag(QGraphicsItem::ItemIsFocusable, false); + QGraphicsWidget::setVisible(true); + focused->setFlag(QGraphicsItem::ItemIsFocusable, true); + } else { + QGraphicsWidget::setVisible(visible); + } // Propagate visibility events QGraphicsView *graphicsView = d->fetchGraphicsView(); |