Skip to content

Commit

Permalink
Remove QWaylandView from the QML API
Browse files Browse the repository at this point in the history
QWaylandQuickItem already encapsulates the view. Also rename
the confusing 'discardFrontBuffers' property to
'allowDiscardFrontBuffer'

Change-Id: Ibd74ad54bfe3d5187c2ed91ff0378b45e144e109
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
  • Loading branch information
paulolav committed Aug 22, 2016
1 parent b7075b7 commit aee2b77
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 41 deletions.
2 changes: 1 addition & 1 deletion examples/wayland/multi-output/qml/GridScreen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ WaylandOutput {
height: gridView.cellHeight
sizeFollowsSurface: false
inputEventsEnabled: false
view.discardFrontBuffers: true
allowDiscardFrontBuffer: true
MouseArea {
anchors.fill: parent
onClicked: item.surface.activated()
Expand Down
2 changes: 1 addition & 1 deletion examples/wayland/multi-output/qml/ShellChrome.qml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ShellSurfaceItem {
id: rootChrome

onSurfaceDestroyed: {
view.bufferLocked = true;
bufferLocked = true;
destroyAnimation.start();
}

Expand Down
2 changes: 1 addition & 1 deletion examples/wayland/pure-qml/qml/Chrome.qml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ShellSurfaceItem {
id: rootChrome

onSurfaceDestroyed: {
view.bufferLocked = true;
bufferLocked = true;
destroyAnimation.start();
}

Expand Down
57 changes: 57 additions & 0 deletions src/compositor/compositor_api/qwaylandquickitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,63 @@ 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
*/
Expand Down
16 changes: 15 additions & 1 deletion src/compositor/compositor_api/qwaylandquickitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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();
Expand Down Expand Up @@ -108,6 +110,15 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickItem : public QQuickItem
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;
Expand Down Expand Up @@ -160,6 +171,9 @@ private Q_SLOTS:
void mouseRelease();
void sizeFollowsSurfaceChanged();
void subsurfaceHandlerChanged();
void outputChanged();
void bufferLockedChanged();
void allowDiscardFrontBufferChanged();
protected:
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) Q_DECL_OVERRIDE;

Expand Down
4 changes: 3 additions & 1 deletion src/compositor/compositor_api/qwaylandquickitem_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,11 @@ class QWaylandQuickItemPrivate : public QQuickItemPrivate
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);
Expand Down
18 changes: 9 additions & 9 deletions src/compositor/compositor_api/qwaylandview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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();
}
}
Expand Down Expand Up @@ -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();
}

