mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
envmanager: Fix KWin effect and script reloading
Previously, we had a silent failure of the dbus call to "reloadConfig" which turned out to be a signal and not a method that we can call. To reload effects, we need to manually call dbus to load and unload each individual one. A similar situation exists for scripts, except that we only unload scripts through individual calls, and call `start` to load all of the enabled scripts at once.
This commit is contained in:
parent
76882f5b5d
commit
051e8b7903
2 changed files with 34 additions and 1 deletions
|
|
@ -62,3 +62,8 @@ QMap<QString, QMap<QString, QVariant>> getKwinrcSettings(KSharedConfig::Ptr m_mo
|
||||||
{"TabletMode", convergenceModeEnabled ? "off" : "auto"} // TabletMode changes depending on whether the device is in convergence mode
|
{"TabletMode", convergenceModeEnabled ? "off" : "auto"} // TabletMode changes depending on whether the device is in convergence mode
|
||||||
}}};
|
}}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Have a separate list here because we need to trigger DBus calls to load/unload each effect/script.
|
||||||
|
// Make sure that the effect/script is added to the kwinrc "Plugins" section above!
|
||||||
|
const QList<QString> KWIN_EFFECTS = {"blur", "mobiletaskswitcher"};
|
||||||
|
const QList<QString> KWIN_SCRIPTS = {"convergentwindows"};
|
||||||
|
|
|
||||||
|
|
@ -170,6 +170,34 @@ const QString Settings::loadSavedConfigSetting(KSharedConfig::Ptr &config, const
|
||||||
|
|
||||||
void Settings::reloadKWinConfig()
|
void Settings::reloadKWinConfig()
|
||||||
{
|
{
|
||||||
QDBusMessage message = QDBusMessage::createSignal(u"/KWin"_s, u"org.kde.KWin"_s, u"reloadConfig"_s);
|
// Most KWin settings are already reloaded through KConfig's notify feature.
|
||||||
|
// However, effects need to manually be loaded/unloaded in a live KWin session.
|
||||||
|
|
||||||
|
KConfigGroup pluginsGroup{m_kwinrcConfig, QStringLiteral("Plugins")};
|
||||||
|
|
||||||
|
for (const auto &effect : KWIN_EFFECTS) {
|
||||||
|
// Read from the config whether the effect is enabled (settings are suffixed with "Enabled", ex. blurEnabled)
|
||||||
|
bool status = pluginsGroup.readEntry(effect + u"Enabled"_s, false);
|
||||||
|
const QString method = status ? u"loadEffect"_s : u"unloadEffect"_s;
|
||||||
|
|
||||||
|
QDBusMessage message = QDBusMessage::createMethodCall(u"org.kde.KWin"_s, u"/Effects"_s, u"org.kde.kwin.Effects"_s, method);
|
||||||
|
message.setArguments({effect});
|
||||||
|
QDBusConnection::sessionBus().send(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unload KWin scripts that are now disabled.
|
||||||
|
for (const auto &script : KWIN_SCRIPTS) {
|
||||||
|
// Read from the config whether the effect is enabled (settings are suffixed with "Enabled", ex. blurEnabled)
|
||||||
|
bool status = pluginsGroup.readEntry(script + u"Enabled"_s, false);
|
||||||
|
|
||||||
|
if (!status) {
|
||||||
|
QDBusMessage message = QDBusMessage::createMethodCall(u"org.kde.KWin"_s, u"/Scripting"_s, u"org.kde.kwin.Scripting"_s, u"unloadScript"_s);
|
||||||
|
message.setArguments({script});
|
||||||
|
QDBusConnection::sessionBus().send(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call "start" to load enabled KWin scripts.
|
||||||
|
QDBusMessage message = QDBusMessage::createMethodCall(u"org.kde.KWin"_s, u"/Scripting"_s, u"org.kde.kwin.Scripting"_s, u"start"_s);
|
||||||
QDBusConnection::sessionBus().send(message);
|
QDBusConnection::sessionBus().send(message);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue