Commit 8522ef17 authored by Martin Flöser's avatar Martin Flöser

Do not hard runtime depend on X11 in RuleBook

Summary:
The RuleBook is created during Workspace startup, so it's a required
component for the overall KWin session. It uses a KXMessages object which
means it has a hard X11 runtime dependency.

This change makes the dependency optional and creates the KXMessages once
X11 is available.

Test Plan: Compiles

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7653
parent 95ae8dad
......@@ -955,9 +955,10 @@ RuleBook::RuleBook(QObject *parent)
: QObject(parent)
, m_updateTimer(new QTimer(this))
, m_updatesDisabled(false)
, m_temporaryRulesMessages(new KXMessages(connection(), rootWindow(), "_KDE_NET_WM_TEMPORARY_RULES", nullptr))
, m_temporaryRulesMessages()
{
connect(m_temporaryRulesMessages.data(), SIGNAL(gotMessage(QString)), SLOT(temporaryRulesMessage(QString)));
initWithX11();
connect(kwinApp(), &Application::x11ConnectionChanged, this, &RuleBook::initWithX11);
connect(m_updateTimer, SIGNAL(timeout()), SLOT(save()));
m_updateTimer->setInterval(1000);
m_updateTimer->setSingleShot(true);
......@@ -969,6 +970,17 @@ RuleBook::~RuleBook()
deleteAll();
}
void RuleBook::initWithX11()
{
auto c = kwinApp()->x11Connection();
if (!c) {
m_temporaryRulesMessages.reset();
return;
}
m_temporaryRulesMessages.reset(new KXMessages(c, kwinApp()->x11RootWindow(), "_KDE_NET_WM_TEMPORARY_RULES", nullptr));
connect(m_temporaryRulesMessages.data(), SIGNAL(gotMessage(QString)), SLOT(temporaryRulesMessage(QString)));
}
void RuleBook::deleteAll()
{
qDeleteAll(m_rules);
......
......@@ -306,6 +306,7 @@ private Q_SLOTS:
private:
void deleteAll();
void initWithX11();
QTimer *m_updateTimer;
bool m_updatesDisabled;
QList<Rules*> m_rules;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment