summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGiulio Camuffo <giulio.camuffo@jollamobile.com>2014-07-03 16:37:47 +0300
committerGiulio Camuffo <giulio.camuffo@jollamobile.com>2014-07-30 16:52:41 +0200
commit4f39034927ebc76c6e7fde5fe692eaa88c085734 (patch)
tree098f035cb30d83dca1f3efaedd59350ea1fa4e4e /src
parentc6f604d2fa3acafce05de15cb9f3195572e39285 (diff)
Introduce QWaylandSurfaceInterface
Wayland is designed to be easily extensible with new protocol, unfortunately it currently isn't possible with QtCompositor. A QtWayland compositor has two ends: the Wayland end and the shell/wm end, which may be implemented in QML. These two ends communicate mainly through the QWaylandSurface and the QWaylandSurfaceView classes, but the Wayland end is currently unable to hook into custom protocol extensions. This is the purpose of the new QWaylandSurfaceInterface class, and of QWaylandSurfaceOp and its subclasses: based on the QEvent model, QWaylandSurfaceOp has only a type member, and its type specific subclasses have additional data if needed. A custom protocol implementation, such as xdg_surface or my_fancy_surface, will use a QWaylandSurfaceInterface subclass which will call its specific protocol functions when it gets the relative operation requests from the parent surface. The QWaylandShellSurface class is now redundant so it is removed. Change-Id: I37a86157a251626215f57ce030c77a26bfd65126 Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'src')
-rw-r--r--src/compositor/compositor_api/compositor_api.pri4
-rw-r--r--src/compositor/compositor_api/qwaylandshellsurface.cpp69
-rw-r--r--src/compositor/compositor_api/qwaylandshellsurface.h73
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.cpp84
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.h12
-rw-r--r--src/compositor/compositor_api/qwaylandsurface_p.h3
-rw-r--r--src/compositor/compositor_api/qwaylandsurfaceinterface.cpp119
-rw-r--r--src/compositor/compositor_api/qwaylandsurfaceinterface.h121
-rw-r--r--src/compositor/wayland_wrapper/qwlextendedsurface.cpp18
-rw-r--r--src/compositor/wayland_wrapper/qwlextendedsurface_p.h6
-rw-r--r--src/compositor/wayland_wrapper/qwlshellsurface.cpp38
-rw-r--r--src/compositor/wayland_wrapper/qwlshellsurface_p.h15
-rw-r--r--src/compositor/wayland_wrapper/qwlsurface.cpp13
-rw-r--r--src/compositor/wayland_wrapper/qwlsurface_p.h5
14 files changed, 370 insertions, 210 deletions
diff --git a/src/compositor/compositor_api/compositor_api.pri b/src/compositor/compositor_api/compositor_api.pri
index ed43e2d97..1a1a15a9a 100644
--- a/src/compositor/compositor_api/compositor_api.pri
+++ b/src/compositor/compositor_api/compositor_api.pri
@@ -11,7 +11,7 @@ HEADERS += \
compositor_api/qwaylandbufferref.h \
compositor_api/qwaylandsurfaceview.h \
compositor_api/qwaylandglobalinterface.h \
- compositor_api/qwaylandshellsurface.h
+ compositor_api/qwaylandsurfaceinterface.h
SOURCES += \
compositor_api/qwaylandcompositor.cpp \
@@ -22,7 +22,7 @@ SOURCES += \
compositor_api/qwaylandbufferref.cpp \
compositor_api/qwaylandsurfaceview.cpp \
compositor_api/qwaylandglobalinterface.cpp \
- compositor_api/qwaylandshellsurface.cpp
+ compositor_api/qwaylandsurfaceinterface.cpp
QT += core-private
diff --git a/src/compositor/compositor_api/qwaylandshellsurface.cpp b/src/compositor/compositor_api/qwaylandshellsurface.cpp
deleted file mode 100644
index 70b853ce3..000000000
--- a/src/compositor/compositor_api/qwaylandshellsurface.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 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 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <private/qobject_p.h>
-
-#include "qwaylandshellsurface.h"
-#include "qwlsurface_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QWaylandShellSurfacePrivate : public QObjectPrivate
-{
-public:
- QWaylandSurface *surface;
-};
-
-QWaylandShellSurface::QWaylandShellSurface(QWaylandSurface *surf)
- : QObject(*new QWaylandShellSurfacePrivate)
-{
- Q_D(QWaylandShellSurface);
- d->surface = surf;
- surf->handle()->setShellSurface(this);
-}
-
-QWaylandShellSurface::~QWaylandShellSurface()
-{
- Q_D(QWaylandShellSurface);
- d->surface->handle()->setShellSurface(Q_NULLPTR);
-}
-
-QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandshellsurface.h b/src/compositor/compositor_api/qwaylandshellsurface.h
deleted file mode 100644
index 030847372..000000000
--- a/src/compositor/compositor_api/qwaylandshellsurface.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 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 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWAYLANDSHELLSURFACE_H
-#define QWAYLANDSHELLSURFACE_H
-
-#include <QObject>
-
-#include <QtCompositor/qwaylandexport.h>
-
-#include "QtCompositor/qwaylandsurface.h"
-
-QT_BEGIN_NAMESPACE
-
-class QWaylandSurface;
-class QWaylandShellSurfacePrivate;
-
-class Q_COMPOSITOR_EXPORT QWaylandShellSurface : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QWaylandShellSurface)
-public:
- QWaylandShellSurface(QWaylandSurface *surface);
- virtual ~QWaylandShellSurface();
-
- // This could be const but it makes sense for it to not be, since
- // it's supposed to modify the surface
- virtual void requestSize(const QSize &size) = 0;
- virtual void ping(uint32_t serial) = 0;
- virtual QWaylandSurface::WindowType windowType() const = 0;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp
index 14d909490..a1a317707 100644
--- a/src/compositor/compositor_api/qwaylandsurface.cpp
+++ b/src/compositor/compositor_api/qwaylandsurface.cpp
@@ -54,6 +54,7 @@
#include "qwaylandcompositor.h"
#include "qwaylandsurface_p.h"
#include "qwaylandbufferref.h"
+#include "qwaylandsurfaceinterface.h"
#include <QtGui/QGuiApplication>
#include <QtGui/QScreen>
@@ -64,6 +65,7 @@ QWaylandSurfacePrivate::QWaylandSurfacePrivate(wl_client *client, quint32 id, QW
: QtWayland::Surface(client, id, compositor, surface)
, closing(false)
, refCount(1)
+ , windowType(QWaylandSurface::WindowType::None)
{}
@@ -83,6 +85,7 @@ QWaylandSurface::QWaylandSurface(QWaylandSurfacePrivate *dptr)
QWaylandSurface::~QWaylandSurface()
{
Q_D(QWaylandSurface);
+ qDeleteAll(d->interfaces);
delete d->m_attacher;
}
@@ -110,6 +113,18 @@ QLinkedList<QWaylandSurface *> QWaylandSurface::subSurfaces() const
return QLinkedList<QWaylandSurface *>();
}
+void QWaylandSurface::addInterface(QWaylandSurfaceInterface *iface)
+{
+ Q_D(QWaylandSurface);
+ d->interfaces.prepend(iface);
+}
+
+void QWaylandSurface::removeInterface(QWaylandSurfaceInterface *iface)
+{
+ Q_D(QWaylandSurface);
+ d->interfaces.removeOne(iface);
+}
+
QWaylandSurface::Type QWaylandSurface::type() const
{
Q_D(const QWaylandSurface);
@@ -142,11 +157,10 @@ QSize QWaylandSurface::size() const
void QWaylandSurface::requestSize(const QSize &size)
{
Q_D(QWaylandSurface);
- if (d->shellSurface()) {
- d->shellSurface()->requestSize(size);
- } else {
+ QWaylandSurfaceResizeOp op(size);
+ if (!sendInterfaceOp(op)) {
int id = wl_resource_get_id(d->resource()->handle);
- qWarning("No shell surface attached to this surface (wl_surface@%d). Cannot forward requestSize call.", id);
+ qWarning("No surface interface forwarded the resize request for this surface (wl_surface@%d).", id);
}
}
@@ -175,9 +189,16 @@ QWaylandSurface::WindowFlags QWaylandSurface::windowFlags() const
QWaylandSurface::WindowType QWaylandSurface::windowType() const
{
Q_D(const QWaylandSurface);
- if (d->shellSurface())
- return d->shellSurface()->windowType();
- return QWaylandSurface::None;
+ return d->windowType;
+}
+
+void QWaylandSurface::setWindowType(WindowType type)
+{
+ Q_D(QWaylandSurface);
+ if (d->windowType != type) {
+ d->windowType = type;
+ emit windowTypeChanged(type);
+ }
}
QtWayland::Surface * QWaylandSurface::handle()
@@ -233,20 +254,28 @@ QWindow::Visibility QWaylandSurface::visibility() const
void QWaylandSurface::setVisibility(QWindow::Visibility visibility)
{
+ QWaylandSurfaceSetVisibilityOp op(visibility);
+ sendInterfaceOp(op);
+}
+
+bool QWaylandSurface::sendInterfaceOp(QWaylandSurfaceOp &op)
+{
Q_D(QWaylandSurface);
- if (d->extendedSurface())
- d->extendedSurface()->setVisibility(visibility);
+ foreach (QWaylandSurfaceInterface *iface, d->interfaces) {
+ if (iface->runOperation(&op))
+ return true;
+ }
+ return false;
}
void QWaylandSurface::ping()
{
Q_D(QWaylandSurface);
- if (d->shellSurface()) {
- uint32_t serial = wl_display_next_serial(compositor()->waylandDisplay());
- d->shellSurface()->ping(serial);
- } else {
+ uint32_t serial = wl_display_next_serial(compositor()->waylandDisplay());
+ QWaylandSurfacePingOp op(serial);
+ if (!sendInterfaceOp(op)) {
int id = wl_resource_get_id(d->resource()->handle);
- qWarning("No shell surface attached to this surface (wl_surface@%d). Cannot forward ping call.", id);
+ qWarning("No surface interface forwarded the ping for this surface (wl_surface@%d).", id);
}
}
@@ -292,12 +321,9 @@ void QWaylandSurface::destroy()
void QWaylandSurface::destroySurface()
{
- Q_D(QWaylandSurface);
- if (d->extendedSurface()) {
- d->extendedSurface()->send_close();
- } else {
+ QWaylandSurfaceOp op(QWaylandSurfaceOp::Close);
+ if (!sendInterfaceOp(op))
destroySurfaceByForce();
- }
}
void QWaylandSurface::destroySurfaceByForce()
@@ -331,6 +357,12 @@ void QWaylandSurface::ref()
++d->refCount;
}
+void QWaylandSurface::setMapped(bool mapped)
+{
+ Q_D(QWaylandSurface);
+ d->setMapped(mapped);
+}
+
void QWaylandSurface::setBufferAttacher(QWaylandBufferAttacher *attacher)
{
Q_D(QWaylandSurface);
@@ -349,4 +381,18 @@ QList<QWaylandSurfaceView *> QWaylandSurface::views() const
return d->views;
}
+QList<QWaylandSurfaceInterface *> QWaylandSurface::interfaces() const
+{
+ Q_D(const QWaylandSurface);
+ return d->interfaces;
+}
+
+QWaylandSurface *QWaylandSurface::fromResource(::wl_resource *res)
+{
+ QtWayland::Surface *s = QtWayland::Surface::fromResource(res);
+ if (s)
+ return s->waylandSurface();
+ return Q_NULLPTR;
+}
+
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h
index 1e835180a..b2371d33d 100644
--- a/src/compositor/compositor_api/qwaylandsurface.h
+++ b/src/compositor/compositor_api/qwaylandsurface.h
@@ -49,6 +49,7 @@
#include <QtCore/QVariantMap>
struct wl_client;
+struct wl_resource;
QT_BEGIN_NAMESPACE
@@ -57,6 +58,8 @@ class QWaylandSurfacePrivate;
class QWaylandCompositor;
class QWaylandBufferRef;
class QWaylandSurfaceView;
+class QWaylandSurfaceInterface;
+class QWaylandSurfaceOp;
namespace QtWayland {
class Surface;
@@ -120,6 +123,8 @@ public:
QWaylandSurface *parentSurface() const;
QLinkedList<QWaylandSurface *> subSurfaces() const;
+ void addInterface(QWaylandSurfaceInterface *interface);
+ void removeInterface(QWaylandSurfaceInterface *interface);
Type type() const;
bool isYInverted() const;
@@ -136,6 +141,7 @@ public:
WindowFlags windowFlags() const;
WindowType windowType() const;
+ void setWindowType(WindowType type);
QWindow::Visibility visibility() const;
void setVisibility(QWindow::Visibility visibility);
@@ -166,11 +172,17 @@ public:
Q_INVOKABLE void ping();
void ref();
+ void setMapped(bool mapped);
void setBufferAttacher(QWaylandBufferAttacher *attacher);
QWaylandBufferAttacher *bufferAttacher() const;
QList<QWaylandSurfaceView *> views() const;
+ QList<QWaylandSurfaceInterface *> interfaces() const;
+
+ bool sendInterfaceOp(QWaylandSurfaceOp &op);
+
+ static QWaylandSurface *fromResource(::wl_resource *resource);
public slots:
void updateSelection();
diff --git a/src/compositor/compositor_api/qwaylandsurface_p.h b/src/compositor/compositor_api/qwaylandsurface_p.h
index e53b084c0..01d7ce545 100644
--- a/src/compositor/compositor_api/qwaylandsurface_p.h
+++ b/src/compositor/compositor_api/qwaylandsurface_p.h
@@ -52,6 +52,7 @@ QT_BEGIN_NAMESPACE
class QWaylandCompositor;
class QWaylandSurface;
class QWaylandSurfaceView;
+class QWaylandSurfaceInterface;
class Q_COMPOSITOR_EXPORT QWaylandSurfacePrivate : public QObjectPrivate, public QtWayland::Surface
{
@@ -60,7 +61,9 @@ public:
bool closing;
int refCount;
+ QWaylandSurface::WindowType windowType;
QList<QWaylandSurfaceView *> views;
+ QList<QWaylandSurfaceInterface *> interfaces;
friend class QWaylandSurface;
};
diff --git a/src/compositor/compositor_api/qwaylandsurfaceinterface.cpp b/src/compositor/compositor_api/qwaylandsurfaceinterface.cpp
new file mode 100644
index 000000000..96efc7d96
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandsurfaceinterface.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Compositor.
+**
+** $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 Digia Plc and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#include "qwaylandsurfaceinterface.h"
+#include "qwaylandsurface.h"
+
+class QWaylandSurfaceInterface::Private
+{
+public:
+ QWaylandSurface *surface;
+};
+
+QWaylandSurfaceInterface::QWaylandSurfaceInterface(QWaylandSurface *surface)
+ : d(new Private)
+{
+ d->surface = surface;
+ surface->addInterface(this);
+}
+
+QWaylandSurfaceInterface::~QWaylandSurfaceInterface()
+{
+ d->surface->removeInterface(this);
+}
+
+QWaylandSurface *QWaylandSurfaceInterface::surface() const
+{
+ return d->surface;
+}
+
+
+
+class QWaylandSurfaceOp::Private
+{
+public:
+ int type;
+};
+
+QWaylandSurfaceOp::QWaylandSurfaceOp(int t)
+ : d(new Private)
+{
+ d->type = t;
+}
+
+int QWaylandSurfaceOp::type() const
+{
+ return d->type;
+}
+
+
+
+QWaylandSurfaceSetVisibilityOp::QWaylandSurfaceSetVisibilityOp(QWindow::Visibility visibility)
+ : QWaylandSurfaceOp(Type::SetVisibility)
+ , m_visibility(visibility)
+{
+}
+
+QWindow::Visibility QWaylandSurfaceSetVisibilityOp::visibility() const
+{
+ return m_visibility;
+}
+
+QWaylandSurfaceResizeOp::QWaylandSurfaceResizeOp(const QSize &size)
+ : QWaylandSurfaceOp(Type::Resize)
+ , m_size(size)
+{
+}
+
+QSize QWaylandSurfaceResizeOp::size() const
+{
+ return m_size;
+}
+
+QWaylandSurfacePingOp::QWaylandSurfacePingOp(uint32_t serial)
+ : QWaylandSurfaceOp(Type::Ping)
+ , m_serial(serial)
+{
+}
+
+uint32_t QWaylandSurfacePingOp::serial() const
+{
+ return m_serial;
+}
diff --git a/src/compositor/compositor_api/qwaylandsurfaceinterface.h b/src/compositor/compositor_api/qwaylandsurfaceinterface.h
new file mode 100644
index 000000000..95ccc0e8c
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandsurfaceinterface.h
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Compositor.
+**
+** $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 Digia Plc and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDSURFACEINTERFACE_H
+#define QWAYLANDSURFACEINTERFACE_H
+
+#include <QWindow>
+
+#include <QtCompositor/qwaylandexport.h>
+#include <wayland-server.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandSurface;
+
+class Q_COMPOSITOR_EXPORT QWaylandSurfaceOp
+{
+public:
+ enum Type {
+ Close,
+ SetVisibility,
+ Resize,
+ Ping,
+ UserType = 1000
+ };
+
+ QWaylandSurfaceOp(int t);
+ int type() const;
+
+private:
+ class Private;
+ Private *const d;
+};
+
+class Q_COMPOSITOR_EXPORT QWaylandSurfaceSetVisibilityOp : public QWaylandSurfaceOp
+{
+public:
+ QWaylandSurfaceSetVisibilityOp(QWindow::Visibility visibility);
+ QWindow::Visibility visibility() const;
+
+private:
+ QWindow::Visibility m_visibility;
+};
+
+class Q_COMPOSITOR_EXPORT QWaylandSurfaceResizeOp : public QWaylandSurfaceOp
+{
+public:
+ QWaylandSurfaceResizeOp(const QSize &size);
+ QSize size() const;
+
+private:
+ QSize m_size;
+};
+
+class Q_COMPOSITOR_EXPORT QWaylandSurfacePingOp : public QWaylandSurfaceOp
+{
+public:
+ QWaylandSurfacePingOp(uint32_t serial);
+ uint32_t serial() const;
+
+private:
+ uint32_t m_serial;
+};
+
+class Q_COMPOSITOR_EXPORT QWaylandSurfaceInterface
+{
+public:
+ QWaylandSurfaceInterface(QWaylandSurface *surf);
+ virtual ~QWaylandSurfaceInterface();
+
+ QWaylandSurface *surface() const;
+
+protected:
+ virtual bool runOperation(QWaylandSurfaceOp *op) = 0;
+
+private:
+ class Private;
+ Private *const d;
+ friend class QWaylandSurface;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/compositor/wayland_wrapper/qwlextendedsurface.cpp b/src/compositor/wayland_wrapper/qwlextendedsurface.cpp
index abbaed5cd..47bbafbf1 100644
--- a/src/compositor/wayland_wrapper/qwlextendedsurface.cpp
+++ b/src/compositor/wayland_wrapper/qwlextendedsurface.cpp
@@ -61,7 +61,8 @@ void SurfaceExtensionGlobal::surface_extension_get_extended_surface(Resource *re
}
ExtendedSurface::ExtendedSurface(struct wl_client *client, uint32_t id, Surface *surface)
- : QtWaylandServer::qt_extended_surface(client,id)
+ : QWaylandSurfaceInterface(surface->waylandSurface())
+ , QtWaylandServer::qt_extended_surface(client,id)
, m_surface(surface)
, m_contentOrientation(Qt::PrimaryOrientation)
, m_windowFlags(0)
@@ -98,6 +99,21 @@ void ExtendedSurface::setVisibility(QWindow::Visibility visibility, bool updateC
send_onscreen_visibility(m_visibility);
}
+bool ExtendedSurface::runOperation(QWaylandSurfaceOp *op)
+{
+ switch (op->type()) {
+ case QWaylandSurfaceOp::Close:
+ send_close();
+ return true;
+ case QWaylandSurfaceOp::SetVisibility:
+ setVisibility(static_cast<QWaylandSurfaceSetVisibilityOp *>(op)->visibility());
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
void ExtendedSurface::extended_surface_update_generic_property(Resource *resource,
const QString &name,
struct wl_array *value)
diff --git a/src/compositor/wayland_wrapper/qwlextendedsurface_p.h b/src/compositor/wayland_wrapper/qwlextendedsurface_p.h
index 3b572108e..af1042687 100644
--- a/src/compositor/wayland_wrapper/qwlextendedsurface_p.h
+++ b/src/compositor/wayland_wrapper/qwlextendedsurface_p.h
@@ -46,6 +46,7 @@
#include <QtCompositor/private/qwayland-server-surface-extension.h>
#include <private/qwlsurface_p.h>
#include <QtCompositor/qwaylandsurface.h>
+#include <QtCompositor/qwaylandsurfaceinterface.h>
#include <QtCore/QVariant>
#include <QtCore/QLinkedList>
@@ -71,7 +72,7 @@ private:
};
-class ExtendedSurface : public QtWaylandServer::qt_extended_surface
+class ExtendedSurface : public QWaylandSurfaceInterface, public QtWaylandServer::qt_extended_surface
{
public:
ExtendedSurface(struct wl_client *client, uint32_t id, Surface *surface);
@@ -96,6 +97,9 @@ public:
QVariant windowProperty(const QString &propertyName) const;
void setWindowProperty(const QString &name, const QVariant &value, bool writeUpdateToClient = true);
+protected:
+ bool runOperation(QWaylandSurfaceOp *op) Q_DECL_OVERRIDE;
+
private:
Surface *m_surface;
diff --git a/src/compositor/wayland_wrapper/qwlshellsurface.cpp b/src/compositor/wayland_wrapper/qwlshellsurface.cpp
index 09439c130..ab7b24541 100644
--- a/src/compositor/wayland_wrapper/qwlshellsurface.cpp
+++ b/src/compositor/wayland_wrapper/qwlshellsurface.cpp
@@ -88,7 +88,7 @@ void Shell::shell_get_shell_surface(Resource *resource, uint32_t id, struct ::wl
ShellSurface::ShellSurface(Shell *shell, wl_client *client, uint32_t id, Surface *surface)
- : QWaylandShellSurface(surface->waylandSurface())
+ : QWaylandSurfaceInterface(surface->waylandSurface())
, wl_shell_surface(client, id)
, m_shell(shell)
, m_surface(surface)
@@ -99,7 +99,6 @@ ShellSurface::ShellSurface(Shell *shell, wl_client *client, uint32_t id, Surface
, m_transientParent(0)
, m_xOffset(0)
, m_yOffset(0)
- , m_windowType(QWaylandSurface::None)
, m_popupLocation()
, m_popupSerial()
{
@@ -164,11 +163,6 @@ void ShellSurface::setOffset(const QPointF &offset)
m_yOffset = offset.y();
}
-QWaylandSurface::WindowType ShellSurface::windowType() const
-{
- return m_windowType;
-}
-
void ShellSurface::mapPopup()
{
if (m_popupGrabber->grabSerial() == m_popupSerial) {
@@ -184,6 +178,21 @@ void ShellSurface::configure(bool hasBuffer)
m_surface->setMapped(hasBuffer);
}
+bool ShellSurface::runOperation(QWaylandSurfaceOp *op)
+{
+ switch (op->type()) {
+ case QWaylandSurfaceOp::Ping:
+ ping(static_cast<QWaylandSurfacePingOp *>(op)->serial());
+ return true;
+ case QWaylandSurfaceOp::Resize:
+ requestSize(static_cast<QWaylandSurfaceResizeOp *>(op)->size());
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
void ShellSurface::requestSize(const QSize &size)
{
send_configure(WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT, size.width(), size.height());
@@ -255,10 +264,7 @@ void ShellSurface::shell_surface_set_toplevel(Resource *resource)
m_xOffset = 0;
m_yOffset = 0;
- if (m_windowType != QWaylandSurface::Toplevel) {
- m_windowType = QWaylandSurface::Toplevel;
- emit m_surface->waylandSurface()->windowTypeChanged(m_windowType);
- }
+ surface()->setWindowType(QWaylandSurface::Toplevel);
if (m_surface->extendedSurface())
m_surface->extendedSurface()->setVisibility(QWindow::Windowed, false);
@@ -280,10 +286,7 @@ void ShellSurface::shell_surface_set_transient(Resource *resource,
if (flags & WL_SHELL_SURFACE_TRANSIENT_INACTIVE)
m_surface->setTransientInactive(true);
- if (m_windowType != QWaylandSurface::Transient) {
- m_windowType = QWaylandSurface::Transient;
- emit m_surface->waylandSurface()->windowTypeChanged(m_windowType);
- }
+ surface()->setWindowType(QWaylandSurface::Transient);
if (m_surface->extendedSurface())
m_surface->extendedSurface()->setVisibility(QWindow::AutomaticVisibility, false);
@@ -318,10 +321,7 @@ void ShellSurface::shell_surface_set_popup(Resource *resource, wl_resource *inpu
m_transientParent = Surface::fromResource(parent);
m_popupLocation = QPointF(x, y);
- if (m_windowType != QWaylandSurface::Popup) {
- m_windowType = QWaylandSurface::Popup;
- emit m_surface->waylandSurface()->windowTypeChanged(m_windowType);
- }
+ surface()->setWindowType(QWaylandSurface::Popup);
if (m_surface->extendedSurface())
m_surface->extendedSurface()->setVisibility(QWindow::AutomaticVisibility, false);
diff --git a/src/compositor/wayland_wrapper/qwlshellsurface_p.h b/src/compositor/wayland_wrapper/qwlshellsurface_p.h
index f3bb27924..b4ce1c975 100644
--- a/src/compositor/wayland_wrapper/qwlshellsurface_p.h
+++ b/src/compositor/wayland_wrapper/qwlshellsurface_p.h
@@ -44,7 +44,7 @@
#include <QtCompositor/qwaylandexport.h>
#include <QtCompositor/qwaylandsurface.h>
#include <QtCompositor/qwaylandglobalinterface.h>
-#include <QtCompositor/qwaylandshellsurface.h>
+#include <QtCompositor/qwaylandsurfaceinterface.h>
#include <wayland-server.h>
#include <QHash>
@@ -84,7 +84,7 @@ private:
QHash<InputDevice*, ShellSurfacePopupGrabber*> m_popupGrabber;
};
-class Q_COMPOSITOR_EXPORT ShellSurface : public QWaylandShellSurface, public QtWaylandServer::wl_shell_surface
+class Q_COMPOSITOR_EXPORT ShellSurface : public QObject, public QWaylandSurfaceInterface, public QtWaylandServer::wl_shell_surface
{
public:
ShellSurface(Shell *shell, struct wl_client *client, uint32_t id, Surface *surface);
@@ -97,13 +97,14 @@ public:
void setOffset(const QPointF &offset);
- QWaylandSurface::WindowType windowType() const Q_DECL_OVERRIDE;
-
void mapPopup();
void configure(bool hasBuffer);
- void requestSize(const QSize &size) Q_DECL_OVERRIDE;
- void ping(uint32_t serial) Q_DECL_OVERRIDE;
+ void requestSize(const QSize &size);
+ void ping(uint32_t serial);
+
+protected:
+ bool runOperation(QWaylandSurfaceOp *op) Q_DECL_OVERRIDE;
private:
Shell *m_shell;
@@ -120,8 +121,6 @@ private:
int32_t m_xOffset;
int32_t m_yOffset;
- QWaylandSurface::WindowType m_windowType;
-
QPointF m_popupLocation;
uint32_t m_popupSerial;
diff --git a/src/compositor/wayland_wrapper/qwlsurface.cpp b/src/compositor/wayland_wrapper/qwlsurface.cpp
index 82648d4ab..12a25b0df 100644
--- a/src/compositor/wayland_wrapper/qwlsurface.cpp
+++ b/src/compositor/wayland_wrapper/qwlsurface.cpp
@@ -48,7 +48,6 @@
#include "qwlsubsurface_p.h"
#include "qwlsurfacebuffer_p.h"
#include "qwaylandsurfaceview.h"
-#include "qwaylandshellsurface.h"
#include <QtCore/QDebug>
#include <QTouchEvent>
@@ -110,7 +109,6 @@ Surface::Surface(struct wl_client *client, uint32_t id, QWaylandCompositor *comp
, m_compositor(compositor->handle())
, m_waylandSurface(surface)
, m_buffer(0)
- , m_shellSurface(0)
, m_surfaceMapped(false)
, m_attacher(0)
, m_extendedSurface(0)
@@ -127,7 +125,6 @@ Surface::Surface(struct wl_client *client, uint32_t id, QWaylandCompositor *comp
Surface::~Surface()
{
delete m_subSurface;
- delete m_shellSurface;
m_bufferRef = QWaylandBufferRef();
@@ -248,16 +245,6 @@ SubSurface *Surface::subSurface() const
return m_subSurface;
}
-void Surface::setShellSurface(QWaylandShellSurface *shellSurface)
-{
- m_shellSurface = shellSurface;
-}
-
-QWaylandShellSurface *Surface::shellSurface() const
-{
- return m_shellSurface;
-}
-
void Surface::setInputPanelSurface(InputPanelSurface *inputPanelSurface)
{
m_inputPanelSurface = inputPanelSurface;
diff --git a/src/compositor/wayland_wrapper/qwlsurface_p.h b/src/compositor/wayland_wrapper/qwlsurface_p.h
index ced4844a4..016ed7553 100644
--- a/src/compositor/wayland_wrapper/qwlsurface_p.h
+++ b/src/compositor/wayland_wrapper/qwlsurface_p.h
@@ -62,7 +62,6 @@
QT_BEGIN_NAMESPACE
class QTouchEvent;
-class QWaylandShellSurface;
namespace QtWayland {
@@ -107,9 +106,6 @@ public:
void setSubSurface(SubSurface *subSurface);
SubSurface *subSurface() const;
- void setShellSurface(QWaylandShellSurface *shellSurface);
- QWaylandShellSurface *shellSurface() const;
-
void setInputPanelSurface(InputPanelSurface *inputPanelSurface);
InputPanelSurface *inputPanelSurface() const;
@@ -157,7 +153,6 @@ protected:
QRegion m_damage;
SurfaceBuffer *m_buffer;
- QWaylandShellSurface *m_shellSurface;
QWaylandBufferRef m_bufferRef;
bool m_surfaceMapped;
QWaylandBufferAttacher *m_attacher;