summaryrefslogtreecommitdiffstats
path: root/src/compositor/compositor_api
diff options
context:
space:
mode:
Diffstat (limited to 'src/compositor/compositor_api')
-rw-r--r--src/compositor/compositor_api/compositor_api.pri10
-rw-r--r--src/compositor/compositor_api/qwaylandbufferref.cpp89
-rw-r--r--src/compositor/compositor_api/qwaylandbufferref.h44
-rw-r--r--src/compositor/compositor_api/qwaylandclient.cpp61
-rw-r--r--src/compositor/compositor_api/qwaylandclient.h56
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor.cpp309
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor.h81
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor_p.h57
-rw-r--r--src/compositor/compositor_api/qwaylandcompositorquickextensions.cpp10
-rw-r--r--src/compositor/compositor_api/qwaylandcompositorquickextensions_p.h94
-rw-r--r--src/compositor/compositor_api/qwaylanddestroylistener.cpp32
-rw-r--r--src/compositor/compositor_api/qwaylanddestroylistener.h34
-rw-r--r--src/compositor/compositor_api/qwaylanddestroylistener_p.h30
-rw-r--r--src/compositor/compositor_api/qwaylanddrag.cpp32
-rw-r--r--src/compositor/compositor_api/qwaylanddrag.h37
-rw-r--r--src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp128
-rw-r--r--src/compositor/compositor_api/qwaylandinputmethodcontrol.h34
-rw-r--r--src/compositor/compositor_api/qwaylandinputmethodcontrol_p.h36
-rw-r--r--src/compositor/compositor_api/qwaylandkeyboard.cpp123
-rw-r--r--src/compositor/compositor_api/qwaylandkeyboard.h34
-rw-r--r--src/compositor/compositor_api/qwaylandkeyboard_p.h49
-rw-r--r--src/compositor/compositor_api/qwaylandkeymap.cpp32
-rw-r--r--src/compositor/compositor_api/qwaylandkeymap.h39
-rw-r--r--src/compositor/compositor_api/qwaylandkeymap_p.h32
-rw-r--r--src/compositor/compositor_api/qwaylandmousetracker.cpp143
-rw-r--r--src/compositor/compositor_api/qwaylandmousetracker_p.h63
-rw-r--r--src/compositor/compositor_api/qwaylandoutput.cpp63
-rw-r--r--src/compositor/compositor_api/qwaylandoutput.h46
-rw-r--r--src/compositor/compositor_api/qwaylandoutput_p.h48
-rw-r--r--src/compositor/compositor_api/qwaylandoutputmode.cpp30
-rw-r--r--src/compositor/compositor_api/qwaylandoutputmode.h32
-rw-r--r--src/compositor/compositor_api/qwaylandoutputmode_p.h33
-rw-r--r--src/compositor/compositor_api/qwaylandpointer.cpp41
-rw-r--r--src/compositor/compositor_api/qwaylandpointer.h32
-rw-r--r--src/compositor/compositor_api/qwaylandpointer_p.h36
-rw-r--r--src/compositor/compositor_api/qwaylandquickchildren.h38
-rw-r--r--src/compositor/compositor_api/qwaylandquickcompositor.cpp50
-rw-r--r--src/compositor/compositor_api/qwaylandquickcompositor.h34
-rw-r--r--src/compositor/compositor_api/qwaylandquickhardwarelayer.cpp45
-rw-r--r--src/compositor/compositor_api/qwaylandquickhardwarelayer_p.h38
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem.cpp601
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem.h53
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem_p.h69
-rw-r--r--src/compositor/compositor_api/qwaylandquickoutput.cpp36
-rw-r--r--src/compositor/compositor_api/qwaylandquickoutput.h38
-rw-r--r--src/compositor/compositor_api/qwaylandquicksurface.cpp81
-rw-r--r--src/compositor/compositor_api/qwaylandquicksurface.h42
-rw-r--r--src/compositor/compositor_api/qwaylandquicksurface_p.h40
-rw-r--r--src/compositor/compositor_api/qwaylandresource.cpp57
-rw-r--r--src/compositor/compositor_api/qwaylandresource.h36
-rw-r--r--src/compositor/compositor_api/qwaylandseat.cpp207
-rw-r--r--src/compositor/compositor_api/qwaylandseat.h50
-rw-r--r--src/compositor/compositor_api/qwaylandseat_p.h32
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.cpp232
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.h73
-rw-r--r--src/compositor/compositor_api/qwaylandsurface_p.h46
-rw-r--r--src/compositor/compositor_api/qwaylandsurfacegrabber.cpp32
-rw-r--r--src/compositor/compositor_api/qwaylandsurfacegrabber.h32
-rw-r--r--src/compositor/compositor_api/qwaylandtouch.cpp45
-rw-r--r--src/compositor/compositor_api/qwaylandtouch.h32
-rw-r--r--src/compositor/compositor_api/qwaylandtouch_p.h35
-rw-r--r--src/compositor/compositor_api/qwaylandview.cpp42
-rw-r--r--src/compositor/compositor_api/qwaylandview.h33
-rw-r--r--src/compositor/compositor_api/qwaylandview_p.h30
64 files changed, 2001 insertions, 2228 deletions
diff --git a/src/compositor/compositor_api/compositor_api.pri b/src/compositor/compositor_api/compositor_api.pri
index bbc3a03e7..d8cfcaad3 100644
--- a/src/compositor/compositor_api/compositor_api.pri
+++ b/src/compositor/compositor_api/compositor_api.pri
@@ -27,8 +27,7 @@ HEADERS += \
compositor_api/qwaylandview_p.h \
compositor_api/qwaylandresource.h \
compositor_api/qwaylandsurfacegrabber.h \
- compositor_api/qwaylandoutputmode_p.h \
- compositor_api/qwaylandquickchildren.h
+ compositor_api/qwaylandoutputmode_p.h
SOURCES += \
compositor_api/qwaylandcompositor.cpp \
@@ -55,7 +54,7 @@ qtConfig(im) {
compositor_api/qwaylandinputmethodcontrol.cpp
}
-QT += core-private
+QT += core-private gui-private
qtConfig(draganddrop) {
HEADERS += \
@@ -66,14 +65,19 @@ qtConfig(draganddrop) {
qtConfig(wayland-compositor-quick) {
SOURCES += \
+ compositor_api/qwaylandmousetracker.cpp \
compositor_api/qwaylandquickcompositor.cpp \
compositor_api/qwaylandquicksurface.cpp \
compositor_api/qwaylandquickoutput.cpp \
compositor_api/qwaylandquickitem.cpp
HEADERS += \
+ compositor_api/qwaylandcompositorquickextensions_p.h \
+ compositor_api/qwaylandmousetracker_p.h \
+ compositor_api/qwaylandquickchildren.h \
compositor_api/qwaylandquickcompositor.h \
compositor_api/qwaylandquicksurface.h \
+ compositor_api/qwaylandquicksurface_p.h \
compositor_api/qwaylandquickoutput.h \
compositor_api/qwaylandquickitem.h \
compositor_api/qwaylandquickitem_p.h
diff --git a/src/compositor/compositor_api/qwaylandbufferref.cpp b/src/compositor/compositor_api/qwaylandbufferref.cpp
index d7f6c43bb..556bc0925 100644
--- a/src/compositor/compositor_api/qwaylandbufferref.cpp
+++ b/src/compositor/compositor_api/qwaylandbufferref.cpp
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QDebug>
#include <QAtomicInt>
@@ -33,8 +7,34 @@
#include "qwaylandbufferref.h"
#include "wayland_wrapper/qwlclientbuffer_p.h"
+#include <type_traits>
+
QT_BEGIN_NAMESPACE
+#define CHECK1(l, r, op) \
+ static_assert(std::is_same_v< \
+ bool, \
+ decltype(std::declval<QWaylandBufferRef l >() op \
+ std::declval<QWaylandBufferRef r >()) \
+ >)
+#define CHECK2(l, r) \
+ CHECK1(l, r, ==); \
+ CHECK1(l, r, !=)
+#define CHECK(l, r) \
+ CHECK2(l, r); \
+ CHECK2(l &, r); \
+ CHECK2(l &, r &); \
+ CHECK2(l, r &)
+
+CHECK(, );
+CHECK(const, );
+CHECK(const, const);
+CHECK(, const);
+
+#undef CHECK
+#undef CHECK2
+#undef CHECK1
+
class QWaylandBufferRefPrivate
{
public:
@@ -114,22 +114,22 @@ QWaylandBufferRef &QWaylandBufferRef::operator=(const QWaylandBufferRef &ref)
}
/*!
- * Returns true if this QWaylandBufferRef references the same buffer as \a ref.
- * Otherwise returns false.
+ \fn bool QWaylandBufferRef::operator==(const QWaylandBufferRef &lhs, const QWaylandBufferRef &rhs)
+
+ Returns \c true if \a lhs references the same buffer as \a rhs.
+ Otherwise returns \c{false}.
*/
-bool QWaylandBufferRef::operator==(const QWaylandBufferRef &ref)
+bool operator==(const QWaylandBufferRef &lhs, const QWaylandBufferRef &rhs) noexcept
{
- return d->buffer == ref.d->buffer;
+ return lhs.d->buffer == rhs.d->buffer;
}
/*!
- * Returns false if this QWaylandBufferRef references the same buffer as \a ref.
- * Otherwise returns true.
+ \fn bool QWaylandBufferRef::operator!=(const QWaylandBufferRef &lhs, const QWaylandBufferRef &rhs)
+
+ Returns \c false if \a lhs references the same buffer as \a rhs.
+ Otherwise returns \c {true}.
*/
-bool QWaylandBufferRef::operator!=(const QWaylandBufferRef &ref)
-{
- return d->buffer != ref.d->buffer;
-}
/*!
* Returns true if this QWaylandBufferRef does not reference a buffer.
@@ -160,6 +160,19 @@ bool QWaylandBufferRef::hasContent() const
{
return QtWayland::ClientBuffer::hasContent(d->buffer);
}
+/*!
+ * Returns true if this QWaylandBufferRef references a buffer that has protected content. Otherwise returns false.
+ *
+ * \note This is an enabler which presumes support in the client buffer integration. None of the
+ * client buffer integrations included with Qt currently support protected content buffers.
+ *
+ * \since 6.2
+ * \sa hasContent()
+ */
+bool QWaylandBufferRef::hasProtectedContent() const
+{
+ return QtWayland::ClientBuffer::hasProtectedContent(d->buffer);
+}
/*!
* Returns true if this QWaylandBufferRef references a buffer that
diff --git a/src/compositor/compositor_api/qwaylandbufferref.h b/src/compositor/compositor_api/qwaylandbufferref.h
index b1aaf5f19..a917726f0 100644
--- a/src/compositor/compositor_api/qwaylandbufferref.h
+++ b/src/compositor/compositor_api/qwaylandbufferref.h
@@ -1,44 +1,17 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDBUFFERREF_H
#define QWAYLANDBUFFERREF_H
#include <QtWaylandCompositor/qtwaylandcompositorglobal.h>
-#include <QImage>
+#include <QtGui/QImage>
#if QT_CONFIG(opengl)
#include <QtGui/qopengl.h>
#endif
#include <QtWaylandCompositor/QWaylandSurface>
-#include <QtWaylandCompositor/qtwaylandcompositorglobal.h>
struct wl_resource;
@@ -51,7 +24,7 @@ namespace QtWayland
class ClientBuffer;
}
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandBufferRef
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandBufferRef
{
public:
QWaylandBufferRef();
@@ -62,9 +35,12 @@ public:
bool isNull() const;
bool hasBuffer() const;
bool hasContent() const;
+ bool hasProtectedContent() const;
bool isDestroyed() const;
+#if QT_WAYLANDCOMPOSITOR_REMOVED_SINCE(6, 3)
bool operator==(const QWaylandBufferRef &ref);
bool operator!=(const QWaylandBufferRef &ref);
+#endif
struct wl_resource *wl_buffer() const;
@@ -106,6 +82,12 @@ private:
class QWaylandBufferRefPrivate *const d;
friend class QWaylandBufferRefPrivate;
friend class QWaylandSurfacePrivate;
+
+ friend Q_WAYLANDCOMPOSITOR_EXPORT
+ bool operator==(const QWaylandBufferRef &lhs, const QWaylandBufferRef &rhs) noexcept;
+ friend inline
+ bool operator!=(const QWaylandBufferRef &lhs, const QWaylandBufferRef &rhs) noexcept
+ { return !(lhs == rhs); }
};
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandclient.cpp b/src/compositor/compositor_api/qwaylandclient.cpp
index 2dba85faf..9c8bc704f 100644
--- a/src/compositor/compositor_api/qwaylandclient.cpp
+++ b/src/compositor/compositor_api/qwaylandclient.cpp
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qwaylandclient.h"
#include <QtCore/private/qobject_p.h>
@@ -75,10 +49,13 @@ public:
QWaylandClient *parent = nullptr;
};
Listener listener;
+
+ QWaylandClient::TextInputProtocols mTextInputProtocols = QWaylandClient::NoProtocol;
};
/*!
* \qmltype WaylandClient
+ * \instantiates QWaylandClient
* \inqmlmodule QtWayland.Compositor
* \since 5.8
* \brief Represents a client connecting to the WaylandCompositor.
@@ -157,7 +134,7 @@ QWaylandClient *QWaylandClient::fromWlClient(QWaylandCompositor *compositor, wl_
}
/*!
- * \qmlproperty WaylandCompositor QtWaylandCompositor::WaylandClient::compositor
+ * \qmlproperty WaylandCompositor QtWayland.Compositor::WaylandClient::compositor
*
* This property holds the compositor of this WaylandClient.
*/
@@ -185,7 +162,7 @@ wl_client *QWaylandClient::client() const
}
/*!
- * \qmlproperty int QtWaylandCompositor::WaylandClient::userId
+ * \qmlproperty int QtWayland.Compositor::WaylandClient::userId
*
* This property holds the user id of this WaylandClient.
*/
@@ -204,7 +181,7 @@ qint64 QWaylandClient::userId() const
}
/*!
- * \qmlproperty int QtWaylandCompositor::WaylandClient::groupId
+ * \qmlproperty int QtWayland.Compositor::WaylandClient::groupId
* \readonly
*
* This property holds the group id of this WaylandClient.
@@ -223,7 +200,7 @@ qint64 QWaylandClient::groupId() const
}
/*!
- * \qmlproperty int QtWaylandCompositor::WaylandClient::processId
+ * \qmlproperty int QtWayland.Compositor::WaylandClient::processId
* \readonly
*
* This property holds the process id of this WaylandClient.
@@ -242,7 +219,7 @@ qint64 QWaylandClient::processId() const
}
/*!
- * \qmlmethod void QtWaylandCompositor::WaylandClient::kill(signal)
+ * \qmlmethod void QtWayland.Compositor::WaylandClient::kill(signal)
*
* Kills the client with the specified \a signal.
*/
@@ -258,7 +235,7 @@ void QWaylandClient::kill(int signal)
}
/*!
- * \qmlmethod void QtWaylandCompositor::WaylandClient::close()
+ * \qmlmethod void QtWayland.Compositor::WaylandClient::close()
*
* Closes the client
*/
@@ -272,4 +249,20 @@ void QWaylandClient::close()
d->compositor->destroyClient(this);
}
+QWaylandClient::TextInputProtocols QWaylandClient::textInputProtocols() const
+{
+ Q_D(const QWaylandClient);
+ return d->mTextInputProtocols;
+}
+
+void QWaylandClient::setTextInputProtocols(TextInputProtocols p)
+{
+ Q_D(QWaylandClient);
+ if (d->mTextInputProtocols != p)
+ d->mTextInputProtocols = p;
+}
+
QT_END_NAMESPACE
+
+#include "moc_qwaylandclient.cpp"
+
diff --git a/src/compositor/compositor_api/qwaylandclient.h b/src/compositor/compositor_api/qwaylandclient.h
index 8f52244c1..fd6172a4f 100644
--- a/src/compositor/compositor_api/qwaylandclient.h
+++ b/src/compositor/compositor_api/qwaylandclient.h
@@ -1,38 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDCLIENT_H
#define QWAYLANDCLIENT_H
#include <QtWaylandCompositor/qtwaylandcompositorglobal.h>
+#include <QtWaylandCompositor/qtwaylandqmlinclude.h>
-#include <QObject>
+#include <QtCore/QObject>
#include <signal.h>
@@ -43,7 +18,7 @@ QT_BEGIN_NAMESPACE
class QWaylandClientPrivate;
class QWaylandCompositor;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandClient : public QObject
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandClient : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandClient)
@@ -52,9 +27,30 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandClient : public QObject
Q_PROPERTY(qint64 userId READ userId CONSTANT)
Q_PROPERTY(qint64 groupId READ groupId CONSTANT)
Q_PROPERTY(qint64 processId READ processId CONSTANT)
+ Q_MOC_INCLUDE("qwaylandcompositor.h")
+
+ QML_NAMED_ELEMENT(WaylandClient)
+ QML_ADDED_IN_VERSION(1, 0)
+ QML_UNCREATABLE("")
public:
~QWaylandClient() override;
+ enum TextInputProtocol {
+ NoProtocol = 0,
+ QtTextInputMethodV1 = 1,
+ TextInputV2 = 2,
+ TextInputV3 = 4,
+
+ TextInputV4 = TextInputV3, // TextInputV4 was an experimental API that is now deprecated
+
+ QtTextInputMethod = QtTextInputMethodV1,
+ TextInput = TextInputV2
+ };
+ Q_DECLARE_FLAGS(TextInputProtocols, TextInputProtocol)
+
+ TextInputProtocols textInputProtocols() const;
+ void setTextInputProtocols(TextInputProtocols p);
+
static QWaylandClient *fromWlClient(QWaylandCompositor *compositor, wl_client *wlClient);
QWaylandCompositor *compositor() const;
diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp
index b75ead7bd..e6f5955b8 100644
--- a/src/compositor/compositor_api/qwaylandcompositor.cpp
+++ b/src/compositor/compositor_api/qwaylandcompositor.cpp
@@ -1,32 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qtwaylandcompositorglobal_p.h"
#include "qwaylandcompositor.h"
@@ -67,6 +41,7 @@
#include <QtCore/QCoreApplication>
#include <QtCore/QStringList>
#include <QtCore/QSocketNotifier>
+#include <QStandardPaths>
#include <QtGui/QDesktopServices>
#include <QtGui/QScreen>
@@ -88,6 +63,7 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(qLcWaylandCompositor, "qt.waylandcompositor")
Q_LOGGING_CATEGORY(qLcWaylandCompositorHardwareIntegration, "qt.waylandcompositor.hardwareintegration")
Q_LOGGING_CATEGORY(qLcWaylandCompositorInputMethods, "qt.waylandcompositor.inputmethods")
+Q_LOGGING_CATEGORY(qLcWaylandCompositorTextInput, "qt.waylandcompositor.textinput")
namespace QtWayland {
@@ -114,14 +90,25 @@ public:
QWaylandKeyboardPrivate *keyb = QWaylandKeyboardPrivate::get(seat->keyboard());
+#if defined(Q_OS_QNX)
+ // The QNX platform plugin delivers scan codes that haven't been adjusted to be
+ // xkbcommon compatible. xkbcommon requires that the scan codes be bumped up by
+ // 8 because that's how evdev/XKB deliver scan codes. You might think that it
+ // would've been better to remove this (odd) requirement from xkbcommon on QNX
+ // but it turns out that conforming to it has much less impact.
+ static int offset = QGuiApplication::platformName() == QStringLiteral("qnx") ? 8 : 0;
+ ke->nativeScanCode += offset;
+#endif
uint32_t code = ke->nativeScanCode;
+ if (code == 0)
+ code = seat->keyboard()->keyToScanCode(ke->key);
bool isDown = ke->keyType == QEvent::KeyPress;
#if QT_CONFIG(xkbcommon)
xkb_state *xkbState = keyb->xkbState();
- Qt::KeyboardModifiers modifiers = QXkbCommon::modifiers(xkbState);
const xkb_keysym_t sym = xkb_state_key_get_one_sym(xkbState, code);
+ Qt::KeyboardModifiers modifiers = QXkbCommon::modifiers(xkbState, sym);
int qtkey = QXkbCommon::keysymToQtKey(sym, modifiers, xkbState, code);
QString text = QXkbCommon::lookupString(xkbState, code);
@@ -149,6 +136,9 @@ public:
QWaylandCompositorPrivate::QWaylandCompositorPrivate(QWaylandCompositor *compositor)
{
+ // Create XDG_RUNTIME_DIR, if it does not already exist
+ QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+
if (QGuiApplication::platformNativeInterface())
display = static_cast<wl_display*>(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("server_wl_display"));
@@ -180,8 +170,10 @@ void QWaylandCompositorPrivate::init()
const int socketArg = arguments.indexOf(QLatin1String("--wayland-socket-name"));
if (socketArg != -1 && socketArg + 1 < arguments.size())
socket_name = arguments.at(socketArg + 1).toLocal8Bit();
+ if (socket_name.isEmpty())
+ socket_name = qgetenv("WAYLAND_DISPLAY");
}
- wl_compositor::init(display, 3);
+ wl_compositor::init(display, 4);
wl_subcompositor::init(display, 1);
#if QT_CONFIG(wayland_datadevice)
@@ -190,9 +182,9 @@ void QWaylandCompositorPrivate::init()
buffer_manager = new QtWayland::BufferManager(q);
wl_display_init_shm(display);
- const QVector<wl_shm_format> formats = QWaylandSharedMemoryFormatHelper::supportedWaylandFormats();
- for (wl_shm_format format : formats)
- wl_display_add_shm_format(display, format);
+
+ for (QWaylandCompositor::ShmFormat format : shmFormats)
+ wl_display_add_shm_format(display, wl_shm_format(format));
if (!socket_name.isEmpty()) {
if (wl_display_add_socket(display, socket_name.constData()))
@@ -205,26 +197,29 @@ void QWaylandCompositorPrivate::init()
emit q->socketNameChanged(socket_name);
}
-#if WAYLAND_VERSION_MAJOR >= 1 && (WAYLAND_VERSION_MAJOR != 1 || WAYLAND_VERSION_MINOR >= 10)
connectToExternalSockets();
-#endif
loop = wl_display_get_event_loop(display);
int fd = wl_event_loop_get_fd(loop);
QSocketNotifier *sockNot = new QSocketNotifier(fd, QSocketNotifier::Read, q);
- QObject::connect(sockNot, SIGNAL(activated(int)), q, SLOT(processWaylandEvents()));
+ QObject::connect(sockNot, SIGNAL(activated(QSocketDescriptor)), q, SLOT(processWaylandEvents()));
QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
QObject::connect(dispatcher, SIGNAL(aboutToBlock()), q, SLOT(processWaylandEvents()));
+ QObject::connect(static_cast<QGuiApplication *>(QGuiApplication::instance()),
+ &QGuiApplication::applicationStateChanged,
+ q,
+ &QWaylandCompositor::applicationStateChanged);
+
initializeHardwareIntegration();
initializeSeats();
initialized = true;
- for (const QPointer<QObject> &object : qExchange(polish_objects, {})) {
+ for (const QPointer<QObject> &object : std::exchange(polish_objects, {})) {
if (object) {
QEvent polishEvent(QEvent::Polish);
QCoreApplication::sendEvent(object.data(), &polishEvent);
@@ -236,18 +231,19 @@ void QWaylandCompositorPrivate::init()
QWaylandCompositorPrivate::~QWaylandCompositorPrivate()
{
- qDeleteAll(clients);
+ // Take copies, since the lists will get modified as elements are deleted
+ const auto clientsToDelete = clients;
+ qDeleteAll(clientsToDelete);
- qDeleteAll(outputs);
+ const auto outputsToDelete = outputs;
+ qDeleteAll(outputsToDelete);
#if QT_CONFIG(wayland_datadevice)
delete data_device_manager;
#endif
-#if QT_CONFIG(opengl)
// Some client buffer integrations need to clean up before the destroying the wl_display
- client_buffer_integration.reset();
-#endif
+ qDeleteAll(client_buffer_integrations);
if (ownsDisplay)
wl_display_destroy(display);
@@ -296,17 +292,15 @@ void QWaylandCompositorPrivate::addPolishObject(QObject *object)
}
}
-#if WAYLAND_VERSION_MAJOR >= 1 && (WAYLAND_VERSION_MAJOR != 1 || WAYLAND_VERSION_MINOR >= 10)
void QWaylandCompositorPrivate::connectToExternalSockets()
{
// Clear out any backlog of user-supplied external socket descriptors
- for (int fd : qAsConst(externally_added_socket_fds)) {
+ for (int fd : std::as_const(externally_added_socket_fds)) {
if (wl_display_add_socket_fd(display, fd) != 0)
qWarning() << "Failed to integrate user-supplied socket fd into the Wayland event loop";
}
externally_added_socket_fds.clear();
}
-#endif
void QWaylandCompositorPrivate::compositor_create_surface(wl_compositor::Resource *resource, uint32_t id)
{
@@ -355,9 +349,28 @@ QWaylandSurface *QWaylandCompositorPrivate::createDefaultSurface()
return new QWaylandSurface();
}
+class SharedMemoryClientBufferIntegration : public QtWayland::ClientBufferIntegration
+{
+public:
+ void initializeHardware(wl_display *display) override;
+ QtWayland::ClientBuffer *createBufferFor(wl_resource *buffer) override;
+};
+
+void SharedMemoryClientBufferIntegration::initializeHardware(wl_display *)
+{
+}
+
+QtWayland::ClientBuffer *SharedMemoryClientBufferIntegration::createBufferFor(wl_resource *buffer)
+{
+ if (wl_shm_buffer_get(buffer))
+ return new QtWayland::SharedMemoryBuffer(buffer);
+ return nullptr;
+}
void QWaylandCompositorPrivate::initializeHardwareIntegration()
{
+ client_buffer_integrations.prepend(new SharedMemoryClientBufferIntegration); // TODO: clean up the opengl dependency
+
#if QT_CONFIG(opengl)
Q_Q(QWaylandCompositor);
if (use_hw_integration_extension)
@@ -365,12 +378,15 @@ void QWaylandCompositorPrivate::initializeHardwareIntegration()
loadClientBufferIntegration();
loadServerBufferIntegration();
+
+ for (auto *integration : std::as_const(client_buffer_integrations))
+ integration->initializeHardware(display);
#endif
}
void QWaylandCompositorPrivate::initializeSeats()
{
- for (QWaylandSeat *seat : qAsConst(seats))
+ for (QWaylandSeat *seat : std::as_const(seats))
seat->initialize();
}
@@ -379,47 +395,40 @@ void QWaylandCompositorPrivate::loadClientBufferIntegration()
#if QT_CONFIG(opengl)
Q_Q(QWaylandCompositor);
QStringList keys = QtWayland::ClientBufferIntegrationFactory::keys();
- QString targetKey;
+ QStringList targetKeys;
QByteArray clientBufferIntegration = qgetenv("QT_WAYLAND_HARDWARE_INTEGRATION");
if (clientBufferIntegration.isEmpty())
clientBufferIntegration = qgetenv("QT_WAYLAND_CLIENT_BUFFER_INTEGRATION");
- if (keys.contains(QString::fromLocal8Bit(clientBufferIntegration.constData()))) {
- targetKey = QString::fromLocal8Bit(clientBufferIntegration.constData());
- } else if (keys.contains(QString::fromLatin1("wayland-egl"))) {
- targetKey = QString::fromLatin1("wayland-egl");
- } else if (!keys.isEmpty()) {
- targetKey = keys.first();
+
+ for (auto b : clientBufferIntegration.split(';')) {
+ QString s = QString::fromLocal8Bit(b);
+ if (keys.contains(s))
+ targetKeys.append(s);
}
- if (!targetKey.isEmpty()) {
- client_buffer_integration.reset(QtWayland::ClientBufferIntegrationFactory::create(targetKey, QStringList()));
- if (client_buffer_integration) {
- qCDebug(qLcWaylandCompositorHardwareIntegration) << "Loaded client buffer integration:" << targetKey;
- client_buffer_integration->setCompositor(q);
- if (!client_buffer_integration->initializeHardware(display)) {
- qCWarning(qLcWaylandCompositorHardwareIntegration)
- << "Failed to initialize hardware for client buffer integration:" << targetKey;
- client_buffer_integration.reset();
- }
- } else {
- qCWarning(qLcWaylandCompositorHardwareIntegration)
- << "Failed to load client buffer integration:" << targetKey;
+ if (targetKeys.isEmpty()) {
+ if (keys.contains(QString::fromLatin1("wayland-egl"))) {
+ targetKeys.append(QString::fromLatin1("wayland-egl"));
+ } else if (!keys.isEmpty()) {
+ targetKeys.append(keys.first());
}
}
- if (!client_buffer_integration) {
- qCWarning(qLcWaylandCompositorHardwareIntegration)
- << "No client buffer integration was loaded, this means that clients will fall back"
- << "to use CPU buffers (wl_shm) for transmitting buffers instead of using zero-copy"
- << "GPU buffer handles. Expect serious performance impact with OpenGL clients due"
- << "to potentially multiple copies between CPU and GPU memory per buffer.\n"
- << "See the QtWayland readme for more info about how to build and configure Qt for"
- << "your device.";
- return;
+ QString hwIntegrationName;
+
+ for (auto targetKey : std::as_const(targetKeys)) {
+ auto *integration = QtWayland::ClientBufferIntegrationFactory::create(targetKey, QStringList());
+ if (integration) {
+ integration->setCompositor(q);
+ client_buffer_integrations.append(integration);
+ if (hwIntegrationName.isEmpty())
+ hwIntegrationName = targetKey;
+ }
}
- if (client_buffer_integration && hw_integration)
- hw_integration->setClientBufferIntegration(targetKey);
+ if (hw_integration && !hwIntegrationName.isEmpty())
+ hw_integration->setClientBufferIntegrationName(hwIntegrationName);
+
#endif
}
@@ -450,12 +459,26 @@ void QWaylandCompositorPrivate::loadServerBufferIntegration()
}
if (server_buffer_integration && hw_integration)
- hw_integration->setServerBufferIntegration(targetKey);
+ hw_integration->setServerBufferIntegrationName(targetKey);
#endif
}
+QWaylandSeat *QWaylandCompositorPrivate::seatFor(QInputEvent *inputEvent)
+{
+ QWaylandSeat *dev = nullptr;
+ for (int i = 0; i < seats.size(); i++) {
+ QWaylandSeat *candidate = seats.at(i);
+ if (candidate->isOwner(inputEvent)) {
+ dev = candidate;
+ break;
+ }
+ }
+ return dev;
+}
+
/*!
\qmltype WaylandCompositor
+ \instantiates QWaylandCompositor
\inqmlmodule QtWayland.Compositor
\since 5.8
\brief Manages the Wayland display server.
@@ -487,35 +510,37 @@ void QWaylandCompositorPrivate::loadServerBufferIntegration()
*/
/*!
- \qmlsignal void QtWaylandCompositor::WaylandCompositor::surfaceRequested(WaylandClient client, int id, int version)
+ \qmlsignal void QtWayland.Compositor::WaylandCompositor::surfaceRequested(WaylandClient client, int id, int version)
- This signal is emitted when a client has created a surface.
- The slot connecting to this signal may create and initialize
- a WaylandSurface instance in the scope of the slot.
- Otherwise a default surface is created.
+ This signal is emitted when a \a client has created a surface with id \a id.
+ The interface \a version is also available.
+
+ The slot connecting to this signal may create and initialize a WaylandSurface
+ instance in the scope of the slot. Otherwise a default surface is created.
*/
/*!
\fn void QWaylandCompositor::surfaceRequested(QWaylandClient *client, uint id, int version)
- This signal is emitted when a client has created a surface.
- The slot connecting to this signal may create and initialize
- a QWaylandSurface instance in the scope of the slot.
- Otherwise a default surface is created.
+ This signal is emitted when a \a client has created a surface with id \a id.
+ The interface \a version is also available.
+
+ The slot connecting to this signal may create and initialize a QWaylandSurface
+ instance in the scope of the slot. Otherwise a default surface is created.
Connections to this signal must be of Qt::DirectConnection connection type.
*/
/*!
- \qmlsignal void QtWaylandCompositor::WaylandCompositor::surfaceCreated(QWaylandSurface *surface)
+ \qmlsignal void QtWayland.Compositor::WaylandCompositor::surfaceCreated(WaylandSurface surface)
- This signal is emitted when a new WaylandSurface instance has been created.
+ This signal is emitted when a new WaylandSurface instance \a surface has been created.
*/
/*!
\fn void QWaylandCompositor::surfaceCreated(QWaylandSurface *surface)
- This signal is emitted when a new QWaylandSurface instance has been created.
+ This signal is emitted when a new QWaylandSurface instance \a surface has been created.
*/
/*!
@@ -554,7 +579,7 @@ void QWaylandCompositor::create()
}
/*!
- * \qmlproperty bool QtWaylandCompositor::WaylandCompositor::created
+ * \qmlproperty bool QtWayland.Compositor::WaylandCompositor::created
*
* This property is true if WaylandCompositor has been initialized,
* otherwise it's false.
@@ -573,7 +598,7 @@ bool QWaylandCompositor::isCreated() const
}
/*!
- * \qmlproperty string QtWaylandCompositor::WaylandCompositor::socketName
+ * \qmlproperty string QtWayland.Compositor::WaylandCompositor::socketName
*
* This property holds the socket name used by WaylandCompositor to communicate with
* clients. It must be set before the component is completed.
@@ -616,7 +641,7 @@ QByteArray QWaylandCompositor::socketName() const
}
/*!
- * \qmlmethod QtWaylandCompositor::WaylandCompositor::addSocketDescriptor(fd)
+ * \qmlmethod QtWayland.Compositor::WaylandCompositor::addSocketDescriptor(fd)
* \since 5.12
*
* Listen for client connections on a file descriptor, \a fd, referring to a
@@ -645,15 +670,10 @@ QByteArray QWaylandCompositor::socketName() const
*/
void QWaylandCompositor::addSocketDescriptor(int fd)
{
-#if WAYLAND_VERSION_MAJOR >= 1 && (WAYLAND_VERSION_MAJOR != 1 || WAYLAND_VERSION_MINOR >= 10)
Q_D(QWaylandCompositor);
d->externally_added_socket_fds.append(fd);
if (isCreated())
d->connectToExternalSockets();
-#else
- Q_UNUSED(fd);
- qWarning() << "QWaylandCompositor::addSocketDescriptor() does nothing on libwayland versions prior to 1.10.0";
-#endif
}
/*!
@@ -684,7 +704,7 @@ QList<QWaylandClient *>QWaylandCompositor::clients() const
}
/*!
- * \qmlmethod QtWaylandCompositor::WaylandCompositor::destroyClientForSurface(surface)
+ * \qmlmethod QtWayland.Compositor::WaylandCompositor::destroyClientForSurface(surface)
*
* Destroys the client for the WaylandSurface \a surface.
*/
@@ -698,7 +718,7 @@ void QWaylandCompositor::destroyClientForSurface(QWaylandSurface *surface)
}
/*!
- * \qmlmethod QtWaylandCompositor::WaylandCompositor::destroyClient(client)
+ * \qmlmethod QtWayland.Compositor::WaylandCompositor::destroyClient(client)
*
* Destroys the given WaylandClient \a client.
*/
@@ -756,7 +776,7 @@ QWaylandOutput *QWaylandCompositor::outputFor(QWindow *window) const
}
/*!
- * \qmlproperty WaylandOutput QtWaylandCompositor::WaylandCompositor::defaultOutput
+ * \qmlproperty WaylandOutput QtWayland.Compositor::WaylandCompositor::defaultOutput
*
* This property contains the first in the list of outputs added to the
* WaylandCompositor, or null if no outputs have been added.
@@ -857,7 +877,7 @@ QWaylandTouch *QWaylandCompositor::createTouchDevice(QWaylandSeat *seat)
}
/*!
- * \qmlproperty bool QtWaylandCompositor::WaylandCompositor::retainedSelection
+ * \qmlproperty bool QtWayland.Compositor::WaylandCompositor::retainedSelection
*
* This property holds whether retained selection is enabled.
*/
@@ -903,7 +923,7 @@ void QWaylandCompositor::overrideSelection(const QMimeData *data)
}
/*!
- * \qmlproperty WaylandSeat QtWaylandCompositor::WaylandCompositor::defaultSeat
+ * \qmlproperty WaylandSeat QtWayland.Compositor::WaylandCompositor::defaultSeat
*
* This property contains the default seat for this
* WaylandCompositor.
@@ -924,27 +944,17 @@ QWaylandSeat *QWaylandCompositor::defaultSeat() const
}
/*!
- * \internal
- *
- * Currently, Qt only supports a single seat, so this exists for
- * future proofing the APIs.
+ * Select the seat for a given input event \a inputEvent.
+ * Currently, Qt only supports a single seat.
*/
QWaylandSeat *QWaylandCompositor::seatFor(QInputEvent *inputEvent)
{
Q_D(QWaylandCompositor);
- QWaylandSeat *dev = nullptr;
- for (int i = 0; i < d->seats.size(); i++) {
- QWaylandSeat *candidate = d->seats.at(i);
- if (candidate->isOwner(inputEvent)) {
- dev = candidate;
- break;
- }
- }
- return dev;
+ return d->seatFor(inputEvent);
}
/*!
- * \qmlproperty bool QtWaylandCompositor::WaylandCompositor::useHardwareIntegrationExtension
+ * \qmlproperty bool QtWayland.Compositor::WaylandCompositor::useHardwareIntegrationExtension
*
* This property holds whether the hardware integration extension should be enabled for
* this WaylandCompositor.
@@ -1029,4 +1039,67 @@ void QWaylandCompositor::grabSurface(QWaylandSurfaceGrabber *grabber, const QWay
}
}
+/*!
+ * \qmlproperty list<enum> QtWayland.Compositor::WaylandCompositor::additionalShmFormats
+ *
+ * This property holds the list of additional wl_shm formats advertised as supported by the
+ * compositor.
+ *
+ * By default, only the required ShmFormat_ARGB8888 and ShmFormat_XRGB8888 are listed and this
+ * list will empty. Additional formats may require conversion internally and can thus affect
+ * performance.
+ *
+ * This property must be set before the compositor component is completed. Subsequent changes
+ * will have no effect.
+ *
+ * \since 6.0
+ */
+
+/*!
+ * \property QWaylandCompositor::additionalShmFormats
+ *
+ * This property holds the list of additional wl_shm formats advertised as supported by the
+ * compositor.
+ *
+ * By default, only the required ShmFormat_ARGB8888 and ShmFormat_XRGB8888 are listed and this
+ * list will empty.
+ *
+ * This property must be set before the compositor is \l{create()}{created}. Subsequent changes
+ * will have no effect.
+ *
+ * \since 6.0
+ */
+void QWaylandCompositor::setAdditionalShmFormats(const QVector<ShmFormat> &additionalShmFormats)
+{
+ Q_D(QWaylandCompositor);
+ if (d->initialized)
+ qCWarning(qLcWaylandCompositorHardwareIntegration) << "Setting QWaylandCompositor::additionalShmFormats after initialization has no effect";
+
+ d->shmFormats = additionalShmFormats;
+ emit additionalShmFormatsChanged();
+}
+
+QVector<QWaylandCompositor::ShmFormat> QWaylandCompositor::additionalShmFormats() const
+{
+ Q_D(const QWaylandCompositor);
+ return d->shmFormats;
+}
+
+void QWaylandCompositor::applicationStateChanged(Qt::ApplicationState state)
+{
+#if QT_CONFIG(xkbcommon)
+ if (state == Qt::ApplicationInactive) {
+ auto *seat = defaultSeat();
+ if (seat != nullptr) {
+ QWaylandKeyboardPrivate *keyb = QWaylandKeyboardPrivate::get(seat->keyboard());
+ keyb->resetKeyboardState();
+ }
+ }
+#else
+ Q_UNUSED(state);
+#endif
+}
+
QT_END_NAMESPACE
+
+#include "moc_qwaylandcompositor.cpp"
diff --git a/src/compositor/compositor_api/qwaylandcompositor.h b/src/compositor/compositor_api/qwaylandcompositor.h
index dfe14293d..1dee5cad1 100644
--- a/src/compositor/compositor_api/qwaylandcompositor.h
+++ b/src/compositor/compositor_api/qwaylandcompositor.h
@@ -1,43 +1,18 @@
-/****************************************************************************
-**
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDCOMPOSITOR_H
#define QWAYLANDCOMPOSITOR_H
#include <QtWaylandCompositor/qtwaylandcompositorglobal.h>
+#include <QtWaylandCompositor/qtwaylandqmlinclude.h>
#include <QtWaylandCompositor/qwaylandcompositorextension.h>
#include <QtWaylandCompositor/QWaylandOutput>
-#include <QObject>
-#include <QImage>
-#include <QRect>
-#include <QLoggingCategory>
+#include <QtCore/QObject>
+#include <QtGui/QImage>
+#include <QtCore/QRect>
+#include <QtCore/QLoggingCategory>
struct wl_display;
@@ -52,7 +27,6 @@ class QWaylandCompositorPrivate;
class QWaylandClient;
class QWaylandSurface;
class QWaylandSeat;
-class QWaylandGlobalInterface;
class QWaylandView;
class QWaylandPointer;
class QWaylandKeyboard;
@@ -60,11 +34,12 @@ class QWaylandTouch;
class QWaylandSurfaceGrabber;
class QWaylandBufferRef;
-Q_WAYLAND_COMPOSITOR_EXPORT Q_DECLARE_LOGGING_CATEGORY(qLcWaylandCompositor)
-Q_WAYLAND_COMPOSITOR_EXPORT Q_DECLARE_LOGGING_CATEGORY(qLcWaylandCompositorHardwareIntegration)
+Q_WAYLANDCOMPOSITOR_EXPORT Q_DECLARE_LOGGING_CATEGORY(qLcWaylandCompositor)
+Q_WAYLANDCOMPOSITOR_EXPORT Q_DECLARE_LOGGING_CATEGORY(qLcWaylandCompositorHardwareIntegration)
Q_DECLARE_LOGGING_CATEGORY(qLcWaylandCompositorInputMethods)
+Q_DECLARE_LOGGING_CATEGORY(qLcWaylandCompositorTextInput)
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandCompositor : public QWaylandObject
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandCompositor : public QWaylandObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandCompositor)
@@ -74,8 +49,32 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandCompositor : public QWaylandObject
Q_PROPERTY(QWaylandOutput *defaultOutput READ defaultOutput WRITE setDefaultOutput NOTIFY defaultOutputChanged)
Q_PROPERTY(bool useHardwareIntegrationExtension READ useHardwareIntegrationExtension WRITE setUseHardwareIntegrationExtension NOTIFY useHardwareIntegrationExtensionChanged)
Q_PROPERTY(QWaylandSeat *defaultSeat READ defaultSeat NOTIFY defaultSeatChanged)
-
+ Q_PROPERTY(QVector<ShmFormat> additionalShmFormats READ additionalShmFormats WRITE setAdditionalShmFormats NOTIFY additionalShmFormatsChanged REVISION(6, 0))
+ Q_MOC_INCLUDE("qwaylandseat.h")
+ QML_NAMED_ELEMENT(WaylandCompositorBase)
+ QML_UNCREATABLE("Cannot create instance of WaylandCompositorBase, use WaylandCompositor instead")
+ QML_ADDED_IN_VERSION(1, 0)
public:
+ // Duplicates subset of supported values wl_shm_format enum
+ enum ShmFormat {
+ ShmFormat_ARGB8888 = 0,
+ ShmFormat_XRGB8888 = 1,
+ ShmFormat_C8 = 0x20203843,
+ ShmFormat_XRGB4444 = 0x32315258,
+ ShmFormat_ARGB4444 = 0x32315241,
+ ShmFormat_XRGB1555 = 0x35315258,
+ ShmFormat_RGB565 = 0x36314752,
+ ShmFormat_RGB888 = 0x34324752,
+ ShmFormat_XBGR8888 = 0x34324258,
+ ShmFormat_ABGR8888 = 0x34324241,
+ ShmFormat_BGR888 = 0x34324742,
+ ShmFormat_XRGB2101010 = 0x30335258,
+ ShmFormat_XBGR2101010 = 0x30334258,
+ ShmFormat_ARGB2101010 = 0x30335241,
+ ShmFormat_ABGR2101010 = 0x30334241
+ };
+ Q_ENUM(ShmFormat)
+
QWaylandCompositor(QObject *parent = nullptr);
~QWaylandCompositor() override;
@@ -116,11 +115,17 @@ public:
bool useHardwareIntegrationExtension() const;
void setUseHardwareIntegrationExtension(bool use);
+ QVector<ShmFormat> additionalShmFormats() const;
+ void setAdditionalShmFormats(const QVector<ShmFormat> &additionalShmFormats);
+
virtual void grabSurface(QWaylandSurfaceGrabber *grabber, const QWaylandBufferRef &buffer);
public Q_SLOTS:
void processWaylandEvents();
+private Q_SLOTS:
+ void applicationStateChanged(Qt::ApplicationState state);
+
Q_SIGNALS:
void createdChanged();
void socketNameChanged(const QByteArray &socketName);
@@ -139,6 +144,8 @@ Q_SIGNALS:
void outputAdded(QWaylandOutput *output);
void outputRemoved(QWaylandOutput *output);
+ void additionalShmFormatsChanged();
+
protected:
virtual void retainedSelectionReceived(QMimeData *mimeData);
virtual QWaylandSeat *createSeat();
diff --git a/src/compositor/compositor_api/qwaylandcompositor_p.h b/src/compositor/compositor_api/qwaylandcompositor_p.h
index 6dec044f8..a8da8b8c4 100644
--- a/src/compositor/compositor_api/qwaylandcompositor_p.h
+++ b/src/compositor/compositor_api/qwaylandcompositor_p.h
@@ -1,32 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2017-2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017-2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDCOMPOSITOR_P_H
#define QWAYLANDCOMPOSITOR_P_H
@@ -50,10 +24,12 @@
#include <QtWaylandCompositor/private/qwayland-server-wayland.h>
+#include <QtCore/qpointer.h>
+
#include <vector>
#if QT_CONFIG(xkbcommon)
-#include <QtXkbCommonSupport/private/qxkbcommon_p.h>
+#include <QtGui/private/qxkbcommon_p.h>
#endif
QT_BEGIN_NAMESPACE
@@ -69,7 +45,7 @@ namespace QtWayland {
class QWindowSystemEventHandler;
class QWaylandSurface;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandCompositorPrivate : public QObjectPrivate, public QtWaylandServer::wl_compositor, public QtWaylandServer::wl_subcompositor
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandCompositorPrivate : public QObjectPrivate, public QtWaylandServer::wl_compositor, public QtWaylandServer::wl_subcompositor
{
public:
static QWaylandCompositorPrivate *get(QWaylandCompositor *compositor) { return compositor->d_func(); }
@@ -89,7 +65,7 @@ public:
QWaylandOutput *defaultOutput() const { return outputs.size() ? outputs.first() : nullptr; }
- inline QtWayland::ClientBufferIntegration *clientBufferIntegration() const;
+ inline const QList<QtWayland::ClientBufferIntegration *> clientBufferIntegrations() const;
inline QtWayland::ServerBufferIntegration *serverBufferIntegration() const;
#if QT_CONFIG(wayland_datadevice)
@@ -113,9 +89,9 @@ public:
inline void addOutput(QWaylandOutput *output);
inline void removeOutput(QWaylandOutput *output);
-#if WAYLAND_VERSION_MAJOR >= 1 && (WAYLAND_VERSION_MAJOR != 1 || WAYLAND_VERSION_MINOR >= 10)
void connectToExternalSockets();
-#endif
+
+ virtual QWaylandSeat *seatFor(QInputEvent *inputEvent);
protected:
void compositor_create_surface(wl_compositor::Resource *resource, uint32_t id) override;
@@ -133,11 +109,10 @@ protected:
void loadServerBufferIntegration();
QByteArray socket_name;
-#if WAYLAND_VERSION_MAJOR >= 1 && (WAYLAND_VERSION_MAJOR != 1 || WAYLAND_VERSION_MINOR >= 10)
QList<int> externally_added_socket_fds;
-#endif
struct wl_display *display = nullptr;
bool ownsDisplay = false;
+ QVector<QWaylandCompositor::ShmFormat> shmFormats;
QList<QWaylandSeat *> seats;
QList<QWaylandOutput *> outputs;
@@ -158,9 +133,9 @@ protected:
#if QT_CONFIG(opengl)
bool use_hw_integration_extension = true;
QScopedPointer<QtWayland::HardwareIntegration> hw_integration;
- QScopedPointer<QtWayland::ClientBufferIntegration> client_buffer_integration;
QScopedPointer<QtWayland::ServerBufferIntegration> server_buffer_integration;
#endif
+ QList<QtWayland::ClientBufferIntegration*> client_buffer_integrations;
QScopedPointer<QWindowSystemEventHandler> eventHandler;
@@ -177,13 +152,9 @@ protected:
Q_DISABLE_COPY(QWaylandCompositorPrivate)
};
-QtWayland::ClientBufferIntegration * QWaylandCompositorPrivate::clientBufferIntegration() const
+const QList<QtWayland::ClientBufferIntegration *> QWaylandCompositorPrivate::clientBufferIntegrations() const
{
-#if QT_CONFIG(opengl)
- return client_buffer_integration.data();
-#else
- return 0;
-#endif
+ return client_buffer_integrations;
}
QtWayland::ServerBufferIntegration * QWaylandCompositorPrivate::serverBufferIntegration() const
diff --git a/src/compositor/compositor_api/qwaylandcompositorquickextensions.cpp b/src/compositor/compositor_api/qwaylandcompositorquickextensions.cpp
new file mode 100644
index 000000000..43fb3b2f9
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandcompositorquickextensions.cpp
@@ -0,0 +1,10 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "qwaylandcompositorquickextensions_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QT_END_NAMESPACE
+
+#include "moc_qwaylandcompositorquickextensions_p.cpp"
diff --git a/src/compositor/compositor_api/qwaylandcompositorquickextensions_p.h b/src/compositor/compositor_api/qwaylandcompositorquickextensions_p.h
new file mode 100644
index 000000000..7e59a5d6e
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandcompositorquickextensions_p.h
@@ -0,0 +1,94 @@
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef QWAYLANDCOMPOSITORQUICKEXTENSIONS_P_H
+#define QWAYLANDCOMPOSITORQUICKEXTENSIONS_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 <QtQml/qqml.h>
+#include <QtWaylandCompositor/qtwaylandcompositorglobal.h>
+#include <QtWaylandCompositor/qwaylandquickextension.h>
+
+#include <QtWaylandCompositor/qwaylandcompositor.h>
+#include <QtWaylandCompositor/qwaylandquickcompositor.h>
+#include <QtWaylandCompositor/qwaylandqtwindowmanager.h>
+#include <QtWaylandCompositor/qwaylandtextinputmanager.h>
+#include <QtCore/private/qglobal_p.h>
+#include <QtWaylandCompositor/qwaylandtextinputmanagerv3.h>
+#include <QtWaylandCompositor/qwaylandqttextinputmethodmanager.h>
+#include <QtWaylandCompositor/qwaylandidleinhibitv1.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickCompositorQuickExtensionContainer : public QWaylandQuickCompositor
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<QWaylandCompositorExtension> extensions READ extensions)
+ Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false)
+ Q_CLASSINFO("DefaultProperty", "data")
+ QML_NAMED_ELEMENT(WaylandCompositor)
+ QML_ADDED_IN_VERSION(1, 0)
+public:
+ QQmlListProperty<QObject> data()
+ {
+ return QQmlListProperty<QObject>(this, &m_objects);
+ }
+
+ QQmlListProperty<QWaylandCompositorExtension> extensions()
+ {
+ return QQmlListProperty<QWaylandCompositorExtension>(this, this,
+ &append_extension,
+ &countFunction,
+ &atFunction,
+ &clearFunction);
+ }
+
+ static qsizetype countFunction(QQmlListProperty<QWaylandCompositorExtension> *list)
+ {
+ return static_cast<QWaylandQuickCompositorQuickExtensionContainer *>(list->data)->extension_vector.size();
+ }
+
+ static QWaylandCompositorExtension *atFunction(QQmlListProperty<QWaylandCompositorExtension> *list, qsizetype index)
+ {
+ return static_cast<QWaylandQuickCompositorQuickExtensionContainer *>(list->data)->extension_vector.at(index);
+ }
+
+ static void append_extension(QQmlListProperty<QWaylandCompositorExtension> *list, QWaylandCompositorExtension *extension)
+ {
+ QWaylandQuickCompositorQuickExtensionContainer *quickExtObj = static_cast<QWaylandQuickCompositorQuickExtensionContainer *>(list->data);
+ extension->setExtensionContainer(quickExtObj);
+ }
+
+ static void clearFunction(QQmlListProperty<QWaylandCompositorExtension> *list)
+ {
+ static_cast<QWaylandQuickCompositorQuickExtensionContainer *>(list->data)->extension_vector.clear();
+ }
+
+private:
+ QList<QObject *> m_objects;
+};
+
+
+// Note: These have to be in a header with a Q_OBJECT macro, otherwise we won't run moc on it
+Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(QWaylandQtWindowManager, QtWindowManager, 1, 0)
+Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(QWaylandIdleInhibitManagerV1,
+ IdleInhibitManagerV1, 1, 0)
+Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(QWaylandTextInputManager, TextInputManager, 1, 0)
+Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(QWaylandTextInputManagerV3, TextInputManagerV3,
+ 1, 0)
+Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(QWaylandQtTextInputMethodManager,
+ QtTextInputMethodManager, 1, 0)
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDCOMPOSITORQUICKEXTENSIONS_P_H
diff --git a/src/compositor/compositor_api/qwaylanddestroylistener.cpp b/src/compositor/compositor_api/qwaylanddestroylistener.cpp
index 958ea311c..26c2ff69e 100644
--- a/src/compositor/compositor_api/qwaylanddestroylistener.cpp
+++ b/src/compositor/compositor_api/qwaylanddestroylistener.cpp
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qwaylanddestroylistener.h"
#include "qwaylanddestroylistener_p.h"
@@ -63,3 +37,5 @@ void QWaylandDestroyListenerPrivate::handler(wl_listener *listener, void *data)
}
QT_END_NAMESPACE
+
+#include "moc_qwaylanddestroylistener.cpp"
diff --git a/src/compositor/compositor_api/qwaylanddestroylistener.h b/src/compositor/compositor_api/qwaylanddestroylistener.h
index f82775dac..e1307b2ca 100644
--- a/src/compositor/compositor_api/qwaylanddestroylistener.h
+++ b/src/compositor/compositor_api/qwaylanddestroylistener.h
@@ -1,32 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDDESTROYLISTENER_H
#define QWAYLANDDESTROYLISTENER_H
@@ -40,7 +14,7 @@ QT_BEGIN_NAMESPACE
class QWaylandDestroyListenerPrivate;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandDestroyListener : public QObject
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandDestroyListener : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandDestroyListener)
diff --git a/src/compositor/compositor_api/qwaylanddestroylistener_p.h b/src/compositor/compositor_api/qwaylanddestroylistener_p.h
index 1ff625dd3..baefc8171 100644
--- a/src/compositor/compositor_api/qwaylanddestroylistener_p.h
+++ b/src/compositor/compositor_api/qwaylanddestroylistener_p.h
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QTWAYLAND_QWLLISTENER_H
#define QTWAYLAND_QWLLISTENER_H
diff --git a/src/compositor/compositor_api/qwaylanddrag.cpp b/src/compositor/compositor_api/qwaylanddrag.cpp
index 2108c3906..2cd391218 100644
--- a/src/compositor/compositor_api/qwaylanddrag.cpp
+++ b/src/compositor/compositor_api/qwaylanddrag.cpp
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qwaylanddrag.h"
@@ -130,3 +104,5 @@ void QWaylandDrag::cancelDrag()
}
QT_END_NAMESPACE
+
+#include "moc_qwaylanddrag.cpp"
diff --git a/src/compositor/compositor_api/qwaylanddrag.h b/src/compositor/compositor_api/qwaylanddrag.h
index 71ff723b2..599b79c98 100644
--- a/src/compositor/compositor_api/qwaylanddrag.h
+++ b/src/compositor/compositor_api/qwaylanddrag.h
@@ -1,36 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDDRAG_H
#define QWAYLANDDRAG_H
#include <QtWaylandCompositor/qtwaylandcompositorglobal.h>
+#include <QtWaylandCompositor/qtwaylandqmlinclude.h>
#include <QtCore/QObject>
#include <QtCore/QPointF>
@@ -43,14 +18,18 @@ class QWaylandDragPrivate;
class QWaylandSurface;
class QWaylandSeat;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandDrag : public QObject
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandDrag : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandDrag)
Q_PROPERTY(QWaylandSurface *icon READ icon NOTIFY iconChanged)
Q_PROPERTY(bool visible READ visible NOTIFY iconChanged)
+ Q_MOC_INCLUDE("qwaylandsurface.h")
+ QML_NAMED_ELEMENT(WaylandDrag)
+ QML_ADDED_IN_VERSION(1, 0)
+ QML_UNCREATABLE("")
public:
explicit QWaylandDrag(QWaylandSeat *seat);
diff --git a/src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp b/src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp
index 5ecb9dfa0..e9a962d28 100644
--- a/src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp
+++ b/src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qwaylandinputmethodcontrol.h"
#include "qwaylandinputmethodcontrol_p.h"
@@ -35,6 +9,8 @@
#include "qwaylandsurface.h"
#include "qwaylandview.h"
#include "qwaylandtextinput.h"
+#include "qwaylandtextinputv3.h"
+#include "qwaylandqttextinputmethod.h"
#include <QtGui/QInputMethodEvent>
@@ -43,11 +19,21 @@ QWaylandInputMethodControl::QWaylandInputMethodControl(QWaylandSurface *surface)
{
connect(d_func()->compositor, &QWaylandCompositor::defaultSeatChanged,
this, &QWaylandInputMethodControl::defaultSeatChanged);
- QWaylandTextInput *textInput = d_func()->textInput();
- if (textInput) {
- connect(textInput, &QWaylandTextInput::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled);
- connect(textInput, &QWaylandTextInput::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled);
- connect(textInput, &QWaylandTextInput::updateInputMethod, this, &QWaylandInputMethodControl::updateInputMethod);
+
+ updateTextInput();
+
+ QWaylandTextInputV3 *textInputV3 = d_func()->textInputV3();
+ if (textInputV3) {
+ connect(textInputV3, &QWaylandTextInputV3::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled);
+ connect(textInputV3, &QWaylandTextInputV3::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled);
+ connect(textInputV3, &QWaylandTextInputV3::updateInputMethod, this, &QWaylandInputMethodControl::updateInputMethod);
+ }
+
+ QWaylandQtTextInputMethod *textInputMethod = d_func()->textInputMethod();
+ if (textInputMethod) {
+ connect(textInputMethod, &QWaylandQtTextInputMethod::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled);
+ connect(textInputMethod, &QWaylandQtTextInputMethod::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled);
+ connect(textInputMethod, &QWaylandQtTextInputMethod::updateInputMethod, this, &QWaylandInputMethodControl::updateInputMethod);
}
}
@@ -56,10 +42,16 @@ QVariant QWaylandInputMethodControl::inputMethodQuery(Qt::InputMethodQuery query
Q_D(const QWaylandInputMethodControl);
QWaylandTextInput *textInput = d->textInput();
-
- if (textInput && textInput->focus() == d->surface) {
+ if (textInput != nullptr && textInput->focus() == d->surface)
return textInput->inputMethodQuery(query, argument);
- }
+
+ QWaylandTextInputV3 *textInputV3 = d->textInputV3();
+ if (textInputV3 != nullptr && textInputV3->focus() == d->surface)
+ return textInputV3->inputMethodQuery(query, argument);
+
+ QWaylandQtTextInputMethod *textInputMethod = d_func()->textInputMethod();
+ if (textInputMethod && textInputMethod->focusedSurface() == d->surface)
+ return textInputMethod->inputMethodQuery(query, argument);
return QVariant();
}
@@ -68,9 +60,12 @@ void QWaylandInputMethodControl::inputMethodEvent(QInputMethodEvent *event)
{
Q_D(QWaylandInputMethodControl);
- QWaylandTextInput *textInput = d->textInput();
- if (textInput) {
+ if (QWaylandTextInput *textInput = d->textInput()) {
textInput->sendInputMethodEvent(event);
+ } else if (QWaylandTextInputV3 *textInputV3 = d->textInputV3()) {
+ textInputV3->sendInputMethodEvent(event);
+ } else if (QWaylandQtTextInputMethod *textInputMethod = d->textInputMethod()) {
+ textInputMethod->sendInputMethodEvent(event);
} else {
event->ignore();
}
@@ -121,7 +116,22 @@ void QWaylandInputMethodControl::setSurface(QWaylandSurface *surface)
d->surface = surface;
QWaylandTextInput *textInput = d->textInput();
- setEnabled(textInput && textInput->isSurfaceEnabled(d->surface));
+ QWaylandTextInputV3 *textInputV3 = d->textInputV3();
+ QWaylandQtTextInputMethod *textInputMethod = d->textInputMethod();
+ setEnabled((textInput && textInput->isSurfaceEnabled(d->surface))
+ || (textInputV3 && textInputV3->isSurfaceEnabled(d->surface))
+ || (textInputMethod && textInputMethod->isSurfaceEnabled(d->surface)));
+}
+
+void QWaylandInputMethodControl::updateTextInput()
+{
+ QWaylandTextInput *textInput = d_func()->textInput();
+
+ if (textInput) {
+ connect(textInput, &QWaylandTextInput::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled, Qt::UniqueConnection);
+ connect(textInput, &QWaylandTextInput::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled, Qt::UniqueConnection);
+ connect(textInput, &QWaylandTextInput::updateInputMethod, this, &QWaylandInputMethodControl::updateInputMethod, Qt::UniqueConnection);
+ }
}
void QWaylandInputMethodControl::defaultSeatChanged()
@@ -129,14 +139,32 @@ void QWaylandInputMethodControl::defaultSeatChanged()
Q_D(QWaylandInputMethodControl);
disconnect(d->textInput(), nullptr, this, nullptr);
+ disconnect(d->textInputV3(), nullptr, this, nullptr);
+ disconnect(d->textInputMethod(), nullptr, this, nullptr);
d->seat = d->compositor->defaultSeat();
QWaylandTextInput *textInput = d->textInput();
+ QWaylandTextInputV3 *textInputV3 = d->textInputV3();
+ QWaylandQtTextInputMethod *textInputMethod = d->textInputMethod();
+
+ if (textInput) {
+ connect(textInput, &QWaylandTextInput::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled);
+ connect(textInput, &QWaylandTextInput::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled);
+ }
+
+ if (textInputV3) {
+ connect(textInputV3, &QWaylandTextInputV3::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled);
+ connect(textInputV3, &QWaylandTextInputV3::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled);
+ }
- connect(textInput, &QWaylandTextInput::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled);
- connect(textInput, &QWaylandTextInput::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled);
+ if (textInputMethod) {
+ connect(textInputMethod, &QWaylandQtTextInputMethod::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled);
+ connect(textInputMethod, &QWaylandQtTextInputMethod::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled);
+ }
- setEnabled(textInput && textInput->isSurfaceEnabled(d->surface));
+ setEnabled((textInput && textInput->isSurfaceEnabled(d->surface))
+ || (textInputV3 && textInputV3->isSurfaceEnabled(d->surface))
+ || (textInputMethod && textInputMethod->isSurfaceEnabled(d->surface)));
}
QWaylandInputMethodControlPrivate::QWaylandInputMethodControlPrivate(QWaylandSurface *surface)
@@ -146,7 +174,23 @@ QWaylandInputMethodControlPrivate::QWaylandInputMethodControlPrivate(QWaylandSur
{
}
+QWaylandQtTextInputMethod *QWaylandInputMethodControlPrivate::textInputMethod() const
+{
+ if (!surface->client() || !surface->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::QtTextInputMethodV1))
+ return nullptr;
+ return QWaylandQtTextInputMethod::findIn(seat);
+}
+
QWaylandTextInput *QWaylandInputMethodControlPrivate::textInput() const
{
+ if (!surface->client() || !surface->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::TextInputV2))
+ return nullptr;
return QWaylandTextInput::findIn(seat);
}
+
+QWaylandTextInputV3 *QWaylandInputMethodControlPrivate::textInputV3() const
+{
+ return QWaylandTextInputV3::findIn(seat);
+}
+
+#include "moc_qwaylandinputmethodcontrol.cpp"
diff --git a/src/compositor/compositor_api/qwaylandinputmethodcontrol.h b/src/compositor/compositor_api/qwaylandinputmethodcontrol.h
index 8cb4a2ea6..3b4d74870 100644
--- a/src/compositor/compositor_api/qwaylandinputmethodcontrol.h
+++ b/src/compositor/compositor_api/qwaylandinputmethodcontrol.h
@@ -1,37 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDINPUTMETHODCONTROL_H
#define QWAYLANDINPUTMETHODCONTROL_H
#include <QtGui/qtguiglobal.h>
-#include <QObject>
+#include <QtCore/QObject>
QT_BEGIN_NAMESPACE
@@ -39,6 +13,7 @@ class QWaylandCompositor;
class QWaylandInputMethodControlPrivate;
class QWaylandSurface;
class QInputMethodEvent;
+class QWaylandTextInput;
class QWaylandInputMethodControl : public QObject
{
@@ -58,6 +33,7 @@ public:
void setEnabled(bool enabled);
void setSurface(QWaylandSurface *surface);
+ void updateTextInput();
Q_SIGNALS:
void enabledChanged(bool enabled);
diff --git a/src/compositor/compositor_api/qwaylandinputmethodcontrol_p.h b/src/compositor/compositor_api/qwaylandinputmethodcontrol_p.h
index 4c20f3e3c..36a0db0c4 100644
--- a/src/compositor/compositor_api/qwaylandinputmethodcontrol_p.h
+++ b/src/compositor/compositor_api/qwaylandinputmethodcontrol_p.h
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDINPUTMETHODCONTROL_P_H
#define QWAYLANDINPUTMETHODCONTROL_P_H
@@ -52,8 +26,10 @@ class QWaylandCompositor;
class QWaylandSeat;
class QWaylandSurface;
class QWaylandTextInput;
+class QWaylandTextInputV3;
+class QWaylandQtTextInputMethod;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandInputMethodControlPrivate : public QObjectPrivate
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandInputMethodControlPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QWaylandInputMethodControl)
@@ -61,6 +37,8 @@ public:
explicit QWaylandInputMethodControlPrivate(QWaylandSurface *surface);
QWaylandTextInput *textInput() const;
+ QWaylandTextInputV3 *textInputV3() const;
+ QWaylandQtTextInputMethod *textInputMethod() const;
QWaylandCompositor *compositor = nullptr;
QWaylandSeat *seat = nullptr;
diff --git a/src/compositor/compositor_api/qwaylandkeyboard.cpp b/src/compositor/compositor_api/qwaylandkeyboard.cpp
index 210b683ff..8af7fbd8c 100644
--- a/src/compositor/compositor_api/qwaylandkeyboard.cpp
+++ b/src/compositor/compositor_api/qwaylandkeyboard.cpp
@@ -1,32 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qtwaylandcompositorglobal_p.h"
#include "qwaylandkeyboard.h"
@@ -39,11 +13,13 @@
#include <QtCore/QFile>
#include <QtCore/QStandardPaths>
+#include <QKeyEvent>
#include <fcntl.h>
#include <unistd.h>
#if QT_CONFIG(xkbcommon)
#include <sys/mman.h>
#include <sys/types.h>
+#include <xkbcommon/xkbcommon-names.h>
#endif
QT_BEGIN_NAMESPACE
@@ -187,11 +163,27 @@ void QWaylandKeyboardPrivate::maybeUpdateXkbScanCodeTable()
continue;
Qt::KeyboardModifiers mods = {};
- int qtKey = QXkbCommon::keysymToQtKey(syms[0], mods);
+ int qtKey = QXkbCommon::keysymToQtKey(syms[0], mods, nullptr, 0, false, false);
if (qtKey != 0)
scanCodesByQtKey->insert({layout, qtKey}, keycode);
}
}, &scanCodesByQtKey);
+
+ shiftIndex = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_SHIFT);
+ controlIndex = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_CTRL);
+ altIndex = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_ALT);
+ }
+}
+
+void QWaylandKeyboardPrivate::resetKeyboardState()
+{
+ if (!xkbContext())
+ return;
+
+ while (!keys.isEmpty()) {
+ uint32_t code = fromWaylandKey(keys.first());
+ keyEvent(code, WL_KEYBOARD_KEY_STATE_RELEASED);
+ updateModifierState(code, WL_KEYBOARD_KEY_STATE_RELEASED);
}
}
#endif
@@ -223,6 +215,15 @@ void QWaylandKeyboardPrivate::updateModifierState(uint code, uint32_t state)
if (focusResource) {
send_modifiers(focusResource->handle, compositor()->nextSerial(), modsDepressed,
modsLatched, modsLocked, group);
+
+ Qt::KeyboardModifiers currentState = Qt::NoModifier;
+ if (xkb_state_mod_index_is_active(xkbState(), shiftIndex, XKB_STATE_MODS_EFFECTIVE) == 1)
+ currentState |= Qt::ShiftModifier;
+ if (xkb_state_mod_index_is_active(xkbState(), controlIndex, XKB_STATE_MODS_EFFECTIVE) == 1)
+ currentState |= Qt::ControlModifier;
+ if (xkb_state_mod_index_is_active(xkbState(), altIndex, XKB_STATE_MODS_EFFECTIVE) == 1)
+ currentState |= Qt::AltModifier;
+ currentModifierState = currentState;
}
#else
Q_UNUSED(code);
@@ -262,17 +263,29 @@ void QWaylandKeyboardPrivate::maybeUpdateKeymap()
#endif
}
+// In all current XKB keymaps there's a constant offset of 8 (for historical
+// reasons) from hardware/evdev scancodes to XKB keycodes. On X11, we pass
+// XKB keycodes (as sent by X server) via QKeyEvent::nativeScanCode. eglfs+evdev
+// adds 8 for consistency, see qtbase/05c07c7636012ebb4131ca099ca4ea093af76410.
+// eglfs+libinput also adds 8, for the same reason. Wayland protocol uses
+// hardware/evdev scancodes, thus we need to subtract 8 before sending the event
+// out and add it when mapping back.
+#define QTWAYLANDKEYBOARD_XKB_HISTORICAL_OFFSET 8
+
+uint QWaylandKeyboardPrivate::fromWaylandKey(const uint key)
+{
+#if QT_CONFIG(xkbcommon)
+ const uint offset = QTWAYLANDKEYBOARD_XKB_HISTORICAL_OFFSET;
+ return key + offset;
+#else
+ return key;
+#endif
+}
+
uint QWaylandKeyboardPrivate::toWaylandKey(const uint nativeScanCode)
{
#if QT_CONFIG(xkbcommon)
- // In all current XKB keymaps there's a constant offset of 8 (for historical
- // reasons) from hardware/evdev scancodes to XKB keycodes. On X11, we pass
- // XKB keycodes (as sent by X server) via QKeyEvent::nativeScanCode. eglfs+evdev
- // adds 8 for consistency, see qtbase/05c07c7636012ebb4131ca099ca4ea093af76410.
- // eglfs+libinput also adds 8, for the same reason. Wayland protocol uses
- // hardware/evdev scancodes, thus we need to minus 8 before sending the event
- // out.
- const uint offset = 8;
+ const uint offset = QTWAYLANDKEYBOARD_XKB_HISTORICAL_OFFSET;
Q_ASSERT(nativeScanCode >= offset);
return nativeScanCode - offset;
#else
@@ -498,6 +511,38 @@ void QWaylandKeyboard::sendKeyReleaseEvent(uint code)
d->sendKeyEvent(code, WL_KEYBOARD_KEY_STATE_RELEASED);
}
+void QWaylandKeyboardPrivate::checkAndRepairModifierState(QKeyEvent *ke)
+{
+#if QT_CONFIG(xkbcommon)
+ if (ke->modifiers() != currentModifierState) {
+ if (focusResource && ke->key() != Qt::Key_Shift
+ && ke->key() != Qt::Key_Control && ke->key() != Qt::Key_Alt) {
+ // Only repair the state for non-modifier keys
+ // ### slightly awkward because the standard modifier handling
+ // is done by QtWayland::WindowSystemEventHandler after the
+ // key event is delivered
+ uint32_t mods = 0;
+
+ if (shiftIndex == 0 && controlIndex == 0)
+ maybeUpdateXkbScanCodeTable();
+
+ if (ke->modifiers() & Qt::ShiftModifier)
+ mods |= 1 << shiftIndex;
+ if (ke->modifiers() & Qt::ControlModifier)
+ mods |= 1 << controlIndex;
+ if (ke->modifiers() & Qt::AltModifier)
+ mods |= 1 << altIndex;
+ qCDebug(qLcWaylandCompositor) << "Keyboard modifier state mismatch detected for event" << ke << "state:" << currentModifierState << "repaired:" << Qt::hex << mods;
+ send_modifiers(focusResource->handle, compositor()->nextSerial(), mods,
+ 0, 0, group);
+ currentModifierState = ke->modifiers();
+ }
+ }
+#else
+ Q_UNUSED(ke);
+#endif
+}
+
/*!
* Returns the current repeat rate.
*/
@@ -589,3 +634,5 @@ uint QWaylandKeyboard::keyToScanCode(int qtKey) const
}
QT_END_NAMESPACE
+
+#include "moc_qwaylandkeyboard.cpp"
diff --git a/src/compositor/compositor_api/qwaylandkeyboard.h b/src/compositor/compositor_api/qwaylandkeyboard.h
index 7c450164a..ebefcd2a2 100644
--- a/src/compositor/compositor_api/qwaylandkeyboard.h
+++ b/src/compositor/compositor_api/qwaylandkeyboard.h
@@ -1,32 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDKEYBOARD_H
#define QWAYLANDKEYBOARD_H
@@ -43,7 +17,7 @@ class QWaylandKeyboardPrivate;
class QWaylandSeat;
class QWaylandKeymap;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandKeyboard : public QWaylandObject
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandKeyboard : public QWaylandObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandKeyboard)
diff --git a/src/compositor/compositor_api/qwaylandkeyboard_p.h b/src/compositor/compositor_api/qwaylandkeyboard_p.h
index 96d174310..a91c60e43 100644
--- a/src/compositor/compositor_api/qwaylandkeyboard_p.h
+++ b/src/compositor/compositor_api/qwaylandkeyboard_p.h
@@ -1,32 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QTWAYLAND_QWLKEYBOARD_P_H
#define QTWAYLAND_QWLKEYBOARD_P_H
@@ -51,17 +25,17 @@
#include <QtCore/private/qobject_p.h>
#include <QtWaylandCompositor/private/qwayland-server-wayland.h>
-#include <QtCore/QVector>
+#include <QtCore/QList>
#if QT_CONFIG(xkbcommon)
#include <xkbcommon/xkbcommon.h>
-#include <QtXkbCommonSupport/private/qxkbcommon_p.h>
+#include <QtGui/private/qxkbcommon_p.h>
#endif
QT_BEGIN_NAMESPACE
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandKeyboardPrivate : public QObjectPrivate
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandKeyboardPrivate : public QObjectPrivate
, public QtWaylandServer::wl_keyboard
{
public:
@@ -83,11 +57,13 @@ public:
}
uint32_t xkbModsMask() const { return modsDepressed | modsLatched | modsLocked; }
void maybeUpdateXkbScanCodeTable();
+ void resetKeyboardState();
#endif
void keyEvent(uint code, uint32_t state);
void sendKeyEvent(uint code, uint32_t state);
void updateModifierState(uint code, uint32_t state);
+ void checkAndRepairModifierState(QKeyEvent *ke);
void maybeUpdateKeymap();
void checkFocusResource(Resource *resource);
@@ -104,6 +80,7 @@ private:
void createXKBState(xkb_keymap *keymap);
#endif
static uint toWaylandKey(const uint nativeScanCode);
+ static uint fromWaylandKey(const uint key);
void sendRepeatInfo();
@@ -113,12 +90,18 @@ private:
Resource *focusResource = nullptr;
QWaylandDestroyListener focusDestroyListener;
- QVector<uint32_t> keys;
+ QList<uint32_t> keys;
uint32_t modsDepressed = 0;
uint32_t modsLatched = 0;
uint32_t modsLocked = 0;
uint32_t group = 0;
+ uint32_t shiftIndex = 0;
+ uint32_t controlIndex = 0;
+ uint32_t altIndex = 0;
+
+ Qt::KeyboardModifiers currentModifierState;
+
bool pendingKeymap = false;
#if QT_CONFIG(xkbcommon)
size_t keymap_size;
diff --git a/src/compositor/compositor_api/qwaylandkeymap.cpp b/src/compositor/compositor_api/qwaylandkeymap.cpp
index bd58a84e1..160693532 100644
--- a/src/compositor/compositor_api/qwaylandkeymap.cpp
+++ b/src/compositor/compositor_api/qwaylandkeymap.cpp
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qwaylandkeymap.h"
#include "qwaylandkeymap_p.h"
@@ -120,3 +94,5 @@ QWaylandKeymapPrivate::QWaylandKeymapPrivate(const QString &layout, const QStrin
}
QT_END_NAMESPACE
+
+#include "moc_qwaylandkeymap.cpp"
diff --git a/src/compositor/compositor_api/qwaylandkeymap.h b/src/compositor/compositor_api/qwaylandkeymap.h
index 30034e664..a919160b2 100644
--- a/src/compositor/compositor_api/qwaylandkeymap.h
+++ b/src/compositor/compositor_api/qwaylandkeymap.h
@@ -1,53 +1,34 @@
-/****************************************************************************
-**
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDKEYMAP_H
#define QWAYLANDKEYMAP_H
#include <QtCore/QObject>
#include <QtWaylandCompositor/qtwaylandcompositorglobal.h>
+#include <QtWaylandCompositor/qtwaylandqmlinclude.h>
+#if QT_CONFIG(wayland_compositor_quick)
#include <QtWaylandCompositor/qwaylandquickchildren.h>
+#endif
QT_BEGIN_NAMESPACE
class QWaylandKeymapPrivate;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandKeymap : public QObject
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandKeymap : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandKeymap)
+#if QT_CONFIG(wayland_compositor_quick)
Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandKeymap)
+#endif
Q_PROPERTY(QString layout READ layout WRITE setLayout NOTIFY layoutChanged)
Q_PROPERTY(QString variant READ variant WRITE setVariant NOTIFY variantChanged)
Q_PROPERTY(QString options READ options WRITE setOptions NOTIFY optionsChanged)
Q_PROPERTY(QString rules READ rules WRITE setRules NOTIFY rulesChanged)
Q_PROPERTY(QString model READ model WRITE setModel NOTIFY modelChanged)
+ QML_NAMED_ELEMENT(WaylandKeymap)
+ QML_ADDED_IN_VERSION(1, 0)
public:
QWaylandKeymap(const QString &layout = QString(), const QString &variant = QString(), const QString &options = QString(),
const QString &model = QString(), const QString &rules = QString(), QObject *parent = nullptr);
diff --git a/src/compositor/compositor_api/qwaylandkeymap_p.h b/src/compositor/compositor_api/qwaylandkeymap_p.h
index fc58f548f..a27500c46 100644
--- a/src/compositor/compositor_api/qwaylandkeymap_p.h
+++ b/src/compositor/compositor_api/qwaylandkeymap_p.h
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDKEYMAP_P_H
#define QWAYLANDKEYMAP_P_H
@@ -46,7 +20,7 @@
QT_BEGIN_NAMESPACE
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandKeymapPrivate : public QObjectPrivate
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandKeymapPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QWaylandKeymap)
public:
diff --git a/src/compositor/compositor_api/qwaylandmousetracker.cpp b/src/compositor/compositor_api/qwaylandmousetracker.cpp
new file mode 100644
index 000000000..efc539779
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandmousetracker.cpp
@@ -0,0 +1,143 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "qwaylandmousetracker_p.h"
+
+#include <QtQuick/private/qquickitem_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandMouseTrackerPrivate : public QQuickItemPrivate
+{
+ Q_DECLARE_PUBLIC(QWaylandMouseTracker)
+public:
+ QWaylandMouseTrackerPrivate()
+ {
+ QImage cursorImage(64,64,QImage::Format_ARGB32);
+ cursorImage.fill(Qt::transparent);
+ cursorPixmap = QPixmap::fromImage(cursorImage);
+ }
+ void handleMousePos(const QPointF &mousePos)
+ {
+ Q_Q(QWaylandMouseTracker);
+ bool xChanged = mousePos.x() != this->mousePos.x();
+ bool yChanged = mousePos.y() != this->mousePos.y();
+ if (xChanged || yChanged) {
+ this->mousePos = mousePos;
+ if (xChanged)
+ emit q->mouseXChanged();
+ if (yChanged)
+ emit q->mouseYChanged();
+ }
+ }
+
+ void setHovered(bool hovered)
+ {
+ Q_Q(QWaylandMouseTracker);
+ if (this->hovered == hovered)
+ return;
+ this->hovered = hovered;
+ emit q->hoveredChanged();
+ }
+
+ QPointF mousePos;
+ bool windowSystemCursorEnabled = false;
+ QPixmap cursorPixmap;
+ bool hovered = false;
+};
+
+QWaylandMouseTracker::QWaylandMouseTracker(QQuickItem *parent)
+ : QQuickItem(*(new QWaylandMouseTrackerPrivate), parent)
+{
+ Q_D(QWaylandMouseTracker);
+ setFiltersChildMouseEvents(true);
+ setAcceptHoverEvents(true);
+ setAcceptedMouseButtons(Qt::AllButtons);
+#if QT_CONFIG(cursor)
+ setCursor(QCursor(d->cursorPixmap));
+#endif
+}
+
+qreal QWaylandMouseTracker::mouseX() const
+{
+ Q_D(const QWaylandMouseTracker);
+ return d->mousePos.x();
+}
+qreal QWaylandMouseTracker::mouseY() const
+{
+ Q_D(const QWaylandMouseTracker);
+ return d->mousePos.y();
+}
+
+#if QT_CONFIG(cursor)
+void QWaylandMouseTracker::setWindowSystemCursorEnabled(bool enable)
+{
+ Q_D(QWaylandMouseTracker);
+ if (d->windowSystemCursorEnabled != enable) {
+ d->windowSystemCursorEnabled = enable;
+ if (enable) {
+ unsetCursor();
+ } else {
+ setCursor(QCursor(d->cursorPixmap));
+ }
+ emit windowSystemCursorEnabledChanged();
+ }
+}
+
+bool QWaylandMouseTracker::windowSystemCursorEnabled() const
+{
+ Q_D(const QWaylandMouseTracker);
+ return d->windowSystemCursorEnabled;
+}
+#endif
+
+bool QWaylandMouseTracker::hovered() const
+{
+ Q_D(const QWaylandMouseTracker);
+ return d->hovered;
+}
+
+bool QWaylandMouseTracker::childMouseEventFilter(QQuickItem *item, QEvent *event)
+{
+ Q_D(QWaylandMouseTracker);
+ if (event->type() == QEvent::MouseMove) {
+ QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
+ d->handleMousePos(mapFromItem(item, mouseEvent->position()));
+ } else if (event->type() == QEvent::HoverMove) {
+ QHoverEvent *hoverEvent = static_cast<QHoverEvent *>(event);
+ d->handleMousePos(mapFromItem(item, hoverEvent->position()));
+ }
+ return false;
+}
+
+void QWaylandMouseTracker::mouseMoveEvent(QMouseEvent *event)
+{
+ Q_D(QWaylandMouseTracker);
+ QQuickItem::mouseMoveEvent(event);
+ d->handleMousePos(event->position());
+}
+
+void QWaylandMouseTracker::hoverMoveEvent(QHoverEvent *event)
+{
+ Q_D(QWaylandMouseTracker);
+ QQuickItem::hoverMoveEvent(event);
+ d->handleMousePos(event->position());
+}
+
+void QWaylandMouseTracker::hoverEnterEvent(QHoverEvent *event)
+{
+ Q_D(QWaylandMouseTracker);
+ Q_UNUSED(event);
+ d->setHovered(true);
+}
+
+void QWaylandMouseTracker::hoverLeaveEvent(QHoverEvent *event)
+{
+ Q_D(QWaylandMouseTracker);
+ Q_UNUSED(event);
+ d->setHovered(false);
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qwaylandmousetracker_p.cpp"
diff --git a/src/compositor/compositor_api/qwaylandmousetracker_p.h b/src/compositor/compositor_api/qwaylandmousetracker_p.h
new file mode 100644
index 000000000..efc49c3f5
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandmousetracker_p.h
@@ -0,0 +1,63 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef QWAYLANDMOUSETRACKER_P_H
+#define QWAYLANDMOUSETRACKER_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 <QtQuick/private/qquickmousearea_p.h>
+
+#include <QtWaylandCompositor/qtwaylandcompositorglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandMouseTrackerPrivate;
+
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandMouseTracker : public QQuickItem
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandMouseTracker)
+ Q_PROPERTY(qreal mouseX READ mouseX NOTIFY mouseXChanged)
+ Q_PROPERTY(qreal mouseY READ mouseY NOTIFY mouseYChanged)
+ Q_PROPERTY(bool containsMouse READ hovered NOTIFY hoveredChanged)
+
+ Q_PROPERTY(bool windowSystemCursorEnabled READ windowSystemCursorEnabled WRITE setWindowSystemCursorEnabled NOTIFY windowSystemCursorEnabledChanged)
+ QML_NAMED_ELEMENT(WaylandMouseTracker)
+ QML_ADDED_IN_VERSION(1, 0)
+public:
+ QWaylandMouseTracker(QQuickItem *parent = nullptr);
+
+ qreal mouseX() const;
+ qreal mouseY() const;
+
+ void setWindowSystemCursorEnabled(bool enable);
+ bool windowSystemCursorEnabled() const;
+ bool hovered() const;
+
+Q_SIGNALS:
+ void mouseXChanged();
+ void mouseYChanged();
+ void windowSystemCursorEnabledChanged();
+ void hoveredChanged();
+
+protected:
+ bool childMouseEventFilter(QQuickItem *item, QEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void hoverMoveEvent(QHoverEvent *event) override;
+ void hoverEnterEvent(QHoverEvent *event) override;
+ void hoverLeaveEvent(QHoverEvent *event) override;
+};
+
+QT_END_NAMESPACE
+
+#endif /*QWAYLANDMOUSETRACKER_P_H*/
diff --git a/src/compositor/compositor_api/qwaylandoutput.cpp b/src/compositor/compositor_api/qwaylandoutput.cpp
index 0f5e79d83..c19e2bd94 100644
--- a/src/compositor/compositor_api/qwaylandoutput.cpp
+++ b/src/compositor/compositor_api/qwaylandoutput.cpp
@@ -1,32 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2017-2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
-** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017-2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qwaylandoutput.h"
#include "qwaylandoutput_p.h"
@@ -249,6 +223,7 @@ QWaylandOutput::QWaylandOutput()
/*!
\qmltype WaylandOutput
+ \instantiates QWaylandOutput
\inqmlmodule QtWayland.Compositor
\since 5.8
\brief Provides access to a displayable area managed by the compositor.
@@ -258,6 +233,9 @@ QWaylandOutput::QWaylandOutput()
a screen managed by the WaylandCompositor.
The type corresponds to the \c wl_output interface in the Wayland protocol.
+
+ \note If the compositor has multiple Wayland outputs, the \l Qt::AA_ShareOpenGLContexts
+ attribute must be set before the \l QGuiApplication object is constructed.
*/
/*!
@@ -380,7 +358,7 @@ void QWaylandOutput::update()
}
/*!
- * \qmlproperty WaylandCompositor QtWaylandCompositor::WaylandOutput::compositor
+ * \qmlproperty WaylandCompositor QtWayland.Compositor::WaylandOutput::compositor
*
* This property holds the compositor displaying content on this WaylandOutput.
*
@@ -420,7 +398,7 @@ void QWaylandOutput::setCompositor(QWaylandCompositor *compositor)
}
/*!
- * \qmlproperty string QtWaylandCompositor::WaylandOutput::manufacturer
+ * \qmlproperty string QtWayland.Compositor::WaylandOutput::manufacturer
*
* This property holds a textual description of the manufacturer of this WaylandOutput.
*/
@@ -448,7 +426,7 @@ void QWaylandOutput::setManufacturer(const QString &manufacturer)
}
/*!
- * \qmlproperty string QtWaylandCompositor::WaylandOutput::model
+ * \qmlproperty string QtWayland.Compositor::WaylandOutput::model
*
* This property holds a textual description of the model of this WaylandOutput.
*/
@@ -476,7 +454,7 @@ void QWaylandOutput::setModel(const QString &model)
}
/*!
- * \qmlproperty point QtWaylandCompositor::WaylandOutput::position
+ * \qmlproperty point QtWayland.Compositor::WaylandOutput::position
*
* This property holds the position of this WaylandOutput in the compositor's coordinate system.
*/
@@ -528,7 +506,8 @@ void QWaylandOutput::addMode(const QWaylandOutputMode &mode, bool preferred)
return;
}
- d->modes.append(mode);
+ if (d->modes.indexOf(mode) < 0)
+ d->modes.append(mode);
if (preferred)
d->preferredMode = d->modes.indexOf(mode);
@@ -580,7 +559,7 @@ void QWaylandOutput::setCurrentMode(const QWaylandOutputMode &mode)
}
/*!
- * \qmlproperty rect QtWaylandCompositor::WaylandOutput::geometry
+ * \qmlproperty rect QtWayland.Compositor::WaylandOutput::geometry
*
* This property holds the geometry of the WaylandOutput.
*/
@@ -599,7 +578,7 @@ QRect QWaylandOutput::geometry() const
}
/*!
- * \qmlproperty rect QtWaylandCompositor::WaylandOutput::availableGeometry
+ * \qmlproperty rect QtWayland.Compositor::WaylandOutput::availableGeometry
*
* This property holds the geometry of the WaylandOutput available for displaying content.
* The available geometry is in output coordinates space, starts from 0,0 and it's as big
@@ -642,7 +621,7 @@ void QWaylandOutput::setAvailableGeometry(const QRect &availableGeometry)
}
/*!
- * \qmlproperty size QtWaylandCompositor::WaylandOutput::physicalSize
+ * \qmlproperty size QtWayland.Compositor::WaylandOutput::physicalSize
*
* This property holds the physical size of the WaylandOutput in millimeters.
*
@@ -690,7 +669,7 @@ void QWaylandOutput::setPhysicalSize(const QSize &size)
*/
/*!
- * \qmlproperty enum QtWaylandCompositor::WaylandOutput::subpixel
+ * \qmlproperty enum QtWayland.Compositor::WaylandOutput::subpixel
*
* This property holds the subpixel arrangement of this WaylandOutput.
*
@@ -747,7 +726,7 @@ void QWaylandOutput::setSubpixel(const Subpixel &subpixel)
*/
/*!
- * \qmlproperty enum QtWaylandCompositor::WaylandOutput::transform
+ * \qmlproperty enum QtWayland.Compositor::WaylandOutput::transform
*
* This property holds the transformation that the QWaylandCompositor applies to a surface
* to compensate for the orientation of the QWaylandOutput.
@@ -793,7 +772,7 @@ void QWaylandOutput::setTransform(const Transform &transform)
}
/*!
- * \qmlproperty int QtWaylandCompositor::WaylandOutput::scaleFactor
+ * \qmlproperty int QtWayland.Compositor::WaylandOutput::scaleFactor
*
* This property holds the factor by which the WaylandCompositor scales surface buffers
* before they are displayed. It is used on high density output devices where unscaled content
@@ -843,7 +822,7 @@ void QWaylandOutput::setScaleFactor(int scale)
}
/*!
- * \qmlproperty bool QtWaylandCompositor::WaylandOutput::sizeFollowsWindow
+ * \qmlproperty bool QtWayland.Compositor::WaylandOutput::sizeFollowsWindow
*
* This property controls whether the size of the WaylandOutput matches the
* size of its window.
@@ -881,7 +860,7 @@ void QWaylandOutput::setSizeFollowsWindow(bool follow)
}
/*!
- * \qmlproperty Window QtWaylandCompositor::WaylandOutput::window
+ * \qmlproperty Window QtWayland.Compositor::WaylandOutput::window
*
* This property holds the Window for this WaylandOutput.
*
diff --git a/src/compositor/compositor_api/qwaylandoutput.h b/src/compositor/compositor_api/qwaylandoutput.h
index c8fdcf515..a45fa5756 100644
--- a/src/compositor/compositor_api/qwaylandoutput.h
+++ b/src/compositor/compositor_api/qwaylandoutput.h
@@ -1,43 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2017-2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
-** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017-2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDOUTPUT_H
#define QWAYLANDOUTPUT_H
+#include <QtWaylandCompositor/qtwaylandqmlinclude.h>
#include <QtWaylandCompositor/qwaylandcompositorextension.h>
#include <QtWaylandCompositor/QWaylandOutputMode>
#include <QtCore/QObject>
-
-#include <QObject>
-#include <QRect>
-#include <QSize>
+#include <QtCore/QRect>
+#include <QtCore/QSize>
struct wl_resource;
@@ -49,9 +22,8 @@ class QWindow;
class QWaylandSurface;
class QWaylandView;
class QWaylandClient;
-class QWaylandOutputSpace;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandOutput : public QWaylandObject
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandOutput : public QWaylandObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandOutput)
@@ -67,8 +39,10 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandOutput : public QWaylandObject
Q_PROPERTY(QWaylandOutput::Transform transform READ transform WRITE setTransform NOTIFY transformChanged)
Q_PROPERTY(int scaleFactor READ scaleFactor WRITE setScaleFactor NOTIFY scaleFactorChanged)
Q_PROPERTY(bool sizeFollowsWindow READ sizeFollowsWindow WRITE setSizeFollowsWindow NOTIFY sizeFollowsWindowChanged)
- Q_ENUMS(Subpixel Transform)
+ QML_NAMED_ELEMENT(WaylandOutputBase)
+ QML_ADDED_IN_VERSION(1, 0)
+ QML_UNCREATABLE("Cannot create instance of WaylandOutputBase, use WaylandOutput instead")
public:
enum Subpixel {
SubpixelUnknown = 0,
diff --git a/src/compositor/compositor_api/qwaylandoutput_p.h b/src/compositor/compositor_api/qwaylandoutput_p.h
index d06d14178..f62def16c 100644
--- a/src/compositor/compositor_api/qwaylandoutput_p.h
+++ b/src/compositor/compositor_api/qwaylandoutput_p.h
@@ -1,33 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2017-2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
-** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017-2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDOUTPUT_P_H
#define QWAYLANDOUTPUT_P_H
@@ -51,10 +25,11 @@
#include <QtWaylandCompositor/private/qwayland-server-wayland.h>
+#include <QtCore/QList>
#include <QtCore/QRect>
-#include <QtCore/QVector>
#include <QtCore/private/qobject_p.h>
+#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE
@@ -78,13 +53,15 @@ struct QWaylandSurfaceViewMapper
}
QWaylandSurface *surface = nullptr;
- QVector<QWaylandView *> views;
+ QList<QWaylandView *> views;
bool has_entered = false;
};
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandOutputPrivate : public QObjectPrivate, public QtWaylandServer::wl_output
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandOutputPrivate : public QObjectPrivate, public QtWaylandServer::wl_output
{
public:
+ Q_DECLARE_PUBLIC(QWaylandOutput)
+
QWaylandOutputPrivate();
~QWaylandOutputPrivate() override;
@@ -115,11 +92,11 @@ private:
QString manufacturer;
QString model;
QPoint position;
- QVector<QWaylandOutputMode> modes;
+ QList<QWaylandOutputMode> modes;
int currentMode = -1;
int preferredMode = -1;
QRect availableGeometry;
- QVector<QWaylandSurfaceViewMapper> surfaceViews;
+ QList<QWaylandSurfaceViewMapper> surfaceViews;
QSize physicalSize;
QWaylandOutput::Subpixel subpixel = QWaylandOutput::SubpixelUnknown;
QWaylandOutput::Transform transform = QWaylandOutput::TransformNormal;
@@ -128,7 +105,6 @@ private:
bool initialized = false;
QSize windowPixelSize;
- Q_DECLARE_PUBLIC(QWaylandOutput)
Q_DISABLE_COPY(QWaylandOutputPrivate)
friend class QWaylandXdgOutputManagerV1Private;
diff --git a/src/compositor/compositor_api/qwaylandoutputmode.cpp b/src/compositor/compositor_api/qwaylandoutputmode.cpp
index e1326c6cd..04e738aec 100644
--- a/src/compositor/compositor_api/qwaylandoutputmode.cpp
+++ b/src/compositor/compositor_api/qwaylandoutputmode.cpp
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qwaylandoutputmode.h"
#include "qwaylandoutputmode_p.h"
diff --git a/src/compositor/compositor_api/qwaylandoutputmode.h b/src/compositor/compositor_api/qwaylandoutputmode.h
index 0b0851ea0..90238b121 100644
--- a/src/compositor/compositor_api/qwaylandoutputmode.h
+++ b/src/compositor/compositor_api/qwaylandoutputmode.h
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDOUTPUTMODE_H
#define QWAYLANDOUTPUTMODE_H
@@ -35,7 +9,7 @@
QT_BEGIN_NAMESPACE
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandOutputMode
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandOutputMode
{
public:
explicit QWaylandOutputMode();
diff --git a/src/compositor/compositor_api/qwaylandoutputmode_p.h b/src/compositor/compositor_api/qwaylandoutputmode_p.h
index 30f84a813..232399c2c 100644
--- a/src/compositor/compositor_api/qwaylandoutputmode_p.h
+++ b/src/compositor/compositor_api/qwaylandoutputmode_p.h
@@ -1,36 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDOUTPUTMODE_P_H
#define QWAYLANDOUTPUTMODE_P_H
#include <QtWaylandCompositor/QWaylandOutput>
+#include <QtCore/private/qglobal_p.h>
//
// W A R N I N G
@@ -45,7 +20,7 @@
QT_BEGIN_NAMESPACE
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandOutputModePrivate
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandOutputModePrivate
{
public:
QWaylandOutputModePrivate() {}
diff --git a/src/compositor/compositor_api/qwaylandpointer.cpp b/src/compositor/compositor_api/qwaylandpointer.cpp
index 38cb5d7f2..ee2c79a69 100644
--- a/src/compositor/compositor_api/qwaylandpointer.cpp
+++ b/src/compositor/compositor_api/qwaylandpointer.cpp
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qwaylandpointer.h"
#include "qwaylandpointer_p.h"
@@ -90,9 +64,9 @@ void QWaylandPointerPrivate::sendLeave()
uint32_t serial = compositor()->nextSerial();
for (auto resource : resourceMap().values(enteredSurface->waylandClient()))
send_leave(resource->handle, serial, enteredSurface->resource());
- enteredSurface = nullptr;
localPosition = QPointF();
enteredSurfaceDestroyListener.reset();
+ enteredSurface = nullptr;
}
void QWaylandPointerPrivate::ensureEntered(QWaylandSurface *surface)
@@ -114,11 +88,10 @@ void QWaylandPointerPrivate::pointer_release(wl_pointer::Resource *resource)
void QWaylandPointerPrivate::pointer_set_cursor(wl_pointer::Resource *resource, uint32_t serial, wl_resource *surface, int32_t hotspot_x, int32_t hotspot_y)
{
- Q_UNUSED(resource);
Q_UNUSED(serial);
if (!surface) {
- seat->cursorSurfaceRequest(nullptr, 0, 0);
+ seat->cursorSurfaceRequested(nullptr, 0, 0, QWaylandClient::fromWlClient(compositor(), resource->client()));
return;
}
@@ -133,7 +106,7 @@ void QWaylandPointerPrivate::pointer_set_cursor(wl_pointer::Resource *resource,
wl_resource *displayRes = wl_client_get_object(resource->client(), 1);
if (s->setRole(&QWaylandPointerPrivate::s_role, displayRes, WL_DISPLAY_ERROR_INVALID_OBJECT)) {
s->markAsCursorSurface(true);
- seat->cursorSurfaceRequest(s, hotspot_x, hotspot_y);
+ seat->cursorSurfaceRequested(s, hotspot_x, hotspot_y, QWaylandClient::fromWlClient(compositor(), resource->client()));
}
}
@@ -392,7 +365,7 @@ uint32_t QWaylandPointer::toWaylandButton(Qt::MouseButton button)
void QWaylandPointer::enteredSurfaceDestroyed(void *data)
{
Q_D(QWaylandPointer);
- Q_UNUSED(data)
+ Q_UNUSED(data);
d->enteredSurfaceDestroyListener.reset();
d->enteredSurface = nullptr;
@@ -417,3 +390,5 @@ void QWaylandPointer::pointerFocusChanged(QWaylandView *newFocus, QWaylandView *
}
QT_END_NAMESPACE
+
+#include "moc_qwaylandpointer.cpp"
diff --git a/src/compositor/compositor_api/qwaylandpointer.h b/src/compositor/compositor_api/qwaylandpointer.h
index 26d9f124f..7d5a96b6e 100644
--- a/src/compositor/compositor_api/qwaylandpointer.h
+++ b/src/compositor/compositor_api/qwaylandpointer.h
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDPOINTER_H
#define QWAYLANDPOINTER_H
@@ -43,7 +17,7 @@ class QWaylandView;
class QWaylandOutput;
class QWaylandClient;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandPointer : public QWaylandObject
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandPointer : public QWaylandObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandPointer)
diff --git a/src/compositor/compositor_api/qwaylandpointer_p.h b/src/compositor/compositor_api/qwaylandpointer_p.h
index 43090bf50..71970351b 100644
--- a/src/compositor/compositor_api/qwaylandpointer_p.h
+++ b/src/compositor/compositor_api/qwaylandpointer_p.h
@@ -1,32 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDPOINTER_P_H
#define QWAYLANDPOINTER_P_H
@@ -56,13 +30,15 @@
#include <QtWaylandCompositor/QWaylandSurface>
#include <QtWaylandCompositor/QWaylandSeat>
+#include <QtCore/qpointer.h>
+
#include <stdint.h>
QT_BEGIN_NAMESPACE
class QWaylandView;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandPointerPrivate : public QObjectPrivate
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandPointerPrivate : public QObjectPrivate
, public QtWaylandServer::wl_pointer
{
Q_DECLARE_PUBLIC(QWaylandPointer)
diff --git a/src/compositor/compositor_api/qwaylandquickchildren.h b/src/compositor/compositor_api/qwaylandquickchildren.h
index ecf382d01..5024b322e 100644
--- a/src/compositor/compositor_api/qwaylandquickchildren.h
+++ b/src/compositor/compositor_api/qwaylandquickchildren.h
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDQUICKCHILDREN_H
#define QWAYLANDQUICKCHILDREN_H
@@ -44,7 +18,7 @@
#include <QtWaylandCompositor/qtwaylandcompositorglobal.h>
#if QT_CONFIG(wayland_compositor_quick)
#include <QtQml/QQmlListProperty>
-#include <QtCore/QVector>
+#include <QtCore/QList>
#endif
QT_BEGIN_NAMESPACE
@@ -66,11 +40,11 @@ QT_BEGIN_NAMESPACE
{ \
static_cast<className *>(list->data)->m_children.append(object); \
} \
- static int countFunction(QQmlListProperty<QObject> *list) \
+ static qsizetype countFunction(QQmlListProperty<QObject> *list) \
{ \
return static_cast<className *>(list->data)->m_children.size(); \
} \
- static QObject *atFunction(QQmlListProperty<QObject> *list, int index) \
+ static QObject *atFunction(QQmlListProperty<QObject> *list, qsizetype index) \
{ \
return static_cast<className *>(list->data)->m_children.at(index); \
} \
@@ -79,7 +53,7 @@ QT_BEGIN_NAMESPACE
static_cast<className *>(list->data)->m_children.clear(); \
} \
private: \
- QVector<QObject *> m_children;
+ QList<QObject *> m_children;
#else
#define Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(className)
#endif
diff --git a/src/compositor/compositor_api/qwaylandquickcompositor.cpp b/src/compositor/compositor_api/qwaylandquickcompositor.cpp
index 2b0258488..43cc8c3e2 100644
--- a/src/compositor/compositor_api/qwaylandquickcompositor.cpp
+++ b/src/compositor/compositor_api/qwaylandquickcompositor.cpp
@@ -1,38 +1,14 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
-** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtQml/QQmlEngine>
#include <QQuickWindow>
-#include <QOpenGLTextureBlitter>
-#include <QOpenGLTexture>
-#include <QOpenGLFramebufferObject>
+#if QT_CONFIG(opengl)
+# include <QOpenGLTextureBlitter>
+# include <QOpenGLTexture>
+# include <QOpenGLFramebufferObject>
+#endif
#include <QMatrix4x4>
#include <QRunnable>
@@ -71,7 +47,7 @@ QWaylandQuickCompositor::QWaylandQuickCompositor(QObject *parent)
}
/*!
- * \qmlproperty list QtWaylandCompositor::WaylandCompositor::extensions
+ * \qmlproperty list QtWayland.Compositor::WaylandCompositor::extensions
*
* A list of extensions that the compositor advertises to its clients. For
* any Wayland extension the compositor should support, instantiate its component,
@@ -80,8 +56,8 @@ QWaylandQuickCompositor::QWaylandQuickCompositor(QObject *parent)
* For instance, the following code would allow the clients to request \c wl_shell
* surfaces in the compositor using the \c wl_shell interface.
*
- * \qml \QtMinorVersion
- * import QtWayland.Compositor 1.\1
+ * \qml
+ * import QtWayland.Compositor
*
* WaylandCompositor {
* WlShell {
@@ -159,10 +135,12 @@ void QWaylandQuickCompositor::grabSurface(QWaylandSurfaceGrabber *grabber, const
GrabState *state = new GrabState;
state->grabber = grabber;
state->buffer = buffer;
- static_cast<QQuickWindow *>(output->window())->scheduleRenderJob(state, QQuickWindow::NoStage);
+ static_cast<QQuickWindow *>(output->window())->scheduleRenderJob(state, QQuickWindow::AfterRenderingStage);
#else
emit grabber->failed(QWaylandSurfaceGrabber::UnknownBufferType);
#endif
}
QT_END_NAMESPACE
+
+#include "moc_qwaylandquickcompositor.cpp"
diff --git a/src/compositor/compositor_api/qwaylandquickcompositor.h b/src/compositor/compositor_api/qwaylandquickcompositor.h
index 873183670..921f1fefb 100644
--- a/src/compositor/compositor_api/qwaylandquickcompositor.h
+++ b/src/compositor/compositor_api/qwaylandquickcompositor.h
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDQUICKCOMPOSITOR_H
#define QWAYLANDQUICKCOMPOSITOR_H
@@ -33,13 +7,15 @@
#include <QtWaylandCompositor/qwaylandcompositor.h>
#include <QtQml/QQmlParserStatus>
+QT_REQUIRE_CONFIG(wayland_compositor_quick);
+
QT_BEGIN_NAMESPACE
class QQuickWindow;
class QWaylandQuickCompositorPrivate;
class QWaylandView;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickCompositor : public QWaylandCompositor, public QQmlParserStatus
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickCompositor : public QWaylandCompositor, public QQmlParserStatus
{
Q_INTERFACES(QQmlParserStatus)
Q_OBJECT
diff --git a/src/compositor/compositor_api/qwaylandquickhardwarelayer.cpp b/src/compositor/compositor_api/qwaylandquickhardwarelayer.cpp
index 55ac61cfa..9cf36b36f 100644
--- a/src/compositor/compositor_api/qwaylandquickhardwarelayer.cpp
+++ b/src/compositor/compositor_api/qwaylandquickhardwarelayer.cpp
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qwaylandquickhardwarelayer_p.h"
@@ -105,7 +79,7 @@ QWaylandQuickHardwareLayer::~QWaylandQuickHardwareLayer()
}
/*!
- * \qmlproperty int QtWaylandCompositor::WaylandHardwareLayer::stackingLevel
+ * \qmlproperty int QtWayland.Compositor::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
@@ -160,9 +134,18 @@ void QWaylandQuickHardwareLayer::componentComplete()
qWarning() << "No hardware layer integration. WaylandHarwareLayer has no effect.";
}
-void QWaylandQuickHardwareLayer::disableSceneGraphPainting()
+void QWaylandQuickHardwareLayer::setSceneGraphPainting(bool enable)
{
- waylandItem()->setPaintEnabled(false);
+ waylandItem()->setPaintEnabled(enable);
+}
+
+// This should be called if QWaylandQuickHardwareLayer used as a native instance, not a qml component.
+void QWaylandQuickHardwareLayer::initialize()
+{
+ classBegin();
+ componentComplete();
}
QT_END_NAMESPACE
+
+#include "moc_qwaylandquickhardwarelayer_p.cpp"
diff --git a/src/compositor/compositor_api/qwaylandquickhardwarelayer_p.h b/src/compositor/compositor_api/qwaylandquickhardwarelayer_p.h
index 594ed490d..d33a8c0d7 100644
--- a/src/compositor/compositor_api/qwaylandquickhardwarelayer_p.h
+++ b/src/compositor/compositor_api/qwaylandquickhardwarelayer_p.h
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDQUICKHARDWARELAYER_P_H
#define QWAYLANDQUICKHARDWARELAYER_P_H
@@ -42,17 +16,20 @@
//
#include <QtWaylandCompositor/QWaylandQuickItem>
+#include <QtCore/private/qglobal_p.h>
QT_BEGIN_NAMESPACE
class QWaylandQuickHardwareLayerPrivate;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickHardwareLayer : public QObject, public QQmlParserStatus
+class Q_WAYLANDCOMPOSITOR_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)
+ QML_NAMED_ELEMENT(WaylandHardwareLayer)
+ QML_ADDED_IN_VERSION(1, 2)
public:
explicit QWaylandQuickHardwareLayer(QObject *parent = nullptr);
~QWaylandQuickHardwareLayer() override;
@@ -65,7 +42,8 @@ public:
void classBegin() override;
void componentComplete() override;
- void disableSceneGraphPainting();
+ void setSceneGraphPainting(bool);
+ void initialize();
Q_SIGNALS:
void stackingLevelChanged();
diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp
index 80e84a884..c643598be 100644
--- a/src/compositor/compositor_api/qwaylandquickitem.cpp
+++ b/src/compositor/compositor_api/qwaylandquickitem.cpp
@@ -1,37 +1,13 @@
-/****************************************************************************
-**
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qwaylandquickitem.h"
#include "qwaylandquickitem_p.h"
#include "qwaylandquicksurface.h"
#include "qwaylandinputmethodcontrol.h"
#include "qwaylandtextinput.h"
+#include "qwaylandtextinputv3.h"
+#include "qwaylandqttextinputmethod.h"
#include "qwaylandquickoutput.h"
#include <QtWaylandCompositor/qwaylandcompositor.h>
#include <QtWaylandCompositor/qwaylandseat.h>
@@ -42,21 +18,30 @@
#include <QtWaylandCompositor/private/qwlclientbufferintegration_p.h>
#include <QtWaylandCompositor/private/qwaylandsurface_p.h>
+#if QT_CONFIG(opengl)
+# include <QtOpenGL/QOpenGLTexture>
+# include <QtGui/QOpenGLFunctions>
+#endif
+
#include <QtGui/QKeyEvent>
#include <QtGui/QGuiApplication>
#include <QtGui/QScreen>
-#include <QtGui/QOpenGLFunctions>
-#include <QtGui/QOpenGLTexture>
#include <QtQuick/QSGSimpleTextureNode>
#include <QtQuick/QQuickWindow>
+#include <QtQuick/qsgtexture.h>
+#include <QtCore/QFile>
#include <QtCore/QMutexLocker>
#include <QtCore/QMutex>
#include <wayland-server-core.h>
#include <QThread>
+#if QT_CONFIG(opengl)
+#include <QtGui/private/qshaderdescription_p.h>
+#endif
+
#ifndef GL_TEXTURE_EXTERNAL_OES
#define GL_TEXTURE_EXTERNAL_OES 0x8D65
#endif
@@ -67,126 +52,219 @@ QT_BEGIN_NAMESPACE
static const struct {
const char * const vertexShaderSourceFile;
const char * const fragmentShaderSourceFile;
- GLenum textureTarget;
int planeCount;
bool canProvideTexture;
QSGMaterial::Flags materialFlags;
QSGMaterialType materialType;
} bufferTypes[] = {
// BufferFormatEgl_Null
- { "", "", 0, 0, false, 0, {} },
+ { "", "", 0, false, {}, {} },
- // BufferFormatEgl_RGB
+ // BufferFormatEgl_RGB (GL_TEXTURE_2D)
{
- ":/qt-project.org/wayland/compositor/shaders/surface.vert",
- ":/qt-project.org/wayland/compositor/shaders/surface_rgbx.frag",
- GL_TEXTURE_2D, 1, true,
+ ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb",
+ ":/qt-project.org/wayland/compositor/shaders/surface_rgbx.frag.qsb",
+ 1, true,
QSGMaterial::Blending,
{}
},
- // BufferFormatEgl_RGBA
+ // BufferFormatEgl_RGBA (GL_TEXTURE_2D)
{
- ":/qt-project.org/wayland/compositor/shaders/surface.vert",
- ":/qt-project.org/wayland/compositor/shaders/surface_rgba.frag",
- GL_TEXTURE_2D, 1, true,
+ ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb",
+ ":/qt-project.org/wayland/compositor/shaders/surface_rgba.frag.qsb",
+ 1, true,
QSGMaterial::Blending,
{}
},
- // BufferFormatEgl_EXTERNAL_OES
+ // BufferFormatEgl_EXTERNAL_OES (GL_TEXTURE_EXTERNAL_OES)
{
- ":/qt-project.org/wayland/compositor/shaders/surface.vert",
+ ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb",
":/qt-project.org/wayland/compositor/shaders/surface_oes_external.frag",
- GL_TEXTURE_EXTERNAL_OES, 1, false,
+ 1, false,
QSGMaterial::Blending,
{}
},
- // BufferFormatEgl_Y_U_V
+ // BufferFormatEgl_Y_U_V (GL_TEXTURE_2D)
{
- ":/qt-project.org/wayland/compositor/shaders/surface.vert",
- ":/qt-project.org/wayland/compositor/shaders/surface_y_u_v.frag",
- GL_TEXTURE_2D, 3, false,
+ ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb",
+ ":/qt-project.org/wayland/compositor/shaders/surface_y_u_v.frag.qsb",
+ 3, false,
QSGMaterial::Blending,
{}
},
- // BufferFormatEgl_Y_UV
+ // BufferFormatEgl_Y_UV (GL_TEXTURE_2D)
{
- ":/qt-project.org/wayland/compositor/shaders/surface.vert",
- ":/qt-project.org/wayland/compositor/shaders/surface_y_uv.frag",
- GL_TEXTURE_2D, 2, false,
+ ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb",
+ ":/qt-project.org/wayland/compositor/shaders/surface_y_uv.frag.qsb",
+ 2, false,
QSGMaterial::Blending,
{}
},
- // BufferFormatEgl_Y_XUXV
+ // BufferFormatEgl_Y_XUXV (GL_TEXTURE_2D)
{
- ":/qt-project.org/wayland/compositor/shaders/surface.vert",
- ":/qt-project.org/wayland/compositor/shaders/surface_y_xuxv.frag",
- GL_TEXTURE_2D, 2, false,
+ ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb",
+ ":/qt-project.org/wayland/compositor/shaders/surface_y_xuxv.frag.qsb",
+ 2, false,
QSGMaterial::Blending,
{}
}
};
QWaylandBufferMaterialShader::QWaylandBufferMaterialShader(QWaylandBufferRef::BufferFormatEgl format)
- : m_format(format)
{
- setShaderSourceFile(QOpenGLShader::Vertex, QString::fromLatin1(bufferTypes[format].vertexShaderSourceFile));
- setShaderSourceFile(QOpenGLShader::Fragment, QString::fromLatin1(bufferTypes[format].fragmentShaderSourceFile));
+ Q_UNUSED(format);
+ setShaderFileName(VertexStage, QString::fromLatin1(bufferTypes[format].vertexShaderSourceFile));
+ auto fragmentShaderSourceFile = QString::fromLatin1(bufferTypes[format].fragmentShaderSourceFile);
+
+ if (format == QWaylandBufferRef::BufferFormatEgl_EXTERNAL_OES)
+ setupExternalOESShader(fragmentShaderSourceFile);
+ else
+ setShaderFileName(FragmentStage, fragmentShaderSourceFile);
}
-void QWaylandBufferMaterialShader::updateState(const QSGMaterialShader::RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
+void QWaylandBufferMaterialShader::setupExternalOESShader(const QString &shaderFilename)
{
- QSGMaterialShader::updateState(state, newEffect, oldEffect);
+#if QT_CONFIG(opengl)
+ QFile shaderFile(shaderFilename);
+ if (!shaderFile.open(QIODevice::ReadOnly)) {
+ qCWarning(qLcWaylandCompositor) << "Cannot find external OES shader file:" << shaderFilename;
+ return;
+ }
+ QByteArray FS = shaderFile.readAll();
+
+ static const char *FS_GLES_PREAMBLE =
+ "#extension GL_OES_EGL_image_external : require\n"
+ "precision highp float;\n";
+ static const char *FS_GL_PREAMBLE =
+ "#version 120\n"
+ "#extension GL_OES_EGL_image_external : require\n";
+ QByteArray fsGLES = FS_GLES_PREAMBLE + FS;
+ QByteArray fsGL = FS_GL_PREAMBLE + FS;
+
+ QShaderDescription desc;
+ QShaderDescriptionPrivate *descData = QShaderDescriptionPrivate::get(&desc);
+
+ QShaderDescription::InOutVariable texCoordInput;
+ texCoordInput.name = "v_texcoord";
+ texCoordInput.type = QShaderDescription::Vec2;
+ texCoordInput.location = 0;
+
+ descData->inVars = { texCoordInput };
+
+ QShaderDescription::InOutVariable fragColorOutput;
+ fragColorOutput.name = "gl_FragColor";
+ fragColorOutput.type = QShaderDescription::Vec4;
+ fragColorOutput.location = 0;
+
+ descData->outVars = { fragColorOutput };
+
+ QShaderDescription::BlockVariable matrixBlockVar;
+ matrixBlockVar.name = "qt_Matrix";
+ matrixBlockVar.type = QShaderDescription::Mat4;
+ matrixBlockVar.offset = 0;
+ matrixBlockVar.size = 64;
+
+ QShaderDescription::BlockVariable opacityBlockVar;
+ opacityBlockVar.name = "qt_Opacity";
+ opacityBlockVar.type = QShaderDescription::Float;
+ opacityBlockVar.offset = 64;
+ opacityBlockVar.size = 4;
+
+ QShaderDescription::UniformBlock ubufStruct;
+ ubufStruct.blockName = "buf";
+ ubufStruct.structName = "ubuf";
+ ubufStruct.size = 64 + 4;
+ ubufStruct.binding = 0;
+ ubufStruct.members = { matrixBlockVar, opacityBlockVar };
+
+ descData->uniformBlocks = { ubufStruct };
+
+ QShaderDescription::InOutVariable samplerTex0;
+ samplerTex0.name = "tex0";
+ samplerTex0.type = QShaderDescription::SamplerExternalOES;
+ samplerTex0.binding = 1;
+
+ descData->combinedImageSamplers = { samplerTex0 };
+
+ QShader shaderPack;
+ shaderPack.setStage(QShader::FragmentStage);
+ shaderPack.setDescription(desc);
+ shaderPack.setShader(QShaderKey(QShader::GlslShader, QShaderVersion(100, QShaderVersion::GlslEs)), QShaderCode(fsGLES));
+ shaderPack.setShader(QShaderKey(QShader::GlslShader, QShaderVersion(120)), QShaderCode(fsGL));
+
+ setShader(FragmentStage, shaderPack);
+#else
+ Q_UNUSED(shaderFilename);
+#endif
+}
- QWaylandBufferMaterial *material = static_cast<QWaylandBufferMaterial *>(newEffect);
- material->bind();
+bool QWaylandBufferMaterialShader::updateUniformData(RenderState &state, QSGMaterial *, QSGMaterial *)
+{
+ bool changed = false;
+ QByteArray *buf = state.uniformData();
+ Q_ASSERT(buf->size() >= 68);
- if (state.isMatrixDirty())
- program()->setUniformValue(m_id_matrix, state.combinedMatrix());
+ if (state.isMatrixDirty()) {
+ const QMatrix4x4 m = state.combinedMatrix();
+ memcpy(buf->data(), m.constData(), 64);
+ changed = true;
+ }
- if (state.isOpacityDirty())
- program()->setUniformValue(m_id_opacity, state.opacity());
-}
+ if (state.isOpacityDirty()) {
+ const float opacity = state.opacity();
+ memcpy(buf->data() + 64, &opacity, 4);
+ changed = true;
+ }
-const char * const *QWaylandBufferMaterialShader::attributeNames() const
-{
- static char const *const attr[] = { "qt_VertexPosition", "qt_VertexTexCoord", nullptr };
- return attr;
+ return changed;
}
-void QWaylandBufferMaterialShader::initialize()
+void QWaylandBufferMaterialShader::updateSampledImage(RenderState &state, int binding, QSGTexture **texture,
+ QSGMaterial *newMaterial, QSGMaterial *)
{
- QSGMaterialShader::initialize();
+ Q_UNUSED(state);
- m_id_matrix = program()->uniformLocation("qt_Matrix");
- m_id_opacity = program()->uniformLocation("qt_Opacity");
-
- for (int i = 0; i < bufferTypes[m_format].planeCount; i++) {
- m_id_tex << program()->uniformLocation("tex" + QByteArray::number(i));
- program()->setUniformValue(m_id_tex[i], i);
+ QWaylandBufferMaterial *material = static_cast<QWaylandBufferMaterial *>(newMaterial);
+ switch (binding) {
+ case 1:
+ *texture = material->m_scenegraphTextures.at(0);
+ break;
+ case 2:
+ *texture = material->m_scenegraphTextures.at(1);
+ break;
+ case 3:
+ *texture = material->m_scenegraphTextures.at(2);
+ break;
+ default:
+ return;
}
- Q_ASSERT(m_id_tex.size() == bufferTypes[m_format].planeCount);
+ // This is for the shared memory case, and is a no-op for others,
+ // this is where the upload from the QImage happens when not yet done.
+ // ### or is this too late? (if buffer.image() disappears in the meantime then this is the wrong...)
+ if (*texture)
+ (*texture)->commitTextureOperations(state.rhi(), state.resourceUpdateBatch());
}
QWaylandBufferMaterial::QWaylandBufferMaterial(QWaylandBufferRef::BufferFormatEgl format)
: m_format(format)
{
- QOpenGLFunctions *gl = QOpenGLContext::currentContext()->functions();
-
- gl->glBindTexture(bufferTypes[m_format].textureTarget, 0);
setFlag(bufferTypes[m_format].materialFlags);
}
QWaylandBufferMaterial::~QWaylandBufferMaterial()
{
+ qDeleteAll(m_scenegraphTextures);
}
-void QWaylandBufferMaterial::setTextureForPlane(int plane, QOpenGLTexture *texture)
+void QWaylandBufferMaterial::setTextureForPlane(int plane,
+ QOpenGLTexture *texture,
+ QSGTexture *scenegraphTexture)
{
if (plane < 0 || plane >= bufferTypes[m_format].planeCount) {
qWarning("plane index is out of range");
@@ -198,10 +276,15 @@ void QWaylandBufferMaterial::setTextureForPlane(int plane, QOpenGLTexture *textu
ensureTextures(plane - 1);
- if (m_textures.size() <= plane)
+ if (m_textures.size() <= plane) {
m_textures << texture;
- else
+ m_scenegraphTextures << scenegraphTexture;
+ } else {
+ delete m_scenegraphTextures[plane];
+
m_textures[plane] = texture;
+ m_scenegraphTextures[plane] = scenegraphTexture;
+ }
}
void QWaylandBufferMaterial::bind()
@@ -228,8 +311,9 @@ QSGMaterialType *QWaylandBufferMaterial::type() const
return const_cast<QSGMaterialType *>(&bufferTypes[m_format].materialType);
}
-QSGMaterialShader *QWaylandBufferMaterial::createShader() const
+QSGMaterialShader *QWaylandBufferMaterial::createShader(QSGRendererInterface::RenderMode renderMode) const
{
+ Q_UNUSED(renderMode);
return new QWaylandBufferMaterialShader(m_format);
}
@@ -248,8 +332,38 @@ void QWaylandBufferMaterial::ensureTextures(int count)
{
for (int plane = m_textures.size(); plane < count; plane++) {
m_textures << nullptr;
+ m_scenegraphTextures << nullptr;
}
}
+
+void QWaylandBufferMaterial::setBufferRef(QWaylandQuickItem *surfaceItem, const QWaylandBufferRef &ref)
+{
+ m_bufferRef = ref;
+ for (int plane = 0; plane < bufferTypes[ref.bufferFormatEgl()].planeCount; plane++) {
+ if (auto texture = ref.toOpenGLTexture(plane)) {
+ QQuickWindow::CreateTextureOptions opt;
+ QWaylandQuickSurface *waylandSurface = qobject_cast<QWaylandQuickSurface *>(surfaceItem->surface());
+ if (waylandSurface != nullptr && waylandSurface->useTextureAlpha() && !waylandSurface->isOpaque())
+ opt |= QQuickWindow::TextureHasAlphaChannel;
+ QSGTexture *scenegraphTexture;
+ if (ref.bufferFormatEgl() == QWaylandBufferRef::BufferFormatEgl_EXTERNAL_OES) {
+ scenegraphTexture = QNativeInterface::QSGOpenGLTexture::fromNativeExternalOES(texture->textureId(),
+ surfaceItem->window(),
+ ref.size(),
+ opt);
+ } else {
+ scenegraphTexture = QNativeInterface::QSGOpenGLTexture::fromNative(texture->textureId(),
+ surfaceItem->window(),
+ ref.size(),
+ opt);
+ }
+ scenegraphTexture->setFiltering(surfaceItem->smooth() ? QSGTexture::Linear : QSGTexture::Nearest);
+ setTextureForPlane(plane, texture, scenegraphTexture);
+ }
+ }
+
+ bind();
+}
#endif // QT_CONFIG(opengl)
QMutex *QWaylandQuickItemPrivate::mutex = nullptr;
@@ -263,8 +377,7 @@ public:
~QWaylandSurfaceTextureProvider() override
{
- if (m_sgTex)
- m_sgTex->deleteLater();
+ delete m_sgTex;
}
void setBufferRef(QWaylandQuickItem *surfaceItem, const QWaylandBufferRef &buffer)
@@ -276,21 +389,18 @@ public:
if (m_ref.hasBuffer()) {
if (buffer.isSharedMemory()) {
m_sgTex = surfaceItem->window()->createTextureFromImage(buffer.image());
-#if QT_CONFIG(opengl)
- if (m_sgTex)
- m_sgTex->bind();
-#endif
} else {
#if QT_CONFIG(opengl)
QQuickWindow::CreateTextureOptions opt;
QWaylandQuickSurface *surface = qobject_cast<QWaylandQuickSurface *>(surfaceItem->surface());
- if (surface && surface->useTextureAlpha()) {
+ if (surface && surface->useTextureAlpha() && !surface->isOpaque()) {
opt |= QQuickWindow::TextureHasAlphaChannel;
}
auto texture = buffer.toOpenGLTexture();
+ GLuint textureId = texture->textureId();
auto size = surface->bufferSize();
- m_sgTex = surfaceItem->window()->createTextureFromId(texture->textureId(), size, opt);
+ m_sgTex = QNativeInterface::QSGOpenGLTexture::fromNative(textureId, surfaceItem->window(), size, opt);
#else
qCWarning(qLcWaylandCompositor) << "Without OpenGL support only shared memory textures are supported";
#endif
@@ -315,6 +425,7 @@ private:
/*!
* \qmltype WaylandQuickItem
+ * \instantiates QWaylandQuickItem
* \inqmlmodule QtWayland.Compositor
* \since 5.8
* \brief Provides a Qt Quick item that represents a WaylandView.
@@ -339,9 +450,8 @@ private:
* Constructs a QWaylandQuickItem with the given \a parent.
*/
QWaylandQuickItem::QWaylandQuickItem(QQuickItem *parent)
- : QQuickItem(*new QWaylandQuickItemPrivate(), parent)
+ : QWaylandQuickItem(*new QWaylandQuickItemPrivate(), parent)
{
- d_func()->init();
}
/*!
@@ -351,6 +461,7 @@ QWaylandQuickItem::QWaylandQuickItem(QWaylandQuickItemPrivate &dd, QQuickItem *p
: QQuickItem(dd, parent)
{
d_func()->init();
+ connect(this, &QQuickItem::activeFocusChanged, this, &QWaylandQuickItem::updateFocus);
}
/*!
@@ -360,13 +471,16 @@ QWaylandQuickItem::~QWaylandQuickItem()
{
Q_D(QWaylandQuickItem);
disconnect(this, &QQuickItem::windowChanged, this, &QWaylandQuickItem::updateWindow);
+ disconnect(this, &QQuickItem::activeFocusChanged, this, &QWaylandQuickItem::updateFocus);
QMutexLocker locker(d->mutex);
- if (d->provider)
+ if (d->provider) {
+ disconnect(d->texProviderConnection);
d->provider->deleteLater();
+ }
}
/*!
- * \qmlproperty WaylandCompositor QtWaylandCompositor::WaylandQuickItem::compositor
+ * \qmlproperty WaylandCompositor QtWayland.Compositor::WaylandQuickItem::compositor
*
* This property holds the compositor for the surface rendered by this WaylandQuickItem.
*/
@@ -392,7 +506,7 @@ QWaylandView *QWaylandQuickItem::view() const
}
/*!
- * \qmlproperty WaylandSurface QtWaylandCompositor::WaylandQuickItem::surface
+ * \qmlproperty WaylandSurface QtWayland.Compositor::WaylandQuickItem::surface
*
* This property holds the surface rendered by this WaylandQuickItem.
*/
@@ -412,16 +526,21 @@ QWaylandSurface *QWaylandQuickItem::surface() const
void QWaylandQuickItem::setSurface(QWaylandSurface *surface)
{
Q_D(QWaylandQuickItem);
+ QWaylandSurface *oldSurf = d->view->surface();
QWaylandCompositor *oldComp = d->view->surface() ? d->view->surface()->compositor() : nullptr;
d->view->setSurface(surface);
QWaylandCompositor *newComp = d->view->surface() ? d->view->surface()->compositor() : nullptr;
if (oldComp != newComp)
emit compositorChanged();
+ if (oldSurf != surface)
+ emit surfaceChanged();
+
+ updateFocus();
update();
}
/*!
- * \qmlproperty enum QtWaylandCompositor::WaylandQuickItem::origin
+ * \qmlproperty enum QtWayland.Compositor::WaylandQuickItem::origin
*
* This property holds the origin of the QWaylandQuickItem.
*/
@@ -467,7 +586,7 @@ void QWaylandQuickItem::mousePressEvent(QMouseEvent *event)
return;
}
- if (!inputRegionContains(event->localPos())) {
+ if (!inputRegionContains(event->position())) {
event->ignore();
return;
}
@@ -477,9 +596,9 @@ void QWaylandQuickItem::mousePressEvent(QMouseEvent *event)
if (d->focusOnClick)
takeFocus(seat);
- seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->localPos()), event->windowPos());
+ seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->position()), event->scenePosition());
seat->sendMousePressEvent(event->button());
- d->hoverPos = event->localPos();
+ d->hoverPos = event->position();
}
/*!
@@ -494,21 +613,21 @@ void QWaylandQuickItem::mouseMoveEvent(QMouseEvent *event)
if (d->isDragging) {
QWaylandQuickOutput *currentOutput = qobject_cast<QWaylandQuickOutput *>(view()->output());
//TODO: also check if dragging onto other outputs
- QWaylandQuickItem *targetItem = qobject_cast<QWaylandQuickItem *>(currentOutput->pickClickableItem(mapToScene(event->localPos())));
+ QWaylandQuickItem *targetItem = qobject_cast<QWaylandQuickItem *>(currentOutput->pickClickableItem(mapToScene(event->position())));
QWaylandSurface *targetSurface = targetItem ? targetItem->surface() : nullptr;
if (targetSurface) {
- QPointF position = mapToItem(targetItem, event->localPos());
+ QPointF position = mapToItem(targetItem, event->position());
QPointF surfacePosition = targetItem->mapToSurface(position);
seat->drag()->dragMove(targetSurface, surfacePosition);
}
} else
#endif // QT_CONFIG(draganddrop)
{
- seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->localPos()), event->windowPos());
- d->hoverPos = event->localPos();
+ seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->position()), event->scenePosition());
+ d->hoverPos = event->position();
}
} else {
- emit mouseMove(event->windowPos());
+ emit mouseMove(event->scenePosition());
event->ignore();
}
}
@@ -542,14 +661,14 @@ void QWaylandQuickItem::mouseReleaseEvent(QMouseEvent *event)
void QWaylandQuickItem::hoverEnterEvent(QHoverEvent *event)
{
Q_D(QWaylandQuickItem);
- if (!inputRegionContains(event->posF())) {
+ if (!inputRegionContains(event->position())) {
event->ignore();
return;
}
if (d->shouldSendInputEvents()) {
QWaylandSeat *seat = compositor()->seatFor(event);
- seat->sendMouseMoveEvent(d->view.data(), event->posF(), mapToScene(event->posF()));
- d->hoverPos = event->posF();
+ seat->sendMouseMoveEvent(d->view.data(), event->position(), mapToScene(event->position()));
+ d->hoverPos = event->position();
} else {
event->ignore();
}
@@ -562,16 +681,16 @@ void QWaylandQuickItem::hoverMoveEvent(QHoverEvent *event)
{
Q_D(QWaylandQuickItem);
if (surface()) {
- if (!inputRegionContains(event->posF())) {
+ if (!inputRegionContains(event->position())) {
event->ignore();
return;
}
}
if (d->shouldSendInputEvents()) {
QWaylandSeat *seat = compositor()->seatFor(event);
- if (event->posF() != d->hoverPos) {
- seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->posF()), mapToScene(event->posF()));
- d->hoverPos = event->posF();
+ if (event->position() != d->hoverPos) {
+ seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->position()), mapToScene(event->position()));
+ d->hoverPos = event->position();
}
} else {
event->ignore();
@@ -640,7 +759,7 @@ void QWaylandQuickItem::keyPressEvent(QKeyEvent *event)
void QWaylandQuickItem::keyReleaseEvent(QKeyEvent *event)
{
Q_D(QWaylandQuickItem);
- if (d->shouldSendInputEvents() && hasFocus()) {
+ if (d->shouldSendInputEvents()) {
QWaylandSeat *seat = compositor()->seatFor(event);
seat->sendFullKeyEvent(event);
} else {
@@ -658,9 +777,9 @@ void QWaylandQuickItem::touchEvent(QTouchEvent *event)
QWaylandSeat *seat = compositor()->seatFor(event);
QPointF pointPos;
- const QList<QTouchEvent::TouchPoint> &points = event->touchPoints();
+ const QList<QTouchEvent::TouchPoint> &points = event->points();
if (!points.isEmpty())
- pointPos = points.at(0).pos();
+ pointPos = points.at(0).position();
if (event->type() == QEvent::TouchBegin && !inputRegionContains(pointPos)) {
event->ignore();
@@ -729,10 +848,16 @@ void QWaylandQuickItem::handleSubsurfaceAdded(QWaylandSurface *childSurface)
childItem->setSurface(childSurface);
childItem->setVisible(true);
childItem->setParentItem(this);
+ childItem->setParent(this);
connect(childSurface, &QWaylandSurface::subsurfacePositionChanged, childItem, &QWaylandQuickItem::handleSubsurfacePosition);
+ connect(childSurface, &QWaylandSurface::destroyed, childItem, &QObject::deleteLater);
} else {
bool success = QMetaObject::invokeMethod(d->subsurfaceHandler, "handleSubsurfaceAdded", Q_ARG(QWaylandSurface *, childSurface));
if (!success)
+ success = QMetaObject::invokeMethod(d->subsurfaceHandler, "handleSubsurfaceAdded",
+ Q_ARG(QVariant, QVariant::fromValue(childSurface)));
+
+ if (!success)
qWarning("QWaylandQuickItem: subsurfaceHandler does not implement handleSubsurfaceAdded()");
}
}
@@ -771,8 +896,15 @@ void QWaylandQuickItem::handlePlaceBelow(QWaylandSurface *referenceSurface)
}
}
+void QWaylandQuickItem::updateFocus()
+{
+ Q_D(const QWaylandQuickItem);
+ if (hasActiveFocus() && compositor())
+ compositor()->defaultSeat()->setKeyboardFocus(d->view->surface());
+}
+
/*!
- \qmlproperty object QtWaylandCompositor::WaylandQuickItem::subsurfaceHandler
+ \qmlproperty object QtWayland.Compositor::WaylandQuickItem::subsurfaceHandler
This property provides a way to override the default subsurface behavior.
@@ -784,8 +916,9 @@ void QWaylandQuickItem::handlePlaceBelow(QWaylandSurface *referenceSurface)
\code
ShellSurfaceItem {
subsurfaceHandler: QtObject {
- function handleSubsurfaceAdded(child) {
- //create custom surface item, and connect the subsurfacePositionChanged signal
+ function handleSubsurfaceAdded(child) {
+ // create custom surface item, and connect the subsurfacePositionChanged signal
+ }
}
}
\endcode
@@ -810,6 +943,11 @@ void QWaylandQuickItem::setSubsurfaceHandler(QObject *handler)
}
/*!
+ * \qmlproperty WaylandOutput QtWayland.Compositor::WaylandQuickItem::output
+ *
+ * This property holds the output on which this item is displayed.
+ */
+/*!
* \property QWaylandQuickItem::output
*
* This property holds the output on which this item is displayed.
@@ -827,7 +965,7 @@ void QWaylandQuickItem::setOutput(QWaylandOutput *output)
}
/*!
- * \qmlproperty bool QtWaylandCompositor::WaylandQuickItem::bufferLocked
+ * \qmlproperty bool QtWayland.Compositor::WaylandQuickItem::bufferLocked
*
* This property holds whether the item's buffer is currently locked. As long as
* the buffer is locked, it will not be released and returned to the client.
@@ -852,6 +990,10 @@ void QWaylandQuickItem::setBufferLocked(bool locked)
{
Q_D(QWaylandQuickItem);
d->view->setBufferLocked(locked);
+
+ // Apply the latest surface size
+ if (!locked)
+ updateSize();
}
/*!
@@ -961,7 +1103,7 @@ void QWaylandQuickItem::takeFocus(QWaylandSeat *device)
{
forceActiveFocus();
- if (!surface())
+ if (!surface() || !surface()->client())
return;
QWaylandSeat *target = device;
@@ -969,9 +1111,27 @@ void QWaylandQuickItem::takeFocus(QWaylandSeat *device)
target = compositor()->defaultSeat();
}
target->setKeyboardFocus(surface());
- QWaylandTextInput *textInput = QWaylandTextInput::findIn(target);
- if (textInput)
- textInput->setFocus(surface());
+
+ qCDebug(qLcWaylandCompositorInputMethods) << Q_FUNC_INFO << " surface:" << surface()
+ << ", client:" << surface()->client()
+ << ", textinputprotocol:" << (int)(surface()->client()->textInputProtocols());
+ if (surface()->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::TextInputV2)) {
+ QWaylandTextInput *textInput = QWaylandTextInput::findIn(target);
+ if (textInput)
+ textInput->setFocus(surface());
+ }
+
+ if (surface()->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::TextInputV3)) {
+ QWaylandTextInputV3 *textInputV3 = QWaylandTextInputV3::findIn(target);
+ if (textInputV3)
+ textInputV3->setFocus(surface());
+ }
+
+ if (surface()->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::QtTextInputMethodV1)) {
+ QWaylandQtTextInputMethod *textInputMethod = QWaylandQtTextInputMethod::findIn(target);
+ if (textInputMethod)
+ textInputMethod->setFocus(surface());
+ }
}
/*!
@@ -1004,17 +1164,21 @@ void QWaylandQuickItem::updateSize()
{
Q_D(QWaylandQuickItem);
+ // No resize if buffer is locked
+ if (isBufferLocked()) {
+ qWarning() << "No update on item size as the buffer is currently locked";
+ return;
+ }
+
QSize size(0, 0);
if (surface())
size = surface()->destinationSize() * d->scaleFactor();
setImplicitSize(size.width(), size.height());
- if (d->sizeFollowsSurface)
- setSize(size);
}
/*!
- * \qmlproperty bool QtWaylandCompositor::WaylandQuickItem::focusOnClick
+ * \qmlproperty bool QtWayland.Compositor::WaylandQuickItem::focusOnClick
*
* This property specifies whether the WaylandQuickItem should take focus when
* it is clicked or touched.
@@ -1057,16 +1221,6 @@ bool QWaylandQuickItem::inputRegionContains(const QPointF &localPosition) const
return false;
}
-// Qt 6: Remove the non-const version
-/*!
- * Returns \c true if the input region of this item's surface contains the
- * position given by \a localPosition.
- */
-bool QWaylandQuickItem::inputRegionContains(const QPointF &localPosition)
-{
- return const_cast<const QWaylandQuickItem *>(this)->inputRegionContains(localPosition);
-}
-
/*!
* \qmlmethod point WaylandQuickItem::mapToSurface(point point)
*
@@ -1118,41 +1272,6 @@ QPointF QWaylandQuickItem::mapFromSurface(const QPointF &point) const
return QPointF(point.x() * xScale, point.y() * yScale);
}
-/*!
- * \qmlproperty bool QtWaylandCompositor::WaylandQuickItem::sizeFollowsSurface
- *
- * This property specifies whether the size of the item should always match
- * the size of its surface.
- *
- * The default is \c true.
- */
-
-/*!
- * \property QWaylandQuickItem::sizeFollowsSurface
- *
- * This property specifies whether the size of the item should always match
- * the size of its surface.
- *
- * The default is \c true.
- */
-bool QWaylandQuickItem::sizeFollowsSurface() const
-{
- Q_D(const QWaylandQuickItem);
- 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);
- if (d->sizeFollowsSurface == sizeFollowsSurface)
- return;
- d->sizeFollowsSurface = sizeFollowsSurface;
- emit sizeFollowsSurfaceChanged();
-}
-
#if QT_CONFIG(im)
QVariant QWaylandQuickItem::inputMethodQuery(Qt::InputMethodQuery query) const
{
@@ -1174,7 +1293,7 @@ QVariant QWaylandQuickItem::inputMethodQuery(Qt::InputMethodQuery query, QVarian
#endif
/*!
- \qmlproperty bool QtWaylandCompositor::WaylandQuickItem::paintEnabled
+ \qmlproperty bool QtWayland.Compositor::WaylandQuickItem::paintEnabled
Returns true if the item is hidden, though the texture
is still updated. As opposed to hiding the item by
@@ -1183,12 +1302,14 @@ QVariant QWaylandQuickItem::inputMethodQuery(Qt::InputMethodQuery query, QVarian
*/
/*!
- Returns true if the item is hidden, though the texture
+ \property QWaylandQuickItem::paintEnabled
+
+ Holds \c 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 false
+ setting \l{QQuickItem::}{visible} to \c false, setting this property to \c false
will not prevent mouse or keyboard input from reaching item.
*/
-bool QWaylandQuickItem::paintEnabled() const
+bool QWaylandQuickItem::isPaintEnabled() const
{
Q_D(const QWaylandQuickItem);
return d->paintEnabled;
@@ -1197,10 +1318,28 @@ bool QWaylandQuickItem::paintEnabled() const
void QWaylandQuickItem::setPaintEnabled(bool enabled)
{
Q_D(QWaylandQuickItem);
- d->paintEnabled = enabled;
+
+ if (enabled != d->paintEnabled) {
+ d->paintEnabled = enabled;
+ emit paintEnabledChanged();
+ }
+
update();
}
+/*!
+ \qmlproperty bool QtWayland.Compositor::WaylandQuickItem::touchEventsEnabled
+
+ This property holds \c true if touch events are forwarded to the client
+ surface, \c false otherwise.
+*/
+
+/*!
+ \property QWaylandQuickItem::touchEventsEnabled
+
+ This property holds \c true if touch events are forwarded to the client
+ surface, \c false otherwise.
+*/
bool QWaylandQuickItem::touchEventsEnabled() const
{
Q_D(const QWaylandQuickItem);
@@ -1235,15 +1374,15 @@ void QWaylandQuickItem::updateWindow()
if (d->connectedWindow) {
connect(d->connectedWindow, &QQuickWindow::beforeSynchronizing, this, &QWaylandQuickItem::beforeSync, Qt::DirectConnection);
connect(d->connectedWindow, &QQuickWindow::screenChanged, this, &QWaylandQuickItem::updateSize); // new screen may have new dpr
- }
- if (compositor() && d->connectedWindow) {
- QWaylandOutput *output = compositor()->outputFor(d->connectedWindow);
- Q_ASSERT(output);
- d->view->setOutput(output);
- }
+ if (compositor()) {
+ QWaylandOutput *output = compositor()->outputFor(d->connectedWindow);
+ Q_ASSERT(output);
+ d->view->setOutput(output);
+ }
- updateSize(); // because scaleFactor depends on devicePixelRatio, which may be different for the new window
+ updateSize(); // because scaleFactor depends on devicePixelRatio, which may be different for the new window
+ }
}
void QWaylandQuickItem::updateOutput()
@@ -1284,7 +1423,7 @@ void QWaylandQuickItem::updateInputMethod(Qt::InputMethodQueries queries)
#endif
/*!
- * \qmlsignal void QtWaylandCompositor::WaylandQuickItem::surfaceDestroyed()
+ * \qmlsignal void QtWayland.Compositor::WaylandQuickItem::surfaceDestroyed()
*
* This signal is emitted when the client has destroyed the \c wl_surface associated
* with the WaylandQuickItem. The handler for this signal is expected to either destroy the
@@ -1315,7 +1454,7 @@ QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat
d->lastMatrix = data->transformNode->combinedMatrix();
const bool bufferHasContent = d->view->currentBuffer().hasContent();
- if (d->view->isBufferLocked() && !bufferHasContent && d->paintEnabled)
+ if (d->view->isBufferLocked() && d->paintEnabled)
return oldNode;
if (!bufferHasContent || !d->paintEnabled || !surface()) {
@@ -1333,16 +1472,42 @@ QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat
|| bufferTypes[ref.bufferFormatEgl()].canProvideTexture
#endif
) {
+#if QT_CONFIG(opengl)
+ if (oldNode && !d->paintByProvider) {
+ // Need to re-create a node
+ delete oldNode;
+ oldNode = nullptr;
+ }
+ d->paintByProvider = true;
+#endif
// This case could covered by the more general path below, but this is more efficient (especially when using ShaderEffect items).
QSGSimpleTextureNode *node = static_cast<QSGSimpleTextureNode *>(oldNode);
if (!node) {
node = new QSGSimpleTextureNode();
+ if (smooth())
+ node->setFiltering(QSGTexture::Linear);
d->newTexture = true;
}
- if (!d->provider)
+ if (!d->provider) {
d->provider = new QWaylandSurfaceTextureProvider();
+ if (compositor()) {
+ d->texProviderConnection =
+ QObject::connect(
+ compositor(),
+ &QObject::destroyed,
+ this,
+ [this](QObject*) {
+ auto *itemPriv = QWaylandQuickItemPrivate::get(this);
+ if (itemPriv->provider) {
+ itemPriv->provider->deleteLater();
+ itemPriv->provider = nullptr;
+ }
+ disconnect(itemPriv->texProviderConnection); }
+ );
+ }
+ }
if (d->newTexture) {
d->newTexture = false;
@@ -1363,6 +1528,13 @@ QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat
#if QT_CONFIG(opengl)
Q_ASSERT(!d->provider);
+ if (oldNode && d->paintByProvider) {
+ // Need to re-create a node
+ delete oldNode;
+ oldNode = nullptr;
+ }
+ d->paintByProvider = false;
+
QSGGeometryNode *node = static_cast<QSGGeometryNode *>(oldNode);
if (!node) {
@@ -1381,13 +1553,20 @@ QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat
if (d->newTexture) {
d->newTexture = false;
- for (int plane = 0; plane < bufferTypes[ref.bufferFormatEgl()].planeCount; plane++)
- if (auto texture = ref.toOpenGLTexture(plane))
- material->setTextureForPlane(plane, texture);
- material->bind();
+ material->setBufferRef(this, ref);
}
- QSGGeometry::updateTexturedRectGeometry(geometry, rect, QRectF(0, 0, 1, 1));
+ const QSize surfaceSize = ref.size() / surface()->bufferScale();
+ const QRectF sourceGeometry = surface()->sourceGeometry();
+ const QRectF normalizedCoordinates =
+ sourceGeometry.isValid()
+ ? QRectF(sourceGeometry.x() / surfaceSize.width(),
+ sourceGeometry.y() / surfaceSize.height(),
+ sourceGeometry.width() / surfaceSize.width(),
+ sourceGeometry.height() / surfaceSize.height())
+ : QRectF(0, 0, 1, 1);
+
+ QSGGeometry::updateTexturedRectGeometry(geometry, rect, normalizedCoordinates);
node->setGeometry(geometry);
node->setFlag(QSGNode::OwnsGeometry, true);
@@ -1430,20 +1609,34 @@ void QWaylandQuickItem::setInputEventsEnabled(bool enabled)
void QWaylandQuickItem::lower()
{
- QQuickItem *parent = parentItem();
+ Q_D(QWaylandQuickItem);
+ d->lower();
+}
+
+void QWaylandQuickItemPrivate::lower()
+{
+ Q_Q(QWaylandQuickItem);
+ QQuickItem *parent = q->parentItem();
Q_ASSERT(parent);
- QQuickItem *bottom = parent->childItems().first();
- if (this != bottom)
- stackBefore(bottom);
+ QQuickItem *bottom = parent->childItems().constFirst();
+ if (q != bottom)
+ q->stackBefore(bottom);
}
void QWaylandQuickItem::raise()
{
- QQuickItem *parent = parentItem();
+ Q_D(QWaylandQuickItem);
+ d->raise();
+}
+
+void QWaylandQuickItemPrivate::raise()
+{
+ Q_Q(QWaylandQuickItem);
+ QQuickItem *parent = q->parentItem();
Q_ASSERT(parent);
- QQuickItem *top = parent->childItems().last();
- if (this != top)
- stackAfter(top);
+ QQuickItem *top = parent->childItems().constLast();
+ if (q != top)
+ q->stackAfter(top);
}
void QWaylandQuickItem::sendMouseMoveEvent(const QPointF &position, QWaylandSeat *seat)
@@ -1573,3 +1766,5 @@ void QWaylandQuickItemPrivate::placeBelowParent()
}
QT_END_NAMESPACE
+
+#include "moc_qwaylandquickitem.cpp"
diff --git a/src/compositor/compositor_api/qwaylandquickitem.h b/src/compositor/compositor_api/qwaylandquickitem.h
index 7731933e7..d30528a8a 100644
--- a/src/compositor/compositor_api/qwaylandquickitem.h
+++ b/src/compositor/compositor_api/qwaylandquickitem.h
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDSURFACEITEM_H
#define QWAYLANDSURFACEITEM_H
@@ -42,27 +16,33 @@
Q_DECLARE_METATYPE(QWaylandQuickSurface*)
+QT_REQUIRE_CONFIG(wayland_compositor_quick);
+
QT_BEGIN_NAMESPACE
class QWaylandSeat;
class QWaylandQuickItemPrivate;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickItem : public QQuickItem
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickItem : public QQuickItem
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandQuickItem)
Q_PROPERTY(QWaylandCompositor *compositor READ compositor NOTIFY compositorChanged)
Q_PROPERTY(QWaylandSurface *surface READ surface WRITE setSurface NOTIFY surfaceChanged)
- Q_PROPERTY(bool paintEnabled READ paintEnabled WRITE setPaintEnabled)
+ Q_PROPERTY(bool paintEnabled READ isPaintEnabled WRITE setPaintEnabled NOTIFY paintEnabledChanged)
Q_PROPERTY(bool touchEventsEnabled READ touchEventsEnabled WRITE setTouchEventsEnabled NOTIFY touchEventsEnabledChanged)
Q_PROPERTY(QWaylandSurface::Origin origin READ origin NOTIFY originChanged)
Q_PROPERTY(bool inputEventsEnabled READ inputEventsEnabled WRITE setInputEventsEnabled NOTIFY inputEventsEnabledChanged)
Q_PROPERTY(bool focusOnClick READ focusOnClick WRITE setFocusOnClick NOTIFY focusOnClickChanged)
- Q_PROPERTY(bool sizeFollowsSurface READ sizeFollowsSurface WRITE setSizeFollowsSurface NOTIFY sizeFollowsSurfaceChanged)
Q_PROPERTY(QObject *subsurfaceHandler READ subsurfaceHandler WRITE setSubsurfaceHandler NOTIFY subsurfaceHandlerChanged)
Q_PROPERTY(QWaylandOutput *output READ output WRITE setOutput NOTIFY outputChanged)
Q_PROPERTY(bool bufferLocked READ isBufferLocked WRITE setBufferLocked NOTIFY bufferLockedChanged)
Q_PROPERTY(bool allowDiscardFrontBuffer READ allowDiscardFrontBuffer WRITE setAllowDiscardFrontBuffer NOTIFY allowDiscardFrontBufferChanged)
+ Q_MOC_INCLUDE("qwaylandcompositor.h")
+ Q_MOC_INCLUDE("qwaylandseat.h")
+ Q_MOC_INCLUDE("qwaylanddrag.h")
+ QML_NAMED_ELEMENT(WaylandQuickItem)
+ QML_ADDED_IN_VERSION(1, 0)
public:
QWaylandQuickItem(QQuickItem *parent = nullptr);
~QWaylandQuickItem() override;
@@ -78,7 +58,7 @@ public:
bool isTextureProvider() const override;
QSGTextureProvider *textureProvider() const override;
- bool paintEnabled() const;
+ bool isPaintEnabled() const;
bool touchEventsEnabled() const;
void setTouchEventsEnabled(bool enabled);
@@ -90,12 +70,8 @@ public:
void setFocusOnClick(bool focus);
bool inputRegionContains(const QPointF &localPosition) const;
- bool inputRegionContains(const QPointF &localPosition);
Q_INVOKABLE QPointF mapToSurface(const QPointF &point) const;
- Q_REVISION(13) Q_INVOKABLE QPointF mapFromSurface(const QPointF &point) const;
-
- bool sizeFollowsSurface() const;
- void setSizeFollowsSurface(bool sizeFollowsSurface);
+ Q_REVISION(1, 13) Q_INVOKABLE QPointF mapFromSurface(const QPointF &point) const;
#if QT_CONFIG(im)
QVariant inputMethodQuery(Qt::InputMethodQuery query) const override;
@@ -164,10 +140,12 @@ private Q_SLOTS:
#if QT_CONFIG(im)
void updateInputMethod(Qt::InputMethodQueries queries);
#endif
+ void updateFocus();
Q_SIGNALS:
void surfaceChanged();
void compositorChanged();
+ void paintEnabledChanged();
void touchEventsEnabledChanged();
void originChanged();
void surfaceDestroyed();
@@ -175,7 +153,6 @@ Q_SIGNALS:
void focusOnClickChanged();
void mouseMove(const QPointF &windowPosition);
void mouseRelease();
- void sizeFollowsSurfaceChanged();
void subsurfaceHandlerChanged();
void outputChanged();
void bufferLockedChanged();
diff --git a/src/compositor/compositor_api/qwaylandquickitem_p.h b/src/compositor/compositor_api/qwaylandquickitem_p.h
index a75cdb2ba..0ddabc7da 100644
--- a/src/compositor/compositor_api/qwaylandquickitem_p.h
+++ b/src/compositor/compositor_api/qwaylandquickitem_p.h
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDQUICKITEM_P_H
#define QWAYLANDQUICKITEM_P_H
@@ -48,6 +22,8 @@
#include <QtWaylandCompositor/QWaylandQuickItem>
#include <QtWaylandCompositor/QWaylandOutput>
+#include <QtCore/qpointer.h>
+
QT_BEGIN_NAMESPACE
class QWaylandSurfaceTextureProvider;
@@ -60,17 +36,11 @@ class QWaylandBufferMaterialShader : public QSGMaterialShader
public:
QWaylandBufferMaterialShader(QWaylandBufferRef::BufferFormatEgl format);
- void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
- char const *const *attributeNames() const override;
-
-protected:
- void initialize() override;
-
-private:
- const QWaylandBufferRef::BufferFormatEgl m_format;
- int m_id_matrix;
- int m_id_opacity;
- QVarLengthArray<int, 3> m_id_tex;
+ bool updateUniformData(RenderState &state,
+ QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
+ void updateSampledImage(RenderState &state, int binding, QSGTexture **texture,
+ QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
+ void setupExternalOESShader(const QString &shaderFilename);
};
class QWaylandBufferMaterial : public QSGMaterial
@@ -79,19 +49,25 @@ public:
QWaylandBufferMaterial(QWaylandBufferRef::BufferFormatEgl format);
~QWaylandBufferMaterial() override;
- void setTextureForPlane(int plane, QOpenGLTexture *texture);
+ void setTextureForPlane(int plane, QOpenGLTexture *texture, QSGTexture *scenegraphTexture);
+ void setBufferRef(QWaylandQuickItem *surfaceItem, const QWaylandBufferRef &ref);
void bind();
+ void updateScenegraphTextures(QRhi *rhi);
QSGMaterialType *type() const override;
- QSGMaterialShader *createShader() const override;
+ QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
private:
+ friend QWaylandBufferMaterialShader;
+
void setTextureParameters(GLenum target);
void ensureTextures(int count);
const QWaylandBufferRef::BufferFormatEgl m_format;
QVarLengthArray<QOpenGLTexture*, 3> m_textures;
+ QVarLengthArray<QSGTexture*, 3> m_scenegraphTextures;
+ QWaylandBufferRef m_bufferRef;
};
#endif // QT_CONFIG(opengl)
@@ -137,6 +113,7 @@ public:
Qt::ExtraButton5 | Qt::ExtraButton6 | Qt::ExtraButton7 | Qt::ExtraButton8 |
Qt::ExtraButton9 | Qt::ExtraButton10 | Qt::ExtraButton11 |
Qt::ExtraButton12 | Qt::ExtraButton13) : Qt::NoButton);
+ q->setAcceptTouchEvents(enable);
q->setAcceptHoverEvents(enable);
inputEventsEnabled = enable;
}
@@ -150,19 +127,25 @@ public:
void placeAboveParent();
void placeBelowParent();
+ virtual void raise();
+ virtual void lower();
+
static QMutex *mutex;
QScopedPointer<QWaylandView> view;
QPointer<QWaylandSurface> oldSurface;
mutable QWaylandSurfaceTextureProvider *provider = nullptr;
+ QMetaObject::Connection texProviderConnection;
bool paintEnabled = true;
bool touchEventsEnabled = true;
bool inputEventsEnabled = true;
bool isDragging = false;
bool newTexture = false;
bool focusOnClick = true;
- bool sizeFollowsSurface = true;
bool belowParent = false;
+#if QT_CONFIG(opengl)
+ bool paintByProvider = false;
+#endif
QPointF hoverPos;
QMatrix4x4 lastMatrix;
@@ -170,7 +153,7 @@ public:
QWaylandOutput *connectedOutput = nullptr;
QWaylandSurface::Origin origin = QWaylandSurface::OriginTopLeft;
QPointer<QObject> subsurfaceHandler;
- QVector<QWaylandSeat *> touchingSeats;
+ QList<QWaylandSeat *> touchingSeats;
};
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandquickoutput.cpp b/src/compositor/compositor_api/qwaylandquickoutput.cpp
index acb907960..de6c3ede4 100644
--- a/src/compositor/compositor_api/qwaylandquickoutput.cpp
+++ b/src/compositor/compositor_api/qwaylandquickoutput.cpp
@@ -1,32 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qwaylandquickoutput.h"
#include "qwaylandquickcompositor.h"
@@ -86,7 +60,7 @@ void QWaylandQuickOutput::update()
}
/*!
- * \qmlproperty bool QtWaylandCompositor::WaylandOutput::automaticFrameCallback
+ * \qmlproperty bool QtWayland.Compositor::WaylandOutput::automaticFrameCallback
*
* This property holds whether the WaylandOutput automatically sends frame
* callbacks when rendering.
@@ -164,3 +138,5 @@ void QWaylandQuickOutput::doFrameCallbacks()
sendFrameCallbacks();
}
QT_END_NAMESPACE
+
+#include "moc_qwaylandquickoutput.cpp"
diff --git a/src/compositor/compositor_api/qwaylandquickoutput.h b/src/compositor/compositor_api/qwaylandquickoutput.h
index 636dc6d7e..c5fde60ff 100644
--- a/src/compositor/compositor_api/qwaylandquickoutput.h
+++ b/src/compositor/compositor_api/qwaylandquickoutput.h
@@ -1,32 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDQUICKOUTPUT_H
#define QWAYLANDQUICKOUTPUT_H
@@ -35,17 +9,21 @@
#include <QtWaylandCompositor/qwaylandoutput.h>
#include <QtWaylandCompositor/qwaylandquickchildren.h>
+QT_REQUIRE_CONFIG(wayland_compositor_quick);
+
QT_BEGIN_NAMESPACE
class QWaylandQuickCompositor;
class QQuickWindow;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickOutput : public QWaylandOutput, public QQmlParserStatus
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickOutput : public QWaylandOutput, public QQmlParserStatus
{
Q_INTERFACES(QQmlParserStatus)
Q_OBJECT
Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandQuickOutput)
Q_PROPERTY(bool automaticFrameCallback READ automaticFrameCallback WRITE setAutomaticFrameCallback NOTIFY automaticFrameCallbackChanged)
+ QML_NAMED_ELEMENT(WaylandOutput)
+ QML_ADDED_IN_VERSION(1, 0)
public:
QWaylandQuickOutput();
QWaylandQuickOutput(QWaylandCompositor *compositor, QWindow *window);
diff --git a/src/compositor/compositor_api/qwaylandquicksurface.cpp b/src/compositor/compositor_api/qwaylandquicksurface.cpp
index 8b2f13a30..920415d68 100644
--- a/src/compositor/compositor_api/qwaylandquicksurface.cpp
+++ b/src/compositor/compositor_api/qwaylandquicksurface.cpp
@@ -1,38 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QSGTexture>
-#include <QOpenGLTexture>
#include <QQuickWindow>
#include <QDebug>
#include "qwaylandquicksurface.h"
+#include "qwaylandquicksurface_p.h"
#include "qwaylandquickcompositor.h"
#include "qwaylandquickitem.h"
#include <QtWaylandCompositor/qwaylandbufferref.h>
@@ -41,22 +15,6 @@
QT_BEGIN_NAMESPACE
-class QWaylandQuickSurfacePrivate : public QWaylandSurfacePrivate
-{
- Q_DECLARE_PUBLIC(QWaylandQuickSurface)
-public:
- QWaylandQuickSurfacePrivate()
- {
- }
-
- ~QWaylandQuickSurfacePrivate() override
- {
- }
-
- bool useTextureAlpha = true;
- bool clientRenderingEnabled = true;
-};
-
QWaylandQuickSurface::QWaylandQuickSurface()
: QWaylandSurface(* new QWaylandQuickSurfacePrivate())
{
@@ -68,13 +26,18 @@ QWaylandQuickSurface::QWaylandQuickSurface(QWaylandCompositor *compositor, QWayl
initialize(compositor, client, id, version);
}
+QWaylandQuickSurface::QWaylandQuickSurface(QWaylandQuickSurfacePrivate &dptr)
+ : QWaylandSurface(dptr)
+{
+}
+
QWaylandQuickSurface::~QWaylandQuickSurface()
{
}
/*!
- * \qmlproperty bool QtWaylandCompositor::WaylandSurface::useTextureAlpha
+ * \qmlproperty bool QtWayland.Compositor::WaylandSurface::useTextureAlpha
*
* This property specifies whether the surface should use texture alpha.
*/
@@ -94,28 +57,6 @@ void QWaylandQuickSurface::setUseTextureAlpha(bool useTextureAlpha)
}
}
-/*!
- * \qmlproperty bool QtWaylandCompositor::WaylandSurface::clientRenderingEnabled
- * \deprecated
- *
- * 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
-{
- Q_D(const QWaylandQuickSurface);
- return d->clientRenderingEnabled;
-}
-
-void QWaylandQuickSurface::setClientRenderingEnabled(bool enabled)
-{
- Q_D(QWaylandQuickSurface);
- qWarning() << Q_FUNC_INFO << "doesn't do anything";
- if (d->clientRenderingEnabled != enabled) {
- d->clientRenderingEnabled = enabled;
- emit clientRenderingEnabledChanged();
- }
-}
-
QT_END_NAMESPACE
+
+#include "moc_qwaylandquicksurface.cpp"
diff --git a/src/compositor/compositor_api/qwaylandquicksurface.h b/src/compositor/compositor_api/qwaylandquicksurface.h
index 394fc8e01..5ed26cfe2 100644
--- a/src/compositor/compositor_api/qwaylandquicksurface.h
+++ b/src/compositor/compositor_api/qwaylandquicksurface.h
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QQUICKWAYLANDSURFACE_H
#define QQUICKWAYLANDSURFACE_H
@@ -35,18 +9,21 @@
struct wl_client;
+QT_REQUIRE_CONFIG(wayland_compositor_quick);
+
QT_BEGIN_NAMESPACE
class QWaylandQuickSurfacePrivate;
class QWaylandQuickCompositor;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickSurface : public QWaylandSurface
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickSurface : public QWaylandSurface
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandQuickSurface)
Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandQuickSurface)
Q_PROPERTY(bool useTextureAlpha READ useTextureAlpha WRITE setUseTextureAlpha NOTIFY useTextureAlphaChanged)
- Q_PROPERTY(bool clientRenderingEnabled READ clientRenderingEnabled WRITE setClientRenderingEnabled NOTIFY clientRenderingEnabledChanged)
+ QML_NAMED_ELEMENT(WaylandSurface)
+ QML_ADDED_IN_VERSION(1, 0)
public:
QWaylandQuickSurface();
QWaylandQuickSurface(QWaylandCompositor *compositor, QWaylandClient *client, quint32 id, int version);
@@ -55,12 +32,11 @@ public:
bool useTextureAlpha() const;
void setUseTextureAlpha(bool useTextureAlpha);
- Q_DECL_DEPRECATED bool clientRenderingEnabled() const;
- Q_DECL_DEPRECATED void setClientRenderingEnabled(bool enabled);
+protected:
+ QWaylandQuickSurface(QWaylandQuickSurfacePrivate &dptr);
Q_SIGNALS:
void useTextureAlphaChanged();
- void clientRenderingEnabledChanged(); //deprecated
};
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandquicksurface_p.h b/src/compositor/compositor_api/qwaylandquicksurface_p.h
new file mode 100644
index 000000000..8426276b0
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandquicksurface_p.h
@@ -0,0 +1,40 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef QWAYLANDQUICKSURFACE_P_H
+#define QWAYLANDQUICKSURFACE_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/private/qwaylandsurface_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickSurfacePrivate : public QWaylandSurfacePrivate
+{
+ Q_DECLARE_PUBLIC(QWaylandQuickSurface)
+public:
+ QWaylandQuickSurfacePrivate()
+ {
+ }
+
+ ~QWaylandQuickSurfacePrivate() override
+ {
+ }
+
+ bool useTextureAlpha = true;
+ bool clientRenderingEnabled = true;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDQUICKSURFACE_P_H
diff --git a/src/compositor/compositor_api/qwaylandresource.cpp b/src/compositor/compositor_api/qwaylandresource.cpp
index 585b238cd..fc744c4b6 100644
--- a/src/compositor/compositor_api/qwaylandresource.cpp
+++ b/src/compositor/compositor_api/qwaylandresource.cpp
@@ -1,43 +1,44 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qwaylandresource.h"
QT_BEGIN_NAMESPACE
+/*!
+ * \class QWaylandResource
+ * \inmodule QtWaylandCompositor
+ * \since 5.8
+ * \brief QWaylandResource is a container for a \c wl_resource.
+ *
+ * The QWaylandResource is a simple wrapper around the Wayland type \c wl_resource, and makes it
+ * possible to use wl_resource pointers in Qt Quick APIs.
+ *
+ * \sa {Custom Shell}
+ */
+
+/*!
+ * Constructs an invalid QWaylandResource. The \l{resource()} accessor will return null.
+ */
QWaylandResource::QWaylandResource()
{
}
+/*!
+ * Constructs a QWaylandResource which contains \a resource.
+ */
QWaylandResource::QWaylandResource(wl_resource *resource)
: m_resource(resource)
{
}
+/*!
+ * \fn wl_resource *QWaylandResource::resource() const
+ *
+ * \return the wl_resource pointer held by this QWaylandResource.
+ */
+
QT_END_NAMESPACE
+
+#include "moc_qwaylandresource.cpp"
diff --git a/src/compositor/compositor_api/qwaylandresource.h b/src/compositor/compositor_api/qwaylandresource.h
index fda1200d3..ab8897700 100644
--- a/src/compositor/compositor_api/qwaylandresource.h
+++ b/src/compositor/compositor_api/qwaylandresource.h
@@ -1,45 +1,23 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDRESOURCE_H
#define QWAYLANDRESOURCE_H
#include <QtCore/QObject>
#include <QtWaylandCompositor/qtwaylandcompositorglobal.h>
+#include <QtWaylandCompositor/qtwaylandqmlinclude.h>
struct wl_resource;
QT_BEGIN_NAMESPACE
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandResource
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandResource
{
Q_GADGET
+ QML_NAMED_ELEMENT(waylandresource)
+ QML_UNCREATABLE("")
+ QML_ADDED_IN_VERSION(1, 0)
public:
QWaylandResource();
explicit QWaylandResource(wl_resource *resource);
diff --git a/src/compositor/compositor_api/qwaylandseat.cpp b/src/compositor/compositor_api/qwaylandseat.cpp
index 0be10f450..0e7df0ec0 100644
--- a/src/compositor/compositor_api/qwaylandseat.cpp
+++ b/src/compositor/compositor_api/qwaylandseat.cpp
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qwaylandseat.h"
#include "qwaylandseat_p.h"
@@ -41,6 +15,7 @@
#include <QtWaylandCompositor/QWaylandKeymap>
#include <QtWaylandCompositor/private/qwaylandseat_p.h>
#include <QtWaylandCompositor/private/qwaylandcompositor_p.h>
+#include <QtWaylandCompositor/private/qwaylandkeyboard_p.h>
#if QT_CONFIG(wayland_datadevice)
#include <QtWaylandCompositor/private/qwldatadevice_p.h>
#endif
@@ -48,6 +23,8 @@
#include "extensions/qwlqtkey_p.h"
#include "extensions/qwaylandtextinput.h"
+#include "extensions/qwaylandtextinputv3.h"
+#include "extensions/qwaylandqttextinputmethod.h"
QT_BEGIN_NAMESPACE
@@ -136,6 +113,7 @@ void QWaylandSeatPrivate::seat_get_touch(wl_seat::Resource *resource, uint32_t i
/*!
* \qmltype WaylandSeat
+ * \instantiates QWaylandSeat
* \inqmlmodule QtWayland.Compositor
* \since 5.8
* \brief Provides access to keyboard, mouse, and touch input.
@@ -177,6 +155,9 @@ QWaylandSeat::QWaylandSeat(QWaylandCompositor *compositor, CapabilityFlags capab
d->capabilities = capabilityFlags;
if (compositor->isCreated())
initialize();
+
+ // Support deprecated signal for backward compatibility
+ connect(this, &QWaylandSeat::cursorSurfaceRequested, this, &QWaylandSeat::cursorSurfaceRequest);
}
/*!
@@ -296,7 +277,7 @@ uint QWaylandSeat::sendTouchPointEvent(QWaylandSurface *surface, int id, const Q
}
/*!
- * \qmlmethod uint QtWaylandCompositor::WaylandSeat::sendTouchPointPressed(WaylandSurface surface, int id, point position)
+ * \qmlmethod uint QtWayland.Compositor::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.
@@ -330,7 +311,7 @@ uint QWaylandSeat::sendTouchPointPressed(QWaylandSurface *surface, int id, const
}
/*!
- * \qmlmethod void QtWaylandCompositor::WaylandSeat::sendTouchPointReleased(WaylandSurface surface, int id, point position)
+ * \qmlmethod void QtWayland.Compositor::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.
@@ -364,7 +345,7 @@ uint QWaylandSeat::sendTouchPointReleased(QWaylandSurface *surface, int id, cons
}
/*!
- * \qmlmethod void QtWaylandCompositor::WaylandSeat::sendTouchPointMoved(WaylandSurface surface, int id, point position)
+ * \qmlmethod void QtWayland.Compositor::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.
@@ -398,7 +379,7 @@ uint QWaylandSeat::sendTouchPointMoved(QWaylandSurface *surface, int id, const Q
}
/*!
- * \qmlmethod void QtWaylandCompositor::WaylandSeat::sendTouchFrameEvent(WaylandClient client)
+ * \qmlmethod void QtWayland.Compositor::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.
@@ -416,7 +397,7 @@ void QWaylandSeat::sendTouchFrameEvent(QWaylandClient *client)
}
/*!
- * \qmlmethod void QtWaylandCompositor::WaylandSeat::sendTouchCancelEvent(WaylandClient client)
+ * \qmlmethod void QtWayland.Compositor::WaylandSeat::sendTouchCancelEvent(WaylandClient client)
*
* Sends a cancel event to the touch device of a \a client.
*/
@@ -434,7 +415,7 @@ void QWaylandSeat::sendTouchCancelEvent(QWaylandClient *client)
/*!
* Sends the \a event to the specified \a surface on the touch device.
*
- * \warning This API will automatically map \l QTouchEvent::TouchPoint::id to a
+ * \warning This API will automatically map \l QEventPoint::id() to a
* sequential id before sending it to the client. It should therefore not be
* used in combination with the other API using explicit ids, as collisions
* might occur.
@@ -451,6 +432,11 @@ void QWaylandSeat::sendFullTouchEvent(QWaylandSurface *surface, QTouchEvent *eve
/*!
* Sends the \a event to the keyboard device.
+ *
+ * \note The \a event should correspond to an actual keyboard key in the current mapping.
+ * For example, \c Qt::Key_Exclam is normally not a separate key: with most keyboards the
+ * exclamation mark is produced with Shift + 1. In that case, to send an exclamation mark
+ * key press event, use \c{QKeyEvent(QEvent::KeyPress, Qt::Key_1, Qt::ShiftModifier)}.
*/
void QWaylandSeat::sendFullKeyEvent(QKeyEvent *event)
{
@@ -464,10 +450,30 @@ void QWaylandSeat::sendFullKeyEvent(QKeyEvent *event)
#if QT_CONFIG(im)
if (keyboardFocus()->inputMethodControl()->enabled()
&& event->nativeScanCode() == 0) {
- QWaylandTextInput *textInput = QWaylandTextInput::findIn(this);
- if (textInput) {
- textInput->sendKeyEvent(event);
- return;
+ if (keyboardFocus()->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::TextInputV2)) {
+ QWaylandTextInput *textInput = QWaylandTextInput::findIn(this);
+ if (textInput) {
+ textInput->sendKeyEvent(event);
+ return;
+ }
+ }
+
+ if (keyboardFocus()->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::QtTextInputMethodV1)) {
+ QWaylandQtTextInputMethod *textInputMethod = QWaylandQtTextInputMethod::findIn(this);
+ if (textInputMethod) {
+ textInputMethod->sendKeyEvent(event);
+ return;
+ }
+ }
+
+ if (keyboardFocus()->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::TextInputV3)) {
+ QWaylandTextInputV3 *textInputV3 = QWaylandTextInputV3::findIn(this);
+ if (textInputV3 && !event->text().isEmpty()) {
+ // it will just commit the text for text-input-unstable-v3 when keyPress
+ if (event->type() == QEvent::KeyPress)
+ textInputV3->sendKeyEvent(event);
+ return;
+ }
}
}
#endif
@@ -487,22 +493,29 @@ void QWaylandSeat::sendFullKeyEvent(QKeyEvent *event)
return;
}
- if (event->type() == QEvent::KeyPress)
+ if (event->type() == QEvent::KeyPress) {
+ QWaylandKeyboardPrivate::get(d->keyboard.data())->checkAndRepairModifierState(event);
d->keyboard->sendKeyPressEvent(scanCode);
- else if (event->type() == QEvent::KeyRelease)
+ } else if (event->type() == QEvent::KeyRelease) {
d->keyboard->sendKeyReleaseEvent(scanCode);
+ }
}
}
/*!
- * \qmlmethod void QtWaylandCompositor::WaylandSeat::sendKeyEvent(int qtKey, bool pressed)
+ * \qmlmethod void QtWayland.Compositor::WaylandSeat::sendKeyEvent(int qtKey, bool pressed)
* \since 5.12
*
- * Sends a key press or release to the keyboard device.
+ * Sends a key press (if \a pressed is \c true) or release (if \a pressed is \c false)
+ * event of a key \a qtKey to the keyboard device.
*/
/*!
- * Sends a key press or release to the keyboard device.
+ * Sends a key press (if \a pressed is \c true) or release (if \a pressed is \c false)
+ * event of a key \a qtKey to the keyboard device.
+ *
+ * \note This function does not support key events that require modifiers, such as \c Qt::Key_Exclam.
+ * Use \l{sendFullKeyEvent} instead.
*
* \since 5.12
*/
@@ -525,6 +538,104 @@ void QWaylandSeat::sendKeyEvent(int qtKey, bool pressed)
}
/*!
+ * \qmlmethod void QtWayland.Compositor::WaylandSeat::sendUnicodeKeyPressEvent(uint unicode)
+ * \since 6.7
+ *
+ * Sends a key press event of a UCS4 \a unicode through a text-input protocol.
+ *
+ * \note This function will not work properly if the client does not support the
+ * text-input protocol that the compositor supports.
+ */
+
+/*!
+ * Sends a key press event of a UCS4 \a unicode through a text-input protocol.
+ *
+ * \note This function will not work properly if the client does not support the
+ * text-input protocol that the compositor supports.
+ *
+ * \sa {sendFullKeyEvent} {sendKeyEvent}
+ *
+ * \since 6.7
+ */
+void QWaylandSeat::sendUnicodeKeyPressEvent(uint unicode)
+{
+ sendUnicodeKeyEvent(unicode, QEvent::KeyPress);
+}
+
+/*!
+ * \qmlmethod void QtWayland.Compositor::WaylandSeat::sendUnicodeKeyReleaseEvent(uint unicode)
+ * \since 6.7
+ *
+ * Sends a key release event of a UCS4 \a unicode through a text-input protocol.
+ *
+ * \note This function will not work properly if the client does not support the
+ * text-input protocol that the compositor supports.
+ */
+
+/*!
+ * Sends a key release event of a UCS4 \a unicode through a text-input protocol.
+ *
+ * \note This function will not work properly if the client does not support the
+ * text-input protocol that the compositor supports.
+ *
+ * \sa {sendFullKeyEvent} {sendKeyEvent}
+ *
+ * \since 6.7
+ */
+void QWaylandSeat::sendUnicodeKeyReleaseEvent(uint unicode)
+{
+ sendUnicodeKeyEvent(unicode, QEvent::KeyRelease);
+}
+
+/*!
+ * \internal
+ *
+ * Sends an \a eventType for the UCS4 \a unicode through a text-input protocol.
+ */
+void QWaylandSeat::sendUnicodeKeyEvent(uint unicode, QEvent::Type eventType)
+{
+ if (!keyboardFocus()) {
+ qWarning("Can't send a unicode key event, no keyboard focus, fix the compositor");
+ return;
+ }
+#if QT_CONFIG(im)
+ QString text;
+ text += QChar::fromUcs4(static_cast<char32_t>(unicode));
+
+ QKeyEvent event(eventType, Qt::Key_unknown, Qt::KeyboardModifiers{}, text);
+ if (keyboardFocus()->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::TextInputV2)) {
+ QWaylandTextInput *textInput = QWaylandTextInput::findIn(this);
+ if (textInput) {
+ textInput->sendKeyEvent(&event);
+ return;
+ }
+ }
+
+ if (keyboardFocus()->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::QtTextInputMethodV1)) {
+ QWaylandQtTextInputMethod *textInputMethod = QWaylandQtTextInputMethod::findIn(this);
+ if (textInputMethod) {
+ textInputMethod->sendKeyEvent(&event);
+ return;
+ }
+ }
+
+ if (keyboardFocus()->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::TextInputV3)) {
+ QWaylandTextInputV3 *textInputV3 = QWaylandTextInputV3::findIn(this);
+ if (textInputV3 && !text.isEmpty()) {
+ // it will just commit the text for text-input-unstable-v3 when keyPress
+ if (eventType == QEvent::KeyPress)
+ textInputV3->sendKeyEvent(&event);
+ return;
+ }
+ }
+#else
+ Q_UNUSED(unicode);
+ Q_UNUSED(eventType);
+ qWarning() << "Can't send a unicode key event: Unable to find a text-input protocol.";
+#endif
+}
+
+/*!
* Returns the keyboard for this input device.
*/
QWaylandKeyboard *QWaylandSeat::keyboard() const
@@ -696,7 +807,7 @@ void QWaylandSeat::handleMouseFocusDestroyed()
}
-/*! \qmlsignal void QtWaylandCompositor::QWaylandSeat::keyboardFocusChanged(QWaylandSurface newFocus, QWaylandSurface oldFocus)
+/*! \qmlsignal void QtWayland.Compositor::WaylandSeat::keyboardFocusChanged(QWaylandSurface newFocus, QWaylandSurface oldFocus)
*
* This signal is emitted when setKeyboardFocus() is called or when a WaylandQuickItem has focus
* and the user starts pressing keys.
@@ -716,7 +827,7 @@ void QWaylandSeat::handleMouseFocusDestroyed()
* \a oldFocus has the surface that lost keyboard focus; or \c nullptr if no surface had focus.
*/
-/*! \qmlsignal void QtWaylandCompositor::QWaylandSeat::cursorSurfaceRequest(QWaylandSurface surface, int hotspotX, int hotspotY)
+/*! \qmlsignal void QtWayland.Compositor::WaylandSeat::cursorSurfaceRequest(QWaylandSurface surface, int hotspotX, int hotspotY)
*
* This signal is emitted when the client has requested for a specific \a surface to be the mouse
* cursor. For example, when the user hovers over a particular surface, and you want the cursor
@@ -734,6 +845,10 @@ void QWaylandSeat::handleMouseFocusDestroyed()
* This signal is emitted when the client has requested for a specific \a surface to be the mouse
* cursor. For example, when the user hovers over a particular surface, and you want the cursor
* to change into a resize arrow.
+ *
+ * Both \a hotspotX and \a hotspotY are offsets from the top-left of a pointer surface, where a
+ * click should happen. For example, if the requested cursor surface is an arrow, the parameters
+ * indicate where the arrow's tip is, on that surface.
*/
/*!
@@ -757,3 +872,5 @@ void QWaylandSeat::handleMouseFocusDestroyed()
*/
QT_END_NAMESPACE
+
+#include "moc_qwaylandseat.cpp"
diff --git a/src/compositor/compositor_api/qwaylandseat.h b/src/compositor/compositor_api/qwaylandseat.h
index 0acaf670a..dd67e83ae 100644
--- a/src/compositor/compositor_api/qwaylandseat.h
+++ b/src/compositor/compositor_api/qwaylandseat.h
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDSEAT_H
#define QWAYLANDSEAT_H
@@ -35,8 +9,10 @@
#include <QtCore/QString>
#include <QtWaylandCompositor/qtwaylandcompositorglobal.h>
+#include <QtWaylandCompositor/qtwaylandqmlinclude.h>
#include <QtWaylandCompositor/qwaylandcompositorextension.h>
#include <QtWaylandCompositor/qwaylandkeyboard.h>
+#include <QtWaylandCompositor/qwaylandview.h>
QT_BEGIN_NAMESPACE
@@ -44,7 +20,6 @@ class QWaylandCompositor;
class QWaylandSurface;
class QKeyEvent;
class QTouchEvent;
-class QWaylandView;
class QInputEvent;
class QWaylandSeatPrivate;
class QWaylandDrag;
@@ -52,15 +27,22 @@ class QWaylandKeyboard;
class QWaylandPointer;
class QWaylandTouch;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandSeat : public QWaylandObject
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandSeat : public QWaylandObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandSeat)
#if QT_CONFIG(draganddrop)
Q_PROPERTY(QWaylandDrag *drag READ drag CONSTANT)
+ Q_MOC_INCLUDE("qwaylanddrag.h")
#endif
Q_PROPERTY(QWaylandKeymap *keymap READ keymap CONSTANT)
+ Q_MOC_INCLUDE("qwaylandkeymap.h")
+ Q_MOC_INCLUDE("qwaylandview.h")
+
+ QML_NAMED_ELEMENT(WaylandSeat)
+ QML_ADDED_IN_VERSION(1, 0)
+ QML_UNCREATABLE("")
public:
enum CapabilityFlag {
// The order should match the enum WL_SEAT_CAPABILITY_*
@@ -89,6 +71,9 @@ public:
void sendFullKeyEvent(QKeyEvent *event);
Q_INVOKABLE void sendKeyEvent(int qtKey, bool pressed);
+ Q_REVISION(6, 7) Q_INVOKABLE void sendUnicodeKeyPressEvent(uint unicode);
+ Q_REVISION(6, 7) Q_INVOKABLE void sendUnicodeKeyReleaseEvent(uint unicode);
+
uint sendTouchPointEvent(QWaylandSurface *surface, int id, const QPointF &point, Qt::TouchPointState state);
Q_INVOKABLE uint sendTouchPointPressed(QWaylandSurface *surface, int id, const QPointF &position);
Q_INVOKABLE uint sendTouchPointReleased(QWaylandSurface *surface, int id, const QPointF &position);
@@ -126,9 +111,14 @@ public:
Q_SIGNALS:
void mouseFocusChanged(QWaylandView *newFocus, QWaylandView *oldFocus);
void keyboardFocusChanged(QWaylandSurface *newFocus, QWaylandSurface *oldFocus);
+#if QT_DEPRECATED_SINCE(6, 1)
void cursorSurfaceRequest(QWaylandSurface *surface, int hotspotX, int hotspotY);
+#endif
+ void cursorSurfaceRequested(QWaylandSurface *surface, int hotspotX, int hotspotY, QWaylandClient *client);
private:
+ void sendUnicodeKeyEvent(uint unicode, QEvent::Type type);
+
void handleMouseFocusDestroyed();
};
diff --git a/src/compositor/compositor_api/qwaylandseat_p.h b/src/compositor/compositor_api/qwaylandseat_p.h
index 200df7493..b82f899a3 100644
--- a/src/compositor/compositor_api/qwaylandseat_p.h
+++ b/src/compositor/compositor_api/qwaylandseat_p.h
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDSEAT_P_H
#define QWAYLANDSEAT_P_H
@@ -74,7 +48,7 @@ class InputMethod;
}
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandSeatPrivate : public QObjectPrivate, public QtWaylandServer::wl_seat
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandSeatPrivate : public QObjectPrivate, public QtWaylandServer::wl_seat
{
public:
Q_DECLARE_PUBLIC(QWaylandSeat)
diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp
index 41a678128..207158bf7 100644
--- a/src/compositor/compositor_api/qwaylandsurface.cpp
+++ b/src/compositor/compositor_api/qwaylandsurface.cpp
@@ -1,32 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2017-2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017-2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qwaylandsurface.h"
#include "qwaylandsurface_p.h"
@@ -127,9 +101,9 @@ QWaylandSurfacePrivate::~QWaylandSurfacePrivate()
bufferRef = QWaylandBufferRef();
- for (QtWayland::FrameCallback *c : qAsConst(pendingFrameCallbacks))
+ for (QtWayland::FrameCallback *c : std::as_const(pendingFrameCallbacks))
c->destroy();
- for (QtWayland::FrameCallback *c : qAsConst(frameCallbacks))
+ for (QtWayland::FrameCallback *c : std::as_const(frameCallbacks))
c->destroy();
}
@@ -195,9 +169,20 @@ void QWaylandSurfacePrivate::surface_attach(Resource *, struct wl_resource *buff
pending.newlyAttached = true;
}
+/*
+ Note: The Wayland protocol specifies that buffer scale and damage can be interleaved, so
+ we cannot scale the damage region until commit. We assume that clients will either use
+ surface_damage or surface_damage_buffer within one frame for one surface.
+*/
+
void QWaylandSurfacePrivate::surface_damage(Resource *, int32_t x, int32_t y, int32_t width, int32_t height)
{
- pending.damage = pending.damage.united(QRect(x, y, width, height));
+ pending.surfaceDamage = pending.surfaceDamage.united(QRect(x, y, width, height));
+}
+
+void QWaylandSurfacePrivate::surface_damage_buffer(Resource *, int32_t x, int32_t y, int32_t width, int32_t height)
+{
+ pending.bufferDamage = pending.bufferDamage.united(QRect(x, y, width, height));
}
void QWaylandSurfacePrivate::surface_frame(Resource *resource, uint32_t callback)
@@ -240,11 +225,36 @@ void QWaylandSurfacePrivate::surface_commit(Resource *)
QSize surfaceSize = bufferSize / bufferScale;
sourceGeometry = !pending.sourceGeometry.isValid() ? QRect(QPoint(), surfaceSize) : pending.sourceGeometry;
destinationSize = pending.destinationSize.isEmpty() ? sourceGeometry.size().toSize() : pending.destinationSize;
- damage = pending.damage.intersected(QRect(QPoint(), destinationSize));
+ QRect destinationRect(QPoint(), destinationSize);
+ // pending.damage is already in surface coordinates
+ damage = pending.surfaceDamage.intersected(destinationRect);
+ if (!pending.bufferDamage.isNull()) {
+ if (bufferScale == 1) {
+ damage |= pending.bufferDamage.intersected(destinationRect); // Already in surface coordinates
+ } else {
+ // We must transform pending.damage from buffer coordinate system to surface coordinates
+ // TODO(QTBUG-85461): Also support wp_viewport setting more complex transformations
+ auto xform = [](const QRect &r, int scale) -> QRect {
+ QRect res{
+ QPoint{ r.x() / scale, r.y() / scale },
+ QPoint{ (r.right() + scale - 1) / scale, (r.bottom() + scale - 1) / scale }
+ };
+ return res;
+ };
+ for (const QRect &r : pending.bufferDamage)
+ damage |= xform(r, bufferScale).intersected(destinationRect);
+ }
+ }
hasContent = bufferRef.hasContent();
frameCallbacks << pendingFrameCallbacks;
- inputRegion = pending.inputRegion.intersected(QRect(QPoint(), destinationSize));
- opaqueRegion = pending.opaqueRegion.intersected(QRect(QPoint(), destinationSize));
+ inputRegion = pending.inputRegion.intersected(destinationRect);
+ opaqueRegion = pending.opaqueRegion.intersected(destinationRect);
+ bool becameOpaque = opaqueRegion.boundingRect().contains(destinationRect);
+ if (becameOpaque != isOpaque) {
+ isOpaque = becameOpaque;
+ emit q->isOpaqueChanged();
+ }
+
QPoint offsetForNextFrame = pending.offset;
if (viewport)
@@ -254,13 +264,14 @@ void QWaylandSurfacePrivate::surface_commit(Resource *)
pending.buffer = QWaylandBufferRef();
pending.offset = QPoint();
pending.newlyAttached = false;
- pending.damage = QRegion();
+ pending.bufferDamage = QRegion();
+ pending.surfaceDamage = QRegion();
pendingFrameCallbacks.clear();
// Notify buffers and views
if (auto *buffer = bufferRef.buffer())
buffer->setCommitted(damage);
- for (auto *view : qAsConst(views))
+ for (auto *view : std::as_const(views))
view->bufferCommitted(bufferRef, damage);
// Now all double-buffered state has been applied so it's safe to emit general signals
@@ -269,12 +280,8 @@ void QWaylandSurfacePrivate::surface_commit(Resource *)
emit q->damaged(damage);
- if (oldBufferSize != bufferSize) {
+ if (oldBufferSize != bufferSize)
emit q->bufferSizeChanged();
-#if QT_DEPRECATED_SINCE(5, 13)
- emit q->sizeChanged();
-#endif
- }
if (oldBufferScale != bufferScale)
emit q->bufferScaleChanged();
@@ -331,7 +338,54 @@ QtWayland::ClientBuffer *QWaylandSurfacePrivate::getBuffer(struct ::wl_resource
}
/*!
+ * \class QWaylandSurfaceRole
+ * \inmodule QtWaylandCompositor
+ * \since 5.8
+ * \brief The QWaylandSurfaceRole class represents the role of the surface in context of wl_surface.
+ *
+ * QWaylandSurfaceRole is used to represent the role of a QWaylandSurface. According to the protocol
+ * specification, the role of a surface is permanent once set, and if the same surface is later
+ * reused for a different role, this constitutes a protocol error. Setting the surface to the same
+ * role multiple times is not an error.
+ *
+ * As an example, the QWaylandXdgShell can assign either "popup" or "toplevel" roles to surfaces.
+ * If \c get_toplevel is requested on a surface which has previously received a \c get_popup
+ * request, then the compositor will issue a protocol error.
+ *
+ * Roles are compared by pointer value, so any two objects of QWaylandSurfaceRole will be considered
+ * different roles, regardless of what their \l{name()}{names} are. A typical way of assigning a
+ * role is to have a static QWaylandSurfaceRole object to represent it.
+ *
+ * \code
+ * class MyShellSurfaceSubType
+ * {
+ * static QWaylandSurfaceRole s_role;
+ * // ...
+ * };
+ *
+ * // ...
+ *
+ * surface->setRole(&MyShellSurfaceSubType::s_role, resource->handle, MY_ERROR_CODE);
+ * \endcode
+ */
+
+/*!
+ * \fn QWaylandSurfaceRole::QWaylandSurfaceRole(const QByteArray &name)
+ *
+ * Creates a QWaylandSurfaceRole and assigns it \a name. The name is used in error messages
+ * involving this QWaylandSurfaceRole.
+ */
+
+/*!
+ * \fn const QByteArray QWaylandSurfaceRole::name()
+ *
+ * Returns the name of the QWaylandSurfaceRole. The name is used in error messages involving this
+ * QWaylandSurfaceRole, for example if an attempt is made to change the role of a surface.
+ */
+
+/*!
* \qmltype WaylandSurface
+ * \instantiates QWaylandSurface
* \inqmlmodule QtWayland.Compositor
* \since 5.8
* \brief Represents a rectangular area on an output device.
@@ -388,7 +442,7 @@ QWaylandSurface::~QWaylandSurface()
}
/*!
- * \qmlmethod void QtWaylandCompositor::WaylandSurface::initialize(WaylandCompositor compositor, WaylandClient client, int id, int version)
+ * \qmlmethod void QtWayland.Compositor::WaylandSurface::initialize(WaylandCompositor compositor, WaylandClient client, int id, int version)
*
* Initializes the WaylandSurface with the given \a compositor and \a client, and with the given \a id
* and \a version.
@@ -423,7 +477,7 @@ bool QWaylandSurface::isInitialized() const
}
/*!
- * \qmlproperty WaylandClient QtWaylandCompositor::WaylandSurface::client
+ * \qmlproperty WaylandClient QtWayland.Compositor::WaylandSurface::client
*
* This property holds the client using this WaylandSurface.
*/
@@ -454,7 +508,7 @@ QWaylandClient *QWaylandSurface::client() const
}
/*!
- * \qmlproperty bool QtWaylandCompositor::WaylandSurface::hasContent
+ * \qmlproperty bool QtWayland.Compositor::WaylandSurface::hasContent
*
* This property holds whether the WaylandSurface has content.
*/
@@ -471,7 +525,7 @@ bool QWaylandSurface::hasContent() const
}
/*!
- * \qmlproperty rect QtWaylandCompositor::WaylandSurface::sourceGeometry
+ * \qmlproperty rect QtWayland.Compositor::WaylandSurface::sourceGeometry
* \since 5.13
*
* This property describes the portion of the attached Wayland buffer that should
@@ -502,7 +556,7 @@ QRectF QWaylandSurface::sourceGeometry() const
}
/*!
- * \qmlproperty size QtWaylandCompositor::WaylandSurface::destinationSize
+ * \qmlproperty size QtWayland.Compositor::WaylandSurface::destinationSize
* \since 5.13
*
* This property holds the size of this WaylandSurface in surface coordinates.
@@ -527,7 +581,7 @@ QSize QWaylandSurface::destinationSize() const
}
/*!
- * \qmlproperty size QtWaylandCompositor::WaylandSurface::bufferSize
+ * \qmlproperty size QtWayland.Compositor::WaylandSurface::bufferSize
*
* This property holds the size of the current buffer of this WaylandSurface in pixels,
* not in surface coordinates.
@@ -555,28 +609,8 @@ QSize QWaylandSurface::bufferSize() const
return d->bufferSize;
}
-#if QT_DEPRECATED_SINCE(5, 13)
-/*!
- * \qmlproperty size QtWaylandCompositor::WaylandSurface::size
- * \obsolete use bufferSize or destinationSize instead
- *
- * This property has been deprecated, use \l bufferSize or \l destinationSize instead.
- */
-
-/*!
- * \property QWaylandSurface::size
- * \obsolete use bufferSize or destinationSize instead
- *
- * This property has been deprecated, use \l bufferSize or \l destinationSize instead.
- */
-QSize QWaylandSurface::size() const
-{
- return bufferSize();
-}
-#endif
-
/*!
- * \qmlproperty size QtWaylandCompositor::WaylandSurface::bufferScale
+ * \qmlproperty size QtWayland.Compositor::WaylandSurface::bufferScale
*
* This property holds the WaylandSurface's buffer scale. The buffer scale lets
* a client supply higher resolution buffer data for use on high resolution
@@ -597,7 +631,7 @@ int QWaylandSurface::bufferScale() const
}
/*!
- * \qmlproperty enum QtWaylandCompositor::WaylandSurface::contentOrientation
+ * \qmlproperty enum QtWayland.Compositor::WaylandSurface::contentOrientation
*
* This property holds the orientation of the WaylandSurface's contents.
*
@@ -627,7 +661,7 @@ Qt::ScreenOrientation QWaylandSurface::contentOrientation() const
*/
/*!
- * \qmlproperty enum QtWaylandCompositor::WaylandSurface::origin
+ * \qmlproperty enum QtWayland.Compositor::WaylandSurface::origin
*
* This property holds the origin of the WaylandSurface's buffer, or
* WaylandSurface.OriginTopLeft if the surface has no buffer.
@@ -666,7 +700,7 @@ QWaylandCompositor *QWaylandSurface::compositor() const
void QWaylandSurface::frameStarted()
{
Q_D(QWaylandSurface);
- for (QtWayland::FrameCallback *c : qAsConst(d->frameCallbacks))
+ for (QtWayland::FrameCallback *c : std::as_const(d->frameCallbacks))
c->canSend = true;
}
@@ -718,7 +752,7 @@ bool QWaylandSurface::inputRegionContains(const QPointF &position) const
}
/*!
- * \qmlmethod void QtWaylandCompositor::WaylandSurface::destroy()
+ * \qmlmethod void QtWayland.Compositor::WaylandSurface::destroy()
*
* Destroys the WaylandSurface.
*/
@@ -733,7 +767,7 @@ void QWaylandSurface::destroy()
}
/*!
- * \qmlmethod bool QtWaylandCompositor::WaylandSurface::isDestroyed()
+ * \qmlmethod bool QtWayland.Compositor::WaylandSurface::isDestroyed()
*
* Returns \c true if the WaylandSurface has been destroyed. Otherwise returns \c false.
*/
@@ -748,7 +782,7 @@ bool QWaylandSurface::isDestroyed() const
}
/*!
- * \qmlproperty bool QtWaylandCompositor::WaylandSurface::cursorSurface
+ * \qmlproperty bool QtWayland.Compositor::WaylandSurface::cursorSurface
*
* This property holds whether the WaylandSurface is a cursor surface.
*/
@@ -775,7 +809,7 @@ bool QWaylandSurface::isCursorSurface() const
}
/*!
- * \qmlproperty bool QtWaylandCompositor::WaylandSurface::inhibitsIdle
+ * \qmlproperty bool QtWayland.Compositor::WaylandSurface::inhibitsIdle
* \since 5.14
*
* This property holds whether this surface is intended to inhibit the idle
@@ -799,6 +833,27 @@ bool QWaylandSurface::inhibitsIdle() const
return !d->idleInhibitors.isEmpty();
}
+/*!
+ * \qmlproperty bool QtWayland.Compositor::WaylandSurface::isOpaque
+ * \since 6.4
+ *
+ * This property holds whether the surface is fully opaque, as reported by the
+ * client through the set_opaque_region request.
+ */
+
+/*!
+ * \property QWaylandSurface::isOpaque
+ * \since 6.4
+ *
+ * This property holds whether the surface is fully opaque, as reported by the
+ * client through the set_opaque_region request.
+ */
+bool QWaylandSurface::isOpaque() const
+{
+ Q_D(const QWaylandSurface);
+ return d->isOpaque;
+}
+
#if QT_CONFIG(im)
QWaylandInputMethodControl *QWaylandSurface::inputMethodControl() const
{
@@ -900,10 +955,19 @@ struct wl_resource *QWaylandSurface::resource() const
}
/*!
- * Sets a \a role on the surface. A role defines how a surface will be mapped on screen; without a role
- * a surface is supposed to be hidden. Only one role can be set on a surface, at all times. Although
- * setting the same role many times is allowed, attempting to change the role of a surface will trigger
- * a protocol error to the \a errorResource and send an \a errorCode to the client.
+ * Sets a \a role on the surface. A role defines how a surface will be mapped on screen; without a
+ * role a surface is supposed to be hidden. Once a role is assigned to a surface, this becomes its
+ * permanent role. Any subsequent call to \c setRole() with a different role will trigger a
+ * protocol error to the \a errorResource and send an \a errorCode to the client. Enforcing this
+ * requirement is the main purpose of the surface role.
+ *
+ * The \a role is compared by pointer value. Any two objects of QWaylandSurfaceRole will be
+ * considered different roles, regardless of their names.
+ *
+ * The surface role is set internally by protocol implementations when a surface is adopted for a
+ * specific purpose, for example in a \l{Shell Extensions - Qt Wayland Compositor}{shell extension}.
+ * Unless you are developing extensions which use surfaces in this way, you should not call this
+ * function.
*
* Returns true if a role can be assigned; false otherwise.
*/
@@ -1011,7 +1075,7 @@ void QWaylandSurfacePrivate::Subsurface::subsurface_set_desync(wl_subsurface::Re
}
/*!
- * \qmlsignal QtWaylandCompositor::WaylandSurface::childAdded(WaylandSurface child)
+ * \qmlsignal QtWayland.Compositor::WaylandSurface::childAdded(WaylandSurface child)
*
* This signal is emitted when a wl_subsurface, \a child, has been added to the surface.
*/
@@ -1023,7 +1087,7 @@ void QWaylandSurfacePrivate::Subsurface::subsurface_set_desync(wl_subsurface::Re
*/
/*!
- * \qmlsignal QtWaylandCompositor::WaylandSurface::surfaceDestroyed()
+ * \qmlsignal QtWayland.Compositor::WaylandSurface::surfaceDestroyed()
*
* This signal is emitted when the corresponding wl_surface is destroyed.
*/
@@ -1035,7 +1099,7 @@ void QWaylandSurfacePrivate::Subsurface::subsurface_set_desync(wl_subsurface::Re
*/
/*!
- * \qmlsignal void QtWaylandCompositor::WaylandSurface::dragStarted(WaylandDrag drag)
+ * \qmlsignal void QtWayland.Compositor::WaylandSurface::dragStarted(WaylandDrag drag)
*
* This signal is emitted when a \a drag has started from this surface.
*/
@@ -1064,3 +1128,5 @@ void QWaylandSurfacePrivate::Subsurface::subsurface_set_desync(wl_subsurface::Re
*/
QT_END_NAMESPACE
+
+#include "moc_qwaylandsurface.cpp"
diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h
index c2ea20059..0494a091e 100644
--- a/src/compositor/compositor_api/qwaylandsurface.h
+++ b/src/compositor/compositor_api/qwaylandsurface.h
@@ -1,39 +1,15 @@
-/****************************************************************************
-**
-** Copyright (C) 2017-2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017-2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDSURFACE_H
#define QWAYLANDSURFACE_H
#include <QtWaylandCompositor/qtwaylandcompositorglobal.h>
+#include <QtWaylandCompositor/qwaylandcompositor.h>
#include <QtWaylandCompositor/qwaylandcompositorextension.h>
#include <QtWaylandCompositor/qwaylandclient.h>
+#include <QtWaylandCompositor/qwaylanddrag.h>
#include <QtCore/QScopedPointer>
#include <QtGui/QImage>
@@ -46,14 +22,10 @@ struct wl_resource;
QT_BEGIN_NAMESPACE
class QTouchEvent;
-class QWaylandClient;
class QWaylandSurfacePrivate;
-class QWaylandCompositor;
class QWaylandBufferRef;
class QWaylandView;
-class QWaylandSurfaceOp;
class QWaylandInputMethodControl;
-class QWaylandDrag;
class QWaylandSurfaceRole
{
@@ -66,24 +38,27 @@ private:
QByteArray m_name;
};
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandSurface : public QWaylandObject
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandSurface : public QWaylandObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandSurface)
Q_PROPERTY(QWaylandClient *client READ client CONSTANT)
- Q_PROPERTY(QRectF sourceGeometry READ sourceGeometry NOTIFY sourceGeometryChanged REVISION 13)
- Q_PROPERTY(QSize destinationSize READ destinationSize NOTIFY destinationSizeChanged REVISION 13)
- Q_PROPERTY(QSize bufferSize READ bufferSize NOTIFY bufferSizeChanged REVISION 13)
-#if QT_DEPRECATED_SINCE(5, 13)
- Q_PROPERTY(QSize size READ size NOTIFY sizeChanged) // Qt 6: Remove
-#endif
+ Q_PROPERTY(QRectF sourceGeometry READ sourceGeometry NOTIFY sourceGeometryChanged REVISION(1, 13))
+ Q_PROPERTY(QSize destinationSize READ destinationSize NOTIFY destinationSizeChanged REVISION(1, 13))
+ Q_PROPERTY(QSize bufferSize READ bufferSize NOTIFY bufferSizeChanged REVISION(1, 13))
Q_PROPERTY(int bufferScale READ bufferScale NOTIFY bufferScaleChanged)
Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation NOTIFY contentOrientationChanged)
Q_PROPERTY(QWaylandSurface::Origin origin READ origin NOTIFY originChanged)
Q_PROPERTY(bool hasContent READ hasContent NOTIFY hasContentChanged)
Q_PROPERTY(bool cursorSurface READ isCursorSurface WRITE markAsCursorSurface NOTIFY cursorSurfaceChanged)
- Q_PROPERTY(bool inhibitsIdle READ inhibitsIdle NOTIFY inhibitsIdleChanged REVISION 14)
-
+ Q_PROPERTY(bool inhibitsIdle READ inhibitsIdle NOTIFY inhibitsIdleChanged REVISION(1, 14))
+ Q_PROPERTY(bool isOpaque READ isOpaque NOTIFY isOpaqueChanged REVISION(6, 4))
+ Q_MOC_INCLUDE("qwaylanddrag.h")
+ Q_MOC_INCLUDE("qwaylandcompositor.h")
+
+ QML_NAMED_ELEMENT(WaylandSurfaceBase)
+ QML_ADDED_IN_VERSION(1, 0)
+ QML_UNCREATABLE("Cannot create instance of WaylandSurfaceBase, use WaylandSurface instead")
public:
enum Origin {
OriginTopLeft,
@@ -108,9 +83,6 @@ public:
QRectF sourceGeometry() const;
QSize destinationSize() const;
-#if QT_DEPRECATED_SINCE(5, 13)
- QT_DEPRECATED QSize size() const;
-#endif
QSize bufferSize() const;
int bufferScale() const;
@@ -141,6 +113,7 @@ public:
bool isCursorSurface() const;
bool inhibitsIdle() const;
+ bool isOpaque() const;
#if QT_CONFIG(im)
QWaylandInputMethodControl *inputMethodControl() const;
@@ -159,12 +132,9 @@ Q_SIGNALS:
void damaged(const QRegion &rect);
void parentChanged(QWaylandSurface *newParent, QWaylandSurface *oldParent);
void childAdded(QWaylandSurface *child);
- Q_REVISION(13) void sourceGeometryChanged();
- Q_REVISION(13) void destinationSizeChanged();
-#if QT_DEPRECATED_SINCE(5, 13)
- QT_DEPRECATED void sizeChanged();
-#endif
- Q_REVISION(13) void bufferSizeChanged();
+ Q_REVISION(1, 13) void sourceGeometryChanged();
+ Q_REVISION(1, 13) void destinationSizeChanged();
+ Q_REVISION(1, 13) void bufferSizeChanged();
void bufferScaleChanged();
void offsetForNextFrame(const QPoint &offset);
void contentOrientationChanged();
@@ -176,6 +146,7 @@ Q_SIGNALS:
void dragStarted(QWaylandDrag *drag);
void cursorSurfaceChanged();
Q_REVISION(14) void inhibitsIdleChanged();
+ Q_REVISION(6, 4) void isOpaqueChanged();
void configure(bool hasBuffer);
void redraw();
diff --git a/src/compositor/compositor_api/qwaylandsurface_p.h b/src/compositor/compositor_api/qwaylandsurface_p.h
index db0df8d1a..b4df7498e 100644
--- a/src/compositor/compositor_api/qwaylandsurface_p.h
+++ b/src/compositor/compositor_api/qwaylandsurface_p.h
@@ -1,32 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
-** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDSURFACE_P_H
#define QWAYLANDSURFACE_P_H
@@ -51,7 +25,7 @@
#include <QtWaylandCompositor/private/qwlregion_p.h>
-#include <QtCore/QVector>
+#include <QtCore/QList>
#include <QtCore/QRect>
#include <QtGui/QRegion>
#include <QtGui/QImage>
@@ -66,19 +40,20 @@
#include <QtWaylandCompositor/private/qwaylandviewporter_p.h>
#include <QtWaylandCompositor/private/qwaylandidleinhibitv1_p.h>
+#include <QtCore/qpointer.h>
+
QT_BEGIN_NAMESPACE
class QWaylandCompositor;
class QWaylandSurface;
class QWaylandView;
-class QWaylandSurfaceInterface;
class QWaylandInputMethodControl;
namespace QtWayland {
class FrameCallback;
}
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandSurfacePrivate : public QObjectPrivate, public QtWaylandServer::wl_surface
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandSurfacePrivate : public QObjectPrivate, public QtWaylandServer::wl_surface
{
public:
static QWaylandSurfacePrivate *get(QWaylandSurface *surface);
@@ -116,6 +91,7 @@ protected:
struct wl_resource *buffer, int x, int y) override;
void surface_damage(Resource *resource,
int32_t x, int32_t y, int32_t width, int32_t height) override;
+ void surface_damage_buffer(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override;
void surface_frame(Resource *resource,
uint32_t callback) override;
void surface_set_opaque_region(Resource *resource,
@@ -140,7 +116,8 @@ public: //member variables
struct {
QWaylandBufferRef buffer;
- QRegion damage;
+ QRegion surfaceDamage;
+ QRegion bufferDamage;
QPoint offset;
bool newlyAttached = false;
QRegion inputRegion;
@@ -158,7 +135,7 @@ public: //member variables
QList<QPointer<QWaylandSurface>> subsurfaceChildren;
- QVector<QWaylandIdleInhibitManagerV1Private::Inhibitor *> idleInhibitors;
+ QList<QWaylandIdleInhibitManagerV1Private::Inhibitor *> idleInhibitors;
QRegion inputRegion;
QRegion opaqueRegion;
@@ -171,6 +148,7 @@ public: //member variables
bool destroyed = false;
bool hasContent = false;
bool isInitialized = false;
+ bool isOpaque = false;
Qt::ScreenOrientation contentOrientation = Qt::PrimaryOrientation;
QWindow::Visibility visibility;
#if QT_CONFIG(im)
diff --git a/src/compositor/compositor_api/qwaylandsurfacegrabber.cpp b/src/compositor/compositor_api/qwaylandsurfacegrabber.cpp
index fd530cba5..5f24d1c77 100644
--- a/src/compositor/compositor_api/qwaylandsurfacegrabber.cpp
+++ b/src/compositor/compositor_api/qwaylandsurfacegrabber.cpp
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qwaylandsurfacegrabber.h"
@@ -109,3 +83,5 @@ void QWaylandSurfaceGrabber::grab()
}
QT_END_NAMESPACE
+
+#include "moc_qwaylandsurfacegrabber.cpp"
diff --git a/src/compositor/compositor_api/qwaylandsurfacegrabber.h b/src/compositor/compositor_api/qwaylandsurfacegrabber.h
index 869ae70c2..b21572ec0 100644
--- a/src/compositor/compositor_api/qwaylandsurfacegrabber.h
+++ b/src/compositor/compositor_api/qwaylandsurfacegrabber.h
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDSURFACEGRABBER_H
#define QWAYLANDSURFACEGRABBER_H
@@ -38,7 +12,7 @@ QT_BEGIN_NAMESPACE
class QWaylandSurface;
class QWaylandSurfaceGrabberPrivate;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandSurfaceGrabber : public QObject
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandSurfaceGrabber : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandSurfaceGrabber)
diff --git a/src/compositor/compositor_api/qwaylandtouch.cpp b/src/compositor/compositor_api/qwaylandtouch.cpp
index 87edaf9da..39aeac491 100644
--- a/src/compositor/compositor_api/qwaylandtouch.cpp
+++ b/src/compositor/compositor_api/qwaylandtouch.cpp
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qwaylandtouch.h"
#include "qwaylandtouch_p.h"
@@ -99,7 +73,7 @@ int QWaylandTouchPrivate::toSequentialWaylandId(int touchId)
return availableId;
}
ids.append(touchId);
- return ids.length() - 1;
+ return ids.size() - 1;
}
/*!
@@ -162,6 +136,9 @@ uint QWaylandTouch::sendTouchPointEvent(QWaylandSurface *surface, int id, const
case Qt::TouchPointStationary:
// stationary points are not sent through wayland, the client must cache them
break;
+ case Qt::TouchPointUnknownState:
+ // Ignored
+ break;
}
return serial;
@@ -208,17 +185,17 @@ void QWaylandTouch::sendFullTouchEvent(QWaylandSurface *surface, QTouchEvent *ev
if (ext && ext->postTouchEvent(event, surface))
return;
- const QList<QTouchEvent::TouchPoint> points = event->touchPoints();
+ const QList<QTouchEvent::TouchPoint> points = event->points();
if (points.isEmpty())
return;
- const int pointCount = points.count();
+ const int pointCount = points.size();
for (int i = 0; i < pointCount; ++i) {
const QTouchEvent::TouchPoint &tp(points.at(i));
// Convert the local pos in the compositor window to surface-relative.
const int id = d->toSequentialWaylandId(tp.id());
- sendTouchPointEvent(surface, id, tp.pos(), tp.state());
- if (tp.state() == Qt::TouchPointReleased)
+ sendTouchPointEvent(surface, id, tp.position(), Qt::TouchPointState(tp.state()));
+ if (tp.state() == QEventPoint::Released)
d->ids[id] = -1;
}
sendFrameEvent(surface->client());
@@ -234,3 +211,5 @@ void QWaylandTouch::addClient(QWaylandClient *client, uint32_t id, uint32_t vers
}
QT_END_NAMESPACE
+
+#include "moc_qwaylandtouch.cpp"
diff --git a/src/compositor/compositor_api/qwaylandtouch.h b/src/compositor/compositor_api/qwaylandtouch.h
index e32c6aab7..bdaa68eb6 100644
--- a/src/compositor/compositor_api/qwaylandtouch.h
+++ b/src/compositor/compositor_api/qwaylandtouch.h
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDTOUCH_H
#define QWAYLANDTOUCH_H
@@ -46,7 +20,7 @@ class QWaylandView;
class QWaylandClient;
class QWaylandSurface;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTouch : public QWaylandObject
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandTouch : public QWaylandObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandTouch)
diff --git a/src/compositor/compositor_api/qwaylandtouch_p.h b/src/compositor/compositor_api/qwaylandtouch_p.h
index 7638fb6f6..eb5d4e783 100644
--- a/src/compositor/compositor_api/qwaylandtouch_p.h
+++ b/src/compositor/compositor_api/qwaylandtouch_p.h
@@ -1,32 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QTWAYLAND_QWLTOUCH_P_H
#define QTWAYLAND_QWLTOUCH_P_H
@@ -50,13 +24,14 @@
#include <QtWaylandCompositor/QWaylandCompositor>
#include <QtCore/QPoint>
+#include <QtCore/qvarlengtharray.h>
#include <QtCore/private/qobject_p.h>
#include <QtWaylandCompositor/private/qwayland-server-wayland.h>
QT_BEGIN_NAMESPACE
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTouchPrivate : public QObjectPrivate, public QtWaylandServer::wl_touch
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandTouchPrivate : public QObjectPrivate, public QtWaylandServer::wl_touch
{
Q_DECLARE_PUBLIC(QWaylandTouch)
public:
diff --git a/src/compositor/compositor_api/qwaylandview.cpp b/src/compositor/compositor_api/qwaylandview.cpp
index 844da7c5d..f8a0f38af 100644
--- a/src/compositor/compositor_api/qwaylandview.cpp
+++ b/src/compositor/compositor_api/qwaylandview.cpp
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qwaylandview.h"
#include "qwaylandview_p.h"
@@ -37,6 +11,7 @@
#include <QtWaylandCompositor/private/qwaylandoutput_p.h>
#include <QtCore/QMutex>
+#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE
@@ -54,6 +29,7 @@ void QWaylandViewPrivate::markSurfaceAsDestroyed(QWaylandSurface *surface)
/*!
* \qmltype WaylandView
+ * \instantiates QWaylandView
* \inqmlmodule QtWayland.Compositor
* \since 5.8
* \brief Represents a view of a surface on an output.
@@ -109,7 +85,7 @@ QObject *QWaylandView::renderObject() const
}
/*!
- * \qmlproperty WaylandSurface QtWaylandCompositor::WaylandView::surface
+ * \qmlproperty WaylandSurface QtWayland.Compositor::WaylandView::surface
*
* This property holds the surface viewed by this WaylandView.
*/
@@ -168,7 +144,7 @@ void QWaylandView::setSurface(QWaylandSurface *newSurface)
}
/*!
- * \qmlproperty WaylandOutput QtWaylandCompositor::WaylandView::output
+ * \qmlproperty WaylandOutput QtWayland.Compositor::WaylandView::output
*
* This property holds the output on which this view displays its surface.
*/
@@ -283,7 +259,7 @@ QRegion QWaylandView::currentDamage()
}
/*!
- * \qmlproperty bool QtWaylandCompositor::WaylandView::bufferLocked
+ * \qmlproperty bool QtWayland.Compositor::WaylandView::bufferLocked
*
* This property holds whether the view's buffer is currently locked. When
* the buffer is locked, advance() will not advance to the next buffer and
@@ -316,7 +292,7 @@ void QWaylandView::setBufferLocked(bool locked)
emit bufferLockedChanged();
}
/*!
- * \qmlproperty bool QtWaylandCompositor::WaylandView::allowDiscardFrontBuffer
+ * \qmlproperty bool QtWayland.Compositor::WaylandView::allowDiscardFrontBuffer
*
* By default, the view locks the current buffer until advance() is called. Set this property
* to true to allow Qt to release the buffer when the primary view is no longer using it.
@@ -388,3 +364,5 @@ struct wl_resource *QWaylandView::surfaceResource() const
}
QT_END_NAMESPACE
+
+#include "moc_qwaylandview.cpp"
diff --git a/src/compositor/compositor_api/qwaylandview.h b/src/compositor/compositor_api/qwaylandview.h
index dea5be8b2..a48dae5f6 100644
--- a/src/compositor/compositor_api/qwaylandview.h
+++ b/src/compositor/compositor_api/qwaylandview.h
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDSURFACEVIEW_H
#define QWAYLANDSURFACEVIEW_H
@@ -42,7 +16,7 @@ class QWaylandSurface;
class QWaylandViewPrivate;
class QWaylandOutput;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandView : public QObject
+class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandView : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandView)
@@ -51,6 +25,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandView : public QObject
Q_PROPERTY(QWaylandOutput *output READ output WRITE setOutput NOTIFY outputChanged)
Q_PROPERTY(bool bufferLocked READ isBufferLocked WRITE setBufferLocked NOTIFY bufferLockedChanged)
Q_PROPERTY(bool allowDiscardFrontBuffer READ allowDiscardFrontBuffer WRITE setAllowDiscardFrontBuffer NOTIFY allowDiscardFrontBufferChanged)
+ Q_MOC_INCLUDE("qwaylandoutput.h")
public:
QWaylandView(QObject *renderObject = nullptr, QObject *parent = nullptr);
~QWaylandView() override;
diff --git a/src/compositor/compositor_api/qwaylandview_p.h b/src/compositor/compositor_api/qwaylandview_p.h
index 685705fa7..01f582738 100644
--- a/src/compositor/compositor_api/qwaylandview_p.h
+++ b/src/compositor/compositor_api/qwaylandview_p.h
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** 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:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWAYLANDSURFACEVIEW_P_H
#define QWAYLANDSURFACEVIEW_P_H