0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 8.0.1338: USE_IM_CONTROL is confusing and incomplete

Problem:    USE_IM_CONTROL is confusing and incomplete.
Solution:   Just use FEAT_MBYTE.  Call 'imactivatefunc' also without GUI.
This commit is contained in:
Bram Moolenaar
2017-11-25 17:14:33 +01:00
parent 50d43153a7
commit 819edbe078
14 changed files with 124 additions and 124 deletions

View File

@@ -4794,6 +4794,26 @@ call_imactivatefunc(int active)
argv[0] = (char_u *)"0";
(void)call_func_retnr(p_imaf, 1, argv, FALSE);
}
static int
call_imstatusfunc(void)
{
int is_active;
/* FIXME: Don't execute user function in unsafe situation. */
if (exiting
# ifdef FEAT_AUTOCMD
|| is_autocmd_blocked()
# endif
)
return FALSE;
/* FIXME: :py print 'xxx' is shown duplicate result.
* Use silent to avoid it. */
++msg_silent;
is_active = call_func_retnr(p_imsf, 0, NULL, FALSE);
--msg_silent;
return (is_active > 0);
}
#endif
#if defined(FEAT_XIM) || defined(PROTO)
@@ -4838,14 +4858,7 @@ im_set_active(int active)
im_is_active = (active && !p_imdisable);
if (im_is_active != was_active)
{
#ifdef FEAT_EVAL
if (p_imaf[0] != NUL)
call_imactivatefunc(im_is_active);
else
#endif
xim_reset();
}
xim_reset();
}
void
@@ -5675,6 +5688,11 @@ im_synthesize_keypress(unsigned int keyval, unsigned int state)
void
xim_reset(void)
{
#ifdef FEAT_EVAL
if (p_imaf[0] != NUL)
call_imactivatefunc(im_is_active);
else
#endif
if (xic != NULL)
{
gtk_im_context_reset(xic);
@@ -5685,12 +5703,7 @@ xim_reset(void)
{
xim_set_focus(gui.in_focus);
# ifdef FEAT_EVAL
if (p_imaf[0] != NUL)
call_imactivatefunc(im_is_active);
else
# endif
if (im_activatekey_keyval != GDK_VoidSymbol)
if (im_activatekey_keyval != GDK_VoidSymbol)
{
if (im_is_active)
{
@@ -5856,23 +5869,7 @@ im_get_status(void)
{
# ifdef FEAT_EVAL
if (p_imsf[0] != NUL)
{
int is_active;
/* FIXME: Don't execute user function in unsafe situation. */
if (exiting
# ifdef FEAT_AUTOCMD
|| is_autocmd_blocked()
# endif
)
return FALSE;
/* FIXME: :py print 'xxx' is shown duplicate result.
* Use silent to avoid it. */
++msg_silent;
is_active = call_func_retnr(p_imsf, 0, NULL, FALSE);
--msg_silent;
return (is_active > 0);
}
return call_imstatusfunc();
# endif
return im_is_active;
}
@@ -5894,30 +5891,45 @@ im_is_preediting(void)
static int xim_is_active = FALSE; /* XIM should be active in the current
mode */
static int xim_has_focus = FALSE; /* XIM is really being used for Vim */
#ifdef FEAT_GUI_X11
# ifdef FEAT_GUI_X11
static XIMStyle input_style;
static int status_area_enabled = TRUE;
#endif
# endif
/*
* Switch using XIM on/off. This is used by the code that changes "State".
* When 'imactivatefunc' is defined use that function instead.
*/
void
im_set_active(int active)
im_set_active(int active_arg)
{
if (xic == NULL)
return;
int active = active_arg;
/* If 'imdisable' is set, XIM is never active. */
if (p_imdisable)
active = FALSE;
#if !defined(FEAT_GUI_GTK)
# if !defined(FEAT_GUI_GTK)
else if (input_style & XIMPreeditPosition)
/* 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
* all the time, like it was done in Vim 5.8. */
active = TRUE;
#endif
# endif
# if defined(FEAT_EVAL)
if (p_imaf[0] != NUL)
{
if (active != im_get_status())
{
call_imactivatefunc(active);
im_is_active = active;
}
return;
}
# endif
if (xic == NULL)
return;
/* Remember the active state, it is needed when Vim gets keyboard focus. */
xim_is_active = active;
@@ -6019,19 +6031,19 @@ xim_set_preedit(void)
}
}
#if defined(FEAT_GUI_X11)
# if defined(FEAT_GUI_X11)
static char e_xim[] = N_("E285: Failed to create input context");
#endif
# endif
#if defined(FEAT_GUI_X11) || defined(PROTO)
# if defined(XtSpecificationRelease) && XtSpecificationRelease >= 6 && !defined(SUN_SYSTEM)
# define USE_X11R6_XIM
# endif
# if defined(FEAT_GUI_X11) || defined(PROTO)
# if defined(XtSpecificationRelease) && XtSpecificationRelease >= 6 && !defined(SUN_SYSTEM)
# define USE_X11R6_XIM
# endif
static int xim_real_init(Window x11_window, Display *x11_display);
#ifdef USE_X11R6_XIM
# ifdef USE_X11R6_XIM
static void xim_destroy_cb(XIM im, XPointer client_data, XPointer call_data);
static void
@@ -6043,9 +6055,9 @@ xim_instantiate_cb(
Window x11_window;
Display *x11_display;
#ifdef XIM_DEBUG
# ifdef XIM_DEBUG
xim_log("xim_instantiate_cb()\n");
#endif
# endif
gui_get_x11_windis(&x11_window, &x11_display);
if (display != x11_display)
@@ -6067,9 +6079,9 @@ xim_destroy_cb(
Window x11_window;
Display *x11_display;
#ifdef XIM_DEBUG
# ifdef XIM_DEBUG
xim_log("xim_destroy_cb()\n");
#endif
#endif
gui_get_x11_windis(&x11_window, &x11_display);
xic = NULL;
@@ -6080,7 +6092,7 @@ xim_destroy_cb(
XRegisterIMInstantiateCallback(x11_display, NULL, NULL, NULL,
xim_instantiate_cb, NULL);
}
#endif
# endif
void
xim_init(void)
@@ -6088,9 +6100,9 @@ xim_init(void)
Window x11_window;
Display *x11_display;
#ifdef XIM_DEBUG
# ifdef XIM_DEBUG
xim_log("xim_init()\n");
#endif
# endif
gui_get_x11_windis(&x11_window, &x11_display);
@@ -6101,10 +6113,10 @@ xim_init(void)
gui_set_shellsize(FALSE, FALSE, RESIZE_BOTH);
#ifdef USE_X11R6_XIM
# ifdef USE_X11R6_XIM
XRegisterIMInstantiateCallback(x11_display, NULL, NULL, NULL,
xim_instantiate_cb, NULL);
#endif
# endif
}
static int
@@ -6116,7 +6128,7 @@ xim_real_init(Window x11_window, Display *x11_display)
*ns,
*end,
tmp[1024];
#define IMLEN_MAX 40
# define IMLEN_MAX 40
char buf[IMLEN_MAX + 7];
XIM xim = NULL;
XIMStyles *xim_styles;
@@ -6181,7 +6193,7 @@ xim_real_init(Window x11_window, Display *x11_display)
return FALSE;
}
#ifdef USE_X11R6_XIM
# ifdef USE_X11R6_XIM
{
XIMCallback destroy_cb;
@@ -6190,7 +6202,7 @@ xim_real_init(Window x11_window, Display *x11_display)
if (XSetIMValues(xim, XNDestroyCallback, &destroy_cb, NULL))
EMSG(_("E287: Warning: Could not set destroy callback to IM"));
}
#endif
# endif
if (XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL) || !xim_styles)
{
@@ -6266,7 +6278,7 @@ xim_real_init(Window x11_window, Display *x11_display)
/* A crash was reported when trying to pass gui.norm_font as XNFontSet,
* thus that has been removed. Hopefully the default works... */
#ifdef FEAT_XFONTSET
# ifdef FEAT_XFONTSET
if (gui.fontset != NOFONTSET)
{
preedit_list = XVaCreateNestedList(0,
@@ -6282,7 +6294,7 @@ xim_real_init(Window x11_window, Display *x11_display)
NULL);
}
else
#endif
# endif
{
preedit_list = XVaCreateNestedList(0,
XNSpotLocation, &over_spot,
@@ -6324,7 +6336,7 @@ xim_real_init(Window x11_window, Display *x11_display)
return TRUE;
}
#endif /* FEAT_GUI_X11 */
# endif /* FEAT_GUI_X11 */
/*
* Get IM status. When IM is on, return TRUE. Else return FALSE.
@@ -6335,6 +6347,10 @@ xim_real_init(Window x11_window, Display *x11_display)
int
im_get_status(void)
{
# ifdef FEAT_EVAL
if (p_imsf[0] != NUL)
return call_imstatusfunc();
# endif
return xim_has_focus;
}
@@ -6458,38 +6474,29 @@ xim_get_status_area_height(void)
#else /* !defined(FEAT_XIM) */
# ifndef FEAT_GUI_W32
static int im_was_set_active = FALSE;
int
im_get_status()
{
# ifdef FEAT_EVAL
if (p_imsf[0] != NUL)
{
int is_active;
/* FIXME: Don't execute user function in unsafe situation. */
if (exiting
# ifdef FEAT_AUTOCMD
|| is_autocmd_blocked()
# endif
)
return FALSE;
/* FIXME: :py print 'xxx' is shown duplicate result.
* Use silent to avoid it. */
++msg_silent;
is_active = call_func_retnr(p_imsf, 0, NULL, FALSE);
--msg_silent;
return (is_active > 0);
}
return call_imstatusfunc();
# endif
return FALSE;
return im_was_set_active;
}
void
im_set_active(int active)
im_set_active(int active_arg)
{
# if defined(USE_IM_CONTROL) && defined(FEAT_EVAL)
if (p_imaf[0] != NUL)
call_imactivatefunc(p_imdisable ? FALSE : active);
# if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
int active = !p_imdisable && active_arg;
if (p_imaf[0] != NUL && active != im_get_status())
{
call_imactivatefunc(active);
im_was_set_active = active;
}
# endif
}
# endif