guard a bit better against multiple desktop containments claiming the same screen

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=738061
This commit is contained in:
Aaron J. Seigo 2007-11-17 20:50:57 +00:00
parent c28155b585
commit 40e5395c3e
2 changed files with 22 additions and 6 deletions

View File

@ -166,7 +166,7 @@ void Containment::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
//kDebug() << "context menu event " << immutable;
if (!applet) {
if (!scene() || static_cast<Corona*>(scene())->isImmutable()) {
kDebug() << "immutability";
//kDebug() << "immutability";
QGraphicsItem::contextMenuEvent(event);
return;
}
@ -176,7 +176,7 @@ void Containment::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
QList<QAction*> actions = contextActions();
if (actions.count() < 1) {
kDebug() << "no applet, but no actions";
//kDebug() << "no applet, but no actions";
QGraphicsItem::contextMenuEvent(event);
return;
}
@ -185,13 +185,13 @@ void Containment::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
desktopMenu.addAction(action);
}
} else {
kDebug() << "immutable applet";
//kDebug() << "immutable applet";
QGraphicsItem::contextMenuEvent(event);
return;
}
event->accept();
kDebug() << "executing at" << event->screenPos();
//kDebug() << "executing at" << event->screenPos();
desktopMenu.exec(event->screenPos());
}
@ -201,7 +201,7 @@ void Containment::setFormFactor(FormFactor formFactor)
return;
}
//kDebug() << "switching FF to " << formFactor;
//kDebug() << "switching FF to " << formFactor;
d->formFactor = formFactor;
Layout *lay = layout();
setLayout(0);
@ -363,6 +363,14 @@ Applet::List Containment::applets() const
void Containment::setScreen(int screen)
{
// screen of -1 means no associated screen.
// sanity check to make sure someone else doesn't have this screen already!
if (type() == DesktopContainment && corona()) {
Containment* currently = corona()->containmentForScreen(screen);
if (currently && currently != this) {
//kDebug() << "currently is on screen" << currently->screen() << "and is" << currently->name() << (QObject*)currently << (QObject*)this;
currently->setScreen(-1);
}
}
//kDebug() << "setting screen to" << screen;
QDesktopWidget *desktop = QApplication::desktop();
@ -395,6 +403,9 @@ void Containment::setScreen(int screen)
r.moveLeft(r.x() + INTER_CONTAINMENT_MARGIN * screensLeft);
r.moveTop(r.y() + INTER_CONTAINMENT_MARGIN * screensAbove);
// FIXME: positioning at this x,y will break if we switch between containments for a
// given screen! we should change the pos() on new containment setup.
setGeometry(r);
//kDebug() << "setting geometry to" << desktop->screenGeometry(screen) << r << geometry();
} else if (type() == PanelContainment) {

View File

@ -98,9 +98,14 @@ int View::screen() const
void View::setContainment(Containment *containment)
{
if( d->containment ) {
if (!containment) {
return;
}
if (d->containment) {
disconnect(d->containment, SIGNAL(geometryChanged()), this, SLOT(updateSceneRect()));
}
d->containment = containment;
d->screen = containment->screen();
updateSceneRect();