diff -Naur fox-1.0.42.orig/configure fox-1.0.42-cur/configure
--- fox-1.0.42.orig/configure	Sat Jun 21 04:38:48 2003
+++ fox-1.0.42-cur/configure	Wed Jul  2 20:11:52 2003
@@ -7663,7 +7663,7 @@
     GL_TESTS="gltest glviewer"
     if test "x$MESA" = "xHAVE_MESA" ; then
       CXXFLAGS="${CXXFLAGS} -DHAVE_MESA"
-      GL_LIBS="-lMesaGL -lMesaGLU"
+      GL_LIBS="-lOSMesa -lGLU"
     else
       GL_LIBS="-lGL -lGLU"
     fi
diff -Naur fox-1.0.42.orig/src/FXApp.cpp fox-1.0.42-cur/src/FXApp.cpp
--- fox-1.0.42.orig/src/FXApp.cpp	Sat Jun 21 04:38:40 2003
+++ fox-1.0.42-cur/src/FXApp.cpp	Fri Jul  4 21:52:01 2003
@@ -790,6 +790,10 @@
     // What's going on
     FXTRACE((100,"%s::openDisplay: opening display.\n",getClassName()));
 #ifndef WIN32
+      // Preparation for XIM
+      if (!XSupportsLocale())
+          setlocale(LC_ALL, "C");
+      XSetLocaleModifiers("");
 
     // Set error handler
     XSetErrorHandler(xerrorhandler);
@@ -847,15 +851,6 @@
 #ifndef NO_XIM
     xic=NULL;
     xim=(void*)XOpenIM((Display*)display,NULL,NULL,NULL);
-    if(xim){
-#ifndef _AIX
-      xic=XCreateIC((XIM)xim,XNInputStyle,XIMPreeditNothing|XIMStatusNothing,XNClientWindow,XDefaultRootWindow((Display*)display),NULL);
-#else
-      // Suggested by Terry Bezue <terryb@nc.rr.com> for AIX
-      xic=XCreateIC((XIM)xim,XNInputStyle,XIMPreeditNothing|XIMStatusNone,XNClientWindow,XDefaultRootWindow((Display*)display),NULL);
-#endif
-      if(xic) XmbResetIC((XIC)xic);
-      }
 #endif
 
     // Window manager communication
@@ -1766,8 +1761,8 @@
   // Get an event
   XNextEvent((Display*)display,&ev);
 
-  // Filter event through input method context, if any
-  if(xim && XFilterEvent(&ev,XDefaultRootWindow((Display*)display))) return FALSE;
+    // Filter event through input method context, if any
+    if (XFilterEvent(&ev, None)) return FALSE;
 
   // Save expose events for later...
   if(ev.xany.type==Expose || ev.xany.type==GraphicsExpose){
@@ -2259,7 +2254,14 @@
             // Assign focus to innermost modal dialog, even when trying to focus
             // on another window; these other windows are dead to inputs anyway.
             // XSetInputFocus causes a spurious BadMatch error; we ignore this in xerrorhandler
-            XSetInputFocus((Display*)display,ev.xclient.window,RevertToParent,ev.xclient.data.l[1]);
+              XSetInputFocus((Display*) display, ev.xclient.window,
+                             RevertToParent, ev.xclient.data.l[1]);
+#ifndef NO_XIM
+              if (xim && xic) {
+                  XSetICValues((XIC) xic, XNFocusWindow, ev.xclient.window, NULL);
+                  XSetICFocus((XIC) xic);
+              }
+#endif
             }
           }
 
@@ -2948,7 +2950,7 @@
 #if defined(__BCPLUSPLUS__) || defined(__BORLANDC__)
   setlocale(LC_CTYPE,"C");  // Locale support broken under Borland C++ 5.5
 #else
-  setlocale(LC_CTYPE,"");
+    setlocale(LC_ALL, "");
 #endif
 
   // Try locate display
diff -Naur fox-1.0.42.orig/src/FXTopWindow.cpp fox-1.0.42-cur/src/FXTopWindow.cpp
--- fox-1.0.42.orig/src/FXTopWindow.cpp	Thu Aug  8 13:42:04 2002
+++ fox-1.0.42-cur/src/FXTopWindow.cpp	Sat Jul  5 00:02:10 2003
@@ -219,6 +219,38 @@
 
       // Set hints
       XSetWMNormalHints(DISPLAY(getApp()),xid,&size);
