add a version containmentForScreen with activity
Summary: add a version of containmentForScreen which it has the activity. which is correct as the activity id of containments in in libplasma side. this ensure the correctness of shellCorona createContainmentForActivity as now it works also for activities different from the current one. to make multimonitor a tad safer with it, when creating containments for an activity, initialize their lastScreen to the asked screen. Test Plan: tried with an old plasmashell and is perfectly retrocompatible Reviewers: #plasma, davidedmundson Reviewed By: #plasma, davidedmundson Subscribers: davidedmundson, #frameworks Tags: #frameworks Differential Revision: https://phabricator.kde.org/D11361
This commit is contained in:
parent
e690c4726e
commit
bfa19dbc8f
@ -196,8 +196,8 @@ Containment *Corona::containmentForScreen(int screen) const
|
|||||||
{
|
{
|
||||||
foreach (Containment *containment, d->containments) {
|
foreach (Containment *containment, d->containments) {
|
||||||
if (containment->screen() == screen &&
|
if (containment->screen() == screen &&
|
||||||
(containment->containmentType() == Plasma::Types::DesktopContainment ||
|
(containment->containmentType() == Plasma::Types::DesktopContainment ||
|
||||||
containment->containmentType() == Plasma::Types::CustomContainment)) {
|
containment->containmentType() == Plasma::Types::CustomContainment)) {
|
||||||
return containment;
|
return containment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -208,13 +208,30 @@ Containment *Corona::containmentForScreen(int screen) const
|
|||||||
Containment *Corona::containmentForScreen(int screen,
|
Containment *Corona::containmentForScreen(int screen,
|
||||||
const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs)
|
const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs)
|
||||||
{
|
{
|
||||||
Containment *containment = containmentForScreen(screen);
|
return containmentForScreen(screen, QString(), defaultPluginIfNonExistent, defaultArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
Containment *Corona::containmentForScreen(int screen,
|
||||||
|
const QString &activity,
|
||||||
|
const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs)
|
||||||
|
{
|
||||||
|
Containment *containment = nullptr;
|
||||||
|
|
||||||
|
foreach (Containment *cont, d->containments) {
|
||||||
|
if (cont->lastScreen() == screen &&
|
||||||
|
(cont->activity().isEmpty() || cont->activity() == activity) &&
|
||||||
|
(cont->containmentType() == Plasma::Types::DesktopContainment ||
|
||||||
|
cont->containmentType() == Plasma::Types::CustomContainment)) {
|
||||||
|
containment = cont;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!containment && !defaultPluginIfNonExistent.isEmpty()) {
|
if (!containment && !defaultPluginIfNonExistent.isEmpty()) {
|
||||||
// screen requests are allowed to bypass immutability
|
// screen requests are allowed to bypass immutability
|
||||||
if (screen >= 0) {
|
if (screen >= 0) {
|
||||||
Plasma::Types::ImmutabilityType imm = d->immutability;
|
Plasma::Types::ImmutabilityType imm = d->immutability;
|
||||||
d->immutability = Types::Mutable;
|
d->immutability = Types::Mutable;
|
||||||
containment = d->addContainment(defaultPluginIfNonExistent, defaultArgs, 0, false);
|
containment = d->addContainment(defaultPluginIfNonExistent, defaultArgs, 0, screen, false);
|
||||||
if (containment) {
|
if (containment) {
|
||||||
// containment->setScreen(screen);
|
// containment->setScreen(screen);
|
||||||
}
|
}
|
||||||
@ -225,6 +242,42 @@ Containment *Corona::containmentForScreen(int screen,
|
|||||||
return containment;
|
return containment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Containment *> Corona::containmentsForActivity(const QString &activity)
|
||||||
|
{
|
||||||
|
QList<Containment *> conts;
|
||||||
|
|
||||||
|
if (activity.isEmpty()) {
|
||||||
|
return conts;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::copy_if(d->containments.begin(),
|
||||||
|
d->containments.end(),
|
||||||
|
std::back_inserter(conts),
|
||||||
|
[activity](Containment *cont) { return cont->activity() == activity &&
|
||||||
|
(cont->containmentType() == Plasma::Types::DesktopContainment ||
|
||||||
|
cont->containmentType() == Plasma::Types::CustomContainment);} );
|
||||||
|
|
||||||
|
return conts;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<Containment *> Corona::containmentsForScreen(int screen)
|
||||||
|
{
|
||||||
|
QList<Containment *> conts;
|
||||||
|
|
||||||
|
if (screen < 0) {
|
||||||
|
return conts;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::copy_if(d->containments.begin(),
|
||||||
|
d->containments.end(),
|
||||||
|
std::back_inserter(conts),
|
||||||
|
[screen](Containment *cont) { return cont->lastScreen() == screen &&
|
||||||
|
(cont->containmentType() == Plasma::Types::DesktopContainment ||
|
||||||
|
cont->containmentType() == Plasma::Types::CustomContainment);} );
|
||||||
|
|
||||||
|
return conts;
|
||||||
|
}
|
||||||
|
|
||||||
QList<Containment *> Corona::containments() const
|
QList<Containment *> Corona::containments() const
|
||||||
{
|
{
|
||||||
return d->containments;
|
return d->containments;
|
||||||
@ -247,7 +300,7 @@ KSharedConfigPtr Corona::config() const
|
|||||||
Containment *Corona::createContainment(const QString &name, const QVariantList &args)
|
Containment *Corona::createContainment(const QString &name, const QVariantList &args)
|
||||||
{
|
{
|
||||||
if (d->immutability == Types::Mutable || args.contains(QVariant::fromValue(QStringLiteral("org.kde.plasma:force-create")))) {
|
if (d->immutability == Types::Mutable || args.contains(QVariant::fromValue(QStringLiteral("org.kde.plasma:force-create")))) {
|
||||||
return d->addContainment(name, args, 0);
|
return d->addContainment(name, args, -1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -256,7 +309,7 @@ Containment *Corona::createContainment(const QString &name, const QVariantList &
|
|||||||
Containment *Corona::createContainmentDelayed(const QString &name, const QVariantList &args)
|
Containment *Corona::createContainmentDelayed(const QString &name, const QVariantList &args)
|
||||||
{
|
{
|
||||||
if (d->immutability == Types::Mutable) {
|
if (d->immutability == Types::Mutable) {
|
||||||
return d->addContainment(name, args, 0, true);
|
return d->addContainment(name, args, 0, -1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -447,7 +500,7 @@ void CoronaPrivate::syncConfig()
|
|||||||
emit q->configSynced();
|
emit q->configSynced();
|
||||||
}
|
}
|
||||||
|
|
||||||
Containment *CoronaPrivate::addContainment(const QString &name, const QVariantList &args, uint id, bool delayedInit)
|
Containment *CoronaPrivate::addContainment(const QString &name, const QVariantList &args, uint id, int lastScreen, bool delayedInit)
|
||||||
{
|
{
|
||||||
QString pluginName = name;
|
QString pluginName = name;
|
||||||
Containment *containment = nullptr;
|
Containment *containment = nullptr;
|
||||||
@ -485,6 +538,9 @@ Containment *CoronaPrivate::addContainment(const QString &name, const QVariantLi
|
|||||||
delete applet;
|
delete applet;
|
||||||
}
|
}
|
||||||
applet = containment = new Containment(q, {}, id);
|
applet = containment = new Containment(q, {}, id);
|
||||||
|
if (lastScreen >= 0) {
|
||||||
|
containment->d->lastScreen = lastScreen;
|
||||||
|
}
|
||||||
//if it's a dummy containment, just say its ui is ready, not blocking the corona
|
//if it's a dummy containment, just say its ui is ready, not blocking the corona
|
||||||
applet->updateConstraints(Plasma::Types::UiReadyConstraint);
|
applet->updateConstraints(Plasma::Types::UiReadyConstraint);
|
||||||
|
|
||||||
@ -574,7 +630,7 @@ QList<Plasma::Containment *> CoronaPrivate::importLayout(const KConfigGroup &con
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
// qCDebug(LOG_PLASMA) << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Adding Containment" << containmentConfig.readEntry("plugin", QString());
|
// qCDebug(LOG_PLASMA) << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Adding Containment" << containmentConfig.readEntry("plugin", QString());
|
||||||
#endif
|
#endif
|
||||||
Containment *c = addContainment(containmentConfig.readEntry("plugin", QString()), QVariantList(), cid);
|
Containment *c = addContainment(containmentConfig.readEntry("plugin", QString()), QVariantList(), cid, -1);
|
||||||
if (!c) {
|
if (!c) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -121,12 +121,30 @@ public:
|
|||||||
*/
|
*/
|
||||||
Containment *createContainment(const QString &name, const QVariantList &args = QVariantList());
|
Containment *createContainment(const QString &name, const QVariantList &args = QVariantList());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Containment for a given physical screen and desktop, creating one
|
||||||
|
* if none exists
|
||||||
|
*
|
||||||
|
* @param screen number of the physical screen to locate
|
||||||
|
* @param activity the activity id of the containment we want,
|
||||||
|
* and empty string if the activity is not important
|
||||||
|
* @param defaultPluginIfNonExistent the plugin to load by default; "null" won't
|
||||||
|
* create it and "default" creates the default plugin
|
||||||
|
* @param defaultArgs optional arguments to pass in when creating a Containment if needed
|
||||||
|
* @since 5.45
|
||||||
|
*/
|
||||||
|
Containment *containmentForScreen(int screen,
|
||||||
|
const QString &activity,
|
||||||
|
const QString &defaultPluginIfNonExistent,
|
||||||
|
const QVariantList &defaultArgs = QVariantList());
|
||||||
|
|
||||||
|
//TODO KF6: add activity here, can't be done now as the overload would get confused
|
||||||
/**
|
/**
|
||||||
* Returns the Containment, if any, for a given physical screen
|
* Returns the Containment, if any, for a given physical screen
|
||||||
*
|
*
|
||||||
* @param screen number of the physical screen to locate
|
* @param screen number of the physical screen to locate
|
||||||
*/
|
*/
|
||||||
Containment *containmentForScreen(int screen) const;
|
PLASMA_DEPRECATED Containment *containmentForScreen(int screen) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Containment for a given physical screen and desktop, creating one
|
* Returns the Containment for a given physical screen and desktop, creating one
|
||||||
@ -137,10 +155,26 @@ public:
|
|||||||
* Containment and "default" creates the default plugin
|
* Containment and "default" creates the default plugin
|
||||||
* @param defaultArgs optional arguments to pass in when creating a Containment if needed
|
* @param defaultArgs optional arguments to pass in when creating a Containment if needed
|
||||||
*/
|
*/
|
||||||
Containment *containmentForScreen(int screen,
|
PLASMA_DEPRECATED PLASMA_DEPRECATED Containment *containmentForScreen(int screen,
|
||||||
const QString &defaultPluginIfNonExistent,
|
const QString &defaultPluginIfNonExistent,
|
||||||
const QVariantList &defaultArgs = QVariantList());
|
const QVariantList &defaultArgs = QVariantList());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all containments which match a particular activity, for any screen
|
||||||
|
* @param activity the activity id we want
|
||||||
|
* @returns the list of matching containments if any, empty if activity is an empty string
|
||||||
|
* @since 5.45
|
||||||
|
*/
|
||||||
|
QList<Containment *> containmentsForActivity(const QString &activity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all containments which match a particular screen, for any activity
|
||||||
|
* @param screen the screen number we want
|
||||||
|
* @returns the list of matching containments if any, empty if screen is < 0
|
||||||
|
* @since 5.45
|
||||||
|
*/
|
||||||
|
QList<Containment *> containmentsForScreen(int screen);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of screens available to plasma.
|
* Returns the number of screens available to plasma.
|
||||||
* Subclasses should override this method as the default
|
* Subclasses should override this method as the default
|
||||||
|
@ -47,7 +47,7 @@ public:
|
|||||||
void syncConfig();
|
void syncConfig();
|
||||||
void notifyContainmentsReady();
|
void notifyContainmentsReady();
|
||||||
void containmentReady(bool ready);
|
void containmentReady(bool ready);
|
||||||
Containment *addContainment(const QString &name, const QVariantList &args, uint id, bool delayedInit = false);
|
Containment *addContainment(const QString &name, const QVariantList &args, uint id, int lastScreen, bool delayedInit = false);
|
||||||
QList<Plasma::Containment *> importLayout(const KConfigGroup &conf, bool mergeConfig);
|
QList<Plasma::Containment *> importLayout(const KConfigGroup &conf, bool mergeConfig);
|
||||||
|
|
||||||
Corona *q;
|
Corona *q;
|
||||||
|
Loading…
Reference in New Issue
Block a user