Git commit 8522ef17eea0daf913eaaf0ee2c2d02d43c9d475 by Martin Fl=C3=B6ser. Committed on 10/09/2017 at 15:06. Pushed by graesslin into branch 'master'. 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 M +14 -2 rules.cpp M +1 -0 rules.h https://commits.kde.org/kwin/8522ef17eea0daf913eaaf0ee2c2d02d43c9d475 diff --git a/rules.cpp b/rules.cpp index 2883ec5c9..efeb107c0 100644 --- a/rules.cpp +++ b/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 =3D kwinApp()->x11Connection(); + if (!c) { + m_temporaryRulesMessages.reset(); + return; + } + m_temporaryRulesMessages.reset(new KXMessages(c, kwinApp()->x11RootWin= dow(), "_KDE_NET_WM_TEMPORARY_RULES", nullptr)); + connect(m_temporaryRulesMessages.data(), SIGNAL(gotMessage(QString)), = SLOT(temporaryRulesMessage(QString))); +} + void RuleBook::deleteAll() { qDeleteAll(m_rules); diff --git a/rules.h b/rules.h index 66e80c576..25044d861 100644 --- a/rules.h +++ b/rules.h @@ -306,6 +306,7 @@ private Q_SLOTS: = private: void deleteAll(); + void initWithX11(); QTimer *m_updateTimer; bool m_updatesDisabled; QList m_rules;