more safety in swapping containments around

svn path=/trunk/KDE/kdelibs/; revision=1200095
This commit is contained in:
Aaron J. Seigo 2010-11-23 22:18:15 +00:00
parent 8e5bcfc79c
commit 3e354c4e81

View File

@ -244,14 +244,14 @@ void View::setContainment(Plasma::Containment *containment)
Containment *oldContainment = d->containment; Containment *oldContainment = d->containment;
int screen = -1; int screen = d->lastScreen;
int desktop = -1; int desktop = d->lastDesktop;
if (oldContainment) { if (oldContainment && oldContainment != containment) {
if (oldContainment != containment) { screen = oldContainment->screen();
screen = d->containment->screen(); desktop = oldContainment->desktop();
desktop = d->containment->desktop(); }
}
} else { if (scene() != containment->scene()) {
setScene(containment->scene()); setScene(containment->scene());
} }
@ -267,15 +267,20 @@ void View::setContainment(Plasma::Containment *containment)
d->lastScreen = screen; d->lastScreen = screen;
d->lastDesktop = desktop; d->lastDesktop = desktop;
//kDebug() << "set screen from setContainment due to old containment"; //kDebug() << "set screen from setContainment due to old containment";
oldContainment->setScreen(-1, -1); if (oldContainment && oldContainment != containment) {
containment->setScreen(-1, -1); oldContainment->setScreen(-1, -1);
containment->setScreen(screen, desktop); }
if (screen != containment->screen() || desktop != containment->desktop()) {
containment->setScreen(screen, desktop);
}
} else { } else {
d->lastScreen = otherScreen; d->lastScreen = otherScreen;
d->lastDesktop = otherDesktop; d->lastDesktop = otherDesktop;
} }
if (oldContainment && oldContainment != d->containment && otherScreen > -1) { if (oldContainment && oldContainment != containment && otherScreen > -1 &&
(!containment || otherScreen != containment->screen() || otherDesktop != containment->desktop())) {
// assign the old containment the old screen/desktop // assign the old containment the old screen/desktop
//kDebug() << "set screen from setContainment" << screen << otherScreen << desktop << otherDesktop; //kDebug() << "set screen from setContainment" << screen << otherScreen << desktop << otherDesktop;
oldContainment->setScreen(otherScreen, otherDesktop); oldContainment->setScreen(otherScreen, otherDesktop);