Changeset View
Changeset View
Standalone View
Standalone View
rules.cpp
Show First 20 Lines • Show All 949 Lines • ▼ Show 20 Line(s) | |||||
950 | 950 | | |||
951 | // Workspace | 951 | // Workspace | ||
952 | KWIN_SINGLETON_FACTORY(RuleBook) | 952 | KWIN_SINGLETON_FACTORY(RuleBook) | ||
953 | 953 | | |||
954 | RuleBook::RuleBook(QObject *parent) | 954 | RuleBook::RuleBook(QObject *parent) | ||
955 | : QObject(parent) | 955 | : QObject(parent) | ||
956 | , m_updateTimer(new QTimer(this)) | 956 | , m_updateTimer(new QTimer(this)) | ||
957 | , m_updatesDisabled(false) | 957 | , m_updatesDisabled(false) | ||
958 | , m_temporaryRulesMessages(new KXMessages(connection(), rootWindow(), "_KDE_NET_WM_TEMPORARY_RULES", nullptr)) | 958 | , m_temporaryRulesMessages() | ||
959 | { | 959 | { | ||
960 | connect(m_temporaryRulesMessages.data(), SIGNAL(gotMessage(QString)), SLOT(temporaryRulesMessage(QString))); | 960 | initWithX11(); | ||
961 | connect(kwinApp(), &Application::x11ConnectionChanged, this, &RuleBook::initWithX11); | ||||
961 | connect(m_updateTimer, SIGNAL(timeout()), SLOT(save())); | 962 | connect(m_updateTimer, SIGNAL(timeout()), SLOT(save())); | ||
962 | m_updateTimer->setInterval(1000); | 963 | m_updateTimer->setInterval(1000); | ||
963 | m_updateTimer->setSingleShot(true); | 964 | m_updateTimer->setSingleShot(true); | ||
964 | } | 965 | } | ||
965 | 966 | | |||
966 | RuleBook::~RuleBook() | 967 | RuleBook::~RuleBook() | ||
967 | { | 968 | { | ||
968 | save(); | 969 | save(); | ||
969 | deleteAll(); | 970 | deleteAll(); | ||
970 | } | 971 | } | ||
971 | 972 | | |||
973 | void RuleBook::initWithX11() | ||||
974 | { | ||||
975 | auto c = kwinApp()->x11Connection(); | ||||
976 | if (!c) { | ||||
977 | m_temporaryRulesMessages.reset(); | ||||
978 | return; | ||||
979 | } | ||||
980 | m_temporaryRulesMessages.reset(new KXMessages(c, kwinApp()->x11RootWindow(), "_KDE_NET_WM_TEMPORARY_RULES", nullptr)); | ||||
981 | connect(m_temporaryRulesMessages.data(), SIGNAL(gotMessage(QString)), SLOT(temporaryRulesMessage(QString))); | ||||
982 | } | ||||
983 | | ||||
972 | void RuleBook::deleteAll() | 984 | void RuleBook::deleteAll() | ||
973 | { | 985 | { | ||
974 | qDeleteAll(m_rules); | 986 | qDeleteAll(m_rules); | ||
975 | m_rules.clear(); | 987 | m_rules.clear(); | ||
976 | } | 988 | } | ||
977 | 989 | | |||
978 | WindowRules RuleBook::find(const Client* c, bool ignore_temporary) | 990 | WindowRules RuleBook::find(const Client* c, bool ignore_temporary) | ||
979 | { | 991 | { | ||
▲ Show 20 Lines • Show All 153 Lines • Show Last 20 Lines |