diff options
Diffstat (limited to 'src/compositor')
40 files changed, 1032 insertions, 425 deletions
diff --git a/src/compositor/compositor.pro b/src/compositor/compositor.pro index dc9000d90..47be591d7 100644 --- a/src/compositor/compositor.pro +++ b/src/compositor/compositor.pro @@ -30,5 +30,7 @@ include ($$PWD/compositor_api/compositor_api.pri) include ($$PWD/extensions/extensions.pri) MODULE_PLUGIN_TYPES = \ - wayland-graphics-integration-server + wayland-graphics-integration-server \ + wayland-hardware-layer-integration \ + load(qt_module) 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 diff --git a/src/compositor/configure.json b/src/compositor/configure.json index a95c4eb01..21f486d78 100644 --- a/src/compositor/configure.json +++ b/src/compositor/configure.json @@ -22,6 +22,26 @@ "-lEGL" ] }, + "wayland-kms": { + "label": "wayland-kms", + "test": { + "tail": [ + "extern \"C\" {", + "#define private priv", + "#include <wayland-kms.h>", + "#undef private", + "}" + ], + "main": [ + "struct wl_resource *buffer = nullptr;", + "struct wl_kms_buffer *kmsBuffer = wayland_kms_buffer_get(buffer);" + ] + }, + "sources": [ + { "type": "pkgConfig", "args": "wayland-kms" }, + "-lwayland-kms" + ] + }, "xcomposite": { "test": "xcomposite", "sources": [ @@ -95,10 +115,22 @@ "label": "libhybris EGL", "condition": "features.wayland-server && features.opengl && features.egl && tests.libhybris-egl-server", "output": [ "privateFeature" ] + }, + "wayland-layer-integration-vsp2": { + "label": "VSP2 hardware layer integration", + "condition": "features.wayland-server && features.eglfs_vsp2 && libs.wayland-kms", + "output": [ "privateFeature" ] } }, "summary": [ - "wayland-server" + "wayland-server", + { + "section": "Qt Wayland Compositor Layer Plugins", + "condition": "features.wayland-server", + "entries": [ + "wayland-layer-integration-vsp2" + ] + } ] } diff --git a/src/compositor/doc/qtwaylandcompositor.qdocconf b/src/compositor/doc/qtwaylandcompositor.qdocconf index 73331aa09..f520c98ba 100644 --- a/src/compositor/doc/qtwaylandcompositor.qdocconf +++ b/src/compositor/doc/qtwaylandcompositor.qdocconf @@ -29,7 +29,7 @@ qhp.QtWaylandCompositor.subprojects.examples.indexTitle = Qt Wayland Composi qhp.QtWaylandCompositor.subprojects.examples.selectors = fake:example qhp.QtWaylandCompositor.subprojects.examples.sortPages = true -depends += qtqml qtquick qtdoc qtquickcontrols qmake qtgui +depends += qtcore qtqml qtquick qtdoc qtquickcontrols qmake qtgui exampledirs += ../../../examples/wayland headerdirs += .. diff --git a/src/compositor/extensions/extensions.pri b/src/compositor/extensions/extensions.pri index 9cb0bcfa1..68e473e14 100644 --- a/src/compositor/extensions/extensions.pri +++ b/src/compositor/extensions/extensions.pri @@ -2,7 +2,6 @@ CONFIG += wayland-scanner CONFIG += generated_privates WAYLANDSERVERSOURCES += \ - ../extensions/surface-extension.xml \ ../extensions/touch-extension.xml \ ../extensions/qtkey-extension.xml \ ../extensions/qt-windowmanager.xml \ @@ -12,7 +11,6 @@ WAYLANDSERVERSOURCES += \ ../3rdparty/protocol/ivi-application.xml \ HEADERS += \ - extensions/qwlextendedsurface_p.h \ extensions/qwlqttouch_p.h \ extensions/qwlqtkey_p.h \ extensions/qwaylandshell.h \ @@ -36,7 +34,6 @@ HEADERS += \ extensions/qwaylandivisurface_p.h \ SOURCES += \ - extensions/qwlextendedsurface.cpp \ extensions/qwlqttouch.cpp \ extensions/qwlqtkey.cpp \ extensions/qwaylandshell.cpp \ @@ -46,6 +43,7 @@ SOURCES += \ extensions/qwaylandqtwindowmanager.cpp \ extensions/qwaylandxdgshellv5.cpp \ extensions/qwaylandxdgshellv6.cpp \ + extensions/qwaylandshellsurface.cpp \ extensions/qwaylandiviapplication.cpp \ extensions/qwaylandivisurface.cpp \ diff --git a/src/compositor/extensions/qwaylandshellsurface.cpp b/src/compositor/extensions/qwaylandshellsurface.cpp new file mode 100644 index 000000000..c1cd5272e --- /dev/null +++ b/src/compositor/extensions/qwaylandshellsurface.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the config.tests 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 <QtWaylandCompositor/QWaylandShellSurface> + +/*! + * \qmltype ShellSurface + * \inqmlmodule QtWayland.Compositor + * \since 5.8 + * \brief Provides a common interface for surface roles specified by shell extensions + * + * This interface represents a Wayland surface role given by a Wayland protocol extension that + * defines how the WaylandSurface should map onto the screen. + * + * Note: Even though this type contains a very limited API, the properties and signals of the + * implementations are named consistently. For example, if you're only using desktop shell + * extensions in your compositor, it's safe to access properties such as title, maximized, etc. + * directly on the ShellSurface. See the various implementations for additional properties and + * signals. + * + * \sa WaylandSurface, ShellSurfaceItem, WlShellSurface, XdgSurfaceV5, IviSurface + */ + +/*! + * \class QWaylandShellSurface + * \inmodule QtWaylandCompositor + * \since 5.8 + * \brief The QWaylandShellSurface class is a common interface for surface roles specified by shell extensions + * + * This interface represents a Wayland surface role given by a Wayland protocol extension that + * defines how the QWaylandSurface should map onto the screen. + * + * \sa QWaylandSurface, QWaylandWlShellSurface, QWaylandXdgSurfaceV5, QWaylandIviSurface + */ + +#ifdef QT_WAYLAND_COMPOSITOR_QUICK +/*! + * \fn QWaylandQuickShellIntegration *QWaylandShellSurface::createIntegration(QWaylandQuickShellSurfaceItem *item) + * + * Creates a QWaylandQuickShellIntegration for this QWaylandQuickShellSurface. It's called + * automatically when QWaylandQuickShellSurfaceItem::shellSurface is assigned. + * + * \sa QWaylandQuickShellSurfaceItem + */ +#endif + +/*! + * \qmlproperty enum QtWaylandCompositor::ShellSurface::windowType + * + * This property holds the window type of the ShellSurface. + */ + +/*! + * \property QWaylandWlShellSurface::windowType + * + * This property holds the window type of the QWaylandShellSurface. + */ diff --git a/src/compositor/extensions/qwaylandwlshell.cpp b/src/compositor/extensions/qwaylandwlshell.cpp index 4cdbb0a3a..c588c1063 100644 --- a/src/compositor/extensions/qwaylandwlshell.cpp +++ b/src/compositor/extensions/qwaylandwlshell.cpp @@ -104,8 +104,8 @@ void QWaylandWlShellPrivate::unregisterShellSurface(QWaylandWlShellSurface *shel QWaylandWlShellSurfacePrivate::QWaylandWlShellSurfacePrivate() : QWaylandCompositorExtensionPrivate() , wl_shell_surface() - , m_shell(Q_NULLPTR) - , m_surface(Q_NULLPTR) + , m_shell(nullptr) + , m_surface(nullptr) , m_windowType(Qt::WindowType::Window) { } @@ -195,7 +195,7 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_fullscreen(Resource *resou Q_Q(QWaylandWlShellSurface); QWaylandOutput *output = output_resource ? QWaylandOutput::fromResource(output_resource) - : Q_NULLPTR; + : nullptr; setWindowType(Qt::WindowType::Window); emit q->setFullScreen(QWaylandWlShellSurface::FullScreenMethod(method), framerate, output); } @@ -220,7 +220,7 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_maximized(Resource *resour Q_Q(QWaylandWlShellSurface); QWaylandOutput *output = output_resource ? QWaylandOutput::fromResource(output_resource) - : Q_NULLPTR; + : nullptr; setWindowType(Qt::WindowType::Window); emit q->setMaximized(output); } diff --git a/src/compositor/extensions/qwlextendedsurface.cpp b/src/compositor/extensions/qwlextendedsurface.cpp deleted file mode 100644 index b0850f0e2..000000000 --- a/src/compositor/extensions/qwlextendedsurface.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module 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 "qwlextendedsurface_p.h" - -#include <QtWaylandCompositor/QWaylandCompositor> - -QT_BEGIN_NAMESPACE - -namespace QtWayland { - -SurfaceExtensionGlobal::SurfaceExtensionGlobal(QWaylandCompositor *compositor) - : QWaylandCompositorExtensionTemplate(compositor) - , QtWaylandServer::qt_surface_extension(compositor->display(), 1) -{ -} - -void SurfaceExtensionGlobal::surface_extension_get_extended_surface(Resource *resource, - uint32_t id, - struct wl_resource *surface_resource) -{ - QWaylandSurface *surface = QWaylandSurface::fromResource(surface_resource); - ExtendedSurface *extSurface = new ExtendedSurface(resource->client(),id, wl_resource_get_version(resource->handle), surface); - emit extendedSurfaceReady(extSurface, surface); -} - -ExtendedSurface::ExtendedSurface(struct wl_client *client, uint32_t id, int version, QWaylandSurface *surface) - : QWaylandCompositorExtensionTemplate(surface) - , QtWaylandServer::qt_extended_surface(client, id, version) - , m_surface(surface) - , m_windowFlags(0) -{ -} - -ExtendedSurface::~ExtendedSurface() -{ -} - -void ExtendedSurface::sendGenericProperty(const QString &name, const QVariant &variant) -{ - QByteArray byteValue; - QDataStream ds(&byteValue, QIODevice::WriteOnly); - ds << variant; - send_set_generic_property(name, byteValue); - -} - -void ExtendedSurface::sendOnScreenVisibilityChange(bool onScreen) -{ - setVisibility(onScreen ? QWindow::AutomaticVisibility : QWindow::Hidden); -} - -void ExtendedSurface::setVisibility(QWindow::Visibility visibility) -{ - send_onscreen_visibility(visibility); -} - -void ExtendedSurface::setParentSurface(QWaylandSurface *surface) -{ - m_surface = surface; -} - -void ExtendedSurface::extended_surface_update_generic_property(Resource *resource, - const QString &name, - struct wl_array *value) -{ - Q_UNUSED(resource); - QVariant variantValue; - QByteArray byteValue((const char*)value->data, value->size); - QDataStream ds(&byteValue, QIODevice::ReadOnly); - ds >> variantValue; - setWindowPropertyImpl(name,variantValue); -} - -Qt::ScreenOrientations ExtendedSurface::contentOrientationMask() const -{ - return m_contentOrientationMask; -} - -void ExtendedSurface::extended_surface_set_content_orientation_mask(Resource *resource, int32_t orientation) -{ - Q_UNUSED(resource); - Qt::ScreenOrientations mask = 0; - if (orientation & QT_EXTENDED_SURFACE_ORIENTATION_PORTRAITORIENTATION) - mask |= Qt::PortraitOrientation; - if (orientation & QT_EXTENDED_SURFACE_ORIENTATION_LANDSCAPEORIENTATION) - mask |= Qt::LandscapeOrientation; - if (orientation & QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDPORTRAITORIENTATION) - mask |= Qt::InvertedPortraitOrientation; - if (orientation & QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION) - mask |= Qt::InvertedLandscapeOrientation; - if (orientation & QT_EXTENDED_SURFACE_ORIENTATION_PRIMARYORIENTATION) - mask |= Qt::PrimaryOrientation; - - Qt::ScreenOrientations oldMask = m_contentOrientationMask; - m_contentOrientationMask = mask; - - if (mask != oldMask) - emit contentOrientationMaskChanged(); -} - -QVariantMap ExtendedSurface::windowProperties() const -{ - return m_windowProperties; -} - -QVariant ExtendedSurface::windowProperty(const QString &propertyName) const -{ - QVariantMap props = m_windowProperties; - return props.value(propertyName); -} - -void ExtendedSurface::setWindowProperty(const QString &name, const QVariant &value) -{ - setWindowPropertyImpl(name,value); - sendGenericProperty(name, value); -} - -void ExtendedSurface::setWindowPropertyImpl(const QString &name, const QVariant &value) -{ - m_windowProperties.insert(name, value); - emit windowPropertyChanged(name,value); -} - -void ExtendedSurface::extended_surface_set_window_flags(Resource *resource, int32_t flags) -{ - Q_UNUSED(resource); - WindowFlags windowFlags(flags); - if (windowFlags == m_windowFlags) - return; - m_windowFlags = windowFlags; - emit windowFlagsChanged(); -} - -void ExtendedSurface::extended_surface_destroy_resource(Resource *) -{ - delete this; -} - -void ExtendedSurface::extended_surface_raise(Resource *) -{ - emit raiseRequested(); -} - -void ExtendedSurface::extended_surface_lower(Resource *) -{ - emit lowerRequested(); -} - -} - -QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwlextendedsurface_p.h b/src/compositor/extensions/qwlextendedsurface_p.h deleted file mode 100644 index 8ad89619a..000000000 --- a/src/compositor/extensions/qwlextendedsurface_p.h +++ /dev/null @@ -1,159 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module 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 WLEXTENDEDSURFACE_H -#define WLEXTENDEDSURFACE_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 <wayland-server.h> - -#include <QtWaylandCompositor/private/qwayland-server-surface-extension.h> -#include <QtWaylandCompositor/qwaylandsurface.h> -#include <QtWaylandCompositor/qwaylandcompositorextension.h> - -#include <QtCore/QVariant> -#include <QtCore/QLinkedList> -#include <QtGui/QWindow> - -QT_BEGIN_NAMESPACE - -class QWaylandCompositor; -class QWaylandSurface; - -namespace QtWayland { - -class ExtendedSurface; - -class Q_WAYLAND_COMPOSITOR_EXPORT SurfaceExtensionGlobal : public QWaylandCompositorExtensionTemplate<SurfaceExtensionGlobal>, public QtWaylandServer::qt_surface_extension -{ - Q_OBJECT -public: - SurfaceExtensionGlobal(QWaylandCompositor *compositor); - -Q_SIGNALS: - void extendedSurfaceReady(ExtendedSurface *extSurface, QWaylandSurface *surface); - -private: - void surface_extension_get_extended_surface(Resource *resource, - uint32_t id, - struct wl_resource *surface); - -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT ExtendedSurface : public QWaylandCompositorExtensionTemplate<ExtendedSurface>, public QtWaylandServer::qt_extended_surface -{ - Q_OBJECT - Q_PROPERTY(Qt::ScreenOrientations contentOrientationMask READ contentOrientationMask NOTIFY contentOrientationMaskChanged) - Q_PROPERTY(WindowFlags windowFlags READ windowFlags NOTIFY windowFlagsChanged) - Q_FLAGS(WindowFlag WindowFlags) -public: - enum WindowFlag { - OverridesSystemGestures = 0x0001, - StaysOnTop = 0x0002, - BypassWindowManager = 0x0004 - }; - Q_DECLARE_FLAGS(WindowFlags, WindowFlag) - - ExtendedSurface(struct wl_client *client, uint32_t id, int version, QWaylandSurface *surface); - ~ExtendedSurface(); - - void sendGenericProperty(const QString &name, const QVariant &variant); - - void sendOnScreenVisibilityChange(bool onScreen); - void setVisibility(QWindow::Visibility visibility); - - void setParentSurface(QWaylandSurface *s); - - Qt::ScreenOrientations contentOrientationMask() const; - - WindowFlags windowFlags() const { return m_windowFlags; } - - QVariantMap windowProperties() const; - QVariant windowProperty(const QString &propertyName) const; - void setWindowProperty(const QString &name, const QVariant &value); - -Q_SIGNALS: - void contentOrientationMaskChanged(); - void windowFlagsChanged(); - void windowPropertyChanged(const QString &name, const QVariant &value); - void raiseRequested(); - void lowerRequested(); - -private: - void setWindowPropertyImpl(const QString &name, const QVariant &value); - - QWaylandSurface *m_surface; - - Qt::ScreenOrientations m_contentOrientationMask; - - WindowFlags m_windowFlags; - - QByteArray m_authenticationToken; - QVariantMap m_windowProperties; - - void extended_surface_update_generic_property(Resource *resource, - const QString &name, - struct wl_array *value) override; - - void extended_surface_set_content_orientation_mask(Resource *resource, - int32_t orientation) override; - - void extended_surface_set_window_flags(Resource *resource, - int32_t flags) override; - - void extended_surface_destroy_resource(Resource *) override; - void extended_surface_raise(Resource *) override; - void extended_surface_lower(Resource *) override; -}; - -} - -QT_END_NAMESPACE - -#endif // WLEXTENDEDSURFACE_H diff --git a/src/compositor/global/qwaylandcompositorextension.cpp b/src/compositor/global/qwaylandcompositorextension.cpp index 7b44dbde6..ee117bbae 100644 --- a/src/compositor/global/qwaylandcompositorextension.cpp +++ b/src/compositor/global/qwaylandcompositorextension.cpp @@ -146,7 +146,7 @@ QWaylandObject::QWaylandObject(QObjectPrivate &d, QObject *parent) QWaylandObject::~QWaylandObject() { foreach (QWaylandCompositorExtension *extension, extension_vector) - QWaylandCompositorExtensionPrivate::get(extension)->extension_container = Q_NULLPTR; + QWaylandCompositorExtensionPrivate::get(extension)->extension_container = nullptr; } QWaylandCompositorExtension *QWaylandObject::extension(const QByteArray &name) @@ -155,7 +155,7 @@ QWaylandCompositorExtension *QWaylandObject::extension(const QByteArray &name) if (extension_vector.at(i)->extensionInterface()->name == name) return extension_vector.at(i); } - return Q_NULLPTR; + return nullptr; } QWaylandCompositorExtension *QWaylandObject::extension(const wl_interface *interface) @@ -164,7 +164,7 @@ QWaylandCompositorExtension *QWaylandObject::extension(const wl_interface *inter if (extension_vector.at(i)->extensionInterface() == interface) return extension_vector.at(i); } - return Q_NULLPTR; + return nullptr; } QList<QWaylandCompositorExtension *> QWaylandObject::extensions() const diff --git a/src/compositor/global/qwaylandcompositorextension.h b/src/compositor/global/qwaylandcompositorextension.h index 73f8aab36..48fce0c96 100644 --- a/src/compositor/global/qwaylandcompositorextension.h +++ b/src/compositor/global/qwaylandcompositorextension.h @@ -114,7 +114,7 @@ public: static T *findIn(QWaylandObject *container) { - if (!container) return Q_NULLPTR; + if (!container) return nullptr; return qobject_cast<T *>(container->extension(T::interfaceName())); } diff --git a/src/compositor/global/qwaylandcompositorextension_p.h b/src/compositor/global/qwaylandcompositorextension_p.h index 56889cfab..68f817aa6 100644 --- a/src/compositor/global/qwaylandcompositorextension_p.h +++ b/src/compositor/global/qwaylandcompositorextension_p.h @@ -64,7 +64,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandCompositorExtensionPrivate : public QO public: QWaylandCompositorExtensionPrivate() : QObjectPrivate() - , extension_container(Q_NULLPTR) + , extension_container(nullptr) , initialized(false) { } diff --git a/src/compositor/hardware_integration/hardware_integration.pri b/src/compositor/hardware_integration/hardware_integration.pri index dd892e07a..6bf7a75b5 100644 --- a/src/compositor/hardware_integration/hardware_integration.pri +++ b/src/compositor/hardware_integration/hardware_integration.pri @@ -12,6 +12,9 @@ qtConfig(opengl) { hardware_integration/qwlserverbufferintegrationfactory_p.h \ hardware_integration/qwlserverbufferintegrationplugin_p.h \ hardware_integration/qwlhwintegration_p.h \ + hardware_integration/qwlhardwarelayerintegration_p.h \ + hardware_integration/qwlhardwarelayerintegrationfactory_p.h \ + hardware_integration/qwlhardwarelayerintegrationplugin_p.h \ SOURCES += \ hardware_integration/qwlclientbufferintegration.cpp \ @@ -21,6 +24,9 @@ qtConfig(opengl) { hardware_integration/qwlserverbufferintegrationfactory.cpp \ hardware_integration/qwlserverbufferintegrationplugin.cpp \ hardware_integration/qwlhwintegration.cpp \ + hardware_integration/qwlhardwarelayerintegration.cpp \ + hardware_integration/qwlhardwarelayerintegrationfactory.cpp \ + hardware_integration/qwlhardwarelayerintegrationplugin.cpp \ } else { system(echo "Qt-Compositor configured as raster only compositor") } diff --git a/src/compositor/hardware_integration/qwlhardwarelayerintegration.cpp b/src/compositor/hardware_integration/qwlhardwarelayerintegration.cpp new file mode 100644 index 000000000..76cf0990a --- /dev/null +++ b/src/compositor/hardware_integration/qwlhardwarelayerintegration.cpp @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWaylandCompositor module 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 "qwlhardwarelayerintegration_p.h" + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +} + +QT_END_NAMESPACE diff --git a/src/compositor/hardware_integration/qwlhardwarelayerintegration_p.h b/src/compositor/hardware_integration/qwlhardwarelayerintegration_p.h new file mode 100644 index 000000000..02de8e8be --- /dev/null +++ b/src/compositor/hardware_integration/qwlhardwarelayerintegration_p.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWaylandCompositor module 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 QWAYLANDHARDWARELAYERINTEGRATION_H +#define QWAYLANDHARDWARELAYERINTEGRATION_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/qtwaylandcompositorglobal.h> + +#include <QObject> +#include <QQmlParserStatus> + +QT_BEGIN_NAMESPACE + +class QPoint; + +class QWaylandQuickHardwareLayer; + +namespace QtWayland { + +class Q_WAYLAND_COMPOSITOR_EXPORT HardwareLayerIntegration : public QObject +{ + Q_OBJECT +public: + HardwareLayerIntegration(QObject *parent = nullptr) + : QObject(parent) + {} + ~HardwareLayerIntegration() override {} + virtual void add(QWaylandQuickHardwareLayer *) {} + virtual void remove(QWaylandQuickHardwareLayer *) {} +}; + +} // namespace QtWayland + +QT_END_NAMESPACE + +#endif // QWAYLANDHARDWARELAYERINTEGRATION_H diff --git a/src/compositor/hardware_integration/qwlhardwarelayerintegrationfactory.cpp b/src/compositor/hardware_integration/qwlhardwarelayerintegrationfactory.cpp new file mode 100644 index 000000000..4b85be820 --- /dev/null +++ b/src/compositor/hardware_integration/qwlhardwarelayerintegrationfactory.cpp @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWaylandCompositor module 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 "qwlhardwarelayerintegrationfactory_p.h" +#include "qwlhardwarelayerintegrationplugin_p.h" +#include "qwlhardwarelayerintegration_p.h" + +#include <QtCore/private/qfactoryloader_p.h> +#include <QtCore/QCoreApplication> +#include <QtCore/QDir> + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +#if QT_CONFIG(library) +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, + (QtWaylandHardwareLayerIntegrationFactoryInterface_iid, QLatin1String("/wayland-hardware-layer-integration"), Qt::CaseInsensitive)) +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, + (QtWaylandHardwareLayerIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive)) +#endif + +QStringList HardwareLayerIntegrationFactory::keys(const QString &pluginPath) +{ +#if QT_CONFIG(library) + QStringList list; + if (!pluginPath.isEmpty()) { + QCoreApplication::addLibraryPath(pluginPath); + list = directLoader()->keyMap().values(); + if (!list.isEmpty()) { + const QString postFix = QStringLiteral(" (from ") + + QDir::toNativeSeparators(pluginPath) + + QLatin1Char(')'); + const QStringList::iterator end = list.end(); + for (QStringList::iterator it = list.begin(); it != end; ++it) + (*it).append(postFix); + } + } + list.append(loader()->keyMap().values()); + return list; +#else + return QStringList(); +#endif +} + +HardwareLayerIntegration *HardwareLayerIntegrationFactory::create(const QString &name, const QStringList &args, const QString &pluginPath) +{ +#if QT_CONFIG(library) + // Try loading the plugin from platformPluginPath first: + if (!pluginPath.isEmpty()) { + QCoreApplication::addLibraryPath(pluginPath); + if (HardwareLayerIntegration *ret = qLoadPlugin<HardwareLayerIntegration, HardwareLayerIntegrationPlugin>(directLoader(), name, args)) + return ret; + } + if (HardwareLayerIntegration *ret = qLoadPlugin<HardwareLayerIntegration, HardwareLayerIntegrationPlugin>(loader(), name, args)) + return ret; +#endif + return nullptr; +} + +} + +QT_END_NAMESPACE diff --git a/src/compositor/hardware_integration/qwlhardwarelayerintegrationfactory_p.h b/src/compositor/hardware_integration/qwlhardwarelayerintegrationfactory_p.h new file mode 100644 index 000000000..83c9c523b --- /dev/null +++ b/src/compositor/hardware_integration/qwlhardwarelayerintegrationfactory_p.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWaylandCompositor module 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 QWAYLANDHARDWARELAYERINTEGRATIONFACTORY_H +#define QWAYLANDHARDWARELAYERINTEGRATIONFACTORY_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/qtwaylandcompositorglobal.h> +#include <QtCore/QStringList> + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +class HardwareLayerIntegration; + +class Q_WAYLAND_COMPOSITOR_EXPORT HardwareLayerIntegrationFactory +{ +public: + static QStringList keys(const QString &pluginPath = QString()); + static HardwareLayerIntegration *create(const QString &name, const QStringList &args, const QString &pluginPath = QString()); +}; + +} + +QT_END_NAMESPACE + +#endif // QWAYLANDHARDWARELAYERINTEGRATIONFACTORY_H diff --git a/src/compositor/hardware_integration/qwlhardwarelayerintegrationplugin.cpp b/src/compositor/hardware_integration/qwlhardwarelayerintegrationplugin.cpp new file mode 100644 index 000000000..0ae3a0b6a --- /dev/null +++ b/src/compositor/hardware_integration/qwlhardwarelayerintegrationplugin.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWaylandCompositor module 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 "qwlhardwarelayerintegrationplugin_p.h" + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +HardwareLayerIntegrationPlugin::HardwareLayerIntegrationPlugin(QObject *parent) : + QObject(parent) +{ +} + +HardwareLayerIntegrationPlugin::~HardwareLayerIntegrationPlugin() +{ +} + +} + +QT_END_NAMESPACE diff --git a/src/compositor/hardware_integration/qwlhardwarelayerintegrationplugin_p.h b/src/compositor/hardware_integration/qwlhardwarelayerintegrationplugin_p.h new file mode 100644 index 000000000..acf80fe33 --- /dev/null +++ b/src/compositor/hardware_integration/qwlhardwarelayerintegrationplugin_p.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWaylandCompositor module 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 QWAYLANDHARDWARELAYERINTEGRATIONPLUGIN_H +#define QWAYLANDHARDWARELAYERINTEGRATIONPLUGIN_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/qtwaylandcompositorglobal.h> + +#include <QtCore/qplugin.h> +#include <QtCore/qfactoryinterface.h> + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +class HardwareLayerIntegration; + +#define QtWaylandHardwareLayerIntegrationFactoryInterface_iid "org.qt-project.Qt.Compositor.QtWaylandHardwareLayerIntegrationFactoryInterface.5.11" + +class Q_WAYLAND_COMPOSITOR_EXPORT HardwareLayerIntegrationPlugin : public QObject +{ + Q_OBJECT +public: + explicit HardwareLayerIntegrationPlugin(QObject *parent = nullptr); + ~HardwareLayerIntegrationPlugin() override; + + virtual HardwareLayerIntegration *create(const QString &key, const QStringList ¶mList) = 0; +}; + +} + +QT_END_NAMESPACE + +#endif // QWAYLANDHARDWARELAYERINTEGRATIONPLUGIN_H |