Mercurial > emacs
comparison src/xterm.c @ 51129:e9be5c94117e
(use_xim): Initialize.
(xim_open_dpy, xim_initialize, xim_close_dpy): Use use_xim.
(x_term_init): Maybe set use_xim.
author | Dave Love <fx@gnu.org> |
---|---|
date | Wed, 21 May 2003 22:11:50 +0000 |
parents | 2c04067bcdc0 |
children | 791af636af55 |
comparison
equal
deleted
inserted
replaced
51128:d0f7882a3321 | 51129:e9be5c94117e |
---|---|
156 #endif | 156 #endif |
157 #endif | 157 #endif |
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. */ |
164 | 166 |
165 Lisp_Object Vx_toolkit_scroll_bars; | 167 Lisp_Object Vx_toolkit_scroll_bars; |
6459 unsigned char *p; | 6461 unsigned char *p; |
6460 | 6462 |
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. */ |
6468 coding.composing = COMPOSITION_DISABLED; | 6470 coding.composing = COMPOSITION_DISABLED; |
6469 decode_coding (&coding, copy_bufptr, p, | 6471 decode_coding (&coding, copy_bufptr, p, |
8023 static void | 8025 static void |
8024 xim_open_dpy (dpyinfo, resource_name) | 8026 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 { |
8033 | 8034 xim = XOpenIM (dpyinfo->display, dpyinfo->xrdb, resource_name, |
8034 if (xim) | 8035 EMACS_CLASS); |
8035 { | 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 |
8048 } | 8052 } |
8049 | 8053 } |
8050 #else /* not USE_XIM */ | 8054 |
8051 dpyinfo->xim = NULL; | 8055 else |
8052 #endif /* not USE_XIM */ | 8056 dpyinfo->xim = NULL; |
8053 } | 8057 } |
8054 | 8058 |
8055 | 8059 |
8056 #ifdef HAVE_X11R6_XIM | 8060 #ifdef HAVE_X11R6_XIM |
8057 | 8061 |
8121 static void | 8125 static void |
8122 xim_initialize (dpyinfo, resource_name) | 8126 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 |
8155 /* Close the connection to the XIM server on display DPYINFO. */ | 8160 /* Close the connection to the XIM server on display DPYINFO. */ |
8156 | 8161 |
8157 static void | 8162 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 */ |
8176 | 8182 |
8177 | 8183 |
10534 if (STRINGP (value) | 10540 if (STRINGP (value) |
10535 && (!strcmp (SDATA (value), "true") | 10541 && (!strcmp (SDATA (value), "true") |
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 |
10542 return dpyinfo; | 10560 return dpyinfo; |
10543 } | 10561 } |