@@ -4447,7 +4447,7 @@ im_set_active(int active)
44474447{
44484448 int was_active ;
44494449
4450- was_active = !!im_is_active ;
4450+ was_active = !!im_get_status () ;
44514451 im_is_active = (active && !p_imdisable );
44524452
44534453 if (im_is_active != was_active )
@@ -5071,44 +5071,25 @@ xim_reset(void)
50715071{
50725072 if (xic != NULL )
50735073 {
5074- /*
5075- * The third-party imhangul module (and maybe others too) ignores
5076- * gtk_im_context_reset() or at least doesn't reset the active state.
5077- * Thus sending imactivatekey would turn it off if it was on before,
5078- * which is clearly not what we want. Fortunately we can work around
5079- * that for imhangul by sending GDK_Escape, but I don't know if it
5080- * works with all IM modules that support an activation key :/
5081- *
5082- * An alternative approach would be to destroy the IM context and
5083- * recreate it. But that means loading/unloading the IM module on
5084- * every mode switch, which causes a quite noticeable delay even on
5085- * my rather fast box...
5086- * *
5087- * Moreover, there are some XIM which cannot respond to
5088- * im_synthesize_keypress(). we hope that they reset by
5089- * xim_shutdown().
5090- */
5091- if (im_activatekey_keyval != GDK_VoidSymbol && im_is_active )
5092- im_synthesize_keypress (GDK_Escape , 0U );
5093-
50945074 gtk_im_context_reset (xic );
50955075
5096- /*
5097- * HACK for Ami: This sequence of function calls makes Ami handle
5098- * the IM reset graciously, without breaking loads of other stuff.
5099- * It seems to force English mode as well, which is exactly what we
5100- * want because it makes the Ami status display work reliably.
5101- */
5102- gtk_im_context_set_use_preedit (xic , FALSE);
5103-
51045076 if (p_imdisable )
51055077 im_shutdown ();
51065078 else
51075079 {
5108- gtk_im_context_set_use_preedit (xic , TRUE);
51095080 xim_set_focus (gui .in_focus );
51105081
5111- if (im_activatekey_keyval != GDK_VoidSymbol )
5082+ if (p_imaf [0 ] != NUL )
5083+ {
5084+ char_u * argv [1 ];
5085+
5086+ if (im_is_active )
5087+ argv [0 ] = (char_u * )"1" ;
5088+ else
5089+ argv [0 ] = (char_u * )"0" ;
5090+ (void )call_func_retnr (p_imaf , 1 , argv , FALSE);
5091+ }
5092+ else if (im_activatekey_keyval != GDK_VoidSymbol )
51125093 {
51135094 if (im_is_active )
51145095 {
@@ -5268,6 +5249,20 @@ xim_queue_key_press_event(GdkEventKey *event, int down)
52685249 int
52695250im_get_status (void )
52705251{
5252+ if (p_imsf [0 ] != NUL )
5253+ {
5254+ int is_active ;
5255+
5256+ /* FIXME: Don't execute user function in unsafe situation. */
5257+ if (exiting || is_autocmd_blocked ())
5258+ return FALSE;
5259+ /* FIXME: :py print 'xxx' is shown duplicate result.
5260+ * Use silent to avoid it. */
5261+ ++ msg_silent ;
5262+ is_active = call_func_retnr (p_imsf , 0 , NULL , FALSE);
5263+ -- msg_silent ;
5264+ return (is_active > 0 );
5265+ }
52715266 return im_is_active ;
52725267}
52735268
0 commit comments