alols/xcape — pull request #10 by calmofthestorm (2012-10-25 20:06:14+00:00)
Title: Fixed crash in handle_key when no keycode is found for a selected keysym

I finally got rid of a dedicated escape key with xmodmap thanks to this program. I found that when I did this, however, xcape would crash with null keycodes in handle_key. The problem is that since I had no escape keycode defined, XKeysymToKeycode was returning 0 in parse_token, but its return value was not being checked. Somehow this caused a crash in handle_key the /second/ time the from key was pressed in a session.

I'm not sure how to fix the underlying issue that we can't send keysyms directly (arguably a limitation of X), but we can at least check in parse_token for mappings that will cause a crash.

While investigating this, I found another issue -- if keys are remapped with xmodmap while xcape is running, it will continue to send the old keycodes even if they are mapped to new symbols. I don't think it's worth the trouble to fix (it would mean looking up keycodes on every keypress) given the user can just restart xcape every time they update their mappings. I added a note in the README to this effect.