[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#520509: libx11-data: Thai XIM not turned on by default due to excessive Compose files



On Wed, Apr 8, 2009 at 5:37 PM, Julien Cristau <jcristau@debian.org> wrote:
> On Sat, 2009-03-21 at 13:00 +0700, Theppitak Karoonboonyanan wrote:
>> Summarized patches:

>> Minimum:
>> - 020_th_TH_iso8859-11_ct.diff: Fixes conversion which
>>   blocks SCIM.
>
> can you provide an appropriate commit message for this?
> http://www.x.org/wiki/Development/Documentation/SubmittingPatches has
> some guidelines.  (needs to explain what this fixes and why)
> I'll push it upstream then.

>> Medium seriousness:
>> - 022_Thai_xim_surr_conv.diff: Fixes surrounding text
>>   retrieval for Thai XIM (good for GTK+, needed for KDE 3).
>>
>> Minor:
>> - 021_Thai_xim_num_caps.diff: Makes Thai XIM work when
>>   NumLock/CapsLock is on.
>>
> Same as above re: commit message, and I'll push this upstream too.

Thanks for the offering. I've reformatted the 3 patches
according to the guidelines.

Regards,
-- 
Theppitak Karoonboonyanan
http://linux.thai.net/~thep/
From e5223cd4a182fc2f6b0ff6c0cad770fba603853d Mon Sep 17 00:00:00 2001
From: Theppitak Karoonboonyanan <thep@linux.thai.net>
Date: Thu, 9 Apr 2009 11:25:25 +0700
Subject: [PATCH] CharSet-to-CompoundText Conversion Failed for Thai Locales

X.Org Bug 16475 <http://bugs.freedesktop.org/show_bug.cgi?id=16475>

Signed-off-by: Theppitak Karoonboonyanan <thep@linux.thai.net>

SCIM fails to commit Thai input characters on Thai locales, because it commits
string in compound text form, which was converted via
XwcTextListToTextProperty(). But the XLC_LOCALE for th_TH and th_TH.UTF-8
declares cs1's ct_encoding as TIS620-0:GR, which was commented out in
src/xlibi18n/lcCT.c default_ct_data, in favor of ISO8859-11 ESC sequence.
So, declaring cs1 as ISO8859-11:GR instead makes it work.

Besides, for th_TH.UTF-8, adding cs2 class with ISO10646-1 encoding also adds
support for UTF-8 input.

And, along discussion in the bug, a similar problem was found for fontset, too,
by causing delays on X apps startups on systems without tis620-0 fonts. This
is normally the case, as mkfontdir and mkfontscale generate iso8859-11 entries
by default for Thai X fonts. So, Thai fontset charset is also patched.
---
 nls/th_TH.UTF-8/XLC_LOCALE.pre |   12 +++++++++---
 nls/th_TH/XLC_LOCALE.pre       |    6 +++---
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/nls/th_TH.UTF-8/XLC_LOCALE.pre b/nls/th_TH.UTF-8/XLC_LOCALE.pre
index 9f1caf7..caede14 100644
--- a/nls/th_TH.UTF-8/XLC_LOCALE.pre
+++ b/nls/th_TH.UTF-8/XLC_LOCALE.pre
@@ -27,8 +27,8 @@ fs1	{
 }
 XCOMM 	fs1 class (Thai) 
 fs2	{
-	charset         TIS620-0:GR
-	font            TIS620-0:GR
+	charset         ISO8859-11:GR
+	font            ISO8859-11:GR
 }
 END XLC_FONTSET
 
@@ -69,7 +69,13 @@ cs1	{
 	length		1
 
 	wc_encoding	\x30000000
-	ct_encoding     TIS620-0:GR
+	ct_encoding     ISO8859-11:GR
+}
+
+XCOMM 	cs2 class
+cs2	{
+	side		none
+	ct_encoding     ISO10646-1
 }
 
 END XLC_XLOCALE
diff --git a/nls/th_TH/XLC_LOCALE.pre b/nls/th_TH/XLC_LOCALE.pre
index 7d55d85..c67d683 100644
--- a/nls/th_TH/XLC_LOCALE.pre
+++ b/nls/th_TH/XLC_LOCALE.pre
@@ -16,8 +16,8 @@ fs0	{
 }
 XCOMM 	fs1 class (Thai) 
 fs1	{
-	charset         TIS620-0:GR
-	font            TIS620-0:GR
+	charset         ISO8859-11:GR
+	font            ISO8859-11:GR
 }
 END XLC_FONTSET
 
@@ -61,7 +61,7 @@ cs1	{
 #else
 	wc_encoding	\x00008080
 #endif
-	ct_encoding     TIS620-0:GR
+	ct_encoding     ISO8859-11:GR
 }
 
 END XLC_XLOCALE
-- 
1.6.2.2

From a2dde094e00d9955d57ff9af7d9c3dc265e68cf8 Mon Sep 17 00:00:00 2001
From: Theppitak Karoonboonyanan <thep@linux.thai.net>
Date: Thu, 9 Apr 2009 11:47:55 +0700
Subject: [PATCH] Thai XIM not filters when NumLock or CapsLock is on

X.Org Bug 12517 <http://bugs.freedesktop.org/show_bug.cgi?id=12517>

Signed-off-by: Theppitak Karoonboonyanan <thep@linux.thai.net>

The Thai XIM component in libx11 activated on 'th*' locales normally filters
input sequence according to orthographic rules. However, when NumLock/CapsLock
is on, this stops working. All sequences are passed through.

This is caused by missing masks in _XimThaiFilter(), which normally screens out
certain special keys from entering orthographic rules. Unfortunately, this
included events with NumLock/CapsLock on. Negating the masks from the check
allows the events to be tested by the rules.
---
 modules/im/ximcp/imThaiFlt.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/modules/im/ximcp/imThaiFlt.c b/modules/im/ximcp/imThaiFlt.c
index 368ea5c..42a30d7 100644
--- a/modules/im/ximcp/imThaiFlt.c
+++ b/modules/im/ximcp/imThaiFlt.c
@@ -1236,6 +1236,22 @@ ThaiFltReplaceInput(Xic ic, unsigned char new_char, KeySym symbol)
     return True;
 }
 
