diff options
author | Ken Moore <ken@ixsystems.com> | 2018-09-06 17:59:57 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2018-09-06 17:59:57 -0400 |
commit | f1fce23e23d0a61ce588c5c089792a1e71dc0500 (patch) | |
tree | dd8fc110244fc6396f3a930ea4d0f7e022956f3f | |
parent | Checkpoint commit for some uncommitted changed to lumina-desktop-unified (diff) | |
download | lumina-f1fce23e23d0a61ce588c5c089792a1e71dc0500.tar.gz lumina-f1fce23e23d0a61ce588c5c089792a1e71dc0500.tar.bz2 lumina-f1fce23e23d0a61ce588c5c089792a1e71dc0500.zip |
Fix up the launching of the desktop session
1. Clear out the lockfiles for a session before launching it
2. Provide some mechanisms for returning lockfile paths without creating a new single-instance session.
3. A couple other random commits I still had staged on my laptop (settings menu tweak)
-rw-r--r-- | src-qt5/core/libLumina/LuminaSingleApplication.cpp | 29 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LuminaSingleApplication.h | 3 | ||||
-rw-r--r-- | src-qt5/core/lumina-desktop/SettingsMenu.cpp | 9 | ||||
-rw-r--r-- | src-qt5/core/lumina-session/lumina-session.pro | 1 | ||||
-rw-r--r-- | src-qt5/core/lumina-session/session.cpp | 7 | ||||
-rw-r--r-- | src-qt5/src-cpp/framework-OSInterface_private.cpp | 1 |
6 files changed, 37 insertions, 13 deletions
diff --git a/src-qt5/core/libLumina/LuminaSingleApplication.cpp b/src-qt5/core/libLumina/LuminaSingleApplication.cpp index 379ac02d..0c04229c 100644 --- a/src-qt5/core/libLumina/LuminaSingleApplication.cpp +++ b/src-qt5/core/libLumina/LuminaSingleApplication.cpp @@ -18,14 +18,7 @@ LSingleApplication::LSingleApplication(int &argc, char **argv, QString appname) this->setAttribute(Qt::AA_UseHighDpiPixmaps); if(appname!="lumina-desktop"){ cTrans = LUtils::LoadTranslation(this, appname); }//save the translator for later //Initialize a couple convenience internal variables - cfile = QDir::tempPath()+"/.LSingleApp-%1-%2-%3"; - QString username = QString::number(getuid()); - //For locking the process use the official process name - not the user input (no masking) - appname = this->applicationName(); - QString display = QString(getenv("DISPLAY")); - if(display.startsWith(":")){ display.remove(0,1); } - display = display.section(".",0,0); - cfile = cfile.arg( username, appname, display ); + cfile = getLockfileName(this->applicationName()); //do not allow masking the utility name lockfile = new QLockFile(cfile+"-lock"); lockfile->setStaleLockTime(0); //long-lived processes for(int i=1; i<argc; i++){ @@ -59,6 +52,26 @@ LSingleApplication::~LSingleApplication(){ } } +QString LSingleApplication::getLockfileName(QString appname){ + QString path = QDir::tempPath()+"/.LSingleApp-%1-%2-%3"; + QString username = QString::number(getuid()); + QString display = QString(getenv("DISPLAY")); + if(display.startsWith(":")){ display.remove(0,1); } + display = display.section(".",0,0); + path = path.arg( username, appname, display ); + return path; +} + +void LSingleApplication::removeLocks(QString appname){ + QString path = getLockfileName(appname); + if(QFile::exists(path+"-lock")){ + QFile::remove(path+"-lock"); + } + if(QFile::exists(path)){ + QFile::remove(path); + } +} + bool LSingleApplication::isPrimaryProcess(){ return (isActive || isBypass); } diff --git a/src-qt5/core/libLumina/LuminaSingleApplication.h b/src-qt5/core/libLumina/LuminaSingleApplication.h index bacf5640..f8302c0d 100644 --- a/src-qt5/core/libLumina/LuminaSingleApplication.h +++ b/src-qt5/core/libLumina/LuminaSingleApplication.h @@ -35,6 +35,9 @@ public: LSingleApplication(int &argc, char **argv, QString appname); ~LSingleApplication(); + static QString getLockfileName(QString appname); + static void removeLocks(QString appname); + bool isPrimaryProcess(); QStringList inputlist; //in case the app wants access to modified inputs (relative path fixes and such) diff --git a/src-qt5/core/lumina-desktop/SettingsMenu.cpp b/src-qt5/core/lumina-desktop/SettingsMenu.cpp index 58208931..ddea7f54 100644 --- a/src-qt5/core/lumina-desktop/SettingsMenu.cpp +++ b/src-qt5/core/lumina-desktop/SettingsMenu.cpp @@ -13,12 +13,12 @@ SettingsMenu::SettingsMenu() : QMenu(){ this->setObjectName("SettingsMenu"); connect(this, SIGNAL(triggered(QAction*)), this, SLOT(runApp(QAction*)) ); connect(QApplication::instance(), SIGNAL(LocaleChanged()), this, SLOT(UpdateMenu()) ); - connect(QApplication::instance(), SIGNAL(IconThemeChanged()), this, SLOT(UpdateMenu()) ); + connect(QApplication::instance(), SIGNAL(IconThemeChanged()), this, SLOT(UpdateMenu()) ); QTimer::singleShot(100, this, SLOT(UpdateMenu()) ); } SettingsMenu::~SettingsMenu(){ - + } void SettingsMenu::UpdateMenu(){ @@ -36,6 +36,9 @@ void SettingsMenu::UpdateMenu(){ act = new QAction( LXDG::findIcon("preferences-other",""), tr("Display"), this); act->setWhatsThis("lumina-xconfig"); this->addAction(act); + act = new QAction( LXDG::findIcon("preferences-desktop-theme",""), tr("Theme"), this); + act->setWhatsThis("lthemeengine"); + this->addAction(act); act = new QAction( LXDG::findIcon("preferences-desktop",""), tr("All Desktop Settings"), this); act->setWhatsThis("lumina-config"); this->addAction(act); @@ -58,7 +61,7 @@ void SettingsMenu::UpdateMenu(){ } act = new QAction( LXDG::findIcon("lumina",""), tr("About Lumina"), this); act->setWhatsThis("lumina-info"); - this->addAction(act); + this->addAction(act); } diff --git a/src-qt5/core/lumina-session/lumina-session.pro b/src-qt5/core/lumina-session/lumina-session.pro index 9d8e8f87..dee736cf 100644 --- a/src-qt5/core/lumina-session/lumina-session.pro +++ b/src-qt5/core/lumina-session/lumina-session.pro @@ -9,6 +9,7 @@ target.path = $${L_BINDIR} include(../libLumina/LDesktopUtils.pri) include(../libLumina/LuminaXDG.pri) include(../libLumina/LuminaThemes.pri) +include(../libLumina/LuminaSingleApplication.pri) SOURCES += main.cpp \ session.cpp diff --git a/src-qt5/core/lumina-session/session.cpp b/src-qt5/core/lumina-session/session.cpp index 0988e7ea..c4337c8e 100644 --- a/src-qt5/core/lumina-session/session.cpp +++ b/src-qt5/core/lumina-session/session.cpp @@ -16,6 +16,7 @@ #include <LUtils.h> #include <LuminaOS.h> #include <LDesktopUtils.h> +#include <LuminaSingleApplication.h> void LSession::stopall(){ stopping = true; @@ -193,13 +194,15 @@ void LSession::start(bool unified){ startProcess("wm", WM); } //Desktop Next - startProcess("runtime","lumina-desktop -new-instance"); + LSingleApplication::removeLocks("lumina-desktop"); + startProcess("runtime","lumina-desktop"); //ScreenSaver if(LUtils::isValidBinary("xscreensaver")){ startProcess("screensaver","xscreensaver -no-splash"); } }else{ //unified process setupCompositor(true); //required for Lumina 2 - startProcess("runtime","lumina-desktop-unified -new-instance"); + LSingleApplication::removeLocks("lumina-desktop-unified"); + startProcess("runtime","lumina-desktop-unified"); } } diff --git a/src-qt5/src-cpp/framework-OSInterface_private.cpp b/src-qt5/src-cpp/framework-OSInterface_private.cpp index b0a22b1d..a15626e9 100644 --- a/src-qt5/src-cpp/framework-OSInterface_private.cpp +++ b/src-qt5/src-cpp/framework-OSInterface_private.cpp @@ -305,6 +305,7 @@ void OSInterface::syncNetworkInfo(OSInterface *os, QHash<QString, QVariant> *has bool ok = false; for(int j=0; j<addressList.length() && !ok; j++){ if( addressList[j].ip().isLoopback() ){ continue; } + else if(addressList[i].ip().isEqual(QHostAddress(QHostAddress::LocalHost)) || addressList[i].ip().isEqual(QHostAddress::LocalHostIPv6) ){ continue; } addressList[j].ip().toIPv4Address(&ok); } if(ok){ active = netconfigL[i]; break; } //found a good one with a valid IPv4 |