Update copyright years
[m17n/m17n-lib.git] / src / input-gui.c
index 904ac8b..2984381 100644 (file)
@@ -1,5 +1,5 @@
 /* input-gui.c -- gui-based input method module.
 /* input-gui.c -- gui-based input method module.
-   Copyright (C) 2003, 2004
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H15PRO112
 
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H15PRO112
 
@@ -17,7 +17,7 @@
 
    You should have received a copy of the GNU Lesser General Public
    License along with the m17n library; if not, write to the Free
 
    You should have received a copy of the GNU Lesser General Public
    License along with the m17n library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    02111-1307, USA.  */
 
 /***en
    02111-1307, USA.  */
 
 /***en
     The input driver @c minput_gui_driver is provided for internal
     input methods that is useful on window systems.  It displays
     preedit text and status text at the inputting spot.  See the
     The input driver @c minput_gui_driver is provided for internal
     input methods that is useful on window systems.  It displays
     preedit text and status text at the inputting spot.  See the
-    documentation of @c minput_gui_driver for more detail.
+    documentation of @c minput_gui_driver for more details.
 
     In the m17n-X library, the foreign input method of name @c Mxim is
     provided.  It uses XIM (X Input Method) as a background input
     engine.  The symbol @c Mxim has a property @c Minput_driver whose
     value is a pointer to the input driver @c minput_xim_driver.  See
 
     In the m17n-X library, the foreign input method of name @c Mxim is
     provided.  It uses XIM (X Input Method) as a background input
     engine.  The symbol @c Mxim has a property @c Minput_driver whose
     value is a pointer to the input driver @c minput_xim_driver.  See
-    the documentation of @c minput_xim_driver for more detail.  */
+    the documentation of @c minput_xim_driver for more details.  */
 
 /***ja
     @addtogroup m17nInputMethodWin
     @brief ¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¾å¤ÎÆþÎϥ᥽¥Ã¥É¤Î¥µ¥Ý¡¼¥È.
 
 
 /***ja
     @addtogroup m17nInputMethodWin
     @brief ¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¾å¤ÎÆþÎϥ᥽¥Ã¥É¤Î¥µ¥Ý¡¼¥È.
 
-    ÆþÎϥɥ饤¥Ð @c minput_gui_driver ¤Ï¡¢¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¾å¤ÇÍѤ¤¤é
-    ¤ì¤ëÆâÉôÆþÎϥ᥽¥Ã¥ÉÍѤǤ¢¤ë¡£¤³¤Î¥É¥é¥¤¥Ð¤ÏÆþÎÏ¥¹¥Ý¥Ã¥È¤Ë preedit 
-    ¥Æ¥­¥¹¥È¤È status ¥Æ¥­¥¹¥È¤òɽ¼¨¤¹¤ë¡£¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï @c
-    minput_gui_driver ¤ÎÀâÌÀ¤ò»²¾È¤Î¤³¤È¡£
+    ÆþÎϥɥ饤¥Ð @c minput_gui_driver ¤Ï¡¢
+    ¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¾å¤ÇÍѤ¤¤é¤ì¤ëÆâÉôÆþÎϥ᥽¥Ã¥ÉÍѤΥɥ饤¥Ð¤Ç¤¢¤ë¡£
+    ¤³¤Î¥É¥é¥¤¥Ð¤ÏÆþÎÏ¥¹¥Ý¥Ã¥È¤Ë preedit ¥Æ¥­¥¹¥È¤È status 
+    ¥Æ¥­¥¹¥È¤òɽ¼¨¤¹¤ë¡£¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï @c minput_gui_driver ¤ÎÀâÌÀ¤ò»²¾È¤Î¤³¤È¡£
 
 
-    m17n-X ¥é¥¤¥Ö¥é¥ê¤Ï¡¢@c Mxim ¤È¸À¤¦Ì¾Á°¤ò»ý¤Ä³°ÉôÆþÎϥ᥽¥Ã¥É¤òÄó
-    ¶¡¤·¤Æ¤¤¤ë¡£¤³¤ì¤Ï XIM (X Input Method) ¤ò¥Ð¥Ã¥¯¥°¥é¥¦¥ó¥É¤ÎÆþÎÏ¥¨
-    ¥ó¥¸¥ó¤È¤·¤ÆÍøÍѤ¹¤ë¡£¥·¥ó¥Ü¥ë @c Mxim ¤Ï @c Minput_driver ¤È¤¤¤¦
-    ¥×¥í¥Ñ¥Æ¥£¤ò»ý¤Ã¤Æ¤ª¤ê¡¢¤½¤ÎÃͤÏÆþÎϥɥ饤¥Ð @c minput_xim_driver 
-    ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£ ¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï @c minput_xim_driver ¤ÎÀâÌÀ¤ò
-    »²¾È¤Î¤³¤È¡£  */
+    m17n-X ¥é¥¤¥Ö¥é¥ê¤Ï¡¢@c Mxim ¤È¸À¤¦Ì¾Á°¤ò»ý¤Ä³°ÉôÆþÎϥ᥽¥Ã¥É¤òÄ󶡤·¤Æ¤¤¤ë¡£¤³¤ì¤Ï 
+    XIM (X Input Method) ¤ò¥Ð¥Ã¥¯¥°¥é¥¦¥ó¥É¤ÎÆþÎÏ¥¨¥ó¥¸¥ó¤È¤·¤ÆÍøÍѤ¹¤ë¡£¥·¥ó¥Ü¥ë
+    @c Mxim ¤Ï @c Minput_driver ¤È¤¤¤¦¥×¥í¥Ñ¥Æ¥£¤ò»ý¤Ã¤Æ¤ª¤ê¡¢¤½¤ÎÃͤÏÆþÎϥɥ饤¥Ð 
+    @c minput_xim_driver ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£ ¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï 
+    @c minput_xim_driver ¤ÎÀâÌÀ¤ò»²¾È¤Î¤³¤È¡£  */
 
 /*=*/
 
 
 /*=*/
 
