blob: b7c4a3239ea12a0ab68878cbb00a3a6a1bab9caa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
// Copyright (C) 2017 Erik Larsson.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QWAYLANDCLIENTEXTENSION_H
#define QWAYLANDCLIENTEXTENSION_H
#include <QObject>
#include <QtWaylandClient/qtwaylandclientglobal.h>
struct wl_interface;
struct wl_registry;
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
class QWaylandIntegration;
}
class QWaylandClientExtensionPrivate;
class QWaylandClientExtensionTemplatePrivate;
class Q_WAYLANDCLIENT_EXPORT QWaylandClientExtension : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandClientExtension)
Q_PROPERTY(int protocolVersion READ version NOTIFY versionChanged)
Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
public:
QWaylandClientExtension(const int version);
~QWaylandClientExtension();
QtWaylandClient::QWaylandIntegration *integration() const;
int version() const;
bool isActive() const;
virtual const struct wl_interface *extensionInterface() const = 0;
virtual void bind(struct ::wl_registry *registry, int id, int version) = 0;
protected:
void setVersion(const int version);
Q_SIGNALS:
void versionChanged();
void activeChanged();
protected Q_SLOTS:
void initialize();
};
template <typename T>
class Q_WAYLANDCLIENT_EXPORT QWaylandClientExtensionTemplate : public QWaylandClientExtension
{
Q_DECLARE_PRIVATE(QWaylandClientExtensionTemplate)
public:
QWaylandClientExtensionTemplate(const int ver) :
QWaylandClientExtension(ver)
{
}
const struct wl_interface *extensionInterface() const override
{
return T::interface();
}
void bind(struct ::wl_registry *registry, int id, int ver) override
{
T* instance = static_cast<T *>(this);
// Make sure lowest version is used of the supplied version from the
// developer and the version specified in the protocol and also the
// compositor version.
if (this->version() > T::interface()->version) {
qWarning("Supplied protocol version to QWaylandClientExtensionTemplate is higher than the version of the protocol, using protocol version instead.");
}
int minVersion = qMin(ver, qMin(T::interface()->version, this->version()));
setVersion(minVersion);
instance->init(registry, id, minVersion);
}
};
QT_END_NAMESPACE
#endif // QWAYLANDCLIENTEXTENSION_H
|