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.

The attached file is a patch of libgtk2.0-0 package to make gtk2+
library support OverTheSpot mode.
It is written by Edward Liu <cp76 csie nctu edu tw>.
After some testing, we feel that this patch is stable enough to update
to the upstream.
Please consider to apply this.


If you're interesting, please read on...

The OverTheSpot mode of XIM will show a floating window sticking with
the cursor position when we are typing.
It is a example of the OverTheSpot mode:
( [CH| ] is the OverTheSpot window )
( | is the place of the cursor. )

I'm typing Chinese... |
                      [CH|]


I'm typing Chinese... |
                      [CH|hqi]

[hqi] is the code of the Chinese character.


I'm typing Chinese... (Ch#1)|
                            [CH|mylm]

[mylm] is the code of another Chinese character.


I'm typing Chinese... (Ch#1)(Ch#2)|
                                  [CH|klg]

[klg] is the code of another Chinese character.

I'm typing Chinese... (Ch#1)(Ch#2)(Ch#3)|
                                        [CH|cnkq]


You can see that the OverTheSpot window is always stick with the cursor
position.

The following is several graphic samples:
http://home.pchome.com.tw/net/tetralet/Linux/Gtk2_OverTheSpot_OpenOffice.png
http://home.pchome.com.tw/net/tetralet/Linux/Gtk2_OverTheSpot_gEdit.png
http://home.pchome.com.tw/net/tetralet/Linux/Firefox-OverTheSpot.png


Unlike OverTheSpot mode,
The Root mode of XIM will show a large, fixed and unmoveable window on
the screen.
It looks a little ugly and sometimes it will disturb the typing if the
input area were under the Root window.
And becouse it is unmoveable, it will be unpleasing if the input area
were too far away from the Root window.

The following is a graphic sample:
http://home.pchome.com.tw/net/tetralet/Linux/Firefox-Root.png

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


And, This patch is reported by bugzilla several months ago,
But there was no answer...
Please visit http://bugzilla.gnome.org/show_bug.cgi?id=158678 for more
details. 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]