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.
This commit is contained in:
parent
9a786cd8bf
commit
0eb37563e9
4 changed files with 17 additions and 6 deletions
|
@ -139,6 +139,8 @@ set(kwin_SRCS
|
||||||
xwl/xwayland_interface.cpp
|
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)
|
if (HAVE_LINUX_VT_H)
|
||||||
set(kwin_SRCS ${kwin_SRCS}
|
set(kwin_SRCS ${kwin_SRCS}
|
||||||
virtual_terminal.cpp
|
virtual_terminal.cpp
|
||||||
|
|
10
src/scripting/org.kde.kwin.Script.xml
Normal file
10
src/scripting/org.kde.kwin.Script.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<!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 <QStandardPaths>
|
||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
|
|
||||||
|
#include "scriptadaptor.h"
|
||||||
|
|
||||||
static QRect scriptValueToRect(const QJSValue &value)
|
static QRect scriptValueToRect(const QJSValue &value)
|
||||||
{
|
{
|
||||||
return QRect(value.property(QStringLiteral("x")).toInt(),
|
return QRect(value.property(QStringLiteral("x")).toInt(),
|
||||||
|
@ -71,6 +73,9 @@ KWin::AbstractScript::AbstractScript(int id, QString scriptName, QString pluginN
|
||||||
if (m_pluginName.isNull()) {
|
if (m_pluginName.isNull()) {
|
||||||
m_pluginName = scriptName;
|
m_pluginName = scriptName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new ScriptAdaptor(this);
|
||||||
|
QDBusConnection::sessionBus().registerObject(QLatin1Char('/') + QString::number(scriptId()), this, QDBusConnection::ExportAdaptors);
|
||||||
}
|
}
|
||||||
|
|
||||||
KWin::AbstractScript::~AbstractScript()
|
KWin::AbstractScript::~AbstractScript()
|
||||||
|
@ -104,13 +109,10 @@ KWin::Script::Script(int id, QString scriptName, QString pluginName, QObject* pa
|
||||||
}
|
}
|
||||||
|
|
||||||
qRegisterMetaType<QList<KWin::AbstractClient *>>();
|
qRegisterMetaType<QList<KWin::AbstractClient *>>();
|
||||||
|
|
||||||
QDBusConnection::sessionBus().registerObject(QLatin1Char('/') + QString::number(scriptId()), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportScriptableInvokables);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KWin::Script::~Script()
|
KWin::Script::~Script()
|
||||||
{
|
{
|
||||||
QDBusConnection::sessionBus().unregisterObject(QLatin1Char('/') + QString::number(scriptId()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KWin::Script::run()
|
void KWin::Script::run()
|
||||||
|
|
|
@ -86,8 +86,6 @@ private:
|
||||||
class Script : public AbstractScript, QDBusContext
|
class Script : public AbstractScript, QDBusContext
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.Scripting")
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Script(int id, QString scriptName, QString pluginName, QObject *parent = nullptr);
|
Script(int id, QString scriptName, QString pluginName, QObject *parent = nullptr);
|
||||||
virtual ~Script();
|
virtual ~Script();
|
||||||
|
@ -237,7 +235,6 @@ private:
|
||||||
class DeclarativeScript : public AbstractScript
|
class DeclarativeScript : public AbstractScript
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.Scripting")
|
|
||||||
public:
|
public:
|
||||||
explicit DeclarativeScript(int id, QString scriptName, QString pluginName, QObject *parent = nullptr);
|
explicit DeclarativeScript(int id, QString scriptName, QString pluginName, QObject *parent = nullptr);
|
||||||
~DeclarativeScript() override;
|
~DeclarativeScript() override;
|
||||||
|
|
Loading…
Reference in a new issue