2016-06-29 17:22:41 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2016 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
#include "kwin_wayland_test.h"
|
|
|
|
#include "composite.h"
|
|
|
|
#include "effectloader.h"
|
2019-09-24 08:48:08 +00:00
|
|
|
#include "x11client.h"
|
2016-06-29 17:22:41 +00:00
|
|
|
#include "cursor.h"
|
2017-08-11 12:59:09 +00:00
|
|
|
#include "effects.h"
|
2016-06-29 17:22:41 +00:00
|
|
|
#include "platform.h"
|
2019-08-30 21:36:58 +00:00
|
|
|
#include "xdgshellclient.h"
|
2016-06-29 17:22:41 +00:00
|
|
|
#include "wayland_server.h"
|
|
|
|
#include "effect_builtins.h"
|
2017-07-27 15:09:40 +00:00
|
|
|
#include "workspace.h"
|
2016-06-29 17:22:41 +00:00
|
|
|
|
|
|
|
#include <KConfigGroup>
|
|
|
|
|
2016-07-01 08:31:45 +00:00
|
|
|
#include <KWayland/Client/seat.h>
|
|
|
|
#include <KWayland/Client/surface.h>
|
|
|
|
#include <KWayland/Client/pointer.h>
|
2017-07-28 04:50:00 +00:00
|
|
|
#include <KWayland/Server/buffer_interface.h>
|
2017-07-27 19:34:48 +00:00
|
|
|
#include <KWayland/Server/surface_interface.h>
|
2016-07-01 08:31:45 +00:00
|
|
|
|
2016-06-29 17:22:41 +00:00
|
|
|
#include <QPainter>
|
|
|
|
|
2017-07-27 15:09:40 +00:00
|
|
|
#include <netwm.h>
|
|
|
|
#include <xcb/xcb_icccm.h>
|
|
|
|
|
2016-06-29 17:22:41 +00:00
|
|
|
using namespace KWin;
|
|
|
|
static const QString s_socketName = QStringLiteral("wayland_test_kwin_scene_qpainter-0");
|
|
|
|
|
|
|
|
class SceneQPainterTest : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private Q_SLOTS:
|
|
|
|
void initTestCase();
|
2016-07-01 08:31:45 +00:00
|
|
|
void cleanup();
|
2016-06-29 17:22:41 +00:00
|
|
|
void testStartFrame();
|
|
|
|
void testCursorMoving();
|
2016-04-22 12:13:37 +00:00
|
|
|
void testWindow_data();
|
2016-07-01 08:31:45 +00:00
|
|
|
void testWindow();
|
2016-11-04 16:53:09 +00:00
|
|
|
void testWindowScaled();
|
2016-07-15 14:06:09 +00:00
|
|
|
void testCompositorRestart_data();
|
|
|
|
void testCompositorRestart();
|
2017-07-27 15:09:40 +00:00
|
|
|
void testX11Window();
|
2016-06-29 17:22:41 +00:00
|
|
|
};
|
|
|
|
|
2016-07-01 08:31:45 +00:00
|
|
|
void SceneQPainterTest::cleanup()
|
|
|
|
{
|
|
|
|
Test::destroyWaylandConnection();
|
|
|
|
}
|
|
|
|
|
2016-06-29 17:22:41 +00:00
|
|
|
void SceneQPainterTest::initTestCase()
|
|
|
|
{
|
2019-08-30 21:36:58 +00:00
|
|
|
qRegisterMetaType<KWin::XdgShellClient *>();
|
2016-07-01 08:31:45 +00:00
|
|
|
qRegisterMetaType<KWin::AbstractClient*>();
|
2016-06-29 17:22:41 +00:00
|
|
|
QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated);
|
|
|
|
QVERIFY(workspaceCreatedSpy.isValid());
|
|
|
|
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
|
2016-07-04 07:09:03 +00:00
|
|
|
QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit()));
|
2016-06-29 17:22:41 +00:00
|
|
|
|
|
|
|
// 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"));
|
|
|
|
ScriptedEffectLoader loader;
|
|
|
|
const auto builtinNames = BuiltInEffects::availableEffectNames() << loader.listOfKnownEffects();
|
|
|
|
for (QString name : builtinNames) {
|
|
|
|
plugins.writeEntry(name + QStringLiteral("Enabled"), false);
|
|
|
|
}
|
|
|
|
|
|
|
|
config->sync();
|
|
|
|
kwinApp()->setConfig(config);
|
|
|
|
|
2017-09-24 12:51:35 +00:00
|
|
|
if (!QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("icons/DMZ-White/index.theme")).isEmpty()) {
|
|
|
|
qputenv("XCURSOR_THEME", QByteArrayLiteral("DMZ-White"));
|
|
|
|
} else {
|
|
|
|
// might be vanilla-dmz (e.g. Arch, FreeBSD)
|
|
|
|
qputenv("XCURSOR_THEME", QByteArrayLiteral("Vanilla-DMZ"));
|
|
|
|
}
|
2016-06-29 17:22:41 +00:00
|
|
|
qputenv("XCURSOR_SIZE", QByteArrayLiteral("24"));
|
|
|
|
qputenv("KWIN_COMPOSE", QByteArrayLiteral("Q"));
|
|
|
|
|
|
|
|
kwinApp()->start();
|
|
|
|
QVERIFY(workspaceCreatedSpy.wait());
|
|
|
|
QVERIFY(Compositor::self());
|
|
|
|
}
|
|
|
|
|
|
|
|
void SceneQPainterTest::testStartFrame()
|
|
|
|
{
|
|
|
|
// this test verifies that the initial rendering is correct
|
|
|
|
Compositor::self()->addRepaintFull();
|
2017-08-11 12:59:09 +00:00
|
|
|
auto scene = Compositor::self()->scene();
|
2016-06-29 17:22:41 +00:00
|
|
|
QVERIFY(scene);
|
2019-02-16 19:50:46 +00:00
|
|
|
QCOMPARE(kwinApp()->platform()->selectedCompositor(), QPainterCompositing);
|
2016-06-29 17:22:41 +00:00
|
|
|
QSignalSpy frameRenderedSpy(scene, &Scene::frameRendered);
|
|
|
|
QVERIFY(frameRenderedSpy.isValid());
|
|
|
|
QVERIFY(frameRenderedSpy.wait());
|
|
|
|
// now let's render a reference image for comparison
|
|
|
|
QImage referenceImage(QSize(1280, 1024), QImage::Format_RGB32);
|
|
|
|
referenceImage.fill(Qt::black);
|
|
|
|
QPainter p(&referenceImage);
|
|
|
|
const QImage cursorImage = kwinApp()->platform()->softwareCursor();
|
|
|
|
QVERIFY(!cursorImage.isNull());
|
|
|
|
p.drawImage(KWin::Cursor::pos() - kwinApp()->platform()->softwareCursorHotspot(), cursorImage);
|
2017-08-11 12:59:09 +00:00
|
|
|
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer());
|
2016-06-29 17:22:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SceneQPainterTest::testCursorMoving()
|
|
|
|
{
|
|
|
|
// this test verifies that rendering is correct also after moving the cursor a few times
|
2017-08-11 12:59:09 +00:00
|
|
|
auto scene = Compositor::self()->scene();
|
2016-06-29 17:22:41 +00:00
|
|
|
QVERIFY(scene);
|
|
|
|
QSignalSpy frameRenderedSpy(scene, &Scene::frameRendered);
|
|
|
|
QVERIFY(frameRenderedSpy.isValid());
|
|
|
|
KWin::Cursor::setPos(0, 0);
|
|
|
|
QVERIFY(frameRenderedSpy.wait());
|
|
|
|
KWin::Cursor::setPos(10, 0);
|
|
|
|
QVERIFY(frameRenderedSpy.wait());
|
|
|
|
KWin::Cursor::setPos(10, 12);
|
|
|
|
QVERIFY(frameRenderedSpy.wait());
|
|
|
|
KWin::Cursor::setPos(12, 14);
|
|
|
|
QVERIFY(frameRenderedSpy.wait());
|
|
|
|
KWin::Cursor::setPos(50, 60);
|
|
|
|
QVERIFY(frameRenderedSpy.wait());
|
|
|
|
KWin::Cursor::setPos(45, 45);
|
|
|
|
QVERIFY(frameRenderedSpy.wait());
|
|
|
|
// now let's render a reference image for comparison
|
|
|
|
QImage referenceImage(QSize(1280, 1024), QImage::Format_RGB32);
|
|
|
|
referenceImage.fill(Qt::black);
|
|
|
|
QPainter p(&referenceImage);
|
|
|
|
const QImage cursorImage = kwinApp()->platform()->softwareCursor();
|
|
|
|
QVERIFY(!cursorImage.isNull());
|
|
|
|
p.drawImage(QPoint(45, 45) - kwinApp()->platform()->softwareCursorHotspot(), cursorImage);
|
2017-08-11 12:59:09 +00:00
|
|
|
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer());
|
2016-06-29 17:22:41 +00:00
|
|
|
}
|
|
|
|
|
2016-04-22 12:13:37 +00:00
|
|
|
void SceneQPainterTest::testWindow_data()
|
|
|
|
{
|
2019-08-27 15:01:14 +00:00
|
|
|
QTest::addColumn<Test::XdgShellSurfaceType>("type");
|
2016-04-22 12:13:37 +00:00
|
|
|
|
2019-08-27 15:01:14 +00:00
|
|
|
QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6;
|
|
|
|
QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable;
|
2016-04-22 12:13:37 +00:00
|
|
|
}
|
|
|
|
|
2016-07-01 08:31:45 +00:00
|
|
|
void SceneQPainterTest::testWindow()
|
|
|
|
{
|
2016-04-22 12:13:37 +00:00
|
|
|
KWin::Cursor::setPos(45, 45);
|
2016-07-01 08:31:45 +00:00
|
|
|
// this test verifies that a window is rendered correctly
|
|
|
|
using namespace KWayland::Client;
|
2016-12-03 13:31:14 +00:00
|
|
|
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat));
|
2016-07-01 08:31:45 +00:00
|
|
|
QVERIFY(Test::waitForWaylandPointer());
|
|
|
|
QScopedPointer<Surface> s(Test::createSurface());
|
2019-08-27 15:01:14 +00:00
|
|
|
QFETCH(Test::XdgShellSurfaceType, type);
|
|
|
|
QScopedPointer<XdgShellSurface> ss(Test::createXdgShellSurface(type, s.data()));
|
2016-07-01 08:31:45 +00:00
|
|
|
QScopedPointer<Pointer> p(Test::waylandSeat()->createPointer());
|
|
|
|
|
2017-08-11 12:59:09 +00:00
|
|
|
auto scene = KWin::Compositor::self()->scene();
|
2016-07-01 08:31:45 +00:00
|
|
|
QVERIFY(scene);
|
|
|
|
QSignalSpy frameRenderedSpy(scene, &Scene::frameRendered);
|
|
|
|
QVERIFY(frameRenderedSpy.isValid());
|
2016-07-04 06:12:42 +00:00
|
|
|
|
|
|
|
// now let's map the window
|
|
|
|
QVERIFY(Test::renderAndWaitForShown(s.data(), QSize(200, 300), Qt::blue));
|
|
|
|
// which should trigger a frame
|
|
|
|
if (frameRenderedSpy.isEmpty()) {
|
|
|
|
QVERIFY(frameRenderedSpy.wait());
|
|
|
|
}
|
2018-05-01 13:33:33 +00:00
|
|
|
// we didn't set a cursor image on the surface yet, so it should be just black + window and previous cursor
|
2016-07-01 08:31:45 +00:00
|
|
|
QImage referenceImage(QSize(1280, 1024), QImage::Format_RGB32);
|
|
|
|
referenceImage.fill(Qt::black);
|
|
|
|
QPainter painter(&referenceImage);
|
|
|
|
painter.fillRect(0, 0, 200, 300, Qt::blue);
|
|
|
|
|
|
|
|
// now let's set a cursor image
|
|
|
|
QScopedPointer<Surface> cs(Test::createSurface());
|
|
|
|
QVERIFY(!cs.isNull());
|
|
|
|
Test::render(cs.data(), QSize(10, 10), Qt::red);
|
|
|
|
p->setCursor(cs.data(), QPoint(5, 5));
|
|
|
|
QVERIFY(frameRenderedSpy.wait());
|
|
|
|
painter.fillRect(KWin::Cursor::pos().x() - 5, KWin::Cursor::pos().y() - 5, 10, 10, Qt::red);
|
2017-08-11 12:59:09 +00:00
|
|
|
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer());
|
2016-07-01 08:31:45 +00:00
|
|
|
// let's move the cursor again
|
|
|
|
KWin::Cursor::setPos(10, 10);
|
|
|
|
QVERIFY(frameRenderedSpy.wait());
|
|
|
|
painter.fillRect(0, 0, 200, 300, Qt::blue);
|
|
|
|
painter.fillRect(5, 5, 10, 10, Qt::red);
|
2017-08-11 12:59:09 +00:00
|
|
|
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer());
|
2016-07-01 08:31:45 +00:00
|
|
|
}
|
|
|
|
|
2016-11-04 16:53:09 +00:00
|
|
|
void SceneQPainterTest::testWindowScaled()
|
|
|
|
{
|
|
|
|
KWin::Cursor::setPos(10, 10);
|
|
|
|
// this test verifies that a window is rendered correctly
|
|
|
|
using namespace KWayland::Client;
|
2017-05-01 15:10:42 +00:00
|
|
|
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat));
|
2016-11-04 16:53:09 +00:00
|
|
|
QVERIFY(Test::waitForWaylandPointer());
|
|
|
|
QScopedPointer<Surface> s(Test::createSurface());
|
2019-08-27 15:01:14 +00:00
|
|
|
QScopedPointer<XdgShellSurface> ss(Test::createXdgShellStableSurface(s.data()));
|
2016-11-04 16:53:09 +00:00
|
|
|
QScopedPointer<Pointer> p(Test::waylandSeat()->createPointer());
|
2018-05-01 13:33:33 +00:00
|
|
|
QSignalSpy pointerEnteredSpy(p.data(), &Pointer::entered);
|
|
|
|
QVERIFY(pointerEnteredSpy.isValid());
|
2016-11-04 16:53:09 +00:00
|
|
|
|
2017-08-11 12:59:09 +00:00
|
|
|
auto scene = KWin::Compositor::self()->scene();
|
2016-11-04 16:53:09 +00:00
|
|
|
QVERIFY(scene);
|
|
|
|
QSignalSpy frameRenderedSpy(scene, &Scene::frameRendered);
|
|
|
|
QVERIFY(frameRenderedSpy.isValid());
|
|
|
|
|
|
|
|
// now let's set a cursor image
|
|
|
|
QScopedPointer<Surface> cs(Test::createSurface());
|
|
|
|
QVERIFY(!cs.isNull());
|
|
|
|
Test::render(cs.data(), QSize(10, 10), Qt::red);
|
|
|
|
|
|
|
|
// now let's map the window
|
|
|
|
s->setScale(2);
|
2017-07-31 14:12:37 +00:00
|
|
|
|
|
|
|
//draw a blue square@400x600 with red rectangle@200x200 in the middle
|
|
|
|
const QSize size(400,600);
|
2017-08-30 09:01:55 +00:00
|
|
|
QImage img(size, QImage::Format_ARGB32_Premultiplied);
|
2017-07-31 14:12:37 +00:00
|
|
|
img.fill(Qt::blue);
|
|
|
|
QPainter surfacePainter(&img);
|
|
|
|
surfacePainter.fillRect(200,300,200,200, Qt::red);
|
|
|
|
|
|
|
|
//add buffer
|
|
|
|
Test::render(s.data(), img);
|
2018-05-01 13:33:33 +00:00
|
|
|
QVERIFY(pointerEnteredSpy.wait());
|
|
|
|
p->setCursor(cs.data(), QPoint(5, 5));
|
2016-11-04 16:53:09 +00:00
|
|
|
|
|
|
|
// which should trigger a frame
|
2018-05-01 13:33:33 +00:00
|
|
|
QVERIFY(frameRenderedSpy.wait());
|
2016-11-04 16:53:09 +00:00
|
|
|
QImage referenceImage(QSize(1280, 1024), QImage::Format_RGB32);
|
|
|
|
referenceImage.fill(Qt::black);
|
|
|
|
QPainter painter(&referenceImage);
|
|
|
|
painter.fillRect(0, 0, 200, 300, Qt::blue);
|
2017-07-31 14:12:37 +00:00
|
|
|
painter.fillRect(100, 150, 100, 100, Qt::red);
|
2016-11-04 16:53:09 +00:00
|
|
|
painter.fillRect(5, 5, 10, 10, Qt::red); //cursor
|
|
|
|
|
2017-08-11 12:59:09 +00:00
|
|
|
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer());
|
2016-11-04 16:53:09 +00:00
|
|
|
}
|
|
|
|
|
2016-07-15 14:06:09 +00:00
|
|
|
void SceneQPainterTest::testCompositorRestart_data()
|
|
|
|
{
|
2019-08-27 15:01:14 +00:00
|
|
|
QTest::addColumn<Test::XdgShellSurfaceType>("type");
|
2016-07-15 14:06:09 +00:00
|
|
|
|
2019-08-27 15:01:14 +00:00
|
|
|
QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6;
|
|
|
|
QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable;
|
2016-07-15 14:06:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SceneQPainterTest::testCompositorRestart()
|
|
|
|
{
|
|
|
|
// this test verifies that the compositor/SceneQPainter survive a restart of the compositor and still render correctly
|
|
|
|
KWin::Cursor::setPos(400, 400);
|
|
|
|
|
|
|
|
// first create a window
|
|
|
|
using namespace KWayland::Client;
|
2016-12-03 13:31:14 +00:00
|
|
|
QVERIFY(Test::setupWaylandConnection());
|
2016-07-15 14:06:09 +00:00
|
|
|
QScopedPointer<Surface> s(Test::createSurface());
|
2019-08-27 15:01:14 +00:00
|
|
|
QFETCH(Test::XdgShellSurfaceType, type);
|
|
|
|
QScopedPointer<XdgShellSurface> ss(Test::createXdgShellSurface(type, s.data()));
|
2016-07-15 14:06:09 +00:00
|
|
|
QVERIFY(Test::renderAndWaitForShown(s.data(), QSize(200, 300), Qt::blue));
|
|
|
|
|
|
|
|
// now let's try to reinitialize the compositing scene
|
|
|
|
auto oldScene = KWin::Compositor::self()->scene();
|
|
|
|
QVERIFY(oldScene);
|
|
|
|
QSignalSpy sceneCreatedSpy(KWin::Compositor::self(), &KWin::Compositor::sceneCreated);
|
|
|
|
QVERIFY(sceneCreatedSpy.isValid());
|
2019-07-02 20:30:27 +00:00
|
|
|
KWin::Compositor::self()->reinitialize();
|
2016-07-15 14:06:09 +00:00
|
|
|
if (sceneCreatedSpy.isEmpty()) {
|
|
|
|
QVERIFY(sceneCreatedSpy.wait());
|
|
|
|
}
|
|
|
|
QCOMPARE(sceneCreatedSpy.count(), 1);
|
2017-08-11 12:59:09 +00:00
|
|
|
auto scene = KWin::Compositor::self()->scene();
|
2016-07-15 14:06:09 +00:00
|
|
|
QVERIFY(scene);
|
|
|
|
|
|
|
|
// this should directly trigger a frame
|
|
|
|
KWin::Compositor::self()->addRepaintFull();
|
|
|
|
QSignalSpy frameRenderedSpy(scene, &Scene::frameRendered);
|
|
|
|
QVERIFY(frameRenderedSpy.isValid());
|
|
|
|
QVERIFY(frameRenderedSpy.wait());
|
|
|
|
|
|
|
|
// render reference image
|
|
|
|
QImage referenceImage(QSize(1280, 1024), QImage::Format_RGB32);
|
|
|
|
referenceImage.fill(Qt::black);
|
|
|
|
QPainter painter(&referenceImage);
|
|
|
|
painter.fillRect(0, 0, 200, 300, Qt::blue);
|
|
|
|
const QImage cursorImage = kwinApp()->platform()->softwareCursor();
|
|
|
|
QVERIFY(!cursorImage.isNull());
|
|
|
|
painter.drawImage(QPoint(400, 400) - kwinApp()->platform()->softwareCursorHotspot(), cursorImage);
|
2017-08-11 12:59:09 +00:00
|
|
|
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer());
|
2016-07-15 14:06:09 +00:00
|
|
|
}
|
|
|
|
|
2017-07-27 15:09:40 +00:00
|
|
|
struct XcbConnectionDeleter
|
|
|
|
{
|
|
|
|
static inline void cleanup(xcb_connection_t *pointer)
|
|
|
|
{
|
|
|
|
xcb_disconnect(pointer);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void SceneQPainterTest::testX11Window()
|
|
|
|
{
|
|
|
|
// this test verifies the condition of BUG: 382748
|
|
|
|
|
|
|
|
// create X11 window
|
|
|
|
QSignalSpy windowAddedSpy(effects, &EffectsHandler::windowAdded);
|
|
|
|
QVERIFY(windowAddedSpy.isValid());
|
|
|
|
|
|
|
|
// create an xcb window
|
|
|
|
QScopedPointer<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr));
|
|
|
|
QVERIFY(!xcb_connection_has_error(c.data()));
|
|
|
|
const QRect windowGeometry(0, 0, 100, 200);
|
|
|
|
xcb_window_t w = xcb_generate_id(c.data());
|
|
|
|
uint32_t value = defaultScreen()->white_pixel;
|
|
|
|
xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, w, rootWindow(),
|
|
|
|
windowGeometry.x(),
|
|
|
|
windowGeometry.y(),
|
|
|
|
windowGeometry.width(),
|
|
|
|
windowGeometry.height(),
|
|
|
|
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, XCB_CW_BACK_PIXEL, &value);
|
|
|
|
xcb_size_hints_t hints;
|
|
|
|
memset(&hints, 0, sizeof(hints));
|
|
|
|
xcb_icccm_size_hints_set_position(&hints, 1, windowGeometry.x(), windowGeometry.y());
|
|
|
|
xcb_icccm_size_hints_set_size(&hints, 1, windowGeometry.width(), windowGeometry.height());
|
|
|
|
xcb_icccm_set_wm_normal_hints(c.data(), w, &hints);
|
|
|
|
xcb_map_window(c.data(), w);
|
|
|
|
xcb_flush(c.data());
|
|
|
|
|
|
|
|
|
|
|
|
// we should get a client for it
|
|
|
|
QSignalSpy windowCreatedSpy(workspace(), &Workspace::clientAdded);
|
|
|
|
QVERIFY(windowCreatedSpy.isValid());
|
|
|
|
QVERIFY(windowCreatedSpy.wait());
|
2019-09-24 08:48:08 +00:00
|
|
|
X11Client *client = windowCreatedSpy.first().first().value<X11Client *>();
|
2017-07-27 15:09:40 +00:00
|
|
|
QVERIFY(client);
|
|
|
|
QCOMPARE(client->window(), w);
|
|
|
|
QCOMPARE(client->clientSize(), QSize(100, 200));
|
2017-07-27 18:36:52 +00:00
|
|
|
if (!client->surface()) {
|
|
|
|
// wait for surface
|
|
|
|
QSignalSpy surfaceChangedSpy(client, &Toplevel::surfaceChanged);
|
|
|
|
QVERIFY(surfaceChangedSpy.isValid());
|
|
|
|
QVERIFY(surfaceChangedSpy.wait());
|
|
|
|
}
|
|
|
|
QVERIFY(client->surface());
|
2017-07-27 19:34:48 +00:00
|
|
|
QTRY_VERIFY(client->surface()->buffer());
|
2019-09-27 10:01:10 +00:00
|
|
|
QTRY_COMPARE(client->surface()->buffer()->data().size(), client->size());
|
2017-07-28 19:17:59 +00:00
|
|
|
QImage compareImage(client->clientSize(), QImage::Format_RGB32);
|
|
|
|
compareImage.fill(Qt::white);
|
|
|
|
QCOMPARE(client->surface()->buffer()->data().copy(QRect(client->clientPos(), client->clientSize())), compareImage);
|
2017-07-27 15:09:40 +00:00
|
|
|
|
|
|
|
// enough time for rendering the window
|
|
|
|
QTest::qWait(100);
|
|
|
|
|
2017-08-11 12:59:09 +00:00
|
|
|
auto scene = KWin::Compositor::self()->scene();
|
2017-07-27 15:09:40 +00:00
|
|
|
QVERIFY(scene);
|
|
|
|
|
|
|
|
// this should directly trigger a frame
|
|
|
|
KWin::Compositor::self()->addRepaintFull();
|
|
|
|
QSignalSpy frameRenderedSpy(scene, &Scene::frameRendered);
|
|
|
|
QVERIFY(frameRenderedSpy.isValid());
|
|
|
|
QVERIFY(frameRenderedSpy.wait());
|
|
|
|
|
|
|
|
const QPoint startPos = client->pos() + client->clientPos();
|
2017-08-11 12:59:09 +00:00
|
|
|
auto image = scene->qpainterRenderBuffer();
|
2017-07-28 19:17:59 +00:00
|
|
|
QCOMPARE(image->copy(QRect(startPos, client->clientSize())), compareImage);
|
2017-07-27 15:09:40 +00:00
|
|
|
|
|
|
|
// and destroy the window again
|
|
|
|
xcb_unmap_window(c.data(), w);
|
|
|
|
xcb_flush(c.data());
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
QSignalSpy windowClosedSpy(client, &X11Client::windowClosed);
|
2017-07-27 15:09:40 +00:00
|
|
|
QVERIFY(windowClosedSpy.isValid());
|
|
|
|
QVERIFY(windowClosedSpy.wait());
|
|
|
|
xcb_destroy_window(c.data(), w);
|
|
|
|
c.reset();
|
|
|
|
}
|
|
|
|
|
2016-06-29 17:22:41 +00:00
|
|
|
WAYLANDTEST_MAIN(SceneQPainterTest)
|
|
|
|
#include "scene_qpainter_test.moc"
|