Entering tablet mode leaves keys pressed after keyboard is disabled
Summary
On a Lenovo Yoga laptop when the screen is folded back into tablet mode, the keyboard and trackpad devices are disabled. If any keys are pressed on the keyboard before entering tablet-mode, they remain in "pressed" state until the keyboard is activated again by exiting tablet mode.
Steps to reproduce
- Press and hold the Meta key on the laptop keyboard
- Fold the laptop into tablet mode
- Release the Meta key on the back of the tablet
- Notice the key does not "release" until the tablet-mode is exited
Example event stream:
$ sudo stdbuf -oL libinput debug-events
:
-event3 DEVICE_ADDED AT Translated Set 2 keyboard seat0 default group14 cap:k
-event7 DEVICE_ADDED TPPS/2 Elan TrackPoint seat0 default group15 cap:p left scroll-nat scroll-button
-event19 DEVICE_ADDED ThinkPad Extra Buttons seat0 default group16 cap:kS
-event3 KEYBOARD_KEY +0.000s KEY_LEFTMETA (125) pressed
event3 KEYBOARD_KEY +0.158s KEY_LEFTMETA (125) released
event3 KEYBOARD_KEY +0.189s KEY_LEFTMETA (125) pressed
-event19 SWITCH_TOGGLE +3.694s switch tablet-mode state 1
event19 SWITCH_TOGGLE +15.740s switch tablet-mode state 0
-event3 KEYBOARD_KEY +15.748s KEY_LEFTMETA (125) released
OBSERVED RESULT
The Meta key code will register as "pressed" but when the keyboard is disabled, the key does not send a "release" code. Therefore, the system thinks the Meta key is still pressed, which makes it impossible to use an external keyboard in this mode. A similar problem affects other modifier keys (Ctrl, Alt, etc.) and confuses applications including the hotkey detection in the OS.
EXPECTED RESULT
When the keyboard is disabled, all pressed keys should be released. This is what happens when a USB keyboard is disconnected, for example.
ADDITIONAL INFORMATION
This laptop can operate in a display mode without being fully folded into a flat tablet. In this mode the keyboard is face-down on the desk behind the laptop display, and the display is held upright like a standalone monitor. This is a useful mode to operate with external keyboards and external monitors. But it's a pain if I accidentally press any keys when folding the laptop into this mode since the keys get "stuck" in the "pressed" position and the keyboard is then disabled.
Required information
- libinput version:
Version: 1.20.0-1ubuntu0.3
- hardware information:
Operating System: KDE neon 5.27
KDE Plasma Version: 5.27.6
KDE Frameworks Version: 5.107.0
Qt Version: 5.15.10
Kernel Version: 5.19.0-46-generic (64-bit)
Graphics Platform: X11
Processors: 8 × Intel® Core™ i7-10610U CPU @ 1.80GHz
Memory: 15.2 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics
Manufacturer: LENOVO
Product Name: 20UCS4TR00
System Version: ThinkPad X1 Yoga Gen 5