Mercurial > emacs
comparison src/xfns.c @ 27157:3dafddaefc2c
(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.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Tue, 04 Jan 2000 23:08:36 +0000 |
parents | 31b7a2a8ea20 |
children | 43230463dfcf |
comparison
equal
deleted
inserted
replaced
27156:488f307b4f59 | 27157:3dafddaefc2c |
---|---|
733 { | 733 { |
734 char *name; | 734 char *name; |
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)); |
741 void x_set_cursor_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); | 742 void x_set_cursor_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
742 void x_set_border_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); | 743 void x_set_border_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
3041 (unsigned char *) props, count); | 3042 (unsigned char *) props, count); |
3042 } | 3043 } |
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 |
3049 /* Create and set up the X widget for frame F. */ | 3116 /* Create and set up the X widget for frame F. */ |
3050 | 3117 |
3196 validate_x_resource_name (); | 3263 validate_x_resource_name (); |
3197 | 3264 |
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; |
3235 XSetWMHints (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | 3272 XSetWMHints (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), |
3236 &f->output_data.x->wm_hints); | 3273 &f->output_data.x->wm_hints); |
3317 f->output_data.x->border_width, | 3354 f->output_data.x->border_width, |
3318 CopyFromParent, /* depth */ | 3355 CopyFromParent, /* depth */ |
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; |
3357 class_hints.res_class = (char *) XSTRING (Vx_resource_class)->data; | 3363 class_hints.res_class = (char *) XSTRING (Vx_resource_class)->data; |
3358 XSetClassHint (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &class_hints); | 3364 XSetClassHint (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &class_hints); |