forked from aniani/vim
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.
This commit is contained in:
@@ -4258,8 +4258,8 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
{not in Vi}
|
{not in Vi}
|
||||||
{only available when compiled with |+mbyte|}
|
{only available when compiled with |+mbyte|}
|
||||||
This option specifies a function that will be called to
|
This option specifies a function that will be called to
|
||||||
activate/inactivate Input Method.
|
activate or deactivate the Input Method.
|
||||||
Does not work in the MS-Windows GUI version.
|
It is not used in the GUI.
|
||||||
|
|
||||||
Example: >
|
Example: >
|
||||||
function ImActivateFunc(active)
|
function ImActivateFunc(active)
|
||||||
@@ -4375,7 +4375,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
{only available when compiled with |+mbyte|}
|
{only available when compiled with |+mbyte|}
|
||||||
This option specifies a function that is called to obtain the status
|
This option specifies a function that is called to obtain the status
|
||||||
of Input Method. It must return a positive number when IME is active.
|
of Input Method. It must return a positive number when IME is active.
|
||||||
Does not work in the MS-Windows GUI version.
|
It is not used in the GUI.
|
||||||
|
|
||||||
Example: >
|
Example: >
|
||||||
function ImStatusFunc()
|
function ImStatusFunc()
|
||||||
|
23
src/mbyte.c
23
src/mbyte.c
@@ -4782,6 +4782,14 @@ iconv_end(void)
|
|||||||
|
|
||||||
#endif /* FEAT_MBYTE */
|
#endif /* FEAT_MBYTE */
|
||||||
|
|
||||||
|
#ifdef FEAT_GUI
|
||||||
|
# define USE_IMACTIVATEFUNC (!gui.in_use && *p_imaf != NUL)
|
||||||
|
# define USE_IMSTATUSFUNC (!gui.in_use && *p_imsf != NUL)
|
||||||
|
#else
|
||||||
|
# define USE_IMACTIVATEFUNC (*p_imaf != NUL)
|
||||||
|
# define USE_IMSTATUSFUNC (*p_imsf != NUL)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
static void
|
static void
|
||||||
call_imactivatefunc(int active)
|
call_imactivatefunc(int active)
|
||||||
@@ -5689,7 +5697,7 @@ im_synthesize_keypress(unsigned int keyval, unsigned int state)
|
|||||||
xim_reset(void)
|
xim_reset(void)
|
||||||
{
|
{
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
if (p_imaf[0] != NUL)
|
if (USE_IMACTIVATEFUNC)
|
||||||
call_imactivatefunc(im_is_active);
|
call_imactivatefunc(im_is_active);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@@ -5868,7 +5876,7 @@ xim_queue_key_press_event(GdkEventKey *event, int down)
|
|||||||
im_get_status(void)
|
im_get_status(void)
|
||||||
{
|
{
|
||||||
# ifdef FEAT_EVAL
|
# ifdef FEAT_EVAL
|
||||||
if (p_imsf[0] != NUL)
|
if (USE_IMSTATUSFUNC)
|
||||||
return call_imstatusfunc();
|
return call_imstatusfunc();
|
||||||
# endif
|
# endif
|
||||||
return im_is_active;
|
return im_is_active;
|
||||||
@@ -5908,16 +5916,14 @@ im_set_active(int active_arg)
|
|||||||
/* If 'imdisable' is set, XIM is never active. */
|
/* If 'imdisable' is set, XIM is never active. */
|
||||||
if (p_imdisable)
|
if (p_imdisable)
|
||||||
active = FALSE;
|
active = FALSE;
|
||||||
# if !defined(FEAT_GUI_GTK)
|
|
||||||
else if (input_style & XIMPreeditPosition)
|
else if (input_style & XIMPreeditPosition)
|
||||||
/* There is a problem in switching XIM off when preediting is used,
|
/* There is a problem in switching XIM off when preediting is used,
|
||||||
* and it is not clear how this can be solved. For now, keep XIM on
|
* and it is not clear how this can be solved. For now, keep XIM on
|
||||||
* all the time, like it was done in Vim 5.8. */
|
* all the time, like it was done in Vim 5.8. */
|
||||||
active = TRUE;
|
active = TRUE;
|
||||||
# endif
|
|
||||||
|
|
||||||
# if defined(FEAT_EVAL)
|
# if defined(FEAT_EVAL)
|
||||||
if (p_imaf[0] != NUL)
|
if (USE_IMACTIVATEFUNC)
|
||||||
{
|
{
|
||||||
if (active != im_get_status())
|
if (active != im_get_status())
|
||||||
{
|
{
|
||||||
@@ -6328,6 +6334,7 @@ xim_real_init(Window x11_window, Display *x11_display)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (!is_not_a_term())
|
||||||
EMSG(_(e_xim));
|
EMSG(_(e_xim));
|
||||||
XCloseIM(xim);
|
XCloseIM(xim);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -6348,7 +6355,7 @@ xim_real_init(Window x11_window, Display *x11_display)
|
|||||||
im_get_status(void)
|
im_get_status(void)
|
||||||
{
|
{
|
||||||
# ifdef FEAT_EVAL
|
# ifdef FEAT_EVAL
|
||||||
if (p_imsf[0] != NUL)
|
if (USE_IMSTATUSFUNC)
|
||||||
return call_imstatusfunc();
|
return call_imstatusfunc();
|
||||||
# endif
|
# endif
|
||||||
return xim_has_focus;
|
return xim_has_focus;
|
||||||
@@ -6480,7 +6487,7 @@ static int im_was_set_active = FALSE;
|
|||||||
im_get_status()
|
im_get_status()
|
||||||
{
|
{
|
||||||
# ifdef FEAT_EVAL
|
# ifdef FEAT_EVAL
|
||||||
if (p_imsf[0] != NUL)
|
if (USE_IMSTATUSFUNC)
|
||||||
return call_imstatusfunc();
|
return call_imstatusfunc();
|
||||||
# endif
|
# endif
|
||||||
return im_was_set_active;
|
return im_was_set_active;
|
||||||
@@ -6492,7 +6499,7 @@ im_set_active(int active_arg)
|
|||||||
# if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
|
# if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
|
||||||
int active = !p_imdisable && active_arg;
|
int active = !p_imdisable && active_arg;
|
||||||
|
|
||||||
if (p_imaf[0] != NUL && active != im_get_status())
|
if (USE_IMACTIVATEFUNC && active != im_get_status())
|
||||||
{
|
{
|
||||||
call_imactivatefunc(active);
|
call_imactivatefunc(active);
|
||||||
im_was_set_active = active;
|
im_was_set_active = active;
|
||||||
|
@@ -17,9 +17,6 @@ func IM_statusfunc()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_iminsert2()
|
func Test_iminsert2()
|
||||||
if has('gui_win32')
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
set imactivatefunc=IM_activatefunc
|
set imactivatefunc=IM_activatefunc
|
||||||
set imstatusfunc=IM_statusfunc
|
set imstatusfunc=IM_statusfunc
|
||||||
set iminsert=2
|
set iminsert=2
|
||||||
@@ -27,6 +24,8 @@ func Test_iminsert2()
|
|||||||
set iminsert=0
|
set iminsert=0
|
||||||
set imactivatefunc=
|
set imactivatefunc=
|
||||||
set imstatusfunc=
|
set imstatusfunc=
|
||||||
call assert_equal(1, s:imactivatefunc_called)
|
|
||||||
call assert_equal(1, s:imstatusfunc_called)
|
let expected = has('gui_running') ? 0 : 1
|
||||||
|
call assert_equal(expected, s:imactivatefunc_called)
|
||||||
|
call assert_equal(expected, s:imstatusfunc_called)
|
||||||
endfunc
|
endfunc
|
||||||
|
@@ -771,6 +771,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1344,
|
||||||
/**/
|
/**/
|
||||||
1343,
|
1343,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user