diff options
| author | Gerd Moellmann | 2000-01-04 23:08:36 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-01-04 23:08:36 +0000 |
| commit | 86779fac991b2fee27d45f332ebd3693499eed41 (patch) | |
| tree | 088aa2cc59dd0a397f67fb70ff4c008ec11b3602 /src | |
| parent | a7cca2405459f4bdf539bd23fd03722a5ad0ad73 (diff) | |
| download | emacs-86779fac991b2fee27d45f332ebd3693499eed41.tar.gz emacs-86779fac991b2fee27d45f332ebd3693499eed41.zip | |
(x_create_im): New function to set IM and IC of a frame.
Check that input style is supported before trying to create an
IC for it.
(x_window): Call x_create_im.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfns.c | 132 |
1 files changed, 69 insertions, 63 deletions
diff --git a/src/xfns.c b/src/xfns.c index c10e08e1eb8..fde3f1b6729 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -735,6 +735,7 @@ struct x_frame_parm_table | |||
| 735 | void (*setter) P_ ((struct frame *, Lisp_Object, Lisp_Object)); | 735 | void (*setter) P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 736 | }; | 736 | }; |
| 737 | 737 | ||
| 738 | static void x_create_im P_ ((struct frame *)); | ||
| 738 | void x_set_foreground_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); | 739 | void x_set_foreground_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 739 | void x_set_background_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); | 740 | void x_set_background_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 740 | void x_set_mouse_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); | 741 | void x_set_mouse_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| @@ -3043,6 +3044,72 @@ hack_wm_protocols (f, widget) | |||
| 3043 | UNBLOCK_INPUT; | 3044 | UNBLOCK_INPUT; |
| 3044 | } | 3045 | } |
| 3045 | #endif | 3046 | #endif |
| 3047 | |||
| 3048 | |||
| 3049 | /* Create input method and input context for frame F. Set FRAME_XIM | ||
| 3050 | (F) and FRAME_XIC (F). */ | ||
| 3051 | |||
| 3052 | static void | ||
| 3053 | x_create_im (f) | ||
| 3054 | struct frame *f; | ||
| 3055 | { | ||
| 3056 | FRAME_XIM (f) = 0; | ||
| 3057 | FRAME_XIC (f) = 0; | ||
| 3058 | |||
| 3059 | #ifdef HAVE_X_I18N | ||
| 3060 | #ifndef X_I18N_INHIBITED | ||
| 3061 | { | ||
| 3062 | XIM xim; | ||
| 3063 | XIC xic = NULL; | ||
| 3064 | XIMStyles *styles; | ||
| 3065 | XIMStyle input_style = XIMPreeditNothing | XIMStatusNothing; | ||
| 3066 | int i, n; | ||
| 3067 | |||
| 3068 | xim = XOpenIM (FRAME_X_DISPLAY(f), NULL, NULL, NULL); | ||
| 3069 | if (!xim) | ||
| 3070 | return; | ||
| 3071 | |||
| 3072 | if (XGetIMValues (xim, XNQueryInputStyle, &styles, NULL) | ||
| 3073 | || !styles) | ||
| 3074 | { | ||
| 3075 | /* Input method doesn't support any input style. */ | ||
| 3076 | XCloseIM (xim); | ||
| 3077 | return; | ||
| 3078 | } | ||
| 3079 | |||
| 3080 | /* See if input_style is supported. Give up if it isn't. */ | ||
| 3081 | n = styles->count_styles; | ||
| 3082 | for (i = 0; i < n; ++i) | ||
| 3083 | if (styles->supported_styles[i] == input_style) | ||
| 3084 | break; | ||
| 3085 | |||
| 3086 | XFree (styles); | ||
| 3087 | if (i == n) | ||
| 3088 | { | ||
| 3089 | XCloseIM (xim); | ||
| 3090 | return; | ||
| 3091 | } | ||
| 3092 | |||
| 3093 | /* Create the input context. */ | ||
| 3094 | xic = XCreateIC (xim, | ||
| 3095 | XNInputStyle, input_style, | ||
| 3096 | XNClientWindow, FRAME_X_WINDOW(f), | ||
| 3097 | XNFocusWindow, FRAME_X_WINDOW(f), | ||
| 3098 | NULL); | ||
| 3099 | |||
| 3100 | if (!xic) | ||
| 3101 | { | ||
| 3102 | XCloseIM (xim); | ||
| 3103 | return; | ||
| 3104 | } | ||
| 3105 | |||
| 3106 | FRAME_XIM (f) = xim; | ||
| 3107 | FRAME_XIC (f) = xic; | ||
| 3108 | } | ||
| 3109 | #endif /* X_I18N_INHIBITED */ | ||
| 3110 | #endif /* HAVE_X_I18N */ | ||
| 3111 | } | ||
| 3112 | |||
| 3046 | 3113 | ||
| 3047 | #ifdef USE_X_TOOLKIT | 3114 | #ifdef USE_X_TOOLKIT |
| 3048 | 3115 | ||
| @@ -3198,37 +3265,7 @@ x_window (f, window_prompting, minibuffer_only) | |||
| 3198 | class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data; | 3265 | class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data; |
| 3199 | class_hints.res_class = (char *) XSTRING (Vx_resource_class)->data; | 3266 | class_hints.res_class = (char *) XSTRING (Vx_resource_class)->data; |
| 3200 | XSetClassHint (FRAME_X_DISPLAY (f), XtWindow (shell_widget), &class_hints); | 3267 | XSetClassHint (FRAME_X_DISPLAY (f), XtWindow (shell_widget), &class_hints); |
| 3201 | 3268 | x_create_im (f); | |
| 3202 | #ifdef HAVE_X_I18N | ||
| 3203 | #ifndef X_I18N_INHIBITED | ||
| 3204 | { | ||
| 3205 | XIM xim; | ||
| 3206 | XIC xic = NULL; | ||
| 3207 | |||
| 3208 | xim = XOpenIM (FRAME_X_DISPLAY (f), NULL, NULL, NULL); | ||
| 3209 | |||
| 3210 | if (xim) | ||
| 3211 | { | ||
| 3212 | xic = XCreateIC (xim, | ||
| 3213 | XNInputStyle, XIMPreeditNothing | XIMStatusNothing, | ||
| 3214 | XNClientWindow, FRAME_X_WINDOW(f), | ||
| 3215 | XNFocusWindow, FRAME_X_WINDOW(f), | ||
| 3216 | NULL); | ||
| 3217 | |||
| 3218 | if (xic == 0) | ||
| 3219 | { | ||
| 3220 | XCloseIM (xim); | ||
| 3221 | xim = NULL; | ||
| 3222 | } | ||
| 3223 | } | ||
| 3224 | FRAME_XIM (f) = xim; | ||
| 3225 | FRAME_XIC (f) = xic; | ||
| 3226 | } | ||
| 3227 | #else /* X_I18N_INHIBITED */ | ||
| 3228 | FRAME_XIM (f) = 0; | ||
| 3229 | FRAME_XIC (f) = 0; | ||
| 3230 | #endif /* X_I18N_INHIBITED */ | ||
| 3231 | #endif /* HAVE_X_I18N */ | ||
| 3232 | 3269 | ||
| 3233 | f->output_data.x->wm_hints.input = True; | 3270 | f->output_data.x->wm_hints.input = True; |
| 3234 | f->output_data.x->wm_hints.flags |= InputHint; | 3271 | f->output_data.x->wm_hints.flags |= InputHint; |
| @@ -3319,38 +3356,7 @@ x_window (f) | |||
| 3319 | InputOutput, /* class */ | 3356 | InputOutput, /* class */ |
| 3320 | FRAME_X_DISPLAY_INFO (f)->visual, | 3357 | FRAME_X_DISPLAY_INFO (f)->visual, |
| 3321 | attribute_mask, &attributes); | 3358 | attribute_mask, &attributes); |
| 3322 | #ifdef HAVE_X_I18N | 3359 | x_create_im (f); |
| 3323 | #ifndef X_I18N_INHIBITED | ||
| 3324 | { | ||
| 3325 | XIM xim; | ||
| 3326 | XIC xic = NULL; | ||
| 3327 | |||
| 3328 | xim = XOpenIM (FRAME_X_DISPLAY(f), NULL, NULL, NULL); | ||
| 3329 | |||
| 3330 | if (xim) | ||
| 3331 | { | ||
| 3332 | xic = XCreateIC (xim, | ||
| 3333 | XNInputStyle, XIMPreeditNothing | XIMStatusNothing, | ||
| 3334 | XNClientWindow, FRAME_X_WINDOW(f), | ||
| 3335 | XNFocusWindow, FRAME_X_WINDOW(f), | ||
| 3336 | NULL); | ||
| 3337 | |||
| 3338 | if (!xic) | ||
| 3339 | { | ||
| 3340 | XCloseIM (xim); | ||
| 3341 | xim = NULL; | ||
| 3342 | } | ||
| 3343 | } | ||
| 3344 | |||
| 3345 | FRAME_XIM (f) = xim; | ||
| 3346 | FRAME_XIC (f) = xic; | ||
| 3347 | } | ||
| 3348 | #else /* X_I18N_INHIBITED */ | ||
| 3349 | FRAME_XIM (f) = 0; | ||
| 3350 | FRAME_XIC (f) = 0; | ||
| 3351 | #endif /* X_I18N_INHIBITED */ | ||
| 3352 | #endif /* HAVE_X_I18N */ | ||
| 3353 | |||
| 3354 | validate_x_resource_name (); | 3360 | validate_x_resource_name (); |
| 3355 | 3361 | ||
| 3356 | class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data; | 3362 | class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data; |