From 0365f5b0e1b0cccfd158297aa746190be4479e0c Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 1 Dec 2015 10:53:23 -0500 Subject: Adjust the main lumina-desktop session a bit: 1) Make it a single-instance process 2) Add a "--check-geoms" input flag which will have the desktop re-scan all monitor geometries and adjust as needed. 3) Adjust the monitor re-detection/adjustment routines a bit to ensure consisten functionality. --- lumina-desktop/LDesktop.cpp | 4 ++-- lumina-desktop/LSession.cpp | 44 ++++++++++++++++++-------------------------- lumina-desktop/LSession.h | 4 +++- lumina-desktop/main.cpp | 7 ++++--- 4 files changed, 27 insertions(+), 32 deletions(-) (limited to 'lumina-desktop') diff --git a/lumina-desktop/LDesktop.cpp b/lumina-desktop/LDesktop.cpp index 23e668cf..5771655b 100644 --- a/lumina-desktop/LDesktop.cpp +++ b/lumina-desktop/LDesktop.cpp @@ -84,7 +84,7 @@ QRect LDesktop::availableScreenGeom(){ void LDesktop::UpdateGeometry(){ //First make sure there is something different about the geometry - if(desktop->screenGeometry()==bgWindow->geometry()){ return; } + if(desktop->screenGeometry(desktopnumber)==bgWindow->geometry()){ return; } //Now update the screen // NOTE: This functionality is highly event-driven based on X changes - so we need to keep things in order (no signals/slots) qDebug() << "Changing Desktop Geom:" << desktopnumber; @@ -96,7 +96,7 @@ void LDesktop::UpdateGeometry(){ PANELS[i]->UpdatePanel(true); //only update geometry }*/ qDebug() << " - Done With Desktop Geom Updates"; - //QTimer::singleShot(0, this, SLOT(UpdatePanels())); + QTimer::singleShot(0, this, SLOT(UpdatePanels())); } void LDesktop::SystemLogout(){ diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index b7ccbbe5..995c442d 100644 --- a/lumina-desktop/LSession.cpp +++ b/lumina-desktop/LSession.cpp @@ -25,7 +25,9 @@ XCBEventFilter *evFilter = 0; -LSession::LSession(int &argc, char ** argv) : QApplication(argc, argv){ +LSession::LSession(int &argc, char ** argv) : LSingleApplication(argc, argv, "lumina-desktop"){ + if(this->isPrimaryProcess()){ + connect(this, SIGNAL(InputsAvailable(QStringList)), this, SLOT(NewCommunication(QStringList)) ); this->setApplicationName("Lumina Desktop Environment"); this->setApplicationVersion( LUtils::LuminaDesktopVersion() ); this->setOrganizationName("LuminaDesktopEnvironment"); @@ -61,9 +63,11 @@ LSession::LSession(int &argc, char ** argv) : QApplication(argc, argv){ //Setup the event filter for Qt5 evFilter = new XCBEventFilter(this); this->installNativeEventFilter( evFilter ); + } //end check for primary process } LSession::~LSession(){ + if(this->isPrimaryProcess()){ WM->stopWM(); for(int i=0; iscreenCount(); i++){ qDebug() << " -- Screen["+QString::number(i)+"]:" << DW->screenGeometry(i); } bool firstrun = (DESKTOPS.length()==0); bool numchange = DESKTOPS.length()!=DW->screenCount(); - //Determine if this is a temporary X screen reset (some full-screen apps modify the screens) - /*WId actWin = XCB->ActiveWindow(); - qDebug() << " -- Active Window:" << XCB->WindowClass(actWin); - //See if the current app is full-screen - int fscreen = -1; - if( XCB->WindowClass(actWin) != "Lumina Desktop Environment" ){ - fscreen = XCB->WindowIsFullscreen(actWin); - }*/ - qDebug() << " -- Desktop Flags:" << firstrun << numchange << DW->isVirtualDesktop(); - //Now go through and - //if(!firstrun){ savedScreens.clear(); } + //qDebug() << " -- Desktop Flags:" << firstrun << numchange << DW->isVirtualDesktop(); for(int i=0; iscreenCount(); i++){ - //if(!firstrun){ savedScreens << DW->screenGeometry(i); } bool found = false; for(int j=0; jScreen()==i || DW->screenGeometry(i)==DW->screenGeometry(DESKTOPS[j]->Screen()) ){ found = true; } if(DESKTOPS[j]->Screen()==i ){ found = true; } } if(!found){ //Start the desktop on the new screen qDebug() << " - Start desktop on screen:" << i << DW->screenGeometry(i) << "Virtual:" << DW->isVirtualDesktop(); - if(firstrun && DW->screenGeometry(i).x()==0){ - DESKTOPS << new LDesktop(i,true); //set this one as the default - }else{ DESKTOPS << new LDesktop(i); - } } } - //qDebug() << " - Done Starting Desktops"; - //return; //temporary stop for debugging if(!firstrun){//Done right here on first run //Now go through and make sure to delete any desktops for detached screens for(int i=0; iScreen()==fscreen){ - qDebug() << " - Hide desktop on screen:" << fscreen; - DESKTOPS[i]->hide(); - }else*/ if(DESKTOPS[i]->Screen() >= DW->screenCount()){ + if(DESKTOPS[i]->Screen() >= DW->screenCount()){ 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]->UpdateGeometry(); DESKTOPS[i]->show(); //QTimer::singleShot(0,DESKTOPS[i], SLOT(checkResolution())); } diff --git a/lumina-desktop/LSession.h b/lumina-desktop/LSession.h index 8147e411..ae217bd8 100644 --- a/lumina-desktop/LSession.h +++ b/lumina-desktop/LSession.h @@ -31,6 +31,7 @@ //#include "BootSplash.h" #include +#include //SYSTEM TRAY STANDARD DEFINITIONS #define SYSTEM_TRAY_REQUEST_DOCK 0 @@ -45,7 +46,7 @@ public: } };*/ -class LSession : public QApplication{ +class LSession : public LSingleApplication{ Q_OBJECT public: LSession(int &argc, char **argv); @@ -138,6 +139,7 @@ public slots: void reloadIconTheme(); private slots: + void NewCommunication(QStringList); void launchStartupApps(); //used during initialization void watcherChange(QString); void screensChanged(); diff --git a/lumina-desktop/main.cpp b/lumina-desktop/main.cpp index 1897fb2f..3602c10e 100644 --- a/lumina-desktop/main.cpp +++ b/lumina-desktop/main.cpp @@ -70,6 +70,10 @@ int main(int argc, char ** argv) setenv("DESKTOP_SESSION","Lumina",1); setenv("XDG_CURRENT_DESKTOP","Lumina",1); unsetenv("QT_QPA_PLATFORMTHEME"); //causes issues with Lumina themes - not many people have this by default... + //Startup the Application + if(DEBUG){ qDebug() << "Session Init:";} + LSession a(argc, argv); + if(!a.isPrimaryProcess()){ return 0; } //Setup the log file qDebug() << "Lumina Log File:" << logfile.fileName(); if(QFile::exists(logfile.fileName()+".old")){ QFile::remove(logfile.fileName()+".old"); } @@ -82,9 +86,6 @@ int main(int argc, char ** argv) logfile.open(QIODevice::WriteOnly | QIODevice::Append); QTime *timer=0; if(DEBUG){ timer = new QTime(); timer->start(); } - //Startup the Application - if(DEBUG){ qDebug() << "Session Init:" << timer->elapsed(); } - LSession a(argc, argv); //Setup Log File qInstallMessageHandler(MessageOutput); if(DEBUG){ qDebug() << "Theme Init:" << timer->elapsed(); } -- cgit