141947d2e8
The main motivation behind this change is to prepare kwin for importing kwayland-server code in libkwin. As is, builtin effects are linked with libkwin. Some builtin effects have wayland specific code. If we move wayland stuff in libkwin, there's going to be a circular dependency between kwin4_effect_builtins and libkwin targets. This change intends to break that dependency by linking builtin effects to kwin executable. The main issue with that is that EffectLoader would need to discover the effects indirectly. QStaticPlugin is used for that purpose. Besides breaking the cyclic dependency, it makes builtin effects use the same plugin infrastructure in libkwineffects that external effects use. Metadata in src/effects/effect_builtins.cpp was converted in a list of python dictionaries, which was fed to a python script that generated main.cpp and metadata.json files.
91 lines
2.9 KiB
C++
91 lines
2.9 KiB
C++
/*
|
|
KWin - the KDE window manager
|
|
This file is part of the KDE project.
|
|
|
|
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
#include "generic_scene_opengl_test.h"
|
|
#include "abstract_client.h"
|
|
#include "composite.h"
|
|
#include "effectloader.h"
|
|
#include "cursor.h"
|
|
#include "platform.h"
|
|
#include "scene.h"
|
|
#include "wayland_server.h"
|
|
|
|
#include <KConfigGroup>
|
|
|
|
using namespace KWin;
|
|
static const QString s_socketName = QStringLiteral("wayland_test_kwin_scene_opengl-0");
|
|
|
|
GenericSceneOpenGLTest::GenericSceneOpenGLTest(const QByteArray &envVariable)
|
|
: QObject()
|
|
, m_envVariable(envVariable)
|
|
{
|
|
}
|
|
|
|
GenericSceneOpenGLTest::~GenericSceneOpenGLTest()
|
|
{
|
|
}
|
|
|
|
void GenericSceneOpenGLTest::cleanup()
|
|
{
|
|
Test::destroyWaylandConnection();
|
|
}
|
|
|
|
void GenericSceneOpenGLTest::initTestCase()
|
|
{
|
|
qRegisterMetaType<KWin::AbstractClient*>();
|
|
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
|
|
QVERIFY(applicationStartedSpy.isValid());
|
|
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
|
|
QVERIFY(waylandServer()->init(s_socketName));
|
|
|
|
// disable all effects - we don't want to have it interact with the rendering
|
|
auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
|
|
KConfigGroup plugins(config, QStringLiteral("Plugins"));
|
|
const auto builtinNames = EffectLoader().listOfKnownEffects();
|
|
for (QString name : builtinNames) {
|
|
plugins.writeEntry(name + QStringLiteral("Enabled"), false);
|
|
}
|
|
|
|
config->sync();
|
|
kwinApp()->setConfig(config);
|
|
|
|
qputenv("XCURSOR_THEME", QByteArrayLiteral("DMZ-White"));
|
|
qputenv("XCURSOR_SIZE", QByteArrayLiteral("24"));
|
|
qputenv("KWIN_COMPOSE", m_envVariable);
|
|
|
|
kwinApp()->start();
|
|
QVERIFY(applicationStartedSpy.wait());
|
|
QVERIFY(Compositor::self());
|
|
|
|
auto scene = KWin::Compositor::self()->scene();
|
|
QVERIFY(scene);
|
|
QCOMPARE(scene->compositingType(), KWin::OpenGLCompositing);
|
|
QCOMPARE(kwinApp()->platform()->selectedCompositor(), KWin::OpenGLCompositing);
|
|
}
|
|
|
|
void GenericSceneOpenGLTest::testRestart()
|
|
{
|
|
// simple restart of the OpenGL compositor without any windows being shown
|
|
QSignalSpy sceneCreatedSpy(KWin::Compositor::self(), &Compositor::sceneCreated);
|
|
QVERIFY(sceneCreatedSpy.isValid());
|
|
KWin::Compositor::self()->reinitialize();
|
|
if (sceneCreatedSpy.isEmpty()) {
|
|
QVERIFY(sceneCreatedSpy.wait());
|
|
}
|
|
QCOMPARE(sceneCreatedSpy.count(), 1);
|
|
auto scene = KWin::Compositor::self()->scene();
|
|
QVERIFY(scene);
|
|
QCOMPARE(scene->compositingType(), KWin::OpenGLCompositing);
|
|
QCOMPARE(kwinApp()->platform()->selectedCompositor(), KWin::OpenGLCompositing);
|
|
|
|
// trigger a repaint
|
|
KWin::Compositor::self()->addRepaintFull();
|
|
// and wait 100 msec to ensure it's rendered
|
|
// TODO: introduce frameRendered signal in SceneOpenGL
|
|
QTest::qWait(100);
|
|
}
|