Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qwaylandiviapplication.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
6
7#include <QtWaylandCompositor/QWaylandCompositor>
8#include <QtWaylandCompositor/QWaylandSurface>
9#include <QtWaylandCompositor/QWaylandIviSurface>
10#include <QtWaylandCompositor/QWaylandResource>
11
13
66
74
79{
82
84 if (!compositor) {
85 qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandIviApplication";
86 return;
87 }
88
89 d->init(compositor->display(), 1);
90}
91
95const struct wl_interface *QWaylandIviApplication::interface()
96{
97 return QWaylandIviApplicationPrivate::interface();
98}
99
104{
105 return QWaylandIviApplicationPrivate::interfaceName();
106}
107
143
148
149void QWaylandIviApplicationPrivate::ivi_application_surface_create(QtWaylandServer::ivi_application::Resource *resource,
150 uint32_t ivi_id, wl_resource *surfaceResource, uint32_t id)
151{
153 QWaylandSurface *surface = QWaylandSurface::fromResource(surfaceResource);
154
155 if (m_iviSurfaces.contains(ivi_id)) {
156 wl_resource_post_error(resource->handle, IVI_APPLICATION_ERROR_IVI_ID,
157 "Given ivi_id, %d, is already assigned to wl_surface@%d", ivi_id,
158 wl_resource_get_id(m_iviSurfaces[ivi_id]->surface()->resource()));
159 return;
160 }
161
162 if (!surface->setRole(QWaylandIviSurface::role(), resource->handle, IVI_APPLICATION_ERROR_ROLE))
163 return;
164
165 QWaylandResource iviSurfaceResource(wl_resource_create(resource->client(), &ivi_surface_interface,
166 wl_resource_get_version(resource->handle), id));
167
168 emit q->iviSurfaceRequested(surface, ivi_id, iviSurfaceResource);
169
170 QWaylandIviSurface *iviSurface = QWaylandIviSurface::fromResource(iviSurfaceResource.resource());
171
172 if (!iviSurface)
173 iviSurface = new QWaylandIviSurface(q, surface, ivi_id, iviSurfaceResource);
174
175 m_iviSurfaces.insert(ivi_id, iviSurface);
176
177 emit q->iviSurfaceCreated(iviSurface);
178}
179
181
182#include "moc_qwaylandiviapplication.cpp"
\inmodule QtCore
Definition qbytearray.h:57
bool remove(const Key &key)
Removes the item that has the key from the hash.
Definition qhash.h:958
bool contains(const Key &key) const noexcept
Returns true if the hash contains an item with the key; otherwise returns false.
Definition qhash.h:1007
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition qhash.h:1303
virtual void initialize()
Initializes the QWaylandCompositorExtension.
\qmltype WaylandCompositor \instantiates QWaylandCompositor \inqmlmodule QtWayland....
void ivi_application_surface_create(Resource *resource, uint32_t ivi_id, wl_resource *surface, uint32_t id) override
QHash< uint, QWaylandIviSurface * > m_iviSurfaces
void unregisterIviSurface(QWaylandIviSurface *iviSurface)
\qmltype IviApplication \instantiates QWaylandIviApplication \inqmlmodule QtWayland....
static const struct wl_interface * interface()
Returns the Wayland interface for the QWaylandIviApplication.
QWaylandIviApplication()
Constructs a QWaylandIviApplication object.
void initialize() override
Initializes the shell extension.
\qmltype IviSurface \instantiates QWaylandIviSurface \inqmlmodule QtWayland.Compositor....
static QWaylandSurfaceRole * role()
Returns the surface role for the QWaylandIviSurface.
static QWaylandIviSurface * fromResource(::wl_resource *resource)
Returns the QWaylandIviSurface corresponding to the resource.
\inmodule QtWaylandCompositor
\qmltype WaylandSurface \instantiates QWaylandSurface \inqmlmodule QtWayland.Compositor
static QWaylandSurface * fromResource(::wl_resource *resource)
Returns the QWaylandSurface corresponding to the Wayland resource resource.
bool setRole(QWaylandSurfaceRole *role, wl_resource *errorResource, uint32_t errorCode)
Sets a role on the surface.
Combined button and popup list for selecting options.
#define qWarning
Definition qlogging.h:166
static QOpenGLCompositor * compositor
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
#define emit