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
This commit is contained in:
parent
95ae8dad1b
commit
8522ef17ee
2 changed files with 15 additions and 2 deletions
16
rules.cpp
16
rules.cpp
|
@ -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);
|
||||
|
|
1
rules.h
1
rules.h
|
@ -306,6 +306,7 @@ private Q_SLOTS:
|
|||
|
||||
private:
|
||||
void deleteAll();
|
||||
void initWithX11();
|
||||
QTimer *m_updateTimer;
|
||||
bool m_updatesDisabled;
|
||||
QList<Rules*> m_rules;
|
||||
|
|
Loading…
Reference in a new issue