aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/core')
-rw-r--r--src-qt5/core/lumina-session/lumina-session.pro3
-rw-r--r--src-qt5/core/lumina-session/session.cpp75
-rw-r--r--src-qt5/core/lumina-session/session.h62
3 files changed, 83 insertions, 57 deletions
diff --git a/src-qt5/core/lumina-session/lumina-session.pro b/src-qt5/core/lumina-session/lumina-session.pro
index e9a6c319..91ef5ed0 100644
--- a/src-qt5/core/lumina-session/lumina-session.pro
+++ b/src-qt5/core/lumina-session/lumina-session.pro
@@ -10,7 +10,8 @@ target.path = $${L_BINDIR}
LIBS += -lLuminaUtils -lxcb -lxcb-damage
DEPENDPATH += ../libLumina
-SOURCES += main.cpp
+SOURCES += main.cpp \
+ session.cpp
HEADERS += session.h
diff --git a/src-qt5/core/lumina-session/session.cpp b/src-qt5/core/lumina-session/session.cpp
new file mode 100644
index 00000000..0e8f80ae
--- /dev/null
+++ b/src-qt5/core/lumina-session/session.cpp
@@ -0,0 +1,75 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2016, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#include "session.h"
+
+#include <QObject>
+#include <QProcess>
+#include <QProcessEnvironment>
+#include <QDebug>
+#include <LuminaUtils.h>
+
+
+void LSession::stopall(){
+ stopping = true;
+ for(int i=0; i<PROCS.length(); i++){
+ if(PROCS[i]->state()!=QProcess::NotRunning){ PROCS[i]->kill(); }
+ }
+ QCoreApplication::processEvents();
+ for(int i=0; i<PROCS.length(); i++){
+ if(PROCS[i]->state()!=QProcess::NotRunning){ PROCS[i]->terminate(); }
+ }
+ //QCoreApplication::exit(0);
+}
+
+void LSession::procFinished(){
+ //Go through and check the status on all the procs to determine which one finished
+ int stopped = 0;
+ for(int i=0; i<PROCS.length(); i++){
+ if(PROCS[i]->state()==QProcess::NotRunning){
+ stopped++;
+ if(!stopping){
+ //See if this process is the main desktop binary
+ if(PROCS[i]->program().section("/",-1) == "Lumina-DE"){ stopall(); } //start closing down everything
+ //else{ PROCS[i]->start(QIODevice::ReadOnly); } //restart the process
+ break;
+ }
+ }
+ }
+ if(stopping && stopped==PROCS.length()){
+ QCoreApplication::exit(0);
+ }
+}
+
+void LSession::startProcess(QString ID, QString command){
+ QString logfile = QDir::homePath()+"/.lumina/logs/"+ID+".log";
+ if(QFile::exists(logfile+".old")){ QFile::remove(logfile+".old"); }
+ if(QFile::exists(logfile)){ QFile::rename(logfile,logfile+".old"); }
+ QProcess *proc = new QProcess();
+ proc->setProcessChannelMode(QProcess::MergedChannels);
+ proc->setProcessEnvironment( QProcessEnvironment::systemEnvironment() );
+ proc->setStandardOutputFile(logfile);
+ proc->start(command, QIODevice::ReadOnly);
+ connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(procFinished()) );
+ PROCS << proc;
+}
+
+void LSession::start(){
+ //First check for a valid installation
+ if( !LUtils::isValidBinary("fluxbox") || !LUtils::isValidBinary("Lumina-DE") ){
+ exit(1);
+ }
+ //Window Manager First
+ // FLUXBOX BUG BYPASS: if the ~/.fluxbox dir does not exist, it will ignore the given config file
+ //if(!QFile::exists(QDir::homePath()+"/.fluxbox")){ QDir dir; dir.mkpath(QDir::homePath()+"/.fluxbox"); }
+ //startProcess("wm", "fluxbox -rc "+QDir::homePath()+"/.lumina/fluxbox-init -no-slit -no-toolbar");
+ //Desktop Next
+ startProcess("runtime","Lumina-DE");
+ //ScreenSaver
+ if(LUtils::isValidBinary("xscreensaver")){ startProcess("screensaver","xscreensaver -no-splash"); }
+ //Compositing manager
+ if(LUtils::isValidBinary("xcompmgr")){ startProcess("compositing","xcompmgr"); }
+}
diff --git a/src-qt5/core/lumina-session/session.h b/src-qt5/core/lumina-session/session.h
index 7e5f1deb..5bd5d44a 100644
--- a/src-qt5/core/lumina-session/session.h
+++ b/src-qt5/core/lumina-session/session.h
@@ -6,54 +6,19 @@
//===========================================
#include <QObject>
#include <QProcess>
-#include <QProcessEnvironment>
-
-#include <LuminaUtils.h>
class LSession : public QObject{
+ Q_OBJECT
private:
QList<QProcess*> PROCS;
bool stopping;
- void startProcess(QString ID, QString command){
- QString logfile = QDir::homePath()+"/.lumina/logs/"+ID+".log";
- if(QFile::exists(logfile+".old")){ QFile::remove(logfile+".old"); }
- if(QFile::exists(logfile)){ QFile::rename(logfile,logfile+".old"); }
- QProcess *proc = new QProcess();
- proc->setProcessChannelMode(QProcess::MergedChannels);
- proc->setProcessEnvironment( QProcessEnvironment::systemEnvironment() );
- proc->setStandardOutputFile(logfile);
- proc->start(command, QIODevice::ReadOnly);
- connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(procFinished()) );
- PROCS << proc;
- }
-
private slots:
- void stopall(){
- stopping = true;
- for(int i=0; i<PROCS.length(); i++){
- if(PROCS[i]->state()!=QProcess::NotRunning){ PROCS[i]->kill(); }
- }
- }
+ void stopall();
- void procFinished(){
- //Go through and check the status on all the procs to determine which one finished
- int stopped = 0;
- for(int i=0; i<PROCS.length(); i++){
- if(PROCS[i]->state()==QProcess::NotRunning){
- stopped++;
- if(!stopping){
- //See if this process is the main desktop binary
- if(PROCS[i]->program().section("/",-1) == "Lumina-DE"){ stopall(); } //start closing down everything
- //else{ PROCS[i]->start(QIODevice::ReadOnly); } //restart the process
- break;
- }
- }
- }
- if(stopping && stopped==PROCS.length()){
- QCoreApplication::exit(0);
- }
- }
+ void procFinished();
+
+ void startProcess(QString ID, QString command);
public:
LSession(){
@@ -61,21 +26,6 @@ public:
}
~LSession(){ }
- void start(){
- //First check for a valid installation
- if( !LUtils::isValidBinary("fluxbox") || !LUtils::isValidBinary("Lumina-DE") ){
- exit(1);
- }
- //Window Manager First
- // FLUXBOX BUG BYPASS: if the ~/.fluxbox dir does not exist, it will ignore the given config file
- //if(!QFile::exists(QDir::homePath()+"/.fluxbox")){ QDir dir; dir.mkpath(QDir::homePath()+"/.fluxbox"); }
- //startProcess("wm", "fluxbox -rc "+QDir::homePath()+"/.lumina/fluxbox-init -no-slit -no-toolbar");
- //Desktop Next
- startProcess("runtime","Lumina-DE");
- //ScreenSaver
- if(LUtils::isValidBinary("xscreensaver")){ startProcess("screensaver","xscreensaver -no-splash"); }
- //Compositing manager
- if(LUtils::isValidBinary("xcompmgr")){ startProcess("compositing","xcompmgr"); }
- }
+ void start();
};
bgstack15