diff --git a/scripting/scripting.cpp b/scripting/scripting.cpp index e791183a53..36b1439ad5 100644 --- a/scripting/scripting.cpp +++ b/scripting/scripting.cpp @@ -142,6 +142,13 @@ void KWin::AbstractScript::installScriptFunctions(QScriptEngine* engine) engine->globalObject().setProperty("readConfig", configFunc); // add global Shortcut registerGlobalShortcutFunction(this, engine, kwinScriptGlobalShortcut); + // global properties + engine->globalObject().setProperty("KWin", engine->newQMetaObject(&WorkspaceWrapper::staticMetaObject)); + QScriptValue workspace = engine->newQObject(AbstractScript::workspace(), QScriptEngine::QtOwnership, + QScriptEngine::ExcludeSuperClassContents | QScriptEngine::ExcludeDeleteLater); + engine->globalObject().setProperty("workspace", workspace, QScriptValue::Undeletable); + // install meta functions + KWin::MetaScripting::registration(engine); } KWin::Script::Script(int id, QString scriptName, QString pluginName, QObject* parent) @@ -162,16 +169,11 @@ void KWin::Script::run() return; } if (scriptFile().open(QIODevice::ReadOnly)) { - QScriptValue workspace = m_engine->newQObject(AbstractScript::workspace(), QScriptEngine::QtOwnership, - QScriptEngine::ExcludeSuperClassContents | QScriptEngine::ExcludeDeleteLater); QScriptValue optionsValue = m_engine->newQObject(options, QScriptEngine::QtOwnership, QScriptEngine::ExcludeSuperClassContents | QScriptEngine::ExcludeDeleteLater); - m_engine->globalObject().setProperty("workspace", workspace, QScriptValue::Undeletable); m_engine->globalObject().setProperty("options", optionsValue, QScriptValue::Undeletable); m_engine->globalObject().setProperty("QTimer", constructTimerClass(m_engine)); - m_engine->globalObject().setProperty("KWin", m_engine->newQMetaObject(&WorkspaceWrapper::staticMetaObject)); QObject::connect(m_engine, SIGNAL(signalHandlerException(QScriptValue)), this, SLOT(sigException(QScriptValue))); - KWin::MetaScripting::registration(m_engine); KWin::MetaScripting::supplyConfig(m_engine); installScriptFunctions(m_engine); @@ -236,10 +238,8 @@ void KWin::DeclarativeScript::run() kdeclarative.setupBindings(); installScriptFunctions(kdeclarative.scriptEngine()); qmlRegisterType("org.kde.kwin", 0, 1, "ThumbnailItem"); - qmlRegisterType("org.kde.kwin", 0, 1, "KWin"); qmlRegisterType(); - m_view->rootContext()->setContextProperty("workspace", workspace()); m_view->rootContext()->setContextProperty("options", options); m_view->setSource(QUrl::fromLocalFile(scriptFile().fileName())); diff --git a/scripting/workspace_wrapper.cpp b/scripting/workspace_wrapper.cpp index 287b3ee31a..122ea0fee6 100644 --- a/scripting/workspace_wrapper.cpp +++ b/scripting/workspace_wrapper.cpp @@ -191,15 +191,6 @@ QString WorkspaceWrapper::supportInformation() const return Workspace::self()->supportInformation(); } -QList< QObject* > WorkspaceWrapper::getClientList() const -{ - QList list; - foreach (Client* client, Workspace::self()->clientList()) { - list << client; - } - return list; -} - void WorkspaceWrapper::setupClientConnections(KWin::Client *client) { connect(client, SIGNAL(clientMinimized(KWin::Client*,bool)), SIGNAL(clientMinimized(KWin::Client*))); diff --git a/scripting/workspace_wrapper.h b/scripting/workspace_wrapper.h index a15f7778f7..77d9433c63 100644 --- a/scripting/workspace_wrapper.h +++ b/scripting/workspace_wrapper.h @@ -148,12 +148,6 @@ void setter( rettype val ); /** * List of Clients currently managed by KWin. - * Use this method in QML scripts. - **/ - Q_INVOKABLE QList< QObject* > getClientList() const; - /** - * List of Clients currently managed by KWin. - * Use this method in JavaScript scripts. **/ Q_INVOKABLE QList< KWin::Client* > clientList() const; /**