Warning: That file was not part of the compilation database. It may have many parsing errors.
1 | /**************************************************************************** |
---|---|
2 | ** |
3 | ** Copyright (C) 2017 Erik Larsson. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtWaylandCompositor module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #ifndef QWAYLANDCLIENTEXTENSION_H |
41 | #define QWAYLANDCLIENTEXTENSION_H |
42 | |
43 | #include <QObject> |
44 | #include <QtWaylandClient/qtwaylandclientglobal.h> |
45 | |
46 | struct wl_interface; |
47 | struct wl_registry; |
48 | |
49 | QT_BEGIN_NAMESPACE |
50 | |
51 | namespace QtWaylandClient { |
52 | class QWaylandIntegration; |
53 | } |
54 | |
55 | class QWaylandClientExtensionPrivate; |
56 | class QWaylandClientExtensionTemplatePrivate; |
57 | |
58 | class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject |
59 | { |
60 | Q_OBJECT |
61 | Q_DECLARE_PRIVATE(QWaylandClientExtension) |
62 | Q_PROPERTY(int protocolVersion READ version NOTIFY versionChanged) |
63 | Q_PROPERTY(bool active READ isActive NOTIFY activeChanged) |
64 | public: |
65 | QWaylandClientExtension(const int version); |
66 | |
67 | QtWaylandClient::QWaylandIntegration *integration() const; |
68 | int version() const; |
69 | bool isActive() const; |
70 | |
71 | virtual const struct wl_interface *extensionInterface() const = 0; |
72 | virtual void bind(struct ::wl_registry *registry, int id, int version) = 0; |
73 | protected: |
74 | void setVersion(const int version); |
75 | Q_SIGNALS: |
76 | void versionChanged(); |
77 | void activeChanged(); |
78 | |
79 | private Q_SLOTS: |
80 | void addRegistryListener(); |
81 | }; |
82 | |
83 | template <typename T> |
84 | class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplate : public QWaylandClientExtension |
85 | { |
86 | Q_DECLARE_PRIVATE(QWaylandClientExtensionTemplate) |
87 | public: |
88 | QWaylandClientExtensionTemplate(const int ver) : |
89 | QWaylandClientExtension(ver) |
90 | { |
91 | } |
92 | |
93 | const struct wl_interface *extensionInterface() const override |
94 | { |
95 | return T::interface(); |
96 | } |
97 | |
98 | void bind(struct ::wl_registry *registry, int id, int ver) override |
99 | { |
100 | T* instance = static_cast<T *>(this); |
101 | // Make sure lowest version is used of the supplied version from the |
102 | // developer and the version specified in the protocol and also the |
103 | // compositor version. |
104 | if (this->version() > T::interface()->version) { |
105 | qWarning(msg: "Supplied protocol version to QWaylandClientExtensionTemplate is higher than the version of the protocol, using protocol version instead."); |
106 | } |
107 | int minVersion = qMin(ver, qMin(T::interface()->version, this->version())); |
108 | setVersion(minVersion); |
109 | instance->init(registry, id, minVersion); |
110 | } |
111 | }; |
112 | |
113 | QT_END_NAMESPACE |
114 | |
115 | #endif // QWAYLANDCLIENTEXTENSION_H |
116 |
Warning: That file was not part of the compilation database. It may have many parsing errors.