Skip to content

Instantly share code, notes, and snippets.

@mattn
Created July 18, 2012 10:05
Show Gist options
  • Select an option

  • Save mattn/3135370 to your computer and use it in GitHub Desktop.

Select an option

Save mattn/3135370 to your computer and use it in GitHub Desktop.
diff -r 11d40fc82f11 src/mbyte.c
--- a/src/mbyte.c Thu Jul 12 22:01:11 2012 +0200
+++ b/src/mbyte.c Wed Jul 18 19:05:01 2012 +0900
@@ -4388,13 +4388,8 @@
void
im_set_active(int active)
{
- int was_active;
-
- was_active = !!im_is_active;
- im_is_active = (active && !p_imdisable);
-
- if (im_is_active != was_active)
- xim_reset();
+ xim_reset();
+ im_is_active = !p_imdisable;
}
void
@@ -5014,59 +5009,11 @@
{
if (xic != NULL)
{
- /*
- * The third-party imhangul module (and maybe others too) ignores
- * gtk_im_context_reset() or at least doesn't reset the active state.
- * Thus sending imactivatekey would turn it off if it was on before,
- * which is clearly not what we want. Fortunately we can work around
- * that for imhangul by sending GDK_Escape, but I don't know if it
- * works with all IM modules that support an activation key :/
- *
- * An alternative approach would be to destroy the IM context and
- * recreate it. But that means loading/unloading the IM module on
- * every mode switch, which causes a quite noticeable delay even on
- * my rather fast box...
- * *
- * Moreover, there are some XIM which cannot respond to
- * im_synthesize_keypress(). we hope that they reset by
- * xim_shutdown().
- */
- if (im_activatekey_keyval != GDK_VoidSymbol && im_is_active)
- im_synthesize_keypress(GDK_Escape, 0U);
-
- gtk_im_context_reset(xic);
-
- /*
- * HACK for Ami: This sequence of function calls makes Ami handle
- * the IM reset graciously, without breaking loads of other stuff.
- * It seems to force English mode as well, which is exactly what we
- * want because it makes the Ami status display work reliably.
- */
- gtk_im_context_set_use_preedit(xic, FALSE);
-
- if (p_imdisable)
- im_shutdown();
- else
+ im_shutdown();
+ if (!p_imdisable)
{
- gtk_im_context_set_use_preedit(xic, TRUE);
+ xim_init();
xim_set_focus(gui.in_focus);
-
- if (im_activatekey_keyval != GDK_VoidSymbol)
- {
- if (im_is_active)
- {
- g_signal_handler_block(xic, im_commit_handler_id);
- im_synthesize_keypress(im_activatekey_keyval,
- im_activatekey_state);
- g_signal_handler_unblock(xic, im_commit_handler_id);
- }
- }
- else
- {
- im_shutdown();
- xim_init();
- xim_set_focus(gui.in_focus);
- }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment