diff --git a/src/scripting/scripting.cpp b/src/scripting/scripting.cpp index e82b3a2ec5..10140449c5 100644 --- a/src/scripting/scripting.cpp +++ b/src/scripting/scripting.cpp @@ -58,18 +58,38 @@ static QRect scriptValueToRect(const QJSValue &value) value.property(QStringLiteral("height")).toInt()); } +static QRectF scriptValueToRectF(const QJSValue &value) +{ + return QRectF(value.property(QStringLiteral("x")).toNumber(), + value.property(QStringLiteral("y")).toNumber(), + value.property(QStringLiteral("width")).toNumber(), + value.property(QStringLiteral("height")).toNumber()); +} + static QPoint scriptValueToPoint(const QJSValue &value) { return QPoint(value.property(QStringLiteral("x")).toInt(), value.property(QStringLiteral("y")).toInt()); } +static QPointF scriptValueToPointF(const QJSValue &value) +{ + return QPointF(value.property(QStringLiteral("x")).toNumber(), + value.property(QStringLiteral("y")).toNumber()); +} + static QSize scriptValueToSize(const QJSValue &value) { return QSize(value.property(QStringLiteral("width")).toInt(), value.property(QStringLiteral("height")).toInt()); } +static QSizeF scriptValueToSizeF(const QJSValue &value) +{ + return QSizeF(value.property(QStringLiteral("width")).toNumber(), + value.property(QStringLiteral("height")).toNumber()); +} + KWin::AbstractScript::AbstractScript(int id, QString scriptName, QString pluginName, QObject *parent) : QObject(parent) , m_scriptId(id) @@ -113,12 +133,23 @@ KWin::Script::Script(int id, QString scriptName, QString pluginName, QObject *pa if (!QMetaType::hasRegisteredConverterFunction()) { QMetaType::registerConverter(scriptValueToRect); } + if (!QMetaType::hasRegisteredConverterFunction()) { + QMetaType::registerConverter(scriptValueToRectF); + } + if (!QMetaType::hasRegisteredConverterFunction()) { QMetaType::registerConverter(scriptValueToPoint); } + if (!QMetaType::hasRegisteredConverterFunction()) { + QMetaType::registerConverter(scriptValueToPointF); + } + if (!QMetaType::hasRegisteredConverterFunction()) { QMetaType::registerConverter(scriptValueToSize); } + if (!QMetaType::hasRegisteredConverterFunction()) { + QMetaType::registerConverter(scriptValueToSizeF); + } qRegisterMetaType>(); }