diff -urN wine-20031016/controls/edit.c wine-20031016-xim-jp106/controls/edit.c
--- wine-20031016/controls/edit.c	2003-09-17 13:28:29.000000000 +0900
+++ wine-20031016-xim-jp106/controls/edit.c	2003-10-19 11:32:57.000000000 +0900
@@ -59,6 +59,7 @@
 WINE_DEFAULT_DEBUG_CHANNEL(edit);
 WINE_DECLARE_DEBUG_CHANNEL(combo);
 WINE_DECLARE_DEBUG_CHANNEL(relay);
+WINE_DECLARE_DEBUG_CHANNEL(xim);
 
 #define BUFLIMIT_MULTI		65534	/* maximum buffer size (not including '\0')
 					   FIXME: BTW, new specs say 65535 (do you dare ???) */
diff -urN wine-20031016/dlls/comctl32/comctl_Ja.rc wine-20031016-xim-jp106/dlls/comctl32/comctl_Ja.rc
--- wine-20031016/dlls/comctl32/comctl_Ja.rc	1970-01-01 09:00:00.000000000 +0900
+++ wine-20031016-xim-jp106/dlls/comctl32/comctl_Ja.rc	2003-10-19 11:32:57.000000000 +0900
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2003 Hajime Segawa
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
+
+IDD_PROPSHEET DIALOG DISCARDABLE 0, 0, 220, 140
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE
+CAPTION "Properties for "
+FONT 9, "MS UI Gothic"
+BEGIN
+  DEFPUSHBUTTON "OK",     IDOK,4,122,50,14, WS_TABSTOP | WS_GROUP
+  PUSHBUTTON    "キャンセル", IDCANCEL,58,122,50,14
+  PUSHBUTTON    "適用(&A)", IDC_APPLY_BUTTON,112,122,50,14,WS_DISABLED
+  PUSHBUTTON    "ヘルプ",   IDHELP,166,122,50,14,WS_TABSTOP|WS_GROUP
+  CONTROL       "Tab",    IDC_TABCONTROL,"SysTabControl32",WS_CLIPSIBLINGS|WS_GROUP|WS_TABSTOP,4,4,212,114
+END
+
+
+IDD_WIZARD DIALOG DISCARDABLE 0, 0, 290, 159
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE
+CAPTION "Wizard"
+FONT 9, "MS UI Gothic"
+BEGIN
+  DEFPUSHBUTTON "完了",  IDC_FINISH_BUTTON,121,138,50,14
+  DEFPUSHBUTTON "進む(&N) >", IDC_NEXT_BUTTON,121,138,50,14
+  PUSHBUTTON    "< 戻る(&B)", IDC_BACK_BUTTON,71,138,50,14
+  PUSHBUTTON    "キャンセル",  IDCANCEL,178,138,50,14
+  PUSHBUTTON    "ヘルプ",    IDHELP,235,138,50,14,WS_GROUP
+  LTEXT         "",        IDC_SUNKEN_LINE,7,129,278,1,SS_SUNKEN
+  CONTROL       "Tab",     IDC_TABCONTROL,"SysTabControl32",WS_CLIPSIBLINGS | WS_DISABLED,7,7,258,5
+END
+
+
+IDD_TBCUSTOMIZE DIALOG DISCARDABLE 10, 20, 357, 125
+STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "Customize Toolbar"
+FONT 9, "MS UI Gothic"
+BEGIN
+  DEFPUSHBUTTON "閉じる(&C)",     IDCANCEL,308,6,44,14
+  PUSHBUTTON    "リセット(R&)",     IDC_RESET_BTN,308,23,44,14
+  PUSHBUTTON    "ヘルプ(&H)",      IDC_HELP_BTN,308,40,44,14
+  PUSHBUTTON    "上へ (&U)",   IDC_MOVEUP_BTN,308,74,44,14
+  PUSHBUTTON    "下へ (&D)", IDC_MOVEDN_BTN,308,91,44,14
+  LTEXT         "A&vailable buttons:", -1,4,5,84,10
+  LISTBOX       IDC_AVAILBTN_LBOX,4,17,120,100, LBS_NOTIFY | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP
+  PUSHBUTTON    "追加(&A) ->",    IDOK, 131, 42, 44, 14
+  PUSHBUTTON    "<- 削除(&R)", IDC_REMOVE_BTN,131,62,44,14
+  LTEXT         "&Toolbar buttons:", -1,182,5,78,10
+  LISTBOX       IDC_TOOLBARBTN_LBOX, 182,17,120,100,LBS_NOTIFY | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP
+END
+
+STRINGTABLE DISCARDABLE
+{
+    IDS_CLOSE    "Close"
+}
+
+STRINGTABLE DISCARDABLE
+{
+    IDM_TODAY    "Today:"
+    IDM_GOTODAY  "Go to today"
+}
+
+STRINGTABLE DISCARDABLE
+{
+    IDS_SEPARATOR "Separator"
+}
+
+STRINGTABLE DISCARDABLE
+{
+    HKY_NONE "None"
+}
diff -urN wine-20031016/dlls/comctl32/rsrc.rc wine-20031016-xim-jp106/dlls/comctl32/rsrc.rc
--- wine-20031016/dlls/comctl32/rsrc.rc	2003-10-03 14:01:34.000000000 +0900
+++ wine-20031016-xim-jp106/dlls/comctl32/rsrc.rc	2003-10-19 11:32:57.000000000 +0900
@@ -1064,3 +1064,4 @@
 #include "comctl_Pt.rc"
 #include "comctl_Ru.rc"
 #include "comctl_Si.rc"
