X11 unicode input

A while ago someone posted a patch for Unicode input in the X11 driver:

 http://lists.arabeyes.org/archives/developer/2004/June/msg00160.html

I’ve cleaned it up to work with SDL CVS, but it fails to fill in the
"unicode" field for key release events (as the documentation for
Xutf8LookupString() says it will), so I can’t commit the patch, since
that’s technically a downgrade from what SDL currently does.

If someone can fix this somehow, I’ll commit it to CVS, otherwise, the
updated patch is attached for those that have a personal need for it.

–ryan.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed…
Name: SDL-x11-utf8-keys.txt
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20051117/04c7b017/attachment.txt

A while ago someone posted a patch for Unicode input in the X11 driver:

 http://lists.arabeyes.org/archives/developer/2004/June/msg00160.html

I’ve cleaned it up to work with SDL CVS, but it fails to fill in the
"unicode" field for key release events (as the documentation for
Xutf8LookupString() says it will), so I can’t commit the patch, since
that’s technically a downgrade from what SDL currently does.

Maybe the reason Xutf8LookupString() has undefined behavior when passing key
release events is that the unicode value has no meaning in this context.

I think, and please correct me if I’m wrong, that SDL doesn’t fill the unicode
field anyway for key release events because of the above reason and thus the
patch cannot really be considered a downgrade.

This has been discussed before in this thread:

If someone can fix this somehow, I’ll commit it to CVS, otherwise, the
updated patch is attached for those that have a personal need for it.

Thanks for taking the time.

Anyway since the manual says that Xutf8LookupString() has undefined behavior
when passing KeyRelease events, I modified this updated patch to check the
type of the event before calling Xutf8LookupString() by replacing the line in
the X11_TranslateKey function that reads:
if (ic == NULL) {

with:
if (ic == NULL || xkey->type != KeyPress) {

Thanks again :-)On Friday 18 November 2005 03:22, Ryan C. Gordon wrote:


Mohammed Yousif
Egypt

“??? ??? ??? ??? ??? ?? ???. ??? ??? ??? ???. ??? ??? ??? ???
??? ??? ???. ??? ?? ??? ???. ??? ??? ?? ??? ???. ???
??? ?? ??? ???. ??? ??? ??? ??? ?? ???” (?? ??? ???)
-------------- next part --------------
A non-text attachment was scrubbed…
Name: SDL-x11-utf8-keys.txt.zip
Type: application/x-zip
Size: 5298 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20051120/82c467ea/attachment.bin

I think, and please correct me if I’m wrong, that SDL doesn’t fill the unicode
field anyway for key release events because of the above reason and thus the
patch cannot really be considered a downgrade.

Hmm…this is a good point. I was concerned there might be programs
relying on the current behaviour, as SDL currently DOES fill in the
unicode field on release, but (as the post you listed demonstrates),
this isn’t reliable even in a 7-bit ASCII world.

with:
if (ic == NULL || xkey->type != KeyPress) {

I think I’ll add that and commit the patch to CVS. Thanks!

–ryan.

I think I’ll add that and commit the patch to CVS. Thanks!

This is all in CVS now.

–ryan.

Thanks.On Monday 21 November 2005 00:32, Ryan C. Gordon wrote:

I think I’ll add that and commit the patch to CVS. Thanks!

This is all in CVS now.


Mohammed Yousif
Egypt

“??? ??? ??? ??? ??? ?? ???. ??? ??? ??? ???. ??? ??? ??? ???
??? ??? ???. ??? ?? ??? ???. ??? ??? ?? ??? ???. ???
??? ?? ??? ???. ??? ??? ??? ??? ?? ???” (?? ??? ???)