#42 tvtime should resolve keysyms based on current layout/group

Billy Biggs
Bugfix (15)
Steven Elliott

I have a Linux system with multiple keyboard layouts/groups configured through the GNOME interface (not using setxkbmap via the command line) so that I'm able to switch between them. In my case dvorak is the primary default group, which means it's group 0 in the X11 API, and the second group is US, which means it's group 1 in the X11 API. When I switch from my primary default group (dvorak) to my secondary group (US) tvtime continues interpret keystrokes as if my primary default group was still in effect.

In tvtime XKeycodeToKeysym() is used which seems to always use group 0 to resolve keysyms. Although there is the newer XkbKeycodeToKeysym() API that allows the group number to be passed, there is not, to me at least, an obvious way of finding the current group without working with X11 extensions.

I've found that XLookupString() resolves keysyms using the current group. It also handles modifiers such as shift, so it simplifies the code a bit. My patch passes in "keyStr" to get the key as a string which is not used. It seems to work to pass in NULL, but that's not documented.

I went through a few keystrokes and it seems to work for me for both my primary and secondary groups.

It's possible that the current behavior with regard to groups is intentional. A few years ago it seemed that it was common for applications, at least when modifiers such as ALT were pressed, to behave like tvtime does now forcing me to use setxkbmap to get the behavior I'm aiming for (for only the current group to be considered regardless of modifiers or other reasons). But currently almost all applications seem to only consider the current group, at least in GNOME.

The patch is against released tvtime 1.0.2 on my Fedora 16 system, but I checked that the patch applies cleanly to latest CVS.