summaryrefslogtreecommitdiffstats
path: root/src/compositor/compositor_api
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@theqtcompany.com>2015-08-11 16:07:23 +0200
committerJørgen Lind <jorgen.lind@theqtcompany.com>2015-08-28 13:10:33 +0200
commite01b81339a37830c48f2cec0583e5d0aba592601 (patch)
treebd3085460c0139a10c5fd5d322b9059e6c97b5ee /src/compositor/compositor_api
parentbc331abe8e8ffaa3db12be7ae69e7b658dd700ac (diff)
Remove QtWayland::Surface
Its enough to have QWaylandSurface and QWaylandSurfacePrivate. Also don't pass QWaylandSurfacePrivate around, but pass QWaylandSurface and then use the QWaylandSurfacePrivate::get function. Change-Id: I915cc9d7b4497ad1c6f1f2dee61d9d0db069ba6b
Diffstat (limited to 'src/compositor/compositor_api')
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor.cpp10
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor.h1
-rw-r--r--src/compositor/compositor_api/qwaylanddrag.cpp1
-rw-r--r--src/compositor/compositor_api/qwaylandinput.cpp1
-rw-r--r--src/compositor/compositor_api/qwaylandinputpanel.cpp6
-rw-r--r--src/compositor/compositor_api/qwaylandquickcompositor.cpp1
-rw-r--r--src/compositor/compositor_api/qwaylandquicksurface.cpp8
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.cpp360
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.h30
-rw-r--r--src/compositor/compositor_api/qwaylandsurface_p.h128
10 files changed, 421 insertions, 125 deletions
diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp
index d358b1d86..d86b48d8a 100644
--- a/src/compositor/compositor_api/qwaylandcompositor.cpp
+++ b/src/compositor/compositor_api/qwaylandcompositor.cpp
@@ -46,9 +46,10 @@
#include "qwaylandpointer.h"
#include "qwaylandtouch.h"
+#include "qwaylandsurface_p.h"
+
#include "wayland_wrapper/qwlcompositor_p.h"
#include "wayland_wrapper/qwldatadevice_p.h"
-#include "wayland_wrapper/qwlsurface_p.h"
#include "wayland_wrapper/qwlinputdevice_p.h"
#include "extensions/qwlinputpanel_p.h"
@@ -123,6 +124,11 @@ uint32_t QWaylandCompositor::nextSerial()
return wl_display_next_serial(waylandDisplay());
}
+QList<QWaylandClient *>QWaylandCompositor::clients() const
+{
+ return m_compositor->clients();
+}
+
void QWaylandCompositor::destroyClientForSurface(QWaylandSurface *surface)
{
destroyClient(surface->client());
@@ -263,7 +269,7 @@ bool QWaylandCompositor::isDragging() const
void QWaylandCompositor::sendDragMoveEvent(const QPoint &global, const QPoint &local,
QWaylandSurface *surface)
{
- m_compositor->sendDragMoveEvent(global, local, surface ? surface->handle() : 0);
+ m_compositor->sendDragMoveEvent(global, local, surface);
}
void QWaylandCompositor::sendDragEndEvent()
diff --git a/src/compositor/compositor_api/qwaylandcompositor.h b/src/compositor/compositor_api/qwaylandcompositor.h
index 3eef0adfa..4e515420c 100644
--- a/src/compositor/compositor_api/qwaylandcompositor.h
+++ b/src/compositor/compositor_api/qwaylandcompositor.h
@@ -108,6 +108,7 @@ public:
::wl_display *waylandDisplay() const;
uint32_t nextSerial();
+ QList<QWaylandClient *>clients() const;
Q_INVOKABLE void destroyClientForSurface(QWaylandSurface *surface);
Q_INVOKABLE void destroyClient(QWaylandClient *client);
diff --git a/src/compositor/compositor_api/qwaylanddrag.cpp b/src/compositor/compositor_api/qwaylanddrag.cpp
index 0dd1c880d..01c6f38b4 100644
--- a/src/compositor/compositor_api/qwaylanddrag.cpp
+++ b/src/compositor/compositor_api/qwaylanddrag.cpp
@@ -41,7 +41,6 @@
#include "qwlcompositor_p.h"
#include "qwlinputdevice_p.h"
#include "qwldatadevice_p.h"
-#include "qwlsurface_p.h"
#include "qwaylandview.h"
QT_BEGIN_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandinput.cpp b/src/compositor/compositor_api/qwaylandinput.cpp
index 8064faf3f..69fe45e96 100644
--- a/src/compositor/compositor_api/qwaylandinput.cpp
+++ b/src/compositor/compositor_api/qwaylandinput.cpp
@@ -39,7 +39,6 @@
#include "qwlinputdevice_p.h"
#include "qwlkeyboard_p.h"
#include "qwaylandcompositor.h"
-#include "qwlsurface_p.h"
#include "qwlcompositor_p.h"
#include "qwaylandview.h"
diff --git a/src/compositor/compositor_api/qwaylandinputpanel.cpp b/src/compositor/compositor_api/qwaylandinputpanel.cpp
index c0317c93a..f4cd2476e 100644
--- a/src/compositor/compositor_api/qwaylandinputpanel.cpp
+++ b/src/compositor/compositor_api/qwaylandinputpanel.cpp
@@ -41,7 +41,6 @@
#include <private/qobject_p.h>
#include "qwlinputpanel_p.h"
-#include "qwlsurface_p.h"
QT_BEGIN_NAMESPACE
@@ -54,10 +53,7 @@ QWaylandSurface *QWaylandInputPanel::focus() const
{
Q_D(const QWaylandInputPanel);
- QtWayland::Surface *surface = d->focus();
- if (surface)
- return surface->waylandSurface();
- return 0;
+ return d->focus();
}
bool QWaylandInputPanel::visible() const
diff --git a/src/compositor/compositor_api/qwaylandquickcompositor.cpp b/src/compositor/compositor_api/qwaylandquickcompositor.cpp
index 14e80f0c3..6ff8374e3 100644
--- a/src/compositor/compositor_api/qwaylandquickcompositor.cpp
+++ b/src/compositor/compositor_api/qwaylandquickcompositor.cpp
@@ -36,7 +36,6 @@
****************************************************************************/
#include <QtCompositor/private/qwlcompositor_p.h>
-#include <QtCompositor/private/qwlsurface_p.h>
#include <QtQml/QQmlEngine>
diff --git a/src/compositor/compositor_api/qwaylandquicksurface.cpp b/src/compositor/compositor_api/qwaylandquicksurface.cpp
index 3e5f1c656..b91afe58f 100644
--- a/src/compositor/compositor_api/qwaylandquicksurface.cpp
+++ b/src/compositor/compositor_api/qwaylandquicksurface.cpp
@@ -54,8 +54,8 @@ QT_BEGIN_NAMESPACE
class QWaylandQuickSurfacePrivate : public QWaylandSurfacePrivate
{
public:
- QWaylandQuickSurfacePrivate(wl_client *client, quint32 id, int version, QWaylandQuickCompositor *c, QWaylandQuickSurface *surf)
- : QWaylandSurfacePrivate(client, id, version, c, surf)
+ QWaylandQuickSurfacePrivate(wl_client *client, quint32 id, int version, QWaylandQuickCompositor *c)
+ : QWaylandSurfacePrivate(client, id, version, c)
, compositor(c)
, useTextureAlpha(true)
, clientRenderingEnabled(true)
@@ -72,7 +72,7 @@ public:
};
QWaylandQuickSurface::QWaylandQuickSurface(wl_client *client, quint32 id, int version, QWaylandQuickCompositor *compositor)
- : QWaylandSurface(new QWaylandQuickSurfacePrivate(client, id, version, compositor, this))
+ : QWaylandSurface(new QWaylandQuickSurfacePrivate(client, id, version, compositor))
{
}
@@ -93,7 +93,7 @@ void QWaylandQuickSurface::setUseTextureAlpha(bool useTextureAlpha)
if (d->useTextureAlpha != useTextureAlpha) {
d->useTextureAlpha = useTextureAlpha;
emit useTextureAlphaChanged();
- emit configure(handle()->currentBufferRef().hasBuffer());
+ emit configure(d->currentBufferRef().hasBuffer());
}
}
diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp
index ca5e3cfb9..fdacee958 100644
--- a/src/compositor/compositor_api/qwaylandsurface.cpp
+++ b/src/compositor/compositor_api/qwaylandsurface.cpp
@@ -36,21 +36,21 @@
****************************************************************************/
#include "qwaylandsurface.h"
+#include "qwaylandsurface_p.h"
#include <private/qobject_p.h>
-#include "wayland_wrapper/qwlsurface_p.h"
#include "wayland_wrapper/qwlcompositor_p.h"
#include "wayland_wrapper/qwlinputdevice_p.h"
#include "wayland_wrapper/qwldatadevice_p.h"
#include "wayland_wrapper/qwldatadevicemanager_p.h"
+#include "wayland_wrapper/qwlregion_p.h"
#include "extensions/qwlextendedsurface_p.h"
#include "extensions/qwlsubsurface_p.h"
#include "qwaylandcompositor.h"
#include "qwaylandclient.h"
-#include "qwaylandsurface_p.h"
#include "qwaylandview_p.h"
#include "qwaylandbufferref.h"
@@ -61,12 +61,72 @@
QT_BEGIN_NAMESPACE
-QWaylandSurfacePrivate::QWaylandSurfacePrivate(wl_client *wlClient, quint32 id, int version, QWaylandCompositor *compositor, QWaylandSurface *surface)
- : QtWayland::Surface(wlClient, id, version, compositor, surface)
- , closing(false)
+namespace QtWayland {
+class FrameCallback {
+public:
+ FrameCallback(QWaylandSurface *surf, wl_resource *res)
+ : surface(surf)
+ , resource(res)
+ , canSend(false)
+ {
+#if WAYLAND_VERSION_MAJOR < 1 || (WAYLAND_VERSION_MAJOR == 1 && WAYLAND_VERSION_MINOR <= 2)
+ res->data = this;
+ res->destroy = destroyCallback;
+#else
+ wl_resource_set_implementation(res, 0, this, destroyCallback);
+#endif
+ }
+ ~FrameCallback()
+ {
+ }
+ void destroy()
+ {
+ if (resource)
+ wl_resource_destroy(resource);
+ else
+ delete this;
+ }
+ void send(uint time)
+ {
+ wl_callback_send_done(resource, time);
+ wl_resource_destroy(resource);
+ }
+ static void destroyCallback(wl_resource *res)
+ {
+#if WAYLAND_VERSION_MAJOR < 1 || (WAYLAND_VERSION_MAJOR == 1 && WAYLAND_VERSION_MINOR <= 2)
+ FrameCallback *_this = static_cast<FrameCallback *>(res->data);
+#else
+ FrameCallback *_this = static_cast<FrameCallback *>(wl_resource_get_user_data(res));
+#endif
+ QWaylandSurfacePrivate::get(_this->surface)->removeFrameCallback(_this);
+ delete _this;
+ }
+ QWaylandSurface *surface;
+ wl_resource *resource;
+ bool canSend;
+};
+}
+static QRegion infiniteRegion() {
+ return QRegion(QRect(QPoint(std::numeric_limits<int>::min(), std::numeric_limits<int>::min()),
+ QPoint(std::numeric_limits<int>::max(), std::numeric_limits<int>::max())));
+}
+
+QWaylandSurfacePrivate::QWaylandSurfacePrivate(wl_client *client, quint32 id, int version, QWaylandCompositor *compositor)
+ : QtWaylandServer::wl_surface(client, id, version)
+ , m_compositor(compositor)
, refCount(1)
- , client(QWaylandClient::fromWlClient(compositor, wlClient))
-{}
+ , client(QWaylandClient::fromWlClient(compositor, client))
+ , m_buffer(0)
+ , m_inputPanelSurface(0)
+ , m_inputRegion(infiniteRegion())
+ , m_isCursorSurface(false)
+ , m_destroyed(false)
+ , m_contentOrientation(Qt::PrimaryOrientation)
+{
+ m_pending.buffer = 0;
+ m_pending.newlyAttached = false;
+ m_pending.inputRegion = infiniteRegion();
+}
QWaylandSurfacePrivate::~QWaylandSurfacePrivate()
{
@@ -74,55 +134,233 @@ QWaylandSurfacePrivate::~QWaylandSurfacePrivate()
QWaylandViewPrivate::get(views.at(i))->markSurfaceAsDestroyed(q_func());
}
views.clear();
+
+ m_bufferRef = QWaylandBufferRef();
+
+ for (int i = 0; i < m_bufferPool.size(); i++)
+ m_bufferPool[i]->setDestroyIfUnused(true);
+
+ foreach (QtWayland::FrameCallback *c, m_pendingFrameCallbacks)
+ c->destroy();
+ foreach (QtWayland::FrameCallback *c, m_frameCallbacks)
+ c->destroy();
}
-QWaylandSurface::QWaylandSurface(wl_client *client, quint32 id, int version, QWaylandCompositor *compositor)
- : QObject(*new QWaylandSurfacePrivate(client, id, version, compositor, this))
+void QWaylandSurfacePrivate::setSize(const QSize &size)
{
+ Q_Q(QWaylandSurface);
+ if (size != m_size) {
+ m_opaqueRegion = QRegion();
+ m_size = size;
+ q->sizeChanged();
+ }
}
-QWaylandSurface::QWaylandSurface(QWaylandSurfacePrivate *dptr)
- : QObject(*dptr)
+void QWaylandSurfacePrivate::sendFrameCallback()
{
+ uint time = m_compositor->currentTimeMsecs();
+ foreach (QtWayland::FrameCallback *callback, m_frameCallbacks) {
+ if (callback->canSend) {
+ callback->send(time);
+ m_frameCallbacks.removeOne(callback);
+ }
+ }
}
-QWaylandSurface::~QWaylandSurface()
+void QWaylandSurfacePrivate::removeFrameCallback(QtWayland::FrameCallback *callback)
{
- Q_D(QWaylandSurface);
- d->m_compositor->unregisterSurface(this);
- d->notifyViewsAboutDestruction();
+ m_pendingFrameCallbacks.removeOne(callback);
+ m_frameCallbacks.removeOne(callback);
}
-QWaylandClient *QWaylandSurface::client() const
+void QWaylandSurfacePrivate::frameStarted()
{
- Q_D(const QWaylandSurface);
- if (d->isDestroyed() || !d->compositor()->clients().contains(d->client))
- return Q_NULLPTR;
+ foreach (QtWayland::FrameCallback *c, m_frameCallbacks)
+ c->canSend = true;
+}
- return d->client;
+void QWaylandSurfacePrivate::notifyViewsAboutDestruction()
+{
+ Q_Q(QWaylandSurface);
+ foreach (QWaylandView *view, views) {
+ QWaylandViewPrivate::get(view)->markSurfaceAsDestroyed(q);
+ }
}
-QWaylandSurface *QWaylandSurface::parentSurface() const
+void QWaylandSurfacePrivate::surface_destroy_resource(Resource *)
{
- Q_D(const QWaylandSurface);
- if (d->subSurface() && d->subSurface()->parent()) {
- return d->subSurface()->parent()->surface();
+ Q_Q(QWaylandSurface);
+ notifyViewsAboutDestruction();
+
+ m_destroyed = true;
+ q->destroy();
+ emit q->surfaceDestroyed();
+}
+
+void QWaylandSurfacePrivate::surface_destroy(Resource *resource)
+{
+ wl_resource_destroy(resource->handle);
+}
+
+void QWaylandSurfacePrivate::surface_attach(Resource *, struct wl_resource *buffer, int x, int y)
+{
+ if (m_pending.buffer)
+ m_pending.buffer->disown();
+ m_pending.buffer = createSurfaceBuffer(buffer);
+ m_pending.offset = QPoint(x, y);
+ m_pending.newlyAttached = true;
+}
+
+void QWaylandSurfacePrivate::surface_damage(Resource *, int32_t x, int32_t y, int32_t width, int32_t height)
+{
+ m_pending.damage = m_pending.damage.united(QRect(x, y, width, height));
+}
+
+void QWaylandSurfacePrivate::surface_frame(Resource *resource, uint32_t callback)
+{
+ Q_Q(QWaylandSurface);
+ struct wl_resource *frame_callback = wl_resource_create(resource->client(), &wl_callback_interface, wl_callback_interface.version, callback);
+ m_pendingFrameCallbacks << new QtWayland::FrameCallback(q, frame_callback);
+}
+
+void QWaylandSurfacePrivate::surface_set_opaque_region(Resource *, struct wl_resource *region)
+{
+ m_opaqueRegion = region ? QtWayland::Region::fromResource(region)->region() : QRegion();
+}
+
+void QWaylandSurfacePrivate::surface_set_input_region(Resource *, struct wl_resource *region)
+{
+ if (region) {
+ m_pending.inputRegion = QtWayland::Region::fromResource(region)->region();
+ } else {
+ m_pending.inputRegion = infiniteRegion();
}
- return 0;
}
-QLinkedList<QWaylandSurface *> QWaylandSurface::subSurfaces() const
+void QWaylandSurfacePrivate::surface_commit(Resource *)
{
- Q_D(const QWaylandSurface);
- if (d->subSurface()) {
- return d->subSurface()->subSurfaces();
+ Q_Q(QWaylandSurface);
+
+ if (m_pending.buffer || m_pending.newlyAttached) {
+ setBackBuffer(m_pending.buffer, m_pending.damage);
+ }
+
+ m_pending.buffer = 0;
+ m_pending.offset = QPoint();
+ m_pending.newlyAttached = false;
+ m_pending.damage = QRegion();
+
+ if (m_buffer)
+ m_buffer->setCommitted();
+
+ m_frameCallbacks << m_pendingFrameCallbacks;
+ m_pendingFrameCallbacks.clear();
+
+ m_inputRegion = m_pending.inputRegion.intersected(QRect(QPoint(), m_size));
+
+ emit q->redraw();
+}
+
+void QWaylandSurfacePrivate::surface_set_buffer_transform(Resource *resource, int32_t orientation)
+{
+ Q_UNUSED(resource);
+ Q_Q(QWaylandSurface);
+ QScreen *screen = QGuiApplication::primaryScreen();
+ bool isPortrait = screen->primaryOrientation() == Qt::PortraitOrientation;
+ Qt::ScreenOrientation oldOrientation = m_contentOrientation;
+ switch (orientation) {
+ case WL_OUTPUT_TRANSFORM_90:
+ m_contentOrientation = isPortrait ? Qt::InvertedLandscapeOrientation : Qt::PortraitOrientation;
+ break;
+ case WL_OUTPUT_TRANSFORM_180:
+ m_contentOrientation = isPortrait ? Qt::InvertedPortraitOrientation : Qt::InvertedLandscapeOrientation;
+ break;
+ case WL_OUTPUT_TRANSFORM_270:
+ m_contentOrientation = isPortrait ? Qt::LandscapeOrientation : Qt::InvertedPortraitOrientation;
+ break;
+ default:
+ m_contentOrientation = Qt::PrimaryOrientation;
+ }
+ if (m_contentOrientation != oldOrientation)
+ emit q->contentOrientationChanged();
+}
+
+void QWaylandSurfacePrivate::setBackBuffer(QtWayland::SurfaceBuffer *buffer, const QRegion &damage)
+{
+ Q_Q(QWaylandSurface);
+ QtWayland::SurfaceBuffer *oldBuffer = m_buffer;
+ m_buffer = buffer;
+ m_bufferRef = QWaylandBufferRef(m_buffer);
+
+ if (m_buffer) {
+ bool valid = m_buffer->waylandBufferHandle() != 0;
+ if (valid)
+ setSize(m_buffer->size());
+
+ m_damage = damage.intersected(QRect(QPoint(), m_size));
+ } else {
+ setSize(QSize());
+ m_damage = QRect();
+ }
+
+ for (int i = 0; i < views.size(); i++) {
+ views.at(i)->attach(m_bufferRef, m_damage);
+ }
+
+ emit q->damaged(m_damage);
+ if (QtWayland::SurfaceBuffer::hasContent(oldBuffer) != QtWayland::SurfaceBuffer::hasContent(m_buffer))
+ emit q->mappedChanged();
+ if (!m_pending.offset.isNull())
+ emit q->offsetForNextFrame(m_pending.offset);
+}
+
+QtWayland::SurfaceBuffer *QWaylandSurfacePrivate::createSurfaceBuffer(struct ::wl_resource *buffer)
+{
+ Q_Q(QWaylandSurface);
+ QtWayland::SurfaceBuffer *newBuffer = 0;
+ for (int i = 0; i < m_bufferPool.size(); i++) {
+ if (!m_bufferPool[i]->isRegisteredWithBuffer()) {
+ newBuffer = m_bufferPool[i];
+ newBuffer->initialize(buffer);
+ break;
+ }
+ }
+
+ if (!newBuffer) {
+ newBuffer = new QtWayland::SurfaceBuffer(q);
+ newBuffer->initialize(buffer);
+ m_bufferPool.append(newBuffer);
+ if (m_bufferPool.size() > 3)
+ qWarning() << "Increased buffer pool size to" << m_bufferPool.size() << "for surface" << q;
}
- return QLinkedList<QWaylandSurface *>();
+
+ return newBuffer;
}
-bool QWaylandSurface::visible() const
+QWaylandSurface::QWaylandSurface(wl_client *client, quint32 id, int version, QWaylandCompositor *compositor)
+ : QObject(*new QWaylandSurfacePrivate(client, id, version, compositor))
{
- return isMapped();
+}
+
+QWaylandSurface::QWaylandSurface(QWaylandSurfacePrivate *dptr)
+ : QObject(*dptr)
+{
+}
+
+QWaylandSurface::~QWaylandSurface()
+{
+ Q_D(QWaylandSurface);
+ d->m_compositor->handle()->unregisterSurface(this);
+ d->notifyViewsAboutDestruction();
+}
+
+QWaylandClient *QWaylandSurface::client() const
+{
+ Q_D(const QWaylandSurface);
+ if (isDestroyed() || !compositor()->clients().contains(d->client))
+ return Q_NULLPTR;
+
+ return d->client;
}
bool QWaylandSurface::isMapped() const
@@ -149,16 +387,10 @@ QWaylandSurface::Origin QWaylandSurface::origin() const
return d->origin();
}
-QtWayland::Surface * QWaylandSurface::handle()
-{
- Q_D(QWaylandSurface);
- return d;
-}
-
QWaylandCompositor *QWaylandSurface::compositor() const
{
Q_D(const QWaylandSurface);
- return d->compositor()->waylandCompositor();
+ return d->compositor();
}
void QWaylandSurface::sendFrameCallbacks()
@@ -167,18 +399,6 @@ void QWaylandSurface::sendFrameCallbacks()
d->sendFrameCallback();
}
-QString QWaylandSurface::className() const
-{
- Q_D(const QWaylandSurface);
- return d->className();
-}
-
-QString QWaylandSurface::title() const
-{
- Q_D(const QWaylandSurface);
- return d->title();
-}
-
bool QWaylandSurface::hasInputPanelSurface() const
{
Q_D(const QWaylandSurface);
@@ -197,6 +417,12 @@ void QWaylandSurface::destroy()
deref();
}
+bool QWaylandSurface::isDestroyed() const
+{
+ Q_D(const QWaylandSurface);
+ return d->isDestroyed();
+}
+
void QWaylandSurface::markAsCursorSurface(bool cursorSurface)
{
Q_D(QWaylandSurface);
@@ -221,7 +447,7 @@ void QWaylandSurface::updateSelection()
if (inputDevice) {
const QtWayland::DataDevice *dataDevice = QWaylandInputDevicePrivate::get(inputDevice)->dataDevice();
if (dataDevice) {
- d->compositor()->dataDeviceManager()->offerRetainedSelection(
+ d->compositor()->handle()->dataDeviceManager()->offerRetainedSelection(
dataDevice->resourceMap().value(d->resource()->client())->handle);
}
}
@@ -237,7 +463,7 @@ void QWaylandSurface::deref()
{
Q_D(QWaylandSurface);
if (--d->refCount == 0)
- compositor()->handle()->destroySurface(d);
+ compositor()->handle()->destroySurface(this);
}
QWaylandView *QWaylandSurface::throttlingView() const
@@ -273,9 +499,9 @@ QList<QWaylandView *> QWaylandSurface::views() const
QWaylandSurface *QWaylandSurface::fromResource(::wl_resource *res)
{
- QtWayland::Surface *s = QtWayland::Surface::fromResource(res);
+ QWaylandSurfacePrivate *s = QWaylandSurfacePrivate::fromResource(res);
if (s)
- return s->waylandSurface();
+ return s->q_func();
return Q_NULLPTR;
}
@@ -290,39 +516,23 @@ QWaylandSurfacePrivate *QWaylandSurfacePrivate::get(QWaylandSurface *surface)
return surface ? surface->d_func() : Q_NULLPTR;
}
-void QWaylandSurfacePrivate::setTitle(const QString &title)
-{
- Q_Q(QWaylandSurface);
- if (m_title != title) {
- m_title = title;
- emit q->titleChanged();
- }
-}
-
-void QWaylandSurfacePrivate::setClassName(const QString &className)
-{
- Q_Q(QWaylandSurface);
- if (m_className != className) {
- m_className = className;
- emit q->classNameChanged();
- }
-}
-
void QWaylandSurfacePrivate::refView(QWaylandView *view)
{
+ Q_Q(QWaylandSurface);
if (views.contains(view))
return;
views.append(view);
- waylandSurface()->ref();
+ q->ref();
}
void QWaylandSurfacePrivate::derefView(QWaylandView *view)
{
+ Q_Q(QWaylandSurface);
int nViews = views.removeAll(view);
for (int i = 0; i < nViews && refCount > 0; i++) {
- waylandSurface()->deref();
+ q->deref();
}
}
diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h
index 17f585e73..45e4be94f 100644
--- a/src/compositor/compositor_api/qwaylandsurface.h
+++ b/src/compositor/compositor_api/qwaylandsurface.h
@@ -40,6 +40,7 @@
#include <QtCompositor/qwaylandexport.h>
#include <QtCompositor/qwaylandextension.h>
+#include <QtCompositor/qwaylandclient.h>
#include <QtCore/QScopedPointer>
#include <QtGui/QImage>
@@ -59,12 +60,6 @@ class QWaylandBufferRef;
class QWaylandView;
class QWaylandSurfaceOp;
-namespace QtWayland {
-class Surface;
-class SurfacePrivate;
-class ExtendedSurface;
-}
-
class Q_COMPOSITOR_EXPORT QWaylandSurface : public QObject, public QWaylandExtensionContainer
{
Q_OBJECT
@@ -72,8 +67,6 @@ class Q_COMPOSITOR_EXPORT QWaylandSurface : public QObject, public QWaylandExten
Q_PROPERTY(QWaylandClient *client READ client CONSTANT)
Q_PROPERTY(QSize size READ size NOTIFY sizeChanged)
Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation NOTIFY contentOrientationChanged)
- Q_PROPERTY(QString className READ className NOTIFY classNameChanged)
- Q_PROPERTY(QString title READ title NOTIFY titleChanged)
Q_PROPERTY(QWaylandSurface::Origin origin READ origin NOTIFY originChanged)
Q_PROPERTY(bool isMapped READ isMapped NOTIFY mappedChanged)
@@ -87,11 +80,8 @@ public:
virtual ~QWaylandSurface();
QWaylandClient *client() const;
+ struct wl_client *waylandClient() const { return client()->client(); }
- QWaylandSurface *parentSurface() const;
- QLinkedList<QWaylandSurface *> subSurfaces() const;
-
- bool visible() const;
bool isMapped() const;
QSize size() const;
@@ -100,21 +90,14 @@ public:
Origin origin() const;
- QtWayland::Surface *handle();
-
- QByteArray authenticationToken() const;
-
QWaylandCompositor *compositor() const;
- QString className() const;
-
- QString title() const;
-
bool hasInputPanelSurface() const;
bool inputRegionContains(const QPoint &p) const;
Q_INVOKABLE void destroy();
+ bool isDestroyed() const;
Q_INVOKABLE void sendFrameCallbacks();
@@ -145,19 +128,12 @@ Q_SIGNALS:
void sizeChanged();
void offsetForNextFrame(const QPoint &offset);
void contentOrientationChanged();
- void extendedSurfaceReady();
- void classNameChanged();
- void titleChanged();
- void raiseRequested();
- void lowerRequested();
void pong();
void surfaceDestroyed();
void originChanged();
void configure(bool hasBuffer);
void redraw();
-
- friend class QtWayland::Surface;
};
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandsurface_p.h b/src/compositor/compositor_api/qwaylandsurface_p.h
index 69e2fb6b9..91e5598f6 100644
--- a/src/compositor/compositor_api/qwaylandsurface_p.h
+++ b/src/compositor/compositor_api/qwaylandsurface_p.h
@@ -41,7 +41,25 @@
#include <QtCompositor/qwaylandexport.h>
#include <private/qobject_p.h>
-#include <QtCompositor/private/qwlsurface_p.h>
+#include <private/qwlsurfacebuffer_p.h>
+#include <QtCompositor/qwaylandsurface.h>
+#include <QtCompositor/qwaylandbufferref.h>
+
+#include <QtCompositor/private/qwlinputpanelsurface_p.h>
+#include <QtCompositor/private/qwlregion_p.h>
+
+#include <QtCore/QVector>
+#include <QtCore/QRect>
+#include <QtGui/QRegion>
+#include <QtGui/QImage>
+#include <QtGui/QWindow>
+
+#include <QtCore/QTextStream>
+#include <QtCore/QMetaType>
+
+#include <wayland-util.h>
+
+#include <QtCompositor/private/qwayland-server-wayland.h>
QT_BEGIN_NAMESPACE
@@ -50,24 +68,116 @@ class QWaylandSurface;
class QWaylandView;
class QWaylandSurfaceInterface;
-class Q_COMPOSITOR_EXPORT QWaylandSurfacePrivate : public QObjectPrivate, public QtWayland::Surface
+namespace QtWayland {
+class FrameCallback;
+}
+
+class Q_COMPOSITOR_EXPORT QWaylandSurfacePrivate : public QObjectPrivate, public QtWaylandServer::wl_surface
{
- Q_DECLARE_PUBLIC(QWaylandSurface)
public:
static QWaylandSurfacePrivate *get(QWaylandSurface *surface);
- QWaylandSurfacePrivate(wl_client *wlClient, quint32 id, int version, QWaylandCompositor *compositor, QWaylandSurface *surface);
+
+ QWaylandSurfacePrivate(wl_client *wlClient, quint32 id, int version, QWaylandCompositor *compositor);
~QWaylandSurfacePrivate();
- void setTitle(const QString &title);
- void setClassName(const QString &className);
+
void refView(QWaylandView *view);
void derefView(QWaylandView *view);
- bool closing;
- int refCount;
+ static QWaylandSurfacePrivate *fromResource(struct ::wl_resource *resource)
+ { return static_cast<QWaylandSurfacePrivate *>(Resource::fromResource(resource)->surface_object); }
- QWaylandClient *client;
+ bool mapped() const { return QtWayland::SurfaceBuffer::hasContent(m_buffer); }
+
+ using QtWaylandServer::wl_surface::resource;
+
+ QSize size() const { return m_size; }
+ void setSize(const QSize &size);
+
+ QRegion inputRegion() const { return m_inputRegion; }
+ QRegion opaqueRegion() const { return m_opaqueRegion; }
+
+ void sendFrameCallback();
+ void removeFrameCallback(QtWayland::FrameCallback *callback);
+
+ QPoint lastMousePos() const { return m_lastLocalMousePos; }
+
+ void setInputPanelSurface(QtWayland::InputPanelSurface *inputPanelSurface) { m_inputPanelSurface = inputPanelSurface; }
+ QtWayland::InputPanelSurface *inputPanelSurface() const { return m_inputPanelSurface; }
+
+ QWaylandCompositor *compositor() const { return m_compositor; }
+
+ bool isCursorSurface() const { return m_isCursorSurface; }
+ void setCursorSurface(bool isCursor) { m_isCursorSurface = isCursor; }
+ void frameStarted();
+
+ inline bool isDestroyed() const { return m_destroyed; }
+
+ Qt::ScreenOrientation contentOrientation() const { return m_contentOrientation; }
+
+ QWaylandSurface::Origin origin() const { return m_buffer ? m_buffer->origin() : QWaylandSurface::OriginTopLeft; }
+
+ QWaylandBufferRef currentBufferRef() const { return m_bufferRef; }
+
+ void notifyViewsAboutDestruction();
+protected:
+ void surface_destroy_resource(Resource *resource) Q_DECL_OVERRIDE;
+
+ void surface_destroy(Resource *resource) Q_DECL_OVERRIDE;
+ void surface_attach(Resource *resource,
+ struct wl_resource *buffer, int x, int y) Q_DECL_OVERRIDE;
+ void surface_damage(Resource *resource,
+ int32_t x, int32_t y, int32_t width, int32_t height) Q_DECL_OVERRIDE;
+ void surface_frame(Resource *resource,
+ uint32_t callback) Q_DECL_OVERRIDE;
+ void surface_set_opaque_region(Resource *resource,
+ struct wl_resource *region) Q_DECL_OVERRIDE;
+ void surface_set_input_region(Resource *resource,
+ struct wl_resource *region) Q_DECL_OVERRIDE;
+ void surface_commit(Resource *resource) Q_DECL_OVERRIDE;
+ void surface_set_buffer_transform(Resource *resource, int32_t transform) Q_DECL_OVERRIDE;
+
+ void setBackBuffer(QtWayland::SurfaceBuffer *buffer, const QRegion &damage);
+ QtWayland::SurfaceBuffer *createSurfaceBuffer(struct ::wl_resource *buffer);
+
+protected: //member variables
+ QWaylandCompositor *m_compositor;
+ int refCount;
+ QWaylandClient *client;
QList<QWaylandView *> views;
+ QRegion m_damage;
+ QtWayland::SurfaceBuffer *m_buffer;
+ QWaylandBufferRef m_bufferRef;
+
+ struct {
+ QtWayland::SurfaceBuffer *buffer;
+ QRegion damage;
+ QPoint offset;
+ bool newlyAttached;
+ QRegion inputRegion;
+ } m_pending;
+
+ QPoint m_lastLocalMousePos;
+ QPoint m_lastGlobalMousePos;
+
+ QList<QtWayland::FrameCallback *> m_pendingFrameCallbacks;
+ QList<QtWayland::FrameCallback *> m_frameCallbacks;
+
+ QtWayland::InputPanelSurface *m_inputPanelSurface;
+
+ QRegion m_inputRegion;
+ QRegion m_opaqueRegion;
+
+ QVector<QtWayland::SurfaceBuffer *> m_bufferPool;
+
+ QSize m_size;
+ bool m_isCursorSurface;
+ bool m_destroyed;
+ Qt::ScreenOrientation m_contentOrientation;
+ QWindow::Visibility m_visibility;
+
+ Q_DECLARE_PUBLIC(QWaylandSurface)
+ Q_DISABLE_COPY(QWaylandSurfacePrivate)
};
QT_END_NAMESPACE