<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Keys can get stuck permanently when grabbing keyboard with evdev"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=101796">101796</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Keys can get stuck permanently when grabbing keyboard with evdev
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Wayland
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux (All)
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>libinput
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>wayland-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>noah.bergbauer@tum.de
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The logic in evdev.c
(<a href="https://github.com/wayland-project/libinput/blob/688142c8a22c00cfe7b9dec6a71e935b899d8b65/src/evdev.c#L167-L169">https://github.com/wayland-project/libinput/blob/688142c8a22c00cfe7b9dec6a71e935b899d8b65/src/evdev.c#L167-L169</a>)
remembers how many times a key is pressed simultaneously and only emits KEY_UP
events when this counter is incremented to 1 and KEY_DOWN when it is
decremented to 0.

This is problematic as key release events might get dropped, for example if the
keyboard is exclusively grabbed by evdev's EVIOCGRAB while a key is pressed.

This issue is easily reproducible by launching one instance of
libinput-debug-events (or any libinput-based application that reads keyboard
input) and then running this in another terminal:
libinput-debug-events --device /path/to/keyboard --grab & (sleep 1 ; killall
libinput-debug-events)

Because you submit the command by pressing the Enter key and
libinput-debug-events launches fast enough, the release event for your Enter
key happens after the device is grabbed, so the first instance of
libinput-debug-events will not receive it. Because of this bug, the Enter key
is now permanently stuck there as it is always pressed either 1 or 2 times, so
libinput will never send any key events for it again.

(Please note that running this test inside any libinput-based desktop
environment (xf86-input-libinput or Wayland) obviously triggers the same bug
and may force you to restart your window manager.)



In other implementations (xf86-input-evdev, Microsoft Windows), missing release
events are handled gracefully: As pressing an already held key indicates a
missing release event, they just ignore this, so a subsequent key release event
actually releases the key.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>