+#include "comctl_Ja.rc"
diff -urN wine-20031016/dlls/commdlg/cdlg_Ja.rc wine-20031016-xim-jp106/dlls/commdlg/cdlg_Ja.rc
--- wine-20031016/dlls/commdlg/cdlg_Ja.rc	2003-07-29 04:14:24.000000000 +0900
+++ wine-20031016-xim-jp106/dlls/commdlg/cdlg_Ja.rc	2003-10-19 11:32:57.000000000 +0900
@@ -25,7 +25,7 @@
 OPEN_FILE DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 275, 134
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "ファイルを開く"
-FONT 8, "ＭＳ Ｐゴシック"
+FONT 9, "MS UI Gothic"
 {
  LTEXT "ファイル名(&N):", 1090, 6, 6, 76, 9
  EDITTEXT 1152, 6, 16, 90, 12, ES_AUTOHSCROLL | ES_OEMCONVERT | WS_BORDER | WS_TABSTOP
@@ -47,7 +47,7 @@
 SAVE_FILE DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 275, 134
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "名前をつけて保存"
-FONT 8, "ＭＳ Ｐゴシック"
+FONT 9, "MS UI Gothic"
 {
  LTEXT "ファイル名(&N):", 1090, 6, 6, 76, 9
  EDITTEXT 1152, 6, 16, 90, 12, ES_AUTOHSCROLL | ES_OEMCONVERT | WS_BORDER | WS_TABSTOP
@@ -69,7 +69,7 @@
 PRINT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 134
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "印刷"
-FONT 8, "ＭＳ Ｐゴシック"
+FONT 9, "MS UI Gothic"
 {
  LTEXT "使用するﾌﾟﾘﾝﾀ:", 1088, 6, 6, 40, 9
  LTEXT "通常使うﾌﾟﾘﾝﾀ", 1089, 60, 6, 150, 9
@@ -92,7 +92,7 @@
 PRINT_SETUP DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 134
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "プリンタの設定"
-FONT 8, "ＭＳ Ｐゴシック"
+FONT 9, "MS UI Gothic"
 {
  GROUPBOX "プリンタの選択", 1072, 6, 10, 180, 65, BS_GROUPBOX
  RADIOBUTTON "通常使うプリンタ(&D)", 1056, 16, 20, 80, 12
@@ -118,7 +118,7 @@
 CHOOSE_FONT DIALOG DISCARDABLE  13, 54, 264, 147
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "フォントの指定"
-FONT 8, "ＭＳ Ｐゴシック"
+FONT 9, "MS UI Gothic"
 {
     LTEXT           "ﾌｫﾝﾄ名(&F):",1088 ,6,3,40,9
     COMBOBOX        1136 ,6,13,94,54,  CBS_OWNERDRAWFIXED | CBS_HASSTRINGS | CBS_DISABLENOSCROLL |
@@ -147,7 +147,7 @@
 CHOOSE_COLOR DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 300, 185
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "色の設定"
-FONT 8, "ＭＳ Ｐゴシック"
+FONT 9, "MS UI Gothic"
 {
  LTEXT "基本色(&B):",   1088, 4,    4,  140, 10
  LTEXT "作成した色(&C):",  1089, 4,   106, 140, 10
@@ -181,7 +181,7 @@
 FINDDLGORD DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 236, 62
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "文字列の検索"
-FONT 8, "ＭＳ Ｐゴシック"
+FONT 9, "MS UI Gothic"
 {
  LTEXT "検索する文字列(&N):", -1, 4, 8, 42, 8
  EDITTEXT 1152, 47, 7, 128, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
@@ -200,7 +200,7 @@
 REPLACEDLGORD DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 230, 94
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "文字列の置換"
-FONT 8, "ＭＳ Ｐゴシック"
+FONT 9, "MS UI Gothic"
 {
  LTEXT "置換前の文字列(&N):", -1, 4, 9, 48, 8
  EDITTEXT 1152, 54, 7, 114, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
@@ -221,7 +221,7 @@
 STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU |
       DS_CONTEXTHELP | DS_3DLOOK
 CAPTION "印刷"
-FONT 8, "ＭＳ Ｐゴシック"
+FONT 9, "MS UI Gothic"
 {
     DEFPUSHBUTTON   "OK",     IDOK,     180,164, 48,14, WS_GROUP | BS_DEFPUSHBUTTON
     PUSHBUTTON      "ｷｬﾝｾﾙ", IDCANCEL, 232,164, 48,14, WS_GROUP
@@ -261,7 +261,7 @@
 STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU |
       DS_CONTEXTHELP | DS_3DLOOK
 CAPTION "印刷の設定"
-FONT 8, "ＭＳ Ｐゴシック"
+FONT 9, "MS UI Gothic"
 BEGIN
     DEFPUSHBUTTON   "OK",IDOK,180,156,48,14,WS_GROUP
     PUSHBUTTON      "Cancel",IDCANCEL,232,156,48,14
@@ -295,7 +295,7 @@
 NEWFILEOPENORD DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 280, 164
 STYLE DS_MODALFRAME | DS_CONTEXTHELP | WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_CLIPCHILDREN
 CAPTION "ﾌｧｲﾙを開く"
-FONT 8, "ＭＳ Ｐゴシック"
+FONT 9, "MS UI Gothic"
 {
     LTEXT	"ﾌｧｲﾙの場所(&I):",IDC_LOOKINSTATIC,5,6,52,8, SS_NOTIFY
     COMBOBOX	IDC_LOOKIN,56,3,132,100,CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
diff -urN wine-20031016/dlls/kernel/locale.c wine-20031016-xim-jp106/dlls/kernel/locale.c
--- wine-20031016/dlls/kernel/locale.c	2003-10-16 05:57:49.000000000 +0900
+++ wine-20031016-xim-jp106/dlls/kernel/locale.c	2003-10-19 11:53:01.000000000 +0900
@@ -62,6 +62,7 @@
     UINT        codepage;
 } charset_names[] =
 {
+    { "eucJP", 20932 },
     { "CP1250", 1250 },
     { "CP1251", 1251 },
     { "CP1252", 1252 },
@@ -112,6 +113,7 @@
 typedef struct {
     char lang[128];
     char country[128];
+    char charset[128];
     LANGID found_lang_id[NLS_MAX_LANGUAGES];
     char found_language[NLS_MAX_LANGUAGES][3];
     char found_country[NLS_MAX_LANGUAGES][3];
@@ -295,7 +297,9 @@
     LCID lcid = MAKELCID(LangID, SORT_DEFAULT);
     char buf_language[128];
     char buf_country[128];
+    char buf_charset[128];
     char buf_en_language[128];
+    char *p, *q;
 
     TRACE("%04X\n", (UINT)LangID);
     if(PRIMARYLANGID(LangID) == LANG_NEUTRAL)
@@ -303,6 +307,7 @@
 
     buf_language[0] = 0;
     buf_country[0] = 0;
+    buf_charset[0] = '\0';
 
     GetLocaleInfoA(lcid, LOCALE_SISO639LANGNAME|LOCALE_NOUSEROVERRIDE|LOCALE_USE_CP_ACP,
                    buf_language, sizeof(buf_language));
@@ -312,18 +317,67 @@
                    buf_country, sizeof(buf_country));
     TRACE("LOCALE_SISO3166CTRYNAME: %s\n", buf_country);
 
+    GetLocaleInfoA(lcid, LOCALE_SCHARSETNAMES|LOCALE_NOUSEROVERRIDE|LOCALE_USE_CP_ACP,
+                  buf_charset, sizeof(buf_charset));
+    TRACE("LOCALE_SCHARSETNAMES: %s\n", buf_charset);
+    
     if(l_data->lang[0] && !strcasecmp(l_data->lang, buf_language))
     {
         if(l_data->country[0])
         {
             if(!strcasecmp(l_data->country, buf_country))
             {
+#if (0)
                 l_data->found_lang_id[0] = LangID;
                 l_data->n_found = 1;
                 TRACE("Found lang_id %04X for %s_%s\n", LangID, l_data->lang, l_data->country);
                 return FALSE; /* stop enumeration */
+#endif
+ 
+                if (l_data->charset != NULL && strlen(l_data->charset) > 0) {
+                   p = buf_charset;
+                   do {
+                   q = p;
+                   if ((p = strchr(p, ',')) != NULL) {
+                      *p++ = '\0';
+                   }
+                   TRACE("q = 0x%x, %s\n", q, ((q == NULL) ? "" : q));
+                      if (q != NULL && strcasecmp(l_data->charset, q) == 0) {
+                         l_data->found_lang_id[0] = LangID;
+                         l_data->n_found = 1;
+                         TRACE("Found lang_id %04X for %s_%s.%s\n", LangID, l_data->lang, l_data->country, l_data->charset);
+                         return FALSE;
+                      }
+                   } while (p != NULL);
+
+                } else {
+                   p = buf_charset;
+                   do {
+                   q = p;
+                   if ((p = strchr(p, ',')) != NULL) {
+                      *p++ = '\0';
+                   }
+                   TRACE("q = 0x%x, %s\n", q, ((q == NULL) ? "" : q));
+                      if (q == NULL || *q == '\0') {
+                         l_data->found_lang_id[0] = LangID;
+                         l_data->n_found = 1;
+                         TRACE("Found lang_id %04X for %s_%s\n", LangID, l_data->lang, l_data->country);
+                         return FALSE;
+                      }
+                   } while (p != NULL);
+                }
+
+                if (l_data->n_found < NLS_MAX_LANGUAGES) {
+                   l_data->found_lang_id[l_data->n_found] = LangID;
+                   strncpy(l_data->found_country[l_data->n_found], buf_country, 3);
+                   strncpy(l_data->found_language[l_data->n_found], buf_language, 3);
+                   l_data->n_found++;
+                   TRACE("Found lang_id %04X for %s_%s\n", LangID, l_data->lang, l_data->country);
+                   return TRUE;
+                }
             }
         }
+
         else /* l_data->country not specified */
         {
             if(l_data->n_found < NLS_MAX_LANGUAGES)
@@ -382,6 +436,9 @@
     char lang_string[256];
     HMODULE hKernel32;
 
+    TRACE(" Lang(%s) Country(%s) CharSet(%s) Dialect(%s)\n",
+	Lang, Country, Charset, Dialect);
+
     if(!Lang)
     {
         l_data.found_lang_id[0] = MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT);
@@ -406,6 +463,15 @@
         strcat(lang_string, l_data.country);
     }
 
+    if (!l_data.n_found) {
+	if (l_data.charset != NULL && strlen(l_data.charset) > 0) {
+	    MESSAGE("Warning: Language '%s.%s' was not found, retrying without charset name...\n", lang_string, l_data.charset);
+	    l_data.charset[0] = '\0';
+	    EnumResourceLanguagesA(GetModuleHandleA("KERNEL32"), (LPSTR)RT_STRING,
+		(LPCSTR) LOCALE_ILANGUAGE, find_language_id_proc, (LONG) &l_data);
+	}
+    }
+
     if(!l_data.n_found)
     {
         if(l_data.country[0])
@@ -425,6 +491,11 @@
         strcat(lang_string, l_data.country);
     }
 
+    if (l_data.charset != NULL && strlen(l_data.charset) > 0) {
+	strcat(lang_string, ".");
+	strcat(lang_string, l_data.charset);
+    }
+
     if(!l_data.n_found)
     {
         MESSAGE("Warning: Language '%s' was not recognized, defaulting to English\n", lang_string);
diff -urN wine-20031016/dlls/user/resources/user32_Ja.rc wine-20031016-xim-jp106/dlls/user/resources/user32_Ja.rc
--- wine-20031016/dlls/user/resources/user32_Ja.rc	2002-06-01 11:55:50.000000000 +0900
+++ wine-20031016-xim-jp106/dlls/user/resources/user32_Ja.rc	2003-10-19 11:32:57.000000000 +0900
@@ -51,7 +51,7 @@
 
 MSGBOX DIALOG 100, 80, 216, 168
 STYLE DS_SYSMODAL | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
-FONT 8, "ＭＳ Ｐゴシック"
+FONT 8, "MS UI Gothic"
 BEGIN
         ICON "", 1088, 8, 20, 16, 16, WS_CHILD | WS_VISIBLE
         LTEXT "", 100, 32, 4, 176, 48, WS_CHILD | WS_VISIBLE | WS_GROUP
diff -urN wine-20031016/dlls/x11drv/X11_calls wine-20031016-xim-jp106/dlls/x11drv/X11_calls
--- wine-20031016/dlls/x11drv/X11_calls	2002-09-25 12:29:55.000000000 +0900
+++ wine-20031016-xim-jp106/dlls/x11drv/X11_calls	2003-10-19 11:32:57.000000000 +0900
@@ -10,13 +10,16 @@
 XChangeGC
 XChangeProperty
 XChangeWindowAttributes
+XCloseIM
 XCopyArea
 XCopyPlane
 XCreateBitmapFromData
 XCreateColormap
+XCreateFontSet
 XCreatePixmap
 XDefineCursor
 XDeleteProperty
+XDestroyIC
 XDrawArc
 XDrawLine
 XDrawLines
@@ -26,13 +29,16 @@
 XFillArc
 XFillPolygon
 XFillRectangle
+XFilterEvent
 XFlush
 XFree
 XFreeColormap
 XFreeColors
 XFreeFont
 XFreeFontNames
+XFreeFontSet
 XFreePixmap
+XFreeStringList
 XGetAtomName
 XGetFontProperty
 XGetGeometry
@@ -66,6 +72,7 @@
 XSetForeground
 XSetFunction
 XSetGraphicsExposures
+XSetICFocus
 XSetLineAttributes
 XSetScreenSaver
 XSetSelectionOwner
@@ -78,3 +85,5 @@
 XUngrabServer
 XUninstallColormap
 XUnmapWindow
+XUnsetICFocus
+XmbLookupString
diff -urN wine-20031016/dlls/x11drv/event.c wine-20031016-xim-jp106/dlls/x11drv/event.c
--- wine-20031016/dlls/x11drv/event.c	2003-09-06 08:08:26.000000000 +0900
+++ wine-20031016-xim-jp106/dlls/x11drv/event.c	2003-10-19 11:32:57.000000000 +0900
@@ -52,6 +52,7 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(event);
 WINE_DECLARE_DEBUG_CHANNEL(clipboard);
+WINE_DECLARE_DEBUG_CHANNEL(xim);
 
 /* X context to associate a hwnd to an X window */
 extern XContext winContext;
@@ -142,12 +143,13 @@
     wine_tsx11_lock();
     while ( XPending( data->display ) )
     {
-        Bool ignore;
+        //Bool ignore;
 
         XNextEvent( data->display, &event );
-        ignore = XFilterEvent( &event, None );
+        //ignore = XFilterEvent( &event, None );
         wine_tsx11_unlock();
-        if (!ignore) EVENT_ProcessEvent( &event );
+	//if (!ignore) EVENT_ProcessEvent( &event );
+	EVENT_ProcessEvent( &event );
         count++;
         wine_tsx11_lock();
     }
@@ -204,7 +206,14 @@
   HWND hWnd;
   Display *display = event->xany.display;
 
-  TRACE( "called.\n" );
+  if( event->type != KeyPress && event->type != KeyRelease
+      && TSXFilterEvent(event, None))
+  {
+    TRACE_(xim)("Filtered event: %s(%d) window %08x\n",
+		event_names[event->type],
+		event->type, (unsigned int)event->xany.window);
+    return;
+  }
 
   switch (event->type)
   {
diff -urN wine-20031016/dlls/x11drv/keyboard.c wine-20031016-xim-jp106/dlls/x11drv/keyboard.c
--- wine-20031016/dlls/x11drv/keyboard.c	2003-10-15 05:07:03.000000000 +0900
+++ wine-20031016-xim-jp106/dlls/x11drv/keyboard.c	2003-10-19 11:32:57.000000000 +0900
@@ -49,10 +49,13 @@
 #include "win.h"
 #include "x11drv.h"
 #include "wine/debug.h"
+#include "heap.h"
+
 
 WINE_DEFAULT_DEBUG_CHANNEL(keyboard);
 WINE_DECLARE_DEBUG_CHANNEL(key);
 WINE_DECLARE_DEBUG_CHANNEL(dinput);
+WINE_DECLARE_DEBUG_CHANNEL(xim);
 
 int min_keycode, max_keycode, keysyms_per_keycode;
 WORD keyc2vkey[256], keyc2scan[256];
@@ -79,6 +82,20 @@
    0x56 /* the 102nd key (actually to the right of l-shift) */
 };
 
+static const WORD main_key_scan_jp106[MAIN_LEN] =
+{
+/* this is 106-key keyboard layout */
+ /* 1    2    3    4    5    6    7    8    9    0    -    ^    \ */
+   0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x90,0x7D,
+/*  q    w    e    r    t    y    u    i    o    p    @    [ */
+   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x91,0x1A,
+/*  a    s    d    f    g    h    j    k    l    ;    :    ] */
+   0x1E,0x1F,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x92,0x1B,
+/*  z    x    c    v    b    n    m    ,    .    / */
+   0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35,
+   0x93 /* the 102nd key (actually to the right of l-shift) */
+};
+
 static const WORD main_key_scan_abnt_qwerty[MAIN_LEN] =
 {
  /* `    1    2    3    4    5    6    7    8    9    0    -    = */
@@ -115,6 +132,16 @@
    VK_OEM_102 /* the 102nd key (actually to the right of l-shift) */
 };
 
+static const WORD main_key_vkey_jp106[MAIN_LEN] =
+{
+/* NOTE: this layout must concur with the scan codes layout above */
+   VK_1,VK_2,VK_3,VK_4,VK_5,VK_6,VK_7,VK_8,VK_9,VK_0,VK_OEM_MINUS,VK_OEM_7,VK_OEM_5,
+   VK_Q,VK_W,VK_E,VK_R,VK_T,VK_Y,VK_U,VK_I,VK_O,VK_P,VK_OEM_3,VK_OEM_4,
+   VK_A,VK_S,VK_D,VK_F,VK_G,VK_H,VK_J,VK_K,VK_L,VK_OEM_PLUS,VK_OEM_1,VK_OEM_6,
+   VK_Z,VK_X,VK_C,VK_V,VK_B,VK_N,VK_M,VK_OEM_COMMA,VK_OEM_PERIOD,VK_OEM_2,
+   VK_OEM_102 /* the 102nd key (actually to the right of l-shift) */
+};
+
 static const WORD main_key_vkey_abnt_qwerty[MAIN_LEN] =
 {
 /* NOTE: this layout must concur with the scan codes layout above */
@@ -722,8 +749,8 @@
  {"Slovenian keyboard layout", &main_key_SI, &main_key_scan_qwerty, &main_key_vkey_qwerty},
  {"Croatian keyboard layout", &main_key_HR, &main_key_scan_qwerty, &main_key_vkey_qwerty},
  {"Croatian keyboard layout (specific)", &main_key_HR_jelly, &main_key_scan_qwerty, &main_key_vkey_qwerty},
- {"Japanese 106 keyboard layout", &main_key_JA_jp106, &main_key_scan_qwerty, &main_key_vkey_qwerty},
- {"Japanese pc98x1 keyboard layout", &main_key_JA_pc98x1, &main_key_scan_qwerty, &main_key_vkey_qwerty},
+ {"Japanese 106 keyboard layout", &main_key_JA_jp106, &main_key_scan_jp106, &main_key_vkey_jp106},
+ {"Japanese pc98x1 keyboard layout", &main_key_JA_pc98x1, &main_key_scan_jp106, &main_key_vkey_jp106},
  {"Slovak keyboard layout", &main_key_SK, &main_key_scan_qwerty, &main_key_vkey_qwerty},
  {"Slovak and Czech keyboard layout without dead keys", &main_key_SK_prog, &main_key_scan_qwerty, &main_key_vkey_qwerty},
  {"Czech keyboard layout", &main_key_CS, &main_key_scan_qwerty, &main_key_vkey_qwerty},
@@ -987,6 +1014,120 @@
     KEYBOARD_UpdateOneState( VK_SHIFT, shift, time );
 }
 
+#define NALLOC 64
+static BOOL XIM_KeyEvent(HWND hwnd, XKeyEvent *event, Window client_window,
+			 XIC xic)
+{
+    static BOOL updatedXIMPos = 0;
+    BOOL done = FALSE;
+    struct x11drv_thread_data *data = NtCurrentTeb()->driver_data;
+
+    if (xic == NULL)
+    {
+        WARN_(xim)("Unable tp retrieve input context\n");
+	return FALSE;
+    }
+
+    TRACE_(xim)("hwnd %04x event_window(%08lx) client_window(%08lx)\n",
+				(unsigned int) hwnd, event->window, client_window);
+
+    if (!data->xim)
+        done = FALSE; /* No input method defined */
+    else if (TSXFilterEvent((XEvent *) event, client_window))
+    {
+        TRACE_(xim)("Filtered.\n");
+	if (!updatedXIMPos)
+	{
+	    POINT p;
+	    XPoint spot;
+	    XVaNestedList preedit_attr;
+	    GetCaretPos(&p);
+	    //ClientToScreen(hwnd, &p);
+	    spot.x = p.x;
+	    spot.y = p.y;
+	    spot.y += 14;   //FIXME: How to get the caret's height
+	    preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL);
+	    XSetICValues(xic, XNPreeditAttributes, preedit_attr, NULL);
+	    TSXFree(preedit_attr);
+	    /* use this variable to check whether we need to update XIM position */
+	    updatedXIMPos = 1;
+	}
+        done = TRUE;
+    }
+    else if (event->type == KeyPress)
+    {
+        KeySym keysym;
+        Status status;
+        int i, nbyte;
+	INT codepage;
+        DWORD dwOutput;
+        WCHAR wcOutput[NALLOC];
+        LPSTR bytes;
+        DWORD nalloc = NALLOC;
+
+        updatedXIMPos = 0;
+
+        bytes = HeapAlloc(GetProcessHeap(),0,NALLOC);
+
+        nbyte = TSXmbLookupString(xic, event, bytes, nalloc, &keysym, &status);
+        TRACE_(xim)("nbyte = %d, status = 0x%x\n", nbyte, status);
+
+        if (status == XBufferOverflow)
+        {
+	    nalloc = nbyte;
+            bytes = HeapReAlloc(GetProcessHeap(), 0, bytes, nbyte);
+            nbyte = TSXmbLookupString(xic, event, bytes, nalloc, &keysym, &status);
+            TRACE_(xim)("nbyte = %d, status = 0x%x\n", nbyte, status);
+        }
+
+        switch (status)
+        {
+        case XLookupBoth:
+            if (keysym < 128 || (keysym & 0xff00) == 0xff00)
+            {
+                TRACE_(xim)("keysym = 0x%x\n", (int)keysym);
+		break; /* Leave to the default handler */
+            }
+	    /* fall through */
+        case XLookupChars:
+            codepage = GetACP();
+            if (codepage == 932)
+            {
+                /*
+                 * Japanese is encoded with windows as SJIS (932) however
+                 * Under unix we use EUS (20932) So we need to translate
+                 * the input as 20932...
+                 */
+                dwOutput = MultiByteToWideChar(20932, 0, bytes, nbyte,
+					       wcOutput, sizeof(wcOutput));
+            }
+            else dwOutput = MultiByteToWideChar(codepage, 0, bytes, nbyte,
+						wcOutput, sizeof(wcOutput));
+
+	    for(i=0; i<dwOutput; i++)
+	    {
+	        TRACE_(xim)("sending wchar %04x\n", wcOutput[i]);
+		PostMessageW(hwnd, WM_IME_CHAR, wcOutput[i], 1);
+	    }
+            done = True;
+            break;
+
+        case XLookupKeySym:
+            TRACE_(xim)("XLookupKeySym\n");
+            break; /* Leave to the default handler */
+
+        case XLookupNone:
+            TRACE_(xim)("XLookupNone\n");
+            done = True; /* No further processing is necessary */
+            break;
+        }
+
+        HeapFree(GetProcessHeap(),0,bytes);
+    }
+    return done;
+}
+
+
 /***********************************************************************
  *           X11DRV_KeyEvent
  *
@@ -1002,6 +1143,11 @@
     XIC xic = X11DRV_get_ic( hwnd );
     DWORD event_time = event->time - X11DRV_server_startticks;
 
+    /* forward to XIM */
+    if (XIM_KeyEvent(GetFocus(), event, X11DRV_get_client_window(hwnd), xic)
+	&& event->type == KeyPress)
+	return;
+
     wine_tsx11_lock();
     if (xic)
         ascii_chars = XmbLookupString(xic, event, Str, sizeof(Str), &keysym, NULL);
diff -urN wine-20031016/dlls/x11drv/ts_xlib.c wine-20031016-xim-jp106/dlls/x11drv/ts_xlib.c
--- wine-20031016/dlls/x11drv/ts_xlib.c	2002-09-25 12:29:55.000000000 +0900
+++ wine-20031016-xim-jp106/dlls/x11drv/ts_xlib.c	2003-10-19 11:32:57.000000000 +0900
@@ -9,6 +9,7 @@
 #ifdef HAVE_X11_XLIB_H
 
 #include <X11/Xlib.h>
+#include <X11/Xutil.h>
 
 #include "ts_xlib.h"
 
@@ -670,6 +671,22 @@
   return r;
 }
 
+XFontSet  TSXCreateFontSet(Display* a0, const  char* a1, char*** a2, int* a3, char** a4)
+{
+  XFontSet  r;
+  wine_tsx11_lock();
+  r = XCreateFontSet(a0, a1, a2, a3, a4);
+  wine_tsx11_unlock();
+  return r;
+}
+
+void  TSXFreeFontSet(Display* a0, XFontSet a1)
+{
+  wine_tsx11_lock();
+  XFreeFontSet(a0, a1);
+  wine_tsx11_unlock();
+}
+
 XIM  TSXOpenIM(Display* a0, struct _XrmHashBucketRec* a1, char* a2, char* a3)
 {
   XIM  r;
@@ -679,4 +696,29 @@
   return r;
 }
 
+void  TSXSetICFocus(XIC a0)
+{
+  wine_tsx11_lock();
+  XSetICFocus(a0);
+  wine_tsx11_unlock();
+}
+
+int   TSXFilterEvent(XEvent* a0, Window a1)
+{
+  int   r;
+  wine_tsx11_lock();
+  r = XFilterEvent(a0, a1);
+  wine_tsx11_unlock();
+  return r;
+}
+
+int  TSXmbLookupString(XIC a0, XKeyPressedEvent* a1, char* a2, int a3, KeySym* a4, int * a5)
+{
+  int  r;
+  wine_tsx11_lock();
+  r = XmbLookupString(a0, a1, a2, a3, a4, a5);
+   wine_tsx11_unlock();
+   return r;
+}
+
 #endif /* defined(HAVE_X11_XLIB_H) */
diff -urN wine-20031016/dlls/x11drv/ts_xlib.h wine-20031016-xim-jp106/dlls/x11drv/ts_xlib.h
--- wine-20031016/dlls/x11drv/ts_xlib.h	2002-09-25 12:29:55.000000000 +0900
+++ wine-20031016-xim-jp106/dlls/x11drv/ts_xlib.h	2003-10-19 11:32:57.000000000 +0900
@@ -92,7 +92,12 @@
 extern int  TSXUngrabServer(Display*);
 extern int  TSXUninstallColormap(Display*, Colormap);
 extern int  TSXUnmapWindow(Display*, Window);
+extern XFontSet  TSXCreateFontSet(Display*, const  char*, char***, int*, char**);
+extern void  TSXFreeFontSet(Display*, XFontSet);
 extern XIM  TSXOpenIM(Display*, struct _XrmHashBucketRec*, char*, char*);
+extern void  TSXSetICFocus(XIC);
+extern int   TSXFilterEvent(XEvent*, Window);
+extern int  TSXmbLookupString(XIC, XKeyPressedEvent*, char*, int, KeySym*, int *);
 
 #endif /* defined(HAVE_X11_XLIB_H) */
 
diff -urN wine-20031016/dlls/x11drv/window.c wine-20031016-xim-jp106/dlls/x11drv/window.c
--- wine-20031016/dlls/x11drv/window.c	2003-10-03 12:38:05.000000000 +0900
+++ wine-20031016-xim-jp106/dlls/x11drv/window.c	2003-10-19 11:32:57.000000000 +0900
@@ -746,7 +746,7 @@
         return 0;
     }
 
-    if (is_top_level)
+    /*if (is_top_level)
     {
         XIM xim = x11drv_thread_data()->xim;
         if (xim) data->xic = XCreateIC( xim,
@@ -754,7 +754,7 @@
                                         XNClientWindow, data->whole_window,
                                         XNFocusWindow, data->whole_window,
                                         0 );
-    }
+    }*/
 
     /* non-maximized child must be at bottom of Z order */
     if ((win->dwStyle & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD)
@@ -799,8 +799,10 @@
                                          0, screen_depth,
                                          InputOutput, visual,
                                          CWEventMask | CWBitGravity | CWBackingStore, &attr );
-    if (data->client_window && is_client_window_mapped( win ))
+    if (data->client_window && is_client_window_mapped( win )) {
+        data->xic = XIM_DoCreateIC( data->client_window );
         XMapWindow( display, data->client_window );
+    }
     wine_tsx11_unlock();
     return data->client_window;
 }
@@ -875,6 +877,14 @@
 
     if (!data) goto done;
 
+    if (data->client_window && data->xic)
+    {
+        wine_tsx11_lock();
+	XUnsetICFocus( data->xic );
+	XDestroyIC( data->xic );
+        wine_tsx11_unlock();
+    }
+
     if (data->whole_window)
     {
         TRACE( "win %p xwin %lx/%lx\n", hwnd, data->whole_window, data->client_window );
@@ -885,11 +895,11 @@
         XDeleteContext( display, data->whole_window, winContext );
         XDeleteContext( display, data->client_window, winContext );
         XDestroyWindow( display, data->whole_window );  /* this destroys client too */
-        if (data->xic)
+        /*if (data->xic)
         {
             XUnsetICFocus( data->xic );
             XDestroyIC( data->xic );
-        }
+	}*/
         destroy_icon_window( display, wndPtr );
         wine_tsx11_unlock();
     }
diff -urN wine-20031016/dlls/x11drv/x11drv.h wine-20031016-xim-jp106/dlls/x11drv/x11drv.h
--- wine-20031016/dlls/x11drv/x11drv.h	2003-10-16 09:21:42.000000000 +0900
+++ wine-20031016-xim-jp106/dlls/x11drv/x11drv.h	2003-10-19 11:32:57.000000000 +0900
@@ -101,6 +101,9 @@
     XRENDERINFO   xrender;
 } X11DRV_PDEVICE;
 
+extern XIMStyle ximStyle;
+extern XFontSet ximFontSet;
+extern XIC XIM_DoCreateIC(Window w);
 
   /* GCs used for B&W and color bitmap operations */
 extern GC BITMAP_monoGC, BITMAP_colorGC;
diff -urN wine-20031016/dlls/x11drv/x11drv_main.c wine-20031016-xim-jp106/dlls/x11drv/x11drv_main.c
--- wine-20031016/dlls/x11drv/x11drv_main.c	2003-10-16 09:21:42.000000000 +0900
+++ wine-20031016-xim-jp106/dlls/x11drv/x11drv_main.c	2003-10-19 11:32:57.000000000 +0900
@@ -50,10 +50,12 @@
 #include "xvidmode.h"
 #include "xrandr.h"
 #include "dga2.h"
+#include "xim.h"
 #include "wine/server.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
+WINE_DECLARE_DEBUG_CHANNEL(xim);
 
 static CRITICAL_SECTION X11DRV_CritSection;
 static CRITICAL_SECTION_DEBUG critsect_debug =
@@ -98,6 +100,9 @@
 #define IS_OPTION_FALSE(ch) \
     ((ch) == 'n' || (ch) == 'N' || (ch) == 'f' || (ch) == 'F' || (ch) == '0')
 
+XIMStyle ximStyle = 0;
+XFontSet ximFontSet;
+
 /***********************************************************************
  *		X11DRV_expect_error
  *
@@ -294,6 +299,171 @@
     RegCloseKey( hkey );
 }
 
+static BOOL X11DRV_SetupXIM(struct x11drv_thread_data *data)
+{
+    BOOL ximDisable;
+    XIMStyle ximStyleRequest, ximStyleRoot, ximStyleNone;
+    XIMStyles *ximStyles = NULL;
+    char buf[100];
+    int i;
+
+    char **list;    //FIXME
+    int count;
+    char * FontSet;
+
+    HKEY hkey, appkey = 0;
+
+    if (RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\InputMethod", 0, NULL,
+                         REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL ))
+    {
+        ERR("Cannot create config registry key\n" );
+        ExitProcess(1);
+    }
+
+    /* open the app-specific key */
+
+    if (GetModuleFileNameA( 0, buf, MAX_PATH ))
+    {
+        HKEY tmpkey;
+        char *p, *appname = buf;
+        if ((p = strrchr( appname, '/' ))) appname = p + 1;
+        if ((p = strrchr( appname, '\\' ))) appname = p + 1;
+        strcat( appname, "\\InputMethod" );
+        if (!RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\AppDefaults", &tmpkey ))
+        {
+            if (RegOpenKeyA( tmpkey, appname, &appkey )) appkey = 0;
+            RegCloseKey( tmpkey );
+        }
+    }
+
+    if (!get_config_key( hkey, appkey, "UseXIM", buf, sizeof(buf) ))
+    {
+        ximDisable = IS_OPTION_FALSE( buf[0] );
+    }
+    else
+        ximDisable=FALSE;
+    if(ximDisable)
+    {
+        MESSAGE("Disabled input method.\n");
+        return FALSE;
+    }
+
+    if (!get_config_key( hkey, appkey, "XIMFontSet", buf, sizeof(buf) ))
+    {
+	    FontSet = strdup( buf );
+    }
+    else
+        FontSet = "-misc-fixed-medium-r-normal--16-*-*-*-*-*";
+
+    ximFontSet = TSXCreateFontSet(data->display, FontSet, &list, &count, NULL);
+
+    TRACE_(xim)("ximFontSet = 0x%x\n", (unsigned int) ximFontSet);
+    TRACE_(xim)("list = 0x%x, count = %d\n", (unsigned int) list, count);
+    if (list != NULL)
+    {
+        int i;
+
+	for (i = 0; i < count; ++i)
+	{
+	    TRACE_(xim)("list[%d] = %s\n", i, list[i]);
+	}
+	wine_tsx11_lock();
+	XFreeStringList(list);
+	wine_tsx11_unlock();
+    }
+
+    if (get_config_key( hkey, appkey, "InputStyle", buf, sizeof(buf) ))
+        sprintf(buf, "overthespot");
+
+    ximStyleRequest = STYLE_OVERTHESPOT;
+    if (strcasecmp(buf, "offthespot") == 0)
+        ximStyleRequest = STYLE_OFFTHESPOT;
+    else if (strcasecmp(buf, "overthespot") == 0)
+        ximStyleRequest = STYLE_OVERTHESPOT;
+    else if (strcasecmp(buf, "root") == 0)
+        ximStyleRequest = STYLE_ROOT;
+
+    wine_tsx11_lock();
+
+    if(!XSupportsLocale())
+    {
+        MESSAGE("X does not support locale.\n");
+        goto err;
+    }
+
+    if(XSetLocaleModifiers("") == NULL)
+    {
+        MESSAGE("Could not set locale modifiers.\n");
+	goto err;
+    }
+
+    data->xim = XOpenIM(data->display, NULL, NULL, NULL);
+    if (data->xim == NULL)
+    {
+        MESSAGE("Could not open input method.\n");
+        goto err;
+    }
+
+    XGetIMValues(data->xim, XNQueryInputStyle, &ximStyles, NULL);
+    if (ximStyles == 0)
+    {
+        MESSAGE("Could not find supported input style.\n");
+    }
+    else
+    {
+        TRACE_(xim)("ximStyles->count_styles = %d\n", ximStyles->count_styles);
+
+	ximStyleRoot = 0;
+	ximStyleNone = 0;
+
+	for (i = 0; i < ximStyles->count_styles; ++i)
+	{
+	    int style = ximStyles->supported_styles[i];
+	    TRACE_(xim)("ximStyles[%d] = %s%s%s%s%s\n", i, 
+			(style&XIMPreeditArea)?"XIMPreeditArea ":"",
+			(style&XIMPreeditCallbacks)?"XIMPreeditCallbacks ":"",
+			(style&XIMPreeditPosition)?"XIMPreeditPosition ":"",
+			(style&XIMPreeditNothing)?"XIMPreeditNothing ":"",
+			(style&XIMPreeditNone)?"XIMPreeditNone ":"");
+	    if (ximStyles->supported_styles[i] == ximStyleRequest)
+	    {
+	        ximStyle = ximStyleRequest;
+		TRACE_(xim)("Setting Style: ximStyleNone = ximStyleRequest\n");
+		break;
+	    }
+
+	    if (ximStyles->supported_styles[i] == STYLE_ROOT)
+	    {
+	        ximStyleRoot = STYLE_ROOT;
+		TRACE_(xim)("Setting Style: ximStyleNone = STYLE_ROOT\n");
+		break;
+	    }
+
+	    if (ximStyles->supported_styles[i] == STYLE_NONE)
+	    {
+	        TRACE_(xim)("Setting Style: ximStyleNone = STYLE_NONE\n");
+		ximStyleNone = STYLE_NONE;
+		break;
+	    }
+	}
+
+	XFree(ximStyles);
+
+	if (ximStyle == 0)
+	    ximStyle = ximStyleRoot;
+
+	if (ximStyle == 0)
+	    ximStyle = ximStyleNone;
+    }
+
+    wine_tsx11_unlock();
+    return TRUE;
+
+err:
+    wine_tsx11_unlock();
+    return FALSE;
+}
+
 
 /***********************************************************************
  *           X11DRV process initialisation routine
@@ -410,6 +580,7 @@
     {
         CloseHandle( data->display_fd );
         wine_tsx11_lock();
+	if (data->xim) XCloseIM(data->xim);
         XCloseDisplay( data->display );
         /* if (data->xim) XCloseIM( data->xim ); */ /* crashes Xlib */
         wine_tsx11_unlock();
@@ -489,6 +660,8 @@
     data->cursor = None;
     data->cursor_window = None;
     data->last_focus = 0;
+    data->xim = 0;
+    X11DRV_SetupXIM(data);
     NtCurrentTeb()->driver_data = data;
     if (desktop_tid) AttachThreadInput( GetCurrentThreadId(), desktop_tid, TRUE );
     return data;
@@ -545,3 +718,81 @@
     TSXSetScreenSaver(gdi_display, timeout, interval, prefer_blanking,
                       allow_exposures);
 }
+
+/***********************************************************************
+ *              XIM IC Functions (X11DRV.@)
+ *
+ */
+XIC XIM_DoCreateIC(Window w)
+{
+    XFontSet FSet = ximFontSet;
+    XPoint spot = {400,400};
+    XVaNestedList preedit = NULL;
+    XVaNestedList status = NULL;
+    XIC xic = NULL;
+    struct x11drv_thread_data *data = NtCurrentTeb()->driver_data;
+
+    TRACE_(xim)("xwin %08x, xim %08x\n",
+		(unsigned int)w, (unsigned int) data->xim);
+
+    if (data->xim == NULL)
+        return FALSE;
+
+    wine_tsx11_lock();
+    if ((ximStyle & (XIMPreeditNothing | XIMPreeditNone)) == 0)
+    {
+        preedit = XVaCreateNestedList(0,
+				      XNFontSet, FSet,
+				      XNSpotLocation, &spot,
+				      NULL);
+	TRACE_(xim)("preedit = 0x%x\n", (unsigned int) preedit);
+    }
+    if ((ximStyle & (XIMStatusNothing | XIMStatusNone)) == 0)
+    {
+        status = XVaCreateNestedList(0,
+				     XNFontSet, FSet, NULL);
+	TRACE_(xim)("status = 0x%x\n", (unsigned int) status);
+    }
+    if (preedit != NULL && status != NULL) {
+        xic = XCreateIC(data->xim,
+			XNClientWindow, w,
+			XNFocusWindow, w,
+			XNInputStyle, ximStyle,
+			XNPreeditAttributes, preedit,
+			XNStatusAttributes, status,
+			NULL);
+    } else if (preedit != NULL) {
+        xic = XCreateIC(data->xim,
+			XNClientWindow, w,
+			XNFocusWindow, w,
+			XNInputStyle, ximStyle,
+			XNPreeditAttributes, preedit,
+			NULL);
+    } else if (status != NULL) {
+        xic = XCreateIC(data->xim,
+			XNClientWindow, w,
+			XNFocusWindow, w,
+			XNInputStyle, ximStyle,
+			XNStatusAttributes, status,
+			NULL);
+    } else {
+        xic = XCreateIC(data->xim,
+			XNClientWindow, w,
+			XNFocusWindow, w,
+			XNInputStyle, ximStyle,
+			NULL);
+    }
+    TRACE_(xim)("xic = 0x%x\n", (unsigned int) xic);
+    if (preedit != NULL) {
+        TSXFree(preedit);
+    }
+    if (status != NULL) {
+        TSXFree(status);
+    }
+
+    XSetICFocus(xic);
+
+    wine_tsx11_unlock();
+
+    return(xic);
+}
diff -urN wine-20031016/dlls/x11drv/xim.h wine-20031016-xim-jp106/dlls/x11drv/xim.h
--- wine-20031016/dlls/x11drv/xim.h	1970-01-01 09:00:00.000000000 +0900
+++ wine-20031016-xim-jp106/dlls/x11drv/xim.h	2003-10-19 11:32:57.000000000 +0900
@@ -0,0 +1,30 @@
+/*
+ * xim.h 
+ * define some constant used in XIM
+ * 
+ * Copyright 2002  liuspider
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#if !defined(__WINE_XIM_H)
+	
+#define __WINE_XIM_H
+
+#define STYLE_OFFTHESPOT (XIMPreeditArea | XIMStatusArea)
+#define STYLE_OVERTHESPOT (XIMPreeditPosition | XIMStatusNothing)
+#define STYLE_ROOT (XIMPreeditNothing | XIMStatusNothing)
+#define STYLE_NONE (XIMPreeditNone | XIMStatusNone)
+
+#endif /* !defined(__WINE_XIM_H) */
diff -urN wine-20031016/include/winnls.h wine-20031016-xim-jp106/include/winnls.h
--- wine-20031016/include/winnls.h	2003-08-22 14:04:56.000000000 +0900
+++ wine-20031016-xim-jp106/include/winnls.h	2003-10-19 11:32:57.000000000 +0900
@@ -269,6 +269,7 @@
 #define LOCALE_IDIGITSUBSTITUTION     0x1014
 
 #define LOCALE_IDEFAULTUNIXCODEPAGE   0x1030 /* Wine extension */
+#define LOCALE_SCHARSETNAMES          0x1015 /* XIM extention */
 
 #define NORM_IGNORECASE     0x00001
 #define NORM_IGNORENONSPACE 0x00002
diff -urN wine-20031016/objects/gdiobj.c wine-20031016-xim-jp106/objects/gdiobj.c
--- wine-20031016/objects/gdiobj.c	2003-09-06 08:15:42.000000000 +0900
+++ wine-20031016-xim-jp106/objects/gdiobj.c	2003-10-19 11:32:57.000000000 +0900
@@ -352,7 +352,7 @@
         { /* DefaultGuiFont */
          -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
            0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
-           {'M','S',' ','P',' ','g','o','t','h','i','c','\0'} /* FIXME: Is this correct? */
+           {'M','S',' ','U','I',' ','G','o','t','h','i','c','\0'}
         },
     },
     {   GB2312_CHARSET,
