<AWT Dev> RFR: JDK-8165232 XKeycodeToKeysym is deprecated and should be replaced with XkbKeycodeToKeysym

Philip Race philip.race at oracle.com
Sun Sep 25 00:04:29 UTC 2016

   94     KeySym *key_syms = XGetKeyboardMapping(display, keycode, index + 1,&num_syms);

I might be mis-reading the API but the docs as I read it have argument 3
as a count .. so it should be 1 here, should it not ?


As written I have a suspicion you will at some point run into an X 
BadValue error

The docs say :-
"In addition, the following expression must be less than or equal
to max_keycode as returned by XDisplayKeycodes():

     first_keycode + keycode_count - 1

To be truly robust here we should somewhere obtain and probably cache
"first key code" and max_keycode.

I say cache since you don't want two X calls every time.

Then if the requested code is outside that ... just return NoSymbol I 


KeySym ks = key_syms[index];

then looks very wrong. You want "0" here .. not index, don't you?
So I must be completely misunderstanding this X API if this is working 
for you.

I am also a bit unclear how we know that the first keysym listed for the
keycode from the list is the one we want ?


On 9/14/16, 10:42 AM, Alan Burlison wrote:
> On 06/09/2016 11:16, Alan Burlison wrote:
>> XKeycodeToKeysym is deprecated and when compiled on Solaris 12 with
>> warnings-as-errors this causes a compile time failure. References to
>> XKeycodeToKeysym should be replaced by XkbKeycodeToKeysym. As this is
>> common XOrg code it will affect Linux as well.
>> Bug:    https://bugs.openjdk.java.net/browse/JDK-8165232
>> Webrev: http://cr.openjdk.java.net/~alanbur/JDK-8165232/
> I've respun this and replaced the calls to XKeycodeToKeysym with 
> equivalent code that uses XGetKeyboardMapping instead. This addresses 
> the problem without introducing a dependency on XKEYBOARD, which I 
> think is is a better fix.
> I'd appreciate any review comments.
> Thanks,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/awt-dev/attachments/20160924/62a2acc1/attachment.html>

More information about the awt-dev mailing list