+Private unsigned
+NumLockMask(Display *d)
+{
+    int i;
+    XModifierKeymap *map = XGetModifierMapping (d);
+    KeyCode numlock_keycode = XKeysymToKeycode (d, XK_Num_Lock);
+    if (numlock_keycode == NoSymbol)
+        return 0;
+
+    for (i = 0; i < 8; i++) {
+        if (map->modifiermap[map->max_keypermod * i] == numlock_keycode)
+            return 1 << i;
+    }
+    return 0;
+}
+
 /*
  * Filter function for TACTIS
  */
@@ -1267,7 +1283,7 @@ _XimThaiFilter(Display *d, Window w, XEvent *ev, XPointer client_data)
     XwcLookupString((XIC)ic, &ev->xkey, wbuf, sizeof(wbuf) / sizeof(wbuf[0]),
 		    &symbol, NULL);
 
-    if ((ev->xkey.state & (AllMods & ~ShiftMask)) ||
+    if ((ev->xkey.state & (AllMods & ~(ShiftMask|LockMask|NumLockMask(d)))) ||
          ((symbol >> 8 == 0xFF) &&
          ((XK_BackSpace <= symbol && symbol <= XK_Clear) ||
            (symbol == XK_Return) ||
-- 
1.6.2.2

From 1cf0fb16dc7fb2c3a14377d6b566af607db47b53 Mon Sep 17 00:00:00 2001
From: Theppitak Karoonboonyanan <thep@linux.thai.net>
Date: Thu, 9 Apr 2009 12:01:07 +0700
Subject: [PATCH] Thai XIM not retrieve MB surrounding on UTF-8 LC

X.Org But 12759 <http://bugs.freedesktop.org/show_bug.cgi?id=12759>

Signed-off-by: Theppitak Karoonboonyanan <thep@linux.thai.net>

On th_TH.UTF-8 locale, Thai XIM rejects all combining characters for GTK+ apps
that use X Input Method.

This is because GTK+ imxim immodule passes surrounding text in locale encoding,
which is UTF-8 for UTF-8 locales. But current Thai XIM in Xlib assumes the
multi-byte StringConversionText response for the StringConversionCallback to
always be TIS-620, by retrieving a single byte and using it as-is.

If the Thai XIM tries to convert the multi-byte text based on locale codeset
before using it, it will work again.
---
 modules/im/ximcp/imThaiFlt.c |   32 ++++++++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/modules/im/ximcp/imThaiFlt.c b/modules/im/ximcp/imThaiFlt.c
index 42a30d7..645f0e6 100644
--- a/modules/im/ximcp/imThaiFlt.c
+++ b/modules/im/ximcp/imThaiFlt.c
@@ -560,13 +560,37 @@ IC_RealGetPreviousChar(Xic ic, unsigned short pos)
         {
             c = 0;
         } else {
+            Xim     im;
+            XlcConv conv;
+            int     from_left;
+            int     to_left;
+            char   *from_buf;
+            char   *to_buf;
+
+            im = (Xim) XIMOfIC((XIC)ic);
             if (screc.text->encoding_is_wchar) {
-                c = ucs2tis(screc.text->string.wcs[0]);
-                XFree(screc.text->string.wcs);
+                conv = _XlcOpenConverter(im->core.lcd, XlcNWideChar,
+                                         im->core.lcd, XlcNCharSet);
+                from_buf = (char *) screc.text->string.wcs;
+                from_left = screc.text->length * sizeof(wchar_t);
             } else {
-                c = screc.text->string.mbs[0];
-                XFree(screc.text->string.mbs);
+                conv = _XlcOpenConverter(im->core.lcd, XlcNMultiByte,
+                                         im->core.lcd, XlcNCharSet);
+                from_buf = screc.text->string.mbs;
+                from_left = screc.text->length;
             }
+            to_buf = (char *)&c;
+            to_left = 1;
+
+            _XlcResetConverter(conv);
+            if (_XlcConvert(conv, (XPointer *)&from_buf, &from_left,
+                            (XPointer *)&to_buf, &to_left, NULL, 0) < 0)
+            {
+                c = (unsigned char) b->mb[b->tree[(ic)->private.local.context].mb];
+            }
+            _XlcCloseConverter(conv);
+
+            XFree(screc.text->string.mbs);
         }
         XFree(screc.text);
         return c;
-- 
1.6.2.2


Reply to: