From kde-commits Tue Aug 31 22:59:11 2010 From: =?utf-8?q?Aaron=20J=2E=20Seigo?= Date: Tue, 31 Aug 2010 22:59:11 +0000 To: kde-commits Subject: branches/KDE/4.5/kdebase/workspace/plasma/desktop/shell Message-Id: <20100831225911.8238FAC871 () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=128329533416771 SVN commit 1170446 by aseigo: backport fixes for: CCBUG:241332 M +25 -0 panelview.cpp M +3 -0 panelview.h M +30 -11 plasmaapp.cpp M +6 -1 plasmaapp.h --- branches/KDE/4.5/kdebase/workspace/plasma/desktop/shell/panelview.cpp #1170445:1170446 @@ -1196,6 +1196,31 @@ recreateUnhideTrigger(); } +bool PanelView:: migratedFrom(int screenId) const +{ + KConfigGroup cg = config(); + QList migrations; + migrations = cg.readEntry("Migrations", migrations); + return migrations.contains(screenId); +} + +void PanelView::migrateTo(int screenId) +{ + KConfigGroup cg = config(); + QList migrations; + migrations = cg.readEntry("Migrations", migrations); + + const int index = migrations.indexOf(screenId); + if (index == -1) { + migrations.append(screenId); + } else { + migrations = migrations.mid(0, migrations.length() - index - 1); + } + + cg.writeEntry("Migrations", migrations); + setScreen(screenId); +} + void PanelView::enterEvent(QEvent *event) { // allow unhiding to happen again even if we were delay-unhidden --- branches/KDE/4.5/kdebase/workspace/plasma/desktop/shell/panelview.h #1170445:1170446 @@ -205,6 +205,9 @@ void updateStruts(); + bool migratedFrom(int screenId) const; + void migrateTo(int screenId); + protected: void moveEvent(QMoveEvent *event); void resizeEvent(QResizeEvent *event); --- branches/KDE/4.5/kdebase/workspace/plasma/desktop/shell/plasmaapp.cpp #1170445:1170446 @@ -664,7 +664,7 @@ QList screens = Kephal::Screens::self()->screens(); screens.removeAll(primary); - // Now we process panels: if there is room on another sreen for the panel, + // Now we process panels: if there is room on another screen for the panel, // we migrate the panel there, otherwise the view is deleted. The primary // screen is preferred in all cases. QMutableListIterator pIt(m_panels); @@ -684,7 +684,7 @@ } if (moveTo) { - panel->containment()->setScreen(moveTo->id()); + panel->migrateTo(moveTo->id()); } else { pIt.remove(); delete panel; @@ -704,7 +704,13 @@ m_panelViewCreationTimer.start(); } } + + foreach (PanelView *view, m_panels) { + if (view->migratedFrom(screen->id())) { + view->migrateTo(screen->id()); } + } +} bool PlasmaApp::canRelocatePanel(PanelView * view, Kephal::Screen *screen) { @@ -740,7 +746,7 @@ if (pv != view && pv->screen() == screen->id() && pv->location() == view->location() && - !pv->geometry().intersects(newGeom)) { + pv->geometry().intersects(newGeom)) { return false; break; } @@ -919,11 +925,6 @@ const QList > containments = m_panelsWaiting; m_panelsWaiting.clear(); - Kephal::Screen *primary = Kephal::Screens::self()->primaryScreen(); - QList screens = Kephal::Screens::self()->screens(); - screens.removeAll(primary); - - QList relocationCandidates; foreach (QWeakPointer containmentPtr, containments) { Plasma::Containment *containment = containmentPtr.data(); if (!containment) { @@ -942,16 +943,32 @@ // try to relocate the panel if it is on a now-non-existent screen if (containment->screen() >= Kephal::ScreenUtils::numScreens()) { - relocationCandidates << containment; + m_panelRelocationCandidates << containment; continue; } createPanelView(containment); } + if (!m_panelRelocationCandidates.isEmpty()) { + QTimer::singleShot(0, this, SLOT(relocatePanels())); + } +} + +void PlasmaApp::relocatePanels() +{ // we go through relocatables last so that all other panels can be set up first, // preventing panel creation ordering to trip up the canRelocatePanel algorithm - foreach (Plasma::Containment *containment, relocationCandidates) { + Kephal::Screen *primary = Kephal::Screens::self()->primaryScreen(); + QList screens = Kephal::Screens::self()->screens(); + screens.removeAll(primary); + + foreach (QWeakPointer c, m_panelRelocationCandidates) { + Plasma::Containment *containment = c.data(); + if (!containment) { + continue; + } + Kephal::Screen *moveTo = 0; PanelView *panelView = createPanelView(containment); if (canRelocatePanel(panelView, primary)) { @@ -966,12 +983,14 @@ } if (moveTo) { - containment->setScreen(moveTo->id(), -1); + panelView->migrateTo(moveTo->id()); } else { m_panels.removeAll(panelView); delete panelView; } } + + m_panelRelocationCandidates.clear(); } PanelView *PlasmaApp::createPanelView(Plasma::Containment *containment) --- branches/KDE/4.5/kdebase/workspace/plasma/desktop/shell/plasmaapp.h #1170445:1170446 @@ -152,13 +152,18 @@ void wallpaperCheckedIn(); void wallpaperCheckInTimeout(); void dashboardClosed(); + void relocatePanels(); private: DesktopCorona *m_corona; + QList m_panels; QList > m_panelsWaiting; + QList > m_panelRelocationCandidates; + + QList m_desktops; QList > m_desktopsWaiting; - QList m_desktops; + QTimer m_panelViewCreationTimer; QTimer m_desktopViewCreationTimer; QWeakPointer m_console;