diff --git a/autotests/coronatest.cpp b/autotests/coronatest.cpp index 3967b8c9e..3e9b51bda 100644 --- a/autotests/coronatest.cpp +++ b/autotests/coronatest.cpp @@ -31,6 +31,8 @@ Plasma::Applet *SimpleLoader::internalLoadApplet(const QString &name, uint apple return new SimpleApplet(0, QString(), appletId); } else if (name == "simplecontainment") { return new SimpleContainment(0, QString(), appletId); + } else if (name == "simplenoscreencontainment") { + return new SimpleNoScreenContainment(0, QString(), appletId); } else { return 0; } @@ -52,6 +54,14 @@ QRect SimpleCorona::screenGeometry(int screen) const return QRect(100*screen, 100, 100, 100); } +int SimpleCorona::screenForContainment(const Plasma::Containment *c) const +{ + if (qobject_cast(c)) { + return -1; + } + return 0; +} + SimpleApplet::SimpleApplet(QObject *parent , const QString &serviceId, uint appletId) : Plasma::Applet(parent, serviceId, appletId) { @@ -83,7 +93,11 @@ SimpleContainment::SimpleContainment(QObject *parent , const QString &serviceId, }); } - +SimpleNoScreenContainment::SimpleNoScreenContainment(QObject *parent , const QString &serviceId, uint appletId) + : Plasma::Containment(parent, serviceId, appletId) +{ + //This containment will *never* be isUiReady() +} static void runKBuildSycoca() { @@ -129,8 +143,20 @@ void CoronaTest::cleanupTestCase() void CoronaTest::restore() { m_corona->loadLayout("plasma-test-appletsrc"); - QCOMPARE(m_corona->containments().count(), 2); - QCOMPARE(m_corona->containments().first()->applets().count(), 2); + QCOMPARE(m_corona->containments().count(), 3); + //TODO: check the order of m_corona->containments() is stable: + //at the moment the ordering seems pretty random + //same thing for the order of containment->applets() + for (auto cont : m_corona->containments()) { + switch (cont->id()) { + case 1: + QCOMPARE(cont->applets().count(), 2); + break; + default: + QCOMPARE(cont->applets().count(), 0); + break; + } + } } void CoronaTest::startupCompletion() diff --git a/autotests/coronatest.h b/autotests/coronatest.h index d4098ef3c..4f6d37f84 100644 --- a/autotests/coronatest.h +++ b/autotests/coronatest.h @@ -43,6 +43,7 @@ public: ~SimpleCorona(); QRect screenGeometry(int) const; + int screenForContainment(const Plasma::Containment *) const; }; class SimpleApplet : public Plasma::Applet @@ -65,6 +66,14 @@ private: QTimer m_timer; }; +class SimpleNoScreenContainment : public Plasma::Containment +{ + Q_OBJECT + +public: + explicit SimpleNoScreenContainment(QObject *parent = 0, const QString &serviceId = QString(), uint appletId = 0); +}; + class CoronaTest : public QObject { Q_OBJECT diff --git a/autotests/plasma-test-appletsrc b/autotests/plasma-test-appletsrc index 972cd5997..a832e9a72 100644 --- a/autotests/plasma-test-appletsrc +++ b/autotests/plasma-test-appletsrc @@ -22,5 +22,15 @@ lastScreen=0 location=4 plugin=simplecontainment +#this is a desktop containment that even if has lastScreen=0 +#its screen will be -1: this is the case of a containment of +#another activity, not the current one +[Containments][5] +formfactor=0 +immutability=1 +lastScreen=0 +location=0 +plugin=simplenoscreencontainment + [General] immutability=1 diff --git a/src/plasma/corona.cpp b/src/plasma/corona.cpp index d51a9b8c7..81a327d73 100644 --- a/src/plasma/corona.cpp +++ b/src/plasma/corona.cpp @@ -557,7 +557,7 @@ QList CoronaPrivate::importLayout(const KConfigGroup &con if (!mergeConfig) { containmentsStarting = 0; foreach (Containment *containment, containments) { - if (!containment->isUiReady() && containment->lastScreen() < q->numScreens()) { + if (!containment->isUiReady() && containment->screen() < q->numScreens() && containment->screen() >= 0) { ++containmentsStarting; QObject::connect(containment, &Plasma::Containment::uiReadyChanged, [=](bool ready) { if (!ready) {