From 73e9d69e1ce4f68ab541c63f0a0d756cc44642cc Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 18 May 2017 15:46:10 -0400 Subject: Add the ability to scan/migrate desktop/panel settings from one monitor ID to another on the first start of the desktop, and enable that migration for single-monitor arrangements. --- src-qt5/core/lumina-desktop/LSession.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src-qt5/core/lumina-desktop/LSession.cpp') diff --git a/src-qt5/core/lumina-desktop/LSession.cpp b/src-qt5/core/lumina-desktop/LSession.cpp index 735390aa..8932ac36 100644 --- a/src-qt5/core/lumina-desktop/LSession.cpp +++ b/src-qt5/core/lumina-desktop/LSession.cpp @@ -403,6 +403,25 @@ void LSession::updateDesktops(){ bool firstrun = (DESKTOPS.length()==0); bool numchange = DESKTOPS.length()!=sC; + QSettings dset("lumina-desktop", "desktopsettings"); + if(firstrun && sC==1){ + //Sanity check - ensure the monitor ID did not change between sessions for single-monitor setups + QString name = QApplication::screens().at(0)->name(); + if(!dset.contains("desktop-"+name+"/screen/lastHeight")){ + //Empty Screen - find the previous one and migrate the settings over + QStringList old = dset.allKeys().filter("desktop-").filter("/screen/lastHeight"); + QStringList lastused = dset.value("last_used_screens").toStringList(); + QString oldname; + for(int i=0; iscreenCount() ) { @@ -431,7 +450,10 @@ void LSession::updateDesktops(){ } //Now add any new desktops + QStringList allNames; + QList scrns = QApplication::screens(); for(int i=0; iname(); if(!dnums.contains(i) && !geoms.contains(DW->screenGeometry(i)) ){ //Start the desktop on this screen qDebug() << " - Start desktop on screen:" << i; @@ -439,7 +461,7 @@ void LSession::updateDesktops(){ geoms << DW->screenGeometry(i); } } - + dset.setValue("last_used_screens", allNames); //Make sure fluxbox also gets prompted to re-load screen config if the number of screens changes in the middle of a session if(numchange && !firstrun) { qDebug() << "Update WM"; @@ -449,7 +471,6 @@ void LSession::updateDesktops(){ //Make sure all the background windows are registered on the system as virtual roots QTimer::singleShot(100,this, SLOT(registerDesktopWindows())); //Determine if any High-DPI screens are available and enable auto-scaling as needed - QList scrns = QApplication::screens(); for(int i=0; iname(); qDebug() << " -- Physical DPI:" << scrns[i]->physicalDotsPerInchX() << "x" << scrns[i]->physicalDotsPerInchY(); -- cgit