19#include <KWayland/Client/keyboard.h>
20#include <KWayland/Client/seat.h>
22#include <linux/input.h>
27static const QString s_socketName = QStringLiteral(
"wayland_test_kwin_bounce_keys-0");
39void BounceKeysTest::initTestCase()
41 KConfig kaccessConfig(
"kaccessrc");
42 kaccessConfig.group(QStringLiteral(
"Keyboard")).writeEntry(
"BounceKeys",
true);
43 kaccessConfig.group(QStringLiteral(
"Keyboard")).writeEntry(
"BounceKeysDelay", 200);
46 qRegisterMetaType<KWin::Window *>();
50 QRect(0, 0, 1280, 1024),
51 QRect(1280, 0, 1280, 1024),
54 qputenv(
"XKB_DEFAULT_RULES",
"evdev");
57 QVERIFY(applicationStartedSpy.wait());
60void BounceKeysTest::init()
66void BounceKeysTest::cleanup()
71void BounceKeysTest::testBounce()
73 std::unique_ptr<KWayland::Client::Keyboard> keyboard(
Test::waylandSeat()->createKeyboard());
76 QVERIFY(surface !=
nullptr);
78 QVERIFY(shellSurface !=
nullptr);
80 QVERIFY(waylandWindow);
83 QSignalSpy enteredSpy(keyboard.get(), &KWayland::Client::Keyboard::entered);
84 QVERIFY(enteredSpy.wait());
86 QSignalSpy keySpy(keyboard.get(), &KWayland::Client::Keyboard::keyChanged);
87 QVERIFY(keySpy.isValid());
89 quint32 timestamp = 0;
93 QVERIFY(keySpy.wait());
94 QCOMPARE(keySpy.first()[0], KEY_A);
95 QCOMPARE(keySpy.first()[1].value<KWayland::Client::Keyboard::KeyState>(), KWayland::Client::Keyboard::KeyState::Pressed);
99 QVERIFY(keySpy.wait());
100 QCOMPARE(keySpy.first()[0], KEY_A);
101 QCOMPARE(keySpy.first()[1].value<KWayland::Client::Keyboard::KeyState>(), KWayland::Client::Keyboard::KeyState::Released);
107 QVERIFY(!keySpy.wait(100));
113 QVERIFY(keySpy.wait());
114 QCOMPARE(keySpy.first()[0], KEY_A);
115 QCOMPARE(keySpy.first()[1].value<KWayland::Client::Keyboard::KeyState>(), KWayland::Client::Keyboard::KeyState::Pressed);
119 QVERIFY(keySpy.wait());
120 QCOMPARE(keySpy.first()[0], KEY_A);
121 QCOMPARE(keySpy.first()[1].value<KWayland::Client::Keyboard::KeyState>(), KWayland::Client::Keyboard::KeyState::Released);
127#include "bounce_keys_test.moc"
#define WAYLANDTEST_MAIN(TestObject)
Window * renderAndWaitForShown(KWayland::Client::Surface *surface, const QSize &size, const QColor &color, const QImage::Format &format=QImage::Format_ARGB32, int timeout=5000)
void keyboardKeyReleased(quint32 key, quint32 time)
void destroyWaylandConnection()
void setOutputConfig(const QList< QRect > &geometries)
void keyboardKeyPressed(quint32 key, quint32 time)
bool waitForWaylandKeyboard()
bool setupWaylandConnection(AdditionalWaylandInterfaces flags=AdditionalWaylandInterfaces())
KWayland::Client::Seat * waylandSeat()
std::unique_ptr< KWayland::Client::Surface > createSurface()
XdgToplevel * createXdgToplevelSurface(KWayland::Client::Surface *surface, QObject *parent=nullptr)
WaylandServer * waylandServer()