summaryrefslogtreecommitdiffstats
path: root/src/compositor/compositor_api
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@theqtcompany.com>2015-08-24 16:51:01 +0200
committerJørgen Lind <jorgen.lind@theqtcompany.com>2015-08-28 13:10:33 +0200
commitd2d70779224b067f6035f431319036054272ce65 (patch)
tree0ea297990553ff75cf82fb840d59dde903903dcd /src/compositor/compositor_api
parent88f821e189bd1d4d4550c1864f622ca7df2a7c34 (diff)
Make the default wl_shell available from QML
This finaly ties together how to use QWaylandQuickItems with different shells It was required to decouple QWaylandView from the QWaylandQuickItem since QML doesn't play to well with muliple inheritance. The QWaylandQuickItem can be retrieved from the QWaylandView which is now conveniently a QObject. Also the QWaylandQuickItem owns the QWaylandView. This architecture also leaves room for creating a QWaylandWidget :) Change-Id: Ib8a00e6f17f0f1bfc3ff244753f021c76db22cb1
Diffstat (limited to 'src/compositor/compositor_api')
-rw-r--r--src/compositor/compositor_api/compositor_api.pri4
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor.cpp3
-rw-r--r--src/compositor/compositor_api/qwaylandinputpanel.cpp2
-rw-r--r--src/compositor/compositor_api/qwaylandkeyboard.cpp4
-rw-r--r--src/compositor/compositor_api/qwaylandoutput.cpp18
-rw-r--r--src/compositor/compositor_api/qwaylandoutput_p.h3
-rw-r--r--src/compositor/compositor_api/qwaylandoutputspace.h2
-rw-r--r--src/compositor/compositor_api/qwaylandoutputspace_p.h6
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem.cpp143
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem.h38
-rw-r--r--src/compositor/compositor_api/qwaylandquicksurface.h1
-rw-r--r--src/compositor/compositor_api/qwaylandshell.cpp91
-rw-r--r--src/compositor/compositor_api/qwaylandshell.h91
-rw-r--r--src/compositor/compositor_api/qwaylandview.cpp138
-rw-r--r--src/compositor/compositor_api/qwaylandview.h50
-rw-r--r--src/compositor/compositor_api/qwaylandview_p.h21
16 files changed, 169 insertions, 446 deletions
diff --git a/src/compositor/compositor_api/compositor_api.pri b/src/compositor/compositor_api/compositor_api.pri
index b8d97b205..281976710 100644
--- a/src/compositor/compositor_api/compositor_api.pri
+++ b/src/compositor/compositor_api/compositor_api.pri
@@ -23,7 +23,7 @@ HEADERS += \
compositor_api/qwaylanddestroylistener.h \
compositor_api/qwaylanddestroylistener_p.h \
compositor_api/qwaylandview.h \
- compositor_api/qwaylandview_p.h
+ compositor_api/qwaylandview_p.h \
SOURCES += \
compositor_api/qwaylandcompositor.cpp \
@@ -39,7 +39,7 @@ SOURCES += \
compositor_api/qwaylandbufferref.cpp \
compositor_api/qwaylandoutputspace.cpp \
compositor_api/qwaylanddestroylistener.cpp \
- compositor_api/qwaylandview.cpp
+ compositor_api/qwaylandview.cpp \
QT += core-private
diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp
index 16724a40e..f798539e2 100644
--- a/src/compositor/compositor_api/qwaylandcompositor.cpp
+++ b/src/compositor/compositor_api/qwaylandcompositor.cpp
@@ -53,13 +53,13 @@
#include "wayland_wrapper/qwldatadevice_p.h"
#include "wayland_wrapper/qwldatadevicemanager_p.h"
-#include "hardware_integration/qwlhwintegration_p.h"
#include "hardware_integration/qwlclientbufferintegration_p.h"
#include "hardware_integration/qwlclientbufferintegrationfactory_p.h"
#include "hardware_integration/qwlserverbufferintegration_p.h"
#include "hardware_integration/qwlserverbufferintegrationfactory_p.h"
#include "extensions/qwaylandwindowmanagerextension.h"
+#include "extensions/qwlhwintegration_p.h"
#include "qwaylandxkb.h"
#include "qwaylandshmformathelper.h"
@@ -130,7 +130,6 @@ public:
QWaylandCompositorPrivate::QWaylandCompositorPrivate(QWaylandCompositor *compositor)
: display(wl_display_create())
#if defined (QT_COMPOSITOR_WAYLAND_GL)
- , hw_integration(0)
, client_buffer_integration(0)
, server_buffer_integration(0)
#endif
diff --git a/src/compositor/compositor_api/qwaylandinputpanel.cpp b/src/compositor/compositor_api/qwaylandinputpanel.cpp
index 0376a2b96..73b2ddb79 100644
--- a/src/compositor/compositor_api/qwaylandinputpanel.cpp
+++ b/src/compositor/compositor_api/qwaylandinputpanel.cpp
@@ -45,7 +45,7 @@
QT_BEGIN_NAMESPACE
QWaylandInputPanel::QWaylandInputPanel(QWaylandCompositor *compositor)
- : QWaylandExtensionTemplate(*new QWaylandInputPanelPrivate(compositor))
+ : QWaylandExtensionTemplate(compositor, *new QWaylandInputPanelPrivate(compositor))
{
}
diff --git a/src/compositor/compositor_api/qwaylandkeyboard.cpp b/src/compositor/compositor_api/qwaylandkeyboard.cpp
index 383c97b00..4de676916 100644
--- a/src/compositor/compositor_api/qwaylandkeyboard.cpp
+++ b/src/compositor/compositor_api/qwaylandkeyboard.cpp
@@ -41,7 +41,7 @@
#include <QtCompositor/QWaylandInputDevice>
#include <QtCompositor/QWaylandClient>
-#include <QtCompositor/private/qwlshellsurface_p.h>
+#include <QtCompositor/QWaylandShellSurface>
#include <QtCore/QFile>
#include <QtCore/QStandardPaths>
@@ -400,7 +400,7 @@ QWaylandSurface *QWaylandKeyboard::focus() const
bool QWaylandKeyboard::setFocus(QWaylandSurface *surface)
{
Q_D(QWaylandKeyboard);
- QtWayland::ShellSurface *shellsurface = QtWayland::ShellSurface::findIn(surface);
+ QWaylandShellSurface *shellsurface = QWaylandShellSurface::findIn(surface);
if (shellsurface && shellsurface->isTransientInactive())
return false;
d->grab->focused(surface);
diff --git a/src/compositor/compositor_api/qwaylandoutput.cpp b/src/compositor/compositor_api/qwaylandoutput.cpp
index 5a83796ef..b445b1372 100644
--- a/src/compositor/compositor_api/qwaylandoutput.cpp
+++ b/src/compositor/compositor_api/qwaylandoutput.cpp
@@ -156,11 +156,6 @@ void QWaylandOutputPrivate::sendGeometryInfo()
}
-void QWaylandOutputPrivate::addView(QWaylandView *view)
-{
- addView(view, view->surface());
-}
-
void QWaylandOutputPrivate::addView(QWaylandView *view, QWaylandSurface *surface)
{
for (int i = 0; i < surfaceViews.size(); i++) {
@@ -175,11 +170,6 @@ void QWaylandOutputPrivate::addView(QWaylandView *view, QWaylandSurface *surface
surfaceViews.append(QWaylandSurfaceViewMapper(surface,view));
}
-void QWaylandOutputPrivate::removeView(QWaylandView *view)
-{
- removeView(view, view->surface());
-}
-
void QWaylandOutputPrivate::removeView(QWaylandView *view, QWaylandSurface *surface)
{
Q_Q(QWaylandOutput);
@@ -197,14 +187,6 @@ void QWaylandOutputPrivate::removeView(QWaylandView *view, QWaylandSurface *surf
qWarning("%s Could not find view %p for surface %p to remove. Possible invalid state", Q_FUNC_INFO, view, surface);
}
-void QWaylandOutputPrivate::updateSurfaceForView(QWaylandView *view, QWaylandSurface *newSurface, QWaylandSurface *oldSurface)
-{
- if (newSurface == oldSurface)
- return;
- removeView(view, oldSurface);
- addView(view, newSurface);
-}
-
QWaylandOutput::QWaylandOutput(QWaylandOutputSpace *outputSpace, QWindow *window,
const QString &manufacturer, const QString &model)
: QObject(*new QWaylandOutputPrivate(outputSpace->compositor(), window, manufacturer, model))
diff --git a/src/compositor/compositor_api/qwaylandoutput_p.h b/src/compositor/compositor_api/qwaylandoutput_p.h
index 88d86d5f4..d952f48fc 100644
--- a/src/compositor/compositor_api/qwaylandoutput_p.h
+++ b/src/compositor/compositor_api/qwaylandoutput_p.h
@@ -90,11 +90,8 @@ public:
~QWaylandOutputPrivate();
static QWaylandOutputPrivate *get(QWaylandOutput *output) { return output->d_func(); }
- void addView(QWaylandView *view);
void addView(QWaylandView *view, QWaylandSurface *surface);
- void removeView(QWaylandView *view);
void removeView(QWaylandView *view, QWaylandSurface *surface);
- void updateSurfaceForView(QWaylandView *view, QWaylandSurface *newSurface, QWaylandSurface *oldSurface);
void sendGeometryInfo();
protected:
diff --git a/src/compositor/compositor_api/qwaylandoutputspace.h b/src/compositor/compositor_api/qwaylandoutputspace.h
index fdb64930d..5282ccfe2 100644
--- a/src/compositor/compositor_api/qwaylandoutputspace.h
+++ b/src/compositor/compositor_api/qwaylandoutputspace.h
@@ -90,8 +90,6 @@ public:
Q_INVOKABLE QPointF mapToSpace(QWaylandView *view, const QPointF &local) const;
Q_SIGNALS:
- void surfaceRequestedPositionChanged(QWaylandSurface *surface, const QPointF &point);
-
void geometryConstraintChanged();
void geometryChanged();
diff --git a/src/compositor/compositor_api/qwaylandoutputspace_p.h b/src/compositor/compositor_api/qwaylandoutputspace_p.h
index 127224bed..0f6fa58fc 100644
--- a/src/compositor/compositor_api/qwaylandoutputspace_p.h
+++ b/src/compositor/compositor_api/qwaylandoutputspace_p.h
@@ -61,12 +61,6 @@ public:
}
- void emitSurfacePositionChanged(QWaylandSurface *surface, const QPointF &point)
- {
- Q_Q(QWaylandOutputSpace);
- q->surfaceRequestedPositionChanged(surface, point);
- }
-
void adjustGeometry()
{
if (geometryConstraint != QWaylandOutputSpace::AutomaticBoundingRect)
diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp
index e46144426..efc1bec08 100644
--- a/src/compositor/compositor_api/qwaylandquickitem.cpp
+++ b/src/compositor/compositor_api/qwaylandquickitem.cpp
@@ -87,7 +87,8 @@ public:
}
} else {
QQuickWindow::CreateTextureOptions opt = QQuickWindow::TextureOwnsGLTexture;
- if (surfaceItem->surface()->useTextureAlpha()) {
+ QWaylandQuickSurface *surface = qobject_cast<QWaylandQuickSurface *>(surfaceItem->surface());
+ if (surface && surface->useTextureAlpha()) {
opt |= QQuickWindow::TextureHasAlphaChannel;
}
@@ -120,7 +121,8 @@ private:
QWaylandQuickItem::QWaylandQuickItem(QQuickItem *parent)
: QQuickItem(parent)
- , QWaylandView()
+ , m_view(new QWaylandView(this, this))
+ , m_oldSurface(Q_NULLPTR)
, m_provider(Q_NULLPTR)
, m_paintEnabled(true)
, m_touchEventsEnabled(false)
@@ -149,7 +151,8 @@ QWaylandQuickItem::QWaylandQuickItem(QQuickItem *parent)
setAcceptHoverEvents(true);
connect(this, &QQuickItem::windowChanged, this, &QWaylandQuickItem::updateWindow);
- connect(this, &QQuickItem::windowChanged, this, &QWaylandQuickItem::outputHasChanged);
+ connect(m_view.data(), &QWaylandView::surfaceChanged, this, &QWaylandQuickItem::surfaceChanged);
+ connect(m_view.data(), &QWaylandView::surfaceChanged, this, &QWaylandQuickItem::handleSurfaceChanged);
}
QWaylandQuickItem::~QWaylandQuickItem()
@@ -160,14 +163,24 @@ QWaylandQuickItem::~QWaylandQuickItem()
m_provider->deleteLater();
}
-QWaylandQuickSurface *QWaylandQuickItem::surface() const
+QWaylandCompositor *QWaylandQuickItem::compositor() const
{
- return static_cast<QWaylandQuickSurface *>(QWaylandView::surface());
+ return m_view->surface() ? m_view->surface()->compositor() : Q_NULLPTR;
}
-void QWaylandQuickItem::setSurface(QWaylandQuickSurface *surface)
+QWaylandView *QWaylandQuickItem::view() const
{
- QWaylandView::setSurface(surface);
+ return m_view.data();
+}
+
+QWaylandSurface *QWaylandQuickItem::surface() const
+{
+ return m_view->surface();
+}
+
+void QWaylandQuickItem::setSurface(QWaylandSurface *surface)
+{
+ m_view->setSurface(surface);
}
QWaylandSurface::Origin QWaylandQuickItem::origin() const
@@ -200,7 +213,7 @@ void QWaylandQuickItem::mouseMoveEvent(QMouseEvent *event)
{
if (shouldSendInputEvents()) {
QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
- inputDevice->sendMouseMoveEvent(this, event->localPos(), event->windowPos());
+ inputDevice->sendMouseMoveEvent(m_view.data(), event->localPos(), event->windowPos());
} else {
event->ignore();
}
@@ -226,7 +239,7 @@ void QWaylandQuickItem::hoverEnterEvent(QHoverEvent *event)
}
if (shouldSendInputEvents()) {
QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
- inputDevice->sendMouseMoveEvent(this, event->pos(), QPoint());
+ inputDevice->sendMouseMoveEvent(m_view.data(), event->pos(), mapToScene(event->pos()));
} else {
event->ignore();
}
@@ -242,7 +255,7 @@ void QWaylandQuickItem::hoverMoveEvent(QHoverEvent *event)
}
if (shouldSendInputEvents()) {
QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
- inputDevice->sendMouseMoveEvent(this, event->pos());
+ inputDevice->sendMouseMoveEvent(m_view.data(), event->pos(), mapToScene(event->pos()));
} else {
event->ignore();
}
@@ -315,8 +328,8 @@ void QWaylandQuickItem::touchEvent(QTouchEvent *event)
}
event->accept();
- if (inputDevice->mouseFocus() != this) {
- inputDevice->sendMouseMoveEvent(this, pointPos, QPointF());
+ if (inputDevice->mouseFocus() != m_view.data()) {
+ inputDevice->sendMouseMoveEvent(m_view.data(), pointPos, mapToScene(pointPos));
}
inputDevice->sendFullTouchEvent(event);
} else {
@@ -332,40 +345,33 @@ void QWaylandQuickItem::mouseUngrabEvent()
}
}
-void QWaylandQuickItem::waylandSurfaceChanged(QWaylandSurface *newSurface, QWaylandSurface *oldSurface)
+void QWaylandQuickItem::handleSurfaceChanged()
{
- QWaylandView::waylandSurfaceChanged(newSurface, oldSurface);
- if (oldSurface) {
- disconnect(oldSurface, &QWaylandSurface::mappedChanged, this, &QWaylandQuickItem::surfaceMappedChanged);
- disconnect(oldSurface, &QWaylandSurface::parentChanged, this, &QWaylandQuickItem::parentChanged);
- disconnect(oldSurface, &QWaylandSurface::sizeChanged, this, &QWaylandQuickItem::updateSize);
- disconnect(oldSurface, &QWaylandSurface::configure, this, &QWaylandQuickItem::updateBuffer);
- disconnect(oldSurface, &QWaylandSurface::redraw, this, &QQuickItem::update);
+ if (m_oldSurface) {
+ disconnect(m_oldSurface, &QWaylandSurface::mappedChanged, this, &QWaylandQuickItem::surfaceMappedChanged);
+ disconnect(m_oldSurface, &QWaylandSurface::parentChanged, this, &QWaylandQuickItem::parentChanged);
+ disconnect(m_oldSurface, &QWaylandSurface::sizeChanged, this, &QWaylandQuickItem::updateSize);
+ disconnect(m_oldSurface, &QWaylandSurface::configure, this, &QWaylandQuickItem::updateBuffer);
+ disconnect(m_oldSurface, &QWaylandSurface::redraw, this, &QQuickItem::update);
}
- if (newSurface) {
+ if (QWaylandSurface *newSurface = m_view->surface()) {
connect(newSurface, &QWaylandSurface::mappedChanged, this, &QWaylandQuickItem::surfaceMappedChanged);
connect(newSurface, &QWaylandSurface::parentChanged, this, &QWaylandQuickItem::parentChanged);
connect(newSurface, &QWaylandSurface::sizeChanged, this, &QWaylandQuickItem::updateSize);
connect(newSurface, &QWaylandSurface::configure, this, &QWaylandQuickItem::updateBuffer);
connect(newSurface, &QWaylandSurface::redraw, this, &QQuickItem::update);
- setWidth(surface()->size().width());
- setHeight(surface()->size().height());
+ setWidth(newSurface->size().width());
+ setHeight(newSurface->size().height());
if (newSurface->origin() != m_origin) {
m_origin = newSurface->origin();
emit originChanged();
}
if (window()) {
QWaylandOutput *output = newSurface->compositor()->output(window());
- setOutput(output);
+ m_view->setOutput(output);
}
}
-
- emit surfaceChanged();
-}
-
-void QWaylandQuickItem::waylandSurfaceDestroyed()
-{
- emit surfaceDestroyed();
+ m_oldSurface = m_view->surface();
}
void QWaylandQuickItem::takeFocus(QWaylandInputDevice *device)
@@ -406,24 +412,6 @@ void QWaylandQuickItem::updateSize()
}
}
-void QWaylandQuickItem::setRequestedPosition(const QPointF &pos)
-{
- bool xChanged = pos.x() != requestedPosition().x();
- bool yChanged = pos.y() != requestedPosition().y();
- QWaylandView::setRequestedPosition(pos);
- if (xChanged)
- emit requestedXPositionChanged();
- if (yChanged)
- emit requestedYPositionChanged();
- if (m_followRequestedPos)
- setPosition(pos);
-}
-
-QPointF QWaylandQuickItem::pos() const
-{
- return position();
-}
-
bool QWaylandQuickItem::followRequestedPosition() const
{
@@ -438,48 +426,11 @@ void QWaylandQuickItem::setFollowRequestedPosition(bool follow)
}
}
-qreal QWaylandQuickItem::requestedXPosition() const
-{
- return requestedPosition().x();
-}
-
-void QWaylandQuickItem::setRequestedXPosition(qreal xPos)
-{
- QPointF reqPos = requestedPosition();
- reqPos.setX(xPos);
- setRequestedPosition(reqPos);
-}
-
-qreal QWaylandQuickItem::requestedYPosition() const
-{
- return requestedPosition().y();
-}
-
-void QWaylandQuickItem::setRequestedYPosition(qreal yPos)
-{
- QPointF reqPos = requestedPosition();
- reqPos.setY(yPos);
- setRequestedPosition(reqPos);
-}
-
void QWaylandQuickItem::syncGraphicsState()
{
}
-bool QWaylandQuickItem::lockedBuffer() const
-{
- return QWaylandView::lockedBuffer();
-}
-
-void QWaylandQuickItem::setLockedBuffer(bool locked)
-{
- if (locked != lockedBuffer()) {
- QWaylandView::setLockedBuffer(locked);
- lockedBufferChanged();
- }
-}
-
/*!
\qmlproperty bool QtWayland::QWaylandSurfaceItem::paintEnabled
@@ -523,32 +474,22 @@ void QWaylandQuickItem::updateWindow()
if (compositor() && m_connectedWindow) {
QWaylandOutput *output = compositor()->output(m_connectedWindow);
Q_ASSERT(output);
- setOutput(output);
+ m_view->setOutput(output);
}
}
void QWaylandQuickItem::beforeSync()
{
- if (advance()) {
+ if (m_view->advance()) {
m_newTexture = true;
update();
}
}
-void QWaylandQuickItem::outputHasChanged()
-{
- if (!compositor())
- return;
- QWaylandOutput *output = Q_NULLPTR;
- if (window())
- output = compositor()->output(window());
- setOutput(output);
-}
-
QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
{
- bool mapped = (surface() && surface()->isMapped() && currentBuffer().hasBuffer())
- || (lockedBuffer() && m_provider);
+ bool mapped = (surface() && surface()->isMapped() && m_view->currentBuffer().hasBuffer())
+ || (m_view->isBufferLocked() && m_provider);
if (!mapped || !m_paintEnabled) {
delete oldNode;
@@ -565,7 +506,7 @@ QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat
if (m_newTexture) {
m_newTexture = false;
- m_provider->setBufferRef(this, currentBuffer());
+ m_provider->setBufferRef(this, m_view->currentBuffer());
node->setTexture(m_provider->texture());
}
diff --git a/src/compositor/compositor_api/qwaylandquickitem.h b/src/compositor/compositor_api/qwaylandquickitem.h
index 33234cfce..93fa276dc 100644
--- a/src/compositor/compositor_api/qwaylandquickitem.h
+++ b/src/compositor/compositor_api/qwaylandquickitem.h
@@ -55,26 +55,28 @@ class QWaylandSurfaceTextureProvider;
class QMutex;
class QWaylandInputDevice;
-class Q_COMPOSITOR_EXPORT QWaylandQuickItem : public QQuickItem, public QWaylandView
+class Q_COMPOSITOR_EXPORT QWaylandQuickItem : public QQuickItem
{
Q_OBJECT
- Q_PROPERTY(QWaylandQuickSurface* surface READ surface WRITE setSurface NOTIFY surfaceChanged)
+ 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)
Q_PROPERTY(bool touchEventsEnabled READ touchEventsEnabled WRITE setTouchEventsEnabled NOTIFY touchEventsEnabledChanged)
Q_PROPERTY(QWaylandSurface::Origin origin READ origin NOTIFY originChanged)
Q_PROPERTY(bool resizeSurfaceToItem READ resizeSurfaceToItem WRITE setResizeSurfaceToItem NOTIFY resizeSurfaceToItemChanged)
Q_PROPERTY(bool followRequestedPosition READ followRequestedPosition WRITE setFollowRequestedPosition NOTIFY followRequestedPositionChanged)
- Q_PROPERTY(qreal requestedXPosition READ requestedXPosition WRITE setRequestedXPosition NOTIFY requestedXPositionChanged)
- Q_PROPERTY(qreal requestedYPosition READ requestedYPosition WRITE setRequestedYPosition NOTIFY requestedYPositionChanged)
Q_PROPERTY(bool inputEventsEnabled READ inputEventsEnabled WRITE setInputEventsEnabled NOTIFY inputEventsEnabledChanged)
- Q_PROPERTY(bool lockedBuffer READ lockedBuffer WRITE setLockedBuffer NOTIFY lockedBufferChanged)
public:
QWaylandQuickItem(QQuickItem *parent = 0);
~QWaylandQuickItem();
- QWaylandQuickSurface *surface() const;
- void setSurface(QWaylandQuickSurface *surface);
+ QWaylandCompositor *compositor() const;
+ QWaylandView *view() const;
+
+ QWaylandSurface *surface() const;
+ void setSurface(QWaylandSurface *surface);
QWaylandSurface::Origin origin() const;
@@ -91,21 +93,11 @@ public:
bool inputEventsEnabled() const { return m_inputEventsEnabled; }
void setInputEventsEnabled(bool enabled);
- void setRequestedPosition(const QPointF &pos) Q_DECL_OVERRIDE;
- QPointF pos() const Q_DECL_OVERRIDE;
-
bool followRequestedPosition() const;
void setFollowRequestedPosition(bool follow);
- qreal requestedXPosition() const;
- void setRequestedXPosition(qreal xPos);
- qreal requestedYPosition() const;
- void setRequestedYPosition(qreal yPos);
Q_INVOKABLE void syncGraphicsState();
- bool lockedBuffer() const;
- void setLockedBuffer(bool locked);
-
protected:
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
@@ -121,21 +113,18 @@ protected:
void touchEvent(QTouchEvent *event);
void mouseUngrabEvent() Q_DECL_OVERRIDE;
- void waylandSurfaceChanged(QWaylandSurface *newSurface, QWaylandSurface *oldSurface) Q_DECL_OVERRIDE;
- void waylandSurfaceDestroyed() Q_DECL_OVERRIDE;
-
public Q_SLOTS:
virtual void takeFocus(QWaylandInputDevice *device = 0);
void setPaintEnabled(bool paintEnabled);
private Q_SLOTS:
void surfaceMappedChanged();
+ void handleSurfaceChanged();
void parentChanged(QWaylandSurface *newParent, QWaylandSurface *oldParent);
void updateSize();
void updateBuffer(bool hasBuffer);
void updateWindow();
void beforeSync();
- void outputHasChanged();
Q_SIGNALS:
void surfaceChanged();
@@ -144,10 +133,7 @@ Q_SIGNALS:
void resizeSurfaceToItemChanged();
void surfaceDestroyed();
void followRequestedPositionChanged();
- void requestedXPositionChanged();
- void requestedYPositionChanged();
void inputEventsEnabledChanged();
- void lockedBufferChanged();
protected:
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *);
@@ -155,10 +141,12 @@ protected:
private:
friend class QWaylandSurfaceNode;
friend class QWaylandQuickSurface;
- bool shouldSendInputEvents() const { return surface() && m_inputEventsEnabled; }
+ bool shouldSendInputEvents() const { return m_view->surface() && m_inputEventsEnabled; }
static QMutex *mutex;
+ QScopedPointer<QWaylandView> m_view;
+ QWaylandSurface *m_oldSurface;
mutable QWaylandSurfaceTextureProvider *m_provider;
bool m_paintEnabled;
bool m_touchEventsEnabled;
diff --git a/src/compositor/compositor_api/qwaylandquicksurface.h b/src/compositor/compositor_api/qwaylandquicksurface.h
index 1373b080e..6926be2f4 100644
--- a/src/compositor/compositor_api/qwaylandquicksurface.h
+++ b/src/compositor/compositor_api/qwaylandquicksurface.h
@@ -43,7 +43,6 @@ struct wl_client;
QT_BEGIN_NAMESPACE
-class QWaylandQuickItem;
class QWaylandQuickSurfacePrivate;
class QWaylandQuickCompositor;
diff --git a/src/compositor/compositor_api/qwaylandshell.cpp b/src/compositor/compositor_api/qwaylandshell.cpp
deleted file mode 100644
index 59b099da1..000000000
--- a/src/compositor/compositor_api/qwaylandshell.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-QWaylandShell::QWaylandShell(QWaylandCompositor *compositor)
- : QWaylandExtensionTemplate(*new QWaylandShellPrivate(compositor))
-{
-
-}
-
-const struct wl_interface *QWaylandShell::interface()
-{
- return QWaylandShellPrivate::interface();
-}
-
-QByteArray QWaylandShell::interfaceName()
-{
- return QWaylandShellPrivate::interfaceName();
-}
-const struct wl_interface *QWaylandShellSurface::interface()
-{
- return QWaylandShellSurfacePrivate::interface();
-}
-
-QByteArray QWaylandShellSurface::interfaceName()
-{
- return QWaylandShellSurfacePrivate::interfaceName();
-}
-
-QWaylandView *QWaylandShellSurface::view() const
-{
- Q_D(const QWaylandShellSurface);
-
- return d->view();
-}
-
-void QWaylandShellSurface::setView(QWaylandView *view)
-{
- Q_D(QWaylandShellSurface);
- d->setView(view);
-}
-
-QWaylandShellSurface::SurfaceType QWaylandShellSurface::surfaceType() const
-{
- Q_D(const QWaylandShellSurface);
- return d->surfaceType();
-}
-
-void QWaylandShellSurface::mapped()
-{
- Q_D(QWaylandSurface);
- d->mapped();
-}
-
-void QWaylandShellSurface::adjustOffset(const QPoint &p)
-{
- Q_D(QWaylandShellSurface);
- d->adjustOffset(p);
-}
diff --git a/src/compositor/compositor_api/qwaylandshell.h b/src/compositor/compositor_api/qwaylandshell.h
deleted file mode 100644
index 16118b911..000000000
--- a/src/compositor/compositor_api/qwaylandshell.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWAYLANDSHELL_H
-#define QWAYLANDSHELL_H
-
-#include <QtCompositor/QWaylandExtension>
-
-class QWaylandShellSurface;
-class QWaylandSurface;
-class QWaylandView;
-
-class Q_COMPOSITOR_EXPORT QWaylandShell : public QWaylandExtensionTemplate<QWaylandShell>
-{
- Q_OBJECT
-public:
- QWaylandShell(QWaylandCompositor *compositor);
-
- static const struct wl_interface *interface();
- static QByteArray interfaceName();
-Q_SIGNALS:
- void shellSurfaceCreated(QWaylandSurface *surface, QWaylandShellSurface *shellSurface);
-};
-
-class QWaylandShellSurface : public QWaylandExtensionTemplate<QWaylandShellSurface>
-{
- Q_OBJECT
- Q_PROPERTY(SurfaceType surfaceType READ surfaceType NOTIFY surfaceTypeChanged)
- Q_PROPERTY(QWaylandView *view READ view WRITE setView NOTIFY viewChanged)
-
-public:
- enum SurfaceType {
- None,
- Toplevel,
- Transient,
- Popup
- };
-
- QWaylandShellSurface(QWaylandSurface *surface);
-
- QWaylandView *view() const;
- void setView(QWaylandView *view);
-
- SurfaceType surfaceType() const;
-
- static const struct wl_interface *interface();
- static QByteArray interfaceName();
-Q_SIGNALS:
- void surfaceTypeChanged();
- void viewChanged();
- void pong();
-
-private Q_SLOTS:
- void mapped();
- void adjustOffset(const QPoint &p);
-};
-
-#endif /*QWAYLANDSHELL_H*/
diff --git a/src/compositor/compositor_api/qwaylandview.cpp b/src/compositor/compositor_api/qwaylandview.cpp
index a711989d5..90f182c5d 100644
--- a/src/compositor/compositor_api/qwaylandview.cpp
+++ b/src/compositor/compositor_api/qwaylandview.cpp
@@ -41,35 +41,32 @@
#include <QtCompositor/QWaylandInputDevice>
#include <QtCompositor/QWaylandCompositor>
#include <QtCompositor/private/qwaylandoutputspace_p.h>
+
#include <QtCore/QMutex>
QT_BEGIN_NAMESPACE
-QWaylandViewPrivate *QWaylandViewPrivate::get(QWaylandView *view)
-{
- return view->d_func();
-}
-
void QWaylandViewPrivate::markSurfaceAsDestroyed(QWaylandSurface *surface)
{
Q_Q(QWaylandView);
Q_ASSERT(surface == this->surface);
q->setSurface(Q_NULLPTR);
- q->waylandSurfaceDestroyed();
+ emit q->surfaceDestroyed();
}
-QWaylandView::QWaylandView()
- : d_ptr(new QWaylandViewPrivate(this))
+QWaylandView::QWaylandView(QObject *renderObject, QObject *parent)
+ : QObject(*new QWaylandViewPrivate(),parent)
{
+ d_func()->renderObject = renderObject;
}
QWaylandView::~QWaylandView()
{
Q_D(QWaylandView);
- if (d->output)
- QWaylandOutputPrivate::get(d->output)->removeView(this);
if (d->surface) {
+ if (d->output)
+ QWaylandOutputPrivate::get(d->output)->removeView(this, d->surface);
QWaylandInputDevice *i = d->surface->compositor()->defaultInputDevice();
if (i->mouseFocus() == this)
i->setMouseFocus(Q_NULLPTR);
@@ -79,6 +76,12 @@ QWaylandView::~QWaylandView()
}
+QObject *QWaylandView::renderObject() const
+{
+ Q_D(const QWaylandView);
+ return d->renderObject;
+}
+
QWaylandSurface *QWaylandView::surface() const
{
Q_D(const QWaylandView);
@@ -91,23 +94,31 @@ void QWaylandView::setSurface(QWaylandSurface *newSurface)
if (d->surface == newSurface)
return;
- QWaylandSurface *oldSurface = d->surface;
- d->surface = newSurface;
- if (oldSurface)
- QWaylandSurfacePrivate::get(oldSurface)->derefView(this);
+ if (d->surface) {
+ QWaylandSurfacePrivate::get(d->surface)->derefView(this);
+ if (d->output)
+ QWaylandOutputPrivate::get(d->output)->removeView(this, d->surface);
+ }
- if (newSurface)
- QWaylandSurfacePrivate::get(newSurface)->refView(this);
+ d->surface = newSurface;
- waylandSurfaceChanged(newSurface, oldSurface);
- if (!d->lockedBuffer) {
+ if (!d->bufferLock) {
d->currentBuffer = QWaylandBufferRef();
d->currentDamage = QRegion();
}
d->nextBuffer = QWaylandBufferRef();
d->nextDamage = QRegion();
+
+ if (d->surface) {
+ QWaylandSurfacePrivate::get(d->surface)->refView(this);
+ if (d->output)
+ QWaylandOutputPrivate::get(d->output)->addView(this, d->surface);
+ }
+
+ emit surfaceChanged();
+
}
QWaylandOutput *QWaylandView::output() const
@@ -122,27 +133,30 @@ void QWaylandView::setOutput(QWaylandOutput *newOutput)
if (d->output == newOutput)
return;
- QWaylandOutput *oldOutput = d->output;
+ if (d->output && d->surface)
+ QWaylandOutputPrivate::get(d->output)->removeView(this, d->surface);
+
d->output = newOutput;
- waylandOutputChanged(newOutput, oldOutput);
-}
+ if (d->output && d->surface)
+ QWaylandOutputPrivate::get(d->output)->addView(this, d->surface);
-QWaylandCompositor *QWaylandView::compositor() const
-{
- Q_D(const QWaylandView);
- return d->surface ? d->surface->compositor() : 0;
+ emit outputChanged();
}
void QWaylandView::setRequestedPosition(const QPointF &pos)
{
Q_D(QWaylandView);
- d->requestedPos = pos;
- if (d->shouldBroadcastRequestedPositionChanged()) {
- Q_ASSERT(d->output->outputSpace());
- QWaylandOutputSpacePrivate *outputSpacePriv = QWaylandOutputSpacePrivate::get(d->output->outputSpace());
- outputSpacePriv->emitSurfacePositionChanged(d->surface, pos);
+ bool xChanged = !qFuzzyCompare(pos.x(), d->requestedPos.x());
+ bool yChanged = !qFuzzyCompare(pos.y(), d->requestedPos.y());
+ if (xChanged || yChanged) {
+ d->requestedPos = pos;
+ emit requestedPositionChanged();
}
+ if (xChanged)
+ emit requestedXPositionChanged();
+ if (yChanged)
+ emit requestedYPositionChanged();
}
QPointF QWaylandView::requestedPosition() const
@@ -151,10 +165,28 @@ QPointF QWaylandView::requestedPosition() const
return d->requestedPos;
}
-QPointF QWaylandView::pos() const
+qreal QWaylandView::requestedXPosition() const
{
Q_D(const QWaylandView);
- return d->requestedPos;
+ return d->requestedPos.x();
+}
+
+void QWaylandView::setRequestedXPosition(qreal xPos)
+{
+ Q_D(QWaylandView);
+ setRequestedPosition(QPointF(xPos, d->requestedPos.y()));
+}
+
+qreal QWaylandView::requestedYPosition() const
+{
+ Q_D(const QWaylandView);
+ return d->requestedPos.y();
+}
+
+void QWaylandView::setRequestedYPosition(qreal yPos)
+{
+ Q_D(QWaylandView);
+ setRequestedPosition(QPointF(d->requestedPos.x(), yPos));
}
void QWaylandView::attach(const QWaylandBufferRef &ref, const QRegion &damage)
@@ -171,7 +203,7 @@ bool QWaylandView::advance()
if (d->currentBuffer == d->nextBuffer)
return false;
- if (d->lockedBuffer)
+ if (d->bufferLock)
return false;
QMutexLocker locker(&d->bufferMutex);
@@ -194,28 +226,16 @@ QRegion QWaylandView::currentDamage()
return d->currentDamage;
}
-bool QWaylandView::lockedBuffer() const
+bool QWaylandView::isBufferLocked() const
{
Q_D(const QWaylandView);
- return d->lockedBuffer;
+ return d->bufferLock;
}
-void QWaylandView::setLockedBuffer(bool locked)
+void QWaylandView::setBufferLock(bool locked)
{
Q_D(QWaylandView);
- d->lockedBuffer = locked;
-}
-
-bool QWaylandView::broadcastRequestedPositionChanged() const
-{
- Q_D(const QWaylandView);
- return d->broadcastRequestedPositionChanged;
-}
-
-void QWaylandView::setBroadcastRequestedPositionChanged(bool broadcast)
-{
- Q_D(QWaylandView);
- d->broadcastRequestedPositionChanged = broadcast;
+ d->bufferLock = locked;
}
struct wl_resource *QWaylandView::surfaceResource() const
@@ -226,24 +246,4 @@ struct wl_resource *QWaylandView::surfaceResource() const
return d->surface->resource();
}
-void QWaylandView::waylandSurfaceChanged(QWaylandSurface *newSurface, QWaylandSurface *oldSurface)
-{
- Q_D(QWaylandView);
- if (d->output)
- QWaylandOutputPrivate::get(d->output)->updateSurfaceForView(this, newSurface, oldSurface);
-}
-
-void QWaylandView::waylandSurfaceDestroyed()
-{
-}
-
-void QWaylandView::waylandOutputChanged(QWaylandOutput *newOutput, QWaylandOutput *oldOutput)
-{
- if (oldOutput)
- QWaylandOutputPrivate::get(oldOutput)->removeView(this);
-
- if (newOutput)
- QWaylandOutputPrivate::get(newOutput)->addView(this);
-}
-
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandview.h b/src/compositor/compositor_api/qwaylandview.h
index 4bb9b39d5..eddcdea49 100644
--- a/src/compositor/compositor_api/qwaylandview.h
+++ b/src/compositor/compositor_api/qwaylandview.h
@@ -37,26 +37,34 @@
#ifndef QWAYLANDSURFACEVIEW_H
#define QWAYLANDSURFACEVIEW_H
-#include <QPointF>
-
#include <QtCompositor/QWaylandBufferRef>
#include <QtCompositor/qwaylandexport.h>
+#include <QtCore/QPointF>
+#include <QtCore/QObject>
+
QT_BEGIN_NAMESPACE
class QWaylandSurface;
-class QWaylandCompositor;
class QWaylandViewPrivate;
class QWaylandOutput;
-class Q_COMPOSITOR_EXPORT QWaylandView
+class Q_COMPOSITOR_EXPORT QWaylandView : public QObject
{
+ Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandView)
+ Q_PROPERTY(QObject *renderObject READ renderObject CONSTANT)
+ Q_PROPERTY(QWaylandSurface *surface READ surface WRITE setSurface NOTIFY surfaceChanged)
+ Q_PROPERTY(QWaylandOutput *output READ output WRITE setOutput NOTIFY outputChanged)
+ Q_PROPERTY(QPointF requestedPosition READ requestedPosition WRITE setRequestedPosition NOTIFY requestedPositionChanged)
+ Q_PROPERTY(qreal requestedXPosition READ requestedXPosition WRITE setRequestedXPosition NOTIFY requestedXPositionChanged)
+ Q_PROPERTY(qreal requestedYPosition READ requestedYPosition WRITE setRequestedYPosition NOTIFY requestedYPositionChanged)
+ Q_PROPERTY(bool bufferLock READ isBufferLocked WRITE setBufferLock NOTIFY bufferLockChanged)
public:
- QWaylandView();
+ QWaylandView(QObject *renderObject = 0, QObject *parent = 0);
virtual ~QWaylandView();
- QWaylandCompositor *compositor() const;
+ QObject *renderObject() const;
QWaylandSurface *surface() const;
void setSurface(QWaylandSurface *surface);
@@ -64,29 +72,31 @@ public:
QWaylandOutput *output() const;
void setOutput(QWaylandOutput *output);
- virtual void setRequestedPosition(const QPointF &pos);
- virtual QPointF requestedPosition() const;
- virtual QPointF pos() const;
+ QPointF requestedPosition() const;
+ void setRequestedPosition(const QPointF &pos);
+ qreal requestedXPosition() const;
+ void setRequestedXPosition(qreal xPos);
+ qreal requestedYPosition() const;
+ void setRequestedYPosition(qreal yPos);
virtual void attach(const QWaylandBufferRef &ref, const QRegion &damage);
virtual bool advance();
virtual QWaylandBufferRef currentBuffer();
virtual QRegion currentDamage();
- bool lockedBuffer() const;
- void setLockedBuffer(bool locked);
-
- bool broadcastRequestedPositionChanged() const;
- void setBroadcastRequestedPositionChanged(bool broadcast);
+ bool isBufferLocked() const;
+ void setBufferLock(bool locked);
struct wl_resource *surfaceResource() const;
-protected:
- virtual void waylandSurfaceChanged(QWaylandSurface *newSurface, QWaylandSurface *oldSurface);
- virtual void waylandSurfaceDestroyed();
- virtual void waylandOutputChanged(QWaylandOutput *newOutput, QWaylandOutput *oldOutput);
-private:
- QScopedPointer<QWaylandViewPrivate> d_ptr;
+Q_SIGNALS:
+ void surfaceChanged();
+ void surfaceDestroyed();
+ void outputChanged();
+ void requestedPositionChanged();
+ void requestedXPositionChanged();
+ void requestedYPositionChanged();
+ void bufferLockChanged();
};
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandview_p.h b/src/compositor/compositor_api/qwaylandview_p.h
index 562b54f6c..c37cd6b71 100644
--- a/src/compositor/compositor_api/qwaylandview_p.h
+++ b/src/compositor/compositor_api/qwaylandview_p.h
@@ -39,6 +39,7 @@
#include <QtCore/QPoint>
#include <QtCore/QMutex>
+#include <QtCore/private/qobject_p.h>
#include <QtCompositor/QWaylandBufferRef>
@@ -47,27 +48,23 @@ QT_BEGIN_NAMESPACE
class QWaylandSurface;
class QWaylandOutput;
-class QWaylandViewPrivate
+class QWaylandViewPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QWaylandView)
public:
- static QWaylandViewPrivate *get(QWaylandView *view);
+ static QWaylandViewPrivate *get(QWaylandView *view) { return view->d_func(); }
- QWaylandViewPrivate(QWaylandView *view)
- : q_ptr(view)
+ QWaylandViewPrivate()
+ : renderObject(Q_NULLPTR)
, surface(Q_NULLPTR)
, output(Q_NULLPTR)
- , lockedBuffer(false)
+ , bufferLock(false)
+ , broadcastRequestedPositionChanged(false)
{ }
void markSurfaceAsDestroyed(QWaylandSurface *surface);
- bool shouldBroadcastRequestedPositionChanged() const
- {
- return broadcastRequestedPositionChanged && output;
- }
-
- QWaylandView *q_ptr;
+ QObject *renderObject;
QWaylandSurface *surface;
QWaylandOutput *output;
QPointF requestedPos;
@@ -76,7 +73,7 @@ public:
QRegion currentDamage;
QWaylandBufferRef nextBuffer;
QRegion nextDamage;
- bool lockedBuffer;
+ bool bufferLock;
bool broadcastRequestedPositionChanged;
};