Export Toplevel to KWin::Scripts
Without the scripting system is not able to handle signals defined on Toplevel instead of Client. REVIEW: 108807
This commit is contained in:
parent
05541740ac
commit
8205adcac3
3 changed files with 24 additions and 0 deletions
|
@ -110,6 +110,20 @@ void Client::fromScriptValue(const QScriptValue &value, KWin::Client* &client)
|
|||
client = qobject_cast<KWin::Client*>(value.toQObject());
|
||||
}
|
||||
|
||||
QScriptValue Toplevel::toScriptValue(QScriptEngine *eng, const KToplevelRef &client)
|
||||
{
|
||||
return eng->newQObject(client, QScriptEngine::QtOwnership,
|
||||
QScriptEngine::ExcludeChildObjects |
|
||||
QScriptEngine::ExcludeDeleteLater |
|
||||
QScriptEngine::PreferExistingWrapperObject |
|
||||
QScriptEngine::AutoCreateDynamicProperties);
|
||||
}
|
||||
|
||||
void Toplevel::fromScriptValue(const QScriptValue &value, KToplevelRef &client)
|
||||
{
|
||||
client = qobject_cast<KWin::Toplevel*>(value.toQObject());
|
||||
}
|
||||
|
||||
// Other helper functions
|
||||
void KWin::MetaScripting::registration(QScriptEngine* eng)
|
||||
{
|
||||
|
@ -117,6 +131,7 @@ void KWin::MetaScripting::registration(QScriptEngine* eng)
|
|||
qScriptRegisterMetaType<QSize>(eng, Size::toScriptValue, Size::fromScriptValue);
|
||||
qScriptRegisterMetaType<QRect>(eng, Rect::toScriptValue, Rect::fromScriptValue);
|
||||
qScriptRegisterMetaType<KClientRef>(eng, Client::toScriptValue, Client::fromScriptValue);
|
||||
qScriptRegisterMetaType<KToplevelRef>(eng, Toplevel::toScriptValue, Toplevel::fromScriptValue);
|
||||
|
||||
qScriptRegisterSequenceMetaType<QStringList>(eng);
|
||||
qScriptRegisterSequenceMetaType< QList<KWin::Client*> >(eng);
|
||||
|
|
|
@ -31,9 +31,11 @@ class QSize;
|
|||
|
||||
namespace KWin {
|
||||
class Client;
|
||||
class Toplevel;
|
||||
}
|
||||
|
||||
typedef KWin::Client* KClientRef;
|
||||
typedef KWin::Toplevel* KToplevelRef;
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
@ -79,6 +81,12 @@ QScriptValue toScriptValue(QScriptEngine *eng, const KClientRef &client);
|
|||
void fromScriptValue(const QScriptValue &value, KClientRef& client);
|
||||
}
|
||||
|
||||
namespace Toplevel
|
||||
{
|
||||
QScriptValue toScriptValue(QScriptEngine *eng, const KToplevelRef &client);
|
||||
void fromScriptValue(const QScriptValue &value, KToplevelRef& client);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges the second QScriptValue in the first one.
|
||||
*/
|
||||
|
|
|
@ -661,5 +661,6 @@ KWIN_COMPARE_PREDICATE(WindowMatchPredicate, Toplevel, Window, cl->window() == v
|
|||
KWIN_COMPARE_PREDICATE(FrameIdMatchPredicate, Toplevel, Window, cl->frameId() == value);
|
||||
|
||||
} // namespace
|
||||
Q_DECLARE_METATYPE(KWin::Toplevel*)
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue