Subject: Key binding problem, 2.1.6+

From: Lee Skinol <[email-masked]>
Date: 13 Feb 99 23:30:26 EDT

->On Thu, Feb 11, 1999 at 06:12:07PM -0400, Lee Skinol wrote:
->> ->On Wed, Feb 10, 1999 at 10:36:32PM -0400, [email-masked] wrote:
->> ->> In bindings.c, in the 2.1.6 code, there's the following
->> ->> loop:
->> ->>
->> ->>   for (i=min; i<=max; i++)
->> ->>     if (!fKey || XKeycodeToKeysym(dpy, i, 0) == keysym)
->> ->>     {
->> ->>       /* Code to add binding, I think */
->> ->>     }
->> ->>
->> ->> In my .fvwm2rc, I have:
->> ->>
->> ->>   Key KP_7        A       M       GotoPage 0 0
->> ->>
->> ->> With the new code, fKey is 1, min is 8, max is 134, and
->> ->> (XKeycodeToKeysym(dpy, i, 0) == keysym) is never true, so
->> ->> the key doesn't get added.  In the 2.1.5 code, the add
->> ->> is done (and it *is* done) at the end of the procedure.
->> ->>
->> ->> Anything else I should look at?
->>
->> ->Bummer, I'd never have thought of that. Could you find
->> ->out what value keysym has and what the corresponding
->> ->keycode should be? This looks as if the XDisplayKeycodes
->> ->function is broken on your system. Theoretically you
->> ->should have had the same problem with 2.0.46 (?) as
->> ->it used the same call. And perhaps you could post the
->> ->output of 'xmodmap -pk' and 'xmodmap -pke'.
->>
->> ->What OS/Xserver do you have?
->>
->> Redhat Linux 5.2, kernel 2.2.1.  XFree 3.3.2.
->>
->> I think I've found the problem.  In 2.1.5, I bind to KP_7, but
->> the latest code requires that I bind it as KP_Home.  Not sure
->> which one is "right."
->...
->>    79           0xff95 (KP_Home)        0xffb7 (KP_7)

->Finally I understand what is happening :) The problem is
->that:

->1) Multiple keycodes can be bound to the same keysym
->2) Multiple keysyms can be bound to the same keycode

->E.g. you could have this in your xmodmap:

->  79           0xff95 (KP_Home)        0xffb7 (KP_7)
->  80           0xffb7 (KP_7)           0xff95 (KP_Home)

->So if you use XKeysymToKeycode on KP_7 you may either
->get 79 or 80 as the return code. On the other hand, if
->you only have

->  79           0xff95 (KP_Home)        0xffb7 (KP_7)

->XKeycodeToKeysym will return KP_Home for the keycode
->79. This doesn't match what we are comparing it with.
->Technically it should be forbidden to bind keysyms that
->require a modifier to get them in X. Unfortunately this
->is not quite clear to the average user (or even the
->expert user).

->A way to fix this would be to check the keysym for every
->possible combination of keycode and a single modifier
->(patch attached, but I don't think the patch is elegant.
->It may prove way too slow).

->To reproduce this bug anyone can just issue

->  # xmodmap -e 'keycode 79 = KP_Home KP_7'

->and put these lines in his .fvwm2rc:

->  key kp_home a n menu some_menu
->  key kp_7    a n menu other_menu

->When you press KP_7 you get 'some_menu', not 'other_menu'
->as you would expect.

->----------- a few minutes later -----------------

->No, the patch doesn't slow things down too much. You might
->notice if you have tons of key bindings. I'll commit the
->patch so that everyone can test it. Please do have a look
->at it if it does the right thing.

->Lee, does the patch solve your problem?

Sorry for the delay in getting back to the list.  Yes, the
patch works fine.  I can bind to either KP_Home or KP_7.

Thanks much!

Lee
--
Visit the official FVWM web page at <URL:http://fvwm.math.uh.edu/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked].