summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/client.pro3
-rw-r--r--src/client/qwaylandcursor.cpp2
-rw-r--r--src/client/qwaylanddisplay.cpp2
-rw-r--r--src/client/qwaylanddisplay_p.h5
-rw-r--r--src/client/qwaylandintegration.cpp15
-rw-r--r--src/client/qwaylandshm.cpp80
-rw-r--r--src/client/qwaylandshm_p.h76
-rw-r--r--src/client/qwaylandshmbackingstore.cpp6
-rw-r--r--src/compositor/compositor_api/compositor_api.pri7
-rw-r--r--src/compositor/compositor_api/qwaylandbufferref.cpp5
-rw-r--r--src/compositor/compositor_api/qwaylandbufferref.h2
-rw-r--r--src/compositor/compositor_api/qwaylandquickcompositor.cpp2
-rw-r--r--src/compositor/compositor_api/qwaylandquicksurface.cpp100
-rw-r--r--src/compositor/compositor_api/qwaylandquicksurface.h5
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.cpp22
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.h5
-rw-r--r--src/compositor/compositor_api/qwaylandsurfaceitem.cpp5
-rw-r--r--src/compositor/compositor_api/qwaylandsurfaceitem.h2
-rw-r--r--src/compositor/compositor_api/qwaylandsurfaceview.cpp2
-rw-r--r--src/compositor/compositor_api/qwaylandsurfaceview.h2
-rw-r--r--src/compositor/compositor_api/qwaylandtexturebufferattacher.cpp101
-rw-r--r--src/compositor/compositor_api/qwaylandtexturebufferattacher_p.h73
-rw-r--r--src/compositor/wayland_wrapper/qwlcompositor.cpp36
-rw-r--r--src/compositor/wayland_wrapper/qwlcompositor_p.h10
-rw-r--r--src/compositor/wayland_wrapper/qwlsubsurface.cpp153
-rw-r--r--src/compositor/wayland_wrapper/qwlsubsurface_p.h83
-rw-r--r--src/compositor/wayland_wrapper/qwlsurface.cpp18
-rw-r--r--src/compositor/wayland_wrapper/qwlsurface_p.h3
-rw-r--r--src/compositor/wayland_wrapper/wayland_wrapper.pri1
-rw-r--r--src/extensions/sub-surface-extension.xml69
30 files changed, 536 insertions, 359 deletions
diff --git a/src/client/client.pro b/src/client/client.pro
index ba17b21c5..ca0e0a7d0 100644
--- a/src/client/client.pro
+++ b/src/client/client.pro
@@ -45,7 +45,6 @@ INCLUDEPATH += $$PWD/../shared
WAYLANDCLIENTSOURCES += \
../3rdparty/protocol/wayland.xml \
../extensions/surface-extension.xml \
- ../extensions/sub-surface-extension.xml \
../extensions/touch-extension.xml \
../extensions/qtkey-extension.xml \
../extensions/windowmanager.xml \
@@ -83,6 +82,7 @@ SOURCES += qwaylandintegration.cpp \
qwaylandwindowmanagerintegration.cpp \
qwaylandinputcontext.cpp \
qwaylanddatadevice.cpp \
+ qwaylandshm.cpp \
HEADERS += qwaylandintegration_p.h \
qwaylandnativeinterface_p.h \
@@ -116,6 +116,7 @@ HEADERS += qwaylandintegration_p.h \
qwaylandwindowmanagerintegration_p.h \
qwaylandinputcontext_p.h \
qwaylanddatadevice_p.h \
+ qwaylandshm_p.h \
include(hardwareintegration/hardwareintegration.pri)
include(shellintegration/shellintegration.pri)
diff --git a/src/client/qwaylandcursor.cpp b/src/client/qwaylandcursor.cpp
index 8dfc95c36..a76e05a9a 100644
--- a/src/client/qwaylandcursor.cpp
+++ b/src/client/qwaylandcursor.cpp
@@ -59,7 +59,7 @@ QWaylandCursor::QWaylandCursor(QWaylandScreen *screen)
int cursorSize = cursorSizeFromEnv.toInt(&hasCursorSize);
if (!hasCursorSize || cursorSize <= 0)
cursorSize = 32;
- mCursorTheme = wl_cursor_theme_load(cursorTheme, cursorSize, mDisplay->shm());
+ mCursorTheme = wl_cursor_theme_load(cursorTheme, cursorSize, mDisplay->shm()->object());
if (!mCursorTheme)
qDebug() << "Could not load theme" << cursorTheme;
initCursorMap();
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
index dbb8e12dd..ccd189477 100644
--- a/src/client/qwaylanddisplay.cpp
+++ b/src/client/qwaylanddisplay.cpp
@@ -252,7 +252,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
mCompositorVersion = qMin((int)version, 3);
mCompositor.init(registry, id, mCompositorVersion);
} else if (interface == QStringLiteral("wl_shm")) {
- mShm = static_cast<struct wl_shm *>(wl_registry_bind(registry, id, &wl_shm_interface,1));
+ mShm.reset(new QWaylandShm(this, version, id));
} else if (interface == QStringLiteral("xdg_shell")
&& qEnvironmentVariableIsSet("QT_WAYLAND_USE_XDG_SHELL")) {
mShellXdg.reset(new QWaylandXdgShell(registry,id));
diff --git a/src/client/qwaylanddisplay_p.h b/src/client/qwaylanddisplay_p.h
index bf48c2123..664407b88 100644
--- a/src/client/qwaylanddisplay_p.h
+++ b/src/client/qwaylanddisplay_p.h
@@ -56,6 +56,7 @@
#include <QtWaylandClient/private/qwayland-wayland.h>
#include <QtWaylandClient/private/qwaylandclientexport_p.h>
#include <QtWaylandClient/private/qwayland-xdg-shell.h>
+#include <QtWaylandClient/private/qwaylandshm_p.h>
struct wl_cursor_image;
@@ -157,7 +158,7 @@ public:
* to enable many listeners at once. */
void addRegistryListener(RegistryListener listener, void *data);
- struct wl_shm *shm() const { return mShm; }
+ QWaylandShm *shm() const { return mShm.data(); }
static uint32_t currentTimeMillisec();
@@ -185,7 +186,7 @@ private:
struct wl_display *mDisplay;
QtWayland::wl_compositor mCompositor;
- struct wl_shm *mShm;
+ QScopedPointer<QWaylandShm> mShm;
QThread *mEventThread;
QWaylandEventThread *mEventThreadObject;
QScopedPointer<QtWayland::wl_shell> mShell;
diff --git a/src/client/qwaylandintegration.cpp b/src/client/qwaylandintegration.cpp
index 82df8a30a..407d90b94 100644
--- a/src/client/qwaylandintegration.cpp
+++ b/src/client/qwaylandintegration.cpp
@@ -129,8 +129,19 @@ QWaylandIntegration::QWaylandIntegration()
mDrag = new QWaylandDrag(mDisplay);
QString icStr = QPlatformInputContextFactory::requested();
- icStr.isNull() ? mInputContext.reset(new QWaylandInputContext(mDisplay))
- : mInputContext.reset(QPlatformInputContextFactory::create(icStr));
+ if (!icStr.isNull()) {
+ mInputContext.reset(QPlatformInputContextFactory::create(icStr));
+ } else {
+ //try to use the input context using the wl_text_input interface
+ QPlatformInputContext *ctx = new QWaylandInputContext(mDisplay);
+ mInputContext.reset(ctx);
+
+ //use the traditional way for on screen keyboards for now
+ if (!mInputContext.data()->isValid()) {
+ ctx = QPlatformInputContextFactory::create();
+ mInputContext.reset(ctx);
+ }
+ }
}
QWaylandIntegration::~QWaylandIntegration()
diff --git a/src/client/qwaylandshm.cpp b/src/client/qwaylandshm.cpp
new file mode 100644
index 000000000..1d7981477
--- /dev/null
+++ b/src/client/qwaylandshm.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 LG Electronics Inc, author: <mikko.levonmaa@lge.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtWaylandClient/private/qwaylandshm_p.h>
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+
+#include "qwaylandshmformathelper.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+QWaylandShm::QWaylandShm(QWaylandDisplay *display, int version, uint32_t id)
+ : QtWayland::wl_shm(display->wl_registry(), id, qMin(version, 1))
+{
+}
+
+QWaylandShm::~QWaylandShm()
+{
+
+}
+
+void QWaylandShm::shm_format(uint32_t format)
+{
+ m_formats << format;
+}
+
+bool QWaylandShm::formatSupported(wl_shm_format format) const
+{
+ return m_formats.contains(format);
+}
+
+bool QWaylandShm::formatSupported(QImage::Format format) const
+{
+ wl_shm_format fmt = formatFrom(format);
+ return formatSupported(fmt);
+}
+
+wl_shm_format QWaylandShm::formatFrom(QImage::Format format)
+{
+ return QWaylandShmFormatHelper::fromQImageFormat(format);
+}
+
+QImage::Format QWaylandShm::formatFrom(wl_shm_format format)
+{
+ return QWaylandShmFormatHelper::fromWaylandShmFormat(format);
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/client/qwaylandshm_p.h b/src/client/qwaylandshm_p.h
new file mode 100644
index 000000000..10feae6a7
--- /dev/null
+++ b/src/client/qwaylandshm_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 LG Electronics Inc, author: <mikko.levonmaa@lge.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDSHM_H
+#define QWAYLANDSHM_H
+
+#include <QVector>
+#include <QImage>
+
+#include <QtWaylandClient/private/qwaylandclientexport_p.h>
+#include <QtWaylandClient/private/qwayland-wayland.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+class QWaylandDisplay;
+
+class Q_WAYLAND_CLIENT_EXPORT QWaylandShm : public QtWayland::wl_shm
+{
+
+public:
+
+ QWaylandShm(QWaylandDisplay *display, int version, uint32_t id);
+ ~QWaylandShm();
+
+ bool formatSupported(wl_shm_format format) const;
+ bool formatSupported(QImage::Format format) const;
+
+ static wl_shm_format formatFrom(QImage::Format format);
+ static QImage::Format formatFrom(wl_shm_format format);
+
+protected:
+ virtual void shm_format(uint32_t format);
+
+private:
+ QVector<uint32_t> m_formats;
+
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif
+
diff --git a/src/client/qwaylandshmbackingstore.cpp b/src/client/qwaylandshmbackingstore.cpp
index f009e0811..2912ee3b9 100644
--- a/src/client/qwaylandshmbackingstore.cpp
+++ b/src/client/qwaylandshmbackingstore.cpp
@@ -42,7 +42,6 @@
#include <wayland-client.h>
#include <wayland-client-protocol.h>
-#include "qwaylandshmformathelper.h"
#include <unistd.h>
#include <fcntl.h>
@@ -85,11 +84,12 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
return;
}
- wl_shm_format wl_format = QWaylandShmFormatHelper::fromQImageFormat(format);
+ QWaylandShm* shm = display->shm();
+ wl_shm_format wl_format = shm->formatFrom(format);
mImage = QImage(data, size.width(), size.height(), stride, format);
mImage.setDevicePixelRatio(qreal(scale));
- mShmPool = wl_shm_create_pool(display->shm(), fd, alloc);
+ mShmPool = wl_shm_create_pool(shm->object(), fd, alloc);
mBuffer = wl_shm_pool_create_buffer(mShmPool,0, size.width(), size.height(),
stride, wl_format);
close(fd);
diff --git a/src/compositor/compositor_api/compositor_api.pri b/src/compositor/compositor_api/compositor_api.pri
index ac356b8fa..903eef9e5 100644
--- a/src/compositor/compositor_api/compositor_api.pri
+++ b/src/compositor/compositor_api/compositor_api.pri
@@ -34,13 +34,16 @@ qtHaveModule(quick) {
compositor_api/qwaylandquickcompositor.cpp \
compositor_api/qwaylandquicksurface.cpp \
compositor_api/qwaylandquickoutput.cpp \
- compositor_api/qwaylandsurfaceitem.cpp
+ compositor_api/qwaylandsurfaceitem.cpp \
+ compositor_api/qwaylandtexturebufferattacher.cpp
HEADERS += \
compositor_api/qwaylandquickcompositor.h \
compositor_api/qwaylandquicksurface.h \
compositor_api/qwaylandquickoutput.h \
- compositor_api/qwaylandsurfaceitem.h
+ compositor_api/qwaylandsurfaceitem.h \
+ compositor_api/qwaylandtexturebufferattacher_p.h
+
QT += qml quick
}
diff --git a/src/compositor/compositor_api/qwaylandbufferref.cpp b/src/compositor/compositor_api/qwaylandbufferref.cpp
index abea24afb..e91a2b8f3 100644
--- a/src/compositor/compositor_api/qwaylandbufferref.cpp
+++ b/src/compositor/compositor_api/qwaylandbufferref.cpp
@@ -102,6 +102,11 @@ QImage QWaylandBufferRef::image() const
return QImage();
}
+void *QWaylandBufferRef::waylandBuffer() const
+{
+ return d->buffer->waylandBufferHandle();
+}
+
#ifdef QT_COMPOSITOR_WAYLAND_GL
GLuint QWaylandBufferRef::createTexture()
diff --git a/src/compositor/compositor_api/qwaylandbufferref.h b/src/compositor/compositor_api/qwaylandbufferref.h
index 103a1b388..d2c4eacb1 100644
--- a/src/compositor/compositor_api/qwaylandbufferref.h
+++ b/src/compositor/compositor_api/qwaylandbufferref.h
@@ -62,6 +62,8 @@ public:
bool isShm() const;
QImage image() const;
+ void *waylandBuffer() const;
+
#ifdef QT_COMPOSITOR_WAYLAND_GL
/**
* There must be a GL context bound when calling this function.
diff --git a/src/compositor/compositor_api/qwaylandquickcompositor.cpp b/src/compositor/compositor_api/qwaylandquickcompositor.cpp
index 3a3c0ecea..db84ea5f8 100644
--- a/src/compositor/compositor_api/qwaylandquickcompositor.cpp
+++ b/src/compositor/compositor_api/qwaylandquickcompositor.cpp
@@ -51,7 +51,7 @@ public:
{
}
- void compositor_create_surface(Resource *resource, uint32_t id) Q_DECL_OVERRIDE
+ void compositor_create_surface(wl_compositor::Resource *resource, uint32_t id) Q_DECL_OVERRIDE
{
QWaylandQuickSurface *surface = new QWaylandQuickSurface(resource->client(), id, wl_resource_get_version(resource->handle), static_cast<QWaylandQuickCompositor *>(m_qt_compositor));
surface->handle()->addToOutput(primaryOutput()->handle());
diff --git a/src/compositor/compositor_api/qwaylandquicksurface.cpp b/src/compositor/compositor_api/qwaylandquicksurface.cpp
index a05a5f9c2..3d52b8624 100644
--- a/src/compositor/compositor_api/qwaylandquicksurface.cpp
+++ b/src/compositor/compositor_api/qwaylandquicksurface.cpp
@@ -41,89 +41,16 @@
#include "qwaylandquickcompositor.h"
#include "qwaylandsurfaceitem.h"
#include "qwaylandoutput.h"
-#include <QtCompositor/qwaylandbufferref.h>
#include <QtCompositor/private/qwaylandsurface_p.h>
+#include <QtCompositor/private/qwaylandtexturebufferattacher_p.h>
QT_BEGIN_NAMESPACE
-class BufferAttacher : public QWaylandBufferAttacher
-{
-public:
- BufferAttacher()
- : surface(0)
- , texture(0)
- , update(false)
- {
-
- }
-
- ~BufferAttacher()
- {
- if (texture)
- texture->deleteLater();
- bufferRef = QWaylandBufferRef();
- nextBuffer = QWaylandBufferRef();
- }
-
- void attach(const QWaylandBufferRef &ref) Q_DECL_OVERRIDE
- {
- nextBuffer = ref;
- update = true;
- }
-
- void createTexture()
- {
- bufferRef = nextBuffer;
- delete texture;
- texture = 0;
-
- QQuickWindow *window = static_cast<QQuickWindow *>(surface->mainOutput()->window());
- if (nextBuffer) {
- if (bufferRef.isShm()) {
- texture = window->createTextureFromImage(bufferRef.image());
- } else {
- QQuickWindow::CreateTextureOptions opt = 0;
- if (surface->useTextureAlpha()) {
- opt |= QQuickWindow::TextureHasAlphaChannel;
- }
- texture = window->createTextureFromId(bufferRef.createTexture(), surface->size(), opt);
- }
- texture->bind();
- }
-
- update = false;
- }
-
- void unmap() Q_DECL_OVERRIDE
- {
- nextBuffer = QWaylandBufferRef();
- update = true;
- }
-
- void invalidateTexture()
- {
- if (bufferRef)
- bufferRef.destroyTexture();
- delete texture;
- texture = 0;
- update = true;
- bufferRef = QWaylandBufferRef();
- }
-
- QWaylandQuickSurface *surface;
- QWaylandBufferRef bufferRef;
- QWaylandBufferRef nextBuffer;
- QSGTexture *texture;
- bool update;
-};
-
-
class QWaylandQuickSurfacePrivate : public QWaylandSurfacePrivate
{
public:
QWaylandQuickSurfacePrivate(wl_client *client, quint32 id, int version, QWaylandQuickCompositor *c, QWaylandQuickSurface *surf)
: QWaylandSurfacePrivate(client, id, version, c, surf)
- , buffer(new BufferAttacher)
, compositor(c)
, useTextureAlpha(true)
, windowPropertyMap(new QQmlPropertyMap)
@@ -146,7 +73,6 @@ public:
output->waylandOutput()->update();
}
- BufferAttacher *buffer;
QWaylandQuickCompositor *compositor;
bool useTextureAlpha;
QQmlPropertyMap *windowPropertyMap;
@@ -157,8 +83,7 @@ QWaylandQuickSurface::QWaylandQuickSurface(wl_client *client, quint32 id, int ve
: QWaylandSurface(new QWaylandQuickSurfacePrivate(client, id, version, compositor, this))
{
Q_D(QWaylandQuickSurface);
- d->buffer->surface = this;
- setBufferAttacher(d->buffer);
+ QWaylandSurface::setBufferAttacher(new QWaylandTextureBufferAttacher(this));
connect(this, &QWaylandSurface::windowPropertyChanged, d->windowPropertyMap, &QQmlPropertyMap::insert);
connect(d->windowPropertyMap, &QQmlPropertyMap::valueChanged, this, &QWaylandSurface::setWindowProperty);
@@ -169,10 +94,14 @@ QWaylandQuickSurface::~QWaylandQuickSurface()
}
+QWaylandTextureBufferAttacher *QWaylandQuickSurface::textureBufferAttacher() const
+{
+ return static_cast<QWaylandTextureBufferAttacher*>(bufferAttacher());
+}
+
QSGTexture *QWaylandQuickSurface::texture() const
{
- Q_D(const QWaylandQuickSurface);
- return d->buffer->texture;
+ return textureBufferAttacher()->texture();
}
bool QWaylandQuickSurface::useTextureAlpha() const
@@ -187,7 +116,7 @@ void QWaylandQuickSurface::setUseTextureAlpha(bool useTextureAlpha)
if (d->useTextureAlpha != useTextureAlpha) {
d->useTextureAlpha = useTextureAlpha;
emit useTextureAlphaChanged();
- emit configure(d->buffer->bufferRef);
+ emit configure(textureBufferAttacher()->currentBuffer());
}
}
@@ -234,18 +163,17 @@ bool QWaylandQuickSurface::event(QEvent *e)
void QWaylandQuickSurface::updateTexture()
{
- Q_D(QWaylandQuickSurface);
- const bool update = d->buffer->update;
- if (d->buffer->update)
- d->buffer->createTexture();
+ QWaylandTextureBufferAttacher *attacher = textureBufferAttacher();
+ const bool update = attacher->isDirty();
+ if (update)
+ attacher->updateTexture();
foreach (QWaylandSurfaceView *view, views())
static_cast<QWaylandSurfaceItem *>(view)->updateTexture(update);
}
void QWaylandQuickSurface::invalidateTexture()
{
- Q_D(QWaylandQuickSurface);
- d->buffer->invalidateTexture();
+ textureBufferAttacher()->invalidateTexture();
foreach (QWaylandSurfaceView *view, views())
static_cast<QWaylandSurfaceItem *>(view)->updateTexture(true);
emit redraw();
diff --git a/src/compositor/compositor_api/qwaylandquicksurface.h b/src/compositor/compositor_api/qwaylandquicksurface.h
index 4c37e6670..9126f8ff1 100644
--- a/src/compositor/compositor_api/qwaylandquicksurface.h
+++ b/src/compositor/compositor_api/qwaylandquicksurface.h
@@ -35,6 +35,7 @@
#define QQUICKWAYLANDSURFACE_H
#include <QtCompositor/qwaylandsurface.h>
+#include <QtCompositor/qwaylandbufferref.h>
struct wl_client;
@@ -45,6 +46,8 @@ class QSGTexture;
class QWaylandSurfaceItem;
class QWaylandQuickSurfacePrivate;
class QWaylandQuickCompositor;
+class QWaylandQuickSurface;
+class QWaylandTextureBufferAttacher;
class Q_COMPOSITOR_EXPORT QWaylandQuickSurface : public QWaylandSurface
{
@@ -67,6 +70,8 @@ public:
QObject *windowPropertyMap() const;
+ QWaylandTextureBufferAttacher *textureBufferAttacher() const;
+
private:
bool event(QEvent *event) Q_DECL_OVERRIDE;
diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp
index a8dc41fd5..64f78bd76 100644
--- a/src/compositor/compositor_api/qwaylandsurface.cpp
+++ b/src/compositor/compositor_api/qwaylandsurface.cpp
@@ -45,7 +45,6 @@
#include "wayland_wrapper/qwlsurface_p.h"
#include "wayland_wrapper/qwlextendedsurface_p.h"
-#include "wayland_wrapper/qwlsubsurface_p.h"
#include "wayland_wrapper/qwlcompositor_p.h"
#include "wayland_wrapper/qwlshellsurface_p.h"
#include "wayland_wrapper/qwlinputdevice_p.h"
@@ -160,24 +159,6 @@ QWaylandClient *QWaylandSurface::client() const
return d->client;
}
-QWaylandSurface *QWaylandSurface::parentSurface() const
-{
- Q_D(const QWaylandSurface);
- if (d->subSurface() && d->subSurface()->parent()) {
- return d->subSurface()->parent()->waylandSurface();
- }
- return 0;
-}
-
-QLinkedList<QWaylandSurface *> QWaylandSurface::subSurfaces() const
-{
- Q_D(const QWaylandSurface);
- if (d->subSurface()) {
- return d->subSurface()->subSurfaces();
- }
- return QLinkedList<QWaylandSurface *>();
-}
-
void QWaylandSurface::addInterface(QWaylandSurfaceInterface *iface)
{
Q_D(QWaylandSurface);
@@ -455,6 +436,9 @@ void QWaylandSurface::setMapped(bool mapped)
void QWaylandSurface::setBufferAttacher(QWaylandBufferAttacher *attacher)
{
Q_D(QWaylandSurface);
+ if (d->m_attacher) {
+ delete d->m_attacher;
+ }
d->m_attacher = attacher;
}
diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h
index db1e1fb44..acff69092 100644
--- a/src/compositor/compositor_api/qwaylandsurface.h
+++ b/src/compositor/compositor_api/qwaylandsurface.h
@@ -159,8 +159,6 @@ public:
QWaylandClient *client() const;
- QWaylandSurface *parentSurface() const;
- QLinkedList<QWaylandSurface *> subSurfaces() const;
void addInterface(QWaylandSurfaceInterface *interface);
void removeInterface(QWaylandSurfaceInterface *interface);
@@ -254,6 +252,9 @@ Q_SIGNALS:
void pong();
void surfaceDestroyed();
+ void viewAdded(QWaylandSurfaceView *view);
+ void viewRemoved(QWaylandSurfaceView *view);
+
void configure(bool hasBuffer);
void redraw();
diff --git a/src/compositor/compositor_api/qwaylandsurfaceitem.cpp b/src/compositor/compositor_api/qwaylandsurfaceitem.cpp
index ca746ae41..e964c9177 100644
--- a/src/compositor/compositor_api/qwaylandsurfaceitem.cpp
+++ b/src/compositor/compositor_api/qwaylandsurfaceitem.cpp
@@ -327,6 +327,11 @@ QPointF QWaylandSurfaceItem::pos() const
return position();
}
+void QWaylandSurfaceItem::setParentView(QWaylandSurfaceView *view)
+{
+ setParentItem(static_cast<QWaylandSurfaceItem *>(view));
+}
+
/*!
\qmlproperty bool QtWayland::QWaylandSurfaceItem::paintEnabled
diff --git a/src/compositor/compositor_api/qwaylandsurfaceitem.h b/src/compositor/compositor_api/qwaylandsurfaceitem.h
index cb51b6bfb..529b839c6 100644
--- a/src/compositor/compositor_api/qwaylandsurfaceitem.h
+++ b/src/compositor/compositor_api/qwaylandsurfaceitem.h
@@ -88,6 +88,8 @@ public:
void setPos(const QPointF &pos) Q_DECL_OVERRIDE;
QPointF pos() const Q_DECL_OVERRIDE;
+ void setParentView(QWaylandSurfaceView *view) Q_DECL_OVERRIDE;
+
protected:
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
diff --git a/src/compositor/compositor_api/qwaylandsurfaceview.cpp b/src/compositor/compositor_api/qwaylandsurfaceview.cpp
index 1d4ba304c..98ac81d5f 100644
--- a/src/compositor/compositor_api/qwaylandsurfaceview.cpp
+++ b/src/compositor/compositor_api/qwaylandsurfaceview.cpp
@@ -53,6 +53,7 @@ QWaylandSurfaceView::QWaylandSurfaceView(QWaylandSurface *surf)
if (surf) {
surf->d_func()->views << this;
surf->ref();
+ emit surf->viewAdded(this);
}
}
@@ -65,6 +66,7 @@ QWaylandSurfaceView::~QWaylandSurfaceView()
d->surface->destroy();
d->surface->d_func()->views.removeOne(this);
+ emit d->surface->viewRemoved(this);
}
delete d;
}
diff --git a/src/compositor/compositor_api/qwaylandsurfaceview.h b/src/compositor/compositor_api/qwaylandsurfaceview.h
index 2da19c264..dc0d93d91 100644
--- a/src/compositor/compositor_api/qwaylandsurfaceview.h
+++ b/src/compositor/compositor_api/qwaylandsurfaceview.h
@@ -55,6 +55,8 @@ public:
virtual void setPos(const QPointF &pos);
virtual QPointF pos() const;
+ virtual void setParentView(QWaylandSurfaceView *view) { Q_UNUSED(view) }
+
private:
class QWaylandSurfaceViewPrivate *const d;
friend class QWaylandSurfaceViewPrivate;
diff --git a/src/compositor/compositor_api/qwaylandtexturebufferattacher.cpp b/src/compositor/compositor_api/qwaylandtexturebufferattacher.cpp
new file mode 100644
index 000000000..11ead006e
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandtexturebufferattacher.cpp
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 LG Electronics Inc, author: <mikko.levonmaa@lge.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandtexturebufferattacher_p.h"
+
+#include <QQuickWindow>
+#include <QSGTexture>
+
+#include <QtCompositor/qwaylandquicksurface.h>
+#include <QtCompositor/qwaylandoutput.h>
+
+QWaylandTextureBufferAttacher::QWaylandTextureBufferAttacher(QWaylandQuickSurface *surface)
+ : m_surface(surface)
+ , m_texture(0)
+ , m_update(false)
+{
+}
+
+QWaylandTextureBufferAttacher::~QWaylandTextureBufferAttacher()
+{
+ if (m_texture)
+ m_texture->deleteLater();
+ m_buffer = QWaylandBufferRef();
+ m_nextBuffer = QWaylandBufferRef();
+}
+
+void QWaylandTextureBufferAttacher::attach(const QWaylandBufferRef &ref)
+{
+ m_nextBuffer = ref;
+ m_update = true;
+}
+
+void QWaylandTextureBufferAttacher::updateTexture()
+{
+ m_buffer = m_nextBuffer;
+ delete m_texture;
+ m_texture = 0;
+
+ QQuickWindow *window = static_cast<QQuickWindow *>(m_surface->mainOutput()->window());
+ if (m_nextBuffer) {
+ if (m_buffer.isShm()) {
+ m_texture = window->createTextureFromImage(m_buffer.image());
+ } else {
+ QQuickWindow::CreateTextureOptions opt = 0;
+ if (m_surface->useTextureAlpha()) {
+ opt |= QQuickWindow::TextureHasAlphaChannel;
+ }
+ m_texture = window->createTextureFromId(m_buffer.createTexture(), m_surface->size(), opt);
+ }
+ m_texture->bind();
+ }
+
+ m_update = false;
+}
+
+void QWaylandTextureBufferAttacher::unmap()
+{
+ m_nextBuffer = QWaylandBufferRef();
+ m_update = true;
+}
+
+void QWaylandTextureBufferAttacher::invalidateTexture()
+{
+ if (m_buffer)
+ m_buffer.destroyTexture();
+ delete m_texture;
+ m_texture = 0;
+ m_update = true;
+ m_buffer = QWaylandBufferRef();
+}
+
diff --git a/src/compositor/compositor_api/qwaylandtexturebufferattacher_p.h b/src/compositor/compositor_api/qwaylandtexturebufferattacher_p.h
new file mode 100644
index 000000000..05a3c99e1
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandtexturebufferattacher_p.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 LG Electronics Inc, author: <mikko.levonmaa@lge.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDTEXTUREBUFFERATTACHER_H
+#define QWAYLANDTEXTUREBUFFERATTACHER_H
+
+#include <QtCompositor/qwaylandsurface.h>
+#include <QtCompositor/qwaylandbufferref.h>
+
+QT_BEGIN_NAMESPACE
+
+class QSGTexture;
+class QWaylandQuickSurface;
+
+class QWaylandTextureBufferAttacher : public QWaylandBufferAttacher
+{
+public:
+ QWaylandTextureBufferAttacher(QWaylandQuickSurface *surface);
+ virtual ~QWaylandTextureBufferAttacher();
+
+ void updateTexture();
+ void invalidateTexture();
+
+ bool isDirty() const { return m_update; }
+ QSGTexture* texture() const { return m_texture; }
+ QWaylandBufferRef currentBuffer() const { return m_buffer; }
+
+protected:
+ virtual void attach(const QWaylandBufferRef &ref) Q_DECL_OVERRIDE;
+ virtual void unmap() Q_DECL_OVERRIDE;
+
+ QWaylandQuickSurface *m_surface;
+ QSGTexture *m_texture;
+
+ QWaylandBufferRef m_buffer;
+ QWaylandBufferRef m_nextBuffer;
+ bool m_update;
+};
+
+QT_END_NAMESPACE
+#endif
+
+
diff --git a/src/compositor/wayland_wrapper/qwlcompositor.cpp b/src/compositor/wayland_wrapper/qwlcompositor.cpp
index f8c8bdc1f..b1dd49dcd 100644
--- a/src/compositor/wayland_wrapper/qwlcompositor.cpp
+++ b/src/compositor/wayland_wrapper/qwlcompositor.cpp
@@ -173,7 +173,6 @@ Compositor::Compositor(QWaylandCompositor *qt_compositor, QWaylandCompositor::Ex
#endif
, m_windowManagerIntegration(0)
, m_surfaceExtension(0)
- , m_subSurfaceExtension(0)
, m_touchExtension(0)
, m_qtkeyExtension(0)
, m_textInputManager()
@@ -196,6 +195,7 @@ void Compositor::init()
m_socket_name = arguments.at(socketArg + 1).toLocal8Bit();
wl_compositor::init(m_display->handle(), 3);
+ wl_subcompositor::init(m_display->handle(), 1);
m_data_device_manager = new DataDeviceManager(this);
@@ -239,7 +239,6 @@ Compositor::~Compositor()
qDeleteAll(m_outputs);
delete m_surfaceExtension;
- delete m_subSurfaceExtension;
delete m_touchExtension;
delete m_qtkeyExtension;
@@ -348,7 +347,7 @@ void Compositor::cleanupGraphicsResources()
m_destroyed_surfaces.clear();
}
-void Compositor::compositor_create_surface(Resource *resource, uint32_t id)
+void Compositor::compositor_create_surface(wl_compositor::Resource *resource, uint32_t id)
{
QWaylandSurface *surface = new QWaylandSurface(resource->client(), id, resource->version(), m_qt_compositor);
m_surfaces << surface->handle();
@@ -357,7 +356,7 @@ void Compositor::compositor_create_surface(Resource *resource, uint32_t id)
m_qt_compositor->surfaceCreated(surface);
}
-void Compositor::compositor_create_region(Resource *resource, uint32_t id)
+void Compositor::compositor_create_region(wl_compositor::Resource *resource, uint32_t id)
{
Q_UNUSED(compositor);
new Region(resource->client(), id);
@@ -374,6 +373,33 @@ void Compositor::destroyClient(QWaylandClient *client)
wl_client_destroy(client->client());
}
+void Compositor::subcompositor_destroy(wl_subcompositor::Resource *resource)
+{
+ wl_resource_destroy(resource->handle);
+}
+
+void Compositor::subcompositor_get_subsurface(wl_subcompositor::Resource *resource, uint32_t id, wl_resource *surface, wl_resource *parent)
+{
+ Surface *s = Surface::fromResource(surface);
+ Surface *p = Surface::fromResource(parent);
+
+ static const char where[] = "get_subsurface: wl_subsurface@";
+ if (s == p) {
+ wl_resource_post_error(resource->handle, WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE, "%s%d: wl_surface@%d cannot be its own parent", where, id, wl_resource_get_id(surface));
+ return;
+ }
+ if (SubSurface::get(s)) {
+ wl_resource_post_error(resource->handle, WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE, "%s%d: wl_surface@%d is already a sub-surface", where, id, wl_resource_get_id(surface));
+ return;
+ }
+
+ if (!s->setRole(SubSurface::role(), resource->handle, WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE))
+ return;
+
+ SubSurface *ss = new SubSurface(s, p, resource->client(), id, resource->version());
+ s->setRoleHandler(ss);
+}
+
ClientBufferIntegration * Compositor::clientBufferIntegration() const
{
#ifdef QT_COMPOSITOR_WAYLAND_GL
@@ -412,8 +438,6 @@ void Compositor::initializeExtensions()
{
if (m_extensions & QWaylandCompositor::SurfaceExtension)
m_surfaceExtension = new SurfaceExtensionGlobal(this);
- if (m_extensions & QWaylandCompositor::SubSurfaceExtension)
- m_subSurfaceExtension = new SubSurfaceExtensionGlobal(this);
if (m_extensions & QWaylandCompositor::TouchExtension)
m_touchExtension = new TouchExtensionGlobal(this);
if (m_extensions & QWaylandCompositor::QtKeyExtension)
diff --git a/src/compositor/wayland_wrapper/qwlcompositor_p.h b/src/compositor/wayland_wrapper/qwlcompositor_p.h
index 0ba30eb20..6fd63d748 100644
--- a/src/compositor/wayland_wrapper/qwlcompositor_p.h
+++ b/src/compositor/wayland_wrapper/qwlcompositor_p.h
@@ -96,7 +96,7 @@ class HardwareIntegration;
class ClientBufferIntegration;
class ServerBufferIntegration;
-class Q_COMPOSITOR_EXPORT Compositor : public QObject, public QtWaylandServer::wl_compositor
+class Q_COMPOSITOR_EXPORT Compositor : public QObject, public QtWaylandServer::wl_compositor, public QtWaylandServer::wl_subcompositor
{
Q_OBJECT
@@ -178,8 +178,11 @@ public slots:
void cleanupGraphicsResources();
protected:
- void compositor_create_surface(Resource *resource, uint32_t id) Q_DECL_OVERRIDE;
- void compositor_create_region(Resource *resource, uint32_t id) Q_DECL_OVERRIDE;
+ void compositor_create_surface(wl_compositor::Resource *resource, uint32_t id) Q_DECL_OVERRIDE;
+ void compositor_create_region(wl_compositor::Resource *resource, uint32_t id) Q_DECL_OVERRIDE;
+ void subcompositor_destroy(wl_subcompositor::Resource *resource) Q_DECL_OVERRIDE;
+ void subcompositor_get_subsurface(wl_subcompositor::Resource *resource, uint32_t id, wl_resource *surface, wl_resource *parent) Q_DECL_OVERRIDE;
+
private slots:
void processWaylandEvents();
@@ -226,7 +229,6 @@ protected:
WindowManagerServerIntegration *m_windowManagerIntegration;
SurfaceExtensionGlobal *m_surfaceExtension;
- SubSurfaceExtensionGlobal *m_subSurfaceExtension;
TouchExtensionGlobal *m_touchExtension;
QtKeyExtensionGlobal *m_qtkeyExtension;
QScopedPointer<TextInputManager> m_textInputManager;
diff --git a/src/compositor/wayland_wrapper/qwlsubsurface.cpp b/src/compositor/wayland_wrapper/qwlsubsurface.cpp
index afc6d1825..5d2dc5306 100644
--- a/src/compositor/wayland_wrapper/qwlsubsurface.cpp
+++ b/src/compositor/wayland_wrapper/qwlsubsurface.cpp
@@ -38,154 +38,113 @@
**
****************************************************************************/
+#include <QDebug>
+
#include "qwlsubsurface_p.h"
#include "qwlcompositor_p.h"
#include "qwaylandsurface.h"
#include "qwaylandsurfaceview.h"
+#include "qwaylandsurfaceitem.h"
+
QT_BEGIN_NAMESPACE
namespace QtWayland {
-SubSurfaceExtensionGlobal::SubSurfaceExtensionGlobal(Compositor *compositor)
- : m_compositor(compositor)
+SubSurface::SubSurface(Surface *surface, Surface *parent, wl_client *client, uint32_t id, int version)
+ : QtWaylandServer::wl_subsurface(client, id, version)
+ , m_surface(surface)
+ , m_parent(parent)
+ , m_synchronized(true)
{
- wl_global_create(m_compositor->wl_display(),
- &qt_sub_surface_extension_interface,
- qt_sub_surface_extension_interface.version,
- this,
- SubSurfaceExtensionGlobal::bind_func);
-}
+ parent->addSubSurface(this);
+ QWaylandSurface *p = parent->waylandSurface();
-void SubSurfaceExtensionGlobal::bind_func(wl_client *client, void *data, uint32_t version, uint32_t id)
-{
- Q_UNUSED(version);
- struct wl_resource *resource = wl_resource_create(client, &qt_sub_surface_extension_interface,version,id);
- wl_resource_set_implementation(resource, &sub_surface_extension_interface, data, 0);
+ foreach (QWaylandSurfaceView *v, p->views())
+ createSubView(v);
+ connect(p, &QWaylandSurface::viewAdded, this, &SubSurface::createSubView);
}
-void SubSurfaceExtensionGlobal::get_sub_surface_aware_surface(wl_client *client, wl_resource *sub_surface_extension_resource, uint32_t id, wl_resource *surface_resource)
+SubSurface::~SubSurface()
{
- Q_UNUSED(sub_surface_extension_resource);
- Surface *surface = Surface::fromResource(surface_resource);
- new SubSurface(client,id,surface);
-}
-
-const struct qt_sub_surface_extension_interface SubSurfaceExtensionGlobal::sub_surface_extension_interface = {
- SubSurfaceExtensionGlobal::get_sub_surface_aware_surface
-};
+ qDeleteAll(m_views);
-SubSurface::SubSurface(wl_client *client, uint32_t id, Surface *surface)
- : m_surface(surface)
- , m_parent(0)
-{
- surface->setSubSurface(this);
- m_sub_surface_resource = wl_resource_create(client, &qt_sub_surface_interface, qt_sub_surface_interface.version, id);
- wl_resource_set_implementation(m_sub_surface_resource, &sub_surface_interface, this, 0);
+ m_surface->setSubSurface(Q_NULLPTR);
+ m_parent->removeSubSurface(this);
}
-SubSurface::~SubSurface()
+const SurfaceRole *SubSurface::role()
{
- if (m_parent) {
- m_parent->removeSubSurface(this);
- }
- QLinkedList<QWaylandSurface *>::iterator it;
- for (it = m_sub_surfaces.begin(); it != m_sub_surfaces.end(); ++it) {
- (*it)->handle()->subSurface()->parentDestroyed();
- }
+ static const SurfaceRole role = { "subsurface" };
+ return &role;
}
-void SubSurface::setSubSurface(SubSurface *subSurface, int x, int y)
+void SubSurface::parentCommit()
{
- if (!m_sub_surfaces.contains(subSurface->m_surface->waylandSurface())) {
- m_sub_surfaces.append(subSurface->m_surface->waylandSurface());
- subSurface->setParent(this);
+ foreach (QWaylandSurfaceView *view, m_views) {
+ view->setPos(m_position);
}
- foreach (QWaylandSurfaceView *view, subSurface->m_surface->waylandSurface()->views())
- view->setPos(QPointF(x,y));
}
-void SubSurface::removeSubSurface(SubSurface *subSurfaces)
+void SubSurface::configure(int dx, int dy)
{
- Q_ASSERT(m_sub_surfaces.contains(subSurfaces->m_surface->waylandSurface()));
- m_sub_surfaces.removeOne(subSurfaces->m_surface->waylandSurface());
+ Q_UNUSED(dx)
+ Q_UNUSED(dy)
}
-SubSurface *SubSurface::parent() const
+void SubSurface::createSubView(QWaylandSurfaceView *view)
{
- return m_parent;
+ QWaylandSurfaceView *v = m_surface->compositor()->waylandCompositor()->createView(m_surface->waylandSurface());
+ v->setParentView(view);
+ v->setPos(m_position);
+ m_views << v;
}
-void SubSurface::setParent(SubSurface *parent)
+void SubSurface::subsurface_destroy_resource(Resource *resource)
{
- if (m_parent == parent)
- return;
-
- QWaylandSurface *oldParent = 0;
- QWaylandSurface *newParent = 0;
-
- if (m_parent) {
- oldParent = m_parent->m_surface->waylandSurface();
- m_parent->removeSubSurface(this);
- }
- if (parent) {
- newParent = parent->m_surface->waylandSurface();
- }
- m_parent = parent;
-
- m_surface->waylandSurface()->parentChanged(newParent,oldParent);
+ Q_UNUSED(resource)
+ delete this;
}
-QLinkedList<QWaylandSurface *> SubSurface::subSurfaces() const
+void SubSurface::subsurface_destroy(Resource *resource)
{
- return m_sub_surfaces;
+ wl_resource_destroy(resource->handle);
}
-void SubSurface::parentDestroyed()
+void SubSurface::subsurface_set_position(Resource *resource, int32_t x, int32_t y)
{
- m_parent = 0;
+ Q_UNUSED(resource)
+
+ m_position = QPoint(x, y);
}
-void SubSurface::attach_sub_surface(wl_client *client, wl_resource *sub_surface_parent_resource, wl_resource *sub_surface_child_resource, int32_t x, int32_t y)
+
+void SubSurface::subsurface_place_above(Resource *resource, ::wl_resource *sibling)
{
- Q_UNUSED(client);
- SubSurface *parent_sub_surface = static_cast<SubSurface *>(sub_surface_parent_resource->data);
- SubSurface *child_sub_surface = static_cast<SubSurface *>(sub_surface_child_resource->data);
- parent_sub_surface->setSubSurface(child_sub_surface,x,y);
+ Q_UNUSED(resource)
+ Q_UNUSED(sibling)
+ qWarning("wl_subsurface.place_above not implemented");
}
-void SubSurface::move_sub_surface(wl_client *client, wl_resource *sub_surface_parent_resource, wl_resource *sub_surface_child_resource, int32_t x, int32_t y)
+void SubSurface::subsurface_place_below(Resource *resource, ::wl_resource *sibling)
{
- Q_UNUSED(client);
- Q_UNUSED(x);
- Q_UNUSED(y);
- SubSurface *parent_sub_surface = static_cast<SubSurface *>(sub_surface_parent_resource->data);
- SubSurface *child_sub_surface = static_cast<SubSurface *>(sub_surface_child_resource->data);
- Q_UNUSED(parent_sub_surface);
- Q_UNUSED(child_sub_surface);
+ Q_UNUSED(resource)
+ Q_UNUSED(sibling)
+ qWarning("wl_subsurface.place_below not implemented");
}
-void SubSurface::raise(wl_client *client, wl_resource *sub_surface_parent_resource, wl_resource *sub_surface_child_resource)
+void SubSurface::subsurface_set_sync(Resource *resource)
{
- Q_UNUSED(client);
- Q_UNUSED(sub_surface_parent_resource);
- Q_UNUSED(sub_surface_child_resource);
+ Q_UNUSED(resource)
+ qWarning("wl_subsurface.set_sync not implemented");
}
-void SubSurface::lower(wl_client *client, wl_resource *sub_surface_parent_resource, wl_resource *sub_surface_child_resource)
+void SubSurface::subsurface_set_desync(Resource *resource)
{
- Q_UNUSED(client);
- Q_UNUSED(sub_surface_parent_resource);
- Q_UNUSED(sub_surface_child_resource);
+ Q_UNUSED(resource)
+ qWarning("wl_subsurface.set_desync not implemented");
}
-const struct qt_sub_surface_interface SubSurface::sub_surface_interface = {
- SubSurface::attach_sub_surface,
- SubSurface::move_sub_surface,
- SubSurface::raise,
- SubSurface::lower
-};
-
}
QT_END_NAMESPACE
diff --git a/src/compositor/wayland_wrapper/qwlsubsurface_p.h b/src/compositor/wayland_wrapper/qwlsubsurface_p.h
index bce79342d..2046ec62b 100644
--- a/src/compositor/wayland_wrapper/qwlsubsurface_p.h
+++ b/src/compositor/wayland_wrapper/qwlsubsurface_p.h
@@ -54,8 +54,9 @@
#include <private/qwlsurface_p.h>
-#include <QtCompositor/private/wayland-sub-surface-extension-server-protocol.h>
+#include <QtCompositor/private/qwayland-server-wayland.h>
+#include <QtCore/QObject>
#include <QtCore/QLinkedList>
QT_BEGIN_NAMESPACE
@@ -65,78 +66,36 @@ class QWaylandSurface;
namespace QtWayland {
-class SubSurfaceExtensionGlobal
+class SubSurface : public QObject, public QtWaylandServer::wl_subsurface, public SurfaceRoleHandler<SubSurface>
{
public:
- SubSurfaceExtensionGlobal(Compositor *compositor);
-
-private:
- Compositor *m_compositor;
-
- static void bind_func(struct wl_client *client, void *data,
- uint32_t version, uint32_t id);
- static void get_sub_surface_aware_surface(struct wl_client *client,
- struct wl_resource *sub_surface_extension_resource,
- uint32_t id,
- struct wl_resource *surface_resource);
-
- static const struct qt_sub_surface_extension_interface sub_surface_extension_interface;
-};
-
-class SubSurface
-{
-public:
- SubSurface(struct wl_client *client, uint32_t id, Surface *surface);
+ SubSurface(Surface *surface, Surface *parent, wl_client *client, uint32_t id, int version);
~SubSurface();
- void setSubSurface(SubSurface *subSurface, int x, int y);
- void removeSubSurface(SubSurface *subSurfaces);
-
- SubSurface *parent() const;
- void setParent(SubSurface *parent);
+ static const SurfaceRole *role();
- QLinkedList<QWaylandSurface *> subSurfaces() const;
+ void parentCommit();
- Surface *surface() const;
- QWaylandSurface *waylandSurface() const;
+protected:
+ void configure(int dx, int dy) Q_DECL_OVERRIDE;
+ void subsurface_destroy_resource(Resource *resource) Q_DECL_OVERRIDE;
+ void subsurface_destroy(Resource *resource) Q_DECL_OVERRIDE;
+ void subsurface_set_position(Resource *resource, int32_t x, int32_t y) Q_DECL_OVERRIDE;
+ void subsurface_place_above(Resource *resource, ::wl_resource *sibling) Q_DECL_OVERRIDE;
+ void subsurface_place_below(Resource *resource, ::wl_resource *sibling) Q_DECL_OVERRIDE;
+ void subsurface_set_sync(Resource *resource) Q_DECL_OVERRIDE;
+ void subsurface_set_desync(Resource *resource) Q_DECL_OVERRIDE;
private:
- void parentDestroyed();
- struct wl_resource *m_sub_surface_resource;
- Surface *m_surface;
+ void createSubView(QWaylandSurfaceView *view);
- SubSurface *m_parent;
- QLinkedList<QWaylandSurface *> m_sub_surfaces;
-
- static void attach_sub_surface(struct wl_client *client,
- struct wl_resource *sub_surface_parent_resource,
- struct wl_resource *sub_surface_child_resource,
- int32_t x,
- int32_t y);
- static void move_sub_surface(struct wl_client *client,
- struct wl_resource *sub_surface_parent_resource,
- struct wl_resource *sub_surface_child_resource,
- int32_t x,
- int32_t y);
- static void raise(struct wl_client *client,
- struct wl_resource *sub_surface_parent_resource,
- struct wl_resource *sub_surface_child_resource);
- static void lower(struct wl_client *client,
- struct wl_resource *sub_surface_parent_resource,
- struct wl_resource *sub_surface_child_resource);
- static const struct qt_sub_surface_interface sub_surface_interface;
+ Surface *m_surface;
+ Surface *m_parent;
+ QPoint m_position;
+ bool m_synchronized;
+ QVector<QWaylandSurfaceView *> m_views;
};
-inline Surface *SubSurface::surface() const
-{
- return m_surface;
-}
-
-inline QWaylandSurface *SubSurface::waylandSurface() const
-{
- return m_surface->waylandSurface();
-}
-
}
QT_END_NAMESPACE
diff --git a/src/compositor/wayland_wrapper/qwlsurface.cpp b/src/compositor/wayland_wrapper/qwlsurface.cpp
index d23c6aeb0..eb79d9c10 100644
--- a/src/compositor/wayland_wrapper/qwlsurface.cpp
+++ b/src/compositor/wayland_wrapper/qwlsurface.cpp
@@ -276,6 +276,21 @@ SubSurface *Surface::subSurface() const
return m_subSurface;
}
+void Surface::addSubSurface(SubSurface *ss)
+{
+ m_subsurfaces << ss;
+}
+
+void Surface::removeSubSurface(SubSurface *ss)
+{
+ for (QVector<SubSurface *>::iterator i = m_subsurfaces.begin(); i != m_subsurfaces.end(); ++i) {
+ if (*i == ss) {
+ m_subsurfaces.erase(i);
+ return;
+ }
+ }
+}
+
void Surface::setInputPanelSurface(InputPanelSurface *inputPanelSurface)
{
m_inputPanelSurface = inputPanelSurface;
@@ -514,6 +529,9 @@ void Surface::surface_commit(Resource *)
m_pending.newlyAttached = false;
m_pending.damage = QRegion();
+ foreach (SubSurface *ss, m_subsurfaces)
+ ss->parentCommit();
+
if (m_buffer)
m_buffer->setCommitted();
diff --git a/src/compositor/wayland_wrapper/qwlsurface_p.h b/src/compositor/wayland_wrapper/qwlsurface_p.h
index 343955c1a..9cb9b5145 100644
--- a/src/compositor/wayland_wrapper/qwlsurface_p.h
+++ b/src/compositor/wayland_wrapper/qwlsurface_p.h
@@ -128,6 +128,8 @@ public:
void setSubSurface(SubSurface *subSurface);
SubSurface *subSurface() const;
+ void addSubSurface(SubSurface *ss);
+ void removeSubSurface(SubSurface *ss);
void setInputPanelSurface(InputPanelSurface *inputPanelSurface);
InputPanelSurface *inputPanelSurface() const;
@@ -236,6 +238,7 @@ protected:
bool m_destroyed;
Qt::ScreenOrientation m_contentOrientation;
QWindow::Visibility m_visibility;
+ QVector<SubSurface *> m_subsurfaces;
const SurfaceRole *m_role;
RoleBase *m_roleHandler;
diff --git a/src/compositor/wayland_wrapper/wayland_wrapper.pri b/src/compositor/wayland_wrapper/wayland_wrapper.pri
index eb66f6949..d65798711 100644
--- a/src/compositor/wayland_wrapper/wayland_wrapper.pri
+++ b/src/compositor/wayland_wrapper/wayland_wrapper.pri
@@ -1,7 +1,6 @@
CONFIG += wayland-scanner
WAYLANDSERVERSOURCES += \
../extensions/surface-extension.xml \
- ../extensions/sub-surface-extension.xml \
../extensions/touch-extension.xml \
../extensions/qtkey-extension.xml \
../extensions/windowmanager.xml \
diff --git a/src/extensions/sub-surface-extension.xml b/src/extensions/sub-surface-extension.xml
deleted file mode 100644
index 4ea87e203..000000000
--- a/src/extensions/sub-surface-extension.xml
+++ /dev/null
@@ -1,69 +0,0 @@
-<protocol name="sub_surface_extension">
-
- <copyright>
- Copyright (C) 2015 The Qt Company Ltd.
- Contact: http://www.qt.io/licensing/
-
- This file is part of the plugins of the Qt Toolkit.
-
- $QT_BEGIN_LICENSE:BSD$
- You may use this file under the terms of the BSD license as follows:
-
- "Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
- * Neither the name of The Qt Company Ltd nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-
- $QT_END_LICENSE$
- </copyright>
-
- <interface name="qt_sub_surface_extension" version="1">
- <request name="get_sub_surface_aware_surface">
- <arg name="id" type="new_id" interface="qt_sub_surface"/>
- <arg name="surface" type="object" interface="wl_surface"/>
- </request>
- </interface>
-
- <interface name="qt_sub_surface" version="1">
- <request name="attach_sub_surface">
- <arg name="sub_surface" type="object" interface="qt_sub_surface"/>
- <arg name="x" type="int"/>
- <arg name="y" type="int"/>
- </request>
-
- <request name="move_sub_surface">
- <arg name="sub_surface" type="object" interface="qt_sub_surface"/>
- <arg name="x" type="int"/>
- <arg name="y" type="int"/>
- </request>
-
- <request name="raise">
- <arg name="sub_surface" type="object" interface="qt_sub_surface"/>
- </request>
-
- <request name="lower">
- <arg name="sub_surface" type="object" interface="qt_sub_surface"/>
- </request>
- </interface>
-</protocol>