redraw (sel_start.y0, sel_end.y1, 1, 0);
     }
   hide_cursor ();
-  if (current_input_context)
+  if (current_input_context
+      && minput_filter (current_input_context, Minput_focus_move, NULL) == 0)
     {
       MText *produced = mtext ();
 
-      minput_reset_ic (current_input_context);
-      minput_lookup (current_input_context, Mnil, NULL, produced);
+          minput_lookup (current_input_context, Mnil, NULL, produced);
       if (mtext_len (produced) > 0)
        {
          insert_chars (produced);
 }
 
 void
+FocusInProc (Widget w, XEvent *event, String *str, Cardinal *num)
+{
+  if (current_input_context
+      && minput_filter (current_input_context, Minput_focus_out, NULL) == 0)
+    {
+      MText *produced = mtext ();
+
+      minput_lookup (current_input_context, Mnil, NULL, produced);
+      if (mtext_len (produced) > 0)
+       {
+         hide_cursor ();
+         insert_chars (produced);
+       }
+      m17n_object_unref (produced);
+    }
+}
+
+void
+FocusOutProc (Widget w, XEvent *event, String *str, Cardinal *num)
+{
+  if (current_input_context
+      && minput_filter (current_input_context, Minput_focus_out, NULL) == 0)
+    {
+      MText *produced = mtext ();
+
+      minput_lookup (current_input_context, Mnil, NULL, produced);
+      if (mtext_len (produced) > 0)
+       {
+         hide_cursor ();
+         insert_chars (produced);
+       }
+      m17n_object_unref (produced);
+    }
+}
+
+void
 ScrollProc (Widget w, XtPointer client_data, XtPointer position)
 {
   int from;
   {"ButtonRelease", ButtonReleaseProc},
   {"ButtonMotion", ButtonMoveProc},
   {"Button2Press", Button2Proc},
-  {"MenuHelp", MenuHelpProc}
+  {"MenuHelp", MenuHelpProc},
+  {"FocusIn", FocusInProc},
+  {"FocusOut", FocusOutProc}
 };
 
 
                  <Btn2Down>: Button2Press()";
   /* Translation table for the top form widget.  */
   String trans2 = "<Key>: Key()\n\
-                  <KeyUp>: Key()";
+                  <KeyUp>: Key()\n\
+                  <FocusIn>: FocusIn()\n\
+                  <FocusOut>: FocusOut()";
   String pop_face_trans
     = "<EnterWindow>: MenuHelp(Pop face property) highlight()\n\
        <LeaveWindow>: MenuHelp() reset()\n\