diff options
author | Ken Moore <ken@pcbsd.org> | 2015-02-17 13:33:47 -0500 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2015-02-17 13:33:47 -0500 |
commit | c2c6b5b3b20318eab442a4002e7521c98a7995d0 (patch) | |
tree | da242f5461e19944f2c5375d34bee4c84ad50014 | |
parent | Clean up some more debugging output from the LPanel class (make it switchable... (diff) | |
download | lumina-c2c6b5b3b20318eab442a4002e7521c98a7995d0.tar.gz lumina-c2c6b5b3b20318eab442a4002e7521c98a7995d0.tar.bz2 lumina-c2c6b5b3b20318eab442a4002e7521c98a7995d0.zip |
Clean up how the lumina-desktop closes down:
Now it is run through a "CleanSession" function beforehand to try and safely close down any applications/trays. Als reduce the number of filesystem watchers: only have one in the session itself, which sends out a signal when the desktop settings config file changes (instead of a watcher in every desktop class).
-rw-r--r-- | lumina-desktop/LDesktop.cpp | 8 | ||||
-rw-r--r-- | lumina-desktop/LDesktop.h | 2 | ||||
-rw-r--r-- | lumina-desktop/LSession.cpp | 86 | ||||
-rw-r--r-- | lumina-desktop/LSession.h | 6 | ||||
-rw-r--r-- | lumina-desktop/SystemWindow.cpp | 42 | ||||
-rw-r--r-- | lumina-desktop/SystemWindow.h | 41 |
6 files changed, 94 insertions, 91 deletions
diff --git a/lumina-desktop/LDesktop.cpp b/lumina-desktop/LDesktop.cpp index daf9b355..31baa48d 100644 --- a/lumina-desktop/LDesktop.cpp +++ b/lumina-desktop/LDesktop.cpp @@ -135,10 +135,10 @@ void LDesktop::InitDesktop(){ bgtimer = new QTimer(this); bgtimer->setSingleShot(true); connect(bgtimer, SIGNAL(timeout()), this, SLOT(UpdateBackground()) ); - watcher = new QFileSystemWatcher(this); - //connect(LSession::instance(), SIGNAL(DesktopConfigChanged()), this, SLOT(SettingsChanged()) ); - watcher->addPath(settings->fileName()); - connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(SettingsChanged()) ); + //watcher = new QFileSystemWatcher(this); + connect(QApplication::instance(), SIGNAL(DesktopConfigChanged()), this, SLOT(SettingsChanged()) ); + //watcher->addPath(settings->fileName()); + //connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(SettingsChanged()) ); if(DEBUG){ qDebug() << "Create bgWindow"; } bgWindow = new QWidget(); diff --git a/lumina-desktop/LDesktop.h b/lumina-desktop/LDesktop.h index 01a9a355..ef91110a 100644 --- a/lumina-desktop/LDesktop.h +++ b/lumina-desktop/LDesktop.h @@ -67,7 +67,7 @@ private: QLabel *workspacelabel; QWidgetAction *wkspaceact; QList<LDPlugin*> PLUGINS; - QFileSystemWatcher *watcher; + //QFileSystemWatcher *watcher; QString CBG; //current background QRect globalWorkRect; void CreateDesktopPluginContainer(LDPlugin*); diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index 91ecd98f..be8e5914 100644 --- a/lumina-desktop/LSession.cpp +++ b/lumina-desktop/LSession.cpp @@ -14,6 +14,8 @@ #include <LuminaX11.h> #include <LuminaUtils.h> +#include <unistd.h> //for usleep() usage + //X includes (these need to be last due to Qt compile issues) #include <X11/Xlib.h> #include <X11/Xutil.h> @@ -124,23 +126,34 @@ void LSession::setupSession(){ if(DEBUG){ qDebug() << " - Init Finished:" << timer->elapsed(); delete timer;} } -/*bool LSession::LoadLocale(QString langCode){ - QTranslator translator; - if ( ! QFile::exists(LOS::LuminaShare()+"i18n/lumina-desktop_" + langCode + ".qm" ) ) langCode.truncate(langCode.indexOf("_")); - bool ok = translator.load( QString("lumina-desktop_") + langCode, LOS::LuminaShare()+"i18n/" ); - if(ok){ - //Remove any old translator - if(currTranslator != 0){ this->removeTranslator(currTranslator); } - //Insert the new translator - currTranslator = &translator; - this->installTranslator( currTranslator ); - qDebug() << "Loaded Locale:" << langCode; - }else{ - qDebug() << "Invalid Locale:" << langCode; - } - emit LocaleChanged(); - return ok; -}*/ +void LSession::CleanupSession(){ + //Close any running applications and tray utilities (Make sure to keep the UI interactive) + LSession::processEvents(); + //Start the logout chimes (if necessary) + if( sessionsettings->value("PlayLogoutAudio",true).toBool() ){ + playAudioFile(LOS::LuminaShare()+"Logout.ogg"); + } + //Close any Tray Apps + for(int i=0; i<RunningTrayApps.length(); i++){ + LX11::CloseWindow(RunningTrayApps[i]); + LSession::processEvents(); + } + //Close any open windows + for(int i=0; i<RunningApps.length(); i++){ + LX11::CloseWindow(RunningApps[i]); + LSession::processEvents(); + } + + //Now wait a moment for things to close down before quitting + for(int i=0; i<20; i++){ LSession::processEvents(); usleep(25); } //1/2 second pause + + /*WL = LX11::WindowList(); + for(int i=0; i<WL.length(); i++){ + LX11::KillWindow(WL[i]); + LSession::processEvents(); + }*/ + LSession::processEvents(); +} void LSession::launchStartupApps(){ //First start any system-defined startups, then do user defined @@ -183,11 +196,28 @@ void LSession::launchStartupApps(){ } } +void LSession::StartLogout(){ + CleanupSession(); + QCoreApplication::exit(0); +} + +void LSession::StartShutdown(){ + CleanupSession(); + LOS::systemShutdown(); + QCoreApplication::exit(0); +} + +void LSession::StartReboot(){ + CleanupSession(); + LOS::systemRestart(); + QCoreApplication::exit(0); +} + void LSession::watcherChange(QString changed){ if(DEBUG){ qDebug() << "Session Watcher Change:" << changed; } if(changed.endsWith("fluxbox-init") || changed.endsWith("fluxbox-keys")){ refreshWindowManager(); } else if(changed.endsWith("sessionsettings.conf") ){ sessionsettings->sync(); emit SessionConfigChanged(); } - else{ emit DesktopConfigChanged(); } + else if(changed.endsWith("desktopsettings.conf") ){ emit DesktopConfigChanged(); } } void LSession::checkUserFiles(){ @@ -511,27 +541,9 @@ void LSession::attachTrayWindow(WId win){ if(TrayStopping){ return; } if(RunningTrayApps.contains(win)){ return; } //already managed RunningTrayApps << win; + LSession::restoreOverrideCursor(); if(DEBUG){ qDebug() << "Tray List Changed"; } emit TrayListChanged(); - /*//Now try to embed the window into the tray - //(NOT USED - Breaks visuals due to X11 graphics constraints - need to do embed in a single visual tray instead) - - qDebug() << "Attach Tray App:" << appnum; - WId cont = LX11::CreateWindow( SystemTrayID, QRect(appnum*64, 0, 64, 64) ); - if( LX11::EmbedWindow(win, cont) ){ - appnum++; - //Successful embed, now set it up for damage report notifications - XDamageCreate( QX11Info::display(), win, XDamageReportRawRectangles ); - //LX11::ResizeWindow(win, 64, 64); //Always use 64x64 if possible (can shrink, not expand later) - LX11::RestoreWindow(win); - //Add it to the tray list - RunningTrayApps << win; - TrayAppContainers << cont; - //Emit that the list has changed - emit TrayListChanged(); - }else{ - LX11::DestroyWindow(cont); //clean up - }*/ } void LSession::removeTrayWindow(WId win){ diff --git a/lumina-desktop/LSession.h b/lumina-desktop/LSession.h index 03a4b397..6ad4ac90 100644 --- a/lumina-desktop/LSession.h +++ b/lumina-desktop/LSession.h @@ -109,9 +109,13 @@ private: //Task Manager Variables QList<WId> RunningApps; + void CleanupSession(); + public slots: void launchStartupApps(); - + void StartLogout(); + void StartShutdown(); + void StartReboot(); private slots: void watcherChange(QString); diff --git a/lumina-desktop/SystemWindow.cpp b/lumina-desktop/SystemWindow.cpp index 15268e0b..0540a5d9 100644 --- a/lumina-desktop/SystemWindow.cpp +++ b/lumina-desktop/SystemWindow.cpp @@ -3,9 +3,11 @@ #include "LSession.h" #include <LuminaOS.h> -#include <unistd.h> //for usleep() usage #include <QPoint> #include <QCursor> +#include <QDebug> +#include <QProcess> +#include <QDesktopWidget> SystemWindow::SystemWindow() : QDialog(), ui(new Ui::SystemWindow){ ui->setupUi(this); //load the designer file @@ -38,23 +40,23 @@ SystemWindow::~SystemWindow(){ } -void SystemWindow::closeAllWindows(){ - this->hide(); - LSession::processEvents(); - if( LSession::handle()->sessionSettings()->value("PlayLogoutAudio",true).toBool() ){ - LSession::handle()->playAudioFile(LOS::LuminaShare()+"Logout.ogg"); - } - QList<WId> WL = LX11::WindowList(); - for(int i=0; i<WL.length(); i++){ - LX11::CloseWindow(WL[i]); - LSession::processEvents(); - } - //Now go through the list again and kill any remaining windows - usleep(60); //60 ms pause - WL = LX11::WindowList(); - for(int i=0; i<WL.length(); i++){ - LX11::KillWindow(WL[i]); - LSession::processEvents(); - } - LSession::processEvents(); +void SystemWindow::sysLogout(){ + QTimer::singleShot(0, LSession::handle(), SLOT(StartLogout()) ); + this->close(); +} + +void SystemWindow::sysRestart(){ + QTimer::singleShot(0, LSession::handle(), SLOT(StartReboot()) ); + this->close(); +} + +void SystemWindow::sysShutdown(){ + QTimer::singleShot(0, LSession::handle(), SLOT(StartShutdown()) ); + this->close(); +} + +void SystemWindow::sysLock(){ + qDebug() << "Locking the desktop..."; + QProcess::startDetached("xscreensaver-command -lock"); + this->close(); } diff --git a/lumina-desktop/SystemWindow.h b/lumina-desktop/SystemWindow.h index 3be8642e..211de5fd 100644 --- a/lumina-desktop/SystemWindow.h +++ b/lumina-desktop/SystemWindow.h @@ -2,17 +2,17 @@ #define _LUMINA_DESKTOP_SYSTEM_WINDOW_H #include <QDialog> -#include <QCoreApplication> -#include <QDesktopWidget> -#include <QList> -#include <QProcess> +//#include <QCoreApplication> + +//#include <QList> +//#include <QProcess> #include "ui_SystemWindow.h" -#include "Globals.h" +//#include "Globals.h" -#include <LuminaXDG.h> -#include <LuminaX11.h> -#include <LuminaOS.h> +//#include <LuminaXDG.h> +//#include <LuminaX11.h> +//#include <LuminaOS.h> @@ -29,35 +29,20 @@ public: private: Ui::SystemWindow *ui; - void closeAllWindows(); + //void closeAllWindows(); private slots: - void sysLogout(){ - closeAllWindows(); - QCoreApplication::exit(0); - } + void sysLogout(); - void sysRestart(){ - closeAllWindows(); - LOS::systemRestart(); - QCoreApplication::exit(0); - } + void sysRestart(); - void sysShutdown(){ - closeAllWindows(); - LOS::systemShutdown(); - QCoreApplication::exit(0); - } + void sysShutdown(); void sysCancel(){ this->close(); } - void sysLock(){ - qDebug() << "Locking the desktop..."; - QProcess::startDetached("xscreensaver-command -lock"); - this->close(); - } + void sysLock(); }; #endif
\ No newline at end of file |