SVN commit 792179 by aseigo: improve mointor hot[un]plug support, patch by Aike J Sommer. thanks, Aike! CCMAIL:dev@aikesommer.name M +5 -1 libs/plasma/view.cpp M +21 -22 plasma/plasma/desktopcorona.cpp M +12 -2 plasma/plasma/rootwidget.cpp --- trunk/KDE/kdebase/workspace/libs/plasma/view.cpp #792178:792179 @@ -124,7 +124,7 @@ void View::setContainment(Containment *containment) { - if (!containment || containment == d->containment) { + if (containment == d->containment) { return; } @@ -136,6 +136,10 @@ } d->containment = containment; + if (! containment) { + return; + } + if (screen > -1) { containment->setScreen(screen); } --- trunk/KDE/kdebase/workspace/plasma/plasma/desktopcorona.cpp #792178:792179 @@ -63,21 +63,19 @@ c->setScreen(i); c->setFormFactor(Plasma::Planar); c->flushUpdatedConstraints(); + } else if (i >= m_numScreens) { + // now ensure that if our screen count changed we actually get views + // for them, even if the Containment already existed for that screen + // so we "lie" and emit a containmentAdded signal for every new screen + // regardless of whether it actually already existed, or just got added + // and therefore had this signal emitted. plasma can handle such + // multiple emissions of the signal, and this is simply the most + // straightforward way of accomplishing this + kDebug() << "Notifying of new screen: " << i; + emit containmentAdded(containmentForScreen(i)); } } - // now ensure that if our screen count changed we actually get views - // for them, even if the Containment already existed for that screen - // so we "lie" and emit a containmentAdded signal for every new screen - // regardless of whether it actually already existed, or just got added - // and therefore had this signal emitted. plasma can handle such - // multiple emissions of the signal, and this is simply the most - // straightforward way of accomplishing this - for (int i = m_numScreens; i < numScreens; ++i) { - kDebug() << "Notifying of new screen: " << i; - emit containmentAdded(containmentForScreen(i)); - } - m_numScreens = numScreens; } @@ -131,18 +129,19 @@ void DesktopCorona::screenResized(int screen) { - bool desktopFound = false; - foreach (Plasma::Containment *c, containments()) { - if (c->screen() == screen) { - // trigger a relayout - c->setScreen(screen); - desktopFound = desktopFound || - c->containmentType() == Plasma::Containment::DesktopContainment || - c->containmentType() == Plasma::Containment::CustomContainment; + int numScreens = QApplication::desktop()->numScreens(); + if (screen < numScreens) { + foreach (Plasma::Containment *c, containments()) { + if (c->screen() == screen) { + // trigger a relayout + c->setScreen(screen); + } } + + checkScreens(); // ensure we have containments for every screen + } else { + m_numScreens = numScreens; } - - checkScreens(); // ensure we have containments for every screen } #include "desktopcorona.moc" --- trunk/KDE/kdebase/workspace/plasma/plasma/rootwidget.cpp #792178:792179 @@ -107,9 +107,18 @@ QDesktopWidget *desktop = QApplication::desktop(); setGeometry(desktop->geometry()); DesktopView *view = viewForScreen(screen); - + if (view) { - view->adjustSize(); + if (screen < desktop->numScreens()) { + view->adjustSize(); + } else { + // the screen was removed, so we'll destroy the + // corresponding view + kDebug() << "removing the view for screen" << screen; + view->setContainment(0); + m_desktops.removeAll(view); + delete view; + } } } @@ -138,6 +147,7 @@ DesktopView *view = new DesktopView(containment, this); view->setGeometry(QApplication::desktop()->screenGeometry(containment->screen())); m_desktops.append(view); + view->show(); } void RootWidget::screenOwnerChanged(int wasScreen, int isScreen, Plasma::Containment* containment)