@@ -4782,6 +4782,14 @@ iconv_end(void)
47824782
47834783#endif /* FEAT_MBYTE */
47844784
4785+ #ifdef FEAT_GUI
4786+ # define USE_IMACTIVATEFUNC (!gui.in_use && *p_imaf != NUL)
4787+ # define USE_IMSTATUSFUNC (!gui.in_use && *p_imsf != NUL)
4788+ #else
4789+ # define USE_IMACTIVATEFUNC (*p_imaf != NUL)
4790+ # define USE_IMSTATUSFUNC (*p_imsf != NUL)
4791+ #endif
4792+
47854793#ifdef FEAT_EVAL
47864794 static void
47874795call_imactivatefunc (int active )
@@ -5689,7 +5697,7 @@ im_synthesize_keypress(unsigned int keyval, unsigned int state)
56895697xim_reset (void )
56905698{
56915699#ifdef FEAT_EVAL
5692- if (p_imaf [ 0 ] != NUL )
5700+ if (USE_IMACTIVATEFUNC )
56935701 call_imactivatefunc (im_is_active );
56945702 else
56955703#endif
@@ -5868,7 +5876,7 @@ xim_queue_key_press_event(GdkEventKey *event, int down)
58685876im_get_status (void )
58695877{
58705878# ifdef FEAT_EVAL
5871- if (p_imsf [ 0 ] != NUL )
5879+ if (USE_IMSTATUSFUNC )
58725880 return call_imstatusfunc ();
58735881# endif
58745882 return im_is_active ;
@@ -5908,16 +5916,14 @@ im_set_active(int active_arg)
59085916 /* If 'imdisable' is set, XIM is never active. */
59095917 if (p_imdisable )
59105918 active = FALSE;
5911- # if !defined(FEAT_GUI_GTK )
59125919 else if (input_style & XIMPreeditPosition )
59135920 /* There is a problem in switching XIM off when preediting is used,
59145921 * and it is not clear how this can be solved. For now, keep XIM on
59155922 * all the time, like it was done in Vim 5.8. */
59165923 active = TRUE;
5917- # endif
59185924
59195925# if defined(FEAT_EVAL )
5920- if (p_imaf [ 0 ] != NUL )
5926+ if (USE_IMACTIVATEFUNC )
59215927 {
59225928 if (active != im_get_status ())
59235929 {
@@ -6328,7 +6334,8 @@ xim_real_init(Window x11_window, Display *x11_display)
63286334 }
63296335 else
63306336 {
6331- EMSG (_ (e_xim ));
6337+ if (!is_not_a_term ())
6338+ EMSG (_ (e_xim ));
63326339 XCloseIM (xim );
63336340 return FALSE;
63346341 }
@@ -6348,7 +6355,7 @@ xim_real_init(Window x11_window, Display *x11_display)
63486355im_get_status (void )
63496356{
63506357# ifdef FEAT_EVAL
6351- if (p_imsf [ 0 ] != NUL )
6358+ if (USE_IMSTATUSFUNC )
63526359 return call_imstatusfunc ();
63536360# endif
63546361 return xim_has_focus ;
@@ -6480,7 +6487,7 @@ static int im_was_set_active = FALSE;
64806487im_get_status ()
64816488{
64826489# ifdef FEAT_EVAL
6483- if (p_imsf [ 0 ] != NUL )
6490+ if (USE_IMSTATUSFUNC )
64846491 return call_imstatusfunc ();
64856492# endif
64866493 return im_was_set_active ;
@@ -6492,7 +6499,7 @@ im_set_active(int active_arg)
64926499# if defined(FEAT_MBYTE ) && defined(FEAT_EVAL )
64936500 int active = !p_imdisable && active_arg ;
64946501
6495- if (p_imaf [ 0 ] != NUL && active != im_get_status ())
6502+ if (USE_IMACTIVATEFUNC && active != im_get_status ())
64966503 {
64976504 call_imactivatefunc (active );
64986505 im_was_set_active = active ;
0 commit comments