Commit 0eb37563 authored by David Edmundson's avatar David Edmundson
Browse files

Restore script DBus API

The Script class has a DBus API we want to export. At some point this
has got broken and the run method is not exported.

It's a bit messy with script subclasses also having other invokables
that we want to export to scripts, so an adaptor is used to keep things

The interface name has technically changed, but KWin was doing something
weird and using the same interface names for the manager. Fortunately
calling Plasma code doesn't specify an interface so this still works.
parent 9a786cd8
......@@ -139,6 +139,8 @@ set(kwin_SRCS
qt5_add_dbus_adaptor(kwin_SRCS scripting/org.kde.kwin.Script.xml scripting/scripting.h KWin::AbstractScript)
set(kwin_SRCS ${kwin_SRCS}
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
<interface name="org.kde.kwin.Script">
<method name="stop">
<method name="run">
......@@ -41,6 +41,8 @@
#include <QStandardPaths>
#include <QQuickWindow>
#include "scriptadaptor.h"
static QRect scriptValueToRect(const QJSValue &value)
return QRect("x")).toInt(),
......@@ -71,6 +73,9 @@ KWin::AbstractScript::AbstractScript(int id, QString scriptName, QString pluginN
if (m_pluginName.isNull()) {
m_pluginName = scriptName;
new ScriptAdaptor(this);
QDBusConnection::sessionBus().registerObject(QLatin1Char('/') + QString::number(scriptId()), this, QDBusConnection::ExportAdaptors);
......@@ -104,13 +109,10 @@ KWin::Script::Script(int id, QString scriptName, QString pluginName, QObject* pa
qRegisterMetaType<QList<KWin::AbstractClient *>>();
QDBusConnection::sessionBus().registerObject(QLatin1Char('/') + QString::number(scriptId()), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportScriptableInvokables);
QDBusConnection::sessionBus().unregisterObject(QLatin1Char('/') + QString::number(scriptId()));
void KWin::Script::run()
......@@ -86,8 +86,6 @@ private:
class Script : public AbstractScript, QDBusContext
Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.Scripting")
Script(int id, QString scriptName, QString pluginName, QObject *parent = nullptr);
virtual ~Script();
......@@ -237,7 +235,6 @@ private:
class DeclarativeScript : public AbstractScript
Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.Scripting")
explicit DeclarativeScript(int id, QString scriptName, QString pluginName, QObject *parent = nullptr);
~DeclarativeScript() override;
Supports Markdown
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