diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2011-04-27 11:59:11 +0200 |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-04-28 15:39:36 +0200 |
commit | dc897ca7d92d76bd8490a812a3da343a326577a2 (patch) | |
tree | 9b027b3a6515da4c40e171fb8d26babb1519d095 /src/gui | |
parent | d04aee22e7acfd7bd0ad2219c4ff29cba0f5cbc4 (diff) |
Lazy init of QWindow
(cherry picked from commit a2c884b6d2fcc77f6aa5e7aaa0aa329f5bef0bbd)
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qwindow_qpa.cpp | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/src/gui/kernel/qwindow_qpa.cpp b/src/gui/kernel/qwindow_qpa.cpp index a01ecd2430..e011c919d5 100644 --- a/src/gui/kernel/qwindow_qpa.cpp +++ b/src/gui/kernel/qwindow_qpa.cpp @@ -74,7 +74,7 @@ public: Qt::WindowFlags windowFlags; QWindow::SurfaceType surfaceType; - + QWindow *parentWindow; QPlatformWindow *platformWindow; bool visible; QWindowFormat requestedFormat; @@ -133,6 +133,15 @@ void QWindow::create() d->windowFlags = d->platformWindow->setWindowFlags(d->windowFlags); } Q_ASSERT(d->platformWindow); + + QObjectList childObjects = children(); + for (int i = 0; i < childObjects.size(); i ++) { + QObject *object = childObjects.at(i); + if(object->isWindowType()) { + QWindow *window = static_cast<QWindow *>(object); + window->setParent(this); + } + } } WId QWindow::winId() const @@ -143,22 +152,35 @@ WId QWindow::winId() const return d->platformWindow->winId(); } +/** + Sets the parent Window. This will lead to the windowing system managing the clip of the window, so it will be clipped to the parent window. + Setting parent to be 0(NULL) means map it as a top level window. If the parent window has grabbed its window system resources, then the current window will also grab its window system resources. + **/ + void QWindow::setParent(QWindow *parent) { Q_D(QWindow); - if (QObject::parent() == parent) { + + if (d->parent == parent) return; - } - //How should we support lazy init when setting parent - if (!parent->d_func()->platformWindow) { - const_cast<QWindow *>(parent)->create(); - } - if(!d->platformWindow) { - create(); - } - d->platformWindow->setParent(parent->d_func()->platformWindow); QObject::setParent(parent); + + if (parent) { + if (parent->d_func()->platformWindow) { + if(!d->platformWindow) { + create(); + } + d->platformWindow->setParent(parent->d_func()->platformWindow); + d->parent = parent; + } + } else { + d->parent = 0; + if (d->parentWindow) { + d->platformWindow->setParent(0); + } + } + } void QWindow::setWindowFormat(const QWindowFormat &format) |