Fix race condition with libinput events on startup

Summary:
In some cases, it's possible that libinput wrote device added events to
the file descriptor before the connection to handle those events was
in-place. This resulted in a compositor without any input devices.

Test Plan:
Ran a wayland session. In about 60% of all cases, no input was
possible. kwin_libinput showed the enumeration of all devices correctly,
but KWin::LibInput::Context did not have any m_devices.
After this change, this did not appear anymore.

Reviewers: #plasma, graesslin, davidedmundson

Reviewed By: #plasma, graesslin, davidedmundson

Subscribers: anthonyfieroni, ngraham, kwin, #kwin, plasma-devel

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8888
icc-effect-5.14.5
Fabian Vogt 2017-11-18 23:23:27 +01:00
parent db6c7e17e6
commit d7d78e2b59
1 changed files with 1 additions and 1 deletions

View File

@ -1728,13 +1728,13 @@ void InputRedirection::setupLibInput()
conn->setInputConfig(kwinApp()->inputConfig());
conn->updateLEDs(m_keyboard->xkb()->leds());
conn->setup();
connect(m_keyboard, &KeyboardInputRedirection::ledsChanged, conn, &LibInput::Connection::updateLEDs);
connect(conn, &LibInput::Connection::eventsRead, this,
[this] {
m_libInput->processEvents();
}, Qt::QueuedConnection
);
conn->setup();
connect(conn, &LibInput::Connection::pointerButtonChanged, m_pointer, &PointerInputRedirection::processButton);
connect(conn, &LibInput::Connection::pointerAxisChanged, m_pointer, &PointerInputRedirection::processAxis);
connect(conn, &LibInput::Connection::pinchGestureBegin, m_pointer, &PointerInputRedirection::processPinchGestureBegin);