on xenial help sign in
add support for launcher surface pips reflecting the proper number of surfaces
commita1b1033f9a4450a19b0877c46dc0a05c0410a0d3 authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 10 May 2016, 17:51 (10 years ago) parentb0fad55
21 files changed+153−38
plugins/Greeter/Unity/Launcher/CMakeLists.txt+1−1 plugins/Greeter/Unity/Launcher/launcheritem.cpp+13 plugins/Greeter/Unity/Launcher/launcheritem.h+3−1 plugins/Greeter/Unity/Launcher/launchermodelas.cpp+2 plugins/Unity/Launcher/CMakeLists.txt+3−1 plugins/Unity/Launcher/launcheritem.cpp+14 plugins/Unity/Launcher/launcheritem.h+3 plugins/Unity/Launcher/launchermodel.cpp+25−1 plugins/Unity/Launcher/launchermodel.h+1 qml/Launcher/LauncherDelegate.qml+4−2 qml/Launcher/LauncherPanel.qml+1 tests/mocks/Unity/Application/ApplicationInfo.cpp+26−25 tests/mocks/Unity/Application/ApplicationInfo.h+3−2 tests/mocks/Unity/Application/MirSurfaceListModel.cpp+2−2 tests/mocks/Unity/Launcher/CMakeLists.txt+1−1 tests/mocks/Unity/Launcher/MockLauncherItem.cpp+14 tests/mocks/Unity/Launcher/MockLauncherItem.h+3 tests/mocks/Unity/Launcher/MockLauncherModel.cpp+5 tests/plugins/Unity/Launcher/CMakeLists.txt+1−1 tests/plugins/Unity/Launcher/launchermodeltest.cpp+13−1 tests/qmltests/Launcher/tst_Launcher.qml+15
plugins/Greeter/Unity/Launcher/CMakeLists.txt+1−1
@@ -1,4 +1,4 @@
1−pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=7)
1+pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=8)
22pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
33
44add_definitions(-DSM_BUSNAME=systemBus)
plugins/Greeter/Unity/Launcher/launcheritem.cpp+13
@@ -179,6 +179,19 @@ void LauncherItem::setAlerting(bool alerting)
179179 }
180180}
181181
182+int LauncherItem::surfaceCount() const
183+{
184+ return m_surfaceCount;
185+}
186+
187+void LauncherItem::setSurfaceCount(int surfaceCount)
188+{
189+ if (m_surfaceCount != surfaceCount) {
190+ m_surfaceCount = surfaceCount;
191+ Q_EMIT surfaceCountChanged(surfaceCount);
192+ }
193+}
194+
182195unity::shell::launcher::QuickListModelInterface *LauncherItem::quickList() const
183196{
184197 return m_quickList;
plugins/Greeter/Unity/Launcher/launcheritem.h+3−1
@@ -42,6 +42,7 @@ public:
4242 bool countVisible() const override;
4343 bool focused() const override;
4444 bool alerting() const override;
45+ int surfaceCount() const override;
4546
4647 unity::shell::launcher::QuickListModelInterface *quickList() const override;
4748
@@ -56,7 +57,7 @@ private:
5657 void setCountVisible(bool countVisible);
5758 void setFocused(bool focused);
5859 void setAlerting(bool alerting);
59−
60+ void setSurfaceCount(int surfaceCount);
6061
6162private:
6263 QString m_appId;
@@ -70,6 +71,7 @@ private:
7071 bool m_countVisible;
7172 bool m_focused;
7273 bool m_alerting;
74+ int m_surfaceCount;
7375 QuickListModel *m_quickList;
7476
7577 friend class LauncherModel;
plugins/Greeter/Unity/Launcher/launchermodelas.cpp+2
@@ -69,6 +69,8 @@ QVariant LauncherModel::data(const QModelIndex &index, int role) const
6969 return item->focused();
7070 case RoleRunning:
7171 return item->running();
72+ case RoleSurfaceCount:
73+ return item->surfaceCount();
7274 }
7375
7476 return QVariant();
plugins/Unity/Launcher/CMakeLists.txt+3−1
@@ -1,4 +1,4 @@
1−pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=7)
1+pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=8)
22pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
33
44add_definitions(-DSM_BUSNAME=systemBus)
@@ -23,6 +23,8 @@ set(QMLLAUNCHERPLUGIN_SRC
2323 asadapter.cpp
2424 ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsServiceDBusAdaptor.cpp
2525 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
26+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
27+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceListInterface.h
2628 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherItemInterface.h
2729 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherModelInterface.h
2830 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/QuickListModelInterface.h
plugins/Unity/Launcher/launcheritem.cpp+14
@@ -35,6 +35,7 @@ LauncherItem::LauncherItem(const QString &appId, const QString &name, const QStr
3535 m_countVisible(false),
3636 m_focused(false),
3737 m_alerting(false),
38+ m_surfaceCount(0),
3839 m_quickList(new QuickListModel(this))
3940{
4041 Q_ASSERT(parent != nullptr);
@@ -213,6 +214,19 @@ void LauncherItem::setAlerting(bool alerting)
213214 }
214215}
215216
217+int LauncherItem::surfaceCount() const
218+{
219+ return m_surfaceCount;
220+}
221+
222+void LauncherItem::setSurfaceCount(int surfaceCount)
223+{
224+ if (m_surfaceCount != surfaceCount) {
225+ m_surfaceCount = surfaceCount;
226+ Q_EMIT surfaceCountChanged(surfaceCount);
227+ }
228+}
229+
216230unity::shell::launcher::QuickListModelInterface *LauncherItem::quickList() const
217231{
218232 return m_quickList;
plugins/Unity/Launcher/launcheritem.h+3
@@ -45,6 +45,7 @@ public:
4545 bool countVisible() const override;
4646 bool focused() const override;
4747 bool alerting() const override;
48+ int surfaceCount() const override;
4849
4950 unity::shell::launcher::QuickListModelInterface *quickList() const override;
5051
@@ -59,6 +60,7 @@ private:
5960 void setCountVisible(bool countVisible);
6061 void setFocused(bool focused);
6162 void setAlerting(bool alerting);
63+ void setSurfaceCount(int surfaceCount);
6264
6365private:
6466 QString m_appId;
@@ -72,6 +74,7 @@ private:
7274 bool m_countVisible;
7375 bool m_focused;
7476 bool m_alerting;
77+ int m_surfaceCount;
7578 QuickListModel *m_quickList;
7679 QuickListEntry m_quitAction;
7780
plugins/Unity/Launcher/launchermodel.cpp+25−1
@@ -25,6 +25,7 @@
2525#include "asadapter.h"
2626
2727#include <unity/shell/application/ApplicationInfoInterface.h>
28+#include <unity/shell/application/MirSurfaceListInterface.h>
2829
2930#include <QDesktopServices>
3031#include <QDebug>
@@ -88,6 +89,8 @@ QVariant LauncherModel::data(const QModelIndex &index, int role) const
8889 return item->alerting();
8990 case RoleRunning:
9091 return item->running();
92+ case RoleSurfaceCount:
93+ return item->surfaceCount();
9194 default:
9295 qWarning() << Q_FUNC_INFO << "missing role, implement me";
9396 return QVariant();
@@ -525,21 +528,42 @@ void LauncherModel::applicationAdded(const QModelIndex &parent, int row)
525528 item->setRecent(true);
526529 Q_EMIT dataChanged(index(itemIndex), index(itemIndex), {RoleRecent});
527530 }
531+ if (item->surfaceCount() != app->surfaceCount()) {
532+ item->setSurfaceCount(app->surfaceList()->count());
533+ Q_EMIT dataChanged(index(itemIndex), index(itemIndex), {RoleSurfaceCount});
534+ }
535+
528536 item->setRunning(true);
529537 } else {
530538 LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString(), this);
531539 item->setRecent(true);
532540 item->setRunning(true);
533541 item->setFocused(app->focused());
534−
542+ item->setSurfaceCount(app->surfaceCount());
535543 beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
536544 m_list.append(item);
537545 endInsertRows();
538546 }
547+ connect(app, &ApplicationInfoInterface::surfaceCountChanged, this, &LauncherModel::applicationSurfaceCountChanged);
539548 m_asAdapter->syncItems(m_list);
540549 Q_EMIT dataChanged(index(itemIndex), index(itemIndex), {RoleRunning});
541550}
542551
552+void LauncherModel::applicationSurfaceCountChanged(int count)
553+{
554+ ApplicationInfoInterface *app = static_cast<ApplicationInfoInterface*>(sender());
555+ int idx = findApplication(app->appId());
556+ if (idx < 0) {
557+ qWarning() << "Received a surface count changed event from an app that's not in the Launcher model";
558+ return;
559+ }
560+ LauncherItem *item = m_list.at(idx);
561+ if (item->surfaceCount() != count) {
562+ item->setSurfaceCount(count);
563+ Q_EMIT dataChanged(index(idx), index(idx), {RoleSurfaceCount});
564+ }
565+}
566+
543567void LauncherModel::applicationRemoved(const QModelIndex &parent, int row)
544568{
545569 Q_UNUSED(parent)
plugins/Unity/Launcher/launchermodel.h+1
@@ -79,6 +79,7 @@ private Q_SLOTS:
7979 void applicationAdded(const QModelIndex &parent, int row);
8080 void applicationRemoved(const QModelIndex &parent, int row);
8181 void focusedAppIdChanged();
82+ void applicationSurfaceCountChanged(int);
8283
8384private:
8485 QList<LauncherItem*> m_list;
qml/Launcher/LauncherDelegate.qml+4−2
@@ -32,6 +32,7 @@ Item {
3232 property bool alerting: false
3333 property bool highlighted: false
3434 property bool shortcutHintShown: false
35+ property int surfaceCount: 1
3536
3637 readonly property int effectiveHeight: Math.cos(angle * Math.PI / 180) * itemHeight
3738 readonly property real foldedHeight: Math.cos(maxAngle * Math.PI / 180) * itemHeight
@@ -171,7 +172,7 @@ Item {
171172 Label {
172173 id: countLabel
173174 objectName: "countLabel"
174− text: root.count
175+ text: root.surfaceCount//root.count
175176 anchors.centerIn: parent
176177 width: root.itemWidth - units.gu(1)
177178 horizontalAlignment: Text.AlignHCenter
@@ -221,7 +222,8 @@ Item {
221222 }
222223 spacing: units.gu(.5)
223224 Repeater {
224− model: 1 // TODO: This should be "Math.min(3, app.surfaceCount)" once we have multiple surfaces
225+ objectName: "surfacePipRepeater"
226+ model: Math.min(3, root.surfaceCount)
225227 Rectangle {
226228 objectName: "runningHighlight" + index
227229 width: units.gu(0.25)
qml/Launcher/LauncherPanel.qml+1
@@ -239,6 +239,7 @@ Rectangle {
239239 alerting: model.alerting
240240 highlighted: root.highlightIndex == index
241241 shortcutHintShown: root.shortcutHintsShown && index <= 9
242+ surfaceCount: model.surfaceCount
242243 z: -Math.abs(offset)
243244 maxAngle: 55
244245 property bool dragging: false
tests/mocks/Unity/Application/ApplicationInfo.cpp+26−25
@@ -55,8 +55,9 @@ QString stateToStr(ApplicationInfo::State state)
5555ApplicationInfo::ApplicationInfo(const QString &appId, QObject *parent)
5656 : ApplicationInfoInterface(appId, parent)
5757 , m_appId(appId)
58+ , m_surfaceList(new MirSurfaceListModel(this))
5859{
59− connect(&m_surfaceList, &MirSurfaceListModel::countChanged,
60+ connect(m_surfaceList, &MirSurfaceListModel::countChanged,
6061 this, &ApplicationInfo::onSurfaceCountChanged, Qt::QueuedConnection);
6162
6263 m_surfaceCreationTimer.setSingleShot(true);
@@ -78,8 +79,8 @@ void ApplicationInfo::createSurface()
7879 if (state() == ApplicationInfo::Stopped) { return; }
7980
8081 QString surfaceName = name();
81− if (m_surfaceList.count() > 0) {
82− surfaceName.append(QString(" %1").arg(m_surfaceList.count()+1));
82+ if (m_surfaceList->count() > 0) {
83+ surfaceName.append(QString(" %1").arg(m_surfaceList->count()+1));
8384 }
8485
8586 auto surfaceManager = SurfaceManager::instance();
@@ -95,7 +96,7 @@ void ApplicationInfo::createSurface()
9596
9697 surface->setShellChrome(m_shellChrome);
9798
98− m_surfaceList.appendSurface(surface);
99+ m_surfaceList->appendSurface(surface);
99100
100101 ++m_liveSurfaceCount;
101102 connect(surface, &MirSurface::liveChanged, this, [this, surface](){
@@ -186,12 +187,12 @@ void ApplicationInfo::setState(State value)
186187 if (value != m_state) {
187188 DEBUG_MSG(qPrintable(stateToStr(value)));
188189 if (!m_manualSurfaceCreation && value == ApplicationInfo::Starting) {
189− Q_ASSERT(m_surfaceList.count() == 0);
190+ Q_ASSERT(m_surfaceList->count() == 0);
190191 m_surfaceCreationTimer.start();
191192 } else if (value == ApplicationInfo::Stopped) {
192193 m_surfaceCreationTimer.stop();
193− for (int i = 0; i < m_surfaceList.count(); ++i) {
194− MirSurface *surface = static_cast<MirSurface*>(m_surfaceList.get(i));
194+ for (int i = 0; i < m_surfaceList->count(); ++i) {
195+ MirSurface *surface = static_cast<MirSurface*>(m_surfaceList->get(i));
195196 surface->setLive(false);
196197 }
197198 }
@@ -205,9 +206,9 @@ void ApplicationInfo::close()
205206{
206207 DEBUG_MSG("");
207208
208− if (m_surfaceList.count() > 0) {
209− for (int i = 0; i < m_surfaceList.count(); ++i) {
210− MirSurface *surface = static_cast<MirSurface*>(m_surfaceList.get(i));
209+ if (m_surfaceList->count() > 0) {
210+ for (int i = 0; i < m_surfaceList->count(); ++i) {
211+ MirSurface *surface = static_cast<MirSurface*>(m_surfaceList->get(i));
211212 surface->close();
212213 }
213214 } else {
@@ -219,15 +220,15 @@ void ApplicationInfo::close()
219220void ApplicationInfo::setFullscreen(bool value)
220221{
221222 m_fullscreen = value;
222− if (m_surfaceList.rowCount() > 0) {
223− m_surfaceList.get(0)->setState(Mir::FullscreenState);
223+ if (m_surfaceList->rowCount() > 0) {
224+ m_surfaceList->get(0)->setState(Mir::FullscreenState);
224225 }
225226}
226227
227228bool ApplicationInfo::fullscreen() const
228229{
229− if (m_surfaceList.rowCount() > 0) {
230− return m_surfaceList.get(0)->state() == Mir::FullscreenState;
230+ if (m_surfaceList->rowCount() > 0) {
231+ return m_surfaceList->get(0)->state() == Mir::FullscreenState;
231232 } else {
232233 return m_fullscreen;
233234 }
@@ -333,16 +334,16 @@ void ApplicationInfo::setInitialSurfaceSize(const QSize &size)
333334void ApplicationInfo::setShellChrome(Mir::ShellChrome shellChrome)
334335{
335336 m_shellChrome = shellChrome;
336− if (m_surfaceList.rowCount() > 0) {
337− static_cast<MirSurface*>(m_surfaceList.get(0))->setShellChrome(shellChrome);
337+ if (m_surfaceList->rowCount() > 0) {
338+ static_cast<MirSurface*>(m_surfaceList->get(0))->setShellChrome(shellChrome);
338339 }
339340}
340341
341342bool ApplicationInfo::focused() const
342343{
343344 bool someSurfaceHasFocus = false; // to be proven wrong
344− for (int i = 0; i < m_surfaceList.count() && !someSurfaceHasFocus; ++i) {
345− someSurfaceHasFocus = m_surfaceList.get(i)->focused();
345+ for (int i = 0; i < m_surfaceList->count() && !someSurfaceHasFocus; ++i) {
346+ someSurfaceHasFocus = m_surfaceList->get(i)->focused();
346347 }
347348 return someSurfaceHasFocus;
348349}
@@ -354,12 +355,12 @@ void ApplicationInfo::setFocused(bool value)
354355 }
355356
356357 if (value) {
357− if (m_surfaceList.count() > 0) {
358− m_surfaceList.get(0)->requestFocus();
358+ if (m_surfaceList->count() > 0) {
359+ m_surfaceList->get(0)->requestFocus();
359360 }
360361 } else {
361− for (int i = 0; i < m_surfaceList.count(); ++i) {
362− MirSurface *surface = static_cast<MirSurface*>(m_surfaceList.get(i));
362+ for (int i = 0; i < m_surfaceList->count(); ++i) {
363+ MirSurface *surface = static_cast<MirSurface*>(m_surfaceList->get(i));
363364 if (surface->focused()) {
364365 surface->setFocused(false);
365366 }
@@ -369,16 +370,16 @@ void ApplicationInfo::setFocused(bool value)
369370
370371void ApplicationInfo::onSurfaceCountChanged()
371372{
372− if (m_surfaceList.count() == 0 && m_state == Running) {
373+ if (m_surfaceList->count() == 0 && m_state == Running) {
373374 setState(Stopped);
374375 }
375376}
376377
377378void ApplicationInfo::requestFocus()
378379{
379− if (m_surfaceList.count() == 0) {
380+ if (m_surfaceList->count() == 0) {
380381 Q_EMIT focusRequested();
381382 } else {
382− m_surfaceList.get(0)->requestFocus();
383+ m_surfaceList->get(0)->requestFocus();
383384 }
384385}
tests/mocks/Unity/Application/ApplicationInfo.h+3−2
@@ -107,7 +107,8 @@ public:
107107
108108 Q_INVOKABLE void setShellChrome(Mir::ShellChrome shellChrome);
109109
110− MirSurfaceListInterface* surfaceList() override { return &m_surfaceList; }
110+ MirSurfaceListInterface* surfaceList() const override { return m_surfaceList; }
111+ int surfaceCount() const override { return m_surfaceList->count(); }
111112
112113 void setFocused(bool value);
113114
@@ -147,7 +148,7 @@ private:
147148 bool m_isTouchApp{true};
148149 bool m_exemptFromLifecycle{false};
149150 QSize m_initialSurfaceSize;
150− MirSurfaceListModel m_surfaceList;
151+ MirSurfaceListModel *m_surfaceList;
151152 int m_liveSurfaceCount{0};
152153 QTimer m_surfaceCreationTimer;
153154 QList<MirSurface*> m_closingSurfaces;
tests/mocks/Unity/Application/MirSurfaceListModel.cpp+2−2
@@ -66,7 +66,7 @@ void MirSurfaceListModel::appendSurface(MirSurface *surface)
6666 m_surfaceList.append(surface);
6767 connectSurface(surface);
6868 endInsertRows();
69− Q_EMIT countChanged();
69+ Q_EMIT countChanged(m_surfaceList.count());
7070}
7171
7272void MirSurfaceListModel::connectSurface(MirSurface *surface)
@@ -82,7 +82,7 @@ void MirSurfaceListModel::removeSurface(MirSurface *surface)
8282 beginRemoveRows(QModelIndex(), i, i);
8383 m_surfaceList.removeAt(i);
8484 endRemoveRows();
85− Q_EMIT countChanged();
85+ Q_EMIT countChanged(m_surfaceList.count());
8686 }
8787}
8888
tests/mocks/Unity/Launcher/CMakeLists.txt+1−1
@@ -1,4 +1,4 @@
1−pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=7)
1+pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=8)
22
33include_directories(
44 ${CMAKE_CURRENT_SOURCE_DIR}
tests/mocks/Unity/Launcher/MockLauncherItem.cpp+14
@@ -38,6 +38,7 @@ MockLauncherItem::MockLauncherItem(const QString &appId, const QString& desktopF
3838 m_countVisible(false),
3939 m_focused(false),
4040 m_alerting(false),
41+ m_surfaceCount(0),
4142 m_quickList(new MockQuickListModel(this))
4243{
4344}
@@ -182,6 +183,19 @@ void MockLauncherItem::setAlerting(bool alerting)
182183 }
183184}
184185
186+int MockLauncherItem::surfaceCount() const
187+{
188+ return m_surfaceCount;
189+}
190+
191+void MockLauncherItem::setSurfaceCount(int surfaceCount)
192+{
193+ if (m_surfaceCount != surfaceCount) {
194+ m_surfaceCount = surfaceCount;
195+ Q_EMIT surfaceCountChanged(surfaceCount);
196+ }
197+}
198+
185199unity::shell::launcher::QuickListModelInterface *MockLauncherItem::quickList() const
186200{
187201 return m_quickList;
tests/mocks/Unity/Launcher/MockLauncherItem.h+3
@@ -46,6 +46,7 @@ public:
4646 bool countVisible() const override;
4747 bool focused() const override;
4848 bool alerting() const override;
49+ int surfaceCount() const override;
4950
5051 unity::shell::launcher::QuickListModelInterface *quickList() const override;
5152
@@ -58,6 +59,7 @@ private:
5859 void setCountVisible(bool countVisible);
5960 void setFocused(bool focused);
6061 void setAlerting(bool alerting);
62+ void setSurfaceCount(int surfaceCount);
6163
6264 QString m_appId;
6365 QString m_desktopFile;
@@ -71,6 +73,7 @@ private:
7173 bool m_countVisible;
7274 bool m_focused;
7375 bool m_alerting;
76+ int m_surfaceCount;
7477 MockQuickListModel *m_quickList;
7578
7679 friend class MockLauncherModel;
tests/mocks/Unity/Launcher/MockLauncherModel.cpp+5
@@ -25,6 +25,7 @@ MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(pa
2525 MockLauncherItem *item = new MockLauncherItem("dialer-app", "/usr/share/applications/dialer-app.desktop", "Dialer", "dialer-app", this);
2626 item->setProgress(0);
2727 item->setPinned(true);
28+ item->setSurfaceCount(1);
2829 item->setRunning(true);
2930 item->setFocused(true);
3031 m_list.append(item);
@@ -36,6 +37,7 @@ MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(pa
3637 item->setProgress(50);
3738 item->setCountVisible(true);
3839 item->setRunning(true);
40+ item->setSurfaceCount(2);
3941 item->setAlerting(false);
4042 m_list.append(item);
4143 item = new MockLauncherItem("music-app", "/usr/share/applications/music-app.desktop", "Music", "soundcloud", this);
@@ -44,6 +46,7 @@ MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(pa
4446 item->setProgress(150);
4547 m_list.append(item);
4648 item = new MockLauncherItem("webbrowser-app", "/usr/share/applications/webbrowser-app.desktop", "Browser", "browser", this);
49+ item->setSurfaceCount(5);
4750 item->setCount(1);
4851 item->setCountVisible(true);
4952 item->setRunning(true);
@@ -119,6 +122,8 @@ QVariant MockLauncherModel::data(const QModelIndex& index, int role) const
119122 return item->focused();
120123 case RoleAlerting:
121124 return item->alerting();
125+ case RoleSurfaceCount:
126+ return item->surfaceCount();
122127 }
123128
124129 return QVariant();
tests/plugins/Unity/Launcher/CMakeLists.txt+1−1
@@ -1,5 +1,5 @@
11pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
2−pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=7)
2+pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=8)
33
44include_directories(
55 ${CMAKE_CURRENT_SOURCE_DIR}
tests/plugins/Unity/Launcher/launchermodeltest.cpp+13−1
@@ -66,13 +66,16 @@ public:
6666 void setExemptFromLifecycle(bool) override {}
6767 QSize initialSurfaceSize() const override { return QSize(); }
6868 void setInitialSurfaceSize(const QSize &) override {}
69− MirSurfaceListInterface* surfaceList() override { return nullptr; }
69+ MirSurfaceListInterface* surfaceList() const override { return nullptr; }
70+ int surfaceCount() const override { return m_surfaceCount; }
71+ void setSurfaceCount(int count) { m_surfaceCount = count; Q_EMIT surfaceCountChanged(count); }
7072
7173 // Methods used for mocking (not in the interface)
7274 void setFocused(bool focused) { m_focused = focused; Q_EMIT focusedChanged(focused); }
7375private:
7476 QString m_appId;
7577 bool m_focused;
78+ int m_surfaceCount = 0;
7679};
7780
7881// This is a mock, specifically to test the LauncherModel
@@ -691,6 +694,15 @@ private Q_SLOTS:
691694 QCOMPARE(getASConfig().at(index).value("countVisible").toBool(), true);
692695 QCOMPARE(getASConfig().at(index).value("count").toInt(), 55);
693696 }
697+
698+ void testSurfaceCountUpdates() {
699+ QString appId = launcherModel->get(0)->appId();
700+
701+ QCOMPARE(launcherModel->get(0)->surfaceCount(), 0);
702+ MockApp *app = qobject_cast<MockApp*>(appManager->findApplication(appId));
703+ app->setSurfaceCount(1);
704+ QCOMPARE(launcherModel->get(0)->surfaceCount(), 1);
705+ }
694706};
695707
696708QTEST_GUILESS_MAIN(LauncherModelTest)
tests/qmltests/Launcher/tst_Launcher.qml+15
@@ -1283,5 +1283,20 @@ Rectangle {
12831283
12841284 assertFocusOnIndex(-2);
12851285 }
1286+
1287+ function test_surfaceCountPips() {
1288+ var launcherListView = findChild(launcher, "launcherListView")
1289+ var moveAnimation = findInvisibleChild(launcherListView, "moveAnimation")
1290+
1291+ for (var i = 0; i < launcherListView.count; i++) {
1292+ launcherListView.moveToIndex(i);
1293+ waitForRendering(launcherListView);
1294+ tryCompare(moveAnimation, "running", false);
1295+
1296+ var delegate = findChild(launcher, "launcherDelegate" + i);
1297+ var surfacePipRepeater = findInvisibleChild(delegate, "surfacePipRepeater");
1298+ compare(surfacePipRepeater.model, Math.min(3, LauncherModel.get(i).surfaceCount))
1299+ }
1300+ }
12861301 }
12871302}