allow setting a bogus desktop value on startup; prevents containments kept around due to desktops disappearing on us from becoming activity spawners
BUG:252264 svn path=/trunk/KDE/kdelibs/; revision=1179185
This commit is contained in:
parent
72b4a73b5d
commit
b5b4ea581a
@ -349,7 +349,7 @@ void Containment::restore(KConfigGroup &group)
|
|||||||
//kDebug() << "setScreen from restore";
|
//kDebug() << "setScreen from restore";
|
||||||
d->lastScreen = group.readEntry("lastScreen", d->lastScreen);
|
d->lastScreen = group.readEntry("lastScreen", d->lastScreen);
|
||||||
d->lastDesktop = group.readEntry("lastDesktop", d->lastDesktop);
|
d->lastDesktop = group.readEntry("lastDesktop", d->lastDesktop);
|
||||||
setScreen(group.readEntry("screen", d->screen), group.readEntry("desktop", d->desktop));
|
d->setScreen(group.readEntry("screen", d->screen), group.readEntry("desktop", d->desktop), false);
|
||||||
QString activityId = group.readEntry("activityId", QString());
|
QString activityId = group.readEntry("activityId", QString());
|
||||||
if (!activityId.isEmpty()) {
|
if (!activityId.isEmpty()) {
|
||||||
d->context()->setCurrentActivityId(activityId);
|
d->context()->setCurrentActivityId(activityId);
|
||||||
@ -363,19 +363,17 @@ void Containment::restore(KConfigGroup &group)
|
|||||||
setWallpaper(group.readEntry("wallpaperplugin", defaultWallpaper),
|
setWallpaper(group.readEntry("wallpaperplugin", defaultWallpaper),
|
||||||
group.readEntry("wallpaperpluginmode", defaultWallpaperMode));
|
group.readEntry("wallpaperpluginmode", defaultWallpaperMode));
|
||||||
|
|
||||||
|
|
||||||
QMetaObject::invokeMethod(d->toolBox.data(), "restore", Q_ARG(KConfigGroup, group));
|
QMetaObject::invokeMethod(d->toolBox.data(), "restore", Q_ARG(KConfigGroup, group));
|
||||||
|
|
||||||
|
|
||||||
KConfigGroup cfg(&group, "ActionPlugins");
|
KConfigGroup cfg(&group, "ActionPlugins");
|
||||||
kDebug() << cfg.keyList();
|
//kDebug() << cfg.keyList();
|
||||||
if (cfg.exists()) {
|
if (cfg.exists()) {
|
||||||
//clear default containmentactionss
|
//clear default containmentactionss
|
||||||
qDeleteAll(d->actionPlugins);
|
qDeleteAll(d->actionPlugins);
|
||||||
d->actionPlugins.clear();
|
d->actionPlugins.clear();
|
||||||
//load the right configactions
|
//load the right configactions
|
||||||
foreach (const QString &key, cfg.keyList()) {
|
foreach (const QString &key, cfg.keyList()) {
|
||||||
kDebug() << "loading" << key;
|
//kDebug() << "loading" << key;
|
||||||
setContainmentActions(key, cfg.readEntry(key, QString()));
|
setContainmentActions(key, cfg.readEntry(key, QString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -934,6 +932,11 @@ Applet::List Containment::applets() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Containment::setScreen(int newScreen, int newDesktop)
|
void Containment::setScreen(int newScreen, int newDesktop)
|
||||||
|
{
|
||||||
|
d->setScreen(newScreen, newDesktop);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContainmentPrivate::setScreen(int newScreen, int newDesktop, bool preventInvalidDesktops)
|
||||||
{
|
{
|
||||||
// What we want to do in here is:
|
// What we want to do in here is:
|
||||||
// * claim the screen as our own
|
// * claim the screen as our own
|
||||||
@ -945,39 +948,42 @@ void Containment::setScreen(int newScreen, int newDesktop)
|
|||||||
// we kick out
|
// we kick out
|
||||||
//
|
//
|
||||||
// a screen of -1 means no associated screen.
|
// a screen of -1 means no associated screen.
|
||||||
Q_ASSERT(corona());
|
Corona *corona = q->corona();
|
||||||
int numScreens = corona()->numScreens();
|
Q_ASSERT(corona);
|
||||||
|
int numScreens = corona->numScreens();
|
||||||
if (newScreen < -1) {
|
if (newScreen < -1) {
|
||||||
newScreen = -1;
|
newScreen = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -1 == All desktops
|
// -1 == All desktops
|
||||||
if (newDesktop < -1 || newDesktop > KWindowSystem::numberOfDesktops() - 1) {
|
if (newDesktop < -1 || (preventInvalidDesktops && newDesktop > KWindowSystem::numberOfDesktops() - 1)) {
|
||||||
newDesktop = -1;
|
newDesktop = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//kDebug() << activity() << "setting screen to " << newScreen << newDesktop << "and type is" << d->type;
|
//kDebug() << activity() << "setting screen to " << newScreen << newDesktop << "and type is" << type;
|
||||||
|
|
||||||
Containment *swapScreensWith(0);
|
Containment *swapScreensWith(0);
|
||||||
if (d->type == DesktopContainment || d->type >= CustomContainment) {
|
if (type == Containment::DesktopContainment || type >= Containment::CustomContainment) {
|
||||||
// we want to listen to changes in work area if our screen changes
|
// we want to listen to changes in work area if our screen changes
|
||||||
if (d->toolBox && d->screen < 0 && newScreen > -1) {
|
if (toolBox) {
|
||||||
connect(KWindowSystem::self(), SIGNAL(workAreaChanged()), d->toolBox.data(), SLOT(positionToolBox()), Qt::UniqueConnection);
|
if (screen < 0 && newScreen > -1) {
|
||||||
} else if (d->toolBox && newScreen < 0) {
|
QObject::connect(KWindowSystem::self(), SIGNAL(workAreaChanged()), toolBox.data(), SLOT(positionToolBox()), Qt::UniqueConnection);
|
||||||
disconnect(KWindowSystem::self(), SIGNAL(workAreaChanged()), d->toolBox.data(), SLOT(positionToolBox()));
|
} else if (newScreen < 0) {
|
||||||
|
QObject::disconnect(KWindowSystem::self(), SIGNAL(workAreaChanged()), toolBox.data(), SLOT(positionToolBox()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newScreen > -1 && corona()) {
|
if (newScreen > -1) {
|
||||||
// sanity check to make sure someone else doesn't have this screen already!
|
// sanity check to make sure someone else doesn't have this screen already!
|
||||||
Containment *currently = corona()->containmentForScreen(newScreen, newDesktop);
|
Containment *currently = corona->containmentForScreen(newScreen, newDesktop);
|
||||||
if (currently && currently != this) {
|
if (currently && currently != q) {
|
||||||
kDebug() << "currently is on screen" << currently->screen()
|
kDebug() << "currently is on screen" << currently->screen()
|
||||||
<< "desktop" << currently->desktop()
|
<< "desktop" << currently->desktop()
|
||||||
<< "and is" << currently->activity()
|
<< "and is" << currently->activity()
|
||||||
<< (QObject*)currently << "i'm" << (QObject*)this;
|
<< (QObject*)currently << "i'm" << (QObject*)q;
|
||||||
//kDebug() << "setScreen due to swap";
|
//kDebug() << "setScreen due to swap";
|
||||||
//make the view completely forget about us
|
//make the view completely forget about us
|
||||||
emit screenChanged(d->screen, -1, this);
|
emit q->screenChanged(screen, -1, q);
|
||||||
currently->setScreen(-1, newDesktop);
|
currently->setScreen(-1, newDesktop);
|
||||||
swapScreensWith = currently;
|
swapScreensWith = currently;
|
||||||
}
|
}
|
||||||
@ -985,32 +991,32 @@ void Containment::setScreen(int newScreen, int newDesktop)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (newScreen < numScreens && newScreen > -1 &&
|
if (newScreen < numScreens && newScreen > -1 &&
|
||||||
(d->type == DesktopContainment || d->type >= CustomContainment)) {
|
(type == Containment::DesktopContainment || type >= Containment::CustomContainment)) {
|
||||||
resize(corona()->screenGeometry(newScreen).size());
|
q->resize(corona->screenGeometry(newScreen).size());
|
||||||
}
|
}
|
||||||
|
|
||||||
int oldDesktop = d->desktop;
|
int oldDesktop = desktop;
|
||||||
d->desktop = newDesktop;
|
desktop = newDesktop;
|
||||||
|
|
||||||
int oldScreen = d->screen;
|
int oldScreen = screen;
|
||||||
d->screen = newScreen;
|
screen = newScreen;
|
||||||
|
|
||||||
|
|
||||||
updateConstraints(Plasma::ScreenConstraint);
|
q->updateConstraints(Plasma::ScreenConstraint);
|
||||||
|
|
||||||
if (oldScreen != newScreen || oldDesktop != newDesktop) {
|
if (oldScreen != newScreen || oldDesktop != newDesktop) {
|
||||||
emit screenChanged(oldScreen, newScreen, this);
|
emit q->screenChanged(oldScreen, newScreen, q);
|
||||||
|
|
||||||
KConfigGroup c = config();
|
KConfigGroup c = q->config();
|
||||||
c.writeEntry("screen", d->screen);
|
c.writeEntry("screen", screen);
|
||||||
c.writeEntry("desktop", d->desktop);
|
c.writeEntry("desktop", desktop);
|
||||||
if (newScreen != -1) {
|
if (newScreen != -1) {
|
||||||
d->lastScreen = newScreen;
|
lastScreen = newScreen;
|
||||||
d->lastDesktop = newDesktop;
|
lastDesktop = newDesktop;
|
||||||
c.writeEntry("lastScreen", d->lastScreen);
|
c.writeEntry("lastScreen", lastScreen);
|
||||||
c.writeEntry("lastDesktop", d->lastDesktop);
|
c.writeEntry("lastDesktop", lastDesktop);
|
||||||
}
|
}
|
||||||
emit configNeedsSaving();
|
emit q->configNeedsSaving();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (swapScreensWith) {
|
if (swapScreensWith) {
|
||||||
@ -1018,10 +1024,10 @@ void Containment::setScreen(int newScreen, int newDesktop)
|
|||||||
swapScreensWith->setScreen(oldScreen, oldDesktop);
|
swapScreensWith->setScreen(oldScreen, oldDesktop);
|
||||||
}
|
}
|
||||||
|
|
||||||
d->checkRemoveAction();
|
checkRemoveAction();
|
||||||
|
|
||||||
if (newScreen >= 0) {
|
if (newScreen >= 0) {
|
||||||
emit activate();
|
emit q->activate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@ public:
|
|||||||
void triggerShowAddWidgets();
|
void triggerShowAddWidgets();
|
||||||
void requestConfiguration();
|
void requestConfiguration();
|
||||||
void checkStatus(Plasma::ItemStatus status);
|
void checkStatus(Plasma::ItemStatus status);
|
||||||
|
void setScreen(int newScreen, int newDesktop, bool preventInvalidDesktops = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when constraints have been updated on this containment to provide
|
* Called when constraints have been updated on this containment to provide
|
||||||
|
Loading…
x
Reference in New Issue
Block a user