/*!
Expand Down
8 changes: 4 additions & 4 deletions src/compositor/compositor_api/qwaylandview.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -79,8 +79,8 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandView : public QObject
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;

Expand All @@ -89,7 +89,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandView : public QObject
void surfaceDestroyed();
void outputChanged();
void bufferLockedChanged();
void discardFrontBuffersChanged();
void allowDiscardFrontBufferChanged();
};

QT_END_NAMESPACE
Expand Down
4 changes: 2 additions & 2 deletions src/compositor/compositor_api/qwaylandview_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class QWaylandViewPrivate : public QObjectPrivate
, bufferLocked(false)
, broadcastRequestedPositionChanged(false)
, forceAdvanceSucceed(false)
, discardFrontBuffers(false)
, allowDiscardFrontBuffer(false)
{ }

void markSurfaceAsDestroyed(QWaylandSurface *surface);
Expand All @@ -89,7 +89,7 @@ class QWaylandViewPrivate : public QObjectPrivate
bool bufferLocked;
bool broadcastRequestedPositionChanged;
bool forceAdvanceSucceed;
bool discardFrontBuffers;
bool allowDiscardFrontBuffer;
};

QT_END_NAMESPACE
Expand Down
41 changes: 21 additions & 20 deletions src/imports/compositor/plugins.qmltypes
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Module {
exports: ["QtWayland.Compositor/WaylandClient 1.0"]
isCreatable: false
exportMetaObjectRevisions: [0]
Property { name: "compositor"; type: "QWaylandCompositor"; isReadonly: true; isPointer: true }
Property { name: "userId"; type: "qlonglong"; isReadonly: true }
Property { name: "groupId"; type: "qlonglong"; isReadonly: true }
Property { name: "processId"; type: "qlonglong"; isReadonly: true }
Expand All @@ -26,7 +27,7 @@ Module {
}
Component {
name: "QWaylandCompositor"
prototype: "QObject"
prototype: "QWaylandObject"
exports: ["QtWayland.Compositor/WaylandCompositorBase 1.0"]
isCreatable: false
exportMetaObjectRevisions: [0]
Expand Down Expand Up @@ -64,6 +65,14 @@ Module {
Parameter { name: "newDevice"; type: "QWaylandSeat"; isPointer: true }
Parameter { name: "oldDevice"; type: "QWaylandSeat"; isPointer: true }
}
Signal {
name: "outputAdded"
Parameter { name: "output"; type: "QWaylandOutput"; isPointer: true }
}
Signal {
name: "outputRemoved"
Parameter { name: "output"; type: "QWaylandOutput"; isPointer: true }
}
Method { name: "processWaylandEvents" }
Method {
name: "destroyClientForSurface"
Expand All @@ -81,7 +90,7 @@ Module {
}
Component {
name: "QWaylandCompositorExtension"
prototype: "QObject"
prototype: "QWaylandObject"
exports: ["QtWayland.Compositor/WaylandExtension 1.0"]
isCreatable: false
exportMetaObjectRevisions: [0]
Expand All @@ -105,7 +114,7 @@ Module {
}
Component {
name: "QWaylandSeat"
prototype: "QObject"
prototype: "QWaylandObject"
exports: ["QtWayland.Compositor/WaylandSeat 1.0"]
isCreatable: false
exportMetaObjectRevisions: [0]
Expand Down Expand Up @@ -148,9 +157,10 @@ Module {
Property { name: "windowSystemCursorEnabled"; type: "bool" }
Signal { name: "hoveredChanged" }
}
Component { name: "QWaylandObject"; prototype: "QObject" }
Component {
name: "QWaylandOutput"
prototype: "QObject"
prototype: "QWaylandObject"
exports: ["QtWayland.Compositor/WaylandOutputBase 1.0"]
isCreatable: false
exportMetaObjectRevisions: [0]
Expand Down Expand Up @@ -233,7 +243,6 @@ Module {
prototype: "QQuickItem"
exports: ["QtWayland.Compositor/WaylandQuickItem 1.0"]
exportMetaObjectRevisions: [0]
Property { name: "view"; type: "QWaylandView"; isReadonly: true; isPointer: true }
Property { name: "compositor"; type: "QWaylandCompositor"; isReadonly: true; isPointer: true }
Property { name: "surface"; type: "QWaylandSurface"; isPointer: true }
Property { name: "paintEnabled"; type: "bool" }
Expand All @@ -243,6 +252,8 @@ Module {
Property { name: "focusOnClick"; type: "bool" }
Property { name: "sizeFollowsSurface"; type: "bool" }
Property { name: "subsurfaceHandler"; type: "QObject"; isPointer: true }
Property { name: "bufferLocked"; type: "bool" }
Property { name: "allowDiscardFrontBuffer"; type: "bool" }
Signal { name: "surfaceDestroyed" }
Signal {
name: "mouseMove"
Expand Down Expand Up @@ -312,7 +323,7 @@ Module {
}
Component {
name: "QWaylandSurface"
prototype: "QObject"
prototype: "QWaylandObject"
exports: ["QtWayland.Compositor/WaylandSurfaceBase 1.0"]
isCreatable: false
exportMetaObjectRevisions: [0]
Expand Down Expand Up @@ -392,19 +403,6 @@ Module {
exportMetaObjectRevisions: [0]
Property { name: "data"; type: "QObject"; isList: true; isReadonly: true }
}
Component {
name: "QWaylandView"
prototype: "QObject"
exports: ["QtWayland.Compositor/WaylandView 1.0"]
isCreatable: false
exportMetaObjectRevisions: [0]
Property { name: "renderObject"; type: "QObject"; isReadonly: true; isPointer: true }
Property { name: "surface"; type: "QWaylandSurface"; isPointer: true }
Property { name: "output"; type: "QWaylandOutput"; isPointer: true }
Property { name: "bufferLocked"; type: "bool" }
Property { name: "discardFrontBuffers"; type: "bool" }
Signal { name: "surfaceDestroyed" }
}
Component {
name: "QWaylandWlShell"
prototype: "QWaylandCompositorExtension"
Expand Down Expand Up @@ -615,6 +613,8 @@ Module {
Parameter { name: "seat"; type: "QWaylandSeat"; isPointer: true }
Parameter { name: "edges"; type: "ResizeEdge" }
}
Signal { name: "setTopLevel" }
Signal { name: "setTransient" }
Signal { name: "setMaximized" }
Signal { name: "unsetMaximized" }
Signal {
Expand Down Expand Up @@ -692,7 +692,6 @@ Module {
Parameter { name: "hotspotX"; type: "QVariant" }
Parameter { name: "hotspotY"; type: "QVariant" }
}
Property { name: "view"; type: "QWaylandView"; isReadonly: true; isPointer: true }
Property { name: "compositor"; type: "QWaylandCompositor"; isReadonly: true; isPointer: true }
Property { name: "surface"; type: "QWaylandSurface"; isPointer: true }
Property { name: "paintEnabled"; type: "bool" }
Expand All @@ -702,6 +701,8 @@ Module {
Property { name: "focusOnClick"; type: "bool" }
Property { name: "sizeFollowsSurface"; type: "bool" }
Property { name: "subsurfaceHandler"; type: "QObject"; isPointer: true }
Property { name: "bufferLocked"; type: "bool" }
Property { name: "allowDiscardFrontBuffer"; type: "bool" }
Signal { name: "surfaceDestroyed" }
Signal {
name: "mouseMove"
Expand Down
1 change: 0 additions & 1 deletion src/imports/compositor/qwaylandquickcompositorplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ class QWaylandCompositorPlugin : public QQmlExtensionPlugin
qmlRegisterUncreatableType<QWaylandCompositorExtension>(uri, 1, 0, "WaylandExtension", QObject::tr("Cannot create instance of WaylandExtension"));
qmlRegisterUncreatableType<QWaylandClient>(uri, 1, 0, "WaylandClient", QObject::tr("Cannot create instance of WaylandClient"));
qmlRegisterUncreatableType<QWaylandOutput>(uri, 1, 0, "WaylandOutputBase", QObject::tr("Cannot create instance of WaylandOutputBase, use WaylandOutput instead"));
qmlRegisterUncreatableType<QWaylandView>(uri, 1, 0, "WaylandView", QObject::tr("Cannot create instance of WaylandView, it can be retrieved by accessor on WaylandQuickItem"));
qmlRegisterUncreatableType<QWaylandSeat>(uri, 1, 0, "WaylandSeat", QObject::tr("Cannot create instance of WaylandSeat"));
qmlRegisterUncreatableType<QWaylandDrag>(uri, 1, 0, "WaylandDrag", QObject::tr("Cannot create instance of WaylandDrag"));
qmlRegisterUncreatableType<QWaylandCompositor>(uri, 1, 0, "WaylandCompositorBase", QObject::tr("Cannot create instance of WaylandCompositorBase, use WaylandCompositor instead"));
Expand Down

0 comments on commit aee2b77

Please sign in to comment.