]> git.mdlowis.com Git - proto/labwc.git/commit
keyboard: avoid stuck keys due to keybindings (alternate approach)
authorJohn Lindgren <john@jlindgren.net>
Sat, 4 Nov 2023 05:23:43 +0000 (01:23 -0400)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sun, 12 Nov 2023 17:37:30 +0000 (17:37 +0000)
commit7571c4bed347c55f69ec1826da679c4aa9c84f18
tree781d63b91f1acbde31969e7d7f8eb1057c98ce55
parent0bd265600edc165b2a763c35c2e148ba93705b5d
keyboard: avoid stuck keys due to keybindings (alternate approach)

Before commit e77330bc3fe7, there were issues with keys becoming "stuck"
if other keys were pressed at the time a keybinding was matched, because
those other keys were included in the "bound" set and the release events
were incorrectly eaten by labwc.

Commit e77330bc3fe7 solved that issue with the "big hammer" approach of
preventing keybindings from working at all if other keys were pressed:

        if (key_state_nr_pressed_keys() > 1) {
                return false;
        }

This is an alternate approach to solving the original problem, by (1)
not including those other keys in the "bound" set and (2) making sure we
always forward release events for un-bound keys to clients (even if a
menu or OSD is displayed).

Details:

- Since we only ever want to store the single matched keycode as bound,
  key_state_store_pressed_keys_as_bound() doesn't really make sense in
  the plural, so rename it to key_state_store_pressed_key_as_bound() and
  pass in the keycode.

- The calls to key_state_store_pressed_keys_as_bound() within
  handle_keybinding() appear to be redundant since it is also called
  from the parent function (handle_compositor_keybindings()). So remove
  these calls.

- Finally, rework the logic for handling key-release events so that we
  always forward release events for keys not in the "bound" set.

This PR does not remove the "key_state_nr_pressed_keys() > 1" check, and
because of that should not result in any functional change. It should
however make it possible to relax or remove that check in future.
include/input/key-state.h
src/input/key-state.c
src/input/keyboard.c