diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2010-08-04 11:48:43 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2010-08-04 12:04:32 (GMT) |
commit | 7992c2d3a4413082fd40e4099f735d95d522b0f3 (patch) | |
tree | 75b37c50356b40508d64e1eb6bf85a9fc0a0d4e4 /src/gui/kernel/qwidget_qpa.cpp | |
parent | 34a3b5d2a0c86a534b9d7b036fb1aaf1eb1c65b1 (diff) | |
download | Qt-7992c2d3a4413082fd40e4099f735d95d522b0f3.zip Qt-7992c2d3a4413082fd40e4099f735d95d522b0f3.tar.gz Qt-7992c2d3a4413082fd40e4099f735d95d522b0f3.tar.bz2 |
Make QWidget::setPlatformWindowFormat recreate platformWindow
if the platformWindow is visible. Also had to make sure that the
QGLContext of a QGLWidget was recreated.
Diffstat (limited to 'src/gui/kernel/qwidget_qpa.cpp')
-rw-r--r-- | src/gui/kernel/qwidget_qpa.cpp | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp index ef53004..e11f1fc 100644 --- a/src/gui/kernel/qwidget_qpa.cpp +++ b/src/gui/kernel/qwidget_qpa.cpp @@ -54,22 +54,26 @@ QT_BEGIN_NAMESPACE static QPlatformScreen *qt_screenForWidget(const QWidget *w); -void setParentForChildrenOfWidget(QPlatformWindow *window, const QWidget *widget) +void q_createNativeChildrenAndSetParent(QPlatformWindow *parentWindow, const QWidget *parentWidget) { - QObjectList children = widget->children(); + QObjectList children = parentWidget->children(); for (int i = 0; i < children.size(); i++) { if (children.at(i)->isWidgetType()) { const QWidget *childWidget = qobject_cast<const QWidget *>(children.at(i)); if (childWidget) { // should not be necessary + if (childWidget->testAttribute(Qt::WA_NativeWindow)) { + if (!childWidget->platformWindow()) + childWidget->winId(); + } if (childWidget->platformWindow()) { - childWidget->platformWindow()->setParent(window); - childWidget->platformWindow()->setWindowFlags(Qt::SubWindow); + childWidget->platformWindow()->setParent(parentWindow); } else { - setParentForChildrenOfWidget(window,childWidget); + q_createNativeChildrenAndSetParent(parentWindow,childWidget); } } } } + } void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow) @@ -79,7 +83,6 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO Q_UNUSED(window); Q_UNUSED(initializeWindow); Q_UNUSED(destroyOldWindow); - // XXX Qt::WindowFlags flags = data.window_flags; @@ -102,12 +105,13 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO setWinId(q->platformWindow()->winId()); - //first check children. then find who for parent. - setParentForChildrenOfWidget(platformWindow,q); + //first check children. and create them if necessary + q_createNativeChildrenAndSetParent(q->platformWindow(),q); + + //if we we have a parent, then set correct parent; if (QWidget *nativeParent = q->nativeParentWidget()) { if (nativeParent->platformWindow()) { platformWindow->setParent(nativeParent->platformWindow()); - platformWindow->setWindowFlags(Qt::SubWindow); } } @@ -143,6 +147,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows) if (topData) { delete topData->platformWindow; topData->platformWindow = 0; + d->data.winid = 0; } } else { if (parentWidget() && parentWidget()->testAttribute(Qt::WA_WState_Created)) { @@ -176,7 +181,6 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) QWidget * parentWithWindow = newparent->platformWindow()? newparent : newparent->nativeParentWidget(); if (parentWithWindow && parentWithWindow->platformWindow()) { q->platformWindow()->setParent(parentWithWindow->platformWindow()); - q->platformWindow()->setWindowFlags(Qt::SubWindow); } } @@ -615,7 +619,7 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) if (isResize) { QResizeEvent e(r.size(), olds); QApplication::sendEvent(q, &e); - if (q->isWindow()) + if (q->platformWindow()) q->update(); } } else { // not visible @@ -743,9 +747,18 @@ QPlatformWindow *QWidget::platformWindow() const void QWidget::setPlatformWindowFormat(const QPlatformWindowFormat &format) { - Q_D(QWidget); - QTLWExtra *topData = d->topData(); - topData->platformWindowFormat = format; + if (isWindow() || testAttribute(Qt::WA_NativeWindow)) { + Q_D(QWidget); + QTLWExtra *topData = d->topData(); + topData->platformWindowFormat = format; + if (testAttribute(Qt::WA_WState_Created)) { + bool wasVisible = testAttribute(Qt::WA_WState_Visible); + destroy(); + d->create_sys(0,true,true); + if (wasVisible) + topData->platformWindow->setVisible(true); + } + } } QPlatformWindowFormat QWidget::platformWindowFormat() const |