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
qwaylandsurfacegrabber.cpp
Go to the documentation of this file.
1
// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
include
"qwaylandsurfacegrabber.h"
6
7
#
include
<
QtCore
/
private
/
qobject_p
.
h
>
8
#
include
<
QtWaylandCompositor
/
qwaylandsurface
.
h
>
9
#
include
<
QtWaylandCompositor
/
qwaylandcompositor
.
h
>
10
#
include
<
QtWaylandCompositor
/
private
/
qwaylandsurface_p
.
h
>
11
12
QT_BEGIN_NAMESPACE
13
14
/*!
15
\class QWaylandSurfaceGrabber
16
\inmodule QtWaylandCompositor
17
\since 5.8
18
\brief The QWaylandSurfaceGrabber class allows to read the content of a QWaylandSurface.
19
20
Sometimes it is needed to get the contents of a surface, for example to provide a screenshot
21
to the user. The QWaylandSurfaceGrabber class provides a simple method to do so, without
22
having to care what type of buffer backs the surface, be it shared memory, OpenGL or something
23
else.
24
*/
25
26
/*!
27
\enum QWaylandSurfaceGrabber::Error
28
29
The Error enum describes the reason for a grab failure.
30
31
\value InvalidSurface The surface is null or otherwise not valid.
32
\value NoBufferAttached The client has not attached a buffer on the surface yet.
33
\value UnknownBufferType The buffer attached on the surface is of an unknown type.
34
\value RendererNotReady The compositor renderer is not ready to grab the surface content.
35
*/
36
37
class
QWaylandSurfaceGrabberPrivate
:
public
QObjectPrivate
38
{
39
Q_DECLARE_PUBLIC(QWaylandSurfaceGrabber)
40
41
QWaylandSurface *surface =
nullptr
;
42
};
43
44
/*!
45
* Create a QWaylandSurfaceGrabber object with the given \a surface and \a parent
46
*/
47
QWaylandSurfaceGrabber::QWaylandSurfaceGrabber(QWaylandSurface *surface, QObject *parent)
48
: QObject(*(
new
QWaylandSurfaceGrabberPrivate), parent)
49
{
50
Q_D(QWaylandSurfaceGrabber);
51
d->surface = surface;
52
}
53
54
/*!
55
* Returns the surface set on this object
56
*/
57
QWaylandSurface *QWaylandSurfaceGrabber::surface()
const
58
{
59
Q_D(
const
QWaylandSurfaceGrabber);
60
return
d->surface;
61
}
62
63
/*!
64
* Grab the content of the surface set on this object.
65
* It may not be possible to do that immediately so the success and failed signals
66
* should be used to be notified of when the grab is completed.
67
*/
68
void
QWaylandSurfaceGrabber::grab()
69
{
70
Q_D(QWaylandSurfaceGrabber);
71
if
(!d->surface) {
72
emit failed(InvalidSurface);
73
return
;
74
}
75
76
QWaylandSurfacePrivate *surf = QWaylandSurfacePrivate::get(d->surface);
77
QWaylandBufferRef buf = surf->bufferRef;
78
if
(!buf.hasBuffer()) {
79
emit failed(NoBufferAttached);
80
return
;
81
}
82
83
d->surface->compositor()->grabSurface(
this
, buf);
84
}
85
86
QT_END_NAMESPACE
87
88
#
include
"moc_qwaylandsurfacegrabber.cpp"
QWaylandSurfaceGrabberPrivate
Definition
qwaylandsurfacegrabber.cpp:38
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtwayland
src
compositor
compositor_api
qwaylandsurfacegrabber.cpp
Generated on
for Qt by
1.18.0