2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2018-03-04 10:23:28 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2018 Martin Flöser <mgraesslin@kde.org>
|
2018-03-04 10:23:28 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2018-03-04 10:23:28 +00:00
|
|
|
#include "kwin_wayland_test.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
|
2018-03-04 10:23:28 +00:00
|
|
|
#include "composite.h"
|
|
|
|
#include "cursor.h"
|
|
|
|
#include "effectloader.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
#include "effects.h"
|
2018-03-04 10:23:28 +00:00
|
|
|
#include "platform.h"
|
2021-11-10 10:34:18 +00:00
|
|
|
#include "renderbackend.h"
|
2018-03-04 10:23:28 +00:00
|
|
|
#include "wayland_server.h"
|
|
|
|
#include "workspace.h"
|
2022-04-22 17:54:31 +00:00
|
|
|
#include "x11window.h"
|
2018-03-04 10:23:28 +00:00
|
|
|
|
|
|
|
#include <KConfigGroup>
|
|
|
|
|
|
|
|
#include <KWayland/Client/connection_thread.h>
|
|
|
|
#include <KWayland/Client/registry.h>
|
|
|
|
#include <KWayland/Client/slide.h>
|
2022-03-23 10:13:38 +00:00
|
|
|
#include <KWayland/Client/surface.h>
|
2018-03-04 10:23:28 +00:00
|
|
|
|
|
|
|
#include <netwm.h>
|
|
|
|
#include <xcb/xcb_icccm.h>
|
|
|
|
|
|
|
|
using namespace KWin;
|
|
|
|
static const QString s_socketName = QStringLiteral("wayland_test_effects_wobbly_shade-0");
|
|
|
|
|
|
|
|
class WobblyWindowsShadeTest : public QObject
|
|
|
|
{
|
2022-03-23 10:13:38 +00:00
|
|
|
Q_OBJECT
|
2018-03-04 10:23:28 +00:00
|
|
|
private Q_SLOTS:
|
|
|
|
void initTestCase();
|
|
|
|
void init();
|
|
|
|
void cleanup();
|
|
|
|
|
|
|
|
void testShadeMove();
|
|
|
|
};
|
|
|
|
|
|
|
|
void WobblyWindowsShadeTest::initTestCase()
|
|
|
|
{
|
2022-04-22 17:39:12 +00:00
|
|
|
qRegisterMetaType<KWin::Window *>();
|
2022-03-23 10:13:38 +00:00
|
|
|
qRegisterMetaType<KWin::Effect *>();
|
2020-07-07 09:32:29 +00:00
|
|
|
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
|
|
|
|
QVERIFY(applicationStartedSpy.isValid());
|
2018-03-04 10:23:28 +00:00
|
|
|
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
|
2020-12-09 13:06:15 +00:00
|
|
|
QVERIFY(waylandServer()->init(s_socketName));
|
2018-03-04 10:23:28 +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"));
|
2021-10-09 15:38:14 +00:00
|
|
|
const auto builtinNames = EffectLoader().listOfKnownEffects();
|
2018-03-04 10:23:28 +00:00
|
|
|
for (QString name : builtinNames) {
|
|
|
|
plugins.writeEntry(name + QStringLiteral("Enabled"), false);
|
|
|
|
}
|
|
|
|
|
|
|
|
config->sync();
|
|
|
|
kwinApp()->setConfig(config);
|
|
|
|
|
|
|
|
qputenv("KWIN_COMPOSE", QByteArrayLiteral("O2"));
|
|
|
|
qputenv("KWIN_EFFECTS_FORCE_ANIMATIONS", "1");
|
|
|
|
kwinApp()->start();
|
2020-07-07 09:32:29 +00:00
|
|
|
QVERIFY(applicationStartedSpy.wait());
|
2018-03-04 10:23:28 +00:00
|
|
|
QVERIFY(Compositor::self());
|
2019-01-06 15:34:10 +00:00
|
|
|
|
2021-11-10 10:34:18 +00:00
|
|
|
QCOMPARE(Compositor::self()->backend()->compositingType(), KWin::OpenGLCompositing);
|
2018-03-04 10:23:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WobblyWindowsShadeTest::init()
|
|
|
|
{
|
|
|
|
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Decoration));
|
|
|
|
}
|
|
|
|
|
|
|
|
void WobblyWindowsShadeTest::cleanup()
|
|
|
|
{
|
|
|
|
Test::destroyWaylandConnection();
|
2019-01-19 14:26:34 +00:00
|
|
|
|
|
|
|
auto effectsImpl = static_cast<EffectsHandlerImpl *>(effects);
|
|
|
|
effectsImpl->unloadAllEffects();
|
|
|
|
QVERIFY(effectsImpl->loadedEffects().isEmpty());
|
2018-03-04 10:23:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct XcbConnectionDeleter
|
|
|
|
{
|
|
|
|
static inline void cleanup(xcb_connection_t *pointer)
|
|
|
|
{
|
|
|
|
xcb_disconnect(pointer);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void WobblyWindowsShadeTest::testShadeMove()
|
|
|
|
{
|
|
|
|
// this test simulates the condition from BUG 390953
|
2022-03-23 10:13:38 +00:00
|
|
|
EffectsHandlerImpl *e = static_cast<EffectsHandlerImpl *>(effects);
|
2021-10-12 11:06:31 +00:00
|
|
|
QVERIFY(e->loadEffect(QStringLiteral("wobblywindows")));
|
|
|
|
QVERIFY(e->isEffectLoaded(QStringLiteral("wobblywindows")));
|
2018-03-04 10:23:28 +00:00
|
|
|
|
|
|
|
QScopedPointer<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr));
|
|
|
|
QVERIFY(!xcb_connection_has_error(c.data()));
|
|
|
|
const QRect windowGeometry(0, 0, 100, 200);
|
2022-04-23 19:51:16 +00:00
|
|
|
xcb_window_t windowId = xcb_generate_id(c.data());
|
|
|
|
xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, windowId, rootWindow(),
|
2018-03-04 10:23:28 +00:00
|
|
|
windowGeometry.x(),
|
|
|
|
windowGeometry.y(),
|
|
|
|
windowGeometry.width(),
|
|
|
|
windowGeometry.height(),
|
|
|
|
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr);
|
|
|
|
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());
|
2022-04-23 19:51:16 +00:00
|
|
|
xcb_icccm_set_wm_normal_hints(c.data(), windowId, &hints);
|
|
|
|
xcb_map_window(c.data(), windowId);
|
2018-03-04 10:23:28 +00:00
|
|
|
xcb_flush(c.data());
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// we should get a window for it
|
2022-04-23 08:33:23 +00:00
|
|
|
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
|
2018-03-04 10:23:28 +00:00
|
|
|
QVERIFY(windowCreatedSpy.isValid());
|
|
|
|
QVERIFY(windowCreatedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
X11Window *window = windowCreatedSpy.first().first().value<X11Window *>();
|
|
|
|
QVERIFY(window);
|
|
|
|
QCOMPARE(window->window(), windowId);
|
|
|
|
QVERIFY(window->isDecorated());
|
|
|
|
QVERIFY(window->isShadeable());
|
|
|
|
QVERIFY(!window->isShade());
|
|
|
|
QVERIFY(window->isActive());
|
|
|
|
|
|
|
|
QSignalSpy windowShownSpy(window, &Window::windowShown);
|
2018-03-04 10:23:28 +00:00
|
|
|
QVERIFY(windowShownSpy.isValid());
|
|
|
|
QVERIFY(windowShownSpy.wait());
|
|
|
|
|
|
|
|
// now shade the window
|
|
|
|
workspace()->slotWindowShade();
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window->isShade());
|
2018-03-04 10:23:28 +00:00
|
|
|
|
|
|
|
QSignalSpy windowStartUserMovedResizedSpy(e, &EffectsHandler::windowStartUserMovedResized);
|
|
|
|
QVERIFY(windowStartUserMovedResizedSpy.isValid());
|
|
|
|
|
|
|
|
// begin move
|
2022-04-23 08:33:23 +00:00
|
|
|
QVERIFY(workspace()->moveResizeWindow() == nullptr);
|
2022-04-23 19:51:16 +00:00
|
|
|
QCOMPARE(window->isInteractiveMove(), false);
|
2018-03-04 10:23:28 +00:00
|
|
|
workspace()->slotWindowMove();
|
2022-04-23 19:51:16 +00:00
|
|
|
QCOMPARE(workspace()->moveResizeWindow(), window);
|
|
|
|
QCOMPARE(window->isInteractiveMove(), true);
|
2018-03-04 10:23:28 +00:00
|
|
|
QCOMPARE(windowStartUserMovedResizedSpy.count(), 1);
|
|
|
|
|
|
|
|
// wait for frame rendered
|
|
|
|
QTest::qWait(100);
|
|
|
|
|
|
|
|
// send some key events, not going through input redirection
|
2022-04-23 19:51:16 +00:00
|
|
|
window->keyPressEvent(Qt::Key_Right);
|
|
|
|
window->updateInteractiveMoveResize(KWin::Cursors::self()->mouse()->pos());
|
2018-03-04 10:23:28 +00:00
|
|
|
|
|
|
|
// wait for frame rendered
|
|
|
|
QTest::qWait(100);
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
window->keyPressEvent(Qt::Key_Right);
|
|
|
|
window->updateInteractiveMoveResize(KWin::Cursors::self()->mouse()->pos());
|
2018-03-04 10:23:28 +00:00
|
|
|
|
|
|
|
// wait for frame rendered
|
|
|
|
QTest::qWait(100);
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
window->keyPressEvent(Qt::Key_Down | Qt::ALT);
|
|
|
|
window->updateInteractiveMoveResize(KWin::Cursors::self()->mouse()->pos());
|
2018-03-04 10:23:28 +00:00
|
|
|
|
|
|
|
// wait for frame rendered
|
|
|
|
QTest::qWait(100);
|
|
|
|
|
|
|
|
// let's end
|
2022-04-23 19:51:16 +00:00
|
|
|
window->keyPressEvent(Qt::Key_Enter);
|
2018-03-04 10:23:28 +00:00
|
|
|
|
|
|
|
// wait for frame rendered
|
|
|
|
QTest::qWait(100);
|
|
|
|
}
|
|
|
|
|
|
|
|
WAYLANDTEST_MAIN(WobblyWindowsShadeTest)
|
|
|
|
#include "wobbly_shade_test.moc"
|