Skip to content

shortcuts-grabber: Record xkb state group & Redesign shortcut regrabbing (Bug #33)

Ghost User requested to merge (removed):shortcuts into master

Changes in respect to the previous version of this merge request:

Key grabbing is now being filtered by key group (i.e: by the index of the active keyboard layout).

[The following sentence is no longer true, except being still true for keys such as F1-F12: It is common for the reference counts to, for example, reach the value of 4 if the user is using 4 keyboard layouts, in which case the new implementation will use a single XGrabKey() call compared to 4 such calls in previous implementations.]


Changes in respect to the previous version of this merge request:

This patch hopes to fix shortcut grabbing issues related to keyboard layouts while maintaining high performance.

The implementation uses a new hash-table for tracking the keycodes grabbed from the X server. The grabbed X11/Xorg keys are reference counted: X11 XGrabKey() is called once per a keycode+modifiers combination and X11 XUngrabKey() is called when the reference count of the combination drops to zero. It is common for the reference counts to, for example, reach the value of 4 if the user is using 4 keyboard layouts, in which case the new implementation will use a single XGrabKey() call compared to 4 such calls in previous implementations.

The grab_all() function has been removed and has been replaced by an optimized regrab_all() function which is more efficient than the sequence ungrab_all()+grab_all().

Tested keyboard layouts:

  • English
  • English (Colemak)
  • French (BÉPO)
  • Slovak (QWERTY)

Test environments:

  • Arch Linux (FR-BÉPO)
  • FreeBSD (basic testing)
  • Gentoo Linux (EN, EN-Colemak, SK-QWERTY)
  • Xubuntu (basic testing)

Text of the previous version of this merge request:

XkbGroupForCoreState(xevent->xkey.state) returns 0 even after a keyboard layout switch. Instead of using the XkbGroupForCoreState() function, this patch watches for XkbStateNotify events from which it obtains the xkb state group.


Please confirm whether this patch fixes #33 (closed). Thanks.


Closes: #33 (closed)

See also: !33 (closed)

Edited by Ghost User

Merge request reports