summaryrefslogtreecommitdiffstats
path: root/src/compositor/wayland_wrapper
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/wayland_wrapper
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/wayland_wrapper')
-rw-r--r--src/compositor/wayland_wrapper/qwlcompositor.cpp10
-rw-r--r--src/compositor/wayland_wrapper/qwlcompositor_p.h4
-rw-r--r--src/compositor/wayland_wrapper/qwldatadevice.cpp8
-rw-r--r--src/compositor/wayland_wrapper/qwldatadevicemanager.cpp3
-rw-r--r--src/compositor/wayland_wrapper/qwlinputdevice.cpp11
-rw-r--r--src/compositor/wayland_wrapper/qwlinputmethod.cpp4
-rw-r--r--src/compositor/wayland_wrapper/qwlinputmethod_p.h5
-rw-r--r--src/compositor/wayland_wrapper/qwlkeyboard.cpp5
-rw-r--r--src/compositor/wayland_wrapper/qwloutput.cpp11
-rw-r--r--src/compositor/wayland_wrapper/qwlpointer.cpp7
-rw-r--r--src/compositor/wayland_wrapper/qwlsurface.cpp427
-rw-r--r--src/compositor/wayland_wrapper/qwlsurface_p.h196
-rw-r--r--src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp9
-rw-r--r--src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h11
-rw-r--r--src/compositor/wayland_wrapper/qwltouch.cpp1
-rw-r--r--src/compositor/wayland_wrapper/qwltouch_p.h2
-rw-r--r--src/compositor/wayland_wrapper/wayland_wrapper.pri2
17 files changed, 43 insertions, 673 deletions
diff --git a/src/compositor/wayland_wrapper/qwlcompositor.cpp b/src/compositor/wayland_wrapper/qwlcompositor.cpp
index fee40c7ef..65b669a02 100644
--- a/src/compositor/wayland_wrapper/qwlcompositor.cpp
+++ b/src/compositor/wayland_wrapper/qwlcompositor.cpp
@@ -40,7 +40,7 @@
#include "qwaylandinput.h"
#include "qwldisplay_p.h"
#include "qwloutput_p.h"
-#include "qwlsurface_p.h"
+#include "qwaylandsurface_p.h"
#include "qwaylandclient.h"
#include "qwaylandcompositor.h"
#include "qwldatadevicemanager_p.h"
@@ -290,11 +290,11 @@ void Compositor::processWaylandEvents()
wl_display_flush_clients(m_display->handle());
}
-void Compositor::destroySurface(Surface *surface)
+void Compositor::destroySurface(QWaylandSurface *surface)
{
- waylandCompositor()->surfaceAboutToBeDestroyed(surface->waylandSurface());
+ waylandCompositor()->surfaceAboutToBeDestroyed(surface);
- m_destroyed_surfaces << surface->waylandSurface();
+ m_destroyed_surfaces << surface;
}
void Compositor::unregisterSurface(QWaylandSurface *surface)
@@ -440,7 +440,7 @@ bool Compositor::isDragging() const
}
void Compositor::sendDragMoveEvent(const QPoint &global, const QPoint &local,
- Surface *surface)
+ QWaylandSurface *surface)
{
Q_UNUSED(global);
Q_UNUSED(local);
diff --git a/src/compositor/wayland_wrapper/qwlcompositor_p.h b/src/compositor/wayland_wrapper/qwlcompositor_p.h
index ce9d95460..fb71ea57c 100644
--- a/src/compositor/wayland_wrapper/qwlcompositor_p.h
+++ b/src/compositor/wayland_wrapper/qwlcompositor_p.h
@@ -96,7 +96,7 @@ public:
QWaylandInputDevice *inputDeviceFor(QInputEvent *inputEvent);
void removeInputDevice(QWaylandInputDevice *device);
- void destroySurface(Surface *surface);
+ void destroySurface(QWaylandSurface *surface);
void destroyClient(QWaylandClient *client);
@@ -131,7 +131,7 @@ public:
DataDeviceManager *dataDeviceManager() const;
bool isDragging() const;
- void sendDragMoveEvent(const QPoint &global, const QPoint &local, Surface *surface);
+ void sendDragMoveEvent(const QPoint &global, const QPoint &local, QWaylandSurface *surface);
void sendDragEndEvent();
void setRetainedSelectionEnabled(bool enabled);
diff --git a/src/compositor/wayland_wrapper/qwldatadevice.cpp b/src/compositor/wayland_wrapper/qwldatadevice.cpp
index bd370a063..8dd33d3b0 100644
--- a/src/compositor/wayland_wrapper/qwldatadevice.cpp
+++ b/src/compositor/wayland_wrapper/qwldatadevice.cpp
@@ -42,7 +42,7 @@
#include "qwlinputdevice_p.h"
#include "qwlkeyboard_p.h"
#include "qwlpointer_p.h"
-#include "qwlsurface_p.h"
+#include "qwaylandsurface_p.h"
#include "qwltouch_p.h"
#include "qwldatadevicemanager_p.h"
@@ -97,10 +97,10 @@ void DataDevice::setDragFocus(QWaylandView *focus, const QPointF &localPosition)
if (!focus)
return;
- if (!m_dragDataSource && m_dragClient != focus->surface()->handle()->resource()->client())
+ if (!m_dragDataSource && m_dragClient != focus->surface()->waylandClient())
return;
- Resource *resource = resourceMap().value(focus->surface()->handle()->resource()->client());
+ Resource *resource = resourceMap().value(focus->surface()->waylandClient());
if (!resource)
return;
@@ -112,7 +112,7 @@ void DataDevice::setDragFocus(QWaylandView *focus, const QPointF &localPosition)
if (m_dragDataSource && !offer)
return;
- send_enter(resource->handle, serial, focus->surface()->handle()->resource()->handle,
+ send_enter(resource->handle, serial, focus->surface()->resource(),
wl_fixed_from_double(localPosition.x()), wl_fixed_from_double(localPosition.y()),
offer->resource()->handle);
diff --git a/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp b/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp
index 35bbf59f4..affc17d72 100644
--- a/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp
+++ b/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp
@@ -41,7 +41,6 @@
#include "qwlinputdevice_p.h"
#include "qwlcompositor_p.h"
#include "qwldataoffer_p.h"
-#include "qwlsurface_p.h"
#include "qwaylandmimehelper.h"
#include <QtCompositor/private/qwaylandsurface_p.h>
@@ -204,7 +203,7 @@ void DataDeviceManager::overrideSelection(const QMimeData &mimeData)
QWaylandSurface *focusSurface = QWaylandInputDevicePrivate::get(dev)->keyboardFocus();
if (focusSurface)
offerFromCompositorToClient(
- QWaylandInputDevicePrivate::get(dev)->dataDevice()->resourceMap().value(QWaylandSurfacePrivate::get(focusSurface)->resource()->client())->handle);
+ QWaylandInputDevicePrivate::get(dev)->dataDevice()->resourceMap().value(focusSurface->waylandClient())->handle);
}
bool DataDeviceManager::offerFromCompositorToClient(wl_resource *clientDataDeviceResource)
diff --git a/src/compositor/wayland_wrapper/qwlinputdevice.cpp b/src/compositor/wayland_wrapper/qwlinputdevice.cpp
index 80d91e684..858495ac1 100644
--- a/src/compositor/wayland_wrapper/qwlinputdevice.cpp
+++ b/src/compositor/wayland_wrapper/qwlinputdevice.cpp
@@ -39,7 +39,6 @@
#include "qwlcompositor_p.h"
#include "qwldatadevice_p.h"
#include "qwlinputmethod_p.h"
-#include "qwlsurface_p.h"
#include "qwlqttouch_p.h"
#include "qwlqtkey_p.h"
#include "qwaylandcompositor.h"
@@ -160,9 +159,9 @@ void QWaylandInputDevicePrivate::sendMouseReleaseEvent(Qt::MouseButton button)
pointerDevice()->sendMouseReleaseEvent(button);
}
-void QWaylandInputDevicePrivate::sendMouseMoveEvent(QWaylandView *surface, const QPointF &localPos, const QPointF &globalPos)
+void QWaylandInputDevicePrivate::sendMouseMoveEvent(QWaylandView *view, const QPointF &localPos, const QPointF &globalPos)
{
- pointerDevice()->sendMouseMoveEvent(surface, localPos,globalPos);
+ pointerDevice()->sendMouseMoveEvent(view, localPos,globalPos);
}
void QWaylandInputDevicePrivate::sendMouseWheelEvent(Qt::Orientation orientation, int delta)
@@ -200,7 +199,7 @@ void QWaylandInputDevicePrivate::sendFullKeyEvent(QKeyEvent *event)
}
QtWayland::QtKeyExtensionGlobal *ext = QtWayland::QtKeyExtensionGlobal::findIn(m_compositor);
- if (ext && ext->postQtKeyEvent(event, keyboardFocus()->handle()))
+ if (ext && ext->postQtKeyEvent(event, keyboardFocus()))
return;
if (!m_keyboard.isNull() && !event->isAutoRepeat()) {
@@ -215,7 +214,7 @@ void QWaylandInputDevicePrivate::sendFullKeyEvent(QWaylandSurface *surface, QKey
{
QtWayland::QtKeyExtensionGlobal *ext = QtWayland::QtKeyExtensionGlobal::findIn(m_compositor);
if (ext)
- ext->postQtKeyEvent(event, surface->handle());
+ ext->postQtKeyEvent(event, surface);
}
void QWaylandInputDevicePrivate::sendFullTouchEvent(QTouchEvent *event)
@@ -244,7 +243,7 @@ QWaylandSurface *QWaylandInputDevicePrivate::keyboardFocus() const
*/
bool QWaylandInputDevicePrivate::setKeyboardFocus(QWaylandSurface *surface)
{
- if (surface && surface->handle()->isDestroyed())
+ if (surface && surface->isDestroyed())
return false;
if (!m_keyboard.isNull() && m_keyboard->setFocus(surface)) {
diff --git a/src/compositor/wayland_wrapper/qwlinputmethod.cpp b/src/compositor/wayland_wrapper/qwlinputmethod.cpp
index ca7ce53fd..59f01c666 100644
--- a/src/compositor/wayland_wrapper/qwlinputmethod.cpp
+++ b/src/compositor/wayland_wrapper/qwlinputmethod.cpp
@@ -55,7 +55,7 @@ InputMethod::InputMethod(QWaylandCompositor *compositor, QWaylandInputDevice *se
, m_textInput()
, m_context()
{
- connect(seat->keyboard(), SIGNAL(focusChanged(Surface*)), this, SLOT(focusChanged(Surface*)));
+ connect(seat->keyboard(), &QWaylandKeyboard::focusChanged, this, &InputMethod::focusChanged);
}
InputMethod::~InputMethod()
@@ -105,7 +105,7 @@ void InputMethod::deactivate()
}
}
-void InputMethod::focusChanged(Surface *surface)
+void InputMethod::focusChanged(QWaylandSurface *surface)
{
if (!m_textInput)
return;
diff --git a/src/compositor/wayland_wrapper/qwlinputmethod_p.h b/src/compositor/wayland_wrapper/qwlinputmethod_p.h
index ee43b7ebc..b49a6668a 100644
--- a/src/compositor/wayland_wrapper/qwlinputmethod_p.h
+++ b/src/compositor/wayland_wrapper/qwlinputmethod_p.h
@@ -42,6 +42,8 @@
#include <QObject>
#include <QScopedPointer>
+#include <QtCompositor/QWaylandSurface>
+
QT_BEGIN_NAMESPACE
class QWaylandInputDevice;
@@ -51,7 +53,6 @@ namespace QtWayland {
class InputMethodContext;
class TextInput;
-class Surface;
class InputMethod : public QObject, public QtWaylandServer::wl_input_method
{
@@ -74,7 +75,7 @@ protected:
void input_method_destroy_resource(Resource *resource);
private Q_SLOTS:
- void focusChanged(Surface *surface);
+ void focusChanged(QWaylandSurface *surface);
private:
QWaylandCompositor *m_compositor;
diff --git a/src/compositor/wayland_wrapper/qwlkeyboard.cpp b/src/compositor/wayland_wrapper/qwlkeyboard.cpp
index d40422c31..c22b0cb26 100644
--- a/src/compositor/wayland_wrapper/qwlkeyboard.cpp
+++ b/src/compositor/wayland_wrapper/qwlkeyboard.cpp
@@ -43,7 +43,6 @@
#include <QtCompositor/QWaylandClient>
#include "qwlcompositor_p.h"
-#include "qwlsurface_p.h"
#include <fcntl.h>
#include <unistd.h>
@@ -117,11 +116,11 @@ void QWaylandKeyboardPrivate::focused(QWaylandSurface *surface)
surface = Q_NULLPTR;
if (m_focusResource && m_focus != surface) {
uint32_t serial = wl_display_next_serial(compositor()->waylandDisplay());
- send_leave(m_focusResource->handle, serial, m_focus->handle()->resource()->handle);
+ send_leave(m_focusResource->handle, serial, m_focus->resource());
m_focusDestroyListener.reset();
}
- Resource *resource = surface ? resourceMap().value(surface->client()->client()) : 0;
+ Resource *resource = surface ? resourceMap().value(surface->waylandClient()) : 0;
if (resource && (m_focus != surface || m_focusResource != resource)) {
uint32_t serial = wl_display_next_serial(compositor()->waylandDisplay());
diff --git a/src/compositor/wayland_wrapper/qwloutput.cpp b/src/compositor/wayland_wrapper/qwloutput.cpp
index caffb9028..82278f301 100644
--- a/src/compositor/wayland_wrapper/qwloutput.cpp
+++ b/src/compositor/wayland_wrapper/qwloutput.cpp
@@ -37,7 +37,6 @@
#include "qwloutput_p.h"
#include "qwlcompositor_p.h"
-#include "qwlsurface_p.h"
#include <QtGui/QWindow>
#include <QRect>
@@ -49,6 +48,8 @@
#include <QtCompositor/QWaylandView>
#include <QtCompositor/QWaylandOutput>
+#include <QtCompositor/private/qwaylandsurface_p.h>
+
QT_BEGIN_NAMESPACE
namespace QtWayland {
@@ -332,7 +333,7 @@ void Output::frameStarted()
for (int i = 0; i < m_surfaceViews.size(); i++) {
SurfaceViewMapper &surfacemapper = m_surfaceViews[i];
if (surfacemapper.maybeThrottelingView())
- surfacemapper.surface->handle()->frameStarted();
+ QWaylandSurfacePrivate::get(surfacemapper.surface)->frameStarted();
}
}
@@ -345,7 +346,7 @@ void Output::sendFrameCallbacks()
surfaceEnter(surfacemapper.surface);
}
if (surfacemapper.maybeThrottelingView())
- surfacemapper.surface->handle()->sendFrameCallback();
+ QWaylandSurfacePrivate::get(surfacemapper.surface)->sendFrameCallback();
}
}
wl_display_flush_clients(compositor()->waylandDisplay());
@@ -355,14 +356,14 @@ void Output::surfaceEnter(QWaylandSurface *surface)
{
if (!surface)
return;
- surface->handle()->send_enter(outputForClient(surface->client())->handle);
+ QWaylandSurfacePrivate::get(surface)->send_enter(outputForClient(surface->client())->handle);
}
void Output::surfaceLeave(QWaylandSurface *surface)
{
if (!surface)
return;
- surface->handle()->send_leave(outputForClient(surface->client())->handle);
+ QWaylandSurfacePrivate::get(surface)->send_leave(outputForClient(surface->client())->handle);
}
void Output::addView(QWaylandView *view)
diff --git a/src/compositor/wayland_wrapper/qwlpointer.cpp b/src/compositor/wayland_wrapper/qwlpointer.cpp
index 13963d269..9e66f4636 100644
--- a/src/compositor/wayland_wrapper/qwlpointer.cpp
+++ b/src/compositor/wayland_wrapper/qwlpointer.cpp
@@ -40,7 +40,6 @@
#include "qwlcompositor_p.h"
#include "qwlinputdevice_p.h"
#include "qwlkeyboard_p.h"
-#include "qwlsurface_p.h"
#include "qwaylandcompositor.h"
#include "qwaylandview.h"
@@ -164,17 +163,17 @@ void QWaylandPointerPrivate::sendMouseMoveEvent(QWaylandView *view, const QPoint
m_localPosition.ry() -= 0.01;
}
- Resource *resource = view ? resourceMap().value(view->surface()->handle()->resource()->client()) : 0;
+ Resource *resource = view ? resourceMap().value(view->surface()->waylandClient()) : 0;
if (resource && !m_hasSentEnter) {
uint32_t serial = compositor()->nextSerial();
QWaylandKeyboard *keyboard = m_seat->keyboard();
if (keyboard) {
keyboard->sendKeyModifiers(view->surface()->client(), serial);
}
- send_enter(resource->handle, serial, view->surface()->handle()->resource()->handle,
+ send_enter(resource->handle, serial, view->surface()->resource(),
wl_fixed_from_double(m_localPosition.x()), wl_fixed_from_double(m_localPosition.y()));
- m_focusDestroyListener.listenForDestruction(view->surface()->handle()->resource()->handle);
+ m_focusDestroyListener.listenForDestruction(view->surface()->resource());
m_hasSentEnter = true;
}
diff --git a/src/compositor/wayland_wrapper/qwlsurface.cpp b/src/compositor/wayland_wrapper/qwlsurface.cpp
deleted file mode 100644
index 45194f13a..000000000
--- a/src/compositor/wayland_wrapper/qwlsurface.cpp
+++ /dev/null
@@ -1,427 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwlsurface_p.h"
-
-#include "qwaylandsurface.h"
-#include "qwaylandsurface_p.h"
-#include "qwaylandview.h"
-#include "qwaylandview_p.h"
-#include "qwaylandoutput.h"
-#include "qwlcompositor_p.h"
-#include "qwlinputdevice_p.h"
-#include "qwlextendedsurface_p.h"
-#include "qwlregion_p.h"
-#include "qwlsubsurface_p.h"
-#include "qwlsurfacebuffer_p.h"
-#include "qwaylandoutput.h"
-#include "qwaylandsurface_p.h"
-
-#include <QtCore/QDebug>
-#include <QTouchEvent>
-#include <QGuiApplication>
-#include <QScreen>
-
-#include <wayland-server.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace QtWayland {
-
-class FrameCallback {
-public:
- FrameCallback(Surface *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
- _this->surface->removeFrameCallback(_this);
- delete _this;
- }
- Surface *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())));
-}
-
-Surface::Surface(struct wl_client *client, uint32_t id, int version, QWaylandCompositor *compositor, QWaylandSurface *surface)
- : QtWaylandServer::wl_surface(client, id, version)
- , m_compositor(compositor->handle())
- , m_waylandSurface(surface)
- , m_buffer(0)
- , m_surfaceMapped(false)
- , m_subSurface(0)
- , m_inputPanelSurface(0)
- , m_inputRegion(infiniteRegion())
- , m_isCursorSurface(false)
- , m_destroyed(false)
- , m_contentOrientation(Qt::PrimaryOrientation)
- , m_visibility(QWindow::Hidden)
-{
- m_pending.buffer = 0;
- m_pending.newlyAttached = false;
- m_pending.inputRegion = infiniteRegion();
-}
-
-Surface::~Surface()
-{
- delete m_subSurface;
-
- m_bufferRef = QWaylandBufferRef();
-
- for (int i = 0; i < m_bufferPool.size(); i++)
- m_bufferPool[i]->setDestroyIfUnused(true);
-
- foreach (FrameCallback *c, m_pendingFrameCallbacks)
- c->destroy();
- foreach (FrameCallback *c, m_frameCallbacks)
- c->destroy();
-}
-
-Surface *Surface::fromResource(struct ::wl_resource *resource)
-{
- return static_cast<Surface *>(Resource::fromResource(resource)->surface_object);
-}
-
-QSize Surface::size() const
-{
- return m_size;
-}
-
-void Surface::setSize(const QSize &size)
-{
- if (size != m_size) {
- m_opaqueRegion = QRegion();
- m_size = size;
- m_waylandSurface->sizeChanged();
- }
-}
-
-QRegion Surface::inputRegion() const
-{
- return m_inputRegion;
-}
-
-QRegion Surface::opaqueRegion() const
-{
- return m_opaqueRegion;
-}
-
-void Surface::sendFrameCallback()
-{
- uint time = m_compositor->currentTimeMsecs();
- foreach (FrameCallback *callback, m_frameCallbacks) {
- if (callback->canSend) {
- callback->send(time);
- m_frameCallbacks.removeOne(callback);
- }
- }
-}
-
-void Surface::removeFrameCallback(FrameCallback *callback)
-{
- m_pendingFrameCallbacks.removeOne(callback);
- m_frameCallbacks.removeOne(callback);
-}
-
-QWaylandSurface * Surface::waylandSurface() const
-{
- return m_waylandSurface;
-}
-
-QPoint Surface::lastMousePos() const
-{
- return m_lastLocalMousePos;
-}
-
-void Surface::setSubSurface(SubSurface *subSurface)
-{
- m_subSurface = subSurface;
-}
-
-SubSurface *Surface::subSurface() const
-{
- return m_subSurface;
-}
-
-void Surface::setInputPanelSurface(InputPanelSurface *inputPanelSurface)
-{
- m_inputPanelSurface = inputPanelSurface;
-}
-
-InputPanelSurface *Surface::inputPanelSurface() const
-{
- return m_inputPanelSurface;
-}
-
-Compositor *Surface::compositor() const
-{
- return m_compositor;
-}
-
-/*!
- * Sets the backbuffer for this surface. The back buffer is not yet on
- * screen and will become live during the next swapBuffers().
- *
- * The backbuffer represents the current state of the surface for the
- * purpose of GUI-thread accessible properties such as size and visibility.
- */
-void Surface::setBackBuffer(SurfaceBuffer *buffer, const QRegion &damage)
-{
- 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();
- }
-
- QWaylandSurfacePrivate *priv = QWaylandSurfacePrivate::get(waylandSurface());
- for (int i = 0; i < priv->views.size(); i++) {
- priv->views.at(i)->attach(m_bufferRef, m_damage);
- }
-
- emit m_waylandSurface->damaged(m_damage);
- setMapped(m_bufferRef.hasBuffer());
- if (!m_pending.offset.isNull())
- emit m_waylandSurface->offsetForNextFrame(m_pending.offset);
-}
-
-bool Surface::mapped() const
-{
- return m_buffer && bool(m_buffer->waylandBufferHandle());
-}
-
-void Surface::setMapped(bool mapped)
-{
- if (m_surfaceMapped == mapped)
- return;
-
- m_surfaceMapped = mapped;
- emit m_waylandSurface->mappedChanged();
-}
-
-SurfaceBuffer *Surface::createSurfaceBuffer(struct ::wl_resource *buffer)
-{
- 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 SurfaceBuffer(this);
- newBuffer->initialize(buffer);
- m_bufferPool.append(newBuffer);
- if (m_bufferPool.size() > 3)
- qWarning() << "Increased buffer pool size to" << m_bufferPool.size() << "for surface with title:" << title() << "className:" << className();
- }
-
- return newBuffer;
-}
-
-Qt::ScreenOrientation Surface::contentOrientation() const
-{
- return m_contentOrientation;
-}
-
-void Surface::notifyViewsAboutDestruction()
-{
- foreach (QWaylandView *view, m_waylandSurface->views()) {
- QWaylandViewPrivate::get(view)->markSurfaceAsDestroyed(m_waylandSurface);
- }
-}
-
-void Surface::surface_destroy_resource(Resource *)
-{
- notifyViewsAboutDestruction();
-
- m_destroyed = true;
- m_waylandSurface->destroy();
- emit m_waylandSurface->surfaceDestroyed();
-}
-
-void Surface::surface_destroy(Resource *resource)
-{
- wl_resource_destroy(resource->handle);
-}
-
-void Surface::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 Surface::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 Surface::surface_frame(Resource *resource, uint32_t callback)
-{
- struct wl_resource *frame_callback = wl_resource_create(resource->client(), &wl_callback_interface, wl_callback_interface.version, callback);
- m_pendingFrameCallbacks << new FrameCallback(this, frame_callback);
-}
-
-void Surface::surface_set_opaque_region(Resource *, struct wl_resource *region)
-{
- m_opaqueRegion = region ? Region::fromResource(region)->region() : QRegion();
-}
-
-void Surface::surface_set_input_region(Resource *, struct wl_resource *region)
-{
- if (region) {
- m_pending.inputRegion = Region::fromResource(region)->region();
- } else {
- m_pending.inputRegion = infiniteRegion();
- }
-}
-
-void Surface::surface_commit(Resource *)
-{
- 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 m_waylandSurface->redraw();
-}
-
-void Surface::surface_set_buffer_transform(Resource *resource, int32_t orientation)
-{
- Q_UNUSED(resource);
- 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 waylandSurface()->contentOrientationChanged();
-}
-
-void Surface::frameStarted()
-{
- foreach (FrameCallback *c, m_frameCallbacks)
- c->canSend = true;
-}
-
-void Surface::setClassName(const QString &className)
-{
- if (m_className != className) {
- m_className = className;
- emit waylandSurface()->classNameChanged();
- }
-}
-
-void Surface::setTitle(const QString &title)
-{
- if (m_title != title) {
- m_title = title;
- emit waylandSurface()->titleChanged();
- }
-}
-
-} // namespace Wayland
-
-QT_END_NAMESPACE
diff --git a/src/compositor/wayland_wrapper/qwlsurface_p.h b/src/compositor/wayland_wrapper/qwlsurface_p.h
deleted file mode 100644
index ae92d6f47..000000000
--- a/src/compositor/wayland_wrapper/qwlsurface_p.h
+++ /dev/null
@@ -1,196 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef WL_SURFACE_H
-#define WL_SURFACE_H
-
-#include <QtCompositor/qwaylandexport.h>
-
-#include <private/qwlsurfacebuffer_p.h>
-#include <QtCompositor/qwaylandsurface.h>
-#include <QtCompositor/qwaylandbufferref.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
-
-class QTouchEvent;
-
-namespace QtWayland {
-
-class Compositor;
-class Buffer;
-class ExtendedSurface;
-class InputPanelSurface;
-class SubSurface;
-class FrameCallback;
-
-class Q_COMPOSITOR_EXPORT Surface : public QtWaylandServer::wl_surface
-{
-public:
- Surface(struct wl_client *client, uint32_t id, int version, QWaylandCompositor *compositor, QWaylandSurface *surface);
- ~Surface();
-
- static Surface *fromResource(struct ::wl_resource *resource);
-
- bool mapped() const;
-
- using QtWaylandServer::wl_surface::resource;
-
- QSize size() const;
- void setSize(const QSize &size);
-
- QRegion inputRegion() const;
- QRegion opaqueRegion() const;
-
- void sendFrameCallback();
- void removeFrameCallback(FrameCallback *callback);
-
- QWaylandSurface *waylandSurface() const;
-
- QPoint lastMousePos() const;
-
- void setSubSurface(SubSurface *subSurface);
- SubSurface *subSurface() const;
-
- void setInputPanelSurface(InputPanelSurface *inputPanelSurface);
- InputPanelSurface *inputPanelSurface() const;
-
- Compositor *compositor() const;
-
- QString className() const { return m_className; }
- void setClassName(const QString &className);
-
- QString title() const { return m_title; }
- void setTitle(const QString &title);
-
- bool isCursorSurface() const { return m_isCursorSurface; }
- void setCursorSurface(bool isCursor) { m_isCursorSurface = isCursor; }
-
- void frameStarted();
-
- void setMapped(bool mapped);
- void setVisibility(QWindow::Visibility visibility) { m_visibility = visibility; }
-
- inline bool isDestroyed() const { return m_destroyed; }
-
- Qt::ScreenOrientation contentOrientation() const;
-
- 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;
-
- Q_DISABLE_COPY(Surface)
-
- Compositor *m_compositor;
- QWaylandSurface *m_waylandSurface;
-
- QRegion m_damage;
- SurfaceBuffer *m_buffer;
- QWaylandBufferRef m_bufferRef;
- bool m_surfaceMapped;
-
- struct {
- SurfaceBuffer *buffer;
- QRegion damage;
- QPoint offset;
- bool newlyAttached;
- QRegion inputRegion;
- } m_pending;
-
- QPoint m_lastLocalMousePos;
- QPoint m_lastGlobalMousePos;
-
- QList<FrameCallback *> m_pendingFrameCallbacks;
- QList<FrameCallback *> m_frameCallbacks;
-
- SubSurface *m_subSurface;
- InputPanelSurface *m_inputPanelSurface;
-
- QRegion m_inputRegion;
- QRegion m_opaqueRegion;
-
- QVector<SurfaceBuffer *> m_bufferPool;
-
- QSize m_size;
- QString m_className;
- QString m_title;
- bool m_isCursorSurface;
- bool m_destroyed;
- Qt::ScreenOrientation m_contentOrientation;
- QWindow::Visibility m_visibility;
-
- void setBackBuffer(SurfaceBuffer *buffer, const QRegion &damage);
-
- SurfaceBuffer *createSurfaceBuffer(struct ::wl_resource *buffer);
-
- friend class QWaylandSurface;
-};
-
-}
-
-QT_END_NAMESPACE
-
-#endif //WL_SURFACE_H
diff --git a/src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp b/src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp
index 225b49f4f..9c7671855 100644
--- a/src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp
+++ b/src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp
@@ -36,7 +36,6 @@
#include "qwlsurfacebuffer_p.h"
-#include "qwlsurface_p.h"
#include "qwlcompositor_p.h"
#ifdef QT_COMPOSITOR_WAYLAND_GL
@@ -53,7 +52,7 @@ QT_BEGIN_NAMESPACE
namespace QtWayland {
-SurfaceBuffer::SurfaceBuffer(Surface *surface)
+SurfaceBuffer::SurfaceBuffer(QWaylandSurface *surface)
: m_surface(surface)
, m_compositor(surface->compositor())
, m_buffer(0)
@@ -161,7 +160,7 @@ QSize SurfaceBuffer::size() const
int height = wl_shm_buffer_get_height(shmBuffer);
return QSize(width, height);
}
- if (ClientBufferIntegration *integration = m_compositor->clientBufferIntegration()) {
+ if (ClientBufferIntegration *integration = m_compositor->handle()->clientBufferIntegration()) {
return integration->bufferSize(m_buffer);
}
@@ -174,7 +173,7 @@ QWaylandSurface::Origin SurfaceBuffer::origin() const
return QWaylandSurface::OriginTopLeft;
}
- if (ClientBufferIntegration *integration = m_compositor->clientBufferIntegration()) {
+ if (ClientBufferIntegration *integration = m_compositor->handle()->clientBufferIntegration()) {
return integration->origin(m_buffer);
}
return QWaylandSurface::OriginTopLeft;
@@ -210,7 +209,7 @@ void SurfaceBuffer::bindToTexture() const
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image.width(), image.height(), 0, GL_RGB, GL_UNSIGNED_BYTE, image.constBits());
}
} else {
- if (QtWayland::ClientBufferIntegration *clientInt = m_compositor->clientBufferIntegration()) {
+ if (QtWayland::ClientBufferIntegration *clientInt = m_compositor->handle()->clientBufferIntegration()) {
clientInt->bindTextureToBuffer(m_buffer);
}
}
diff --git a/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h b/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h
index 8eecfa73f..ce2c2686d 100644
--- a/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h
+++ b/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h
@@ -50,12 +50,10 @@ QT_BEGIN_NAMESPACE
class QWaylandClientBufferIntegration;
class QWaylandBufferRef;
+class QWaylandCompositor;
namespace QtWayland {
-class Surface;
-class Compositor;
-
struct surface_buffer_destroy_listener
{
struct wl_listener listener;
@@ -65,7 +63,7 @@ struct surface_buffer_destroy_listener
class SurfaceBuffer
{
public:
- SurfaceBuffer(Surface *surface);
+ SurfaceBuffer(QWaylandSurface *surface);
~SurfaceBuffer();
@@ -96,13 +94,14 @@ public:
QImage image() const;
void bindToTexture() const;
+ static bool hasContent(SurfaceBuffer *buffer) { return buffer && buffer->isRegisteredWithBuffer(); }
private:
void ref();
void deref();
void destroyIfUnused();
- Surface *m_surface;
- Compositor *m_compositor;
+ QWaylandSurface *m_surface;
+ QWaylandCompositor *m_compositor;
struct ::wl_resource *m_buffer;
struct surface_buffer_destroy_listener m_destroy_listener;
bool m_committed;
diff --git a/src/compositor/wayland_wrapper/qwltouch.cpp b/src/compositor/wayland_wrapper/qwltouch.cpp
index 7f69f955f..85675a624 100644
--- a/src/compositor/wayland_wrapper/qwltouch.cpp
+++ b/src/compositor/wayland_wrapper/qwltouch.cpp
@@ -38,7 +38,6 @@
#include "qwltouch_p.h"
#include "qwlcompositor_p.h"
-#include "qwlsurface_p.h"
#include "qwaylandview.h"
#include "qwlqttouch_p.h"
diff --git a/src/compositor/wayland_wrapper/qwltouch_p.h b/src/compositor/wayland_wrapper/qwltouch_p.h
index 52beb81a6..c970d1c87 100644
--- a/src/compositor/wayland_wrapper/qwltouch_p.h
+++ b/src/compositor/wayland_wrapper/qwltouch_p.h
@@ -87,7 +87,7 @@ public:
if (!mouseFocus || !mouseFocus->surface())
return;
- m_focusResource = resourceMap().value(mouseFocus->surface()->client()->client());
+ m_focusResource = resourceMap().value(mouseFocus->surface()->waylandClient());
}
private:
void resetFocusState();
diff --git a/src/compositor/wayland_wrapper/wayland_wrapper.pri b/src/compositor/wayland_wrapper/wayland_wrapper.pri
index 2bc732565..cf7194fe6 100644
--- a/src/compositor/wayland_wrapper/wayland_wrapper.pri
+++ b/src/compositor/wayland_wrapper/wayland_wrapper.pri
@@ -18,7 +18,6 @@ HEADERS += \
wayland_wrapper/qwloutput_p.h \
wayland_wrapper/qwlpointer_p.h \
wayland_wrapper/qwlregion_p.h \
- wayland_wrapper/qwlsurface_p.h \
wayland_wrapper/qwlsurfacebuffer_p.h \
wayland_wrapper/qwltouch_p.h \
../shared/qwaylandxkb.h \
@@ -37,7 +36,6 @@ SOURCES += \
wayland_wrapper/qwloutput.cpp \
wayland_wrapper/qwlpointer.cpp \
wayland_wrapper/qwlregion.cpp \
- wayland_wrapper/qwlsurface.cpp \
wayland_wrapper/qwlsurfacebuffer.cpp \
wayland_wrapper/qwltouch.cpp \
../shared/qwaylandxkb.cpp \