+
+#ifndef NO_XIM
+        // Create XIC
+        if (getApp()->xim && !getApp()->xic) {
+            static const XIMStyle candidate[] = {
+                (XIMPreeditNothing | XIMStatusNothing),
+                (XIMPreeditNothing | XIMStatusNone),
+                0 };
+            
+            XIMStyle style_selected = 0;
+            XIMStyles* im_styles;
+            XGetIMValues((XIM) getApp()->xim, XNQueryInputStyle, &im_styles, NULL);
+            for (int i = 0; candidate[i]; i++) {
+                for (int j = 0; j < im_styles->count_styles; j++) {
+                    if ((candidate[i] & im_styles->supported_styles[j]) == candidate[i]) {
+                        style_selected = im_styles->supported_styles[j];
+                        goto l1;
+                    }
+                }
+            }
+        l1:
+            XFree(im_styles);
+            if (style_selected) {
+                FXWindow* client = getApp()->mainWindow ? getApp()->mainWindow : this;
+                getApp()->xic = XCreateIC((XIM) getApp()->xim,
+                                          XNInputStyle, style_selected,
+                                          XNClientWindow, client->id(),
+                                          NULL);
+            }
+            if (getApp()->xic) XmbResetIC((XIC) getApp()->xic);
+        }
+#endif
 #endif
 
       // Set title
@@ -249,6 +281,12 @@
   if(xid){
 #ifndef WIN32
     XSetInputFocus(DISPLAY(getApp()),xid,RevertToPointerRoot,CurrentTime);
+#ifndef NO_XIM
+      if (getApp()->xim && getApp()->xic) {
+          XSetICValues((XIC) getApp()->xic, XNFocusWindow, xid, NULL);
+          XSetICFocus((XIC) getApp()->xic);
+      }
+#endif
 #else
     SetFocus((HWND)xid);
 #endif
@@ -269,6 +307,12 @@
       if(getOwner() && getOwner()->id()){
         FXTRACE((100,"back to owner\n"));
         XSetInputFocus(DISPLAY(getApp()),getOwner()->id(),RevertToPointerRoot,CurrentTime);
+#ifndef NO_XIM
+          if (getApp()->xim && getApp()->xic) {
+              XSetICValues((XIC) getApp()->xic, XNFocusWindow, getOwner()->id(), NULL);
+              XSetICFocus((XIC) getApp()->xic);
+          }
+#endif
         }
       else{
         FXTRACE((100,"back to NULL\n"));
diff -Naur fox-1.0.42.orig/src/FXWindow.cpp fox-1.0.42-cur/src/FXWindow.cpp
--- fox-1.0.42.orig/src/FXWindow.cpp	Mon Jun 16 00:23:02 2003
+++ fox-1.0.42-cur/src/FXWindow.cpp	Fri Jul  4 21:18:07 2003
@@ -2130,6 +2130,15 @@
     }
   }
 
+#if !defined(WIN32) && !defined(NO_XIM)
+static unsigned int get_im_event_mask(void* im, void* ic)
+{
+    static unsigned int im_event_mask = 0;
+    if (im && ic && !im_event_mask)
+        XGetICValues((XIC) ic, XNFilterEvents, &im_event_mask, NULL);
+    return im_event_mask;
+}
+#endif
 
 // Enable the window
 void FXWindow::enable(){
@@ -2137,7 +2146,12 @@
     flags|=FLAG_ENABLED;
     if(xid){
 #ifndef WIN32
-      FXuint events=BASIC_EVENT_MASK|ENABLED_EVENT_MASK;
+#ifndef NO_XIM
+        FXuint events = BASIC_EVENT_MASK | ENABLED_EVENT_MASK |
+                        get_im_event_mask(getApp()->xim, getApp()->xic);
+#else
+        FXuint events = BASIC_EVENT_MASK | ENABLED_EVENT_MASK;
+#endif
       if(flags&FLAG_SHELL) events|=SHELL_EVENT_MASK;
       XSelectInput(DISPLAY(getApp()),xid,events);
 #else
@@ -2155,7 +2169,11 @@
     flags&=~FLAG_ENABLED;
     if(xid){
 #ifndef WIN32
-      FXuint events=BASIC_EVENT_MASK;
+#ifndef NO_XIM
+        FXuint events = BASIC_EVENT_MASK | get_im_event_mask(getApp()->xim, getApp()->xic);
+#else
+        FXuint events = BASIC_EVENT_MASK;
+#endif
       if(flags&FLAG_SHELL) events|=SHELL_EVENT_MASK;
       XSelectInput(DISPLAY(getApp()),xid,events);
       if(getApp()->mouseGrabWindow==this){
