comparison src/input-method-xlib.c @ 444:576fb035e263 r21-2-37

Import from CVS: tag r21-2-37
author cvs
date Mon, 13 Aug 2007 11:36:19 +0200
parents abe6d1db359e
children 3078fd1074e8
comparison
equal deleted inserted replaced
443:a8296e22da4e 444:576fb035e263
32 32
33 The XIM is of the device, by the device, for the device. 33 The XIM is of the device, by the device, for the device.
34 The XIC is of each frame, by each frame, for each frame. 34 The XIC is of each frame, by each frame, for each frame.
35 The exceptions are: 35 The exceptions are:
36 1. Activate XICs on poor frames when the XIM is back. 36 1. Activate XICs on poor frames when the XIM is back.
37 2. Deactivate all the XICs when the XIM go down. 37 2. Deactivate all the XICs when the XIM goes down.
38 38
39 Methods: 39 Implementation:
40 40
41 - Register a callback for an XIM when the X device is being initialized. 41 - Register a callback for an XIM when the X device is being initialized.
42 XIM_init_device (d) { XRegisterIMInstantiateCallback (); } 42 XIM_init_device (d) { XRegisterIMInstantiateCallback (); }
43 The "XRegisterIMInstantiateCallback" is called when an XIM become 43 The "XRegisterIMInstantiateCallback" is called when an XIM become
44 available on the X display. 44 available on the X display.
53 53
54 - Release all the XICs when the XIM was down accidentally. 54 - Release all the XICs when the XIM was down accidentally.
55 In IMDestroyCallback: 55 In IMDestroyCallback:
56 DEVICE_FRAME_LOOP (...) { FRAME_X_XIC (f) = NULL; } 56 DEVICE_FRAME_LOOP (...) { FRAME_X_XIC (f) = NULL; }
57 57
58 - Re-enable XIC for all the frames which doesn't have XIC when the XIM 58 - Re-enable XIC for all the frames which don't have XIC when the XIM
59 is back. 59 is back.
60 In IMInstantiateCallback: 60 In IMInstantiateCallback:
61 DEVICE_FRAME_LOOP (...) { XIM_init_frame (f); } 61 DEVICE_FRAME_LOOP (...) { XIM_init_frame (f); }
62 62
63 63
69 */ 69 */
70 70
71 #include <config.h> 71 #include <config.h>
72 #include "lisp.h" 72 #include "lisp.h"
73 #include <X11/Xlocale.h> /* More portable than <locale.h> ? */ 73 #include <X11/Xlocale.h> /* More portable than <locale.h> ? */
74 #include <X11/Xlib.h>
74 #include "frame.h" 75 #include "frame.h"
75 #include "device.h" 76 #include "device.h"
76 #include "window.h" 77 #include "window.h"
77 #include "buffer.h" 78 #include "buffer.h"
78 #include "console-x.h" 79 #include "console-x.h"
79 #include "EmacsFrame.h" 80 #include "EmacsFrame.h"
80 #include "events.h" 81 #include "events.h"
81
82 #ifdef THIS_IS_X11R6
83 #include <X11/IntrinsicP.h>
84 #endif
85 82
86 #ifndef XIM_XLIB 83 #ifndef XIM_XLIB
87 #error XIM_XLIB is not defined?? 84 #error XIM_XLIB is not defined??
88 #endif 85 #endif
89 86
120 "XIMPreeditNothing|XIMStatusNone\n" 117 "XIMPreeditNothing|XIMStatusNone\n"
121 "XIMPreeditNone|XIMStatusArea\n" 118 "XIMPreeditNone|XIMStatusArea\n"
122 "XIMPreeditNone|XIMStatusNothing\n" 119 "XIMPreeditNone|XIMStatusNothing\n"
123 "XIMPreeditNone|XIMStatusNone"; 120 "XIMPreeditNone|XIMStatusNone";
124 121
125 static Boolean xim_initted = False;
126
127 static XIMStyle best_style (XIMStyles *user, XIMStyles *xim); 122 static XIMStyle best_style (XIMStyles *user, XIMStyles *xim);
128 123
129 /* #### it appears this prototype is missing from the X11R6.4 includes, 124 /* This function is documented, but no prototype in the header files */
130 at least the XFree86 version ... */ 125 EXTERN_C char * XSetIMValues(XIM, ...);
131 char * XSetIMValues(XIM, ...);
132 126
133 void 127 void
134 Initialize_Locale (void) 128 Initialize_Locale (void)
135 { 129 {
136 char *locale; 130 char *locale;
179 xim_warn ("XSetLocaleModifiers(\"\") failed\n" 173 xim_warn ("XSetLocaleModifiers(\"\") failed\n"
180 "Check the value of the XMODIFIERS environment variable.\n"); 174 "Check the value of the XMODIFIERS environment variable.\n");
181 } 175 }
182 } 176 }
183 177
184 #ifdef THIS_IS_X11R6 /* Callbacks for IM are supported from X11R6 or later. */ 178 /* Callbacks for IM are supported from X11R6 or later. */
179 #ifdef HAVE_XREGISTERIMINSTANTIATECALLBACK
180
181 static Boolean xim_initted = False;
182
185 /* Called from when XIM is destroying. 183 /* Called from when XIM is destroying.
186 Clear all the XIC when the XIM was destroying... */ 184 Clear all the XIC when the XIM was destroying... */
187 static void 185 static void
188 IMDestroyCallback (XIM im, XPointer client_data, XPointer call_data) 186 IMDestroyCallback (XIM im, XPointer client_data, XPointer call_data)
189 { 187 {
222 xim_initted = True; 220 xim_initted = True;
223 XtGetApplicationNameAndClass (dpy, &name, &class); 221 XtGetApplicationNameAndClass (dpy, &name, &class);
224 DEVICE_X_XIM (d) = xim = XOpenIM (dpy, XtDatabase (dpy), name, class); 222 DEVICE_X_XIM (d) = xim = XOpenIM (dpy, XtDatabase (dpy), name, class);
225 223
226 /* destroy callback for im */ 224 /* destroy callback for im */
227 ximcallback.callback = IMDestroyCallback; 225 ximcallback.callback = (XIMProc) IMDestroyCallback;
228 ximcallback.client_data = (XPointer) d; 226 ximcallback.client_data = (XPointer) d;
229 XSetIMValues (xim, XNDestroyCallback, &ximcallback, NULL); 227 XSetIMValues (xim, XNDestroyCallback, &ximcallback, NULL);
230 } 228 }
231 229
232 /* activate XIC on all the X frames... */ 230 /* activate XIC on all the X frames... */
238 XIM_init_frame (target_frame); 236 XIM_init_frame (target_frame);
239 } 237 }
240 } 238 }
241 return; 239 return;
242 } 240 }
243 #endif /* if THIS_IS_X11R6 */ 241 #endif /* HAVE_XREGISTERIMINSTANTIATECALLBACK */
244 242
245 /* Initialize XIM for X device. 243 /* Initialize XIM for X device.
246 Register the use of XIM using XRegisterIMInstantiateCallback. */ 244 Register the use of XIM using XRegisterIMInstantiateCallback. */
247 void 245 void
248 XIM_init_device (struct device *d) 246 XIM_init_device (struct device *d)
249 { 247 {
250 #ifdef THIS_IS_X11R6 248 #ifdef HAVE_XREGISTERIMINSTANTIATECALLBACK /* X11R6+ */
251 DEVICE_X_XIM (d) = NULL; 249 DEVICE_X_XIM (d) = NULL;
252 XRegisterIMInstantiateCallback (DEVICE_X_DISPLAY (d), NULL, NULL, NULL, 250 XRegisterIMInstantiateCallback (DEVICE_X_DISPLAY (d), NULL, NULL, NULL,
253 IMInstantiateCallback, 251 #ifdef XREGISTERIMINSTANTIATECALLBACK_NONSTANDARD_PROTOTYPE
254 /* The sixth parameter is of type 252 /* The sixth parameter is of type
255 XPointer in XFree86 but (XPointer *) 253 XPointer in XFree86 but (XPointer *)
256 on most other X11's. */ 254 on most other X11's. */
257 (void *) d); 255 (XIDProc) IMInstantiateCallback,
256 (XPointer) d
257 #else /* X Consortium prototype */
258 (XIMProc) IMInstantiateCallback,
259 (XPointer *) d
260 #endif /* XREGISTERIMINSTANTIATECALLBACK_NONSTANDARD_PROTOTYPE */
261 );
258 return; 262 return;
259 #else 263 #else /* pre-X11R6 */
260 Display *dpy = DEVICE_X_DISPLAY (d); 264 Display *dpy = DEVICE_X_DISPLAY (d);
261 char *name, *class; 265 char *name, *class;
262 XIM xim; 266 XIM xim;
263 267
264 XtGetApplicationNameAndClass (dpy, &name, &class); 268 XtGetApplicationNameAndClass (dpy, &name, &class);
271 else 275 else
272 { 276 {
273 XGetIMValues (xim, XNQueryInputStyle, &DEVICE_X_XIM_STYLES (d), NULL); 277 XGetIMValues (xim, XNQueryInputStyle, &DEVICE_X_XIM_STYLES (d), NULL);
274 return; 278 return;
275 } 279 }
276 #endif 280 #endif /* HAVE_XREGISTERIMINSTANTIATECALLBACK */
277 } 281 }
278 282
279 283
280 /* 284 /*
281 * For the frames 285 * For the frames
405 409
406 XIM_SetGeometry (f); 410 XIM_SetGeometry (f);
407 411
408 XSetICFocus (xic); 412 XSetICFocus (xic);
409 413
410 #ifdef THIS_IS_X11R6 414 #ifdef HAVE_XREGISTERIMINSTANTIATECALLBACK
411 /* when frame is going to be destroyed (closed) */ 415 /* when frame is going to be destroyed (closed) */
412 XtAddCallback (FRAME_X_TEXT_WIDGET(f), XNDestroyCallback, 416 XtAddCallback (FRAME_X_TEXT_WIDGET(f), XNDestroyCallback,
413 XIM_delete_frame, (XtPointer)f); 417 XIM_delete_frame, (XtPointer)f);
414 #endif 418 #endif
415 } 419 }