@@ -60,6 +59,7 @@
 #include <string.h>
 #include <ctype.h>
 
 #include <string.h>
 #include <ctype.h>
 
+#include "config.h"
 #include "m17n-gui.h"
 #include "m17n-misc.h"
 #include "internal.h"
 #include "m17n-gui.h"
 #include "m17n-misc.h"
 #include "internal.h"
@@ -105,13 +105,13 @@ win_create_ic (MInputContext *ic)
   win_ic_info->ic_info = (MInputContextInfo *) ic->info;
   win_ic_info->frame = frame;
   win_ic_info->client.win = win_info->client;
   win_ic_info->ic_info = (MInputContextInfo *) ic->info;
   win_ic_info->frame = frame;
   win_ic_info->client.win = win_info->client;
-  mwin__window_geometry (frame, win_info->client, win_info->client,
+  (*frame->driver->window_geometry) (frame, win_info->client, win_info->client,
                         &win_ic_info->client.geometry);
   win_ic_info->focus.win = win_info->focus;
                         &win_ic_info->client.geometry);
   win_ic_info->focus.win = win_info->focus;
-  mwin__window_geometry (frame, win_info->focus, win_info->client,
+  (*frame->driver->window_geometry) (frame, win_info->focus, win_info->client,
                         &win_ic_info->focus.geometry);
 
                         &win_ic_info->focus.geometry);
 
-  win_ic_info->preedit.win = mwin__create_window (frame, win_info->client);
+  win_ic_info->preedit.win = (*frame->driver->create_window) (frame, win_info->client);
   win_ic_info->preedit.control.two_dimensional = 1;
   win_ic_info->preedit.control.as_image = 0;
   win_ic_info->preedit.control.with_cursor = 1;
   win_ic_info->preedit.control.two_dimensional = 1;
   win_ic_info->preedit.control.as_image = 0;
   win_ic_info->preedit.control.with_cursor = 1;
@@ -120,11 +120,11 @@ win_create_ic (MInputContext *ic)
   win_ic_info->preedit.geometry.x = -1;
   win_ic_info->preedit.geometry.y = -1;
 
   win_ic_info->preedit.geometry.x = -1;
   win_ic_info->preedit.geometry.y = -1;
 
-  win_ic_info->status.win = mwin__create_window (frame, win_info->client);
+  win_ic_info->status.win = (*frame->driver->create_window) (frame, win_info->client);
   win_ic_info->status.control.as_image = 1;
   win_ic_info->status.control.enable_bidi = 1;
 
   win_ic_info->status.control.as_image = 1;
   win_ic_info->status.control.enable_bidi = 1;
 
-  win_ic_info->candidates.win = mwin__create_window (frame, win_info->client);
+  win_ic_info->candidates.win = (*frame->driver->create_window) (frame, win_info->client);
   win_ic_info->candidates.control.as_image = 1;
 
   ic->info = win_ic_info;
   win_ic_info->candidates.control.as_image = 1;
 
   ic->info = win_ic_info;
@@ -137,10 +137,11 @@ win_destroy_ic (MInputContext *ic)
 {
   MInputGUIContextInfo *win_ic_info = (MInputGUIContextInfo *) ic->info;
   MInputContextInfo *ic_info = (MInputContextInfo *) win_ic_info->ic_info;
 {
   MInputGUIContextInfo *win_ic_info = (MInputGUIContextInfo *) ic->info;
   MInputContextInfo *ic_info = (MInputContextInfo *) win_ic_info->ic_info;
+  MFrame *frame = win_ic_info->frame;
 
 
-  mwin__destroy_window (win_ic_info->frame, win_ic_info->preedit.win);
-  mwin__destroy_window (win_ic_info->frame, win_ic_info->status.win);
-  mwin__destroy_window (win_ic_info->frame, win_ic_info->candidates.win);
+  (*frame->driver->destroy_window) (frame, win_ic_info->preedit.win);
+  (*frame->driver->destroy_window) (frame, win_ic_info->status.win);
+  (*frame->driver->destroy_window) (frame, win_ic_info->candidates.win);
   ic->info = ic_info;
   (*minput_default_driver.destroy_ic) (ic);
   free (win_ic_info);
   ic->info = ic_info;
   (*minput_default_driver.destroy_ic) (ic);
   free (win_ic_info);
@@ -157,10 +158,8 @@ win_filter (MInputContext *ic, MSymbol key, void *arg)
       || ! ic->active)
     return 0;
 
       || ! ic->active)
     return 0;
 
