diff options
Diffstat (limited to 'src/quick/items/qquickwindow.cpp')
-rw-r--r-- | src/quick/items/qquickwindow.cpp | 128 |
1 files changed, 60 insertions, 68 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 894059e193..a993889c45 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -50,8 +50,6 @@ #include <QtQuick/private/qsgrenderer_p.h> #include <QtQuick/private/qsgtexture_p.h> -#include <QtQuick/private/qsgflashnode_p.h> - #include <private/qsgrenderloop_p.h> #include <private/qquickanimatorcontroller_p.h> @@ -218,6 +216,7 @@ void QQuickWindow::exposeEvent(QExposeEvent *) /*! \reimp */ void QQuickWindow::resizeEvent(QResizeEvent *) { + d_func()->windowManager->resize(this); } /*! \reimp */ @@ -416,12 +415,13 @@ void QQuickWindowPrivate::init(QQuickWindow *c) contentItemPrivate->flags |= QQuickItem::ItemIsFocusScope; windowManager = QSGRenderLoop::instance(); - context = windowManager->sceneGraphContext(); + QSGContext *sg = windowManager->sceneGraphContext(); + context = windowManager->createRenderContext(sg); q->setSurfaceType(QWindow::OpenGLSurface); - q->setFormat(context->defaultSurfaceFormat()); + q->setFormat(sg->defaultSurfaceFormat()); animationController = new QQuickAnimatorController(); - animationController->window = q; + animationController->m_window = q; QObject::connect(context, SIGNAL(initialized()), q, SIGNAL(sceneGraphInitialized()), Qt::DirectConnection); QObject::connect(context, SIGNAL(invalidated()), q, SIGNAL(sceneGraphInvalidated()), Qt::DirectConnection); @@ -666,14 +666,18 @@ void QQuickWindowPrivate::setFocusInScope(QQuickItem *scope, QQuickItem *item, Q QVarLengthArray<QQuickItem *, 20> changed; // Does this change the active focus? - if (item == contentItem || (scopePrivate->activeFocus && item->isEnabled())) { + if (item == contentItem || scopePrivate->activeFocus) { QQuickItem *oldActiveFocusItem = 0; oldActiveFocusItem = activeFocusItem; - newActiveFocusItem = item; - while (newActiveFocusItem->isFocusScope() - && newActiveFocusItem->scopedFocusItem() - && newActiveFocusItem->scopedFocusItem()->isEnabled()) { - newActiveFocusItem = newActiveFocusItem->scopedFocusItem(); + if (item->isEnabled()) { + newActiveFocusItem = item; + while (newActiveFocusItem->isFocusScope() + && newActiveFocusItem->scopedFocusItem() + && newActiveFocusItem->scopedFocusItem()->isEnabled()) { + newActiveFocusItem = newActiveFocusItem->scopedFocusItem(); + } + } else { + newActiveFocusItem = scope; } if (oldActiveFocusItem) { @@ -772,23 +776,24 @@ void QQuickWindowPrivate::clearFocusInScope(QQuickItem *scope, QQuickItem *item, oldActiveFocusItem = activeFocusItem; newActiveFocusItem = scope; - Q_ASSERT(oldActiveFocusItem); - #ifndef QT_NO_IM qApp->inputMethod()->commit(); #endif activeFocusItem = 0; - QFocusEvent event(QEvent::FocusOut, reason); - q->sendEvent(oldActiveFocusItem, &event); - QQuickItem *afi = oldActiveFocusItem; - while (afi && afi != scope) { - if (QQuickItemPrivate::get(afi)->activeFocus) { - QQuickItemPrivate::get(afi)->activeFocus = false; - changed << afi; + if (oldActiveFocusItem) { + QFocusEvent event(QEvent::FocusOut, reason); + q->sendEvent(oldActiveFocusItem, &event); + + QQuickItem *afi = oldActiveFocusItem; + while (afi && afi != scope) { + if (QQuickItemPrivate::get(afi)->activeFocus) { + QQuickItemPrivate::get(afi)->activeFocus = false; + changed << afi; + } + afi = afi->parentItem(); } - afi = afi->parentItem(); } } @@ -821,6 +826,11 @@ void QQuickWindowPrivate::clearFocusInScope(QQuickItem *scope, QQuickItem *item, notifyFocusChangesRecur(changed.data(), changed.count() - 1); } +void QQuickWindowPrivate::clearFocusObject() +{ + contentItem->setFocus(false, Qt::OtherFocusReason); +} + void QQuickWindowPrivate::notifyFocusChangesRecur(QQuickItem **items, int remaining) { QPointer<QQuickItem> item(*items); @@ -862,7 +872,7 @@ void QQuickWindowPrivate::cleanup(QSGNode *n) /*! \qmltype Window \instantiates QQuickWindow - \inqmlmodule QtQuick.Window 2 + \inqmlmodule QtQuick.Window \ingroup qtquick-visual \brief Creates a new top-level window @@ -2136,7 +2146,7 @@ bool QQuickWindowPrivate::dragOverThreshold(qreal d, Qt::Axis axis, QMouseEvent } /*! - \qmlproperty list<Object> QtQuick.Window::Window::data + \qmlproperty list<Object> Window::data \default The data property allows you to freely mix visual children, resources @@ -2345,10 +2355,6 @@ void QQuickWindowPrivate::updateDirtyNodes() void QQuickWindowPrivate::updateDirtyNode(QQuickItem *item) { -#ifdef QML_RUNTIME_TESTING - bool didFlash = false; -#endif - QQuickItemPrivate *itemPriv = QQuickItemPrivate::get(item); quint32 dirty = itemPriv->dirtyAttributes; itemPriv->dirtyAttributes = 0; @@ -2572,19 +2578,6 @@ void QQuickWindowPrivate::updateDirtyNode(QQuickItem *item) } #endif -#ifdef QML_RUNTIME_TESTING - if (itemPriv->sceneGraphContext()->isFlashModeEnabled()) { - QSGFlashNode *flash = new QSGFlashNode(); - flash->setRect(item->boundingRect()); - itemPriv->childContainerNode()->appendChildNode(flash); - didFlash = true; - } - Q_Q(QQuickWindow); - if (didFlash) { - q->maybeUpdate(); - } -#endif - } void QQuickWindow::maybeUpdate() @@ -2624,9 +2617,7 @@ void QQuickWindow::setTransientParent_helper(QQuickWindow *window) QOpenGLContext *QQuickWindow::openglContext() const { Q_D(const QQuickWindow); - if (d->context->isReady()) - return d->context->glContext(); - return 0; + return d->context->openglContext(); } /*! @@ -2672,7 +2663,7 @@ QOpenGLContext *QQuickWindow::openglContext() const /*! \qmltype CloseEvent \instantiates QQuickCloseEvent - \inqmlmodule QtQuick.Window 2 + \inqmlmodule QtQuick.Window \ingroup qtquick-visual \brief Notification that a \l Window is about to be closed \since 5.1 @@ -2685,7 +2676,7 @@ QOpenGLContext *QQuickWindow::openglContext() const */ /*! - \qmlproperty bool QtQuick.Window::CloseEvent::accepted + \qmlproperty bool CloseEvent::accepted This property indicates whether the application will allow the user to close the window. It is true by default. @@ -2700,7 +2691,7 @@ QOpenGLContext *QQuickWindow::openglContext() const */ /*! - \qmlsignal QtQuick.Window::closing(CloseEvent close) + \qmlsignal closing(CloseEvent close) \since 5.1 This signal is emitted when the user tries to close the window. @@ -2809,7 +2800,7 @@ QOpenGLFramebufferObject *QQuickWindow::renderTarget() const Grabs the contents of the window and returns it as an image. It is possible to call the grabWindow() function when the window is not - visible. This requires that the window is \l{QWindow::create} {created} + visible. This requires that the window is \l{QWindow::create()} {created} and has a valid size and that no other QQuickWindow instances are rendering in the same process. @@ -2822,7 +2813,7 @@ QImage QQuickWindow::grabWindow() Q_D(QQuickWindow); if (!isVisible()) { - if (d->context->isReady()) { + if (d->context->openglContext()) { qWarning("QQuickWindow::grabWindow: scene graph already in use"); return QImage(); } @@ -2834,6 +2825,7 @@ QImage QQuickWindow::grabWindow() QOpenGLContext context; context.setFormat(requestedFormat()); + context.setShareContext(QSGContext::sharedOpenGLContext()); context.create(); context.makeCurrent(this); d->context->initialize(&context); @@ -3019,7 +3011,7 @@ QSGTexture *QQuickWindow::createTextureFromImage(const QImage &image) const QSGTexture *QQuickWindow::createTextureFromImage(const QImage &image, CreateTextureOptions options) const { Q_D(const QQuickWindow); - if (d->context && d->context->isReady()) { + if (d->context && d->context->openglContext()) { if (options & TextureCanUseAtlas) return d->context->createTexture(image); else @@ -3047,7 +3039,7 @@ QSGTexture *QQuickWindow::createTextureFromImage(const QImage &image, CreateText QSGTexture *QQuickWindow::createTextureFromId(uint id, const QSize &size, CreateTextureOptions options) const { Q_D(const QQuickWindow); - if (d->context && d->context->isReady()) { + if (d->context && d->context->openglContext()) { QSGPlainTexture *texture = new QSGPlainTexture(); texture->setTextureId(id); texture->setHasAlphaChannel(options & TextureHasAlphaChannel); @@ -3060,7 +3052,7 @@ QSGTexture *QQuickWindow::createTextureFromId(uint id, const QSize &size, Create } /*! - \qmlproperty color QtQuick.Window::Window::color + \qmlproperty color Window::color The background color for the window. @@ -3189,7 +3181,7 @@ void QQuickWindow::resetOpenGLState() } /*! - \qmlproperty string QtQuick.Window::Window::title + \qmlproperty string Window::title The window's title in the windowing system. @@ -3200,7 +3192,7 @@ void QQuickWindow::resetOpenGLState() */ /*! - \qmlproperty Qt::WindowModality QtQuick.Window::Window::modality + \qmlproperty Qt::WindowModality Window::modality The modality of the window. @@ -3210,7 +3202,7 @@ void QQuickWindow::resetOpenGLState() */ /*! - \qmlproperty Qt::WindowFlags QtQuick.Window::Window::flags + \qmlproperty Qt::WindowFlags Window::flags The window flags of the window. @@ -3223,10 +3215,10 @@ void QQuickWindow::resetOpenGLState() */ /*! - \qmlproperty int QtQuick.Window::Window::x - \qmlproperty int QtQuick.Window::Window::y - \qmlproperty int QtQuick.Window::Window::width - \qmlproperty int QtQuick.Window::Window::height + \qmlproperty int Window::x + \qmlproperty int Window::y + \qmlproperty int Window::width + \qmlproperty int Window::height Defines the window's position and size. @@ -3241,8 +3233,8 @@ void QQuickWindow::resetOpenGLState() */ /*! - \qmlproperty int QtQuick.Window::Window::minimumWidth - \qmlproperty int QtQuick.Window::Window::minimumHeight + \qmlproperty int Window::minimumWidth + \qmlproperty int Window::minimumHeight \since 5.1 Defines the window's minimum size. @@ -3252,8 +3244,8 @@ void QQuickWindow::resetOpenGLState() */ /*! - \qmlproperty int QtQuick.Window::Window::maximumWidth - \qmlproperty int QtQuick.Window::Window::maximumHeight + \qmlproperty int Window::maximumWidth + \qmlproperty int Window::maximumHeight \since 5.1 Defines the window's maximum size. @@ -3263,7 +3255,7 @@ void QQuickWindow::resetOpenGLState() */ /*! - \qmlproperty bool QtQuick.Window::Window::visible + \qmlproperty bool Window::visible Whether the window is visible on the screen. @@ -3273,7 +3265,7 @@ void QQuickWindow::resetOpenGLState() */ /*! - \qmlproperty QWindow::Visibility QtQuick.Window::Window::visibility + \qmlproperty QWindow::Visibility Window::visibility The screen-occupation state of the window. @@ -3293,7 +3285,7 @@ void QQuickWindow::resetOpenGLState() */ /*! - \qmlproperty Qt::ScreenOrientation QtQuick.Window::Window::contentOrientation + \qmlproperty Qt::ScreenOrientation Window::contentOrientation This is a hint to the window manager in case it needs to display additional content like popups, dialogs, status bars, or similar @@ -3314,7 +3306,7 @@ void QQuickWindow::resetOpenGLState() */ /*! - \qmlproperty real QtQuick.Window::Window::opacity + \qmlproperty real Window::opacity The opacity of the window. @@ -3331,7 +3323,7 @@ void QQuickWindow::resetOpenGLState() */ /*! - \qmlproperty Item QtQuick.Window::Window::activeFocusItem + \qmlproperty Item Window::activeFocusItem \since 5.1 The item which currently has active focus or \c null if there is @@ -3339,7 +3331,7 @@ void QQuickWindow::resetOpenGLState() */ /*! - \qmlproperty QtQuick.Window::Window::active + \qmlproperty Window::active \since 5.1 The active status of the window. |