From 8427ce5b81e3887731d408b2f4460310c352827c Mon Sep 17 00:00:00 2001 From: Kris Moore Date: Sun, 7 Feb 2016 14:56:03 -0500 Subject: Further cleanup of updateDesktops(), fix spacing / indentation and change some logic which seems to fix up any remaining segfaults --- lumina-desktop/LSession.cpp | 89 ++++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 41 deletions(-) diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index c8cf2049..bf0059ab 100644 --- a/lumina-desktop/LSession.cpp +++ b/lumina-desktop/LSession.cpp @@ -20,7 +20,7 @@ #include //for usleep() usage #ifndef DEBUG -#define DEBUG 0 +#define DEBUG 1 #endif XCBEventFilter *evFilter = 0; @@ -483,59 +483,66 @@ void LSession::updateDesktops(){ qDebug() << " - Update Desktops"; QDesktopWidget *DW = this->desktop(); int sC = DW->screenCount(); - qDebug() << " -- Number:" << sC; + qDebug() << " Screen Count:" << sC; + qDebug() << " DESKTOPS Length:" << DESKTOPS.length(); if(sC<1){ return; } //stop here - no screens available temporarily (displayport/4K issue) for(int i=0; iscreenGeometry(i); } + bool firstrun = (DESKTOPS.length()==0); bool numchange = DESKTOPS.length()!=sC; - //qDebug() << " -- Desktop Flags:" << firstrun << numchange << DW->isVirtualDesktop(); - for(int i=0; iisVirtualDesktop(); + for(int i=0; iScreen()==i ){ found = true; } + for (int j=0; jScreen() == i ) { found = true; break; } } - if(!found){ + if(!found) { //Start the desktop on the new screen qDebug() << " - Start desktop on screen:" << i << DW->screenGeometry(i) << "Virtual:" << DW->isVirtualDesktop(); - DESKTOPS << new LDesktop(i); + DESKTOPS << new LDesktop(i); } - } - if(!firstrun){//Done right here on first run - //Now go through and make sure to delete any desktops for detached screens + } - if(DESKTOPS.length() < 1){ return; } - for(int i=0; iscreenGeometry(i); - if ( geom.isNull() ) - continue; - if ( geom.x() == 0 || geom.y() == 0 ) - continue; - - if(DESKTOPS[i]->Screen() >= sC){ - qDebug() << " - Close desktop on screen:" << DESKTOPS[i]->Screen(); - DESKTOPS[i]->prepareToClose(); - delete DESKTOPS.takeAt(i); - i--; - }else{ - qDebug() << " - Show desktop on screen:" << DESKTOPS[i]->Screen(); - DESKTOPS[i]->UpdateGeometry(); - DESKTOPS[i]->show(); - //QTimer::singleShot(0,DESKTOPS[i], SLOT(checkResolution())); - } - } - //Make sure fluxbox also gets prompted to re-load screen config if the number of screens changes - if(numchange){ - qDebug() << "Update WM"; - //QTimer::singleShot(1000,WM, SLOT(restartWM())); //Note: This causes crashes in X if a full-screen app - WM->updateWM(); + // If we only have one desktop, let's end here + if (DESKTOPS.length() <= 1) { + QTimer::singleShot(100,this, SLOT(registerDesktopWindows())); + return; + } + + // If this isn't the initial setup + if (!firstrun) { + + //Now go through and make sure to delete any desktops for detached screens + for (int i=1; iScreen() >= sC) { + qDebug() << " - Close desktop:" << i; + qDebug() << " - Close desktop on screen:" << DESKTOPS[i]->Screen(); + DESKTOPS[i]->prepareToClose(); + //delete DESKTOPS.takeAt(i); + DESKTOPS.removeAt(i); + i--; + } else { + qDebug() << " - Show desktop:" << i; + qDebug() << " - Show desktop on screen:" << DESKTOPS[i]->Screen(); + DESKTOPS[i]->UpdateGeometry(); + DESKTOPS[i]->show(); + //QTimer::singleShot(0,DESKTOPS[i], SLOT(checkResolution())); } } - //Make sure all the background windows are registered on the system as virtual roots - QTimer::singleShot(100,this, SLOT(registerDesktopWindows())); - //qDebug() << " - Done Checking Desktops"; + + //Make sure fluxbox also gets prompted to re-load screen config if the number of screens changes + if (numchange) { + qDebug() << "Update WM"; + //QTimer::singleShot(1000,WM, SLOT(restartWM())); //Note: This causes crashes in X if a full-screen app + WM->updateWM(); + } + } // End of !firstrun + + //Make sure all the background windows are registered on the system as virtual roots + QTimer::singleShot(100,this, SLOT(registerDesktopWindows())); + //qDebug() << " - Done Checking Desktops"; } void LSession::registerDesktopWindows(){ -- cgit