-  if (key == Mnil)
+  if (key == Mnil && arg)
     {
     {
-      if (! arg)
-       return 0;
       key = minput_event_to_key (win_ic_info->frame, arg);
       if (key == Mnil)
        return 1;
       key = minput_event_to_key (win_ic_info->frame, arg);
       if (key == Mnil)
        return 1;
@@ -281,7 +280,7 @@ adjust_window_and_draw (MFrame *frame, MInputContext *ic, MText *mt, int type)
        }
     }
 
        }
     }
 
-  mwin__adjust_window (frame, win, geometry, &physical);
+  (*frame->driver->adjust_window) (frame, win, geometry, &physical);
   mdraw_text_with_control (frame, win, -x0, -y0, mt, 0, len, control);
 }
 
   mdraw_text_with_control (frame, win, -x0, -y0, mt, 0, len, control);
 }
 
@@ -298,7 +297,7 @@ win_callback (MInputContext *ic, MSymbol command)
 
       if (! win_ic_info->preedit.mapped)
        {
 
       if (! win_ic_info->preedit.mapped)
        {
-         mwin__map_window (frame, win_ic_info->preedit.win);
+         (*frame->driver->map_window) (frame, win_ic_info->preedit.win);
          win_ic_info->preedit.mapped = 1;
        }
       win_ic_info->preedit.control.cursor_pos = ic->cursor_pos;
          win_ic_info->preedit.mapped = 1;
        }
       win_ic_info->preedit.control.cursor_pos = ic->cursor_pos;
@@ -311,7 +310,7 @@ win_callback (MInputContext *ic, MSymbol command)
       if (ic->im->language != Mnil)
        mtext_put_prop (ic->preedit, 0, mtext_nchars (ic->preedit), Mlanguage,
                        ic->im->language);
       if (ic->im->language != Mnil)
        mtext_put_prop (ic->preedit, 0, mtext_nchars (ic->preedit), Mlanguage,
                        ic->im->language);
-      if (ic->candidate_list)
+      if (ic->candidate_list && ic->candidate_show)
        mtext_push_prop (ic->preedit, ic->candidate_from, ic->candidate_to,
                         Mface, mface_reverse_video);
       if (mtext_nchars (ic->produced) == 0)
        mtext_push_prop (ic->preedit, ic->candidate_from, ic->candidate_to,
                         Mface, mface_reverse_video);
       if (mtext_nchars (ic->produced) == 0)
@@ -352,7 +351,7 @@ win_callback (MInputContext *ic, MSymbol command)
        {
          if (win_ic_info->candidates.mapped)
            {
        {
          if (win_ic_info->candidates.mapped)
            {
-             mwin__unmap_window (frame, win_ic_info->candidates.win);
+             (*frame->driver->unmap_window) (frame, win_ic_info->candidates.win);
              win_ic_info->candidates.mapped = 0;
            }
          return;
              win_ic_info->candidates.mapped = 0;
            }
          return;
@@ -360,7 +359,7 @@ win_callback (MInputContext *ic, MSymbol command)
 
       if (! win_ic_info->candidates.mapped)
        {
 
       if (! win_ic_info->candidates.mapped)
        {
-         mwin__map_window (frame, win_ic_info->candidates.win);
+         (*frame->driver->map_window) (frame, win_ic_info->candidates.win);
          win_ic_info->candidates.mapped = 1;
        }
 
          win_ic_info->candidates.mapped = 1;
        }
 
@@ -420,23 +419,23 @@ win_callback (MInputContext *ic, MSymbol command)
     }
   else if (command == Minput_set_spot)
     {
     }
   else if (command == Minput_set_spot)
     {
-      minput__callback (ic, Minput_preedit_draw);
-      minput__callback (ic, Minput_status_draw);
-      minput__callback (ic, Minput_candidates_draw);
+      minput_callback (ic, Minput_preedit_draw);
+      minput_callback (ic, Minput_status_draw);
+      minput_callback (ic, Minput_candidates_draw);
     }
   else if (command == Minput_toggle)
     {
       if (ic->active)
        {
     }
   else if (command == Minput_toggle)
     {
       if (ic->active)
        {
-         minput__callback (ic, Minput_preedit_done);
-         minput__callback (ic, Minput_status_done);
-         minput__callback (ic, Minput_candidates_done);
+         minput_callback (ic, Minput_preedit_done);
+         minput_callback (ic, Minput_status_done);
+         minput_callback (ic, Minput_candidates_done);
        }
       else
        {
        }
       else
        {
-         minput__callback (ic, Minput_preedit_start);
-         minput__callback (ic, Minput_status_start);
-         minput__callback (ic, Minput_candidates_start);
+         minput_callback (ic, Minput_preedit_start);
+         minput_callback (ic, Minput_status_start);
+         minput_callback (ic, Minput_candidates_start);
        }
     }
   else if (command == Minput_preedit_start)
        }
     }
   else if (command == Minput_preedit_start)
