Re: A OverTheSpot patch for gtk 2.4.x and 2.6.x



Hi,

The OverTheSpot mode of XIM is the most common input method for
Chinese/Japanese users.
but it is a pity that gtk2+ library don't support it,
so that all the gtk2+ based applications, like Mozilla, Firefox,
Thunderbird, Gaim, gEdit, NVU... can not support the OverTheSpot mode.


There are several gif animations showing the defferents between
OnTheSpot and OverTheSpot mode.

We must key in *several* "codes" to get *one* Chinese character when
typing Chinese characters.


When using OnTheSpot mode,
The "code" will take about 4~5 Chinese character wide,
and it will make the whole line move (shake) too much when typing.

for example:
(We want to insert [Ch#02] between [Ch#01] and [Ch#03] )

  I'm typing Chinese... [Ch#01][Ch#03]
->
  I'm typing Chinese... [Ch#01](Code1)[Ch#03]
->
  I'm typing Chinese... [Ch#01](Code1)(Code2)[Ch#03]
->
  I'm typing Chinese... [Ch#01](Code1)(Code2)(Code3)[Ch#03]
->
  I'm typing Chinese... [Ch#01](Code1)(Code2)(Code3)(Code4)[Ch#03]
->
  I'm typing Chinese... [Ch#01][Ch#02][Ch#03]

You can see that the whole line grow and decrease so much when typing so
that we feel it is unpleasing when using.
(Sorry it is very hard to explain with words)
Please see the screenshot bellow:

 http://home.pchome.com.tw/net/tetralet/Linux/OnTheSpotNotGood.gif

And

 http://home.pchome.com.tw/net/tetralet/Linux/OnTheSpotNotGood2.gif


Unlike OnTheSpot mode,
We feel the OverTheSpot mode is more pleasing to use.

for example:
( [CH| ] is the OverTheSpot window )
( | is the place of the cursor. )

I'm typing Chinese... [Ch#01]|[Ch#03]
                             [CH|]

I'm typing Chinese... [Ch#01]|[Ch#03]
                             [CH|(Code1)(Code2)(Code3)(Code4)]

I'm typing Chinese... [Ch#01][Ch#02]|[Ch#03]
                                    [CH|]

Please see the screenshot bellow:

 http://home.pchome.com.tw/net/tetralet/Linux/OverTheSpotIsBetter.gif


I think that gtk+ 2 is a low-level core libraryvery basic library,
So that I think it should trying to support *all* the input modes.
If someone don't like to use OverTheSpot mode, he/she can swith to
OnTheSpot mode.
I don't think gtk+ 2 don't support OverTheSpot at all is a very good idea.

We feel that this patch is very important to us.
Please consider to apply this. Thanks.

diff -uNr gtk+-2.4.13.orig/modules/input/gtkimcontextxim.c gtk+-2.4.13/modules/input/gtkimcontextxim.c
--- gtk+-2.4.13.orig/modules/input/gtkimcontextxim.c	2004-11-22 05:00:27.000000000 +0800
+++ gtk+-2.4.13/modules/input/gtkimcontextxim.c	2004-11-22 05:02:51.000000000 +0800
@@ -179,7 +179,7 @@
 		      XIMPreeditArea | XIMPreeditNothing | XIMPreeditNone)
 #define STATUS_MASK (XIMStatusCallbacks | XIMStatusArea | \
 		      XIMStatusNothing | XIMStatusNone)
-#define ALLOWED_MASK (XIMPreeditCallbacks | XIMPreeditNothing | XIMPreeditNone | \
+#define ALLOWED_MASK (XIMPreeditCallbacks | XIMPreeditNothing | XIMPreeditNone | XIMPreeditPosition | \
 		      XIMStatusCallbacks | XIMStatusNothing | XIMStatusNone)
 
 static XIMStyle 
@@ -263,6 +263,10 @@
 		NULL);
   if (preedit_style == GTK_IM_PREEDIT_CALLBACK)
     info->preedit_style_setting = XIMPreeditCallbacks;
+#if 0
+  else if (preedit_style == GTK_IM_PREEDIT_POSITION)
+    info->preedit_style_setting = XIMPreeditpPosition;
+#endif
   else if (preedit_style == GTK_IM_PREEDIT_NOTHING)
     info->preedit_style_setting = XIMPreeditNothing;
   else if (preedit_style == GTK_IM_PREEDIT_NONE)
@@ -806,7 +810,7 @@
     return;
 
   spot.x = area->x;
-  spot.y = area->y;
+  spot.y = area->y + area->height;
 
   preedit_attr = XVaCreateNestedList (0,
 				      XNSpotLocation, &spot,
@@ -1412,6 +1416,36 @@
       else
 	im_style |= XIMStatusNothing;
 
+      XFontSet fontset = NULL;
+
+      if ((context_xim->im_info->style & PREEDIT_MASK) == XIMPreeditPosition) {
+        XPoint          spot;
+        spot.x = spot.y = 0;
+        XRectangle      rect;
+        rect.x = rect.y = 0;
+        rect.width = rect.height = 32;
+
+        int missing_charsetcount;
+        char **missing_charsetlist, *def_string;
+
+        fontset = XCreateFontSet(GDK_DISPLAY(),
+                                          "10x20,10x20",
+                                          &missing_charsetlist,
+                                          &missing_charsetcount,
+                                          &def_string);
+
+        list1 = XVaCreateNestedList(0,
+                    XNArea, &rect,
+                    XNSpotLocation, &spot,
+                    XNForeground, 0,
+                    XNBackground, 0,
+                    XNFontSet, fontset,
+          NULL);
+
+        im_style = XIMPreeditPosition| XIMStatusNothing;
+        name1 = XNPreeditAttributes;
+      }
+
       xic = XCreateIC (context_xim->im_info->im,
 		       XNInputStyle, im_style,
 		       XNClientWindow, GDK_DRAWABLE_XID (context_xim->client_window),


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