Skip to content

Commit 2877d33

Browse files
committed
patch 8.0.1344: using 'imactivatefunc' in the GUI does not work
Problem: Using 'imactivatefunc' in the GUI does not work. Solution: Do not use 'imactivatefunc' and 'imstatusfunc' in the GUI.
1 parent d7ccc4d commit 2877d33

4 files changed

Lines changed: 25 additions & 17 deletions

File tree

runtime/doc/options.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4258,8 +4258,8 @@ A jump table for the options with a short description can be found at |Q_op|.
42584258
{not in Vi}
42594259
{only available when compiled with |+mbyte|}
42604260
This option specifies a function that will be called to
4261-
activate/inactivate Input Method.
4262-
Does not work in the MS-Windows GUI version.
4261+
activate or deactivate the Input Method.
4262+
It is not used in the GUI.
42634263

42644264
Example: >
42654265
function ImActivateFunc(active)
@@ -4375,7 +4375,7 @@ A jump table for the options with a short description can be found at |Q_op|.
43754375
{only available when compiled with |+mbyte|}
43764376
This option specifies a function that is called to obtain the status
43774377
of Input Method. It must return a positive number when IME is active.
4378-
Does not work in the MS-Windows GUI version.
4378+
It is not used in the GUI.
43794379

43804380
Example: >
43814381
function ImStatusFunc()

src/mbyte.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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
47874795
call_imactivatefunc(int active)
@@ -5689,7 +5697,7 @@ im_synthesize_keypress(unsigned int keyval, unsigned int state)
56895697
xim_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)
58685876
im_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)
63486355
im_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;
64806487
im_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;

src/testdir/test_iminsert.vim

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@ func IM_statusfunc()
1717
endfunc
1818

1919
func Test_iminsert2()
20-
if has('gui_win32')
21-
return
22-
endif
2320
set imactivatefunc=IM_activatefunc
2421
set imstatusfunc=IM_statusfunc
2522
set iminsert=2
2623
normal! i
2724
set iminsert=0
2825
set imactivatefunc=
2926
set imstatusfunc=
30-
call assert_equal(1, s:imactivatefunc_called)
31-
call assert_equal(1, s:imstatusfunc_called)
27+
28+
let expected = has('gui_running') ? 0 : 1
29+
call assert_equal(expected, s:imactivatefunc_called)
30+
call assert_equal(expected, s:imstatusfunc_called)
3231
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ static char *(features[]) =
771771

772772
static int included_patches[] =
773773
{ /* Add new patch number below this line */
774+
/**/
775+
1344,
774776
/**/
775777
1343,
776778
/**/

0 commit comments

Comments
 (0)