@@ -446,7 +445,7 @@ win_callback (MInputContext *ic, MSymbol command)
     {
       if (win_ic_info->preedit.mapped)
        {
     {
       if (win_ic_info->preedit.mapped)
        {
-         mwin__unmap_window (frame, win_ic_info->preedit.win);
+         (*frame->driver->unmap_window) (frame, win_ic_info->preedit.win);
          win_ic_info->preedit.mapped = 0;
        }
     }
          win_ic_info->preedit.mapped = 0;
        }
     }
@@ -454,7 +453,7 @@ win_callback (MInputContext *ic, MSymbol command)
     {
       if (! win_ic_info->status.mapped)
        {
     {
       if (! win_ic_info->status.mapped)
        {
-         mwin__map_window (frame, win_ic_info->status.win);
+         (*frame->driver->map_window) (frame, win_ic_info->status.win);
          win_ic_info->status.mapped = 1;
        }
     }
          win_ic_info->status.mapped = 1;
        }
     }
@@ -462,7 +461,7 @@ win_callback (MInputContext *ic, MSymbol command)
     {
       if (win_ic_info->status.mapped)
        {
     {
       if (win_ic_info->status.mapped)
        {
-         mwin__unmap_window (frame, win_ic_info->status.win);
+         (*frame->driver->unmap_window) (frame, win_ic_info->status.win);
          win_ic_info->status.mapped = 0;
        }
     }
          win_ic_info->status.mapped = 0;
        }
     }
@@ -470,7 +469,7 @@ win_callback (MInputContext *ic, MSymbol command)
     {
       if (! win_ic_info->candidates.mapped)
        {
     {
       if (! win_ic_info->candidates.mapped)
        {
-         mwin__map_window (frame, win_ic_info->candidates.win);
+         (*frame->driver->map_window) (frame, win_ic_info->candidates.win);
          win_ic_info->candidates.mapped = 1;
        }
     }
          win_ic_info->candidates.mapped = 1;
        }
     }
@@ -478,10 +477,32 @@ win_callback (MInputContext *ic, MSymbol command)
     {
       if (win_ic_info->candidates.mapped)
        {
     {
       if (win_ic_info->candidates.mapped)
        {
-         mwin__unmap_window (frame, win_ic_info->candidates.win);
+         (*frame->driver->unmap_window) (frame, win_ic_info->candidates.win);
          win_ic_info->candidates.mapped = 0;
        }
     }
          win_ic_info->candidates.mapped = 0;
        }
     }
+  else if (command == Minput_reset)
+    {
+      MInputCallbackFunc func;
+
+      if (minput_default_driver.callback_list
+         && (func = ((MInputCallbackFunc)
+                     mplist_get_func (minput_default_driver.callback_list,
+                                      Minput_reset))))
+       {
+         MInputContextInfo *ic_info
+           = (MInputContextInfo *) win_ic_info->ic_info;
+         ic->info = ic_info;
+         (func) (ic, Minput_reset);
+         ic->info = win_ic_info;
+       }
+      if (ic->preedit_changed)
+       minput_callback (ic, Minput_preedit_draw);
+      if (ic->status_changed)
+       minput_callback (ic, Minput_status_draw);
+      if (ic->candidates_changed)
+       minput_callback (ic, Minput_candidates_draw);
+    }
 }
 
 static int
 }
 
 static int
@@ -512,19 +533,23 @@ minput__win_init ()
     MPlist *plist = mplist ();
 
     minput_gui_driver.callback_list = plist;
     MPlist *plist = mplist ();
 
     minput_gui_driver.callback_list = plist;
-    plist = mplist_add (plist, Minput_preedit_start, (void *) win_callback);
-    plist = mplist_add (plist, Minput_preedit_draw, (void *) win_callback);
-    plist = mplist_add (plist, Minput_preedit_done, (void *) win_callback);
-    plist = mplist_add (plist, Minput_status_start, (void *) win_callback);
-    plist = mplist_add (plist, Minput_status_draw, (void *) win_callback);
-    plist = mplist_add (plist, Minput_status_done, (void *) win_callback);
-    plist = mplist_add (plist, Minput_candidates_start, (void *) win_callback);
-    plist = mplist_add (plist, Minput_candidates_draw, (void *) win_callback);
-    plist = mplist_add (plist, Minput_candidates_done, (void *) win_callback);
-    plist = mplist_add (plist, Minput_set_spot, (void *) win_callback);
-    plist = mplist_add (plist, Minput_toggle, (void *) win_callback);
+    mplist_put_func (plist, Minput_preedit_start, M17N_FUNC (win_callback));
+    mplist_put_func (plist, Minput_preedit_draw, M17N_FUNC (win_callback));
+    mplist_put_func (plist, Minput_preedit_done, M17N_FUNC (win_callback));
+    mplist_put_func (plist, Minput_status_start, M17N_FUNC (win_callback));
+    mplist_put_func (plist, Minput_status_draw, M17N_FUNC (win_callback));
+    mplist_put_func (plist, Minput_status_done, M17N_FUNC (win_callback));
+    mplist_put_func (plist, Minput_candidates_start, M17N_FUNC (win_callback));
+    mplist_put_func (plist, Minput_candidates_draw, M17N_FUNC (win_callback));
+    mplist_put_func (plist, Minput_candidates_done, M17N_FUNC (win_callback));
+    mplist_put_func (plist, Minput_set_spot, M17N_FUNC (win_callback));
+    mplist_put_func (plist, Minput_toggle, M17N_FUNC (win_callback));
+    mplist_put_func (plist, Minput_reset, M17N_FUNC (win_callback));
   }
   }
