summaryrefslogtreecommitdiffstats
path: root/src/compositor/compositor_api/qwaylandcompositor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/compositor/compositor_api/qwaylandcompositor.cpp')
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor.cpp102
1 files changed, 57 insertions, 45 deletions
diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp
index 795cb6a59..391b39416 100644
--- a/src/compositor/compositor_api/qwaylandcompositor.cpp
+++ b/src/compositor/compositor_api/qwaylandcompositor.cpp
@@ -39,7 +39,7 @@
#include "qwaylandcompositor_p.h"
#include <QtWaylandCompositor/qwaylandclient.h>
-#include <QtWaylandCompositor/qwaylandinput.h>
+#include <QtWaylandCompositor/qwaylandseat.h>
#include <QtWaylandCompositor/qwaylandoutput.h>
#include <QtWaylandCompositor/qwaylandview.h>
#include <QtWaylandCompositor/qwaylandclient.h>
@@ -58,12 +58,15 @@
#include "hardware_integration/qwlclientbufferintegrationfactory_p.h"
#include "hardware_integration/qwlserverbufferintegration_p.h"
#include "hardware_integration/qwlserverbufferintegrationfactory_p.h"
+
+#ifdef QT_WAYLAND_COMPOSITOR_GL
#include "hardware_integration/qwlhwintegration_p.h"
+#endif
-#include "extensions/qwaylandwindowmanagerextension.h"
+#include "extensions/qwaylandqtwindowmanager.h"
#include "qwaylandxkb_p.h"
-#include "qwaylandshmformathelper_p.h"
+#include "qwaylandsharedmemoryformathelper_p.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QStringList>
@@ -76,8 +79,8 @@
#include <QtGui/qpa/qplatformnativeinterface.h>
#include <QtGui/private/qguiapplication_p.h>
-#ifdef QT_COMPOSITOR_WAYLAND_GL
-# include <QtGui/private/qopengltextureblitter_p.h>
+#ifdef QT_WAYLAND_COMPOSITOR_GL
+# include <QOpenGLTextureBlitter>
# include <QOpenGLContext>
# include <QOpenGLFramebufferObject>
# include <QMatrix4x4>
@@ -97,7 +100,7 @@ public:
{
if (e->type == QWindowSystemInterfacePrivate::Key) {
QWindowSystemInterfacePrivate::KeyEvent *ke = static_cast<QWindowSystemInterfacePrivate::KeyEvent *>(e);
- QWaylandKeyboardPrivate *keyb = QWaylandKeyboardPrivate::get(compositor->defaultInputDevice()->keyboard());
+ QWaylandKeyboardPrivate *keyb = QWaylandKeyboardPrivate::get(compositor->defaultSeat()->keyboard());
uint32_t code = ke->nativeScanCode;
bool isDown = ke->keyType == QEvent::KeyPress;
@@ -138,7 +141,7 @@ public:
QWaylandCompositorPrivate::QWaylandCompositorPrivate(QWaylandCompositor *compositor)
: display(0)
-#if defined (QT_COMPOSITOR_WAYLAND_GL)
+#if defined (QT_WAYLAND_COMPOSITOR_GL)
, use_hw_integration_extension(true)
, client_buffer_integration(0)
, server_buffer_integration(0)
@@ -172,7 +175,7 @@ void QWaylandCompositorPrivate::init()
data_device_manager = new QtWayland::DataDeviceManager(q);
wl_display_init_shm(display);
- QVector<wl_shm_format> formats = QWaylandShmFormatHelper::supportedWaylandFormats();
+ QVector<wl_shm_format> formats = QWaylandSharedMemoryFormatHelper::supportedWaylandFormats();
foreach (wl_shm_format format, formats)
wl_display_add_shm_format(display, format);
@@ -197,7 +200,7 @@ void QWaylandCompositorPrivate::init()
QObject::connect(dispatcher, SIGNAL(aboutToBlock()), q, SLOT(processWaylandEvents()));
initializeHardwareIntegration();
- initializeDefaultInputDevice();
+ initializeDefaultSeat();
initialized = true;
@@ -287,7 +290,7 @@ void QWaylandCompositorPrivate::compositor_create_surface(wl_compositor::Resourc
{
Q_Q(QWaylandCompositor);
QWaylandClient *client = QWaylandClient::fromWlClient(q, resource->client());
- emit q->createSurface(client, id, resource->version());
+ emit q->surfaceRequested(client, id, resource->version());
#ifndef QT_NO_DEBUG
Q_ASSERT_X(!QWaylandSurfacePrivate::hasUninitializedSurface(), "QWaylandCompositor", QStringLiteral("Found uninitialized QWaylandSurface after emitting QWaylandCompositor::createSurface for id %1. All surfaces has to be initialized immediately after creation. See QWaylandSurface::initialize.").arg(id).toLocal8Bit().constData());
#endif
@@ -332,7 +335,7 @@ QWaylandSurface *QWaylandCompositorPrivate::createDefaultSurface()
void QWaylandCompositorPrivate::initializeHardwareIntegration()
{
-#ifdef QT_COMPOSITOR_WAYLAND_GL
+#ifdef QT_WAYLAND_COMPOSITOR_GL
Q_Q(QWaylandCompositor);
if (use_hw_integration_extension)
hw_integration.reset(new QtWayland::HardwareIntegration(q));
@@ -347,17 +350,17 @@ void QWaylandCompositorPrivate::initializeHardwareIntegration()
#endif
}
-void QWaylandCompositorPrivate::initializeDefaultInputDevice()
+void QWaylandCompositorPrivate::initializeDefaultSeat()
{
Q_Q(QWaylandCompositor);
- QWaylandInputDevice *device = q->createInputDevice();
- inputDevices.append(device);
- q->defaultInputDeviceChanged(device, nullptr);
+ QWaylandSeat *device = q->createSeat();
+ seats.append(device);
+ q->defaultSeatChanged(device, nullptr);
}
void QWaylandCompositorPrivate::loadClientBufferIntegration()
{
-#ifdef QT_COMPOSITOR_WAYLAND_GL
+#ifdef QT_WAYLAND_COMPOSITOR_GL
Q_Q(QWaylandCompositor);
QStringList keys = QtWayland::ClientBufferIntegrationFactory::keys();
QString targetKey;
@@ -386,7 +389,7 @@ void QWaylandCompositorPrivate::loadClientBufferIntegration()
void QWaylandCompositorPrivate::loadServerBufferIntegration()
{
-#ifdef QT_COMPOSITOR_WAYLAND_GL
+#ifdef QT_WAYLAND_COMPOSITOR_GL
QStringList keys = QtWayland::ServerBufferIntegrationFactory::keys();
QString targetKey;
QByteArray serverBufferIntegration = qgetenv("QT_WAYLAND_SERVER_BUFFER_INTEGRATION");
@@ -408,12 +411,12 @@ void QWaylandCompositorPrivate::loadServerBufferIntegration()
\brief Manages the Wayland display server.
The WaylandCompositor manages the connections to the clients, as well as the different
- \l{WaylandOutput}{outputs} and \l{QWaylandInputDevice}{input devices}.
+ \l{WaylandOutput}{outputs} and \l{QWaylandSeat}{seats}.
Normally, a compositor application will have a single WaylandCompositor
instance, which can have several outputs as children. When a client
requests the compositor to create a surface, the request is handled by
- the onCreateSurface handler.
+ the onSurfaceRequested handler.
Extensions that are supported by the compositor should be instantiated and added to the
extensions property.
@@ -427,7 +430,7 @@ void QWaylandCompositorPrivate::loadServerBufferIntegration()
\brief The QWaylandCompositor class manages the Wayland display server.
The QWaylandCompositor manages the connections to the clients, as well as the different \l{QWaylandOutput}{outputs}
- and \l{QWaylandInputDevice}{input devices}.
+ and \l{QWaylandSeat}{seats}.
Normally, a compositor application will have a single WaylandCompositor
instance, which can have several outputs as children.
@@ -568,9 +571,9 @@ void QWaylandCompositor::destroyClient(QWaylandClient *client)
if (!client)
return;
- QWaylandWindowManagerExtension *wmExtension = QWaylandWindowManagerExtension::findIn(this);
+ QWaylandQtWindowManager *wmExtension = QWaylandQtWindowManager::findIn(this);
if (wmExtension)
- wmExtension->sendQuitMessage(client->client());
+ wmExtension->sendQuitMessage(client);
wl_client_destroy(client->client());
}
@@ -682,33 +685,33 @@ void QWaylandCompositor::processWaylandEvents()
/*!
* \internal
*/
-QWaylandInputDevice *QWaylandCompositor::createInputDevice()
+QWaylandSeat *QWaylandCompositor::createSeat()
{
- return new QWaylandInputDevice(this);
+ return new QWaylandSeat(this);
}
/*!
* \internal
*/
-QWaylandPointer *QWaylandCompositor::createPointerDevice(QWaylandInputDevice *inputDevice)
+QWaylandPointer *QWaylandCompositor::createPointerDevice(QWaylandSeat *seat)
{
- return new QWaylandPointer(inputDevice);
+ return new QWaylandPointer(seat);
}
/*!
* \internal
*/
-QWaylandKeyboard *QWaylandCompositor::createKeyboardDevice(QWaylandInputDevice *inputDevice)
+QWaylandKeyboard *QWaylandCompositor::createKeyboardDevice(QWaylandSeat *seat)
{
- return new QWaylandKeyboard(inputDevice);
+ return new QWaylandKeyboard(seat);
}
/*!
* \internal
*/
-QWaylandTouch *QWaylandCompositor::createTouchDevice(QWaylandInputDevice *inputDevice)
+QWaylandTouch *QWaylandCompositor::createTouchDevice(QWaylandSeat *seat)
{
- return new QWaylandTouch(inputDevice);
+ return new QWaylandTouch(seat);
}
/*!
@@ -751,38 +754,38 @@ void QWaylandCompositor::overrideSelection(const QMimeData *data)
}
/*!
- * \qmlproperty object QtWaylandCompositor::WaylandCompositor::defaultInputDevice
+ * \qmlproperty object QtWaylandCompositor::WaylandCompositor::defaultSeat
*
- * This property contains the default input device for this
+ * This property contains the default seat for this
* WaylandCompositor.
*/
/*!
- * \property QWaylandCompositor::defaultInputDevice
+ * \property QWaylandCompositor::defaultSeat
*
- * This property contains the default input device for this
+ * This property contains the default seat for this
* QWaylandCompositor.
*/
-QWaylandInputDevice *QWaylandCompositor::defaultInputDevice() const
+QWaylandSeat *QWaylandCompositor::defaultSeat() const
{
Q_D(const QWaylandCompositor);
- if (d->inputDevices.size())
- return d->inputDevices.first();
+ if (d->seats.size())
+ return d->seats.first();
return Q_NULLPTR;
}
/*!
* \internal
*
- * Currently, Qt only supports a single input device, so this exists for
+ * Currently, Qt only supports a single seat, so this exists for
* future proofing the APIs.
*/
-QWaylandInputDevice *QWaylandCompositor::inputDeviceFor(QInputEvent *inputEvent)
+QWaylandSeat *QWaylandCompositor::seatFor(QInputEvent *inputEvent)
{
Q_D(QWaylandCompositor);
- QWaylandInputDevice *dev = NULL;
- for (int i = 0; i < d->inputDevices.size(); i++) {
- QWaylandInputDevice *candidate = d->inputDevices.at(i);
+ QWaylandSeat *dev = NULL;
+ for (int i = 0; i < d->seats.size(); i++) {
+ QWaylandSeat *candidate = d->seats.at(i);
if (candidate->isOwner(inputEvent)) {
dev = candidate;
break;
@@ -810,12 +813,17 @@ QWaylandInputDevice *QWaylandCompositor::inputDeviceFor(QInputEvent *inputEvent)
*/
bool QWaylandCompositor::useHardwareIntegrationExtension() const
{
+#ifdef QT_WAYLAND_COMPOSITOR_GL
Q_D(const QWaylandCompositor);
return d->use_hw_integration_extension;
+#else
+ return false;
+#endif
}
void QWaylandCompositor::setUseHardwareIntegrationExtension(bool use)
{
+#ifdef QT_WAYLAND_COMPOSITOR_GL
Q_D(QWaylandCompositor);
if (use == d->use_hw_integration_extension)
return;
@@ -825,6 +833,10 @@ void QWaylandCompositor::setUseHardwareIntegrationExtension(bool use)
d->use_hw_integration_extension = use;
useHardwareIntegrationExtensionChanged();
+#else
+ if (use)
+ qWarning() << "Hardware integration not supported without OpenGL support";
+#endif
}
/*!
@@ -832,16 +844,16 @@ void QWaylandCompositor::setUseHardwareIntegrationExtension(bool use)
* The default implementation requires a OpenGL context to be bound to the current thread
* to work. If this is not possible, reimplement this function in your compositor subclass
* to implement custom logic.
- * The default implementation only grabs SHM and OpenGL buffers, reimplement this in your
+ * The default implementation only grabs shared memory and OpenGL buffers, reimplement this in your
* compositor subclass to handle more buffer types.
* \note You should not call this manually, but rather use QWaylandSurfaceGrabber (\a grabber).
*/
void QWaylandCompositor::grabSurface(QWaylandSurfaceGrabber *grabber, const QWaylandBufferRef &buffer)
{
- if (buffer.isShm()) {
+ if (buffer.isSharedMemory()) {
emit grabber->success(buffer.image());
} else {
-#ifdef QT_COMPOSITOR_WAYLAND_GL
+#ifdef QT_WAYLAND_COMPOSITOR_GL
if (QOpenGLContext::currentContext()) {
QOpenGLFramebufferObject fbo(buffer.size());
fbo.bind();