Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent grabKey from accidentally grabbing all unbound keys
grabKeys doesn't check that a KeySym is valid before looking up the KeyCode(s) it's bound to. In particular, KeySym 0 (NoSymbol) gets mapped to every unbound KeyCode, since that's what XKeycodeToKeysym returns for those. This can most easily be reproduced using `statusBar` in xmonad-contrib, with def as the key-mapping function; this unexpectedly invokes the following instances: instance Default b => a -> b where def = const def instance (Default a, Default b) => (a, b) where def = (def, def) instance Default CInt where def = 0 thus producing a function which binds `toggleStruts` to the (KeyMask, KeySym) pair (0, 0) (and demonstrating why Default is a dangerous abstraction). The person who reported this used xmodmap to clear KeySyms from their numpad keys, and then xmonad would bind strut toggling to the entire numpad. Note that it is not reliably possible to override `def` in this situation (without introducing a new type); the only thing we can do is try to avoid the aftermath, and I would expect that an inadvertent 0 KeySym is the most common error here anyway. Fixes: #293 Fixes: 40cb12c ("Grab all keycodes linked to each keysym, not just one") Co-authored-by: Brandon S Allbery KF8NH <allbery.b@gmail.com>
- Loading branch information