diff options
Diffstat (limited to 'src/compositor/compositor_api')
39 files changed, 591 insertions, 381 deletions
diff --git a/src/compositor/compositor_api/compositor_api.pri b/src/compositor/compositor_api/compositor_api.pri index 1724ec965..e803d14c0 100644 --- a/src/compositor/compositor_api/compositor_api.pri +++ b/src/compositor/compositor_api/compositor_api.pri @@ -6,8 +6,8 @@ HEADERS += \ compositor_api/qwaylandclient.h \ compositor_api/qwaylandsurface.h \ compositor_api/qwaylandsurface_p.h \ - compositor_api/qwaylandinput.h \ - compositor_api/qwaylandinput_p.h \ + compositor_api/qwaylandseat.h \ + compositor_api/qwaylandseat_p.h \ compositor_api/qwaylandkeyboard.h \ compositor_api/qwaylandkeyboard_p.h \ compositor_api/qwaylandpointer.h \ @@ -30,7 +30,7 @@ SOURCES += \ compositor_api/qwaylandcompositor.cpp \ compositor_api/qwaylandclient.cpp \ compositor_api/qwaylandsurface.cpp \ - compositor_api/qwaylandinput.cpp \ + compositor_api/qwaylandseat.cpp \ compositor_api/qwaylandkeyboard.cpp \ compositor_api/qwaylandpointer.cpp \ compositor_api/qwaylandtouch.cpp \ @@ -45,7 +45,9 @@ SOURCES += \ QT += core-private -qtHaveModule(quick) { +qtHaveModule(quick):contains(QT_CONFIG, opengl) { + DEFINES += QT_WAYLAND_COMPOSITOR_QUICK + SOURCES += \ compositor_api/qwaylandquickcompositor.cpp \ compositor_api/qwaylandquicksurface.cpp \ diff --git a/src/compositor/compositor_api/qwaylandbufferref.cpp b/src/compositor/compositor_api/qwaylandbufferref.cpp index 624deaff9..7cc17fcbe 100644 --- a/src/compositor/compositor_api/qwaylandbufferref.cpp +++ b/src/compositor/compositor_api/qwaylandbufferref.cpp @@ -205,8 +205,8 @@ QWaylandBufferRef::BufferType QWaylandBufferRef::bufferType() const if (d->nullOrDestroyed()) return BufferType_Null; - if (isShm()) - return BufferType_Shm; + if (isSharedMemory()) + return BufferType_SharedMemory; return BufferType_Egl; } @@ -222,12 +222,12 @@ QWaylandBufferRef::BufferFormatEgl QWaylandBufferRef::bufferFormatEgl() const /*! * Returns true if the buffer is a shared memory buffer. Otherwise returns false. */ -bool QWaylandBufferRef::isShm() const +bool QWaylandBufferRef::isSharedMemory() const { if (d->nullOrDestroyed()) return false; - return d->buffer->isShm(); + return d->buffer->isSharedMemory(); } /*! @@ -241,7 +241,7 @@ QImage QWaylandBufferRef::image() const return d->buffer->image(); } -#ifdef QT_COMPOSITOR_WAYLAND_GL +#ifdef QT_WAYLAND_COMPOSITOR_GL GLuint QWaylandBufferRef::textureForPlane(int plane) const { if (d->nullOrDestroyed()) @@ -249,7 +249,6 @@ GLuint QWaylandBufferRef::textureForPlane(int plane) const return d->buffer->textureForPlane(plane); } -#endif /*! * Binds the buffer to the current OpenGL texture. This may @@ -267,10 +266,11 @@ void QWaylandBufferRef::bindToTexture() const void QWaylandBufferRef::updateTexture() const { - if (d->nullOrDestroyed() || d->buffer->isShm()) + if (d->nullOrDestroyed() || d->buffer->isSharedMemory()) return; d->buffer->updateTexture(); } +#endif QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandbufferref.h b/src/compositor/compositor_api/qwaylandbufferref.h index 50c85b965..77f817aba 100644 --- a/src/compositor/compositor_api/qwaylandbufferref.h +++ b/src/compositor/compositor_api/qwaylandbufferref.h @@ -39,7 +39,7 @@ #include <QImage> -#ifdef QT_COMPOSITOR_WAYLAND_GL +#ifdef QT_WAYLAND_COMPOSITOR_GL #include <QtGui/qopengl.h> #endif @@ -77,7 +77,7 @@ public: enum BufferType { BufferType_Null, - BufferType_Shm, + BufferType_SharedMemory, BufferType_Egl }; @@ -94,14 +94,14 @@ public: BufferType bufferType() const; BufferFormatEgl bufferFormatEgl() const; - bool isShm() const; + bool isSharedMemory() const; QImage image() const; -#ifdef QT_COMPOSITOR_WAYLAND_GL - GLuint textureForPlane(int plane) const; -#endif +#ifdef QT_WAYLAND_COMPOSITOR_GL + GLuint textureForPlane(int plane) const; void bindToTexture() const; void updateTexture() const; +#endif private: class QWaylandBufferRefPrivate *const d; diff --git a/src/compositor/compositor_api/qwaylandclient.cpp b/src/compositor/compositor_api/qwaylandclient.cpp index fbf8c1275..23c3745d7 100644 --- a/src/compositor/compositor_api/qwaylandclient.cpp +++ b/src/compositor/compositor_api/qwaylandclient.cpp @@ -164,6 +164,24 @@ QWaylandClient *QWaylandClient::fromWlClient(QWaylandCompositor *compositor, wl_ } /*! + * \qmlproperty object QtWaylandCompositor::WaylandClient::compositor + * + * This property holds the compositor of this WaylandClient. + */ + +/*! + * \property QWaylandClient::compositor + * + * This property holds the compositor of this QWaylandClient. + */ +QWaylandCompositor *QWaylandClient::compositor() const +{ + Q_D(const QWaylandClient); + + return d->compositor; +} + +/*! * Returns the Wayland client of this QWaylandClient. */ wl_client *QWaylandClient::client() const diff --git a/src/compositor/compositor_api/qwaylandclient.h b/src/compositor/compositor_api/qwaylandclient.h index 26e7b95e5..50e7baf72 100644 --- a/src/compositor/compositor_api/qwaylandclient.h +++ b/src/compositor/compositor_api/qwaylandclient.h @@ -55,6 +55,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandClient : public QObject Q_OBJECT Q_DECLARE_PRIVATE(QWaylandClient) + Q_PROPERTY(QWaylandCompositor *compositor READ compositor CONSTANT) Q_PROPERTY(qint64 userId READ userId CONSTANT) Q_PROPERTY(qint64 groupId READ groupId CONSTANT) Q_PROPERTY(qint64 processId READ processId CONSTANT) @@ -63,6 +64,8 @@ public: static QWaylandClient *fromWlClient(QWaylandCompositor *compositor, wl_client *wlClient); + QWaylandCompositor *compositor() const; + wl_client *client() const; qint64 userId() const; 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(); diff --git a/src/compositor/compositor_api/qwaylandcompositor.h b/src/compositor/compositor_api/qwaylandcompositor.h index f97484d86..15022b378 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.h +++ b/src/compositor/compositor_api/qwaylandcompositor.h @@ -58,7 +58,7 @@ class QOpenGLContext; class QWaylandCompositorPrivate; class QWaylandClient; class QWaylandSurface; -class QWaylandInputDevice; +class QWaylandSeat; class QWaylandGlobalInterface; class QWaylandView; class QWaylandPointer; @@ -77,7 +77,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandCompositor : public QWaylandObject Q_PROPERTY(bool retainedSelection READ retainedSelectionEnabled WRITE setRetainedSelectionEnabled) Q_PROPERTY(QWaylandOutput *defaultOutput READ defaultOutput WRITE setDefaultOutput NOTIFY defaultOutputChanged) Q_PROPERTY(bool useHardwareIntegrationExtension READ useHardwareIntegrationExtension WRITE setUseHardwareIntegrationExtension NOTIFY useHardwareIntegrationExtensionChanged) - Q_PROPERTY(QWaylandInputDevice *defaultInputDevice READ defaultInputDevice NOTIFY defaultInputDeviceChanged) + Q_PROPERTY(QWaylandSeat *defaultSeat READ defaultSeat NOTIFY defaultSeatChanged) public: QWaylandCompositor(QObject *parent = nullptr); @@ -111,11 +111,11 @@ public: bool retainedSelectionEnabled() const; void overrideSelection(const QMimeData *data); - QWaylandInputDevice *defaultInputDevice() const; + QWaylandSeat *defaultSeat() const; QWaylandView *createSurfaceView(QWaylandSurface *surface); - QWaylandInputDevice *inputDeviceFor(QInputEvent *inputEvent); + QWaylandSeat *seatFor(QInputEvent *inputEvent); bool useHardwareIntegrationExtension() const; void setUseHardwareIntegrationExtension(bool use); @@ -126,21 +126,25 @@ public Q_SLOTS: void processWaylandEvents(); Q_SIGNALS: - void createSurface(QWaylandClient *client, uint id, int version); + void surfaceRequested(QWaylandClient *client, uint id, int version); void surfaceCreated(QWaylandSurface *surface); void surfaceAboutToBeDestroyed(QWaylandSurface *surface); void subsurfaceChanged(QWaylandSurface *child, QWaylandSurface *parent); void defaultOutputChanged(); - void defaultInputDeviceChanged(QWaylandInputDevice *newDevice, QWaylandInputDevice *oldDevice); + void defaultSeatChanged(QWaylandSeat *newDevice, QWaylandSeat *oldDevice); void useHardwareIntegrationExtensionChanged(); + + void outputAdded(QWaylandOutput *output); + void outputRemoved(QWaylandOutput *output); + protected: virtual void retainedSelectionReceived(QMimeData *mimeData); - virtual QWaylandInputDevice *createInputDevice(); - virtual QWaylandPointer *createPointerDevice(QWaylandInputDevice *inputDevice); - virtual QWaylandKeyboard *createKeyboardDevice(QWaylandInputDevice *inputDevice); - virtual QWaylandTouch *createTouchDevice(QWaylandInputDevice *inputDevice); + virtual QWaylandSeat *createSeat(); + virtual QWaylandPointer *createPointerDevice(QWaylandSeat *seat); + virtual QWaylandKeyboard *createKeyboardDevice(QWaylandSeat *seat); + virtual QWaylandTouch *createTouchDevice(QWaylandSeat *seat); QWaylandCompositor(QWaylandCompositorPrivate &dptr, QObject *parent = nullptr); }; diff --git a/src/compositor/compositor_api/qwaylandcompositor_p.h b/src/compositor/compositor_api/qwaylandcompositor_p.h index 8966acb38..708d0113d 100644 --- a/src/compositor/compositor_api/qwaylandcompositor_p.h +++ b/src/compositor/compositor_api/qwaylandcompositor_p.h @@ -90,12 +90,12 @@ public: QtWayland::DataDeviceManager *dataDeviceManager() const { return data_device_manager; } void feedRetainedSelectionData(QMimeData *data); - QWaylandPointer *callCreatePointerDevice(QWaylandInputDevice *inputDevice) - { return q_func()->createPointerDevice(inputDevice); } - QWaylandKeyboard *callCreateKeyboardDevice(QWaylandInputDevice *inputDevice) - { return q_func()->createKeyboardDevice(inputDevice); } - QWaylandTouch *callCreateTouchDevice(QWaylandInputDevice *inputDevice) - { return q_func()->createTouchDevice(inputDevice); } + QWaylandPointer *callCreatePointerDevice(QWaylandSeat *seat) + { return q_func()->createPointerDevice(seat); } + QWaylandKeyboard *callCreateKeyboardDevice(QWaylandSeat *seat) + { return q_func()->createKeyboardDevice(seat); } + QWaylandTouch *callCreateTouchDevice(QWaylandSeat *seat) + { return q_func()->createTouchDevice(seat); } inline void addClient(QWaylandClient *client); inline void removeClient(QWaylandClient *client); @@ -114,7 +114,7 @@ protected: protected: void initializeHardwareIntegration(); void initializeExtensions(); - void initializeDefaultInputDevice(); + void initializeDefaultSeat(); void loadClientBufferIntegration(); void loadServerBufferIntegration(); @@ -122,7 +122,7 @@ protected: QByteArray socket_name; struct wl_display *display; - QList<QWaylandInputDevice *> inputDevices; + QList<QWaylandSeat *> seats; QList<QWaylandOutput *> outputs; QList<QWaylandSurface *> all_surfaces; @@ -135,7 +135,7 @@ protected: QList<QWaylandClient *> clients; -#ifdef QT_COMPOSITOR_WAYLAND_GL +#ifdef QT_WAYLAND_COMPOSITOR_GL bool use_hw_integration_extension; QScopedPointer<QtWayland::HardwareIntegration> hw_integration; QScopedPointer<QtWayland::ClientBufferIntegration> client_buffer_integration; @@ -154,7 +154,7 @@ protected: QtWayland::ClientBufferIntegration * QWaylandCompositorPrivate::clientBufferIntegration() const { -#ifdef QT_COMPOSITOR_WAYLAND_GL +#ifdef QT_WAYLAND_COMPOSITOR_GL return client_buffer_integration.data(); #else return 0; @@ -163,7 +163,7 @@ QtWayland::ClientBufferIntegration * QWaylandCompositorPrivate::clientBufferInte QtWayland::ServerBufferIntegration * QWaylandCompositorPrivate::serverBufferIntegration() const { -#ifdef QT_COMPOSITOR_WAYLAND_GL +#ifdef QT_WAYLAND_COMPOSITOR_GL return server_buffer_integration.data(); #else return 0; @@ -185,16 +185,20 @@ void QWaylandCompositorPrivate::removeClient(QWaylandClient *client) void QWaylandCompositorPrivate::addOutput(QWaylandOutput *output) { Q_ASSERT(output); + Q_Q(QWaylandCompositor); if (outputs.contains(output)) return; outputs.append(output); + emit q->outputAdded(output); } void QWaylandCompositorPrivate::removeOutput(QWaylandOutput *output) { Q_ASSERT(output); Q_ASSERT(outputs.count(output) == 1); - outputs.removeOne(output); + Q_Q(QWaylandCompositor); + if (outputs.removeOne(output)) + emit q->outputRemoved(output); } QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylanddrag.cpp b/src/compositor/compositor_api/qwaylanddrag.cpp index cc45c1279..3c3d9ce52 100644 --- a/src/compositor/compositor_api/qwaylanddrag.cpp +++ b/src/compositor/compositor_api/qwaylanddrag.cpp @@ -40,33 +40,33 @@ #include "qwldatadevice_p.h" #include "qwaylandview.h" -#include <QtWaylandCompositor/private/qwaylandinput_p.h> +#include <QtWaylandCompositor/private/qwaylandseat_p.h> QT_BEGIN_NAMESPACE class QWaylandDragPrivate : public QObjectPrivate { public: - QWaylandDragPrivate(QWaylandInputDevice *id) - : inputDevice(id) + QWaylandDragPrivate(QWaylandSeat *seat) + : seat(seat) { } QtWayland::DataDevice *dataDevice() { - return QWaylandInputDevicePrivate::get(inputDevice)->dataDevice(); + return QWaylandSeatPrivate::get(seat)->dataDevice(); } const QtWayland::DataDevice *dataDevice() const { - return QWaylandInputDevicePrivate::get(inputDevice)->dataDevice(); + return QWaylandSeatPrivate::get(seat)->dataDevice(); } - QWaylandInputDevice *inputDevice; + QWaylandSeat *seat; }; -QWaylandDrag::QWaylandDrag(QWaylandInputDevice *inputDevice) - : QObject(* new QWaylandDragPrivate(inputDevice)) +QWaylandDrag::QWaylandDrag(QWaylandSeat *seat) + : QObject(* new QWaylandDragPrivate(seat)) { } @@ -81,6 +81,19 @@ QWaylandSurface *QWaylandDrag::icon() const return dataDevice->dragIcon(); } +QWaylandSurface *QWaylandDrag::origin() const +{ + Q_D(const QWaylandDrag); + const QtWayland::DataDevice *dataDevice = d->dataDevice(); + return dataDevice ? dataDevice->dragOrigin() : nullptr; +} + +QWaylandSeat *QWaylandDrag::seat() const +{ + Q_D(const QWaylandDrag); + return d->seat; +} + bool QWaylandDrag::visible() const { diff --git a/src/compositor/compositor_api/qwaylanddrag.h b/src/compositor/compositor_api/qwaylanddrag.h index 00a2bee8e..08ad11018 100644 --- a/src/compositor/compositor_api/qwaylanddrag.h +++ b/src/compositor/compositor_api/qwaylanddrag.h @@ -46,12 +46,7 @@ QT_BEGIN_NAMESPACE class QWaylandDragPrivate; class QWaylandSurface; -class QWaylandView; -class QWaylandInputDevice; - -namespace QtWayland { - class DataDevice; -} +class QWaylandSeat; class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandDrag : public QObject { @@ -62,10 +57,11 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandDrag : public QObject Q_PROPERTY(bool visible READ visible NOTIFY iconChanged) public: - explicit QWaylandDrag(QWaylandInputDevice *inputDevice); + explicit QWaylandDrag(QWaylandSeat *seat); QWaylandSurface *icon() const; - // QPointF position() const; + QWaylandSurface *origin() const; + QWaylandSeat *seat() const; bool visible() const; public Q_SLOTS: @@ -76,9 +72,6 @@ public Q_SLOTS: Q_SIGNALS: void iconChanged(); void dragStarted(); // QWaylandSurface *icon???? - -private: - //friend class QtWayland::DataDevice; }; QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp b/src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp index 122c589da..68279bb97 100644 --- a/src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp +++ b/src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp @@ -38,7 +38,7 @@ #include "qwaylandinputmethodcontrol_p.h" #include "qwaylandcompositor.h" -#include "qwaylandinput.h" +#include "qwaylandseat.h" #include "qwaylandsurface.h" #include "qwaylandview.h" #include "qwaylandtextinput.h" @@ -48,8 +48,8 @@ QWaylandInputMethodControl::QWaylandInputMethodControl(QWaylandSurface *surface) : QObject(*new QWaylandInputMethodControlPrivate(surface), surface) { - connect(d_func()->compositor, &QWaylandCompositor::defaultInputDeviceChanged, - this, &QWaylandInputMethodControl::defaultInputDeviceChanged); + connect(d_func()->compositor, &QWaylandCompositor::defaultSeatChanged, + this, &QWaylandInputMethodControl::defaultSeatChanged); QWaylandTextInput *textInput = d_func()->textInput(); if (textInput) { connect(textInput, &QWaylandTextInput::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled); @@ -135,13 +135,13 @@ void QWaylandInputMethodControl::setSurface(QWaylandSurface *surface) setEnabled(textInput && textInput->isSurfaceEnabled(d->surface)); } -void QWaylandInputMethodControl::defaultInputDeviceChanged() +void QWaylandInputMethodControl::defaultSeatChanged() { Q_D(QWaylandInputMethodControl); disconnect(d->textInput(), 0, this, 0); - d->inputDevice = d->compositor->defaultInputDevice(); + d->seat = d->compositor->defaultSeat(); QWaylandTextInput *textInput = d->textInput(); connect(textInput, &QWaylandTextInput::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled); @@ -153,7 +153,7 @@ void QWaylandInputMethodControl::defaultInputDeviceChanged() QWaylandInputMethodControlPrivate::QWaylandInputMethodControlPrivate(QWaylandSurface *surface) : QObjectPrivate() , compositor(surface->compositor()) - , inputDevice(compositor->defaultInputDevice()) + , seat(compositor->defaultSeat()) , surface(surface) , enabled(false) { @@ -161,5 +161,5 @@ QWaylandInputMethodControlPrivate::QWaylandInputMethodControlPrivate(QWaylandSur QWaylandTextInput *QWaylandInputMethodControlPrivate::textInput() const { - return QWaylandTextInput::findIn(inputDevice); + return QWaylandTextInput::findIn(seat); } diff --git a/src/compositor/compositor_api/qwaylandinputmethodcontrol.h b/src/compositor/compositor_api/qwaylandinputmethodcontrol.h index f71650294..ab894c9c5 100644 --- a/src/compositor/compositor_api/qwaylandinputmethodcontrol.h +++ b/src/compositor/compositor_api/qwaylandinputmethodcontrol.h @@ -74,7 +74,7 @@ Q_SIGNALS: #endif private: - void defaultInputDeviceChanged(); + void defaultSeatChanged(); void surfaceEnabled(QWaylandSurface *surface); void surfaceDisabled(QWaylandSurface *surface); }; diff --git a/src/compositor/compositor_api/qwaylandinputmethodcontrol_p.h b/src/compositor/compositor_api/qwaylandinputmethodcontrol_p.h index a687e5299..a4f9ce877 100644 --- a/src/compositor/compositor_api/qwaylandinputmethodcontrol_p.h +++ b/src/compositor/compositor_api/qwaylandinputmethodcontrol_p.h @@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE class QWaylandCompositor; -class QWaylandInputDevice; +class QWaylandSeat; class QWaylandSurface; class QWaylandTextInput; @@ -70,7 +70,7 @@ public: QWaylandTextInput *textInput() const; QWaylandCompositor *compositor; - QWaylandInputDevice *inputDevice; + QWaylandSeat *seat; QWaylandSurface *surface; bool enabled; }; diff --git a/src/compositor/compositor_api/qwaylandkeyboard.cpp b/src/compositor/compositor_api/qwaylandkeyboard.cpp index 22870654e..42349fb24 100644 --- a/src/compositor/compositor_api/qwaylandkeyboard.cpp +++ b/src/compositor/compositor_api/qwaylandkeyboard.cpp @@ -38,7 +38,7 @@ #include "qwaylandkeyboard.h" #include "qwaylandkeyboard_p.h" #include <QtWaylandCompositor/QWaylandCompositor> -#include <QtWaylandCompositor/QWaylandInputDevice> +#include <QtWaylandCompositor/QWaylandSeat> #include <QtWaylandCompositor/QWaylandClient> #include <QtCore/QFile> @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE -QWaylandKeyboardPrivate::QWaylandKeyboardPrivate(QWaylandInputDevice *seat) +QWaylandKeyboardPrivate::QWaylandKeyboardPrivate(QWaylandSeat *seat) : QtWaylandServer::wl_keyboard() , seat(seat) , focus() @@ -384,24 +384,24 @@ void QWaylandKeyboardPrivate::sendRepeatInfo() * \preliminary * \brief The QWaylandKeyboard class represents a keyboard device. * - * This class provides access to the keyboard device in a QWaylandInputDevice. It corresponds to + * This class provides access to the keyboard device in a QWaylandSeat. It corresponds to * the Wayland interface wl_keyboard. */ /*! - * Constructs a QWaylandKeyboard for the given \a inputDevice and with the given \a parent. + * Constructs a QWaylandKeyboard for the given \a seat and with the given \a parent. */ -QWaylandKeyboard::QWaylandKeyboard(QWaylandInputDevice *inputDevice, QObject *parent) - : QWaylandObject(* new QWaylandKeyboardPrivate(inputDevice), parent) +QWaylandKeyboard::QWaylandKeyboard(QWaylandSeat *seat, QObject *parent) + : QWaylandObject(* new QWaylandKeyboardPrivate(seat), parent) { Q_D(QWaylandKeyboard); connect(&d->focusDestroyListener, &QWaylandDestroyListener::fired, this, &QWaylandKeyboard::focusDestroyed); } /*! - * Returns the input device for this QWaylandKeyboard. + * Returns the seat for this QWaylandKeyboard. */ -QWaylandInputDevice *QWaylandKeyboard::inputDevice() const +QWaylandSeat *QWaylandKeyboard::seat() const { Q_D(const QWaylandKeyboard); return d->seat; diff --git a/src/compositor/compositor_api/qwaylandkeyboard.h b/src/compositor/compositor_api/qwaylandkeyboard.h index b5bf6fe5c..1348f5cd9 100644 --- a/src/compositor/compositor_api/qwaylandkeyboard.h +++ b/src/compositor/compositor_api/qwaylandkeyboard.h @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE class QWaylandKeyboard; class QWaylandKeyboardPrivate; -class QWaylandInputDevice; +class QWaylandSeat; class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandKeymap { @@ -76,9 +76,9 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandKeyboard : public QWaylandObject Q_PROPERTY(quint32 repeatRate READ repeatRate WRITE setRepeatRate NOTIFY repeatRateChanged) Q_PROPERTY(quint32 repeatDelay READ repeatDelay WRITE setRepeatDelay NOTIFY repeatDelayChanged) public: - QWaylandKeyboard(QWaylandInputDevice *inputDevice, QObject *parent = nullptr); + QWaylandKeyboard(QWaylandSeat *seat, QObject *parent = nullptr); - QWaylandInputDevice *inputDevice() const; + QWaylandSeat *seat() const; QWaylandCompositor *compositor() const; quint32 repeatRate() const; diff --git a/src/compositor/compositor_api/qwaylandkeyboard_p.h b/src/compositor/compositor_api/qwaylandkeyboard_p.h index ede97d8ba..ac306282e 100644 --- a/src/compositor/compositor_api/qwaylandkeyboard_p.h +++ b/src/compositor/compositor_api/qwaylandkeyboard_p.h @@ -50,7 +50,7 @@ // #include <QtWaylandCompositor/qwaylandexport.h> -#include <QtWaylandCompositor/qwaylandinput.h> +#include <QtWaylandCompositor/qwaylandseat.h> #include <QtWaylandCompositor/qwaylandkeyboard.h> #include <QtWaylandCompositor/qwaylanddestroylistener.h> @@ -74,7 +74,7 @@ public: static QWaylandKeyboardPrivate *get(QWaylandKeyboard *keyboard); - QWaylandKeyboardPrivate(QWaylandInputDevice *seat); + QWaylandKeyboardPrivate(QWaylandSeat *seat); ~QWaylandKeyboardPrivate(); QWaylandCompositor *compositor() const { return seat->compositor(); } @@ -111,7 +111,7 @@ private: void sendRepeatInfo(); - QWaylandInputDevice *seat; + QWaylandSeat *seat; QWaylandSurface *focus; Resource *focusResource; diff --git a/src/compositor/compositor_api/qwaylandoutput.cpp b/src/compositor/compositor_api/qwaylandoutput.cpp index a2ebf8b25..c34080b36 100644 --- a/src/compositor/compositor_api/qwaylandoutput.cpp +++ b/src/compositor/compositor_api/qwaylandoutput.cpp @@ -846,7 +846,7 @@ void QWaylandOutput::sendFrameCallbacks() Q_D(QWaylandOutput); for (int i = 0; i < d->surfaceViews.size(); i++) { const QWaylandSurfaceViewMapper &surfacemapper = d->surfaceViews.at(i); - if (surfacemapper.surface && surfacemapper.surface->isMapped()) { + if (surfacemapper.surface && surfacemapper.surface->hasContent()) { if (!surfacemapper.has_entered) { surfaceEnter(surfacemapper.surface); d->surfaceViews[i].has_entered = true; diff --git a/src/compositor/compositor_api/qwaylandpointer.cpp b/src/compositor/compositor_api/qwaylandpointer.cpp index 5e9778637..742987c8b 100644 --- a/src/compositor/compositor_api/qwaylandpointer.cpp +++ b/src/compositor/compositor_api/qwaylandpointer.cpp @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE QWaylandSurfaceRole QWaylandPointerPrivate::s_role("wl_pointer"); -QWaylandPointerPrivate::QWaylandPointerPrivate(QWaylandPointer *pointer, QWaylandInputDevice *seat) +QWaylandPointerPrivate::QWaylandPointerPrivate(QWaylandPointer *pointer, QWaylandSeat *seat) : QObjectPrivate() , wl_pointer() , seat(seat) @@ -97,24 +97,24 @@ void QWaylandPointerPrivate::pointer_set_cursor(wl_pointer::Resource *resource, * \preliminary * \brief The QWaylandPointer class represents a pointer device. * - * This class provides access to the pointer device in a QWaylandInputDevice. It corresponds to + * This class provides access to the pointer device in a QWaylandSeat. It corresponds to * the Wayland interface wl_pointer. */ /*! - * Constructs a QWaylandPointer for the given \a inputDevice and with the given \a parent. + * Constructs a QWaylandPointer for the given \a seat and with the given \a parent. */ -QWaylandPointer::QWaylandPointer(QWaylandInputDevice *inputDevice, QObject *parent) - : QWaylandObject(* new QWaylandPointerPrivate(this, inputDevice), parent) +QWaylandPointer::QWaylandPointer(QWaylandSeat *seat, QObject *parent) + : QWaylandObject(* new QWaylandPointerPrivate(this, seat), parent) { connect(&d_func()->focusDestroyListener, &QWaylandDestroyListener::fired, this, &QWaylandPointer::focusDestroyed); - connect(inputDevice, &QWaylandInputDevice::mouseFocusChanged, this, &QWaylandPointer::pointerFocusChanged); + connect(seat, &QWaylandSeat::mouseFocusChanged, this, &QWaylandPointer::pointerFocusChanged); } /*! * Returns the input device for this QWaylandPointer. */ -QWaylandInputDevice *QWaylandPointer::inputDevice() const +QWaylandSeat *QWaylandPointer::seat() const { Q_D(const QWaylandPointer); return d->seat; diff --git a/src/compositor/compositor_api/qwaylandpointer.h b/src/compositor/compositor_api/qwaylandpointer.h index 9d7d06807..0db1635bb 100644 --- a/src/compositor/compositor_api/qwaylandpointer.h +++ b/src/compositor/compositor_api/qwaylandpointer.h @@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE class QWaylandPointer; class QWaylandPointerPrivate; -class QWaylandInputDevice; +class QWaylandSeat; class QWaylandView; class QWaylandOutput; class QWaylandClient; @@ -56,9 +56,9 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandPointer : public QWaylandObject Q_DECLARE_PRIVATE(QWaylandPointer) Q_PROPERTY(bool isButtonPressed READ isButtonPressed NOTIFY buttonPressedChanged) public: - QWaylandPointer(QWaylandInputDevice *inputDevice, QObject *parent = nullptr); + QWaylandPointer(QWaylandSeat *seat, QObject *parent = nullptr); - QWaylandInputDevice *inputDevice() const; + QWaylandSeat *seat() const; QWaylandCompositor *compositor() const; QWaylandOutput *output() const; diff --git a/src/compositor/compositor_api/qwaylandpointer_p.h b/src/compositor/compositor_api/qwaylandpointer_p.h index 5ac030029..54ac72d11 100644 --- a/src/compositor/compositor_api/qwaylandpointer_p.h +++ b/src/compositor/compositor_api/qwaylandpointer_p.h @@ -61,7 +61,7 @@ #include <QtWaylandCompositor/private/qwayland-server-wayland.h> #include <QtWaylandCompositor/QWaylandView> #include <QtWaylandCompositor/QWaylandSurface> -#include <QtWaylandCompositor/QWaylandInputDevice> +#include <QtWaylandCompositor/QWaylandSeat> #include <stdint.h> @@ -74,7 +74,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandPointerPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QWaylandPointer) public: - QWaylandPointerPrivate(QWaylandPointer *pointer, QWaylandInputDevice *seat); + QWaylandPointerPrivate(QWaylandPointer *pointer, QWaylandSeat *seat); QWaylandCompositor *compositor() const { return seat->compositor(); } @@ -86,7 +86,7 @@ protected: private: void focusDestroyed(void *data); - QWaylandInputDevice *seat; + QWaylandSeat *seat; QWaylandOutput *output; QPointF localPosition; diff --git a/src/compositor/compositor_api/qwaylandquickcompositor.cpp b/src/compositor/compositor_api/qwaylandquickcompositor.cpp index 64e6fec70..07ea381b4 100644 --- a/src/compositor/compositor_api/qwaylandquickcompositor.cpp +++ b/src/compositor/compositor_api/qwaylandquickcompositor.cpp @@ -37,7 +37,7 @@ #include <QtQml/QQmlEngine> #include <QQuickWindow> -#include <QtGui/private/qopengltextureblitter_p.h> +#include <QOpenGLTextureBlitter> #include <QOpenGLFramebufferObject> #include <QMatrix4x4> #include <QRunnable> @@ -114,7 +114,7 @@ void QWaylandQuickCompositor::componentComplete() */ void QWaylandQuickCompositor::grabSurface(QWaylandSurfaceGrabber *grabber, const QWaylandBufferRef &buffer) { - if (buffer.isShm()) { + if (buffer.isSharedMemory()) { QWaylandCompositor::grabSurface(grabber, buffer); return; } diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp index a1855529c..08eefffa0 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.cpp +++ b/src/compositor/compositor_api/qwaylandquickitem.cpp @@ -39,14 +39,17 @@ #include "qwaylandquicksurface.h" #include "qwaylandinputmethodcontrol.h" #include "qwaylandtextinput.h" +#include "qwaylandquickoutput.h" #include <QtWaylandCompositor/qwaylandcompositor.h> -#include <QtWaylandCompositor/qwaylandinput.h> +#include <QtWaylandCompositor/qwaylandseat.h> #include <QtWaylandCompositor/qwaylandbufferref.h> +#include <QtWaylandCompositor/QWaylandDrag> #include <QtWaylandCompositor/private/qwlclientbufferintegration_p.h> #include <QtGui/QKeyEvent> #include <QtGui/QGuiApplication> #include <QtGui/QScreen> +#include <QtGui/QOpenGLFunctions> #include <QtQuick/QSGSimpleTextureNode> #include <QtQuick/QQuickWindow> @@ -293,7 +296,7 @@ public: delete m_sgTex; m_sgTex = 0; if (m_ref.hasBuffer()) { - if (buffer.isShm()) { + if (buffer.isSharedMemory()) { m_sgTex = surfaceItem->window()->createTextureFromImage(buffer.image()); if (m_sgTex) { m_sgTex->bind(); @@ -492,13 +495,13 @@ void QWaylandQuickItem::mousePressEvent(QMouseEvent *event) return; } - QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event); + QWaylandSeat *seat = compositor()->seatFor(event); if (d->focusOnClick) - takeFocus(inputDevice); + takeFocus(seat); - inputDevice->sendMouseMoveEvent(d->view.data(), event->localPos() / d->scaleFactor(), event->windowPos()); - inputDevice->sendMousePressEvent(event->button()); + seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->localPos()), event->windowPos()); + seat->sendMousePressEvent(event->button()); } /*! @@ -508,8 +511,20 @@ void QWaylandQuickItem::mouseMoveEvent(QMouseEvent *event) { Q_D(QWaylandQuickItem); if (d->shouldSendInputEvents()) { - QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event); - inputDevice->sendMouseMoveEvent(d->view.data(), event->localPos() / d->scaleFactor(), event->windowPos()); + QWaylandSeat *seat = compositor()->seatFor(event); + if (d->isDragging) { + QWaylandQuickOutput *currentOutput = qobject_cast<QWaylandQuickOutput *>(view()->output()); + //TODO: also check if dragging onto other outputs + QWaylandQuickItem *targetItem = qobject_cast<QWaylandQuickItem *>(currentOutput->pickClickableItem(mapToScene(event->localPos()))); + QWaylandSurface *targetSurface = targetItem ? targetItem->surface() : nullptr; + if (targetSurface) { + QPointF position = mapToItem(targetItem, event->localPos()); + QPointF surfacePosition = targetItem->mapToSurface(position); + seat->drag()->dragMove(targetSurface, surfacePosition); + } + } else { + seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->localPos()), event->windowPos()); + } } else { emit mouseMove(event->windowPos()); event->ignore(); @@ -523,8 +538,13 @@ void QWaylandQuickItem::mouseReleaseEvent(QMouseEvent *event) { Q_D(QWaylandQuickItem); if (d->shouldSendInputEvents()) { - QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event); - inputDevice->sendMouseReleaseEvent(event->button()); + QWaylandSeat *seat = compositor()->seatFor(event); + if (d->isDragging) { + d->isDragging = false; + seat->drag()->drop(); + } else { + seat->sendMouseReleaseEvent(event->button()); + } } else { emit mouseRelease(); event->ignore(); @@ -542,8 +562,8 @@ void QWaylandQuickItem::hoverEnterEvent(QHoverEvent *event) return; } if (d->shouldSendInputEvents()) { - QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event); - inputDevice->sendMouseMoveEvent(d->view.data(), event->pos(), mapToScene(event->pos())); + QWaylandSeat *seat = compositor()->seatFor(event); + seat->sendMouseMoveEvent(d->view.data(), event->pos(), mapToScene(event->pos())); } else { event->ignore(); } @@ -562,8 +582,8 @@ void QWaylandQuickItem::hoverMoveEvent(QHoverEvent *event) } } if (d->shouldSendInputEvents()) { - QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event); - inputDevice->sendMouseMoveEvent(d->view.data(), event->pos() / d->scaleFactor(), mapToScene(event->pos())); + QWaylandSeat *seat = compositor()->seatFor(event); + seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->pos()), mapToScene(event->pos())); } else { event->ignore(); } @@ -576,8 +596,8 @@ void QWaylandQuickItem::hoverLeaveEvent(QHoverEvent *event) { Q_D(QWaylandQuickItem); if (d->shouldSendInputEvents()) { - QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event); - inputDevice->setMouseFocus(Q_NULLPTR); + QWaylandSeat *seat = compositor()->seatFor(event); + seat->setMouseFocus(Q_NULLPTR); } else { event->ignore(); } @@ -595,8 +615,8 @@ void QWaylandQuickItem::wheelEvent(QWheelEvent *event) return; } - QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event); - inputDevice->sendMouseWheelEvent(event->orientation(), event->delta()); + QWaylandSeat *seat = compositor()->seatFor(event); + seat->sendMouseWheelEvent(event->orientation(), event->delta()); } else { event->ignore(); } @@ -609,8 +629,8 @@ void QWaylandQuickItem::keyPressEvent(QKeyEvent *event) { Q_D(QWaylandQuickItem); if (d->shouldSendInputEvents()) { - QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event); - inputDevice->sendFullKeyEvent(event); + QWaylandSeat *seat = compositor()->seatFor(event); + seat->sendFullKeyEvent(event); } else { event->ignore(); } @@ -623,8 +643,8 @@ void QWaylandQuickItem::keyReleaseEvent(QKeyEvent *event) { Q_D(QWaylandQuickItem); if (d->shouldSendInputEvents() && hasFocus()) { - QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event); - inputDevice->sendFullKeyEvent(event); + QWaylandSeat *seat = compositor()->seatFor(event); + seat->sendFullKeyEvent(event); } else { event->ignore(); } @@ -637,7 +657,7 @@ void QWaylandQuickItem::touchEvent(QTouchEvent *event) { Q_D(QWaylandQuickItem); if (d->shouldSendInputEvents() && d->touchEventsEnabled) { - QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event); + QWaylandSeat *seat = compositor()->seatFor(event); if (event->type() == QEvent::TouchBegin) { QQuickItem *grabber = window()->mouseGrabberItem(); @@ -656,10 +676,10 @@ void QWaylandQuickItem::touchEvent(QTouchEvent *event) } event->accept(); - if (inputDevice->mouseFocus() != d->view.data()) { - inputDevice->sendMouseMoveEvent(d->view.data(), pointPos, mapToScene(pointPos)); + if (seat->mouseFocus() != d->view.data()) { + seat->sendMouseMoveEvent(d->view.data(), pointPos, mapToScene(pointPos)); } - inputDevice->sendFullTouchEvent(event); + seat->sendFullTouchEvent(event); } else { event->ignore(); } @@ -757,31 +777,90 @@ void QWaylandQuickItem::setSubsurfaceHandler(QObject *handler) } /*! + * \property QWaylandQuickItem::output + * + * This property holds the output on which this item is displayed. + */ +QWaylandOutput *QWaylandQuickItem::output() const +{ + Q_D(const QWaylandQuickItem); + return d->view->output(); +} + +void QWaylandQuickItem::setOutput(QWaylandOutput *output) +{ + Q_D(QWaylandQuickItem); + d->view->setOutput(output); +} + +/*! + * \property QWaylandQuickItem::bufferLocked + * + * This property holds whether the item's buffer is currently locked. As long as + * the buffer is locked, it will not be released and returned to the client. + * + * The default is false. + */ +bool QWaylandQuickItem::isBufferLocked() const +{ + Q_D(const QWaylandQuickItem); + return d->view->isBufferLocked(); +} + +void QWaylandQuickItem::setBufferLocked(bool locked) +{ + Q_D(QWaylandQuickItem); + d->view->setBufferLocked(locked); +} + +/*! + * \property bool QWaylandQuickItem::allowDiscardFrontBuffer + * + * By default, the item locks the current buffer until a new buffer is available + * and updatePaintNode() is called. Set this property to true to allow Qt to release the buffer + * immediately when the throttling view is no longer using it. This is useful for items that have + * slow update intervals. + */ +bool QWaylandQuickItem::allowDiscardFrontBuffer() const +{ + Q_D(const QWaylandQuickItem); + return d->view->allowDiscardFrontBuffer(); +} + +void QWaylandQuickItem::setAllowDiscardFrontBuffer(bool discard) +{ + Q_D(QWaylandQuickItem); + d->view->setAllowDiscardFrontBuffer(discard); +} + +/*! * \internal */ void QWaylandQuickItem::handleSurfaceChanged() { Q_D(QWaylandQuickItem); if (d->oldSurface) { - disconnect(d->oldSurface, &QWaylandSurface::mappedChanged, this, &QWaylandQuickItem::surfaceMappedChanged); + disconnect(d->oldSurface, &QWaylandSurface::hasContentChanged, this, &QWaylandQuickItem::surfaceMappedChanged); disconnect(d->oldSurface, &QWaylandSurface::parentChanged, this, &QWaylandQuickItem::parentChanged); disconnect(d->oldSurface, &QWaylandSurface::sizeChanged, this, &QWaylandQuickItem::updateSize); disconnect(d->oldSurface, &QWaylandSurface::bufferScaleChanged, this, &QWaylandQuickItem::updateSize); disconnect(d->oldSurface, &QWaylandSurface::configure, this, &QWaylandQuickItem::updateBuffer); disconnect(d->oldSurface, &QWaylandSurface::redraw, this, &QQuickItem::update); disconnect(d->oldSurface, &QWaylandSurface::childAdded, this, &QWaylandQuickItem::handleSubsurfaceAdded); + disconnect(d->oldSurface, &QWaylandSurface::dragStarted, this, &QWaylandQuickItem::handleDragStarted); #ifndef QT_NO_IM disconnect(d->oldSurface->inputMethodControl(), &QWaylandInputMethodControl::updateInputMethod, this, &QWaylandQuickItem::updateInputMethod); #endif } if (QWaylandSurface *newSurface = d->view->surface()) { - connect(newSurface, &QWaylandSurface::mappedChanged, this, &QWaylandQuickItem::surfaceMappedChanged); + connect(newSurface, &QWaylandSurface::hasContentChanged, this, &QWaylandQuickItem::surfaceMappedChanged); connect(newSurface, &QWaylandSurface::parentChanged, this, &QWaylandQuickItem::parentChanged); connect(newSurface, &QWaylandSurface::sizeChanged, this, &QWaylandQuickItem::updateSize); connect(newSurface, &QWaylandSurface::bufferScaleChanged, this, &QWaylandQuickItem::updateSize); connect(newSurface, &QWaylandSurface::configure, this, &QWaylandQuickItem::updateBuffer); connect(newSurface, &QWaylandSurface::redraw, this, &QQuickItem::update); connect(newSurface, &QWaylandSurface::childAdded, this, &QWaylandQuickItem::handleSubsurfaceAdded); + connect(newSurface, &QWaylandSurface::dragStarted, this, &QWaylandQuickItem::handleDragStarted); #ifndef QT_NO_IM connect(newSurface->inputMethodControl(), &QWaylandInputMethodControl::updateInputMethod, this, &QWaylandQuickItem::updateInputMethod); #endif @@ -808,16 +887,16 @@ void QWaylandQuickItem::handleSurfaceChanged() * Calling this function causes the item to take the focus of the * input \a device. */ -void QWaylandQuickItem::takeFocus(QWaylandInputDevice *device) +void QWaylandQuickItem::takeFocus(QWaylandSeat *device) { forceActiveFocus(); if (!surface()) return; - QWaylandInputDevice *target = device; + QWaylandSeat *target = device; if (!target) { - target = compositor()->defaultInputDevice(); + target = compositor()->defaultSeat(); } target->setKeyboardFocus(surface()); QWaylandTextInput *textInput = QWaylandTextInput::findIn(target); @@ -898,13 +977,23 @@ void QWaylandQuickItem::setFocusOnClick(bool focus) */ bool QWaylandQuickItem::inputRegionContains(const QPointF &localPosition) { - Q_D(QWaylandQuickItem); if (QWaylandSurface *s = surface()) - return s->inputRegionContains(localPosition.toPoint() / d->scaleFactor()); + return s->inputRegionContains(mapToSurface(localPosition).toPoint()); return false; } /*! + * Maps the given \a point in this item's coordinate system to the equivalent + * point within the Wayland surface's coordinate system, and returns the mapped + * coordinate. + */ +QPointF QWaylandQuickItem::mapToSurface(const QPointF &point) const +{ + Q_D(const QWaylandQuickItem); + return point / d->scaleFactor(); +} + +/*! * \qmlproperty bool QtWaylandCompositor::WaylandQuickItem::sizeFollowsSurface * * This property specifies whether the size of the item should always match @@ -1043,9 +1132,9 @@ void QWaylandQuickItem::updateInputMethod(Qt::InputMethodQueries queries) QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) { Q_D(QWaylandQuickItem); - const bool mapped = surface() && surface()->isMapped() && d->view->currentBuffer().hasBuffer(); + const bool hasContent = surface() && surface()->hasContent() && d->view->currentBuffer().hasBuffer(); - if (!mapped || !d->paintEnabled) { + if (!hasContent || !d->paintEnabled) { delete oldNode; return 0; } @@ -1055,7 +1144,7 @@ QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat const QRectF rect = invertY ? QRectF(0, height(), width(), -height()) : QRectF(0, 0, width(), height()); - if (ref.isShm() || bufferTypes[ref.bufferFormatEgl()].canProvideTexture) { + if (ref.isSharedMemory() || bufferTypes[ref.bufferFormatEgl()].canProvideTexture) { QSGSimpleTextureNode *node = static_cast<QSGSimpleTextureNode *>(oldNode); if (!node) { @@ -1138,6 +1227,8 @@ void QWaylandQuickItem::setInputEventsEnabled(bool enabled) { Q_D(QWaylandQuickItem); if (d->inputEventsEnabled != enabled) { + if (enabled) + setEnabled(true); d->setInputEventsEnabled(enabled); emit inputEventsEnabledChanged(); } @@ -1172,5 +1263,13 @@ void QWaylandQuickItem::handleSubsurfacePosition(const QPoint &pos) QQuickItem::setPosition(pos * d->scaleFactor()); } +void QWaylandQuickItem::handleDragStarted(QWaylandDrag *drag) +{ + Q_D(QWaylandQuickItem); + Q_ASSERT(drag->origin() == surface()); + drag->seat()->setMouseFocus(nullptr); + d->isDragging = true; +} + QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandquickitem.h b/src/compositor/compositor_api/qwaylandquickitem.h index 07b6a40a4..5c89d58b4 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.h +++ b/src/compositor/compositor_api/qwaylandquickitem.h @@ -51,14 +51,13 @@ Q_DECLARE_METATYPE(QWaylandQuickSurface*) QT_BEGIN_NAMESPACE -class QWaylandInputDevice; +class QWaylandSeat; class QWaylandQuickItemPrivate; class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickItem : public QQuickItem { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandQuickItem) - Q_PROPERTY(QWaylandView *view READ view CONSTANT) Q_PROPERTY(QWaylandCompositor *compositor READ compositor) Q_PROPERTY(QWaylandSurface *surface READ surface WRITE setSurface NOTIFY surfaceChanged) Q_PROPERTY(bool paintEnabled READ paintEnabled WRITE setPaintEnabled) @@ -68,6 +67,9 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickItem : public QQuickItem Q_PROPERTY(bool focusOnClick READ focusOnClick WRITE setFocusOnClick NOTIFY focusOnClickChanged) Q_PROPERTY(bool sizeFollowsSurface READ sizeFollowsSurface WRITE setSizeFollowsSurface NOTIFY sizeFollowsSurfaceChanged) Q_PROPERTY(QObject *subsurfaceHandler READ subsurfaceHandler WRITE setSubsurfaceHandler NOTIFY subsurfaceHandlerChanged) + Q_PROPERTY(QWaylandOutput *output READ output WRITE setOutput NOTIFY outputChanged) + Q_PROPERTY(bool bufferLocked READ isBufferLocked WRITE setBufferLocked NOTIFY bufferLockedChanged) + Q_PROPERTY(bool allowDiscardFrontBuffer READ allowDiscardFrontBuffer WRITE setAllowDiscardFrontBuffer NOTIFY allowDiscardFrontBufferChanged) public: QWaylandQuickItem(QQuickItem *parent = nullptr); ~QWaylandQuickItem(); @@ -95,6 +97,7 @@ public: void setFocusOnClick(bool focus); bool inputRegionContains(const QPointF &localPosition); + Q_INVOKABLE QPointF mapToSurface(const QPointF &point) const; bool sizeFollowsSurface() const; void setSizeFollowsSurface(bool sizeFollowsSurface); @@ -107,6 +110,15 @@ public: QObject *subsurfaceHandler() const; void setSubsurfaceHandler(QObject*); + QWaylandOutput *output() const; + void setOutput(QWaylandOutput *output); + + bool isBufferLocked() const; + void setBufferLocked(bool locked); + + bool allowDiscardFrontBuffer() const; + void setAllowDiscardFrontBuffer(bool discard); + protected: void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; @@ -128,7 +140,7 @@ protected: virtual void surfaceChangedEvent(QWaylandSurface *newSurface, QWaylandSurface *oldSurface); public Q_SLOTS: - virtual void takeFocus(QWaylandInputDevice *device = nullptr); + virtual void takeFocus(QWaylandSeat *device = nullptr); void setPaintEnabled(bool paintEnabled); void raise(); void lower(); @@ -143,6 +155,7 @@ private Q_SLOTS: void beforeSync(); void handleSubsurfaceAdded(QWaylandSurface *childSurface); void handleSubsurfacePosition(const QPoint &pos); + void handleDragStarted(QWaylandDrag *drag); #ifndef QT_NO_IM void updateInputMethod(Qt::InputMethodQueries queries); #endif @@ -158,6 +171,9 @@ Q_SIGNALS: void mouseRelease(); void sizeFollowsSurfaceChanged(); void subsurfaceHandlerChanged(); + void outputChanged(); + void bufferLockedChanged(); + void allowDiscardFrontBufferChanged(); protected: QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) Q_DECL_OVERRIDE; diff --git a/src/compositor/compositor_api/qwaylandquickitem_p.h b/src/compositor/compositor_api/qwaylandquickitem_p.h index b529ba959..8c242ac88 100644 --- a/src/compositor/compositor_api/qwaylandquickitem_p.h +++ b/src/compositor/compositor_api/qwaylandquickitem_p.h @@ -112,6 +112,7 @@ public: , paintEnabled(true) , touchEventsEnabled(false) , inputEventsEnabled(true) + , isDragging(false) , newTexture(false) , focusOnClick(true) , sizeFollowsSurface(true) @@ -138,9 +139,11 @@ public: QObject::connect(view.data(), &QWaylandView::surfaceChanged, q, &QWaylandQuickItem::surfaceChanged); QObject::connect(view.data(), &QWaylandView::surfaceChanged, q, &QWaylandQuickItem::handleSurfaceChanged); QObject::connect(view.data(), &QWaylandView::surfaceDestroyed, q, &QWaylandQuickItem::surfaceDestroyed); + QObject::connect(view.data(), &QWaylandView::outputChanged, q, &QWaylandQuickItem::outputChanged); + QObject::connect(view.data(), &QWaylandView::bufferLockedChanged, q, &QWaylandQuickItem::bufferLockedChanged); + QObject::connect(view.data(), &QWaylandView::allowDiscardFrontBufferChanged, q, &QWaylandQuickItem::allowDiscardFrontBuffer); } - void setInputEventsEnabled(bool enable) { Q_Q(QWaylandQuickItem); @@ -164,6 +167,7 @@ public: bool paintEnabled; bool touchEventsEnabled; bool inputEventsEnabled; + bool isDragging; bool newTexture; bool focusOnClick; bool sizeFollowsSurface; diff --git a/src/compositor/compositor_api/qwaylandquickoutput.cpp b/src/compositor/compositor_api/qwaylandquickoutput.cpp index 8abf6cbb1..0e25362fc 100644 --- a/src/compositor/compositor_api/qwaylandquickoutput.cpp +++ b/src/compositor/compositor_api/qwaylandquickoutput.cpp @@ -37,6 +37,7 @@ #include "qwaylandquickoutput.h" #include "qwaylandquickcompositor.h" +#include "qwaylandquickitem_p.h" QT_BEGIN_NAMESPACE @@ -102,6 +103,44 @@ void QWaylandQuickOutput::setAutomaticFrameCallback(bool automatic) automaticFrameCallbackChanged(); } +static QQuickItem* clickableItemAtPosition(QQuickItem *rootItem, const QPointF &position) +{ + if (!rootItem->isEnabled() || !rootItem->isVisible()) + return nullptr; + + QList<QQuickItem *> paintOrderItems = QQuickItemPrivate::get(rootItem)->paintOrderChildItems(); + auto negativeZStart = paintOrderItems.crend(); + for (auto it = paintOrderItems.crbegin(); it != paintOrderItems.crend(); ++it) { + if ((*it)->z() < 0) { + negativeZStart = it; + break; + } + QQuickItem *item = clickableItemAtPosition(*it, rootItem->mapToItem(*it, position)); + if (item) + return item; + } + + if (rootItem->contains(position) && rootItem->acceptedMouseButtons() != Qt::NoButton) + return rootItem; + + for (auto it = negativeZStart; it != paintOrderItems.crend(); ++it) { + QQuickItem *item = clickableItemAtPosition(*it, rootItem->mapToItem(*it, position)); + if (item) + return item; + } + + return nullptr; +} + +QQuickItem *QWaylandQuickOutput::pickClickableItem(const QPointF &position) +{ + QQuickWindow *quickWindow = qobject_cast<QQuickWindow *>(window()); + if (!quickWindow) + return nullptr; + + return clickableItemAtPosition(quickWindow->contentItem(), position); +} + /*! * \internal */ diff --git a/src/compositor/compositor_api/qwaylandquickoutput.h b/src/compositor/compositor_api/qwaylandquickoutput.h index 83091e4c7..2cef03282 100644 --- a/src/compositor/compositor_api/qwaylandquickoutput.h +++ b/src/compositor/compositor_api/qwaylandquickoutput.h @@ -59,6 +59,8 @@ public: bool automaticFrameCallback() const; void setAutomaticFrameCallback(bool automatic); + QQuickItem *pickClickableItem(const QPointF &position); + public Q_SLOTS: void updateStarted(); diff --git a/src/compositor/compositor_api/qwaylandinput.cpp b/src/compositor/compositor_api/qwaylandseat.cpp index 6f0f8c758..f84325185 100644 --- a/src/compositor/compositor_api/qwaylandinput.cpp +++ b/src/compositor/compositor_api/qwaylandseat.cpp @@ -34,8 +34,8 @@ ** ****************************************************************************/ -#include "qwaylandinput.h" -#include "qwaylandinput_p.h" +#include "qwaylandseat.h" +#include "qwaylandseat_p.h" #include "qwaylandcompositor.h" #include "qwaylandinputmethodcontrol.h" @@ -44,7 +44,7 @@ #include <QtWaylandCompositor/QWaylandTouch> #include <QtWaylandCompositor/QWaylandPointer> #include <QtWaylandCompositor/QWaylandWlShellSurface> -#include <QtWaylandCompositor/private/qwaylandinput_p.h> +#include <QtWaylandCompositor/private/qwaylandseat_p.h> #include <QtWaylandCompositor/private/qwaylandcompositor_p.h> #include <QtWaylandCompositor/private/qwldatadevice_p.h> @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE -QWaylandInputDevicePrivate::QWaylandInputDevicePrivate(QWaylandInputDevice *inputdevice, QWaylandCompositor *compositor) +QWaylandSeatPrivate::QWaylandSeatPrivate(QWaylandSeat *seat, QWaylandCompositor *compositor) : QObjectPrivate() , QtWaylandServer::wl_seat(compositor->display(), 4) , compositor(compositor) @@ -61,29 +61,29 @@ QWaylandInputDevicePrivate::QWaylandInputDevicePrivate(QWaylandInputDevice *inpu , keyboardFocus(nullptr) , capabilities() , data_device() - , drag_handle(new QWaylandDrag(inputdevice)) + , drag_handle(new QWaylandDrag(seat)) { } -QWaylandInputDevicePrivate::~QWaylandInputDevicePrivate() +QWaylandSeatPrivate::~QWaylandSeatPrivate() { } -void QWaylandInputDevicePrivate::setCapabilities(QWaylandInputDevice::CapabilityFlags caps) +void QWaylandSeatPrivate::setCapabilities(QWaylandSeat::CapabilityFlags caps) { - Q_Q(QWaylandInputDevice); + Q_Q(QWaylandSeat); if (capabilities != caps) { - QWaylandInputDevice::CapabilityFlags changed = caps ^ capabilities; + QWaylandSeat::CapabilityFlags changed = caps ^ capabilities; - if (changed & QWaylandInputDevice::Pointer) { + if (changed & QWaylandSeat::Pointer) { pointer.reset(pointer.isNull() ? QWaylandCompositorPrivate::get(compositor)->callCreatePointerDevice(q) : 0); } - if (changed & QWaylandInputDevice::Keyboard) { + if (changed & QWaylandSeat::Keyboard) { keyboard.reset(keyboard.isNull() ? QWaylandCompositorPrivate::get(compositor)->callCreateKeyboardDevice(q) : 0); } - if (changed & QWaylandInputDevice::Touch) { + if (changed & QWaylandSeat::Touch) { touch.reset(touch.isNull() ? QWaylandCompositorPrivate::get(compositor)->callCreateTouchDevice(q) : 0); } @@ -93,45 +93,45 @@ void QWaylandInputDevicePrivate::setCapabilities(QWaylandInputDevice::Capability wl_seat::send_capabilities(resources.at(i)->handle, (uint32_t)capabilities); } - if ((changed & caps & QWaylandInputDevice::Keyboard) && keyboardFocus != nullptr) + if ((changed & caps & QWaylandSeat::Keyboard) && keyboardFocus != nullptr) keyboard->setFocus(keyboardFocus); } } -void QWaylandInputDevicePrivate::clientRequestedDataDevice(QtWayland::DataDeviceManager *, struct wl_client *client, uint32_t id) +void QWaylandSeatPrivate::clientRequestedDataDevice(QtWayland::DataDeviceManager *, struct wl_client *client, uint32_t id) { - Q_Q(QWaylandInputDevice); + Q_Q(QWaylandSeat); if (!data_device) data_device.reset(new QtWayland::DataDevice(q)); data_device->add(client, id, 1); } -void QWaylandInputDevicePrivate::seat_destroy_resource(wl_seat::Resource *) +void QWaylandSeatPrivate::seat_destroy_resource(wl_seat::Resource *) { // cleanupDataDeviceForClient(resource->client(), true); } -void QWaylandInputDevicePrivate::seat_bind_resource(wl_seat::Resource *resource) +void QWaylandSeatPrivate::seat_bind_resource(wl_seat::Resource *resource) { // The order of capabilities matches the order defined in the wayland protocol wl_seat::send_capabilities(resource->handle, (uint32_t)capabilities); } -void QWaylandInputDevicePrivate::seat_get_pointer(wl_seat::Resource *resource, uint32_t id) +void QWaylandSeatPrivate::seat_get_pointer(wl_seat::Resource *resource, uint32_t id) { if (!pointer.isNull()) { pointer->addClient(QWaylandClient::fromWlClient(compositor, resource->client()), id, resource->version()); } } -void QWaylandInputDevicePrivate::seat_get_keyboard(wl_seat::Resource *resource, uint32_t id) +void QWaylandSeatPrivate::seat_get_keyboard(wl_seat::Resource *resource, uint32_t id) { if (!keyboard.isNull()) { keyboard->addClient(QWaylandClient::fromWlClient(compositor, resource->client()), id, resource->version()); } } -void QWaylandInputDevicePrivate::seat_get_touch(wl_seat::Resource *resource, uint32_t id) +void QWaylandSeatPrivate::seat_get_touch(wl_seat::Resource *resource, uint32_t id) { if (!touch.isNull()) { touch->addClient(QWaylandClient::fromWlClient(compositor, resource->client()), id, resource->version()); @@ -149,56 +149,56 @@ QWaylandKeymap::QWaylandKeymap(const QString &layout, const QString &variant, co /*! - * \class QWaylandInputDevice + * \class QWaylandSeat * \inmodule QtWaylandCompositor * \preliminary - * \brief The QWaylandInputDevice class provides access to keyboard, mouse, and touch input. + * \brief The QWaylandSeat class provides access to keyboard, mouse, and touch input. * - * The QWaylandInputDevice provides access to different types of user input and maintains + * The QWaylandSeat provides access to different types of user input and maintains * a keyboard focus and a mouse pointer. It corresponds to the wl_seat interface in the Wayland protocol. */ /*! - * \enum QWaylandInputDevice::CapabilityFlag + * \enum QWaylandSeat::CapabilityFlag * - * This enum type describes the capabilities of a QWaylandInputDevice. + * This enum type describes the capabilities of a QWaylandSeat. * - * \value Pointer The QWaylandInputDevice supports pointer input. - * \value Keyboard The QWaylandInputDevice supports keyboard input. - * \value Touch The QWaylandInputDevice supports touch input. + * \value Pointer The QWaylandSeat supports pointer input. + * \value Keyboard The QWaylandSeat supports keyboard input. + * \value Touch The QWaylandSeat supports touch input. */ /*! - * Constructs a QWaylandInputDevice for the given \a compositor and with the given \a capabilityFlags. + * Constructs a QWaylandSeat for the given \a compositor and with the given \a capabilityFlags. */ -QWaylandInputDevice::QWaylandInputDevice(QWaylandCompositor *compositor, CapabilityFlags capabilityFlags) - : QWaylandObject(*new QWaylandInputDevicePrivate(this,compositor)) +QWaylandSeat::QWaylandSeat(QWaylandCompositor *compositor, CapabilityFlags capabilityFlags) + : QWaylandObject(*new QWaylandSeatPrivate(this,compositor)) { d_func()->setCapabilities(capabilityFlags); } /*! - * Destroys the QWaylandInputDevice + * Destroys the QWaylandSeat */ -QWaylandInputDevice::~QWaylandInputDevice() +QWaylandSeat::~QWaylandSeat() { } /*! - * Sends a mouse press event for \a button to the QWaylandInputDevice's pointer device. + * Sends a mouse press event for \a button to the QWaylandSeat's pointer device. */ -void QWaylandInputDevice::sendMousePressEvent(Qt::MouseButton button) +void QWaylandSeat::sendMousePressEvent(Qt::MouseButton button) { - Q_D(QWaylandInputDevice); + Q_D(QWaylandSeat); d->pointer->sendMousePressEvent(button); } /*! - * Sends a mouse release event for \a button to the QWaylandInputDevice's pointer device. + * Sends a mouse release event for \a button to the QWaylandSeat's pointer device. */ -void QWaylandInputDevice::sendMouseReleaseEvent(Qt::MouseButton button) +void QWaylandSeat::sendMouseReleaseEvent(Qt::MouseButton button) { - Q_D(QWaylandInputDevice); + Q_D(QWaylandSeat); d->pointer->sendMouseReleaseEvent(button); } @@ -206,36 +206,36 @@ void QWaylandInputDevice::sendMouseReleaseEvent(Qt::MouseButton button) * Sets the mouse focus to \a view and sends a mouse move event to the pointer device with the * local position \a localPos and output space position \a outputSpacePos. **/ -void QWaylandInputDevice::sendMouseMoveEvent(QWaylandView *view, const QPointF &localPos, const QPointF &outputSpacePos) +void QWaylandSeat::sendMouseMoveEvent(QWaylandView *view, const QPointF &localPos, const QPointF &outputSpacePos) { - Q_D(QWaylandInputDevice); + Q_D(QWaylandSeat); d->pointer->sendMouseMoveEvent(view, localPos, outputSpacePos); } /*! - * Sends a mouse wheel event to the QWaylandInputDevice's pointer device with the given \a orientation and \a delta. + * Sends a mouse wheel event to the QWaylandSeat's pointer device with the given \a orientation and \a delta. */ -void QWaylandInputDevice::sendMouseWheelEvent(Qt::Orientation orientation, int delta) +void QWaylandSeat::sendMouseWheelEvent(Qt::Orientation orientation, int delta) { - Q_D(QWaylandInputDevice); + Q_D(QWaylandSeat); d->pointer->sendMouseWheelEvent(orientation, delta); } /*! * Sends a key press event with the key \a code to the keyboard device. */ -void QWaylandInputDevice::sendKeyPressEvent(uint code) +void QWaylandSeat::sendKeyPressEvent(uint code) { - Q_D(QWaylandInputDevice); + Q_D(QWaylandSeat); d->keyboard->sendKeyPressEvent(code); } /*! * Sends a key release event with the key \a code to the keyboard device. */ -void QWaylandInputDevice::sendKeyReleaseEvent(uint code) +void QWaylandSeat::sendKeyReleaseEvent(uint code) { - Q_D(QWaylandInputDevice); + Q_D(QWaylandSeat); d->keyboard->sendKeyReleaseEvent(code); } @@ -243,9 +243,9 @@ void QWaylandInputDevice::sendKeyReleaseEvent(uint code) * Sends a touch point event with the given \a id and \a state to the touch device. The position * of the touch point is given by \a point. */ -void QWaylandInputDevice::sendTouchPointEvent(int id, const QPointF &point, Qt::TouchPointState state) +void QWaylandSeat::sendTouchPointEvent(int id, const QPointF &point, Qt::TouchPointState state) { - Q_D(QWaylandInputDevice); + Q_D(QWaylandSeat); if (d->touch.isNull()) { return; } @@ -255,9 +255,9 @@ void QWaylandInputDevice::sendTouchPointEvent(int id, const QPointF &point, Qt:: /*! * Sends a frame event to the touch device. */ -void QWaylandInputDevice::sendTouchFrameEvent() +void QWaylandSeat::sendTouchFrameEvent() { - Q_D(QWaylandInputDevice); + Q_D(QWaylandSeat); if (!d->touch.isNull()) { d->touch->sendFrameEvent(); } @@ -266,9 +266,9 @@ void QWaylandInputDevice::sendTouchFrameEvent() /*! * Sends a cancel event to the touch device. */ -void QWaylandInputDevice::sendTouchCancelEvent() +void QWaylandSeat::sendTouchCancelEvent() { - Q_D(QWaylandInputDevice); + Q_D(QWaylandSeat); if (!d->touch.isNull()) { d->touch->sendCancelEvent(); } @@ -277,9 +277,9 @@ void QWaylandInputDevice::sendTouchCancelEvent() /*! * Sends the \a event to the touch device. */ -void QWaylandInputDevice::sendFullTouchEvent(QTouchEvent *event) +void QWaylandSeat::sendFullTouchEvent(QTouchEvent *event) { - Q_D(QWaylandInputDevice); + Q_D(QWaylandSeat); if (!mouseFocus()) { qWarning("Cannot send touch event, no pointer focus, fix the compositor"); return; @@ -294,9 +294,9 @@ void QWaylandInputDevice::sendFullTouchEvent(QTouchEvent *event) /*! * Sends the \a event to the keyboard device. */ -void QWaylandInputDevice::sendFullKeyEvent(QKeyEvent *event) +void QWaylandSeat::sendFullKeyEvent(QKeyEvent *event) { - Q_D(QWaylandInputDevice); + Q_D(QWaylandSeat); if (!keyboardFocus()) { qWarning("Cannot send key event, no keyboard focus, fix the compositor"); @@ -327,18 +327,18 @@ void QWaylandInputDevice::sendFullKeyEvent(QKeyEvent *event) /*! * Returns the keyboard for this input device. */ -QWaylandKeyboard *QWaylandInputDevice::keyboard() const +QWaylandKeyboard *QWaylandSeat::keyboard() const { - Q_D(const QWaylandInputDevice); + Q_D(const QWaylandSeat); return d->keyboard.data(); } /*! * Returns the current focused surface for keyboard input. */ -QWaylandSurface *QWaylandInputDevice::keyboardFocus() const +QWaylandSurface *QWaylandSeat::keyboardFocus() const { - Q_D(const QWaylandInputDevice); + Q_D(const QWaylandSeat); if (d->keyboard.isNull() || !d->keyboard->focus()) return Q_NULLPTR; @@ -348,9 +348,9 @@ QWaylandSurface *QWaylandInputDevice::keyboardFocus() const /*! * Sets the current keyboard focus to \a surface. */ -bool QWaylandInputDevice::setKeyboardFocus(QWaylandSurface *surface) +bool QWaylandSeat::setKeyboardFocus(QWaylandSurface *surface) { - Q_D(QWaylandInputDevice); + Q_D(QWaylandSeat); if (surface && surface->isDestroyed()) return false; @@ -372,47 +372,47 @@ bool QWaylandInputDevice::setKeyboardFocus(QWaylandSurface *surface) } /*! - * Sets the key map of this QWaylandInputDevice to \a keymap. + * Sets the key map of this QWaylandSeat to \a keymap. */ -void QWaylandInputDevice::setKeymap(const QWaylandKeymap &keymap) +void QWaylandSeat::setKeymap(const QWaylandKeymap &keymap) { if (keyboard()) keyboard()->setKeymap(keymap); } /*! - * Returns the pointer device for this QWaylandInputDevice. + * Returns the pointer device for this QWaylandSeat. */ -QWaylandPointer *QWaylandInputDevice::pointer() const +QWaylandPointer *QWaylandSeat::pointer() const { - Q_D(const QWaylandInputDevice); + Q_D(const QWaylandSeat); return d->pointer.data(); } /*! - * Returns the touch device for this QWaylandInputDevice. + * Returns the touch device for this QWaylandSeat. */ -QWaylandTouch *QWaylandInputDevice::touch() const +QWaylandTouch *QWaylandSeat::touch() const { - Q_D(const QWaylandInputDevice); + Q_D(const QWaylandSeat); return d->touch.data(); } /*! * Returns the view that currently has mouse focus. */ -QWaylandView *QWaylandInputDevice::mouseFocus() const +QWaylandView *QWaylandSeat::mouseFocus() const { - Q_D(const QWaylandInputDevice); + Q_D(const QWaylandSeat); return d->mouseFocus; } /*! * Sets the current mouse focus to \a view. */ -void QWaylandInputDevice::setMouseFocus(QWaylandView *view) +void QWaylandSeat::setMouseFocus(QWaylandView *view) { - Q_D(QWaylandInputDevice); + Q_D(QWaylandSeat); if (view == d->mouseFocus) return; @@ -422,52 +422,52 @@ void QWaylandInputDevice::setMouseFocus(QWaylandView *view) } /*! - * Returns the compositor for this QWaylandInputDevice. + * Returns the compositor for this QWaylandSeat. */ -QWaylandCompositor *QWaylandInputDevice::compositor() const +QWaylandCompositor *QWaylandSeat::compositor() const { - Q_D(const QWaylandInputDevice); + Q_D(const QWaylandSeat); return d->compositor; } /*! - * Returns the drag object for this QWaylandInputDevice. + * Returns the drag object for this QWaylandSeat. */ -QWaylandDrag *QWaylandInputDevice::drag() const +QWaylandDrag *QWaylandSeat::drag() const { - Q_D(const QWaylandInputDevice); + Q_D(const QWaylandSeat); return d->drag_handle.data(); } /*! - * Returns the capability flags for this QWaylandInputDevice. + * Returns the capability flags for this QWaylandSeat. */ -QWaylandInputDevice::CapabilityFlags QWaylandInputDevice::capabilities() const +QWaylandSeat::CapabilityFlags QWaylandSeat::capabilities() const { - Q_D(const QWaylandInputDevice); + Q_D(const QWaylandSeat); return d->capabilities; } /*! * \internal */ -bool QWaylandInputDevice::isOwner(QInputEvent *inputEvent) const +bool QWaylandSeat::isOwner(QInputEvent *inputEvent) const { Q_UNUSED(inputEvent); return true; } /*! - * Returns the QWaylandInputDevice corresponding to the \a resource. The \a resource is expected + * Returns the QWaylandSeat corresponding to the \a resource. The \a resource is expected * to have the type wl_seat. */ -QWaylandInputDevice *QWaylandInputDevice::fromSeatResource(struct ::wl_resource *resource) +QWaylandSeat *QWaylandSeat::fromSeatResource(struct ::wl_resource *resource) { - return static_cast<QWaylandInputDevicePrivate *>(QWaylandInputDevicePrivate::Resource::fromResource(resource)->seat_object)->q_func(); + return static_cast<QWaylandSeatPrivate *>(QWaylandSeatPrivate::Resource::fromResource(resource)->seat_object)->q_func(); } /*! - * \fn void QWaylandInputDevice::mouseFocusChanged(QWaylandView *newFocus, QWaylandView *oldFocus) + * \fn void QWaylandSeat::mouseFocusChanged(QWaylandView *newFocus, QWaylandView *oldFocus) * * This signal is emitted when the mouse focus has changed from \a oldFocus to \a newFocus. */ diff --git a/src/compositor/compositor_api/qwaylandinput.h b/src/compositor/compositor_api/qwaylandseat.h index d1cb922b7..bfd6e4041 100644 --- a/src/compositor/compositor_api/qwaylandinput.h +++ b/src/compositor/compositor_api/qwaylandseat.h @@ -34,8 +34,8 @@ ** ****************************************************************************/ -#ifndef QWAYLANDINPUT_H -#define QWAYLANDINPUT_H +#ifndef QWAYLANDSEAT_H +#define QWAYLANDSEAT_H #include <QtCore/qnamespace.h> #include <QtCore/QPoint> @@ -53,20 +53,18 @@ class QKeyEvent; class QTouchEvent; class QWaylandView; class QInputEvent; -class QWaylandInputDevicePrivate; +class QWaylandSeatPrivate; class QWaylandDrag; class QWaylandKeyboard; class QWaylandPointer; class QWaylandTouch; -namespace QtWayland { -class InputDevice; -} - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandInputDevice : public QWaylandObject +class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandSeat : public QWaylandObject { Q_OBJECT - Q_DECLARE_PRIVATE(QWaylandInputDevice) + Q_DECLARE_PRIVATE(QWaylandSeat) + + Q_PROPERTY(QWaylandDrag *drag READ drag CONSTANT) public: enum CapabilityFlag { // The order should match the enum WL_SEAT_CAPABILITY_* @@ -79,8 +77,8 @@ public: Q_DECLARE_FLAGS(CapabilityFlags, CapabilityFlag) Q_ENUM(CapabilityFlags) - QWaylandInputDevice(QWaylandCompositor *compositor, CapabilityFlags capabilityFlags = DefaultCapabilities); - virtual ~QWaylandInputDevice(); + QWaylandSeat(QWaylandCompositor *compositor, CapabilityFlags capabilityFlags = DefaultCapabilities); + virtual ~QWaylandSeat(); void sendMousePressEvent(Qt::MouseButton button); void sendMouseReleaseEvent(Qt::MouseButton button); @@ -116,11 +114,11 @@ public: QWaylandDrag *drag() const; - QWaylandInputDevice::CapabilityFlags capabilities() const; + QWaylandSeat::CapabilityFlags capabilities() const; virtual bool isOwner(QInputEvent *inputEvent) const; - static QWaylandInputDevice *fromSeatResource(struct ::wl_resource *resource); + static QWaylandSeat *fromSeatResource(struct ::wl_resource *resource); Q_SIGNALS: void mouseFocusChanged(QWaylandView *newFocus, QWaylandView *oldFocus); @@ -128,8 +126,8 @@ Q_SIGNALS: void cursorSurfaceRequest(QWaylandSurface *surface, int hotspotX, int hotspotY); }; -Q_DECLARE_OPERATORS_FOR_FLAGS(QWaylandInputDevice::CapabilityFlags) +Q_DECLARE_OPERATORS_FOR_FLAGS(QWaylandSeat::CapabilityFlags) QT_END_NAMESPACE -#endif // QWAYLANDINPUT_H +#endif // QWAYLANDSEAT_H diff --git a/src/compositor/compositor_api/qwaylandinput_p.h b/src/compositor/compositor_api/qwaylandseat_p.h index 5e57c43cc..6588600cf 100644 --- a/src/compositor/compositor_api/qwaylandinput_p.h +++ b/src/compositor/compositor_api/qwaylandseat_p.h @@ -34,8 +34,8 @@ ** ****************************************************************************/ -#ifndef QWAYLANDINPUT_P_H -#define QWAYLANDINPUT_P_H +#ifndef QWAYLANDSEAT_P_H +#define QWAYLANDSEAT_P_H // // W A R N I N G @@ -51,7 +51,7 @@ #include <stdint.h> #include <QtWaylandCompositor/qwaylandexport.h> -#include <QtWaylandCompositor/qwaylandinput.h> +#include <QtWaylandCompositor/qwaylandseat.h> #include <QtCore/QList> #include <QtCore/QPoint> @@ -68,7 +68,7 @@ QT_BEGIN_NAMESPACE class QKeyEvent; class QTouchEvent; -class QWaylandInputDevice; +class QWaylandSeat; class QWaylandDrag; class QWaylandView; @@ -85,18 +85,18 @@ class InputMethod; } -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandInputDevicePrivate : public QObjectPrivate, public QtWaylandServer::wl_seat +class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandSeatPrivate : public QObjectPrivate, public QtWaylandServer::wl_seat { public: - Q_DECLARE_PUBLIC(QWaylandInputDevice) + Q_DECLARE_PUBLIC(QWaylandSeat) - QWaylandInputDevicePrivate(QWaylandInputDevice *device, QWaylandCompositor *compositor); - ~QWaylandInputDevicePrivate(); + QWaylandSeatPrivate(QWaylandSeat *seat, QWaylandCompositor *compositor); + ~QWaylandSeatPrivate(); void clientRequestedDataDevice(QtWayland::DataDeviceManager *dndSelection, struct wl_client *client, uint32_t id); - void setCapabilities(QWaylandInputDevice::CapabilityFlags caps); + void setCapabilities(QWaylandSeat::CapabilityFlags caps); - static QWaylandInputDevicePrivate *get(QWaylandInputDevice *device) { return device->d_func(); } + static QWaylandSeatPrivate *get(QWaylandSeat *device) { return device->d_func(); } QtWayland::DataDevice *dataDevice() const { return data_device.data(); } @@ -116,7 +116,7 @@ private: QWaylandCompositor *compositor; QWaylandView *mouseFocus; QWaylandSurface *keyboardFocus; - QWaylandInputDevice::CapabilityFlags capabilities; + QWaylandSeat::CapabilityFlags capabilities; QScopedPointer<QWaylandPointer> pointer; QScopedPointer<QWaylandKeyboard> keyboard; @@ -128,4 +128,4 @@ private: QT_END_NAMESPACE -#endif // QWAYLANDINPUT_P_H +#endif // QWAYLANDSEAT_P_H diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp index edb34e0bd..ea94433bb 100644 --- a/src/compositor/compositor_api/qwaylandsurface.cpp +++ b/src/compositor/compositor_api/qwaylandsurface.cpp @@ -52,7 +52,7 @@ #include <QtWaylandCompositor/private/qwaylandcompositor_p.h> #include <QtWaylandCompositor/private/qwaylandview_p.h> -#include <QtWaylandCompositor/private/qwaylandinput_p.h> +#include <QtWaylandCompositor/private/qwaylandseat_p.h> #include <QtCore/private/qobject_p.h> @@ -129,7 +129,7 @@ QWaylandSurfacePrivate::QWaylandSurfacePrivate() , bufferScale(1) , isCursorSurface(false) , destroyed(false) - , mapped(false) + , hasContent(false) , isInitialized(false) , contentOrientation(Qt::PrimaryOrientation) , inputMethodControl(Q_NULLPTR) @@ -193,9 +193,9 @@ void QWaylandSurfacePrivate::notifyViewsAboutDestruction() foreach (QWaylandView *view, views) { QWaylandViewPrivate::get(view)->markSurfaceAsDestroyed(q); } - if (mapped) { - mapped = false; - emit q->mappedChanged(); + if (hasContent) { + hasContent = false; + emit q->hasContentChanged(); } } @@ -342,10 +342,10 @@ void QWaylandSurfacePrivate::setBackBuffer(QtWayland::SurfaceBuffer *b, const QR emit q->damaged(damage); - bool oldMapped = mapped; - mapped = QtWayland::SurfaceBuffer::hasContent(buffer); - if (oldMapped != mapped) - emit q->mappedChanged(); + bool oldHasContent = hasContent; + hasContent = QtWayland::SurfaceBuffer::hasContent(buffer); + if (oldHasContent != hasContent) + emit q->hasContentChanged(); if (!pending.offset.isNull()) emit q->offsetForNextFrame(pending.offset); @@ -484,20 +484,20 @@ QWaylandClient *QWaylandSurface::client() const } /*! - * \qmlproperty bool QtWaylandCompositor::WaylandSurface::isMapped + * \qmlproperty bool QtWaylandCompositor::WaylandSurface::hasContent * * This property holds whether the WaylandSurface has content. */ /*! - * \property QWaylandSurface::isMapped + * \property QWaylandSurface::hasContent * * This property holds whether the QWaylandSurface has content. */ -bool QWaylandSurface::isMapped() const +bool QWaylandSurface::hasContent() const { Q_D(const QWaylandSurface); - return d->mapped; + return d->hasContent; } /*! @@ -708,9 +708,9 @@ QWaylandInputMethodControl *QWaylandSurface::inputMethodControl() const void QWaylandSurface::updateSelection() { Q_D(QWaylandSurface); - QWaylandInputDevice *inputDevice = d->compositor->defaultInputDevice(); - if (inputDevice) { - const QtWayland::DataDevice *dataDevice = QWaylandInputDevicePrivate::get(inputDevice)->dataDevice(); + QWaylandSeat *seat = d->compositor->defaultSeat(); + if (seat) { + const QtWayland::DataDevice *dataDevice = QWaylandSeatPrivate::get(seat)->dataDevice(); if (dataDevice) { QWaylandCompositorPrivate::get(d->compositor)->dataDeviceManager()->offerRetainedSelection( dataDevice->resourceMap().value(d->resource()->client())->handle); @@ -894,4 +894,16 @@ void QWaylandSurfacePrivate::Subsurface::subsurface_set_desync(wl_subsurface::Re qDebug() << Q_FUNC_INFO; } +/*! + * \qmlsignal void QtWaylandCompositor::WaylandSurface::dragStarted(object drag) + * + * This signal is emitted when a drag has started from this surface. + */ + +/*! + * \fn void QWaylandSurface::dragStarted(QWaylandDrag *drag) + * + * This signal is emitted when a drag has started from this surface. + */ + QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h index 816b5c987..ed358fefa 100644 --- a/src/compositor/compositor_api/qwaylandsurface.h +++ b/src/compositor/compositor_api/qwaylandsurface.h @@ -60,6 +60,7 @@ class QWaylandBufferRef; class QWaylandView; class QWaylandSurfaceOp; class QWaylandInputMethodControl; +class QWaylandDrag; class QWaylandSurfaceRole { @@ -81,7 +82,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandSurface : public QWaylandObject Q_PROPERTY(int bufferScale READ bufferScale NOTIFY bufferScaleChanged) Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation NOTIFY contentOrientationChanged) Q_PROPERTY(QWaylandSurface::Origin origin READ origin NOTIFY originChanged) - Q_PROPERTY(bool isMapped READ isMapped NOTIFY mappedChanged) + Q_PROPERTY(bool hasContent READ hasContent NOTIFY hasContentChanged) Q_PROPERTY(bool cursorSurface READ isCursorSurface WRITE markAsCursorSurface) public: @@ -104,7 +105,7 @@ public: bool setRole(QWaylandSurfaceRole *role, wl_resource *errorResource, uint32_t errorCode); QWaylandSurfaceRole *role() const; - bool isMapped() const; + bool hasContent() const; QSize size() const; int bufferScale() const; @@ -143,7 +144,7 @@ protected: QWaylandSurface(QWaylandSurfacePrivate &dptr); Q_SIGNALS: - void mappedChanged(); + void hasContentChanged(); void damaged(const QRegion &rect); void parentChanged(QWaylandSurface *newParent, QWaylandSurface *oldParent); void childAdded(QWaylandSurface *child); @@ -156,6 +157,7 @@ Q_SIGNALS: void subsurfacePositionChanged(const QPoint &position); void subsurfacePlaceAbove(QWaylandSurface *sibling); void subsurfacePlaceBelow(QWaylandSurface *sibling); + void dragStarted(QWaylandDrag *drag); void configure(bool hasBuffer); void redraw(); diff --git a/src/compositor/compositor_api/qwaylandsurface_p.h b/src/compositor/compositor_api/qwaylandsurface_p.h index e37179cc6..0596b61ba 100644 --- a/src/compositor/compositor_api/qwaylandsurface_p.h +++ b/src/compositor/compositor_api/qwaylandsurface_p.h @@ -171,7 +171,7 @@ public: //member variables int bufferScale; bool isCursorSurface; bool destroyed; - bool mapped; + bool hasContent; bool isInitialized; Qt::ScreenOrientation contentOrientation; QWindow::Visibility visibility; diff --git a/src/compositor/compositor_api/qwaylandsurfacegrabber.cpp b/src/compositor/compositor_api/qwaylandsurfacegrabber.cpp index d415642c4..f751a3d96 100644 --- a/src/compositor/compositor_api/qwaylandsurfacegrabber.cpp +++ b/src/compositor/compositor_api/qwaylandsurfacegrabber.cpp @@ -51,7 +51,8 @@ QT_BEGIN_NAMESPACE Sometimes it is needed to get the contents of a surface, for example to provide a screenshot to the user. The QWaylandSurfaceGrabber class provides a simple method to do so, without - having to care what type of buffer backs the surface, be it SHM, OpenGL or something else. + having to care what type of buffer backs the surface, be it shared memory, OpenGL or something + else. */ /*! diff --git a/src/compositor/compositor_api/qwaylandtouch.cpp b/src/compositor/compositor_api/qwaylandtouch.cpp index a9b44527e..c07809e71 100644 --- a/src/compositor/compositor_api/qwaylandtouch.cpp +++ b/src/compositor/compositor_api/qwaylandtouch.cpp @@ -38,7 +38,7 @@ #include "qwaylandtouch_p.h" #include <QtWaylandCompositor/QWaylandCompositor> -#include <QtWaylandCompositor/QWaylandInputDevice> +#include <QtWaylandCompositor/QWaylandSeat> #include <QtWaylandCompositor/QWaylandView> #include <QtWaylandCompositor/QWaylandClient> @@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE -QWaylandTouchPrivate::QWaylandTouchPrivate(QWaylandTouch *touch, QWaylandInputDevice *seat) +QWaylandTouchPrivate::QWaylandTouchPrivate(QWaylandTouch *touch, QWaylandSeat *seat) : wl_touch() , seat(seat) , focusResource() @@ -80,12 +80,12 @@ void QWaylandTouchPrivate::touch_release(Resource *resource) void QWaylandTouchPrivate::sendDown(uint32_t time, int touch_id, const QPointF &position) { Q_Q(QWaylandTouch); - if (!focusResource || !q->mouseFocus()) + if (!focusResource || !seat->mouseFocus()) return; uint32_t serial = q->compositor()->nextSerial(); - wl_touch_send_down(focusResource->handle, serial, time, q->mouseFocus()->surfaceResource(), touch_id, + wl_touch_send_down(focusResource->handle, serial, time, seat->mouseFocus()->surfaceResource(), touch_id, wl_fixed_from_double(position.x()), wl_fixed_from_double(position.y())); } @@ -113,15 +113,15 @@ void QWaylandTouchPrivate::sendMotion(uint32_t time, int touch_id, const QPointF * \preliminary * \brief The QWaylandTouch class provides access to a touch device. * - * This class provides access to the touch device in a QWaylandInputDevice. It corresponds to + * This class provides access to the touch device in a QWaylandSeat. It corresponds to * the Wayland interface wl_touch. */ /*! - * Constructs a QWaylandTouch for the \a inputDevice and with the given \a parent. + * Constructs a QWaylandTouch for the \a seat and with the given \a parent. */ -QWaylandTouch::QWaylandTouch(QWaylandInputDevice *inputDevice, QObject *parent) - : QWaylandObject(*new QWaylandTouchPrivate(this, inputDevice), parent) +QWaylandTouch::QWaylandTouch(QWaylandSeat *seat, QObject *parent) + : QWaylandObject(*new QWaylandTouchPrivate(this, seat), parent) { connect(&d_func()->focusDestroyListener, &QWaylandDestroyListener::fired, this, &QWaylandTouch::focusDestroyed); } @@ -129,7 +129,7 @@ QWaylandTouch::QWaylandTouch(QWaylandInputDevice *inputDevice, QObject *parent) /*! * Returns the input device for this QWaylandTouch. */ -QWaylandInputDevice *QWaylandTouch::inputDevice() const +QWaylandSeat *QWaylandTouch::seat() const { Q_D(const QWaylandTouch); return d->seat; @@ -147,9 +147,6 @@ QWaylandCompositor *QWaylandTouch::compositor() const /*! * Sends a touch point event for the touch device with the given \a id, * \a position, and \a state. - * - * - * \sa mouseFocus() */ void QWaylandTouch::sendTouchPointEvent(int id, const QPointF &position, Qt::TouchPointState state) { @@ -246,15 +243,6 @@ struct wl_resource *QWaylandTouch::focusResource() const } /*! - * Returns the view currently holding mouse focus in the input device. - */ -QWaylandView *QWaylandTouch::mouseFocus() const -{ - Q_D(const QWaylandTouch); - return d->seat->mouseFocus(); -} - -/*! * \internal */ void QWaylandTouch::focusDestroyed(void *data) diff --git a/src/compositor/compositor_api/qwaylandtouch.h b/src/compositor/compositor_api/qwaylandtouch.h index b6c40ea96..c058d42ae 100644 --- a/src/compositor/compositor_api/qwaylandtouch.h +++ b/src/compositor/compositor_api/qwaylandtouch.h @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE class QWaylandTouch; class QWaylandTouchPrivate; -class QWaylandInputDevice; +class QWaylandSeat; class QWaylandView; class QWaylandClient; @@ -57,9 +57,9 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTouch : public QWaylandObject Q_OBJECT Q_DECLARE_PRIVATE(QWaylandTouch) public: - QWaylandTouch(QWaylandInputDevice *inputDevice, QObject *parent = nullptr); + QWaylandTouch(QWaylandSeat *seat, QObject *parent = nullptr); - QWaylandInputDevice *inputDevice() const; + QWaylandSeat *seat() const; QWaylandCompositor *compositor() const; virtual void sendTouchPointEvent(int id, const QPointF &position, Qt::TouchPointState state); @@ -72,7 +72,6 @@ public: wl_resource *focusResource() const; - QWaylandView *mouseFocus() const; private: void focusDestroyed(void *data); void mouseFocusChanged(QWaylandView *newFocus, QWaylandView *oldFocus); diff --git a/src/compositor/compositor_api/qwaylandtouch_p.h b/src/compositor/compositor_api/qwaylandtouch_p.h index ea334eea1..2f60076a7 100644 --- a/src/compositor/compositor_api/qwaylandtouch_p.h +++ b/src/compositor/compositor_api/qwaylandtouch_p.h @@ -52,7 +52,7 @@ #include <QtWaylandCompositor/qwaylandexport.h> #include <QtWaylandCompositor/QWaylandDestroyListener> #include <QtWaylandCompositor/QWaylandTouch> -#include <QtWaylandCompositor/QWaylandInputDevice> +#include <QtWaylandCompositor/QWaylandSeat> #include <QtWaylandCompositor/QWaylandView> #include <QtWaylandCompositor/QWaylandCompositor> @@ -67,7 +67,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTouchPrivate : public QObjectPrivate, { Q_DECLARE_PUBLIC(QWaylandTouch) public: - explicit QWaylandTouchPrivate(QWaylandTouch *touch, QWaylandInputDevice *seat); + explicit QWaylandTouchPrivate(QWaylandTouch *touch, QWaylandSeat *seat); QWaylandCompositor *compositor() const { return seat->compositor(); } @@ -92,7 +92,7 @@ private: void touch_destroy_resource(Resource *resource) Q_DECL_OVERRIDE; void touch_release(Resource *resource) Q_DECL_OVERRIDE; - QWaylandInputDevice *seat; + QWaylandSeat *seat; Resource *focusResource; QWaylandDestroyListener focusDestroyListener; diff --git a/src/compositor/compositor_api/qwaylandview.cpp b/src/compositor/compositor_api/qwaylandview.cpp index 12b67bf5d..1f32bb61d 100644 --- a/src/compositor/compositor_api/qwaylandview.cpp +++ b/src/compositor/compositor_api/qwaylandview.cpp @@ -37,7 +37,7 @@ #include "qwaylandview.h" #include "qwaylandview_p.h" #include "qwaylandsurface.h" -#include <QtWaylandCompositor/QWaylandInputDevice> +#include <QtWaylandCompositor/QWaylandSeat> #include <QtWaylandCompositor/QWaylandCompositor> #include <QtWaylandCompositor/private/qwaylandsurface_p.h> @@ -96,7 +96,7 @@ QWaylandView::~QWaylandView() if (d->surface) { if (d->output) QWaylandOutputPrivate::get(d->output)->removeView(this, d->surface); - QWaylandInputDevice *i = d->surface->compositor()->defaultInputDevice(); + QWaylandSeat *i = d->surface->compositor()->defaultSeat(); if (i->mouseFocus() == this) i->setMouseFocus(Q_NULLPTR); @@ -145,7 +145,7 @@ void QWaylandView::setSurface(QWaylandSurface *newSurface) d->surface = newSurface; - if (!d->bufferLock) { + if (!d->bufferLocked) { d->currentBuffer = QWaylandBufferRef(); d->currentDamage = QRegion(); } @@ -216,7 +216,7 @@ void QWaylandView::attach(const QWaylandBufferRef &ref, const QRegion &damage) * * If this view is set as the surface's throttling view, discardCurrentBuffer() * is called on all views of the same surface for which the - * \l{QWaylandView::discardFrontBuffers}{discardFrontBuffers} + * \l{QWaylandView::allowDiscardFrontBuffer}{allowDiscardFrontBuffer} * property is set to true and the current buffer is the same as the * throttling view's current buffer. * @@ -231,12 +231,12 @@ bool QWaylandView::advance() if (d->currentBuffer == d->nextBuffer && !d->forceAdvanceSucceed) return false; - if (d->bufferLock) + if (d->bufferLocked) return false; if (d->surface && d->surface->throttlingView() == this) { Q_FOREACH (QWaylandView *view, d->surface->views()) { - if (view != this && view->discardFrontBuffers() && view->d_func()->currentBuffer == d->currentBuffer) + if (view != this && view->allowDiscardFrontBuffer() && view->d_func()->currentBuffer == d->currentBuffer) view->discardCurrentBuffer(); } } @@ -280,7 +280,7 @@ QRegion QWaylandView::currentDamage() } /*! - * \qmlproperty bool QtWaylandCompositor::WaylandView::bufferLock + * \qmlproperty bool QtWaylandCompositor::WaylandView::bufferLocked * * This property holds whether the view's buffer is currently locked. When * the buffer is locked, advance() will not advance to the next buffer and @@ -290,7 +290,7 @@ QRegion QWaylandView::currentDamage() */ /*! - * \property QWaylandView::bufferLock + * \property QWaylandView::bufferLocked * * This property holds whether the view's buffer is currently locked. When * the buffer is locked, advance() will not advance to the next buffer @@ -301,42 +301,43 @@ QRegion QWaylandView::currentDamage() bool QWaylandView::isBufferLocked() const { Q_D(const QWaylandView); - return d->bufferLock; + return d->bufferLocked; } -void QWaylandView::setBufferLock(bool locked) +void QWaylandView::setBufferLocked(bool locked) { Q_D(QWaylandView); - if (d->bufferLock == locked) + if (d->bufferLocked == locked) return; - d->bufferLock = locked; - emit bufferLockChanged(); + d->bufferLocked = locked; + emit bufferLockedChanged(); } /*! - * \qmlproperty bool QtWaylandCompositor::WaylandView::discardFrontBuffers + * \qmlproperty bool QtWaylandCompositor::WaylandView::allowDiscardFrontBuffer * * By default, the view locks the current buffer until advance() is called. Set this property * to true to allow Qt to release the buffer when the throttling view is no longer using it. */ + /*! - * \property QWaylandView::discardFrontBuffers + * \property QWaylandView::allowDiscardFrontBuffer * * By default, the view locks the current buffer until advance() is called. Set this property * to \c true to allow Qt to release the buffer when the throttling view is no longer using it. */ -bool QWaylandView::discardFrontBuffers() const +bool QWaylandView::allowDiscardFrontBuffer() const { Q_D(const QWaylandView); - return d->discardFrontBuffers; + return d->allowDiscardFrontBuffer; } -void QWaylandView::setDiscardFrontBuffers(bool discard) +void QWaylandView::setAllowDiscardFrontBuffer(bool discard) { Q_D(QWaylandView); - if (d->discardFrontBuffers == discard) + if (d->allowDiscardFrontBuffer == discard) return; - d->discardFrontBuffers = discard; - emit discardFrontBuffersChanged(); + d->allowDiscardFrontBuffer = discard; + emit allowDiscardFrontBufferChanged(); } /*! diff --git a/src/compositor/compositor_api/qwaylandview.h b/src/compositor/compositor_api/qwaylandview.h index f89d8ca78..6247e06e2 100644 --- a/src/compositor/compositor_api/qwaylandview.h +++ b/src/compositor/compositor_api/qwaylandview.h @@ -56,8 +56,8 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandView : public QObject Q_PROPERTY(QObject *renderObject READ renderObject CONSTANT) Q_PROPERTY(QWaylandSurface *surface READ surface WRITE setSurface NOTIFY surfaceChanged) Q_PROPERTY(QWaylandOutput *output READ output WRITE setOutput NOTIFY outputChanged) - Q_PROPERTY(bool bufferLock READ isBufferLocked WRITE setBufferLock NOTIFY bufferLockChanged) - Q_PROPERTY(bool discardFrontBuffers READ discardFrontBuffers WRITE setDiscardFrontBuffers NOTIFY discardFrontBuffersChanged) + Q_PROPERTY(bool bufferLocked READ isBufferLocked WRITE setBufferLocked NOTIFY bufferLockedChanged) + Q_PROPERTY(bool allowDiscardFrontBuffer READ allowDiscardFrontBuffer WRITE setAllowDiscardFrontBuffer NOTIFY allowDiscardFrontBufferChanged) public: QWaylandView(QObject *renderObject = nullptr, QObject *parent = nullptr); virtual ~QWaylandView(); @@ -77,10 +77,10 @@ public: virtual QRegion currentDamage(); bool isBufferLocked() const; - void setBufferLock(bool locked); + void setBufferLocked(bool locked); - bool discardFrontBuffers() const; - void setDiscardFrontBuffers(bool discard); + bool allowDiscardFrontBuffer() const; + void setAllowDiscardFrontBuffer(bool discard); struct wl_resource *surfaceResource() const; @@ -88,8 +88,8 @@ Q_SIGNALS: void surfaceChanged(); void surfaceDestroyed(); void outputChanged(); - void bufferLockChanged(); - void discardFrontBuffersChanged(); + void bufferLockedChanged(); + void allowDiscardFrontBufferChanged(); }; QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandview_p.h b/src/compositor/compositor_api/qwaylandview_p.h index 8c4cea085..d9fd352ed 100644 --- a/src/compositor/compositor_api/qwaylandview_p.h +++ b/src/compositor/compositor_api/qwaylandview_p.h @@ -69,10 +69,10 @@ public: : renderObject(Q_NULLPTR) , surface(Q_NULLPTR) , output(Q_NULLPTR) - , bufferLock(false) + , bufferLocked(false) , broadcastRequestedPositionChanged(false) , forceAdvanceSucceed(false) - , discardFrontBuffers(false) + , allowDiscardFrontBuffer(false) { } void markSurfaceAsDestroyed(QWaylandSurface *surface); @@ -86,10 +86,10 @@ public: QRegion currentDamage; QWaylandBufferRef nextBuffer; QRegion nextDamage; - bool bufferLock; + bool bufferLocked; bool broadcastRequestedPositionChanged; bool forceAdvanceSucceed; - bool discardFrontBuffers; + bool allowDiscardFrontBuffer; }; QT_END_NAMESPACE |