diff options
Diffstat (limited to 'src/compositor/compositor_api')
22 files changed, 444 insertions, 63 deletions
diff --git a/src/compositor/compositor_api/compositor_api.pri b/src/compositor/compositor_api/compositor_api.pri index 35f57f808..e5df0f1ff 100644 --- a/src/compositor/compositor_api/compositor_api.pri +++ b/src/compositor/compositor_api/compositor_api.pri @@ -26,7 +26,8 @@ HEADERS += \ compositor_api/qwaylandview_p.h \ compositor_api/qwaylandresource.h \ compositor_api/qwaylandsurfacegrabber.h \ - compositor_api/qwaylandoutputmode_p.h + compositor_api/qwaylandoutputmode_p.h \ + compositor_api/qwaylandquickhardwarelayer_p.h \ SOURCES += \ compositor_api/qwaylandcompositor.cpp \ @@ -43,7 +44,8 @@ SOURCES += \ compositor_api/qwaylanddestroylistener.cpp \ compositor_api/qwaylandview.cpp \ compositor_api/qwaylandresource.cpp \ - compositor_api/qwaylandsurfacegrabber.cpp + compositor_api/qwaylandsurfacegrabber.cpp \ + compositor_api/qwaylandquickhardwarelayer.cpp qtConfig(im) { HEADERS += \ diff --git a/src/compositor/compositor_api/qwaylandbufferref.cpp b/src/compositor/compositor_api/qwaylandbufferref.cpp index 57a120e48..8ceeeea56 100644 --- a/src/compositor/compositor_api/qwaylandbufferref.cpp +++ b/src/compositor/compositor_api/qwaylandbufferref.cpp @@ -185,7 +185,7 @@ bool QWaylandBufferRef::isDestroyed() const */ struct ::wl_resource *QWaylandBufferRef::wl_buffer() const { - return d->buffer ? d->buffer->waylandBufferHandle() : Q_NULLPTR; + return d->buffer ? d->buffer->waylandBufferHandle() : nullptr; } /*! diff --git a/src/compositor/compositor_api/qwaylandclient.cpp b/src/compositor/compositor_api/qwaylandclient.cpp index 2b73c06ca..122fd41c3 100644 --- a/src/compositor/compositor_api/qwaylandclient.cpp +++ b/src/compositor/compositor_api/qwaylandclient.cpp @@ -146,7 +146,7 @@ QWaylandClient *QWaylandClient::fromWlClient(QWaylandCompositor *compositor, wl_ if (!wlClient) return 0; - QWaylandClient *client = Q_NULLPTR; + QWaylandClient *client = nullptr; wl_listener *l = wl_client_get_destroy_listener(wlClient, QWaylandClientPrivate::client_destroy_callback); diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp index 4e7040889..4c662a34a 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.cpp +++ b/src/compositor/compositor_api/qwaylandcompositor.cpp @@ -656,7 +656,7 @@ QWaylandOutput *QWaylandCompositor::outputFor(QWindow *window) const return output; } - return Q_NULLPTR; + return nullptr; } /*! @@ -822,7 +822,7 @@ QWaylandSeat *QWaylandCompositor::defaultSeat() const Q_D(const QWaylandCompositor); if (d->seats.size()) return d->seats.first(); - return Q_NULLPTR; + return nullptr; } /*! diff --git a/src/compositor/compositor_api/qwaylandcompositor_p.h b/src/compositor/compositor_api/qwaylandcompositor_p.h index 3970ff152..18595a806 100644 --- a/src/compositor/compositor_api/qwaylandcompositor_p.h +++ b/src/compositor/compositor_api/qwaylandcompositor_p.h @@ -87,7 +87,7 @@ public: void destroySurface(QWaylandSurface *surface); void unregisterSurface(QWaylandSurface *surface); - QWaylandOutput *defaultOutput() const { return outputs.size() ? outputs.first() : Q_NULLPTR; } + QWaylandOutput *defaultOutput() const { return outputs.size() ? outputs.first() : nullptr; } inline QtWayland::ClientBufferIntegration *clientBufferIntegration() const; inline QtWayland::ServerBufferIntegration *serverBufferIntegration() const; diff --git a/src/compositor/compositor_api/qwaylandkeyboard.cpp b/src/compositor/compositor_api/qwaylandkeyboard.cpp index c30f7b18d..930eae1ae 100644 --- a/src/compositor/compositor_api/qwaylandkeyboard.cpp +++ b/src/compositor/compositor_api/qwaylandkeyboard.cpp @@ -122,7 +122,7 @@ void QWaylandKeyboardPrivate::sendEnter(QWaylandSurface *surface, Resource *keyb void QWaylandKeyboardPrivate::focused(QWaylandSurface *surface) { if (surface && surface->isCursorSurface()) - surface = Q_NULLPTR; + surface = nullptr; if (focus != surface) { if (focusResource) { uint32_t serial = compositor()->nextSerial(); @@ -466,7 +466,7 @@ QWaylandClient *QWaylandKeyboard::focusClient() const { Q_D(const QWaylandKeyboard); if (!d->focusResource) - return Q_NULLPTR; + return nullptr; return QWaylandClient::fromWlClient(compositor(), d->focusResource->client()); } diff --git a/src/compositor/compositor_api/qwaylandoutput.cpp b/src/compositor/compositor_api/qwaylandoutput.cpp index c369bb26c..7627195da 100644 --- a/src/compositor/compositor_api/qwaylandoutput.cpp +++ b/src/compositor/compositor_api/qwaylandoutput.cpp @@ -46,6 +46,7 @@ #include <QtWaylandCompositor/private/qwaylandsurface_p.h> #include <QtWaylandCompositor/private/qwaylandcompositor_p.h> +#include <QtWaylandCompositor/private/qwaylandview_p.h> #include <QtCore/QCoreApplication> #include <QtCore/QtMath> @@ -104,8 +105,8 @@ static QtWaylandServer::wl_output::transform toWlTransform(const QWaylandOutput: QWaylandOutputPrivate::QWaylandOutputPrivate() : QtWaylandServer::wl_output() - , compositor(Q_NULLPTR) - , window(Q_NULLPTR) + , compositor(nullptr) + , window(nullptr) , currentMode(-1) , preferredMode(-1) , subpixel(QWaylandOutput::SubpixelUnknown) @@ -319,7 +320,7 @@ struct ::wl_resource *QWaylandOutput::resourceForClient(QWaylandClient *client) if (r) return r->handle; - return Q_NULLPTR; + return nullptr; } /*! @@ -895,8 +896,10 @@ void QWaylandOutput::sendFrameCallbacks() surfaceEnter(surfacemapper.surface); d->surfaceViews[i].has_entered = true; } - if (surfacemapper.maybePrimaryView()) - surfacemapper.surface->sendFrameCallbacks(); + if (auto primaryView = surfacemapper.maybePrimaryView()) { + if (!QWaylandViewPrivate::get(primaryView)->independentFrameCallback) + surfacemapper.surface->sendFrameCallbacks(); + } } } wl_display_flush_clients(d->compositor->display()); @@ -997,7 +1000,7 @@ void QWaylandOutput::handleSetHeight(int newHeight) void QWaylandOutput::handleWindowDestroyed() { Q_D(QWaylandOutput); - d->window = Q_NULLPTR; + d->window = nullptr; emit windowChanged(); emit windowDestroyed(); } diff --git a/src/compositor/compositor_api/qwaylandoutput_p.h b/src/compositor/compositor_api/qwaylandoutput_p.h index 594fe1291..dab6daf73 100644 --- a/src/compositor/compositor_api/qwaylandoutput_p.h +++ b/src/compositor/compositor_api/qwaylandoutput_p.h @@ -87,7 +87,7 @@ struct QWaylandSurfaceViewMapper if (surface && surface->primaryView() == views.at(i)) return views.at(i); } - return Q_NULLPTR; + return nullptr; } QWaylandSurface *surface; diff --git a/src/compositor/compositor_api/qwaylandpointer.cpp b/src/compositor/compositor_api/qwaylandpointer.cpp index bf4bf547d..4bdee9be2 100644 --- a/src/compositor/compositor_api/qwaylandpointer.cpp +++ b/src/compositor/compositor_api/qwaylandpointer.cpp @@ -133,7 +133,7 @@ void QWaylandPointerPrivate::pointer_set_cursor(wl_pointer::Resource *resource, Q_UNUSED(serial); if (!surface) { - seat->cursorSurfaceRequest(Q_NULLPTR, 0, 0); + seat->cursorSurfaceRequest(nullptr, 0, 0); return; } @@ -250,7 +250,7 @@ void QWaylandPointer::sendMouseMoveEvent(QWaylandView *view, const QPointF &loca { Q_D(QWaylandPointer); if (view && (!view->surface() || view->surface()->isCursorSurface())) - view = Q_NULLPTR; + view = nullptr; d->seat->setMouseFocus(view); d->localPosition = localPos; d->spacePosition = outputSpacePos; diff --git a/src/compositor/compositor_api/qwaylandquickhardwarelayer.cpp b/src/compositor/compositor_api/qwaylandquickhardwarelayer.cpp new file mode 100644 index 000000000..f82de0014 --- /dev/null +++ b/src/compositor/compositor_api/qwaylandquickhardwarelayer.cpp @@ -0,0 +1,178 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandquickhardwarelayer_p.h" + +#include <QtWaylandCompositor/private/qwlhardwarelayerintegration_p.h> +#include <QtWaylandCompositor/private/qwlhardwarelayerintegrationfactory_p.h> + +#include <QtCore/private/qobject_p.h> +#include <QMatrix4x4> + +QT_BEGIN_NAMESPACE + +class QWaylandQuickHardwareLayerPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QWaylandQuickHardwareLayer) +public: + QtWayland::HardwareLayerIntegration *layerIntegration(); + QWaylandQuickItem *m_waylandItem = nullptr; + int m_stackingLevel = 0; + QMatrix4x4 m_matrixFromRenderThread; + static QtWayland::HardwareLayerIntegration *s_hardwareLayerIntegration; +}; + +QtWayland::HardwareLayerIntegration *QWaylandQuickHardwareLayerPrivate::s_hardwareLayerIntegration = nullptr; + +QtWayland::HardwareLayerIntegration *QWaylandQuickHardwareLayerPrivate::layerIntegration() +{ + if (!s_hardwareLayerIntegration) { + QStringList keys = QtWayland::HardwareLayerIntegrationFactory::keys(); + + QString environmentKey = QString::fromLocal8Bit(qgetenv("QT_WAYLAND_HARDWARE_LAYER_INTEGRATION").constData()); + if (!environmentKey.isEmpty()) { + if (keys.contains(environmentKey)) { + s_hardwareLayerIntegration = QtWayland::HardwareLayerIntegrationFactory::create(environmentKey, QStringList()); + } else { + qWarning() << "Unknown hardware layer integration:" << environmentKey + << "Valid layer integrations are" << keys; + } + } else if (!keys.isEmpty()) { + s_hardwareLayerIntegration = QtWayland::HardwareLayerIntegrationFactory::create(keys.first(), QStringList()); + } else { + qWarning() << "No wayland hardware layer integrations found"; + } + } + + return s_hardwareLayerIntegration; +} + +/*! + * \qmltype WaylandHardwareLayer + * \inqmlmodule QtWayland.Compositor + * \preliminary + * \brief Makes a parent WaylandQuickItem use hardware layers for rendering + * + * This item needs to be a descendant of a WaylandQuickItem or a derivative, + * (i.e. ShellSurfaceItem or similar) + * + * The Surface of the parent WaylandQuickItem will be drawn in a hardware specific way instead + * of the regular way using the QtQuick scene graph. On some platforms, the WaylandQuickItem's + * current buffer and the scene graph can be blended in a separate step. This makes it possible for + * clients to update continuously without triggering a full redraw of the compositor scene graph for + * each frame. + * + * The preferred hardware layer integration may be overridden by setting the + * QT_WAYLAND_HARDWARE_LAYER_INTEGRATION environment variable. + */ + +QWaylandQuickHardwareLayer::QWaylandQuickHardwareLayer(QObject *parent) + : QObject(*new QWaylandQuickHardwareLayerPrivate(), parent) +{ +} + +QWaylandQuickHardwareLayer::~QWaylandQuickHardwareLayer() +{ + Q_D(QWaylandQuickHardwareLayer); + if (d->layerIntegration()) + d->layerIntegration()->remove(this); +} + +/*! + * \qmlproperty int QtWaylandCompositor::WaylandHardwareLayer::stackingLevel + * + * This property holds the stacking level of this hardware layer relative to other hardware layers, + * and can be used to sort hardware layers. I.e. a layer with a higher level is rendered on top of + * one with a lower level. + * + * Layers with level 0 will be drawn in an implementation defined order on top of the compositor + * scene graph. + * + * Layers with a level below 0 are drawn beneath the compositor scene graph, if supported by the + * hardware layer integration. + */ +int QWaylandQuickHardwareLayer::stackingLevel() const +{ + Q_D(const QWaylandQuickHardwareLayer); + return d->m_stackingLevel; +} + +void QWaylandQuickHardwareLayer::setStackingLevel(int level) +{ + Q_D(QWaylandQuickHardwareLayer); + if (level == d->m_stackingLevel) + return; + + d->m_stackingLevel = level; + emit stackingLevelChanged(); +} + +QWaylandQuickItem *QWaylandQuickHardwareLayer::waylandItem() const +{ + Q_D(const QWaylandQuickHardwareLayer); + return d->m_waylandItem; +} + +void QWaylandQuickHardwareLayer::classBegin() +{ + Q_D(QWaylandQuickHardwareLayer); + for (QObject *p = parent(); p != nullptr; p = p->parent()) { + if (auto *waylandItem = qobject_cast<QWaylandQuickItem *>(p)) { + d->m_waylandItem = waylandItem; + break; + } + } +} + +void QWaylandQuickHardwareLayer::componentComplete() +{ + Q_D(QWaylandQuickHardwareLayer); + Q_ASSERT(d->m_waylandItem); + if (auto integration = d->layerIntegration()) + integration->add(this); + else + qWarning() << "No hardware layer integration. WaylandHarwareLayer has no effect."; +} + +void QWaylandQuickHardwareLayer::disableSceneGraphPainting() +{ + waylandItem()->setPaintEnabled(false); +} + +QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandquickhardwarelayer_p.h b/src/compositor/compositor_api/qwaylandquickhardwarelayer_p.h new file mode 100644 index 000000000..24cb709f4 --- /dev/null +++ b/src/compositor/compositor_api/qwaylandquickhardwarelayer_p.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDQUICKHARDWARELAYER_P_H +#define QWAYLANDQUICKHARDWARELAYER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtWaylandCompositor/QWaylandQuickItem> + +QT_BEGIN_NAMESPACE + +class QWaylandQuickHardwareLayerPrivate; + +class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickHardwareLayer : public QObject, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + Q_DECLARE_PRIVATE(QWaylandQuickHardwareLayer) + Q_PROPERTY(int stackingLevel READ stackingLevel WRITE setStackingLevel NOTIFY stackingLevelChanged) +public: + explicit QWaylandQuickHardwareLayer(QObject *parent = nullptr); + ~QWaylandQuickHardwareLayer() override; + + int stackingLevel() const; + void setStackingLevel(int level); + + QWaylandQuickItem *waylandItem() const; + + void classBegin() override; + void componentComplete() override; + + void disableSceneGraphPainting(); + +Q_SIGNALS: + void stackingLevelChanged(); +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDQUICKHARDWARELAYER_P_H diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp index 5414d06ae..74ce326e5 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.cpp +++ b/src/compositor/compositor_api/qwaylandquickitem.cpp @@ -384,7 +384,7 @@ QWaylandQuickItem::~QWaylandQuickItem() QWaylandCompositor *QWaylandQuickItem::compositor() const { Q_D(const QWaylandQuickItem); - return d->view->surface() ? d->view->surface()->compositor() : Q_NULLPTR; + return d->view->surface() ? d->view->surface()->compositor() : nullptr; } /*! @@ -587,7 +587,7 @@ void QWaylandQuickItem::hoverLeaveEvent(QHoverEvent *event) Q_D(QWaylandQuickItem); if (d->shouldSendInputEvents()) { QWaylandSeat *seat = compositor()->seatFor(event); - seat->setMouseFocus(Q_NULLPTR); + seat->setMouseFocus(nullptr); } else { event->ignore(); } @@ -949,9 +949,14 @@ void QWaylandQuickItem::parentChanged(QWaylandSurface *newParent, QWaylandSurfac void QWaylandQuickItem::updateSize() { Q_D(QWaylandQuickItem); - if (d->sizeFollowsSurface && surface()) { - setSize(surface()->size() * (d->scaleFactor() / surface()->bufferScale())); - } + + QSize size(0, 0); + if (surface()) + size = surface()->size() * (d->scaleFactor() / surface()->bufferScale()); + + setImplicitSize(size.width(), size.height()); + if (d->sizeFollowsSurface) + setSize(size); } /*! @@ -1006,7 +1011,13 @@ bool QWaylandQuickItem::inputRegionContains(const QPointF &localPosition) QPointF QWaylandQuickItem::mapToSurface(const QPointF &point) const { Q_D(const QWaylandQuickItem); - return point / d->scaleFactor(); + if (!surface() || surface()->size().isEmpty()) + return point / d->scaleFactor(); + + qreal xScale = width() / surface()->size().width(); + qreal yScale = height() / surface()->size().height(); + + return QPointF(point.x() / xScale, point.y() / yScale); } /*! @@ -1032,6 +1043,9 @@ bool QWaylandQuickItem::sizeFollowsSurface() const return d->sizeFollowsSurface; } +//TODO: sizeFollowsSurface became obsolete when we added an implementation for +//implicit size. The property is here for compatibility reasons only and should +//be removed or at least default to false in Qt 6. void QWaylandQuickItem::setSizeFollowsSurface(bool sizeFollowsSurface) { Q_D(QWaylandQuickItem); @@ -1066,14 +1080,14 @@ QVariant QWaylandQuickItem::inputMethodQuery(Qt::InputMethodQuery query, QVarian Returns true if the item is hidden, though the texture is still updated. As opposed to hiding the item by - setting \l{Item::visible}{visible} to \c false, setting this property to \c true + setting \l{Item::visible}{visible} to \c false, setting this property to \c false will not prevent mouse or keyboard input from reaching item. */ /*! Returns true if the item is hidden, though the texture is still updated. As opposed to hiding the item by - setting \l{Item::visible}{visible} to \c false, setting this property to \c true + setting \l{Item::visible}{visible} to \c false, setting this property to \c false will not prevent mouse or keyboard input from reaching item. */ bool QWaylandQuickItem::paintEnabled() const @@ -1176,9 +1190,10 @@ void QWaylandQuickItem::updateInputMethod(Qt::InputMethodQueries queries) * \sa QWaylandQuickkItem::bufferLocked */ -QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) +QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) { Q_D(QWaylandQuickItem); + d->lastMatrix = data->transformNode->combinedMatrix(); const bool bufferHasContent = d->view->currentBuffer().hasContent(); if (d->view->isBufferLocked() && !bufferHasContent && d->paintEnabled) @@ -1186,7 +1201,7 @@ QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat if (!bufferHasContent || !d->paintEnabled) { delete oldNode; - return 0; + return nullptr; } QWaylandBufferRef ref = d->view->currentBuffer(); diff --git a/src/compositor/compositor_api/qwaylandquickitem.h b/src/compositor/compositor_api/qwaylandquickitem.h index cd44a4fbc..11457fa6e 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.h +++ b/src/compositor/compositor_api/qwaylandquickitem.h @@ -184,7 +184,7 @@ Q_SIGNALS: void bufferLockedChanged(); void allowDiscardFrontBufferChanged(); protected: - QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override; + QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) override; QWaylandQuickItem(QWaylandQuickItemPrivate &dd, QQuickItem *parent = nullptr); }; diff --git a/src/compositor/compositor_api/qwaylandquickitem_p.h b/src/compositor/compositor_api/qwaylandquickitem_p.h index 30b96c4f6..400cda742 100644 --- a/src/compositor/compositor_api/qwaylandquickitem_p.h +++ b/src/compositor/compositor_api/qwaylandquickitem_p.h @@ -109,9 +109,9 @@ class QWaylandQuickItemPrivate : public QQuickItemPrivate public: QWaylandQuickItemPrivate() : QQuickItemPrivate() - , view(Q_NULLPTR) - , oldSurface(Q_NULLPTR) - , provider(Q_NULLPTR) + , view(nullptr) + , oldSurface(nullptr) + , provider(nullptr) , paintEnabled(true) , touchEventsEnabled(true) , inputEventsEnabled(true) @@ -119,7 +119,7 @@ public: , newTexture(false) , focusOnClick(true) , sizeFollowsSurface(true) - , connectedWindow(Q_NULLPTR) + , connectedWindow(nullptr) , origin(QWaylandSurface::OriginTopLeft) { } @@ -149,6 +149,8 @@ public: q->updateWindow(); } + static const QWaylandQuickItemPrivate* get(const QWaylandQuickItem *item) { return item->d_func(); } + void setInputEventsEnabled(bool enable) { Q_Q(QWaylandQuickItem); @@ -177,6 +179,7 @@ public: bool focusOnClick; bool sizeFollowsSurface; QPoint hoverPos; + QMatrix4x4 lastMatrix; QQuickWindow *connectedWindow; QWaylandSurface::Origin origin; diff --git a/src/compositor/compositor_api/qwaylandquicksurface.cpp b/src/compositor/compositor_api/qwaylandquicksurface.cpp index ec68ee6a1..1197e9e43 100644 --- a/src/compositor/compositor_api/qwaylandquicksurface.cpp +++ b/src/compositor/compositor_api/qwaylandquicksurface.cpp @@ -49,9 +49,6 @@ #include <QtWaylandCompositor/QWaylandView> #include <QtWaylandCompositor/private/qwaylandsurface_p.h> -#include <QtWaylandCompositor/private/qwayland-server-surface-extension.h> -#include <QtWaylandCompositor/private/qwlextendedsurface_p.h> - QT_BEGIN_NAMESPACE class QWaylandQuickSurfacePrivate : public QWaylandSurfacePrivate @@ -112,8 +109,11 @@ void QWaylandQuickSurface::setUseTextureAlpha(bool useTextureAlpha) /*! * \qmlproperty bool QtWaylandCompositor::WaylandSurface::clientRenderingEnabled + * \deprecated * - * This property specifies whether client rendering is enabled for the surface. + * This property used to specify whether client rendering was enabled for the surface. + * It depended on a Wayland extension that was part of the private API. The surface extension + * is not used anymore, so this property does nothing. */ bool QWaylandQuickSurface::clientRenderingEnabled() const { @@ -124,12 +124,9 @@ bool QWaylandQuickSurface::clientRenderingEnabled() const void QWaylandQuickSurface::setClientRenderingEnabled(bool enabled) { Q_D(QWaylandQuickSurface); + qWarning() << Q_FUNC_INFO << "doesn't do anything"; if (d->clientRenderingEnabled != enabled) { d->clientRenderingEnabled = enabled; - - if (QtWayland::ExtendedSurface *extSurface = QtWayland::ExtendedSurface::findIn(this)) - extSurface->setVisibility(enabled ? QWindow::AutomaticVisibility : QWindow::Hidden); - emit clientRenderingEnabledChanged(); } } diff --git a/src/compositor/compositor_api/qwaylandquicksurface.h b/src/compositor/compositor_api/qwaylandquicksurface.h index 7ec08e123..273fb25f4 100644 --- a/src/compositor/compositor_api/qwaylandquicksurface.h +++ b/src/compositor/compositor_api/qwaylandquicksurface.h @@ -63,12 +63,12 @@ public: bool useTextureAlpha() const; void setUseTextureAlpha(bool useTextureAlpha); - bool clientRenderingEnabled() const; - void setClientRenderingEnabled(bool enabled); + Q_DECL_DEPRECATED bool clientRenderingEnabled() const; + Q_DECL_DEPRECATED void setClientRenderingEnabled(bool enabled); Q_SIGNALS: void useTextureAlphaChanged(); - void clientRenderingEnabledChanged(); + void clientRenderingEnabledChanged(); //deprecated }; QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandseat.cpp b/src/compositor/compositor_api/qwaylandseat.cpp index b4b45392c..4b506bcda 100644 --- a/src/compositor/compositor_api/qwaylandseat.cpp +++ b/src/compositor/compositor_api/qwaylandseat.cpp @@ -65,7 +65,7 @@ QWaylandSeatPrivate::QWaylandSeatPrivate(QWaylandSeat *seat) , QtWaylandServer::wl_seat() , isInitialized(false) , compositor(nullptr) - , mouseFocus(Q_NULLPTR) + , mouseFocus(nullptr) , keyboardFocus(nullptr) , capabilities() #if QT_CONFIG(wayland_datadevice) @@ -298,7 +298,93 @@ uint QWaylandSeat::sendTouchPointEvent(QWaylandSurface *surface, int id, const Q } /*! - * Sends a frame event to the touch device of a \a client. + * \qmlmethod uint QtWaylandCompositor::WaylandSeat::sendTouchPointPressed(WaylandSurface surface, int id, point position) + * + * Sends a touch pressed event for the touch point \a id on \a surface with + * position \a position. + * + * \note You need to send a touch frame event when you are done sending touch + * events. + * + * Returns the serial for the touch down event. + */ + +/*! + * Sends a touch pressed event for the touch point \a id on \a surface with + * position \a position. + * + * \note You need to send a touch frame event when you are done sending touch + * events. + * + * Returns the serial for the touch down event. + */ +uint QWaylandSeat::sendTouchPointPressed(QWaylandSurface *surface, int id, const QPointF &position) +{ + return sendTouchPointEvent(surface, id, position, Qt::TouchPointPressed); +} + +/*! + * \qmlmethod void QtWaylandCompositor::WaylandSeat::sendTouchPointReleased(WaylandSurface surface, int id, point position) + * + * Sends a touch released event for the touch point \a id on \a surface with + * position \a position. + * + * \note You need to send a touch frame event when you are done sending touch + * events. + * + * Returns the serial for the touch up event. + */ + +/*! + * Sends a touch released event for the touch point \a id on \a surface with + * position \a position. + * + * \note You need to send a touch frame event when you are done sending touch + * events. + * + * Returns the serial for the touch up event. + */ +uint QWaylandSeat::sendTouchPointReleased(QWaylandSurface *surface, int id, const QPointF &position) +{ + return sendTouchPointEvent(surface, id, position, Qt::TouchPointReleased); +} + +/*! + * \qmlmethod void QtWaylandCompositor::WaylandSeat::sendTouchPointMoved(WaylandSurface surface, int id, point position) + * + * Sends a touch moved event for the touch point \a id on \a surface with + * position \a position. + * + * \note You need to send a touch frame event when you are done sending touch + * events. + * + * Returns the serial for the touch motion event. + */ + +/*! + * Sends a touch moved event for the touch point \a id on \a surface with + * position \a position. + * + * \note You need to send a touch frame event when you are done sending touch + * events. + * + * Returns the serial for the touch motion event. + */ +uint QWaylandSeat::sendTouchPointMoved(QWaylandSurface *surface, int id, const QPointF &position) +{ + return sendTouchPointEvent(surface, id, position, Qt::TouchPointMoved); +} + +/*! + * \qmlmethod void QtWaylandCompositor::WaylandSeat::sendTouchFrameEvent(WaylandClient client) + * + * Sends a frame event to the touch device of a \a client to indicate the end + * of a series of touch up, down, and motion events. + */ + +/*! + * Sends a frame event to the touch device of a \a client to indicate the end + * of a series of touch up, down, and motion events. */ void QWaylandSeat::sendTouchFrameEvent(QWaylandClient *client) { @@ -308,6 +394,12 @@ void QWaylandSeat::sendTouchFrameEvent(QWaylandClient *client) } /*! + * \qmlmethod void QtWaylandCompositor::WaylandSeat::sendTouchCancelEvent(WaylandClient client) + * + * Sends a cancel event to the touch device of a \a client. + */ + +/*! * Sends a cancel event to the touch device of a \a client. */ void QWaylandSeat::sendTouchCancelEvent(QWaylandClient *client) @@ -381,7 +473,7 @@ QWaylandSurface *QWaylandSeat::keyboardFocus() const { Q_D(const QWaylandSeat); if (d->keyboard.isNull() || !d->keyboard->focus()) - return Q_NULLPTR; + return nullptr; return d->keyboard->focus(); } diff --git a/src/compositor/compositor_api/qwaylandseat.h b/src/compositor/compositor_api/qwaylandseat.h index e5ef46dc6..d22e05a5b 100644 --- a/src/compositor/compositor_api/qwaylandseat.h +++ b/src/compositor/compositor_api/qwaylandseat.h @@ -99,8 +99,11 @@ public: void sendFullKeyEvent(QKeyEvent *event); uint sendTouchPointEvent(QWaylandSurface *surface, int id, const QPointF &point, Qt::TouchPointState state); - void sendTouchFrameEvent(QWaylandClient *client); - void sendTouchCancelEvent(QWaylandClient *client); + Q_INVOKABLE uint sendTouchPointPressed(QWaylandSurface *surface, int id, const QPointF &position); + Q_INVOKABLE uint sendTouchPointReleased(QWaylandSurface *surface, int id, const QPointF &position); + Q_INVOKABLE uint sendTouchPointMoved(QWaylandSurface *surface, int id, const QPointF &position); + Q_INVOKABLE void sendTouchFrameEvent(QWaylandClient *client); + Q_INVOKABLE void sendTouchCancelEvent(QWaylandClient *client); void sendFullTouchEvent(QWaylandSurface *surface, QTouchEvent *event); diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp index 05113c41c..37b6876ac 100644 --- a/src/compositor/compositor_api/qwaylandsurface.cpp +++ b/src/compositor/compositor_api/qwaylandsurface.cpp @@ -49,7 +49,6 @@ #include "wayland_wrapper/qwldatadevicemanager_p.h" #endif -#include "extensions/qwlextendedsurface_p.h" #include "qwaylandinputmethodcontrol_p.h" #include <QtWaylandCompositor/QWaylandCompositor> @@ -127,9 +126,9 @@ QList<QWaylandSurfacePrivate *> QWaylandSurfacePrivate::uninitializedSurfaces; QWaylandSurfacePrivate::QWaylandSurfacePrivate() : QtWaylandServer::wl_surface() - , compositor(Q_NULLPTR) + , compositor(nullptr) , refCount(1) - , client(Q_NULLPTR) + , client(nullptr) , role(0) , inputRegion(infiniteRegion()) , bufferScale(1) @@ -139,7 +138,7 @@ QWaylandSurfacePrivate::QWaylandSurfacePrivate() , isInitialized(false) , contentOrientation(Qt::PrimaryOrientation) #if QT_CONFIG(im) - , inputMethodControl(Q_NULLPTR) + , inputMethodControl(nullptr) #endif , subsurface(0) { @@ -459,7 +458,7 @@ QWaylandClient *QWaylandSurface::client() const { Q_D(const QWaylandSurface); if (isDestroyed() || !compositor() || !compositor()->clients().contains(d->client)) - return Q_NULLPTR; + return nullptr; return d->client; } @@ -603,7 +602,7 @@ void QWaylandSurface::sendFrameCallbacks() int i = 0; while (i < d->frameCallbacks.size()) { if (d->frameCallbacks.at(i)->canSend) { - d->frameCallbacks.at(i)->surface = Q_NULLPTR; + d->frameCallbacks.at(i)->surface = nullptr; d->frameCallbacks.at(i)->send(time); d->frameCallbacks.removeAt(i); } else { @@ -716,7 +715,7 @@ QWaylandView *QWaylandSurface::primaryView() const { Q_D(const QWaylandSurface); if (d->views.isEmpty()) - return Q_NULLPTR; + return nullptr; return d->views.first(); } @@ -808,7 +807,7 @@ QWaylandSurfaceRole *QWaylandSurface::role() const QWaylandSurfacePrivate *QWaylandSurfacePrivate::get(QWaylandSurface *surface) { - return surface ? surface->d_func() : Q_NULLPTR; + return surface ? surface->d_func() : nullptr; } void QWaylandSurfacePrivate::ref() diff --git a/src/compositor/compositor_api/qwaylandsurfacegrabber.h b/src/compositor/compositor_api/qwaylandsurfacegrabber.h index ce1e397e5..c28614f37 100644 --- a/src/compositor/compositor_api/qwaylandsurfacegrabber.h +++ b/src/compositor/compositor_api/qwaylandsurfacegrabber.h @@ -60,7 +60,7 @@ public: RendererNotReady, }; Q_ENUM(Error) - explicit QWaylandSurfaceGrabber(QWaylandSurface *surface, QObject *parent = Q_NULLPTR); + explicit QWaylandSurfaceGrabber(QWaylandSurface *surface, QObject *parent = nullptr); QWaylandSurface *surface() const; void grab(); diff --git a/src/compositor/compositor_api/qwaylandview.cpp b/src/compositor/compositor_api/qwaylandview.cpp index 9e8297574..4d6f392e1 100644 --- a/src/compositor/compositor_api/qwaylandview.cpp +++ b/src/compositor/compositor_api/qwaylandview.cpp @@ -55,7 +55,7 @@ void QWaylandViewPrivate::markSurfaceAsDestroyed(QWaylandSurface *surface) Q_Q(QWaylandView); Q_ASSERT(surface == this->surface); - q->setSurface(Q_NULLPTR); + q->setSurface(nullptr); emit q->surfaceDestroyed(); } @@ -376,7 +376,7 @@ struct wl_resource *QWaylandView::surfaceResource() const { Q_D(const QWaylandView); if (!d->surface) - return Q_NULLPTR; + return nullptr; return d->surface->resource(); } diff --git a/src/compositor/compositor_api/qwaylandview_p.h b/src/compositor/compositor_api/qwaylandview_p.h index 326e0b297..1cc55954c 100644 --- a/src/compositor/compositor_api/qwaylandview_p.h +++ b/src/compositor/compositor_api/qwaylandview_p.h @@ -40,6 +40,8 @@ #ifndef QWAYLANDSURFACEVIEW_P_H #define QWAYLANDSURFACEVIEW_P_H +#include "qwaylandview.h" + #include <QtCore/QPoint> #include <QtCore/QMutex> #include <QtCore/private/qobject_p.h> @@ -69,9 +71,9 @@ public: static QWaylandViewPrivate *get(QWaylandView *view) { return view->d_func(); } QWaylandViewPrivate() - : renderObject(Q_NULLPTR) - , surface(Q_NULLPTR) - , output(Q_NULLPTR) + : renderObject(nullptr) + , surface(nullptr) + , output(nullptr) , nextBufferCommitted(false) , bufferLocked(false) , broadcastRequestedPositionChanged(false) @@ -95,6 +97,7 @@ public: bool broadcastRequestedPositionChanged; bool forceAdvanceSucceed; bool allowDiscardFrontBuffer; + bool independentFrameCallback = false; //If frame callbacks are independent of the main quick scene graph }; QT_END_NAMESPACE |