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
This commit is contained in:
Andrey Butirsky 2020-12-07 19:40:14 +03:00 committed by David Edmundson
parent 09e079b78f
commit 03fc51ef2f
2 changed files with 12 additions and 7 deletions

View file

@ -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);

View file

@ -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);
}