+#if 0
+  /* This will make the caller of minput_method_open() pazzled.  */
   minput_driver = &minput_gui_driver;
   minput_driver = &minput_gui_driver;
+#endif
 
   face_box_prop.width = 1;
   face_box_prop.color_top = face_box_prop.color_left
 
   face_box_prop.width = 1;
   face_box_prop.color_top = face_box_prop.color_left
@@ -580,11 +605,11 @@ minput__win_fini ()
 
     The argument $ARG of the function minput_create_ic () must be a
     pointer to the structure @c MInputGUIArgIC.  See the documentation
 
     The argument $ARG of the function minput_create_ic () must be a
     pointer to the structure @c MInputGUIArgIC.  See the documentation
-    of @c MInputGUIArgIC for more detail.
+    of @c MInputGUIArgIC for more details.
 
 
-    If the argument $KEY is @c Mnil, the argument $ARG of the
-    function minput_filter () must be a pointer to the object of type
-    @c XEvent.  In that case, $KEY is generated from $ARG.
+    If the argument $KEY of function minput_filter () is @c Mnil, the
+    argument $ARG must be a pointer to the object of type @c XEvent.
+    In that case, $KEY is generated from $ARG.
 
     The argument $ARG of the function minput_lookup () must be the
     same one as that of the function minput_filter (). */
 
     The argument $ARG of the function minput_lookup () must be the
     same one as that of the function minput_filter (). */
