2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2010-09-21 14:31:40 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2010 Rohan Prabhu <rohan@rohanprabhu.com>
|
2010-09-21 14:31:40 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2010-09-21 14:31:40 +00:00
|
|
|
|
2011-01-01 09:37:08 +00:00
|
|
|
#ifndef KWIN_SCRIPTING_META_H
|
|
|
|
#define KWIN_SCRIPTING_META_H
|
2010-09-21 14:31:40 +00:00
|
|
|
|
|
|
|
#include <QScriptValueIterator>
|
|
|
|
|
2012-01-01 13:31:11 +00:00
|
|
|
// forward declarations
|
|
|
|
class QPoint;
|
|
|
|
class QRect;
|
|
|
|
class QScriptContext;
|
|
|
|
class QSize;
|
|
|
|
|
|
|
|
namespace KWin {
|
2019-10-25 11:21:27 +00:00
|
|
|
class AbstractClient;
|
2013-02-06 14:25:02 +00:00
|
|
|
class Toplevel;
|
2019-09-24 08:48:08 +00:00
|
|
|
class X11Client;
|
2012-01-01 13:31:11 +00:00
|
|
|
}
|
2010-09-21 14:31:40 +00:00
|
|
|
|
2019-10-25 11:21:27 +00:00
|
|
|
typedef KWin::AbstractClient *KAbstractClientRef;
|
2019-09-24 08:48:08 +00:00
|
|
|
typedef KWin::X11Client *KClientRef;
|
2013-02-06 14:25:02 +00:00
|
|
|
typedef KWin::Toplevel* KToplevelRef;
|
2010-09-21 14:31:40 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
namespace MetaScripting
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2019-02-02 18:17:44 +00:00
|
|
|
* The toScriptValue and fromScriptValue functions used in qScriptRegisterMetaType.
|
|
|
|
* Conversion functions for QPoint
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2010-09-21 14:31:40 +00:00
|
|
|
namespace Point
|
|
|
|
{
|
|
|
|
QScriptValue toScriptValue(QScriptEngine*, const QPoint&);
|
|
|
|
void fromScriptValue(const QScriptValue&, QPoint&);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-02-02 18:17:44 +00:00
|
|
|
* The toScriptValue and fromScriptValue functions used in qScriptRegisterMetaType.
|
|
|
|
* Conversion functions for QSize
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2010-09-21 14:31:40 +00:00
|
|
|
namespace Size
|
|
|
|
{
|
|
|
|
QScriptValue toScriptValue(QScriptEngine*, const QSize&);
|
|
|
|
void fromScriptValue(const QScriptValue&, QSize&);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-02-02 18:17:44 +00:00
|
|
|
* The toScriptValue and fromScriptValue functions used in qScriptRegisterMetaType.
|
|
|
|
* Conversion functions for QRect
|
|
|
|
* TODO: QRect conversions have to be linked from plasma as they provide a lot more
|
|
|
|
* features. As for QSize and QPoint, I don't really plan any such thing.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2010-09-21 14:31:40 +00:00
|
|
|
namespace Rect
|
|
|
|
{
|
|
|
|
QScriptValue toScriptValue(QScriptEngine*, const QRect&);
|
|
|
|
void fromScriptValue(const QScriptValue&, QRect&);
|
|
|
|
}
|
|
|
|
|
2019-10-25 11:21:27 +00:00
|
|
|
namespace AbstractClient
|
|
|
|
{
|
|
|
|
QScriptValue toScriptValue(QScriptEngine *engine, const KAbstractClientRef &client);
|
|
|
|
void fromScriptValue(const QScriptValue &value, KAbstractClientRef &client);
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
namespace X11Client
|
2012-01-01 13:31:11 +00:00
|
|
|
{
|
|
|
|
QScriptValue toScriptValue(QScriptEngine *eng, const KClientRef &client);
|
|
|
|
void fromScriptValue(const QScriptValue &value, KClientRef& client);
|
|
|
|
}
|
2010-09-21 14:31:40 +00:00
|
|
|
|
2013-02-06 14:25:02 +00:00
|
|
|
namespace Toplevel
|
|
|
|
{
|
|
|
|
QScriptValue toScriptValue(QScriptEngine *eng, const KToplevelRef &client);
|
|
|
|
void fromScriptValue(const QScriptValue &value, KToplevelRef& client);
|
|
|
|
}
|
|
|
|
|
2010-09-21 14:31:40 +00:00
|
|
|
/**
|
2019-02-02 18:17:44 +00:00
|
|
|
* Merges the second QScriptValue in the first one.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2010-09-21 14:31:40 +00:00
|
|
|
void valueMerge(QScriptValue&, QScriptValue);
|
|
|
|
|
|
|
|
/**
|
2019-02-02 18:17:44 +00:00
|
|
|
* Registers all the meta conversion to the provided QScriptEngine
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2010-09-21 14:31:40 +00:00
|
|
|
void registration(QScriptEngine* eng);
|
|
|
|
|
|
|
|
/**
|
2019-02-02 18:17:44 +00:00
|
|
|
* Functions for the JS function objects, config.exists and config.get.
|
|
|
|
* Read scripting/IMPLIST for details on how they work
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2010-09-21 14:31:40 +00:00
|
|
|
QScriptValue configExists(QScriptContext*, QScriptEngine*);
|
|
|
|
QScriptValue getConfigValue(QScriptContext*, QScriptEngine*);
|
|
|
|
|
|
|
|
/**
|
2019-02-02 18:17:44 +00:00
|
|
|
* Provide a config object to the given QScriptEngine depending
|
|
|
|
* on the keys provided in the QVariant. The provided QVariant
|
|
|
|
* MUST returns (true) on isHash()
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2010-09-21 14:31:40 +00:00
|
|
|
void supplyConfig(QScriptEngine*, const QVariant&);
|
|
|
|
|
|
|
|
/**
|
2019-02-02 18:17:44 +00:00
|
|
|
* For engines whose scripts have no associated configuration.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2010-09-21 14:31:40 +00:00
|
|
|
void supplyConfig(QScriptEngine*);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-02-02 18:17:44 +00:00
|
|
|
* Code linked from plasma for QTimer.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2010-09-21 14:31:40 +00:00
|
|
|
QScriptValue constructTimerClass(QScriptEngine *eng);
|
|
|
|
|
2010-12-12 18:22:09 +00:00
|
|
|
#endif
|