Merge branch 'Plasma/5.8'

icc-effect-5.14.5
Martin Gräßlin 2016-11-03 08:51:49 +01:00
commit d1076fc5b9
11 changed files with 134 additions and 65 deletions

View File

@ -86,6 +86,7 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
Declarative Declarative
KCMUtils KCMUtils
KIO KIO
TextWidgets
NewStuff NewStuff
Service Service
XmlGui XmlGui
@ -347,10 +348,10 @@ add_subdirectory(helpers)
########### next target ############### ########### next target ###############
set(kwin_KDEINIT_SRCS set(kwin_KDEINIT_SRCS
workspace.cpp workspace.cpp
dbusinterface.cpp dbusinterface.cpp
abstract_client.cpp abstract_client.cpp
client.cpp client.cpp
client_machine.cpp client_machine.cpp
cursor.cpp cursor.cpp
debug_console.cpp debug_console.cpp
@ -363,25 +364,25 @@ set(kwin_KDEINIT_SRCS
pointer_input.cpp pointer_input.cpp
touch_input.cpp touch_input.cpp
netinfo.cpp netinfo.cpp
placement.cpp placement.cpp
atoms.cpp atoms.cpp
utils.cpp utils.cpp
layers.cpp layers.cpp
main.cpp main.cpp
options.cpp options.cpp
outline.cpp outline.cpp
events.cpp events.cpp
killwindow.cpp killwindow.cpp
geometrytip.cpp geometrytip.cpp
screens.cpp screens.cpp
shadow.cpp shadow.cpp
sm.cpp sm.cpp
group.cpp group.cpp
manage.cpp manage.cpp
overlaywindow.cpp overlaywindow.cpp
activation.cpp activation.cpp
useractions.cpp useractions.cpp
geometry.cpp geometry.cpp
rules.cpp rules.cpp
composite.cpp composite.cpp
toplevel.cpp toplevel.cpp

View File

@ -666,7 +666,6 @@ void MoveResizeWindowTest::testAdjustClientGeometryOfAutohidingX11Panel()
QVERIFY(panelHiddenSpy.wait()); QVERIFY(panelHiddenSpy.wait());
// now try to snap again // now try to snap again
QEXPECT_FAIL("", "BUG 365892", Continue);
QCOMPARE(Workspace::self()->adjustClientPosition(testWindow, targetPoint, false), targetPoint); QCOMPARE(Workspace::self()->adjustClientPosition(testWindow, targetPoint, false), targetPoint);
// and destroy the panel again // and destroy the panel again

View File

@ -12,6 +12,7 @@ target_link_libraries(kwin_mousemark_config
KF5::GlobalAccel KF5::GlobalAccel
KF5::I18n KF5::I18n
KF5::Service KF5::Service
KF5::TextWidgets
KF5::XmlGui KF5::XmlGui
) )

View File

@ -52,7 +52,7 @@ MouseMarkEffectConfig::MouseMarkEffectConfig(QWidget* parent, const QVariantList
{ {
m_ui = new MouseMarkEffectConfigForm(this); m_ui = new MouseMarkEffectConfigForm(this);
m_ui->kcfg_LineWidth->setSuffix(ki18np(" pixel", " pixels").toString()); m_ui->kcfg_LineWidth->setSuffix(ki18np(" pixel", " pixels"));
QVBoxLayout* layout = new QVBoxLayout(this); QVBoxLayout* layout = new QVBoxLayout(this);

View File

@ -17,10 +17,10 @@
<string>Appearance</string> <string>Appearance</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>&amp;Width:</string> <string>Wid&amp;th:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -30,26 +30,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="2" column="0">
<widget class="QSpinBox" name="kcfg_LineWidth">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="value">
<number>3</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>&amp;Color:</string> <string>&amp;Color:</string>
@ -62,7 +43,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="2" column="1">
<widget class="KColorCombo" name="kcfg_Color"> <widget class="KColorCombo" name="kcfg_Color">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@ -72,15 +53,24 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="KPluralHandlingSpinBox" name="kcfg_LineWidth">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="value">
<number>3</number>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="KShortcutsEditor" name="editor" native="true"> <widget class="KShortcutsEditor" name="editor"/>
<property name="actionTypes">
<enum>KShortcutsEditor::GlobalAction</enum>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
@ -106,9 +96,14 @@
<customwidget> <customwidget>
<class>KShortcutsEditor</class> <class>KShortcutsEditor</class>
<extends>QWidget</extends> <extends>QWidget</extends>
<header location="global">KShortcutsEditor</header> <header>kshortcutseditor.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>KPluralHandlingSpinBox</class>
<extends>QSpinBox</extends>
<header>kpluralhandlingspinbox.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections/> <connections/>

View File

@ -527,6 +527,8 @@ QPoint Workspace::adjustClientPosition(AbstractClient* c, QPoint pos, bool unres
continue; continue;
if ((*l)->isMinimized()) if ((*l)->isMinimized())
continue; // is minimized continue; // is minimized
if (!(*l)->isShown(false))
continue;
if ((*l)->tabGroup() && (*l) != (*l)->tabGroup()->current()) if ((*l)->tabGroup() && (*l) != (*l)->tabGroup()->current())
continue; // is not active tab continue; // is not active tab
if (!((*l)->isOnDesktop(c->desktop()) || c->isOnDesktop((*l)->desktop()))) if (!((*l)->isOnDesktop(c->desktop()) || c->isOnDesktop((*l)->desktop())))

View File

@ -492,7 +492,7 @@ bool ScriptedEffect::init(const QString &effectName, const QString &pathToScript
m_engine->globalObject().setProperty(QStringLiteral("effects"), effectsObject, QScriptValue::Undeletable); m_engine->globalObject().setProperty(QStringLiteral("effects"), effectsObject, QScriptValue::Undeletable);
m_engine->globalObject().setProperty(QStringLiteral("Effect"), m_engine->newQMetaObject(&ScriptedEffect::staticMetaObject)); m_engine->globalObject().setProperty(QStringLiteral("Effect"), m_engine->newQMetaObject(&ScriptedEffect::staticMetaObject));
#ifndef KWIN_UNIT_TEST #ifndef KWIN_UNIT_TEST
m_engine->globalObject().setProperty(QStringLiteral("KWin"), m_engine->newQMetaObject(&WorkspaceWrapper::staticMetaObject)); m_engine->globalObject().setProperty(QStringLiteral("KWin"), m_engine->newQMetaObject(&QtScriptWorkspaceWrapper::staticMetaObject));
#endif #endif
m_engine->globalObject().setProperty(QStringLiteral("QEasingCurve"), m_engine->newQMetaObject(&QEasingCurve::staticMetaObject)); m_engine->globalObject().setProperty(QStringLiteral("QEasingCurve"), m_engine->newQMetaObject(&QEasingCurve::staticMetaObject));
m_engine->globalObject().setProperty(QStringLiteral("effect"), m_engine->newQObject(this, QScriptEngine::QtOwnership, QScriptEngine::ExcludeDeleteLater), QScriptValue::Undeletable); m_engine->globalObject().setProperty(QStringLiteral("effect"), m_engine->newQObject(this, QScriptEngine::QtOwnership, QScriptEngine::ExcludeDeleteLater), QScriptValue::Undeletable);

View File

@ -46,6 +46,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QMenu> #include <QMenu>
#include <QQmlContext> #include <QQmlContext>
#include <QQmlEngine> #include <QQmlEngine>
#include <QQmlExpression>
#include <QtScript/QScriptEngine> #include <QtScript/QScriptEngine>
#include <QtScript/QScriptValue> #include <QtScript/QScriptValue>
#include <QtCore/QStandardPaths> #include <QtCore/QStandardPaths>
@ -301,9 +302,9 @@ void KWin::Script::installScriptFunctions(QScriptEngine* engine)
QScriptValue assertNotNullFunc = engine->newFunction(kwinAssertNotNull); QScriptValue assertNotNullFunc = engine->newFunction(kwinAssertNotNull);
engine->globalObject().setProperty(QStringLiteral("assertNotNull"), assertNotNullFunc); engine->globalObject().setProperty(QStringLiteral("assertNotNull"), assertNotNullFunc);
// global properties // global properties
engine->globalObject().setProperty(QStringLiteral("KWin"), engine->newQMetaObject(&WorkspaceWrapper::staticMetaObject)); engine->globalObject().setProperty(QStringLiteral("KWin"), engine->newQMetaObject(&QtScriptWorkspaceWrapper::staticMetaObject));
QScriptValue workspace = engine->newQObject(Scripting::self()->workspaceWrapper(), QScriptEngine::QtOwnership, QScriptValue workspace = engine->newQObject(Scripting::self()->workspaceWrapper(), QScriptEngine::QtOwnership,
QScriptEngine::ExcludeSuperClassContents | QScriptEngine::ExcludeDeleteLater); QScriptEngine::ExcludeDeleteLater);
engine->globalObject().setProperty(QStringLiteral("workspace"), workspace, QScriptValue::Undeletable); engine->globalObject().setProperty(QStringLiteral("workspace"), workspace, QScriptValue::Undeletable);
// install meta functions // install meta functions
KWin::MetaScripting::registration(engine); KWin::MetaScripting::registration(engine);
@ -535,7 +536,7 @@ void KWin::ScriptUnloaderAgent::scriptUnload(qint64 id)
KWin::DeclarativeScript::DeclarativeScript(int id, QString scriptName, QString pluginName, QObject* parent) KWin::DeclarativeScript::DeclarativeScript(int id, QString scriptName, QString pluginName, QObject* parent)
: AbstractScript(id, scriptName, pluginName, parent) : AbstractScript(id, scriptName, pluginName, parent)
, m_context(new QQmlContext(Scripting::self()->qmlEngine(), this)) , m_context(new QQmlContext(Scripting::self()->declarativeScriptSharedContext(), this))
, m_component(new QQmlComponent(Scripting::self()->qmlEngine(), this)) , m_component(new QQmlComponent(Scripting::self()->qmlEngine(), this))
{ {
m_context->setContextProperty(QStringLiteral("KWin"), new JSEngineGlobalMethodsWrapper(this)); m_context->setContextProperty(QStringLiteral("KWin"), new JSEngineGlobalMethodsWrapper(this));
@ -630,7 +631,8 @@ KWin::Scripting::Scripting(QObject *parent)
: QObject(parent) : QObject(parent)
, m_scriptsLock(new QMutex(QMutex::Recursive)) , m_scriptsLock(new QMutex(QMutex::Recursive))
, m_qmlEngine(new QQmlEngine(this)) , m_qmlEngine(new QQmlEngine(this))
, m_workspaceWrapper(new WorkspaceWrapper(this)) , m_declarativeScriptSharedContext(new QQmlContext(m_qmlEngine, this))
, m_workspaceWrapper(new QtScriptWorkspaceWrapper(this))
{ {
init(); init();
QDBusConnection::sessionBus().registerObject(QStringLiteral("/Scripting"), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportScriptableInvokables); QDBusConnection::sessionBus().registerObject(QStringLiteral("/Scripting"), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportScriptableInvokables);
@ -655,6 +657,11 @@ void KWin::Scripting::init()
m_qmlEngine->rootContext()->setContextProperty(QStringLiteral("workspace"), m_workspaceWrapper); m_qmlEngine->rootContext()->setContextProperty(QStringLiteral("workspace"), m_workspaceWrapper);
m_qmlEngine->rootContext()->setContextProperty(QStringLiteral("options"), options); m_qmlEngine->rootContext()->setContextProperty(QStringLiteral("options"), options);
m_declarativeScriptSharedContext->setContextProperty(QStringLiteral("workspace"), new DeclarativeScriptWorkspaceWrapper(this));
// QQmlListProperty interfaces only work via properties, rebind them as functions here
QQmlExpression expr(m_declarativeScriptSharedContext, nullptr, "workspace.clientList = function() { return workspace.clients }");
expr.evaluate();
} }
void KWin::Scripting::start() void KWin::Scripting::start()

View File

@ -51,7 +51,7 @@ namespace KWin
class AbstractClient; class AbstractClient;
class Client; class Client;
class ScriptUnloaderAgent; class ScriptUnloaderAgent;
class WorkspaceWrapper; class QtScriptWorkspaceWrapper;
class KWIN_EXPORT AbstractScript : public QObject class KWIN_EXPORT AbstractScript : public QObject
{ {
@ -362,7 +362,9 @@ public:
QQmlEngine *qmlEngine() const; QQmlEngine *qmlEngine() const;
QQmlEngine *qmlEngine(); QQmlEngine *qmlEngine();
WorkspaceWrapper *workspaceWrapper() const; QQmlContext *declarativeScriptSharedContext() const;
QQmlContext *declarativeScriptSharedContext();
QtScriptWorkspaceWrapper *workspaceWrapper() const;
AbstractScript *findScript(const QString &pluginName) const; AbstractScript *findScript(const QString &pluginName) const;
@ -381,7 +383,8 @@ private:
LoadScriptList queryScriptsToLoad(); LoadScriptList queryScriptsToLoad();
static Scripting *s_self; static Scripting *s_self;
QQmlEngine *m_qmlEngine; QQmlEngine *m_qmlEngine;
WorkspaceWrapper *m_workspaceWrapper; QQmlContext *m_declarativeScriptSharedContext;
QtScriptWorkspaceWrapper *m_workspaceWrapper;
}; };
inline inline
@ -397,7 +400,19 @@ QQmlEngine *Scripting::qmlEngine()
} }
inline inline
WorkspaceWrapper *Scripting::workspaceWrapper() const QQmlContext *Scripting::declarativeScriptSharedContext() const
{
return m_declarativeScriptSharedContext;
}
inline
QQmlContext *Scripting::declarativeScriptSharedContext()
{
return m_declarativeScriptSharedContext;
}
inline
QtScriptWorkspaceWrapper *Scripting::workspaceWrapper() const
{ {
return m_workspaceWrapper; return m_workspaceWrapper;
} }

View File

@ -90,12 +90,12 @@ void WorkspaceWrapper::setNumberOfDesktops(int count)
VirtualDesktopManager::self()->setCount(count); VirtualDesktopManager::self()->setCount(count);
} }
#define GETTER( rettype, getterName ) \ #define GETTER( klass, rettype, getterName ) \
rettype WorkspaceWrapper::getterName( ) const { \ rettype klass::getterName( ) const { \
return Workspace::self()->getterName(); \ return Workspace::self()->getterName(); \
} }
GETTER(KWin::AbstractClient*, activeClient) GETTER(WorkspaceWrapper, KWin::AbstractClient*, activeClient)
GETTER(QList< KWin::Client* >, clientList) GETTER(QtScriptWorkspaceWrapper, QList< KWin::Client* >, clientList)
#undef GETTER #undef GETTER
@ -324,4 +324,28 @@ QSize WorkspaceWrapper::virtualScreenSize() const
return screens()->size(); return screens()->size();
} }
QtScriptWorkspaceWrapper::QtScriptWorkspaceWrapper(QObject* parent)
: WorkspaceWrapper(parent) {}
QQmlListProperty<KWin::Client> DeclarativeScriptWorkspaceWrapper::clients()
{
return QQmlListProperty<KWin::Client>(this, 0, &DeclarativeScriptWorkspaceWrapper::countClientList, &DeclarativeScriptWorkspaceWrapper::atClientList);
}
int DeclarativeScriptWorkspaceWrapper::countClientList(QQmlListProperty<KWin::Client> *clients)
{
Q_UNUSED(clients)
return Workspace::self()->clientList().size();
}
KWin::Client *DeclarativeScriptWorkspaceWrapper::atClientList(QQmlListProperty<KWin::Client> *clients, int index)
{
Q_UNUSED(clients)
return Workspace::self()->clientList().at(index);
}
DeclarativeScriptWorkspaceWrapper::DeclarativeScriptWorkspaceWrapper(QObject* parent)
: WorkspaceWrapper(parent) {}
} // KWin } // KWin

View File

@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QSize> #include <QSize>
#include <QStringList> #include <QStringList>
#include <QRect> #include <QRect>
#include <QtQml/QQmlListProperty>
#include <kwinglobals.h> #include <kwinglobals.h>
namespace KWin namespace KWin
@ -198,7 +199,10 @@ public:
ElectricNone ElectricNone
}; };
protected:
explicit WorkspaceWrapper(QObject* parent = nullptr); explicit WorkspaceWrapper(QObject* parent = nullptr);
public:
#define GETTERSETTERDEF( rettype, getter, setter ) \ #define GETTERSETTERDEF( rettype, getter, setter ) \
rettype getter() const; \ rettype getter() const; \
void setter( rettype val ); void setter( rettype val );
@ -222,10 +226,6 @@ void setter( rettype val );
QSize virtualScreenSize() const; QSize virtualScreenSize() const;
QRect virtualScreenGeometry() const; QRect virtualScreenGeometry() const;
/**
* List of Clients currently managed by KWin.
**/
Q_INVOKABLE QList< KWin::Client* > clientList() const;
/** /**
* Returns the geometry a Client can use with the specified option. * Returns the geometry a Client can use with the specified option.
* This method should be preferred over other methods providing screen sizes as the * This method should be preferred over other methods providing screen sizes as the
@ -349,6 +349,31 @@ private Q_SLOTS:
void setupClientConnections(KWin::Client* client); void setupClientConnections(KWin::Client* client);
}; };
class QtScriptWorkspaceWrapper : public WorkspaceWrapper
{
Q_OBJECT
public:
/**
* List of Clients currently managed by KWin.
**/
Q_INVOKABLE QList< KWin::Client* > clientList() const;
explicit QtScriptWorkspaceWrapper(QObject* parent = nullptr);
};
class DeclarativeScriptWorkspaceWrapper : public WorkspaceWrapper
{
Q_OBJECT
Q_PROPERTY(QQmlListProperty<KWin::Client> clients READ clients)
public:
QQmlListProperty<KWin::Client> clients();
static int countClientList(QQmlListProperty<KWin::Client> *clients);
static KWin::Client *atClientList(QQmlListProperty<KWin::Client> *clients, int index);
explicit DeclarativeScriptWorkspaceWrapper(QObject* parent = nullptr);
};
} }
#endif #endif