diff options
| author | Dave Love | 2003-05-21 22:11:50 +0000 |
|---|---|---|
| committer | Dave Love | 2003-05-21 22:11:50 +0000 |
| commit | 51f3cc3b8ab8c318dfe19d819cfd10c57e3febb8 (patch) | |
| tree | 9470715765f0fd0747182cce81ac0a572640ceea /src | |
| parent | 7ad6faa724e25fefdd46b6f5fafabb1b0e8f7827 (diff) | |
| download | emacs-51f3cc3b8ab8c318dfe19d819cfd10c57e3febb8.tar.gz emacs-51f3cc3b8ab8c318dfe19d819cfd10c57e3febb8.zip | |
(use_xim): Initialize.
(xim_open_dpy, xim_initialize, xim_close_dpy): Use use_xim.
(x_term_init): Maybe set use_xim.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xterm.c | 112 |
1 files changed, 65 insertions, 47 deletions
diff --git a/src/xterm.c b/src/xterm.c index 128a1bf0ef2..1d28bb5b92a 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -158,6 +158,8 @@ extern void _XEditResCheckMessages (); | |||
| 158 | 158 | ||
| 159 | #define abs(x) ((x) < 0 ? -(x) : (x)) | 159 | #define abs(x) ((x) < 0 ? -(x) : (x)) |
| 160 | 160 | ||
| 161 | /* Default to using XIM if available. */ | ||
| 162 | int use_xim = 1; | ||
| 161 | 163 | ||
| 162 | 164 | ||
| 163 | /* Non-nil means Emacs uses toolkit scroll bars. */ | 165 | /* Non-nil means Emacs uses toolkit scroll bars. */ |
| @@ -6461,7 +6463,7 @@ handle_one_xevent (dpyinfo, eventp, bufp_r, numcharsp, finish) | |||
| 6461 | require = decoding_buffer_size (&coding, nbytes); | 6463 | require = decoding_buffer_size (&coding, nbytes); |
| 6462 | p = (unsigned char *) alloca (require); | 6464 | p = (unsigned char *) alloca (require); |
| 6463 | coding.mode |= CODING_MODE_LAST_BLOCK; | 6465 | coding.mode |= CODING_MODE_LAST_BLOCK; |
| 6464 | /* We explicitely disable composition | 6466 | /* We explicitly disable composition |
| 6465 | handling because key data should | 6467 | handling because key data should |
| 6466 | not contain any composition | 6468 | not contain any composition |
| 6467 | sequence. */ | 6469 | sequence. */ |
| @@ -8025,31 +8027,33 @@ xim_open_dpy (dpyinfo, resource_name) | |||
| 8025 | struct x_display_info *dpyinfo; | 8027 | struct x_display_info *dpyinfo; |
| 8026 | char *resource_name; | 8028 | char *resource_name; |
| 8027 | { | 8029 | { |
| 8028 | #ifdef USE_XIM | ||
| 8029 | XIM xim; | 8030 | XIM xim; |
| 8030 | 8031 | ||
| 8031 | xim = XOpenIM (dpyinfo->display, dpyinfo->xrdb, resource_name, EMACS_CLASS); | 8032 | if (use_xim) |
| 8032 | dpyinfo->xim = xim; | ||
| 8033 | |||
| 8034 | if (xim) | ||
| 8035 | { | 8033 | { |
| 8034 | xim = XOpenIM (dpyinfo->display, dpyinfo->xrdb, resource_name, | ||
| 8035 | EMACS_CLASS); | ||
| 8036 | dpyinfo->xim = xim; | ||
| 8037 | |||
| 8038 | if (xim) | ||
| 8039 | { | ||
| 8036 | #ifdef HAVE_X11R6 | 8040 | #ifdef HAVE_X11R6 |
| 8037 | XIMCallback destroy; | 8041 | XIMCallback destroy; |
| 8038 | #endif | 8042 | #endif |
| 8039 | 8043 | ||
| 8040 | /* Get supported styles and XIM values. */ | 8044 | /* Get supported styles and XIM values. */ |
| 8041 | XGetIMValues (xim, XNQueryInputStyle, &dpyinfo->xim_styles, NULL); | 8045 | XGetIMValues (xim, XNQueryInputStyle, &dpyinfo->xim_styles, NULL); |
| 8042 | 8046 | ||
| 8043 | #ifdef HAVE_X11R6 | 8047 | #ifdef HAVE_X11R6 |
| 8044 | destroy.callback = xim_destroy_callback; | 8048 | destroy.callback = xim_destroy_callback; |
| 8045 | destroy.client_data = (XPointer)dpyinfo; | 8049 | destroy.client_data = (XPointer)dpyinfo; |
| 8046 | XSetIMValues (xim, XNDestroyCallback, &destroy, NULL); | 8050 | XSetIMValues (xim, XNDestroyCallback, &destroy, NULL); |
| 8047 | #endif | 8051 | #endif |
| 8052 | } | ||
| 8048 | } | 8053 | } |
| 8049 | 8054 | ||
| 8050 | #else /* not USE_XIM */ | 8055 | else |
| 8051 | dpyinfo->xim = NULL; | 8056 | dpyinfo->xim = NULL; |
| 8052 | #endif /* not USE_XIM */ | ||
| 8053 | } | 8057 | } |
| 8054 | 8058 | ||
| 8055 | 8059 | ||
| @@ -8123,32 +8127,33 @@ xim_initialize (dpyinfo, resource_name) | |||
| 8123 | struct x_display_info *dpyinfo; | 8127 | struct x_display_info *dpyinfo; |
| 8124 | char *resource_name; | 8128 | char *resource_name; |
| 8125 | { | 8129 | { |
| 8126 | #ifdef USE_XIM | 8130 | if (use_xim) |
| 8131 | { | ||
| 8127 | #ifdef HAVE_X11R6_XIM | 8132 | #ifdef HAVE_X11R6_XIM |
| 8128 | struct xim_inst_t *xim_inst; | 8133 | struct xim_inst_t *xim_inst; |
| 8129 | int len; | 8134 | int len; |
| 8130 | 8135 | ||
| 8131 | dpyinfo->xim = NULL; | 8136 | dpyinfo->xim = NULL; |
| 8132 | xim_inst = (struct xim_inst_t *) xmalloc (sizeof (struct xim_inst_t)); | 8137 | xim_inst = (struct xim_inst_t *) xmalloc (sizeof (struct xim_inst_t)); |
| 8133 | xim_inst->dpyinfo = dpyinfo; | 8138 | xim_inst->dpyinfo = dpyinfo; |
| 8134 | len = strlen (resource_name); | 8139 | len = strlen (resource_name); |
| 8135 | xim_inst->resource_name = (char *) xmalloc (len + 1); | 8140 | xim_inst->resource_name = (char *) xmalloc (len + 1); |
| 8136 | bcopy (resource_name, xim_inst->resource_name, len + 1); | 8141 | bcopy (resource_name, xim_inst->resource_name, len + 1); |
| 8137 | XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb, | 8142 | XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb, |
| 8138 | resource_name, EMACS_CLASS, | 8143 | resource_name, EMACS_CLASS, |
| 8139 | xim_instantiate_callback, | 8144 | xim_instantiate_callback, |
| 8140 | /* Fixme: This is XPointer in | 8145 | /* Fixme: This is XPointer in |
| 8141 | XFree86 but (XPointer *) on | 8146 | XFree86 but (XPointer *) on |
| 8142 | Tru64, at least. */ | 8147 | Tru64, at least. */ |
| 8143 | (XPointer) xim_inst); | 8148 | (XPointer) xim_inst); |
| 8144 | #else /* not HAVE_X11R6_XIM */ | 8149 | #else /* not HAVE_X11R6_XIM */ |
| 8145 | dpyinfo->xim = NULL; | 8150 | dpyinfo->xim = NULL; |
| 8146 | xim_open_dpy (dpyinfo, resource_name); | 8151 | xim_open_dpy (dpyinfo, resource_name); |
| 8147 | #endif /* not HAVE_X11R6_XIM */ | 8152 | #endif /* not HAVE_X11R6_XIM */ |
| 8148 | 8153 | ||
| 8149 | #else /* not USE_XIM */ | 8154 | } |
| 8150 | dpyinfo->xim = NULL; | 8155 | else |
| 8151 | #endif /* not USE_XIM */ | 8156 | dpyinfo->xim = NULL; |
| 8152 | } | 8157 | } |
| 8153 | 8158 | ||
| 8154 | 8159 | ||
| @@ -8158,18 +8163,19 @@ static void | |||
| 8158 | xim_close_dpy (dpyinfo) | 8163 | xim_close_dpy (dpyinfo) |
| 8159 | struct x_display_info *dpyinfo; | 8164 | struct x_display_info *dpyinfo; |
| 8160 | { | 8165 | { |
| 8161 | #ifdef USE_XIM | 8166 | if (use_xim) |
| 8167 | { | ||
| 8162 | #ifdef HAVE_X11R6_XIM | 8168 | #ifdef HAVE_X11R6_XIM |
| 8163 | if (dpyinfo->display) | 8169 | if (dpyinfo->display) |
| 8164 | XUnregisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb, | 8170 | XUnregisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb, |
| 8165 | NULL, EMACS_CLASS, | 8171 | NULL, EMACS_CLASS, |
| 8166 | xim_instantiate_callback, NULL); | 8172 | xim_instantiate_callback, NULL); |
| 8167 | #endif /* not HAVE_X11R6_XIM */ | 8173 | #endif /* not HAVE_X11R6_XIM */ |
| 8168 | if (dpyinfo->display) | 8174 | if (dpyinfo->display) |
| 8169 | XCloseIM (dpyinfo->xim); | 8175 | XCloseIM (dpyinfo->xim); |
| 8170 | dpyinfo->xim = NULL; | 8176 | dpyinfo->xim = NULL; |
| 8171 | XFree (dpyinfo->xim_styles); | 8177 | XFree (dpyinfo->xim_styles); |
| 8172 | #endif /* USE_XIM */ | 8178 | } |
| 8173 | } | 8179 | } |
| 8174 | 8180 | ||
| 8175 | #endif /* not HAVE_X11R6_XIM */ | 8181 | #endif /* not HAVE_X11R6_XIM */ |
| @@ -10536,6 +10542,18 @@ x_term_init (display_name, xrm_option, resource_name) | |||
| 10536 | || !strcmp (SDATA (value), "on"))) | 10542 | || !strcmp (SDATA (value), "on"))) |
| 10537 | XSynchronize (dpyinfo->display, True); | 10543 | XSynchronize (dpyinfo->display, True); |
| 10538 | } | 10544 | } |
| 10545 | |||
| 10546 | { | ||
| 10547 | Lisp_Object value; | ||
| 10548 | value = display_x_get_resource (dpyinfo, | ||
| 10549 | build_string ("useXIM"), | ||
| 10550 | build_string ("UseXIM"), | ||
| 10551 | Qnil, Qnil); | ||
| 10552 | if (STRINGP (value) | ||
| 10553 | && (!strcmp (XSTRING (value)->data, "false") | ||
| 10554 | || !strcmp (XSTRING (value)->data, "off"))) | ||
| 10555 | use_xim = 0; | ||
| 10556 | } | ||
| 10539 | 10557 | ||
| 10540 | UNBLOCK_INPUT; | 10558 | UNBLOCK_INPUT; |
| 10541 | 10559 | ||