Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwaylandivisurface.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:critical reason:network-protocol
4
8#if QT_CONFIG(wayland_compositor_quick)
9#include "qwaylandivisurfaceintegration_p.h"
10#endif
11
12#include <QtWaylandCompositor/QWaylandResource>
13#include <QDebug>
14
15#include <QtWaylandCompositor/private/qwaylandutils_p.h>
16
18
19QWaylandSurfaceRole QWaylandIviSurfacePrivate::s_role("ivi_surface");
20
21/*!
22 * \qmltype IviSurface
23 * \nativetype QWaylandIviSurface
24 * \inqmlmodule QtWayland.Compositor.IviApplication
25 * \since 5.8
26 * \brief Provides a simple way to identify and resize a surface.
27 *
28 * This type is part of the \l{IviApplication} extension and provides a way to extend
29 * the functionality of an existing WaylandSurface with a way to resize and identify it.
30 *
31 * It corresponds to the Wayland \c ivi_surface interface.
32 */
33
34/*!
35 * \class QWaylandIviSurface
36 * \inmodule QtWaylandCompositor
37 * \since 5.8
38 * \brief The QWaylandIviSurface class provides a simple way to identify and resize a surface.
39 *
40 * This class is part of the QWaylandIviApplication extension and provides a way to
41 * extend the functionality of an existing QWaylandSurface with a way to resize and identify it.
42 *
43 * It corresponds to the Wayland \c ivi_surface interface.
44 */
45
46/*!
47 * Constructs a QWaylandIviSurface.
48 */
49QWaylandIviSurface::QWaylandIviSurface()
50 : QWaylandShellSurfaceTemplate<QWaylandIviSurface>(*new QWaylandIviSurfacePrivate())
51{
52}
53
54/*!
55 * Constructs a QWaylandIviSurface for \a surface and initializes it with the
56 * given \a application, \a surface, \a iviId, and \a resource.
57 */
58QWaylandIviSurface::QWaylandIviSurface(QWaylandIviApplication *application, QWaylandSurface *surface, uint iviId, const QWaylandResource &resource)
59 : QWaylandShellSurfaceTemplate<QWaylandIviSurface>(*new QWaylandIviSurfacePrivate())
60{
61 initialize(application, surface, iviId, resource);
62}
63
64/*!
65 * \qmlmethod void IviSurface::initialize(IviApplication iviApplication, WaylandSurface surface, int iviId, WaylandResource resource)
66 *
67 * Initializes the IviSurface, associating it with the given \a iviApplication, \a surface,
68 * \a iviId, and \a resource.
69 */
70
71/*!
72 * Initializes the QWaylandIviSurface, associating it with the given \a iviApplication, \a surface,
73 * \a iviId, and \a resource.
74 */
75void QWaylandIviSurface::initialize(QWaylandIviApplication *iviApplication, QWaylandSurface *surface, uint iviId, const QWaylandResource &resource)
76{
77 Q_D(QWaylandIviSurface);
78
79 d->m_iviApplication = iviApplication;
80 d->m_surface = surface;
81 d->m_iviId = iviId;
82
83 d->init(resource.resource());
84 setExtensionContainer(surface);
85
86 emit surfaceChanged();
87 emit iviIdChanged();
88
89 QWaylandCompositorExtension::initialize();
90}
91
92/*!
93 * \qmlproperty WaylandSurface IviSurface::surface
94 *
95 * This property holds the surface associated with this IviSurface.
96 */
97
98/*!
99 * \property QWaylandIviSurface::surface
100 *
101 * This property holds the surface associated with this QWaylandIviSurface.
102 */
103QWaylandSurface *QWaylandIviSurface::surface() const
104{
105 Q_D(const QWaylandIviSurface);
106 return d->m_surface;
107}
108
109/*!
110 * \qmlproperty int IviSurface::iviId
111 * \readonly
112 *
113 * This property holds the ivi id id of this IviSurface.
114 */
115
116/*!
117 * \property QWaylandIviSurface::iviId
118 *
119 * This property holds the ivi id of this QWaylandIviSurface.
120 */
121uint QWaylandIviSurface::iviId() const
122{
123 Q_D(const QWaylandIviSurface);
124 return d->m_iviId;
125}
126
127/*!
128 * Returns the Wayland interface for the QWaylandIviSurface.
129 */
130const struct wl_interface *QWaylandIviSurface::interface()
131{
132 return QWaylandIviSurfacePrivate::interface();
133}
134
135QByteArray QWaylandIviSurface::interfaceName()
136{
137 return QWaylandIviSurfacePrivate::interfaceName();
138}
139
140/*!
141 * Returns the surface role for the QWaylandIviSurface.
142 */
143QWaylandSurfaceRole *QWaylandIviSurface::role()
144{
145 return &QWaylandIviSurfacePrivate::s_role;
146}
147
148/*!
149 * Returns the QWaylandIviSurface corresponding to the \a resource.
150 */
151QWaylandIviSurface *QWaylandIviSurface::fromResource(wl_resource *resource)
152{
153 if (auto p = QtWayland::fromResource<QWaylandIviSurfacePrivate *>(resource))
154 return p->q_func();
155 return nullptr;
156}
157
158/*!
159 * \qmlmethod int IviSurface::sendConfigure(size size)
160 *
161 * Sends a configure event to the client, telling it to resize the surface to the given \a size.
162 */
163
164/*!
165 * Sends a configure event to the client, telling it to resize the surface to the given \a size.
166 */
167void QWaylandIviSurface::sendConfigure(const QSize &size)
168{
169 if (!size.isValid()) {
170 qWarning() << "Can't configure ivi_surface with an invalid size" << size;
171 return;
172 }
173 Q_D(QWaylandIviSurface);
174 d->send_configure(size.width(), size.height());
175}
176
177#if QT_CONFIG(wayland_compositor_quick)
178QWaylandQuickShellIntegration *QWaylandIviSurface::createIntegration(QWaylandQuickShellSurfaceItem *item)
179{
180 return new QtWayland::IviSurfaceIntegration(item);
181}
182#endif
183
184/*!
185 * \internal
186 */
187void QWaylandIviSurface::initialize()
188{
189 QWaylandShellSurfaceTemplate::initialize();
190}
191
192QWaylandIviSurfacePrivate::QWaylandIviSurfacePrivate()
193{
194}
195
196void QWaylandIviSurfacePrivate::ivi_surface_destroy_resource(QtWaylandServer::ivi_surface::Resource *resource)
197{
198 Q_UNUSED(resource);
199 Q_Q(QWaylandIviSurface);
200 QWaylandIviApplicationPrivate::get(m_iviApplication)->unregisterIviSurface(q);
201 delete q;
202}
203
204void QWaylandIviSurfacePrivate::ivi_surface_destroy(QtWaylandServer::ivi_surface::Resource *resource)
205{
206 wl_resource_destroy(resource->handle);
207}
208
209QT_END_NAMESPACE
210
211#include "moc_qwaylandivisurface.cpp"
Combined button and popup list for selecting options.