summaryrefslogtreecommitdiffstats
path: root/src/plugins/shellintegration
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@qt.io>2018-05-29 14:50:11 +0200
committerPaul Olav Tvete <paul.tvete@qt.io>2018-05-29 16:05:26 +0000
commit0e1809d116561a73fbfb5e878efaace26228df84 (patch)
treeacaa71551721dda7e0dcaa1e994bc472c0b4372e /src/plugins/shellintegration
parent649fb15215f15736f53fab4f02be5dbd388512c0 (diff)
Client: use new shell plugin pattern for ivi-shell
Initialize should return false if the ivi-application global is not present. The previous code worked because ivi-shell was last in the priority list. This may not always be the case if we add more shells, or allow QT_WAYLAND_SHELL_INTEGRATION to be a list. Change-Id: Iec4409db039b3ebe163264187f901af5d845e54d Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Diffstat (limited to 'src/plugins/shellintegration')
-rw-r--r--src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp36
-rw-r--r--src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.h8
2 files changed, 15 insertions, 29 deletions
diff --git a/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp b/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp
index 14074625a..efb61dc9f 100644
--- a/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp
+++ b/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp
@@ -58,18 +58,21 @@ QWaylandIviShellIntegration::QWaylandIviShellIntegration()
{
}
-QWaylandIviShellIntegration::~QWaylandIviShellIntegration()
-{
- delete m_iviApplication;
- delete m_iviController;
-}
-
bool QWaylandIviShellIntegration::initialize(QWaylandDisplay *display)
{
- QWaylandShellIntegration::initialize(display);
- display->addRegistryListener(registryIvi, this);
+ for (QWaylandDisplay::RegistryGlobal global : display->globals()) {
+ if (global.interface == QLatin1String("ivi_application") && !m_iviApplication)
+ m_iviApplication.reset(new QtWayland::ivi_application(display->wl_registry(), global.id, global.version));
+ if (global.interface == QLatin1String("ivi_controller") && !m_iviController)
+ m_iviController.reset(new QtWayland::ivi_controller(display->wl_registry(), global.id, global.version));
+ }
+
+ if (!m_iviApplication) {
+ qCDebug(lcQpaWayland) << "Couldn't find global ivi_application for ivi-shell";
+ return false;
+ }
- return true;
+ return QWaylandShellIntegration::initialize(display);
}
/* get unique id
@@ -154,21 +157,6 @@ QWaylandShellSurface *QWaylandIviShellIntegration::createShellSurface(QWaylandWi
return iviSurface;
}
-void QWaylandIviShellIntegration::registryIvi(void *data,
- struct wl_registry *registry,
- uint32_t id,
- const QString &interface,
- uint32_t version)
-{
- QWaylandIviShellIntegration *shell = static_cast<QWaylandIviShellIntegration *>(data);
-
- if (interface == QStringLiteral("ivi_application"))
- shell->m_iviApplication = new QtWayland::ivi_application(registry, id, version);
-
- if (interface == QStringLiteral("ivi_controller"))
- shell->m_iviController = new QtWayland::ivi_controller(registry, id, version);
-}
-
}
QT_END_NAMESPACE
diff --git a/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.h b/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.h
index 11a2ae99b..fc16d2f64 100644
--- a/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.h
+++ b/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.h
@@ -58,18 +58,16 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandIviShellIntegration : public QWaylandShell
{
public:
QWaylandIviShellIntegration();
- ~QWaylandIviShellIntegration() override;
+
bool initialize(QWaylandDisplay *display) override;
QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
private:
- static void registryIvi(void *data, struct wl_registry *registry,
- uint32_t id, const QString &interface, uint32_t version);
uint32_t getNextUniqueSurfaceId();
private:
- QtWayland::ivi_application *m_iviApplication = nullptr;
- QtWayland::ivi_controller *m_iviController = nullptr;
+ QScopedPointer<QtWayland::ivi_application> m_iviApplication;
+ QScopedPointer<QtWayland::ivi_controller> m_iviController;
uint32_t m_lastSurfaceId = 0;
uint32_t m_surfaceNumber = 0;
bool m_useEnvSurfaceId = false;