diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0d13ceecdf..ed827187ba 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/scripting/org.kde.kwin.Script.xml b/src/scripting/org.kde.kwin.Script.xml new file mode 100644 index 0000000000..d22c282149 --- /dev/null +++ b/src/scripting/org.kde.kwin.Script.xml @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/src/scripting/scripting.cpp b/src/scripting/scripting.cpp index 26363737cd..840ac245c1 100644 --- a/src/scripting/scripting.cpp +++ b/src/scripting/scripting.cpp @@ -41,6 +41,8 @@ #include #include +#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>(); - - 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() diff --git a/src/scripting/scripting.h b/src/scripting/scripting.h index 3dea60d409..0580e6816c 100644 --- a/src/scripting/scripting.h +++ b/src/scripting/scripting.h @@ -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;