@@ -592,26 +617,24 @@ minput__win_fini ()
 /***ja
     @brief ¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¤ÎÆâÉôÆþÎϥ᥽¥Ã¥ÉÍÑÆþÎϥɥ饤¥Ð.
 
 /***ja
     @brief ¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¤ÎÆâÉôÆþÎϥ᥽¥Ã¥ÉÍÑÆþÎϥɥ饤¥Ð.
 
-    ÆþÎϥɥ饤¥Ð @c minput_gui_driver ¤Ï¡¢¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¾å¤ÇÍѤ¤¤é
-    ¤ì¤ëÆþÎϥ᥽¥Ã¥ÉÍѤǤ¢¤ë¡£
+    ÆþÎϥɥ饤¥Ð @c minput_gui_driver
+    ¤Ï¡¢¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¾å¤ÇÍѤ¤¤é¤ì¤ëÆþÎϥ᥽¥Ã¥ÉÍѥɥ饤¥Ð¤Ç¤¢¤ë¡£
 
 
-    ¤³¤Î¥É¥é¥¤¥Ð¤Ï¡¢´Ø¿ô minput_set_spot () ¤Ë¤è¤Ã¤ÆÀßÄꤵ¤ì¤¿ÆþÎÏ¥¹¥Ý¥Ã
-    ¥È¤Ë preedit ¥Æ¥­¥¹¥ÈÍѤΥµ¥Ö¥¦¥£¥ó¥É¥¦¤È status ¥Æ¥­¥¹¥ÈÍѤΥµ¥Ö
-    ¥¦¥£¥ó¥É¥¦¤òºî¤ê¡¢¤½¤ì¤¾¤ì¤òɽ¼¨¤¹¤ë¡£
+    ¤³¤Î¥É¥é¥¤¥Ð¤Ï¡¢´Ø¿ô minput_set_spot () ¤Ë¤è¤Ã¤ÆÀßÄꤵ¤ì¤¿ÆþÎÏ¥¹¥Ý¥Ã¥È¤Ë
+    preedit ¥Æ¥­¥¹¥ÈÍѤΥµ¥Ö¥¦¥£¥ó¥É¥¦¤È status 
+    ¥Æ¥­¥¹¥ÈÍѤΥµ¥Ö¥¦¥£¥ó¥É¥¦¤òºî¤ê¡¢¤½¤ì¤¾¤ì¤òɽ¼¨¤¹¤ë¡£
 
 
-    ¥Þ¥¯¥í M17N_INIT () ¤ÏÊÑ¿ô @c minput_driver ¤ò¤³¤Î¥É¥é¥¤¥Ð
-    ¤Ø¤Î¥Ý¥¤¥ó¥¿¤ËÀßÄꤷ¡¢Á´¤Æ¤ÎÆâÉôÆþÎϥ᥽¥Ã¥É¤¬¤³¤Î¥É¥é¥¤¥Ð¤ò»È¤¦¤è
-    ¤¦¤Ë¤¹¤ë¡£
+    ¥Þ¥¯¥í M17N_INIT () ¤ÏÊÑ¿ô @c minput_driver 
+    ¤ò¤³¤Î¥É¥é¥¤¥Ð¤Ø¤Î¥Ý¥¤¥ó¥¿¤ËÀßÄꤷ¡¢Á´¤Æ¤ÎÆâÉôÆþÎϥ᥽¥Ã¥É¤¬¤³¤Î¥É¥é¥¤¥Ð¤ò»È¤¦¤è¤¦¤Ë¤¹¤ë¡£
 
     ¤·¤¿¤¬¤Ã¤Æ¡¢@c minput_driver ¤¬¥Ç¥Õ¥©¥ë¥ÈÃͤΤޤޤǤ¢¤ì¤Ð¡¢minput_ 
 
     ¤·¤¿¤¬¤Ã¤Æ¡¢@c minput_driver ¤¬¥Ç¥Õ¥©¥ë¥ÈÃͤΤޤޤǤ¢¤ì¤Ð¡¢minput_ 
-    ¤Ç»Ï¤Þ¤ë̾Á°¤ò»ý¤Ä´Ø¿ô¤Î°ú¿ô¤Î¤¦¤Á¥É¥é¥¤¥Ð°Í¸¤Î¤â¤Î¤Ï°Ê²¼¤Î¤è¤¦¤Ë
-    ¤Ê¤ë¡£
+    ¤Ç»Ï¤Þ¤ë̾Á°¤ò»ý¤Ä´Ø¿ô¤Î°ú¿ô¤Î¤¦¤Á¥É¥é¥¤¥Ð°Í¸¤Î¤â¤Î¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤Ê¤ë¡£
 
     ´Ø¿ô minput_open_im () ¤Î°ú¿ô $ARG ¤Ï̵»ë¤µ¤ì¤ë¡£
 
 
     ´Ø¿ô minput_open_im () ¤Î°ú¿ô $ARG ¤Ï̵»ë¤µ¤ì¤ë¡£
 
-    ´Ø¿ô minput_create_ic () ¤Î°ú¿ô $ARG ¤Ï¹½Â¤ÂΠ@c MInputGUIArgIC ¤Ø
-    ¤Î¥Ý¥¤¥ó¥¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï @c MInputGUIArgIC ¤Î
-    ÀâÌÀ¤ò»²¾È¤Î¤³¤È¡£
+    ´Ø¿ô minput_create_ic () ¤Î°ú¿ô $ARG ¤Ï¹½Â¤ÂΠ@c MInputGUIArgIC 
+    ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï @c MInputGUIArgIC 
+    ¤ÎÀâÌÀ¤ò»²¾È¤Î¤³¤È¡£
 
     ´Ø¿ô minput_filter () ¤Î°ú¿ô $ARG ¤¬ @c Mnil ¤Î¾ì¹ç¡¢ $ARG ¤Ï @c
     XEvent ·¿¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£¤³¤Î¾ì¹ç 
 
     ´Ø¿ô minput_filter () ¤Î°ú¿ô $ARG ¤¬ @c Mnil ¤Î¾ì¹ç¡¢ $ARG ¤Ï @c
     XEvent ·¿¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£¤³¤Î¾ì¹ç 
@@ -625,6 +648,21 @@ MInputDriver minput_gui_driver;
 /*=*/
 
 /***en
 /*=*/
 
 /***en
+    @brief Symbol of the name "xim".
+
+    The variable Mxim is a symbol of name "xim".  It is a name of the
+    input method driver #minput_xim_driver.  */ 
+/***ja
+    @brief "xim"¤ò̾Á°¤È¤·¤Æ»ý¤Ä¥·¥ó¥Ü¥ë .
+
+    ÊÑ¿ô Mxim ¤Ï"xim"¤ò̾Á°¤È¤·¤Æ»ý¤Ä¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£"xim" 
+    ¤ÏÆþÎϥ᥽¥Ã¥É¥É¥é¥¤¥Ð #minput_xim_driver ¤Î̾Á°¤Ç¤¢¤ë¡£  */ 
+
+MSymbol Mxim;
+
+/*=*/
+
+/***en
     @brief Convert an event to an input key.
 
     The minput_event_to_key () function returns the input key
     @brief Convert an event to an input key.
 
     The minput_event_to_key () function returns the input key
@@ -645,41 +683,40 @@ MInputDriver minput_gui_driver;
     the byte is bitwise anded by 0x1F and the Control modifier is
     cleared.
 
     the byte is bitwise anded by 0x1F and the Control modifier is
     cleared.
 
-    If $EVENT still has Shift, Control, Meta, Alt, Super, and/or Hyper
-    modifiers, the name is preceded by "S-", "C-", "M-", "A-", "s-",
-    and/or "H-" respectively in this order.
+    If $EVENT still has modifiers, the name is preceded by "S-"
+    (Shift), "C-" (Control), "M-" (Meta), "A-" (Alt), "G-" (AltGr),
+    "s-" (Super), and "H-" (Hyper) in this order.
 
     For instance, if the keysym name is "a" and the event has Shift,
 
     For instance, if the keysym name is "a" and the event has Shift,
-    Meta, and Hyper modifiers, the resulting name is "H-M-A".
+    Meta, and Hyper modifiers, the resulting name is "M-H-A".
 
     At last, a symbol who has the name is returned.  */
 
 /***ja
     @brief ¥¤¥Ù¥ó¥È¤òÆþÎÏ¥­¡¼¤ËÊÑ´¹¤¹¤ë.
 
 
     At last, a symbol who has the name is returned.  */
 
 /***ja
     @brief ¥¤¥Ù¥ó¥È¤òÆþÎÏ¥­¡¼¤ËÊÑ´¹¤¹¤ë.
 
-    ´Ø¿ô minput_name_to_key () ¤Ï¡¢$FRAME ¤Î¥¤¥Ù¥ó¥È $EVENT ¤ËÂбþ¤¹¤ë
-    ÆþÎÏ¥­¡¼¤òÊÖ¤¹¡£¤³¤³¤Ç¤Î¡ÖÂбþ¡×¤Ï¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à°Í¸¤Ç¤¢¤ë¡£
+    ´Ø¿ô minput_event_to_key () ¤Ï¡¢$FRAME ¤Î¥¤¥Ù¥ó¥È $EVENT 
+    ¤ËÂбþ¤¹¤ëÆþÎÏ¥­¡¼¤òÊÖ¤¹¡£¤³¤³¤Ç¤Î¡ÖÂбþ¡×¤Ï¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¤Ë°Í¸¤¹¤ë¡£
 
 
-    m17n-X ¥é¥¤¥Ö¥é¥ê¤Î¾ì¹ç¤Ë¤Ï¡¢$EVENT ¤Ï ¹½Â¤ÂΠ@c XKeyEvent ¤Ø¤Î¥Ý
-    ¥¤¥ó¥¿¤Ç¤¢¤ê¡¢¼¡¤Î¤è¤¦¤Ë½èÍý¤µ¤ì¤ë¡£
+    m17n-X ¥é¥¤¥Ö¥é¥ê¤Î¾ì¹ç¤Ë¤Ï¡¢$EVENT ¤Ï ¹½Â¤ÂΠ@c XKeyEvent 
+    ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ê¡¢¼¡¤Î¤è¤¦¤Ë½èÍý¤µ¤ì¤ë¡£
 
 
-    ¤Þ¤º¡¢´Ø¿ô @c XKeysymToString ¤Ë¤è¤Ã¤Æ¡¢$EVENT ¤Î keysym Ì¾¤ò¼èÆÀ
-    ¤·¡¢¼¡¤¤¤Ç°Ê²¼¤ÎÊѹ¹¤ò²Ã¤¨¤ë¡£
+    ¤Þ¤º¡¢´Ø¿ô @c XKeysymToString ¤Ë¤è¤Ã¤Æ¡¢$EVENT ¤Î keysym 
+    Ì¾¤ò¼èÆÀ¤·¡¢¼¡¤¤¤Ç°Ê²¼¤ÎÊѹ¹¤ò²Ã¤¨¤ë¡£
 
 
-    Ì¾Á°¤¬ "a" .. "z" ¤Î¤¤¤º¤ì¤«¤Ç¤¢¤Ã¤Æ $EVENT ¤Ë Shift ¥â¥Ç¥£¥Õ¥¡¥¤
-    ¥¢¤¬¤¢¤ì¤Ð¡¢Ì¾Á°¤Ï¤½¤ì¤¾¤ì "A" .. "Z" ¤ËÊÑ´¹¤µ¤ì¡¢Shift ¥â¥Ç¥£¥Õ¥¡
-    ¥¤¥¢¤Ï¼è¤ê½ü¤«¤ì¤ë¡£
+    Ì¾Á°¤¬ "a" .. "z" ¤Î¤¤¤º¤ì¤«¤Ç¤¢¤Ã¤Æ $EVENT ¤Ë Shift 
+    ¥â¥Ç¥£¥Õ¥¡¥¤¥¢¤¬¤¢¤ì¤Ð¡¢Ì¾Á°¤Ï¤½¤ì¤¾¤ì "A" .. "Z" ¤ËÊÑ´¹¤µ¤ì¡¢Shift 
+    ¥â¥Ç¥£¥Õ¥¡¥¤¥¢¤Ï¼è¤ê½ü¤«¤ì¤ë¡£
 
 
-    Ì¾Á°¤¬£±¥Ð¥¤¥ÈŤǠ$EVENT ¤Ë Control ¥â¥Ç¥£¥Õ¥¡¥¤¥¢¤¬¤¢¤ì¤Ð¡¢Ì¾Á°
-    ¤È 0x1F ¤ò¥Ó¥Ã¥Èñ°Ì and ±é»»¤¹¤ë¡£Control ¥â¥Ç¥£¥Õ¥¡¥¤¥¢¤Ï¼è¤ê½ü
-    ¤«¤ì¤ë¡£
+    Ì¾Á°¤¬£±¥Ð¥¤¥ÈŤǠ$EVENT ¤Ë Control ¥â¥Ç¥£¥Õ¥¡¥¤¥¢¤¬¤¢¤ì¤Ð¡¢Ì¾Á°¤È
+    0x1F ¤È¤ò¥Ó¥Ã¥Èñ°Ì¤Ç and ±é»»¤·¡¢Control ¥â¥Ç¥£¥Õ¥¡¥¤¥¢¤Ï¼è¤ê½ü¤«¤ì¤ë¡£
 
 
-    $EVENT ¤Ë¤Þ¤À Shift, Control, Meta, Alt, Super, Hyper ¤Ê¤É¤Î¥â¥Ç¥£
-    ¥Õ¥¡¥¤¥¢¤¬¤¢¤ì¤Ð¡¢Ì¾Á°¤ÎÁ°¤Ë¤½¤ì¤¾¤ì"S-", "C-", "M-", "A-", "s-",
-    "H-" ¤¬ÉÕ¤¯¡£
+    ¤½¤ì¤Ç¤â $EVENT ¤Ë¤Þ¤À¥â¥Ç¥£¥Õ¥¡¥¤¥¢¤¬¤¢¤ì¤Ð¡¢Ì¾Á°¤ÎÁ°¤Ë¤½¤ì¤¾¤ì
+    "S-" (Shift), "C-" (Control), "M-" (Meta), "A-" (Alt), , "G-" (AltGr),
+    "s-" (Super), "H-" (Hyper)¤¬¤³¤Î½çÈÖ¤ÇÉÕ¤¯¡£
     
     
-    ¤¿¤È¤¨¤Ð¡¢keysym Ì¾¤¬ "a" ¤Ç¥¤¥Ù¥ó¥È¤¬ Shift, Meta, and Hyper ¥â¥Ç¥£
-    ¥Õ¥¡¥¤¥¢¤ò»ý¤Æ¤Ð¡¢ÆÀ¤é¤ì¤ë̾Á°¤Ï "H-M-A" ¤Ç¤¢¤ë¡£
+    ¤¿¤È¤¨¤Ð¡¢keysym Ì¾¤¬ "a" ¤Ç¥¤¥Ù¥ó¥È¤¬ Shift, Meta, and Hyper 
+    ¥â¥Ç¥£¥Õ¥¡¥¤¥¢¤ò»ý¤Æ¤Ð¡¢ÆÀ¤é¤ì¤ë̾Á°¤Ï "M-H-A" ¤Ç¤¢¤ë¡£
 
     ºÇ¸å¤Ë¤½¤Î̾Á°¤ò»ý¤Ä¥·¥ó¥Ü¥ë¤òÊÖ¤¹¡£*/
 
 
     ºÇ¸å¤Ë¤½¤Î̾Á°¤ò»ý¤Ä¥·¥ó¥Ü¥ë¤òÊÖ¤¹¡£*/
 
