on xenial help sign in
fix issues from review
commit9118c5f7920c5b9752e53d5d2d62d36bf3e17242 authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 16 Mar 2017, 11:46 (10 years ago) parent6180c1c
7 files changed+39−10
CMakeLists.txt+1−1 debian/control+1−1 plugins/Unity/Launcher/CMakeLists.txt+2 plugins/Unity/Launcher/launchermodel.cpp+27−5 plugins/Unity/Launcher/launchermodel.h+3−1 qml/Launcher/LauncherPanel.qml+1 tests/plugins/Unity/Launcher/launchermodeltest.cpp+4−2
CMakeLists.txt+1−1
@@ -70,7 +70,7 @@ find_package(Qt5DBus 5.6 REQUIRED)
7070find_package(Qt5Concurrent 5.6 REQUIRED)
7171find_package(Qt5Sql 5.6 REQUIRED)
7272
73−pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=26)
73+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=27)
7474pkg_check_modules(GEONAMES REQUIRED geonames>=0.2)
7575pkg_check_modules(GIO REQUIRED gio-2.0>=2.32)
7676pkg_check_modules(GLIB REQUIRED glib-2.0>=2.32)
debian/control+1−1
@@ -38,7 +38,7 @@ Build-Depends: cmake,
3838 libubuntugestures5-private-dev (>= 1.3.2030),
3939 libudev-dev,
4040 libudm-common-dev,
41− libunity-api-dev (>= 8.5),
41+ libunity-api-dev (>= 8.6),
4242 libusermetricsoutput1-dev,
4343# Need those X11 libs touch emulation from mouse events in manual QML tests on a X11 desktop
4444 libx11-dev[!arm64 !armhf],
plugins/Unity/Launcher/CMakeLists.txt+2
@@ -30,6 +30,8 @@ set(QMLLAUNCHERPLUGIN_SRC
3030 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
3131 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
3232 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceListInterface.h
33+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceInterface.h
34+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h
3335 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherItemInterface.h
3436 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherModelInterface.h
3537 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/QuickListModelInterface.h
plugins/Unity/Launcher/launchermodel.cpp+27−5
@@ -23,6 +23,7 @@
2323
2424#include <unity/shell/application/ApplicationInfoInterface.h>
2525#include <unity/shell/application/MirSurfaceListInterface.h>
26+#include <unity/shell/application/MirSurfaceInterface.h>
2627
2728#include <QDesktopServices>
2829#include <QDebug>
@@ -540,15 +541,29 @@ void LauncherModel::applicationAdded(const QModelIndex &parent, int row)
540541 m_list.append(item);
541542 endInsertRows();
542543 }
543− connect(app, &ApplicationInfoInterface::surfaceCountChanged, this, &LauncherModel::applicationSurfaceCountChanged);
544+ connect(app, &ApplicationInfoInterface::surfaceCountChanged, this, &LauncherModel::updateSurfaceList);
544545 m_asAdapter->syncItems(m_list);
545546 Q_EMIT dataChanged(index(itemIndex), index(itemIndex), {RoleRunning});
546547}
547548
548−void LauncherModel::applicationSurfaceCountChanged(int count)
549+void LauncherModel::updateSurfaceList()
549550{
550− Q_UNUSED(count)
551551 ApplicationInfoInterface *app = static_cast<ApplicationInfoInterface*>(sender());
552+ updateSurfaceListForApp(app);
553+}
554+
555+void LauncherModel::updateSurfaceListForSurface()
556+{
557+ MirSurfaceInterface *iface = static_cast<MirSurfaceInterface*>(sender());
558+ ApplicationInfoInterface* app = m_appManager->findApplication(iface->appId());
559+ if (!app) {
560+ return;
561+ }
562+ updateSurfaceListForApp(app);
563+}
564+
565+void LauncherModel::updateSurfaceListForApp(ApplicationInfoInterface* app)
566+{
552567 int idx = findApplication(app->appId());
553568 if (idx < 0) {
554569 qWarning() << "Received a surface count changed event from an app that's not in the Launcher model";
@@ -558,7 +573,14 @@ void LauncherModel::applicationSurfaceCountChanged(int count)
558573 QList<QPair<QString, QString> > surfaces;
559574 for (int i = 0; i < app->surfaceList()->count(); ++i) {
560575 MirSurfaceInterface* iface = app->surfaceList()->get(i);
561− surfaces.append({iface->persistentId(), iface->name()});
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()) {
581+ name = app->name();
582+ }
583+ surfaces.append({iface->persistentId(), name});
562584 }
563585 item->setSurfaces(surfaces);
564586 Q_EMIT dataChanged(index(idx), index(idx), {RoleSurfaceCount});
@@ -582,7 +604,7 @@ void LauncherModel::applicationRemoved(const QModelIndex &parent, int row)
582604 return;
583605 }
584606
585− disconnect(app, &ApplicationInfoInterface::surfaceCountChanged, this, &LauncherModel::applicationSurfaceCountChanged);
607+ disconnect(app, &ApplicationInfoInterface::surfaceCountChanged, this, &LauncherModel::updateSurfaceList);
586608
587609 LauncherItem * item = m_list.at(appIndex);
588610
plugins/Unity/Launcher/launchermodel.h+3−1
@@ -75,7 +75,9 @@ private Q_SLOTS:
7575 void applicationAdded(const QModelIndex &parent, int row);
7676 void applicationRemoved(const QModelIndex &parent, int row);
7777 void focusedAppIdChanged();
78− void applicationSurfaceCountChanged(int);
78+ void updateSurfaceList();
79+ void updateSurfaceListForApp(ApplicationInfoInterface *app);
80+ void updateSurfaceListForSurface();
7981
8082private:
8183 QList<LauncherItem*> m_list;
qml/Launcher/LauncherPanel.qml+1
@@ -841,6 +841,7 @@ Rectangle {
841841 fontSize: index == 0 ? "medium" : "small"
842842 font.weight: index == 0 ? Font.Medium : Font.Light
843843 color: model.clickable ? theme.palette.normal.backgroundText : theme.palette.disabled.backgroundText
844+ elide: Text.ElideRight
844845 }
845846
846847 onClicked: {
tests/plugins/Unity/Launcher/launchermodeltest.cpp+4−2
@@ -42,10 +42,11 @@ class MockSurface: public unity::shell::application::MirSurfaceInterface
4242{
4343 Q_OBJECT
4444public:
45− MockSurface(const QString &id, QObject* parent): unityapi::MirSurfaceInterface(parent), m_id(id) {}
45+ MockSurface(const QString &id, const QString &appId, QObject* parent): unityapi::MirSurfaceInterface(parent), m_id(id), m_appId(appId) {}
4646 Mir::Type type() const override { return Mir::NormalType;}
4747 QString name() const override { return QStringLiteral("mock surface"); }
4848 QString persistentId() const override { return m_id; }
49+ QString appId() const override { return m_appId; }
4950 QPoint position() const override { return QPoint(); }
5051 QSize size() const override { return QSize(); }
5152 void resize(const QSize &size) override { Q_UNUSED(size) }
@@ -77,6 +78,7 @@ public:
7778
7879private:
7980 QString m_id;
81+ QString m_appId;
8082};
8183
8284class MockSurfaceList: public unity::shell::application::MirSurfaceListInterface
@@ -811,7 +813,7 @@ private Q_SLOTS:
811813 QCOMPARE(launcherModel->get(0)->surfaceCount(), 0);
812814 MockApp *app = qobject_cast<MockApp*>(appManager->findApplication(appId));
813815 MockSurfaceList* surfaces = new MockSurfaceList(appManager);
814− surfaces->append(new MockSurface("foobar", surfaces));
816+ surfaces->append(new MockSurface("foobar", "foobar", surfaces));
815817 app->setSurfaces(surfaces);
816818 QCOMPARE(launcherModel->get(0)->surfaceCount(), 1);
817819