mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
plasma: implement option to disable session management
I have idea about adding one more option but not sure if I should, the idea is to restart applications even if not registered for session management since klauncher tracks applications anyway. which applications are restarted then becomes limited to what klauncher starts tho Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
d30570a6e3
commit
e7f9852d5f
4 changed files with 67 additions and 11 deletions
|
@ -95,7 +95,27 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="sessionManagementLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Session Management:</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="4" column="1">
|
||||||
|
<widget class="QCheckBox" name="sessionManagement">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
|
|
|
@ -66,11 +66,13 @@ WorkspaceOptionsModule::WorkspaceOptionsModule(QWidget *parent, const QVariantLi
|
||||||
connect(m_ui->cacheTheme, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
connect(m_ui->cacheTheme, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
||||||
connect(m_ui->cacheTheme, SIGNAL(toggled(bool)), this, SLOT(cacheThemeChanged(bool)));
|
connect(m_ui->cacheTheme, SIGNAL(toggled(bool)), this, SLOT(cacheThemeChanged(bool)));
|
||||||
connect(m_ui->themeCacheSize, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
connect(m_ui->themeCacheSize, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||||
|
connect(m_ui->sessionManagement, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
||||||
|
|
||||||
if (!m_plasmaFound) {
|
if (!m_plasmaFound) {
|
||||||
m_ui->formFactor->setEnabled(false);
|
m_ui->formFactor->setEnabled(false);
|
||||||
m_ui->cacheTheme->setEnabled(false);
|
m_ui->cacheTheme->setEnabled(false);
|
||||||
m_ui->themeCacheSize->setEnabled(false);
|
m_ui->themeCacheSize->setEnabled(false);
|
||||||
|
m_ui->sessionManagement->setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,6 +90,8 @@ void WorkspaceOptionsModule::save()
|
||||||
KConfigGroup cg2(&config, "CachePolicies");
|
KConfigGroup cg2(&config, "CachePolicies");
|
||||||
cg2.writeEntry("CacheTheme", m_ui->cacheTheme->isChecked());
|
cg2.writeEntry("CacheTheme", m_ui->cacheTheme->isChecked());
|
||||||
cg2.writeEntry("ThemeCacheKb", m_ui->themeCacheSize->value() * 1024);
|
cg2.writeEntry("ThemeCacheKb", m_ui->themeCacheSize->value() * 1024);
|
||||||
|
KConfigGroup cg3(&config, "General");
|
||||||
|
cg3.writeEntry("SessionManagement", m_ui->sessionManagement->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool isDesktop = (m_ui->formFactor->currentIndex() == 0);
|
const bool isDesktop = (m_ui->formFactor->currentIndex() == 0);
|
||||||
|
@ -160,6 +164,8 @@ void WorkspaceOptionsModule::load()
|
||||||
m_ui->cacheTheme->setChecked(cg2.readEntry("CacheTheme", true));
|
m_ui->cacheTheme->setChecked(cg2.readEntry("CacheTheme", true));
|
||||||
const int themeCacheKb = cg2.readEntry("ThemeCacheKb", 81920);
|
const int themeCacheKb = cg2.readEntry("ThemeCacheKb", 81920);
|
||||||
m_ui->themeCacheSize->setValue(themeCacheKb / 1024);
|
m_ui->themeCacheSize->setValue(themeCacheKb / 1024);
|
||||||
|
KConfigGroup cg3(&config, "General");
|
||||||
|
m_ui->sessionManagement->setChecked(cg3.readEntry("SessionManagement", true));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorkspaceOptionsModule::defaults()
|
void WorkspaceOptionsModule::defaults()
|
||||||
|
|
|
@ -72,6 +72,7 @@
|
||||||
|
|
||||||
static const int s_sessiondelay = 500; // ms
|
static const int s_sessiondelay = 500; // ms
|
||||||
static const int s_phasetimeout = 10000; // ms
|
static const int s_phasetimeout = 10000; // ms
|
||||||
|
static const bool s_defaultsm = true;
|
||||||
static const QString s_defaultwm = QString::fromLatin1("kwin");
|
static const QString s_defaultwm = QString::fromLatin1("kwin");
|
||||||
static const QStringList s_defaultwmcommands = QStringList() << s_defaultwm;
|
static const QStringList s_defaultwmcommands = QStringList() << s_defaultwm;
|
||||||
|
|
||||||
|
@ -123,7 +124,9 @@ PlasmaApp::PlasmaApp()
|
||||||
m_logoutAfterStartup(false),
|
m_logoutAfterStartup(false),
|
||||||
m_confirm(0),
|
m_confirm(0),
|
||||||
m_sdtype(KWorkSpace::ShutdownTypeNone),
|
m_sdtype(KWorkSpace::ShutdownTypeNone),
|
||||||
m_sessionManager(false)
|
m_failSafe(false),
|
||||||
|
m_sessionManager(false),
|
||||||
|
m_dirWatch(nullptr)
|
||||||
{
|
{
|
||||||
KGlobal::locale()->insertCatalog("libplasma");
|
KGlobal::locale()->insertCatalog("libplasma");
|
||||||
KGlobal::locale()->insertCatalog("plasmagenericshell");
|
KGlobal::locale()->insertCatalog("plasmagenericshell");
|
||||||
|
@ -268,6 +271,13 @@ void PlasmaApp::setupDesktop()
|
||||||
|
|
||||||
void PlasmaApp::setupSession()
|
void PlasmaApp::setupSession()
|
||||||
{
|
{
|
||||||
|
if (!m_failSafe) {
|
||||||
|
m_dirWatch = new KDirWatch(this);
|
||||||
|
m_dirWatch->setInterval(5000);
|
||||||
|
m_dirWatch->addFile(KGlobal::dirs()->saveLocation("config") + QLatin1String("plasmarc"));
|
||||||
|
connect(m_dirWatch, SIGNAL(dirty(QString)), this, SLOT(configDirty()));
|
||||||
|
}
|
||||||
|
|
||||||
m_phaseTimer = new QTimer(this);
|
m_phaseTimer = new QTimer(this);
|
||||||
m_phaseTimer->setInterval(500);
|
m_phaseTimer->setInterval(500);
|
||||||
connect(m_phaseTimer, SIGNAL(timeout()), this, SLOT(nextPhase()));
|
connect(m_phaseTimer, SIGNAL(timeout()), this, SLOT(nextPhase()));
|
||||||
|
@ -287,9 +297,11 @@ void PlasmaApp::setupSession()
|
||||||
sessionBus,
|
sessionBus,
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
const bool failsafe = (qgetenv("KDE_FAILSAFE").toInt() == 1);
|
m_failSafe = (qgetenv("KDE_FAILSAFE").toInt() == 1);
|
||||||
if (!failsafe) {
|
KConfig cfg("plasmarc", KConfig::NoGlobals);
|
||||||
m_sessionManager = true;
|
KConfigGroup config(&cfg, "General");
|
||||||
|
if (!m_failSafe) {
|
||||||
|
m_sessionManager = config.readEntry("SessionManagement", s_defaultsm);
|
||||||
connect(
|
connect(
|
||||||
sessionBus.interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString)),
|
sessionBus.interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString)),
|
||||||
this, SLOT(serviceOwnerChanged(QString,QString,QString))
|
this, SLOT(serviceOwnerChanged(QString,QString,QString))
|
||||||
|
@ -299,9 +311,7 @@ void PlasmaApp::setupSession()
|
||||||
KGlobal::dirs()->addResourceType("windowmanagers", "data", "plasma/windowmanagers");
|
KGlobal::dirs()->addResourceType("windowmanagers", "data", "plasma/windowmanagers");
|
||||||
|
|
||||||
QStringList wmcommands;
|
QStringList wmcommands;
|
||||||
if (!failsafe) {
|
if (!m_failSafe) {
|
||||||
KConfig cfg("plasmarc", KConfig::NoGlobals);
|
|
||||||
KConfigGroup config(&cfg, "General");
|
|
||||||
const QString wmname = config.readEntry("windowManager", s_defaultwm);
|
const QString wmname = config.readEntry("windowManager", s_defaultwm);
|
||||||
if (wmname != s_defaultwm) {
|
if (wmname != s_defaultwm) {
|
||||||
KDesktopFile wmfile("windowmanagers", wmname + ".desktop");
|
KDesktopFile wmfile("windowmanagers", wmname + ".desktop");
|
||||||
|
@ -330,10 +340,18 @@ void PlasmaApp::setupSession()
|
||||||
clientgroup.deleteGroup();
|
clientgroup.deleteGroup();
|
||||||
clientgroup.sync();
|
clientgroup.sync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_wmProc = new QProcess(this);
|
m_wmProc = new QProcess(this);
|
||||||
m_wmProc->start(wmprog, wmcommands);
|
m_wmProc->start(wmprog, wmcommands);
|
||||||
|
|
||||||
|
if (!m_failSafe && !m_sessionManager) {
|
||||||
|
kDebug() << "deleting previous session";
|
||||||
|
// make sure when session management is enabled again it is a fresh start even if KDirWatch
|
||||||
|
// did not had the time to detect the changes done to the config
|
||||||
|
sessiongroup.deleteGroup();
|
||||||
|
sessiongroup.sync();
|
||||||
|
}
|
||||||
|
|
||||||
m_phaseTimer->start();
|
m_phaseTimer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,14 +364,14 @@ void PlasmaApp::panelHidden(bool hidden)
|
||||||
{
|
{
|
||||||
if (hidden) {
|
if (hidden) {
|
||||||
++m_panelHidden;
|
++m_panelHidden;
|
||||||
//kDebug() << "panel hidden" << m_panelHidden;
|
// kDebug() << "panel hidden" << m_panelHidden;
|
||||||
} else {
|
} else {
|
||||||
--m_panelHidden;
|
--m_panelHidden;
|
||||||
if (m_panelHidden < 0) {
|
if (m_panelHidden < 0) {
|
||||||
kDebug() << "panelHidden(false) called too many times!";
|
kDebug() << "panelHidden(false) called too many times!";
|
||||||
m_panelHidden = 0;
|
m_panelHidden = 0;
|
||||||
}
|
}
|
||||||
//kDebug() << "panel unhidden" << m_panelHidden;
|
// kDebug() << "panel unhidden" << m_panelHidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,7 +506,7 @@ bool PlasmaApp::x11EventFilter(XEvent *event)
|
||||||
} else if (event->type == EnterNotify) {
|
} else if (event->type == EnterNotify) {
|
||||||
panel->hintOrUnhide(QPoint(-1, -1));
|
panel->hintOrUnhide(QPoint(-1, -1));
|
||||||
//kDebug() << "entry";
|
//kDebug() << "entry";
|
||||||
//FIXME: this if it was possible to avoid the polling
|
// FIXME: this if it was possible to avoid the polling
|
||||||
/*} else if (event->type == LeaveNotify) {
|
/*} else if (event->type == LeaveNotify) {
|
||||||
panel->unhintHide();
|
panel->unhintHide();
|
||||||
*/
|
*/
|
||||||
|
@ -1128,6 +1146,14 @@ void PlasmaApp::serviceOwnerChanged(const QString &name, const QString &oldOwner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlasmaApp::configDirty()
|
||||||
|
{
|
||||||
|
KConfig cfg("plasmarc", KConfig::NoGlobals);
|
||||||
|
KConfigGroup config(&cfg, "General");
|
||||||
|
m_sessionManager = config.readEntry("SessionManagement", s_defaultsm);
|
||||||
|
kDebug() << "plasmarc dirty" << m_sessionManager;
|
||||||
|
}
|
||||||
|
|
||||||
void PlasmaApp::suspendStartup(const QString &app)
|
void PlasmaApp::suspendStartup(const QString &app)
|
||||||
{
|
{
|
||||||
m_startupSuspend++;
|
m_startupSuspend++;
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include <KUniqueApplication>
|
#include <KUniqueApplication>
|
||||||
#include <KActionCollection>
|
#include <KActionCollection>
|
||||||
|
#include <KDirWatch>
|
||||||
#include <Plasma/Plasma>
|
#include <Plasma/Plasma>
|
||||||
#include <plasma/packagemetadata.h>
|
#include <plasma/packagemetadata.h>
|
||||||
|
|
||||||
|
@ -150,6 +151,7 @@ private Q_SLOTS:
|
||||||
void clientSaved();
|
void clientSaved();
|
||||||
void clientSaveCanceled();
|
void clientSaveCanceled();
|
||||||
void serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner);
|
void serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner);
|
||||||
|
void configDirty();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KActionCollection* m_actionCollection;
|
KActionCollection* m_actionCollection;
|
||||||
|
@ -180,7 +182,9 @@ private:
|
||||||
bool m_logoutAfterStartup;
|
bool m_logoutAfterStartup;
|
||||||
int m_confirm;
|
int m_confirm;
|
||||||
KWorkSpace::ShutdownType m_sdtype;
|
KWorkSpace::ShutdownType m_sdtype;
|
||||||
|
bool m_failSafe;
|
||||||
bool m_sessionManager;
|
bool m_sessionManager;
|
||||||
|
KDirWatch* m_dirWatch;
|
||||||
QList<org::kde::KApplication*> m_clients;
|
QList<org::kde::KApplication*> m_clients;
|
||||||
QList<org::kde::KApplication*> m_saveQueue;
|
QList<org::kde::KApplication*> m_saveQueue;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue