summaryrefslogtreecommitdiffstats
path: root/src/compositor/extensions/qwaylandwlshell.cpp
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@theqtcompany.com>2016-03-19 15:36:22 +0100
committerJohan Helsing <johan.helsing@qt.io>2016-06-13 11:04:30 +0000
commit5fbb2043a1be8b14e70335c2b2db77702e52fa10 (patch)
treea6283e3ce41f66f7efab12a0682f7c28964be143 /src/compositor/extensions/qwaylandwlshell.cpp
parentb8d74c81e501f05d7d91c0b236e070729514d866 (diff)
Compositor, wl_shell: Maintain a list of all shellSurfaces
QWaylandShellSurface is added to a list of all shell surfaces. This list can be convenient in a number of places, namely: * Closing all popups * Checking for protocol errors * Other uses for iterating over all shell surfaces Change-Id: I384b4e2170840e8db55ca01c49eccc0463f38863 Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Diffstat (limited to 'src/compositor/extensions/qwaylandwlshell.cpp')
-rw-r--r--src/compositor/extensions/qwaylandwlshell.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/compositor/extensions/qwaylandwlshell.cpp b/src/compositor/extensions/qwaylandwlshell.cpp
index 90f591956..51c73fc64 100644
--- a/src/compositor/extensions/qwaylandwlshell.cpp
+++ b/src/compositor/extensions/qwaylandwlshell.cpp
@@ -86,9 +86,16 @@ void QWaylandWlShellPrivate::shell_get_shell_surface(Resource *resource, uint32_
shellSurface = new QWaylandWlShellSurface(q, surface, shellSurfaceResource);
}
+ m_shellSurfaces.append(shellSurface);
emit q->shellSurfaceCreated(shellSurface);
}
+void QWaylandWlShellPrivate::unregisterShellSurface(QWaylandWlShellSurface *shellSurface)
+{
+ if (!m_shellSurfaces.removeOne(shellSurface))
+ qWarning("Unexpected state. Can't find registered shell surface.");
+}
+
QWaylandWlShellSurfacePrivate::QWaylandWlShellSurfacePrivate()
: QWaylandCompositorExtensionPrivate()
, wl_shell_surface()
@@ -308,6 +315,23 @@ void QWaylandWlShell::initialize()
d->init(compositor->display(), 1);
}
+QList<QWaylandWlShellSurface *> QWaylandWlShell::shellSurfaces() const
+{
+ Q_D(const QWaylandWlShell);
+ return d->m_shellSurfaces;
+}
+
+QList<QWaylandWlShellSurface *> QWaylandWlShell::shellSurfacesForClient(QWaylandClient *client) const
+{
+ Q_D(const QWaylandWlShell);
+ QList<QWaylandWlShellSurface *> surfsForClient;
+ Q_FOREACH (QWaylandWlShellSurface *shellSurface, d->m_shellSurfaces) {
+ if (shellSurface->surface()->client() == client)
+ surfsForClient.append(shellSurface);
+ }
+ return surfsForClient;
+}
+
/*!
* Returns the Wayland interface for the QWaylandWlShell.
*/
@@ -385,6 +409,12 @@ QWaylandWlShellSurface::QWaylandWlShellSurface(QWaylandWlShell *shell, QWaylandS
initialize(shell, surface, res);
}
+QWaylandWlShellSurface::~QWaylandWlShellSurface()
+{
+ Q_D(QWaylandWlShellSurface);
+ QWaylandWlShellPrivate::get(d->m_shell)->unregisterShellSurface(this);
+}
+
/*!
* \qmlmethod void QtWaylandCompositor::WlShellSurface::initialize(object shell, object surface, object client, int id)
*