diff options
Diffstat (limited to 'lumina-desktop/LSession.cpp')
-rw-r--r-- | lumina-desktop/LSession.cpp | 89 |
1 files 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 <unistd.h> //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; i<sC; i++){ qDebug() << " -- Screen["+QString::number(i)+"]:" << DW->screenGeometry(i); } + bool firstrun = (DESKTOPS.length()==0); bool numchange = DESKTOPS.length()!=sC; - //qDebug() << " -- Desktop Flags:" << firstrun << numchange << DW->isVirtualDesktop(); - for(int i=0; i<sC; i++){ + + //qDebug() << " -- Desktop Flags:" << firstrun << numchange << DW->isVirtualDesktop(); + for(int i=0; i<sC; i++){ bool found = false; - for(int j=0; j<DESKTOPS.length() && !found; j++){ - if(DESKTOPS[j]->Screen()==i ){ found = true; } + for (int j=0; j<DESKTOPS.length() && !found; j++) { + if( DESKTOPS[j]->Screen() == 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; i<DESKTOPS.length(); i++){ - - // Check for 0x0 screen geom - QRect geom = DW->screenGeometry(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; i<DESKTOPS.length(); i++){ + if (DESKTOPS[i]->Screen() >= 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(){ |