wayland: Release all keys upon keyboard leaving

Biggest most annoying symptom was that the window was rendered unusable
after alt+tab, but any other combination is also problematic.
This commit is contained in:
Aleix Pol Gonzalez 2023-08-31 17:41:11 +02:00 committed by David Edmundson
parent 82be16df29
commit 3d2a3de07e
2 changed files with 10 additions and 0 deletions

View file

@ -51,6 +51,12 @@ WaylandInputDevice::WaylandInputDevice(KWayland::Client::Keyboard *keyboard, Way
: m_seat(seat)
, m_keyboard(keyboard)
{
connect(keyboard, &Keyboard::left, this, [this](quint32 time) {
for (quint32 key : std::as_const(m_pressedKeys)) {
Q_EMIT keyChanged(key, InputRedirection::KeyboardKeyReleased, std::chrono::milliseconds(time), this);
}
m_pressedKeys.clear();
});
connect(keyboard, &Keyboard::keyChanged, this, [this](quint32 key, Keyboard::KeyState nativeState, quint32 time) {
InputRedirection::KeyboardKeyState state;
switch (nativeState) {
@ -59,8 +65,10 @@ WaylandInputDevice::WaylandInputDevice(KWayland::Client::Keyboard *keyboard, Way
m_seat->backend()->togglePointerLock();
}
state = InputRedirection::KeyboardKeyPressed;
m_pressedKeys.insert(key);
break;
case Keyboard::KeyState::Released:
m_pressedKeys.remove(key);
state = InputRedirection::KeyboardKeyReleased;
break;
default:

View file

@ -97,6 +97,8 @@ private:
std::unique_ptr<KWayland::Client::Pointer> m_pointer;
std::unique_ptr<KWayland::Client::PointerPinchGesture> m_pinchGesture;
std::unique_ptr<KWayland::Client::PointerSwipeGesture> m_swipeGesture;
QSet<quint32> m_pressedKeys;
};
class WaylandInputBackend : public InputBackend