[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mozilla-gtk
Subject:    [Fwd: code review 7614 ... was Re: X KeySym to Unicode conversion in
From:       ftang () netscape ! com (Yung-Fong Tang)
Date:       2000-01-12 21:03:58
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Pavlov:
Please code review and let me know is this ok or not. I have already
check in the [xterm-122 source based] keysym2ucs.{c,h} into
mozilla/widget/src/gtk w/ mitchell's approval.

Other Unix folks, can you try this with european characters input ?

The bug I want to fix is Bugzilla bug 7614

Also, can some one help us to fix  Bugzilla bug 20932 ? Even writing a
good test procedure / test cases will help....

Frank Tang

[Attachment #5 (text/html)]

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Pavlov:
<br>Please code review and let me know is this ok or not. I have already
check in the [xterm-122 source based] keysym2ucs.{c,h} into mozilla/widget/src/gtk
w/ mitchell's approval.
<p>Other Unix folks, can you try this with european characters input ?
<p>The bug I want to fix is <a \
href="http://bugzilla.mozilla.org/show_bug.cgi?id=7614">Bugzilla bug 7614</a>
<p>Also, can some one help us to fix&nbsp; <a \
href="http://bugzilla.mozilla.org/show_bug.cgi?id=20932">Bugzilla bug 20932</a> ? \
Even writing a good test procedure / test cases will help.... <p>Frank Tang</html>


["nsmail9K.TMP" (message/rfc822)]

This is a multi-part message in MIME format.
[Attachment #8 (multipart/alternative)]


Here is a reply for technical issue- so I leave license related folks out of
the loop.
Markus Kuhn wrote:

> Yung-Fong Tang wrote on 2000-01-08 07:13 UTC:
> > I just find the soruce from xterm-122
> > (  http://www.clark.net/pub/dickey/xterm/xterm.tar.gz   )
> > under keysym2ucs.c . What is the license term of xterm these days?
> > Is the following apply to this file also ?
>
> I am the author of the keysym2ucs.c file, and this file is in the public
> domain as far as I am concerned. I'll attach below my latest version of
> this file, plus the original table file (authored by Richard Verhoeven
> with heavy modification by myself) and the Perl script that I wrote to
> convert it to a C lookup routine. Feel free to use it in whatever way
> you like, but please keep our names somewhere in the source.
>
> Important: Please understand that this file is only a temporary hack.
> Eventually, Xlib will support a UTF-8 locale and XmbLookupString() will
> be able to deliver Unicode/UTF-8 strings from key events directly to the
> application. Once Xlib is able to convert keysyms to Unicode, this table
> will be obsolete and Xlib's functions should be used instead as the
> official conversion technique!

I don't think so. This will only make it work under UTF-8 locale, right ?
Japanese, Chinese, Korean locale will still need it. To make mozilla use it, I
simply need to change the follwoing code
1. I need to wrap the header file w/ extern "C" as below and check in
mozilla/widget/src/gtk/

/* $XFree86: xc/programs/xterm/keysym2ucs.h,v 1.1 1999/06/12 15:37:18 dawes
Exp $ */
/*
 * This module converts keysym values into the corresponding ISO 10646-1
 * (UCS, Unicode) values.
 */

#include <X11/X.h>

#ifdef __cplusplus
extern "C" {
#endif

long keysym2ucs(KeySym keysym);

#ifdef __cplusplus
} /* extern "C" */
#endif

2. Add keysym2ucs.c to mozilla/widget/src/gtk
3. apply the attached patch

It work very nice. I test it by the following way-
1. xmodmap -kpe > f1
2. cp f1 f2 (keep an backup ...)
3. change f2 and change the 'at' of the shift 2 to 'abreve'
4. xmodmap - < f2
5. In mozilla, type Shift + '2', it will input abreve instead of @ !!!!
6. to switch it back, run "xmodmap - <f1"
This even work under Japanese locale!!!!

pavlov, can  you approve my check in ? This will fix bug 7614 :)

> Also the suggested technique of interpreting 0x01000000 + unicode_value
> as a valid key symbol for any Unicode character is at the moment just an
> ad-hoc convention that still has to be sanctioned by X.Org in the
> next revision of the X11 standards.

We won't use that part.

> The Perl script is just used as "./convmap.pl >keysym2ucs.c".
>
> I have not done any proofreading on the 0xffxx keysyms in keysym.map,
> which are discarded by the Perl script anyway.
>
> Please let me know if you have any questions of find any bugs.
>
> Markus
>
> --
> Markus G. Kuhn, Computer Laboratory, University of Cambridge, UK
> Email: mkuhn at acm.org,  WWW: <http://www.cl.cam.ac.uk/~mgk25/>
>
>   ------------------------------------------------------------------------

[Attachment #11 (text/html)]

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
&nbsp;
<br>Here is a reply for technical issue- so I leave license related folks
out of the loop.
<br>Markus Kuhn wrote:
<blockquote TYPE=CITE>Yung-Fong Tang wrote on 2000-01-08 07:13 UTC:
<br>> I just find the soruce from xterm-122
<br>> (&nbsp; <a href="http://www.clark.net/pub/dickey/xterm/xterm.tar.gz">http://www.clark.net/pub/dickey/xterm/xterm.tar.gz</a>&nbsp;&nbsp;
 )
<br>> under keysym2ucs.c . What is the license term of xterm these days?
<br>> Is the following apply to this file also ?
<p>I am the author of the keysym2ucs.c file, and this file is in the public
<br>domain as far as I am concerned. I'll attach below my latest version
of
<br>this file, plus the original table file (authored by Richard Verhoeven
<br>with heavy modification by myself) and the Perl script that I wrote
to
<br>convert it to a C lookup routine. Feel free to use it in whatever way
<br>you like, but please keep our names somewhere in the source.
<p>Important: Please understand that this file is only a temporary hack.
<br>Eventually, Xlib will support a UTF-8 locale and XmbLookupString()
will
<br>be able to deliver Unicode/UTF-8 strings from key events directly to
the
<br>application. Once Xlib is able to convert keysyms to Unicode, this
table
<br>will be obsolete and Xlib's functions should be used instead as the
<br>official conversion technique!</blockquote>
I don't think so. This will only make it work under UTF-8 locale, right
? Japanese, Chinese, Korean locale will still need it. To make mozilla
use it, I simply need to change the follwoing code
<br>1. I need to wrap the header file w/ extern "C" as below and check
in mozilla/widget/src/gtk/
<p><font color="#CC0000">/* $XFree86: xc/programs/xterm/keysym2ucs.h,v
1.1 1999/06/12 15:37:18 dawes Exp $ */<br>
/*<br>
&nbsp;* This module converts keysym values into the corresponding ISO 10646-1<br>
&nbsp;* (UCS, Unicode) values.<br>
&nbsp;*/<br>
<br>
#include &lt;X11/X.h><br>
<br>
</font><font color="#3333FF">#ifdef __cplusplus<br>
extern "C" {&nbsp;<br>
#endif<br>
<br>
</font><font color="#CC0000">long keysym2ucs(KeySym keysym);&nbsp;<br>
<br>
</font><font color="#3333FF">#ifdef __cplusplus<br>
} /* extern "C" */<br>
#endif<br>
<br>
<br>
</font>2. Add keysym2ucs.c to mozilla/widget/src/gtk
<br>3. apply the attached patch
<p>It work very nice. I test it by the following way-
<br>1. xmodmap -kpe > f1
<br>2. cp f1 f2 (keep an backup ...)
<br>3. change f2 and change the 'at' of the shift 2 to 'abreve'
<br>4. xmodmap - &lt; f2
<br>5. In mozilla, type Shift + '2', it will input abreve instead of @
!!!!
<br>6. to switch it back, run "xmodmap - &lt;f1"
<br>This even work under Japanese locale!!!!
<p>pavlov, can&nbsp; you approve my check in ? This will fix bug 7614 :)
<blockquote TYPE=CITE>Also the suggested technique of interpreting 0x01000000
+ unicode_value
<br>as a valid key symbol for any Unicode character is at the moment just
an
<br>ad-hoc convention that still has to be sanctioned by X.Org in the
<br>next revision of the X11 standards.</blockquote>
We won't use that part.
<blockquote TYPE=CITE>The Perl script is just used as "./convmap.pl >keysym2ucs.c".
<p>I have not done any proofreading on the 0xffxx keysyms in keysym.map,
<br>which are discarded by the Perl script anyway.
<p>Please let me know if you have any questions of find any bugs.
<p>Markus
<p>--
<br>Markus G. Kuhn, Computer Laboratory, University of Cambridge, UK
<br>Email: mkuhn at acm.org,&nbsp; WWW: &lt;<a \
href="http://www.cl.cam.ac.uk/~mgk25/">http://www.cl.cam.ac.uk/~mgk25/</a>> <p>&nbsp; \
------------------------------------------------------------------------</blockquote> \
</html>


["gtkucs2.txt" (text/plain)]

? gtk/keysym2ucs.c
? gtk/nsGtkEventHandler.cpp.bk108
? gtk/keysym2ucs.h
Index: gtk/Makefile.in
===================================================================
RCS file: /m/pub/mozilla/widget/src/gtk/Makefile.in,v
retrieving revision 1.59
diff -c -r1.59 Makefile.in
*** Makefile.in	2000/01/06 11:11:38	1.59
--- Makefile.in	2000/01/12 00:02:45
***************
*** 27,32 ****
--- 27,35 ----
  REQUIRES	= util img xpcom raptor netlib
  
  CPPSRCS		= \
+ 		keysym2ucs.c
+ 
+ CPPSRCS		= \
  		nsAppShell.cpp \
  		nsButton.cpp \
  		nsCheckButton.cpp \
Index: gtk/nsGtkEventHandler.cpp
===================================================================
RCS file: /m/pub/mozilla/widget/src/gtk/nsGtkEventHandler.cpp,v
retrieving revision 1.126
diff -c -r1.126 nsGtkEventHandler.cpp
*** nsGtkEventHandler.cpp	2000/01/05 01:26:55	1.126
--- nsGtkEventHandler.cpp	2000/01/12 00:02:45
***************
*** 21,26 ****
--- 21,27 ----
   */
  
  #include "nsWidget.h"
+ #include "keysym2ucs.h"
  #include "nsWindow.h"
  
  #include "nsScrollbar.h"
***************
*** 361,370 ****
      // XXX
      anEvent.isMeta = PR_FALSE; //(aGEK->state & GDK_MOD2_MASK) ? PR_TRUE : PR_FALSE;
  
!     if(aGEK->length)
         anEvent.charCode = nsConvertCharCodeToUnicode(aGEK);
!     else 
         anEvent.charCode = 0;
  
      if (anEvent.charCode) {
        anEvent.keyCode = 0;
--- 362,381 ----
      // XXX
      anEvent.isMeta = PR_FALSE; //(aGEK->state & GDK_MOD2_MASK) ? PR_TRUE : PR_FALSE;
  
!     if(aGEK->length) {
         anEvent.charCode = nsConvertCharCodeToUnicode(aGEK);
!     } else  {
         anEvent.charCode = 0;
+        // now, let's handle some keysym which XmbLookupString didn't handle
+        // because they are not part of the locale encoding
+        if( (aGEK->keyval >= 0x100 && (aGEK->keyval <= 0xf000) ||
+            (aGEK->keyval & 0xff000000U) == 0x01000000))
+        {
+           long ucs = keysym2ucs(aGEK->keyval);
+           if( (-1 != ucs ) && ( ucs < 0x10000))
+              anEvent.charCode = ucs;
+        }
+     }
  
      if (anEvent.charCode) {
        anEvent.keyCode = 0;

["ftang.vcf" (text/x-vcard)]
["ftang.vcf" (text/x-vcard)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic