Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qwaylandclientextension.h
Go to the documentation of this file.
1
// Copyright (C) 2017 Erik Larsson.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
ifndef
QWAYLANDCLIENTEXTENSION_H
6
#
define
QWAYLANDCLIENTEXTENSION_H
7
8
#
include
<
QtCore
/
QObject
>
9
#
include
<
QtWaylandClient
/
qtwaylandclientglobal
.
h
>
10
11
struct
wl_interface;
12
struct
wl_registry;
13
14
QT_BEGIN_NAMESPACE
15
16
namespace
QtWaylandClient
{
17
class
QWaylandIntegration;
18
}
19
20
class
QWaylandClientExtensionPrivate;
21
class
QWaylandClientExtensionTemplatePrivate;
22
23
class
Q_WAYLANDCLIENT_EXPORT
QWaylandClientExtension
:
public
QObject
24
{
25
Q_OBJECT
26
Q_DECLARE_PRIVATE(QWaylandClientExtension)
27
Q_PROPERTY(
int
protocolVersion READ version NOTIFY versionChanged)
28
Q_PROPERTY(
bool
active READ isActive NOTIFY activeChanged)
29
public
:
30
explicit
QWaylandClientExtension(
int
version, QObject *parent);
31
explicit
QWaylandClientExtension(
const
int
version);
32
~QWaylandClientExtension();
33
34
QtWaylandClient::QWaylandIntegration *integration()
const
;
35
int
version()
const
;
36
bool
isActive()
const
;
37
38
virtual
const
struct
wl_interface *extensionInterface()
const
= 0;
39
virtual
void
bind(
struct
::wl_registry *registry,
int
id,
int
version) = 0;
40
protected
:
41
void
setVersion(
const
int
version);
42
Q_SIGNALS:
43
void
versionChanged();
44
void
activeChanged();
45
46
protected
Q_SLOTS:
47
void
initialize();
48
};
49
50
51
template
<
typename
T,
auto
destruct =
nullptr
>
52
class
QWaylandClientExtensionTemplate
:
public
QWaylandClientExtension
53
{
54
Q_DECLARE_PRIVATE
(
QWaylandClientExtensionTemplate
)
55
56
public
:
57
explicit
QWaylandClientExtensionTemplate
(
int
ver
,
QObject
*
parent
=
nullptr
)
58
:
QWaylandClientExtension
(
ver
,
parent
)
59
{
60
if
constexpr
(
destruct
!=
nullptr
) {
61
connect
(
this
, &
QWaylandClientExtensionTemplate
::
activeChanged
,
this
, [
this
] {
62
if
(!
isActive
()) {
63
std
::
invoke
(
destruct
,
static_cast
<
T
*>(
this
));
64
}
65
});
66
}
67
}
68
69
~
QWaylandClientExtensionTemplate
()
70
{
71
if
constexpr
(
destruct
!=
nullptr
) {
72
if
(
isActive
()) {
73
std
::
invoke
(
destruct
,
static_cast
<
T
*>(
this
));
74
}
75
}
76
}
77
78
const
struct
wl_interface
*
extensionInterface
()
const
override
79
{
80
return
T
::
interface
();
81
}
82
83
void
bind
(
struct
::
wl_registry
*
registry
,
int
id
,
int
ver
)
override
84
{
85
T
*
instance
=
static_cast
<
T
*>(
this
);
86
// Make sure lowest version is used of the supplied version from the
87
// developer and the version specified in the protocol and also the
88
// compositor version.
89
if
(
this
->
version
() >
T
::
interface
()->
version
) {
90
qWarning
(
"Supplied protocol version to QWaylandClientExtensionTemplate is higher "
91
"than the version of the protocol, using protocol version instead.\n"
92
" interface.name: %s"
,
93
T
::
interface
()->
name
);
94
}
95
int
minVersion
=
qMin
(
ver
,
qMin
(
T
::
interface
()->
version
,
this
->
version
()));
96
setVersion
(
minVersion
);
97
instance
->
init
(
registry
,
id
,
minVersion
);
98
}
99
};
100
101
QT_END_NAMESPACE
102
103
#
endif
// QWAYLANDCLIENTEXTENSION_H
QWaylandClientExtensionTemplate
A class for implementing custom extensions on the Wayland protocol.
Definition
qwaylandclientextension.h:53
QWaylandClientExtension
A class for implementing custom extensions on the Wayland protocol.
Definition
qwaylandclientextension.h:24
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QtWaylandClient
Definition
qwaylandclientextension.h:16
qtbase
src
plugins
platforms
wayland
global
qwaylandclientextension.h
Generated on
for Qt by
1.18.0