2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2017-07-06 17:07:01 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2017 Martin Flöser <mgraesslin@kde.org>
|
2017-07-06 17:07:01 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2017-07-06 17:07:01 +00:00
|
|
|
#include "kwin_wayland_test.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
|
2022-08-29 07:55:49 +00:00
|
|
|
#include "core/output.h"
|
2022-11-05 10:43:41 +00:00
|
|
|
#include "core/outputbackend.h"
|
2017-07-06 17:07:01 +00:00
|
|
|
#include "pointer_input.h"
|
|
|
|
#include "useractions.h"
|
|
|
|
#include "wayland_server.h"
|
2022-04-22 17:39:12 +00:00
|
|
|
#include "window.h"
|
2017-07-06 17:07:01 +00:00
|
|
|
#include "workspace.h"
|
|
|
|
|
|
|
|
#include <KWayland/Client/compositor.h>
|
|
|
|
#include <KWayland/Client/keyboard.h>
|
|
|
|
#include <KWayland/Client/pointer.h>
|
|
|
|
#include <KWayland/Client/seat.h>
|
|
|
|
#include <KWayland/Client/shm_pool.h>
|
|
|
|
#include <KWayland/Client/surface.h>
|
|
|
|
#include <KWayland/Client/touch.h>
|
|
|
|
|
|
|
|
#include <linux/input.h>
|
|
|
|
|
|
|
|
using namespace KWin;
|
|
|
|
|
|
|
|
static const QString s_socketName = QStringLiteral("wayland_test_kwin_dont_crash_useractions_menu-0");
|
|
|
|
|
|
|
|
class TestDontCrashUseractionsMenu : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private Q_SLOTS:
|
|
|
|
void initTestCase();
|
|
|
|
void init();
|
|
|
|
void cleanup();
|
|
|
|
|
|
|
|
void testShowHideShowUseractionsMenu();
|
|
|
|
};
|
|
|
|
|
|
|
|
void TestDontCrashUseractionsMenu::initTestCase()
|
|
|
|
{
|
2022-04-22 17:39:12 +00:00
|
|
|
qRegisterMetaType<KWin::Window *>();
|
2020-07-07 09:32:29 +00:00
|
|
|
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
|
2020-12-09 13:06:15 +00:00
|
|
|
QVERIFY(waylandServer()->init(s_socketName));
|
2023-05-08 10:16:00 +00:00
|
|
|
Test::setOutputConfig({
|
|
|
|
QRect(0, 0, 1280, 1024),
|
|
|
|
QRect(1280, 0, 1280, 1024),
|
|
|
|
});
|
2017-07-06 17:07:01 +00:00
|
|
|
|
2017-07-08 08:47:17 +00:00
|
|
|
// force style to breeze as that's the one which triggered the crash
|
|
|
|
QVERIFY(kwinApp()->setStyle(QStringLiteral("breeze")));
|
|
|
|
|
2017-07-06 17:07:01 +00:00
|
|
|
kwinApp()->start();
|
2020-07-07 09:32:29 +00:00
|
|
|
QVERIFY(applicationStartedSpy.wait());
|
2022-07-11 10:41:15 +00:00
|
|
|
const auto outputs = workspace()->outputs();
|
2021-08-31 07:03:05 +00:00
|
|
|
QCOMPARE(outputs.count(), 2);
|
|
|
|
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024));
|
2017-07-06 17:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestDontCrashUseractionsMenu::init()
|
|
|
|
{
|
|
|
|
QVERIFY(Test::setupWaylandConnection());
|
|
|
|
|
2021-08-28 18:58:29 +00:00
|
|
|
workspace()->setActiveOutput(QPoint(640, 512));
|
2023-02-09 13:07:56 +00:00
|
|
|
KWin::input()->pointer()->warp(QPoint(640, 512));
|
2017-07-06 17:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestDontCrashUseractionsMenu::cleanup()
|
|
|
|
{
|
|
|
|
Test::destroyWaylandConnection();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestDontCrashUseractionsMenu::testShowHideShowUseractionsMenu()
|
|
|
|
{
|
|
|
|
// this test creates the condition of BUG 382063
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface1(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface1(Test::createXdgToplevelSurface(surface1.get()));
|
|
|
|
auto window = Test::renderAndWaitForShown(surface1.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window);
|
2017-07-06 17:07:01 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
workspace()->showWindowMenu(QRect(), window);
|
2017-07-06 17:07:01 +00:00
|
|
|
auto userActionsMenu = workspace()->userActionsMenu();
|
|
|
|
QTRY_VERIFY(userActionsMenu->isShown());
|
2022-04-23 08:33:23 +00:00
|
|
|
QVERIFY(userActionsMenu->hasWindow());
|
2017-07-06 17:07:01 +00:00
|
|
|
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::keyboardKeyPressed(KEY_ESC, 0);
|
|
|
|
Test::keyboardKeyReleased(KEY_ESC, 1);
|
2017-07-06 17:07:01 +00:00
|
|
|
QTRY_VERIFY(!userActionsMenu->isShown());
|
2022-04-23 08:33:23 +00:00
|
|
|
QVERIFY(!userActionsMenu->hasWindow());
|
2017-07-06 17:07:01 +00:00
|
|
|
|
|
|
|
// and show again, this triggers BUG 382063
|
2022-04-23 19:51:16 +00:00
|
|
|
workspace()->showWindowMenu(QRect(), window);
|
2017-07-06 17:07:01 +00:00
|
|
|
QTRY_VERIFY(userActionsMenu->isShown());
|
2022-04-23 08:33:23 +00:00
|
|
|
QVERIFY(userActionsMenu->hasWindow());
|
2017-07-06 17:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WAYLANDTEST_MAIN(TestDontCrashUseractionsMenu)
|
|
|
|
#include "dont_crash_useractions_menu.moc"
|