diff options
author | Paul Olav Tvete <paul.tvete@qt.io> | 2016-08-25 11:06:08 +0200 |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@qt.io> | 2016-08-25 11:06:32 +0200 |
commit | 07e37a79485405ce47a30e01d9168e7efa3dda7b (patch) | |
tree | da891fa3ca9cc9861aa79e6eee92aaa9501c0f72 /src/compositor | |
parent | 768a28b284fa806cba38f864c56ba2e2c37296f2 (diff) | |
parent | a40d9903ae99ce12f66a79347811a54378b1c083 (diff) |
Merge remote-tracking branch 'qt/dev' into 5.8
Change-Id: Ic0eda36fba20875c2077df2219943ddc57fbff4c
Diffstat (limited to 'src/compositor')
-rw-r--r-- | src/compositor/compositor_api/qwaylandoutput.cpp | 2 | ||||
-rw-r--r-- | src/compositor/compositor_api/qwaylandquickitem.cpp | 65 | ||||
-rw-r--r-- | src/compositor/compositor_api/qwaylandquickitem.h | 16 | ||||
-rw-r--r-- | src/compositor/compositor_api/qwaylandquickitem_p.h | 4 | ||||
-rw-r--r-- | src/compositor/compositor_api/qwaylandsurface.cpp | 24 | ||||
-rw-r--r-- | src/compositor/compositor_api/qwaylandsurface.h | 6 | ||||
-rw-r--r-- | src/compositor/compositor_api/qwaylandsurface_p.h | 2 | ||||
-rw-r--r-- | src/compositor/compositor_api/qwaylandview.cpp | 18 | ||||
-rw-r--r-- | src/compositor/compositor_api/qwaylandview.h | 8 | ||||
-rw-r--r-- | src/compositor/compositor_api/qwaylandview_p.h | 4 | ||||
-rw-r--r-- | src/compositor/extensions/qwaylandwlshellintegration.cpp | 10 | ||||
-rw-r--r-- | src/compositor/extensions/qwaylandwlshellintegration_p.h | 2 |
12 files changed, 117 insertions, 44 deletions
diff --git a/src/compositor/compositor_api/qwaylandoutput.cpp b/src/compositor/compositor_api/qwaylandoutput.cpp index 65bac3352..9e66b9a44 100644 --- a/src/compositor/compositor_api/qwaylandoutput.cpp +++ b/src/compositor/compositor_api/qwaylandoutput.cpp @@ -842,7 +842,7 @@ void QWaylandOutput::sendFrameCallbacks() Q_D(QWaylandOutput); for (int i = 0; i < d->surfaceViews.size(); i++) { const QWaylandSurfaceViewMapper &surfacemapper = d->surfaceViews.at(i); - if (surfacemapper.surface && surfacemapper.surface->isMapped()) { + if (surfacemapper.surface && surfacemapper.surface->hasContent()) { if (!surfacemapper.has_entered) { surfaceEnter(surfacemapper.surface); d->surfaceViews[i].has_entered = true; diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp index 2b24938fa..6ea44feac 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.cpp +++ b/src/compositor/compositor_api/qwaylandquickitem.cpp @@ -777,13 +777,70 @@ void QWaylandQuickItem::setSubsurfaceHandler(QObject *handler) } /*! + * \property QWaylandQuickItem::output + * + * This property holds the output on which this item is displayed. + */ +QWaylandOutput *QWaylandQuickItem::output() const +{ + Q_D(const QWaylandQuickItem); + return d->view->output(); +} + +void QWaylandQuickItem::setOutput(QWaylandOutput *output) +{ + Q_D(QWaylandQuickItem); + d->view->setOutput(output); +} + +/*! + * \property QWaylandQuickItem::bufferLocked + * + * This property holds whether the item's buffer is currently locked. As long as + * the buffer is locked, it will not be released and returned to the client. + * + * The default is false. + */ +bool QWaylandQuickItem::isBufferLocked() const +{ + Q_D(const QWaylandQuickItem); + return d->view->isBufferLocked(); +} + +void QWaylandQuickItem::setBufferLocked(bool locked) +{ + Q_D(QWaylandQuickItem); + d->view->setBufferLocked(locked); +} + +/*! + * \property bool QWaylandQuickItem::allowDiscardFrontBuffer + * + * By default, the item locks the current buffer until a new buffer is available + * and updatePaintNode() is called. Set this property to true to allow Qt to release the buffer + * immediately when the throttling view is no longer using it. This is useful for items that have + * slow update intervals. + */ +bool QWaylandQuickItem::allowDiscardFrontBuffer() const +{ + Q_D(const QWaylandQuickItem); + return d->view->allowDiscardFrontBuffer(); +} + +void QWaylandQuickItem::setAllowDiscardFrontBuffer(bool discard) +{ + Q_D(QWaylandQuickItem); + d->view->setAllowDiscardFrontBuffer(discard); +} + +/*! * \internal */ void QWaylandQuickItem::handleSurfaceChanged() { Q_D(QWaylandQuickItem); if (d->oldSurface) { - disconnect(d->oldSurface, &QWaylandSurface::mappedChanged, this, &QWaylandQuickItem::surfaceMappedChanged); + disconnect(d->oldSurface, &QWaylandSurface::hasContentChanged, this, &QWaylandQuickItem::surfaceMappedChanged); disconnect(d->oldSurface, &QWaylandSurface::parentChanged, this, &QWaylandQuickItem::parentChanged); disconnect(d->oldSurface, &QWaylandSurface::sizeChanged, this, &QWaylandQuickItem::updateSize); disconnect(d->oldSurface, &QWaylandSurface::bufferScaleChanged, this, &QWaylandQuickItem::updateSize); @@ -796,7 +853,7 @@ void QWaylandQuickItem::handleSurfaceChanged() #endif } if (QWaylandSurface *newSurface = d->view->surface()) { - connect(newSurface, &QWaylandSurface::mappedChanged, this, &QWaylandQuickItem::surfaceMappedChanged); + connect(newSurface, &QWaylandSurface::hasContentChanged, this, &QWaylandQuickItem::surfaceMappedChanged); connect(newSurface, &QWaylandSurface::parentChanged, this, &QWaylandQuickItem::parentChanged); connect(newSurface, &QWaylandSurface::sizeChanged, this, &QWaylandQuickItem::updateSize); connect(newSurface, &QWaylandSurface::bufferScaleChanged, this, &QWaylandQuickItem::updateSize); @@ -1068,9 +1125,9 @@ void QWaylandQuickItem::updateInputMethod(Qt::InputMethodQueries queries) QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) { Q_D(QWaylandQuickItem); - const bool mapped = surface() && surface()->isMapped() && d->view->currentBuffer().hasBuffer(); + const bool hasContent = surface() && surface()->hasContent() && d->view->currentBuffer().hasBuffer(); - if (!mapped || !d->paintEnabled) { + if (!hasContent || !d->paintEnabled) { delete oldNode; return 0; } diff --git a/src/compositor/compositor_api/qwaylandquickitem.h b/src/compositor/compositor_api/qwaylandquickitem.h index 0a6c78919..5c89d58b4 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.h +++ b/src/compositor/compositor_api/qwaylandquickitem.h @@ -58,7 +58,6 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickItem : public QQuickItem { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandQuickItem) - Q_PROPERTY(QWaylandView *view READ view CONSTANT) Q_PROPERTY(QWaylandCompositor *compositor READ compositor) Q_PROPERTY(QWaylandSurface *surface READ surface WRITE setSurface NOTIFY surfaceChanged) Q_PROPERTY(bool paintEnabled READ paintEnabled WRITE setPaintEnabled) @@ -68,6 +67,9 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickItem : public QQuickItem Q_PROPERTY(bool focusOnClick READ focusOnClick WRITE setFocusOnClick NOTIFY focusOnClickChanged) Q_PROPERTY(bool sizeFollowsSurface READ sizeFollowsSurface WRITE setSizeFollowsSurface NOTIFY sizeFollowsSurfaceChanged) Q_PROPERTY(QObject *subsurfaceHandler READ subsurfaceHandler WRITE setSubsurfaceHandler NOTIFY subsurfaceHandlerChanged) + Q_PROPERTY(QWaylandOutput *output READ output WRITE setOutput NOTIFY outputChanged) + Q_PROPERTY(bool bufferLocked READ isBufferLocked WRITE setBufferLocked NOTIFY bufferLockedChanged) + Q_PROPERTY(bool allowDiscardFrontBuffer READ allowDiscardFrontBuffer WRITE setAllowDiscardFrontBuffer NOTIFY allowDiscardFrontBufferChanged) public: QWaylandQuickItem(QQuickItem *parent = nullptr); ~QWaylandQuickItem(); @@ -108,6 +110,15 @@ public: QObject *subsurfaceHandler() const; void setSubsurfaceHandler(QObject*); + QWaylandOutput *output() const; + void setOutput(QWaylandOutput *output); + + bool isBufferLocked() const; + void setBufferLocked(bool locked); + + bool allowDiscardFrontBuffer() const; + void setAllowDiscardFrontBuffer(bool discard); + protected: void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; @@ -160,6 +171,9 @@ Q_SIGNALS: void mouseRelease(); void sizeFollowsSurfaceChanged(); void subsurfaceHandlerChanged(); + void outputChanged(); + void bufferLockedChanged(); + void allowDiscardFrontBufferChanged(); protected: QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) Q_DECL_OVERRIDE; diff --git a/src/compositor/compositor_api/qwaylandquickitem_p.h b/src/compositor/compositor_api/qwaylandquickitem_p.h index fca0d9d29..8c242ac88 100644 --- a/src/compositor/compositor_api/qwaylandquickitem_p.h +++ b/src/compositor/compositor_api/qwaylandquickitem_p.h @@ -139,9 +139,11 @@ public: QObject::connect(view.data(), &QWaylandView::surfaceChanged, q, &QWaylandQuickItem::surfaceChanged); QObject::connect(view.data(), &QWaylandView::surfaceChanged, q, &QWaylandQuickItem::handleSurfaceChanged); QObject::connect(view.data(), &QWaylandView::surfaceDestroyed, q, &QWaylandQuickItem::surfaceDestroyed); + QObject::connect(view.data(), &QWaylandView::outputChanged, q, &QWaylandQuickItem::outputChanged); + QObject::connect(view.data(), &QWaylandView::bufferLockedChanged, q, &QWaylandQuickItem::bufferLockedChanged); + QObject::connect(view.data(), &QWaylandView::allowDiscardFrontBufferChanged, q, &QWaylandQuickItem::allowDiscardFrontBuffer); } - void setInputEventsEnabled(bool enable) { Q_Q(QWaylandQuickItem); diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp index 98f6a1d28..09eba77e0 100644 --- a/src/compositor/compositor_api/qwaylandsurface.cpp +++ b/src/compositor/compositor_api/qwaylandsurface.cpp @@ -129,7 +129,7 @@ QWaylandSurfacePrivate::QWaylandSurfacePrivate() , bufferScale(1) , isCursorSurface(false) , destroyed(false) - , mapped(false) + , hasContent(false) , isInitialized(false) , contentOrientation(Qt::PrimaryOrientation) , inputMethodControl(Q_NULLPTR) @@ -193,9 +193,9 @@ void QWaylandSurfacePrivate::notifyViewsAboutDestruction() foreach (QWaylandView *view, views) { QWaylandViewPrivate::get(view)->markSurfaceAsDestroyed(q); } - if (mapped) { - mapped = false; - emit q->mappedChanged(); + if (hasContent) { + hasContent = false; + emit q->hasContentChanged(); } } @@ -342,10 +342,10 @@ void QWaylandSurfacePrivate::setBackBuffer(QtWayland::SurfaceBuffer *b, const QR emit q->damaged(damage); - bool oldMapped = mapped; - mapped = QtWayland::SurfaceBuffer::hasContent(buffer); - if (oldMapped != mapped) - emit q->mappedChanged(); + bool oldHasContent = hasContent; + hasContent = QtWayland::SurfaceBuffer::hasContent(buffer); + if (oldHasContent != hasContent) + emit q->hasContentChanged(); if (!pending.offset.isNull()) emit q->offsetForNextFrame(pending.offset); @@ -484,20 +484,20 @@ QWaylandClient *QWaylandSurface::client() const } /*! - * \qmlproperty bool QtWaylandCompositor::WaylandSurface::isMapped + * \qmlproperty bool QtWaylandCompositor::WaylandSurface::hasContent * * This property holds whether the WaylandSurface has content. */ /*! - * \property QWaylandSurface::isMapped + * \property QWaylandSurface::hasContent * * This property holds whether the QWaylandSurface has content. */ -bool QWaylandSurface::isMapped() const +bool QWaylandSurface::hasContent() const { Q_D(const QWaylandSurface); - return d->mapped; + return d->hasContent; } /*! diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h index 13cf0e437..ed358fefa 100644 --- a/src/compositor/compositor_api/qwaylandsurface.h +++ b/src/compositor/compositor_api/qwaylandsurface.h @@ -82,7 +82,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandSurface : public QWaylandObject Q_PROPERTY(int bufferScale READ bufferScale NOTIFY bufferScaleChanged) Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation NOTIFY contentOrientationChanged) Q_PROPERTY(QWaylandSurface::Origin origin READ origin NOTIFY originChanged) - Q_PROPERTY(bool isMapped READ isMapped NOTIFY mappedChanged) + Q_PROPERTY(bool hasContent READ hasContent NOTIFY hasContentChanged) Q_PROPERTY(bool cursorSurface READ isCursorSurface WRITE markAsCursorSurface) public: @@ -105,7 +105,7 @@ public: bool setRole(QWaylandSurfaceRole *role, wl_resource *errorResource, uint32_t errorCode); QWaylandSurfaceRole *role() const; - bool isMapped() const; + bool hasContent() const; QSize size() const; int bufferScale() const; @@ -144,7 +144,7 @@ protected: QWaylandSurface(QWaylandSurfacePrivate &dptr); Q_SIGNALS: - void mappedChanged(); + void hasContentChanged(); void damaged(const QRegion &rect); void parentChanged(QWaylandSurface *newParent, QWaylandSurface *oldParent); void childAdded(QWaylandSurface *child); diff --git a/src/compositor/compositor_api/qwaylandsurface_p.h b/src/compositor/compositor_api/qwaylandsurface_p.h index e37179cc6..0596b61ba 100644 --- a/src/compositor/compositor_api/qwaylandsurface_p.h +++ b/src/compositor/compositor_api/qwaylandsurface_p.h @@ -171,7 +171,7 @@ public: //member variables int bufferScale; bool isCursorSurface; bool destroyed; - bool mapped; + bool hasContent; bool isInitialized; Qt::ScreenOrientation contentOrientation; QWindow::Visibility visibility; diff --git a/src/compositor/compositor_api/qwaylandview.cpp b/src/compositor/compositor_api/qwaylandview.cpp index f6e086523..f605de55c 100644 --- a/src/compositor/compositor_api/qwaylandview.cpp +++ b/src/compositor/compositor_api/qwaylandview.cpp @@ -215,7 +215,7 @@ void QWaylandView::attach(const QWaylandBufferRef &ref, const QRegion &damage) * * If this view is set as its surface's throttling view, discardCurrentBuffer() * will be called on all views of the same surface for which the - * \l{QWaylandView::discardFrontBuffers}{discardFrontBuffers} + * \l{QWaylandView::allowDiscardFrontBuffer}{allowDiscardFrontBuffer} * property is set to true and the current buffer is the same as the * throttling view's current buffer. * @@ -236,7 +236,7 @@ bool QWaylandView::advance() if (d->surface && d->surface->throttlingView() == this) { Q_FOREACH (QWaylandView *view, d->surface->views()) { - if (view != this && view->discardFrontBuffers() && view->d_func()->currentBuffer == d->currentBuffer) + if (view != this && view->allowDiscardFrontBuffer() && view->d_func()->currentBuffer == d->currentBuffer) view->discardCurrentBuffer(); } } @@ -314,24 +314,24 @@ void QWaylandView::setBufferLocked(bool locked) } /*! - * \property bool QWaylandView::discardFrontBuffers + * \property bool QWaylandView::allowDiscardFrontBuffer * * By default, the view locks the current buffer until advance() is called. Set this property * to true to allow Qt to release the buffer when the throttling view is no longer using it. */ -bool QWaylandView::discardFrontBuffers() const +bool QWaylandView::allowDiscardFrontBuffer() const { Q_D(const QWaylandView); - return d->discardFrontBuffers; + return d->allowDiscardFrontBuffer; } -void QWaylandView::setDiscardFrontBuffers(bool discard) +void QWaylandView::setAllowDiscardFrontBuffer(bool discard) { Q_D(QWaylandView); - if (d->discardFrontBuffers == discard) + if (d->allowDiscardFrontBuffer == discard) return; - d->discardFrontBuffers = discard; - emit discardFrontBuffersChanged(); + d->allowDiscardFrontBuffer = discard; + emit allowDiscardFrontBufferChanged(); } /*! diff --git a/src/compositor/compositor_api/qwaylandview.h b/src/compositor/compositor_api/qwaylandview.h index a6c5dce90..6247e06e2 100644 --- a/src/compositor/compositor_api/qwaylandview.h +++ b/src/compositor/compositor_api/qwaylandview.h @@ -57,7 +57,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandView : public QObject Q_PROPERTY(QWaylandSurface *surface READ surface WRITE setSurface NOTIFY surfaceChanged) Q_PROPERTY(QWaylandOutput *output READ output WRITE setOutput NOTIFY outputChanged) Q_PROPERTY(bool bufferLocked READ isBufferLocked WRITE setBufferLocked NOTIFY bufferLockedChanged) - Q_PROPERTY(bool discardFrontBuffers READ discardFrontBuffers WRITE setDiscardFrontBuffers NOTIFY discardFrontBuffersChanged) + Q_PROPERTY(bool allowDiscardFrontBuffer READ allowDiscardFrontBuffer WRITE setAllowDiscardFrontBuffer NOTIFY allowDiscardFrontBufferChanged) public: QWaylandView(QObject *renderObject = nullptr, QObject *parent = nullptr); virtual ~QWaylandView(); @@ -79,8 +79,8 @@ public: bool isBufferLocked() const; void setBufferLocked(bool locked); - bool discardFrontBuffers() const; - void setDiscardFrontBuffers(bool discard); + bool allowDiscardFrontBuffer() const; + void setAllowDiscardFrontBuffer(bool discard); struct wl_resource *surfaceResource() const; @@ -89,7 +89,7 @@ Q_SIGNALS: void surfaceDestroyed(); void outputChanged(); void bufferLockedChanged(); - void discardFrontBuffersChanged(); + void allowDiscardFrontBufferChanged(); }; QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandview_p.h b/src/compositor/compositor_api/qwaylandview_p.h index 768ebd4bc..d9fd352ed 100644 --- a/src/compositor/compositor_api/qwaylandview_p.h +++ b/src/compositor/compositor_api/qwaylandview_p.h @@ -72,7 +72,7 @@ public: , bufferLocked(false) , broadcastRequestedPositionChanged(false) , forceAdvanceSucceed(false) - , discardFrontBuffers(false) + , allowDiscardFrontBuffer(false) { } void markSurfaceAsDestroyed(QWaylandSurface *surface); @@ -89,7 +89,7 @@ public: bool bufferLocked; bool broadcastRequestedPositionChanged; bool forceAdvanceSucceed; - bool discardFrontBuffers; + bool allowDiscardFrontBuffer; }; QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandwlshellintegration.cpp b/src/compositor/extensions/qwaylandwlshellintegration.cpp index ee4783ba9..1acc01dd7 100644 --- a/src/compositor/extensions/qwaylandwlshellintegration.cpp +++ b/src/compositor/extensions/qwaylandwlshellintegration.cpp @@ -111,8 +111,8 @@ void WlShellIntegration::handleSetPopup(QWaylandSeat *seat, QWaylandSurface *par if (!popupShellSurfaces.contains(m_shellSurface)) { popupShellSurfaces.append(m_shellSurface); - QObject::connect(m_shellSurface->surface(), &QWaylandSurface::mappedChanged, - this, &WlShellIntegration::handleSurfaceUnmapped); + QObject::connect(m_shellSurface->surface(), &QWaylandSurface::hasContentChanged, + this, &WlShellIntegration::handleSurfaceHasContentChanged); } } @@ -120,8 +120,8 @@ void WlShellIntegration::handlePopupClosed() { handlePopupRemoved(); if (m_shellSurface) - QObject::disconnect(m_shellSurface->surface(), &QWaylandSurface::mappedChanged, - this, &WlShellIntegration::handleSurfaceUnmapped); + QObject::disconnect(m_shellSurface->surface(), &QWaylandSurface::hasContentChanged, + this, &WlShellIntegration::handleSurfaceHasContentChanged); } void WlShellIntegration::handlePopupRemoved() @@ -141,7 +141,7 @@ void WlShellIntegration::handleShellSurfaceDestroyed() m_shellSurface = nullptr; } -void WlShellIntegration::handleSurfaceUnmapped() +void WlShellIntegration::handleSurfaceHasContentChanged() { if (!m_shellSurface || !m_shellSurface->surface()->size().isEmpty()) return; diff --git a/src/compositor/extensions/qwaylandwlshellintegration_p.h b/src/compositor/extensions/qwaylandwlshellintegration_p.h index 69bbbcd9c..f68040cdf 100644 --- a/src/compositor/extensions/qwaylandwlshellintegration_p.h +++ b/src/compositor/extensions/qwaylandwlshellintegration_p.h @@ -69,7 +69,7 @@ private Q_SLOTS: void handleStartResize(QWaylandSeat *seat, QWaylandWlShellSurface::ResizeEdge edges); void handleSetPopup(QWaylandSeat *seat, QWaylandSurface *parent, const QPoint &relativeToParent); void handleShellSurfaceDestroyed(); - void handleSurfaceUnmapped(); + void handleSurfaceHasContentChanged(); void adjustOffsetForNextFrame(const QPointF &offset); private: |