move new copied dock to explicit screen

--if the new copied dock is on a multi-screen
environment the algorithm adds it in the first
available alternative screen that has the same
edge free
pull/1/head
Michail Vourlakos 8 years ago
parent 2078cb1cb2
commit 5eb63a3cbc

@ -1153,12 +1153,44 @@ void DockCorona::copyDock(Plasma::Containment *containment)
auto config = newContainment->config();
newContainment->restore(config);
QList<Plasma::Types::Location> edges = freeEdges(newContainment->screen());
if (edges.count() > 0) {
newContainment->setLocation(edges.at(0));
} else {
newContainment->setLocation(Plasma::Types::BottomEdge);
//in multi-screen environment the copied dock is moved to alternative screens first
const auto screens = qGuiApp->screens();
auto dock = m_dockViews[containment];
bool setOnExplicitScreen = false;
if (dock && screens.count() > 1) {
int dockScrId = m_screenPool->id(dock->currentScreen());
if (dockScrId != -1) {
foreach (auto scr, screens) {
int copyScrId = m_screenPool->id(scr->name());
//the screen must exist and not be the same with the original dock
if (copyScrId > -1 && copyScrId != dockScrId) {
QList<Plasma::Types::Location> fEdges = freeEdges(copyScrId);
if (fEdges.contains((Plasma::Types::Location)containment->location())) {
///set this containment to an explicit screen
newContainment->config().writeEntry("onPrimary", false);
newContainment->config().writeEntry("lastScreen", copyScrId);
setOnExplicitScreen = true;
}
}
}
}
}
if (!setOnExplicitScreen) {
QList<Plasma::Types::Location> edges = freeEdges(newContainment->screen());
if (edges.count() > 0) {
newContainment->setLocation(edges.at(0));
} else {
newContainment->setLocation(Plasma::Types::BottomEdge);
}
}
if (currentSession() != Dock::DefaultSession) {

Loading…
Cancel
Save