@@ -688,14 +725,16 @@ MSymbol
 minput_event_to_key (MFrame *frame, void *event)
 {
   int modifiers;
 minput_event_to_key (MFrame *frame, void *event)
 {
   int modifiers;
-  MSymbol key = mwin__parse_event (frame, event, &modifiers);
+  MSymbol key;
   char *name, *str;
 
   char *name, *str;
 
+  M_CHECK_READABLE (frame, MERROR_IM, Mnil);
+  key = (*frame->driver->parse_event) (frame, event, &modifiers);
   if (! modifiers)
     return key;
 
   name = msymbol_name (key);
   if (! modifiers)
     return key;
 
   name = msymbol_name (key);
-  str = alloca (strlen (name) + 2 * 6 + 1);
+  str = alloca (strlen (name) + 2 * 8 + 1);
   str[0] = '\0';
   if (modifiers & MINPUT_KEY_SHIFT_MODIFIER)
     strcat (str, "S-");
   str[0] = '\0';
   if (modifiers & MINPUT_KEY_SHIFT_MODIFIER)
     strcat (str, "S-");
@@ -705,6 +744,8 @@ minput_event_to_key (MFrame *frame, void *event)
     strcat (str, "M-");
   if (modifiers & MINPUT_KEY_ALT_MODIFIER)
     strcat (str, "A-");
     strcat (str, "M-");
   if (modifiers & MINPUT_KEY_ALT_MODIFIER)
     strcat (str, "A-");
+  if (modifiers & MINPUT_KEY_ALTGR_MODIFIER)
+    strcat (str, "G-");
   if (modifiers & MINPUT_KEY_SUPER_MODIFIER)
     strcat (str, "s-");
   if (modifiers & MINPUT_KEY_HYPER_MODIFIER)
   if (modifiers & MINPUT_KEY_SUPER_MODIFIER)
     strcat (str, "s-");
   if (modifiers & MINPUT_KEY_HYPER_MODIFIER)