Commit f67daa07 authored by Andrey Butirsky's avatar Andrey Butirsky Committed by David Edmundson

keyboard_interface: Always update modifiers cache

We send modifiers to the active client when they change, and when we
focus an existing client we send the cached state.

For this reason it's important we always update our internal store of
modifiers regardless of whether a surface is currently active.

Unit test is adopted accordingly.

BUG: 429930
parent 725e97aa
Pipeline #44129 passed with stage
in 5 minutes and 51 seconds
......@@ -1489,6 +1489,9 @@ void TestWaylandSeat::testKeyboard()
m_seatInterface->setHasKeyboard(true);
QVERIFY(keyboardSpy.wait());
// update modifiers before any surface focused
m_seatInterface->keyboard()->updateModifiers(4, 3, 2, 1);
// create the surface
QSignalSpy surfaceCreatedSpy(m_compositorInterface, SIGNAL(surfaceCreated(KWaylandServer::SurfaceInterface*)));
QVERIFY(surfaceCreatedSpy.isValid());
......@@ -1552,10 +1555,10 @@ void TestWaylandSeat::testKeyboard()
// we get the modifiers sent after the enter
QVERIFY(modifierSpy.wait());
QCOMPARE(modifierSpy.count(), 1);
QCOMPARE(modifierSpy.first().at(0).value<quint32>(), quint32(0));
QCOMPARE(modifierSpy.first().at(1).value<quint32>(), quint32(0));
QCOMPARE(modifierSpy.first().at(2).value<quint32>(), quint32(0));
QCOMPARE(modifierSpy.first().at(3).value<quint32>(), quint32(0));
QCOMPARE(modifierSpy.first().at(0).value<quint32>(), quint32(4));
QCOMPARE(modifierSpy.first().at(1).value<quint32>(), quint32(3));
QCOMPARE(modifierSpy.first().at(2).value<quint32>(), quint32(2));
QCOMPARE(modifierSpy.first().at(3).value<quint32>(), quint32(1));
QCOMPARE(enteredSpy.count(), 1);
// TODO: get through API
QCOMPARE(enteredSpy.first().first().value<quint32>(), m_display->serial() - 1);
......
......@@ -220,9 +220,6 @@ void KeyboardInterface::keyReleased(quint32 key)
void KeyboardInterface::updateModifiers(quint32 depressed, quint32 latched, quint32 locked, quint32 group)
{
if (!d->focusedSurface) {
return;
}
bool changed = false;
#define UPDATE( value ) \
if (d->modifiers.value != value) { \
......@@ -236,6 +233,11 @@ void KeyboardInterface::updateModifiers(quint32 depressed, quint32 latched, quin
if (!changed) {
return;
}
if (!d->focusedSurface) {
return;
}
d->modifiers.serial = d->seat->d_func()->nextSerial();
d->sendModifiers(depressed, latched, locked, group, d->modifiers.serial);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment