@@ -23,6 +23,7 @@
24#include <unity/shell/application/ApplicationInfoInterface.h>
24#include <unity/shell/application/ApplicationInfoInterface.h>
25#include <unity/shell/application/MirSurfaceListInterface.h>
25#include <unity/shell/application/MirSurfaceListInterface.h>
26+#include <unity/shell/application/MirSurfaceInterface.h>
27#include <QDesktopServices>
28#include <QDesktopServices>
28#include <QDebug>
29#include <QDebug>
@@ -198,12 +199,25 @@ void LauncherModel::quickListActionInvoked(const QString &appId, int actionIndex
199 pin(appId);
200 pin(appId);
201− } else if (actionId == QLatin1String("launch_item")) {
202+ } else if (actionId == QStringLiteral("launch_item")) {
202 QDesktopServices::openUrl(getUrlForAppId(appId));
203 QDesktopServices::openUrl(getUrlForAppId(appId));
203− } else if (actionId == QLatin1String("stop_item")) { // Quit
204+ } else if (actionId == QStringLiteral("stop_item")) { // Quit
204 if (m_appManager) {
205 if (m_appManager) {
205 m_appManager->stopApplication(appId);
206 m_appManager->stopApplication(appId);
208+ } else if (actionId.startsWith(QStringLiteral("surface_"))){
209+ ApplicationInfoInterface *appInfo = m_appManager->findApplication(appId);
211+ qWarning() << "App for" << appId << "not found in launcher. Cannot invoke quicklist action";
213+ for (int i = 0; i < appInfo->surfaceList()->count(); ++i) {
214+ MirSurfaceInterface *iface = appInfo->surfaceList()->get(i);
215+ QString id = actionId;
216+ id.remove(QRegExp("^surface_"));
217+ if (id == iface->persistentId()) {
207 // Nope, we don't know this action, let the backend forward it to the application
221 // Nope, we don't know this action, let the backend forward it to the application
209 // TODO: forward quicklist action to app, possibly via m_dbusIface
223 // TODO: forward quicklist action to app, possibly via m_dbusIface
@@ -517,40 +531,59 @@ void LauncherModel::applicationAdded(const QModelIndex &parent, int row)
517 item->setRecent(true);
531 item->setRecent(true);
518 Q_EMIT dataChanged(index(itemIndex), index(itemIndex), {RoleRecent});
532 Q_EMIT dataChanged(index(itemIndex), index(itemIndex), {RoleRecent});
520− if (item->surfaceCount() != app->surfaceCount()) {
521− item->setSurfaceCount(app->surfaceCount());
522− Q_EMIT dataChanged(index(itemIndex), index(itemIndex), {RoleSurfaceCount});
525 item->setRunning(true);
534 item->setRunning(true);
527 LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString(), this);
536 LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString(), this);
528 item->setRecent(true);
537 item->setRecent(true);
529 item->setRunning(true);
538 item->setRunning(true);
530 item->setFocused(app->focused());
539 item->setFocused(app->focused());
531− item->setSurfaceCount(app->surfaceCount());
532 beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
540 beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
533 m_list.append(item);
541 m_list.append(item);
534 endInsertRows();
542 endInsertRows();
536− connect(app, &ApplicationInfoInterface::surfaceCountChanged, this, &LauncherModel::applicationSurfaceCountChanged);
544+ connect(app, &ApplicationInfoInterface::surfaceCountChanged, this, &LauncherModel::updateSurfaceList);
537 m_asAdapter->syncItems(m_list);
545 m_asAdapter->syncItems(m_list);
538 Q_EMIT dataChanged(index(itemIndex), index(itemIndex), {RoleRunning});
546 Q_EMIT dataChanged(index(itemIndex), index(itemIndex), {RoleRunning});
541−void LauncherModel::applicationSurfaceCountChanged(int count)
549+void LauncherModel::updateSurfaceList()
543 ApplicationInfoInterface *app = static_cast<ApplicationInfoInterface*>(sender());
551 ApplicationInfoInterface *app = static_cast<ApplicationInfoInterface*>(sender());
552+ updateSurfaceListForApp(app);
555+void LauncherModel::updateSurfaceListForSurface()
557+ MirSurfaceInterface *iface = static_cast<MirSurfaceInterface*>(sender());
558+ ApplicationInfoInterface* app = m_appManager->findApplication(iface->appId());
562+ updateSurfaceListForApp(app);
565+void LauncherModel::updateSurfaceListForApp(ApplicationInfoInterface* app)
544 int idx = findApplication(app->appId());
567 int idx = findApplication(app->appId());
545 if (idx < 0) {
568 if (idx < 0) {
546 qWarning() << "Received a surface count changed event from an app that's not in the Launcher model";
569 qWarning() << "Received a surface count changed event from an app that's not in the Launcher model";
549 LauncherItem *item = m_list.at(idx);
572 LauncherItem *item = m_list.at(idx);
550− if (item->surfaceCount() != count) {
573+ QList<QPair<QString, QString> > surfaces;
551− item->setSurfaceCount(count);
574+ for (int i = 0; i < app->surfaceList()->count(); ++i) {
552− Q_EMIT dataChanged(index(idx), index(idx), {RoleSurfaceCount});
575+ MirSurfaceInterface* iface = app->surfaceList()->get(i);
576+ // Avoid duplicate connections, so let's just disconnect first to be sure
577+ disconnect(iface, &MirSurfaceInterface::nameChanged, this, &LauncherModel::updateSurfaceListForSurface);
578+ connect(iface, &MirSurfaceInterface::nameChanged, this, &LauncherModel::updateSurfaceListForSurface);
579+ QString name = iface->name();
580+ if (name.isEmpty()) {
583+ surfaces.append({iface->persistentId(), name});
585+ item->setSurfaces(surfaces);
586+ Q_EMIT dataChanged(index(idx), index(idx), {RoleSurfaceCount});
556void LauncherModel::applicationRemoved(const QModelIndex &parent, int row)
589void LauncherModel::applicationRemoved(const QModelIndex &parent, int row)
@@ -571,7 +604,7 @@ void LauncherModel::applicationRemoved(const QModelIndex &parent, int row)
574− disconnect(app, &ApplicationInfoInterface::surfaceCountChanged, this, &LauncherModel::applicationSurfaceCountChanged);
607+ disconnect(app, &ApplicationInfoInterface::surfaceCountChanged, this, &LauncherModel::updateSurfaceList);
576 LauncherItem * item = m_list.at(appIndex);
609 LauncherItem * item = m_list.at(appIndex);