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
separated.

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
xwl/xwayland_interface.cpp
)
qt5_add_dbus_adaptor(kwin_SRCS scripting/org.kde.kwin.Script.xml scripting/scripting.h KWin::AbstractScript)
if (HAVE_LINUX_VT_H)
set(kwin_SRCS ${kwin_SRCS}
virtual_terminal.cpp
......
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.kde.kwin.Script">
<method name="stop">
</method>
<method name="run">
</method>
</interface>
</node>
......@@ -41,6 +41,8 @@
#include <QStandardPaths>
#include <QQuickWindow>
#include "scriptadaptor.h"
static QRect scriptValueToRect(const QJSValue &value)
{
return QRect(value.property(QStringLiteral("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);
}
KWin::AbstractScript::~AbstractScript()
......@@ -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);
}
KWin::Script::~Script()
{
QDBusConnection::sessionBus().unregisterObject(QLatin1Char('/') + QString::number(scriptId()));
}
void KWin::Script::run()
......
......@@ -86,8 +86,6 @@ private:
class Script : public AbstractScript, QDBusContext
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.Scripting")
public:
Script(int id, QString scriptName, QString pluginName, QObject *parent = nullptr);
virtual ~Script();
......@@ -237,7 +235,6 @@ private:
class DeclarativeScript : public AbstractScript
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.Scripting")
public:
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