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

Philip Race philip.race at oracle.com
Mon Sep 26 22:01:09 UTC 2016

So that looks like it should work although the duplicate definition irks.
Can we remove the static and have it just be extern declared in XWindow.c ?

For testing can you submit a jprt job and I'll see if I can rustle up some
SQE support to identify any tests that might be good to run.


On 9/26/16, 9:53 AM, Alan Burlison wrote:
> On 25/09/2016 01:04, Philip Race wrote:
>>   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 ?
>> https://tronche.com/gui/x/xlib/input/XGetKeyboardMapping.html
> I think you are right, I was reading the third parameter as being the 
> number of keysyms to be returned, whereas it is the number of 
> keycodes, starting with the one passed in argument 2, that are to be 
> returned. In that case yes, 1 would seem to be the correct value. I've 
> made that change,
>> 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.
>> https://tronche.com/gui/x/xlib/input/XDisplayKeycodes.html
>> 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
>> suppose.
> Yes, I think you'll get a BadValue error. It appears that under those 
> conditions the original call to XKeycodeToKeysym will return NoSymbol, 
> so doing the same seems best. Also it would probably make sense to add 
> range checking to the index parameter as well.
> I've updated the webrev with the above suggestions.
>> Furthermore
>> 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 ?
> I think 'index' is right once 1 is provided as the third parameter to 
> XGetKeyboardMapping as what is coming back is an array of keysyms.
> I'd run the original code through the JDK testuite and it passed, if 
> you have any suggestions how better to test this I'd be grateful to 
> hear them.
> Thanks,

More information about the awt-dev mailing list