*** empty log message ***
[m17n/m17n-lib-js.git] / xex.js
diff --git a/xex.js b/xex.js
index a1d38c0..08930d8 100644 (file)
--- a/xex.js
+++ b/xex.js
@@ -2812,7 +2812,7 @@ MIM.im_domain.DefType (MIM.State.prototype);
            {
              this.commit ();
              this.keys.val.splice (0, this.key_head);
-             this.key_head = 0;
+             this.key_head = this.state_key_head = this.commit_key_head0;
              this.prev_state = null;
            }
        }
@@ -2875,17 +2875,7 @@ MIM.im_domain.DefType (MIM.State.prototype);
        {
          this.keys.val.splice (0, this.commit_key_head);
          this.key_head -= this.commit_key_head;
-         if (this.key_head < 0)
-           {
-             Xex.Log ('RECOVER key_head');
-             this.key_head = 0;
-           }
          this.state_key_head -= this.commit_key_head;
-         if (this.state_key_head < 0)
-           {
-             Xex.Log ('RECOVER state_key_head');
-             this.state_key_head = 0;
-           }
          this.commit_key_head = 0;
        }
       if (this.key_unhandled)
@@ -3138,41 +3128,39 @@ MIM.update = function (target, ic)
   ic.range[0] += ic.produced.length;
   ic.range[1] = ic.range[0] + ic.preedit.length;
   MIM.set_caret (target, ic);
-  target.wait_update = false;
 };
 
 MIM.focus_in = function (event)
 {
   var target = event.target;
   var ic = target.mim_ic;
-  if (target.wait_focus_in);
+  if (ic.wait_update == true)
     {
       Xex.Log ("Focus in " + target.tagName + ' IGNORED');
       event.preventDefault ();
-      return;
+      return false;
     }
   Xex.Log ("Focus in " + target.tagName);
   ic.Filter (MIM.Key.FocusIn);
-  //target.removeEventListener (target, 'focus', MIM.focus_in);
-  target.wait_update = true;
-  setTimeout (MIM.update (target, ic), 100);
+  MIM.update (target, ic);
 }
 
 MIM.focus_out = function (event)
 {
   var target = event.target;
   var ic = target.mim_ic;
-  if (target.wait_focus_out)
+  function reset_update () { ic.wait_update = false; };
+  if (ic.wait_update == true)
     {
       Xex.Log ("Focus out " + target.tagName + ' IGNORED');
       event.preventDefault ();
-      return;
+      return false;
     }
   Xex.Log ("Focus out " + target.tagName);
   ic.Filter (MIM.Key.FocusOut);
-  //target.removeEventListener (target, 'blur', MIM.focus_out);
-  target.wait_update = true;
-  setTimeout (MIM.update (target, ic), 100);
+  ic.wait_update = true;
+  MIM.update (target, ic, true);
+  setTimeout (reset_update, 1000);
 };
 
 MIM.keydown = function (event)
@@ -3199,7 +3187,6 @@ MIM.keydown = function (event)
     }
   else
     {
-      while (target.wait_update);
       if (! MIM.get_range (target, ic))
        ic.reset ();
     }