428
|
1 /* Various functions for X11R5+ input methods, using the Xlib interface.
|
|
2 Copyright (C) 1996 Sun Microsystems.
|
793
|
3 Copyright (C) 2002 Ben Wing.
|
428
|
4
|
|
5 This file is part of XEmacs.
|
|
6
|
|
7 XEmacs is free software; you can redistribute it and/or modify it
|
|
8 under the terms of the GNU General Public License as published by the
|
|
9 Free Software Foundation; either version 2, or (at your option) any
|
|
10 later version.
|
|
11
|
|
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
15 for more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License
|
|
18 along with XEmacs; see the file COPYING. If not, write to
|
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
20 Boston, MA 02111-1307, USA. */
|
|
21
|
|
22 /* Synched up with: Not in FSF. */
|
|
23
|
|
24 /* Written by Martin Buchholz. */
|
|
25
|
|
26 /* This file implements an interface to X input methods, available
|
|
27 with X11R5 and above. See O'Reilly, Xlib programmer's guide,
|
|
28 and X11 R6 release guide chapters on internationalized input,
|
|
29 for further details */
|
|
30
|
|
31 /*
|
|
32 Policy:
|
|
33
|
|
34 The XIM is of the device, by the device, for the device.
|
|
35 The XIC is of each frame, by each frame, for each frame.
|
|
36 The exceptions are:
|
|
37 1. Activate XICs on poor frames when the XIM is back.
|
444
|
38 2. Deactivate all the XICs when the XIM goes down.
|
428
|
39
|
444
|
40 Implementation:
|
428
|
41
|
|
42 - Register a callback for an XIM when the X device is being initialized.
|
|
43 XIM_init_device (d) { XRegisterIMInstantiateCallback (); }
|
|
44 The "XRegisterIMInstantiateCallback" is called when an XIM become
|
|
45 available on the X display.
|
|
46
|
|
47 - Catch the XIC when the frame is being initialized if XIM was available.
|
|
48 XIM_init_frame (f) { ... XCreateIC (); ... }
|
|
49
|
|
50 - Release the XIC when the frame is being closed.
|
|
51 XIM_delete_frame (f) { ... FRAME_X_XIC (f) = NULL; ... }
|
|
52 "XIM_delete_frame" is a "DestroyCallback" function declared in
|
|
53 XIM_init_frame ();
|
|
54
|
|
55 - Release all the XICs when the XIM was down accidentally.
|
|
56 In IMDestroyCallback:
|
|
57 DEVICE_FRAME_LOOP (...) { FRAME_X_XIC (f) = NULL; }
|
|
58
|
444
|
59 - Re-enable XIC for all the frames which don't have XIC when the XIM
|
428
|
60 is back.
|
|
61 In IMInstantiateCallback:
|
|
62 DEVICE_FRAME_LOOP (...) { XIM_init_frame (f); }
|
|
63
|
|
64
|
|
65 Note:
|
|
66
|
|
67 - Currently, we don't use XDestroyIC because of _XimProtoCloseIM
|
|
68 (internally registered as im->methods->close) does "Xfree (ic)".
|
|
69
|
|
70 */
|
|
71
|
|
72 #include <config.h>
|
|
73 #include "lisp.h"
|
872
|
74
|
|
75 #include "buffer.h"
|
|
76 #include "device-impl.h"
|
|
77 #include "events.h"
|
|
78 #include "frame-impl.h"
|
|
79 #include "window-impl.h"
|
|
80
|
|
81 #include "console-x-impl.h"
|
|
82 #include "EmacsFrame.h"
|
|
83
|
428
|
84 #include <X11/Xlocale.h> /* More portable than <locale.h> ? */
|
444
|
85 #include <X11/Xlib.h>
|
428
|
86
|
448
|
87 #if !defined (XIM_XLIB) && !defined (USE_XFONTSET)
|
|
88 #error neither XIM_XLIB nor USE_XFONTSET is defined??
|
428
|
89 #endif
|
|
90
|
771
|
91 #ifdef XIM_XLIB /* XIM_XLIB specific */
|
428
|
92
|
|
93 /* Get/Set IC values for just one attribute */
|
|
94 #ifdef DEBUG_XEMACS
|
|
95 #define XIC_Value(Get_Set, xic, name, attr, value) \
|
|
96 do { \
|
|
97 char *bad_arg; \
|
|
98 XVaNestedList list = XVaCreateNestedList (0, attr, value, NULL); \
|
|
99 if ((bad_arg = X##Get_Set##ICValues (xic, name, list, NULL)) != NULL) \
|
|
100 stderr_out ("X" #Get_Set "ICValues " "bad Arg: %s\n", bad_arg); \
|
|
101 XFree (list); \
|
|
102 } while (0)
|
|
103 #else /* ! DEBUG_XEMACS */
|
|
104 #define XIC_Value(Get_Set, xic, name, attr, value) \
|
|
105 do { \
|
|
106 XVaNestedList list = XVaCreateNestedList (0, attr, value, NULL); \
|
|
107 X##Get_Set##ICValues (xic, name, list, NULL); \
|
|
108 XFree (list); \
|
|
109 } while (0)
|
|
110 #endif /* DEBUG_XEMACS */
|
|
111
|
|
112 static char DefaultXIMStyles[] =
|
|
113 "XIMPreeditPosition|XIMStatusArea\n"
|
|
114 "XIMPreeditPosition|XIMStatusNone\n"
|
|
115 "XIMPreeditPosition|XIMStatusNothing\n"
|
|
116 "XIMPreeditNothing|XIMStatusArea\n"
|
|
117 "XIMPreeditNothing|XIMStatusNothing\n"
|
|
118 "XIMPreeditNothing|XIMStatusNone\n"
|
|
119 "XIMPreeditNone|XIMStatusArea\n"
|
|
120 "XIMPreeditNone|XIMStatusNothing\n"
|
|
121 "XIMPreeditNone|XIMStatusNone";
|
|
122
|
|
123 static XIMStyle best_style (XIMStyles *user, XIMStyles *xim);
|
771
|
124
|
448
|
125 #endif /* XIM_XLIB only */
|
428
|
126
|
444
|
127 /* This function is documented, but no prototype in the header files */
|
|
128 EXTERN_C char * XSetIMValues(XIM, ...);
|
442
|
129
|
448
|
130 #ifdef XIM_XLIB /* starting XIM specific codes */
|
|
131
|
444
|
132 /* Callbacks for IM are supported from X11R6 or later. */
|
|
133 #ifdef HAVE_XREGISTERIMINSTANTIATECALLBACK
|
|
134
|
|
135 static Boolean xim_initted = False;
|
|
136
|
428
|
137 /* Called from when XIM is destroying.
|
|
138 Clear all the XIC when the XIM was destroying... */
|
|
139 static void
|
2286
|
140 IMDestroyCallback (XIM UNUSED (im), XPointer client_data,
|
|
141 XPointer UNUSED (call_data))
|
428
|
142 {
|
|
143 struct device *d = (struct device *)client_data;
|
|
144 Lisp_Object tail;
|
|
145
|
|
146 DEVICE_FRAME_LOOP (tail, d)
|
|
147 {
|
|
148 struct frame *target_frame = XFRAME (XCAR (tail));
|
|
149 if (FRAME_X_P (target_frame) && FRAME_X_XIC (target_frame))
|
|
150 {
|
|
151 /* XDestroyIC (FRAME_X_XIC (target_frame)); */
|
|
152 FRAME_X_XIC (target_frame) = NULL;
|
|
153 }
|
|
154 }
|
|
155
|
|
156 DEVICE_X_XIM (d) = NULL;
|
|
157 xim_initted = False;
|
|
158 return;
|
|
159 }
|
|
160
|
|
161 /* This is registered in XIM_init_device (when DEVICE is initializing).
|
|
162 This activates XIM when XIM becomes available. */
|
|
163 static void
|
2286
|
164 IMInstantiateCallback (Display *dpy, XPointer client_data,
|
|
165 XPointer UNUSED (call_data))
|
428
|
166 {
|
|
167 struct device *d = (struct device *)client_data;
|
|
168 XIM xim;
|
1204
|
169 char *name, *class_;
|
428
|
170 XIMCallback ximcallback;
|
|
171 Lisp_Object tail;
|
|
172
|
|
173 /* if no xim is presented, initialize xim ... */
|
|
174 if ( xim_initted == False )
|
|
175 {
|
|
176 xim_initted = True;
|
1204
|
177 XtGetApplicationNameAndClass (dpy, &name, &class_);
|
|
178 DEVICE_X_XIM (d) = xim = XOpenIM (dpy, XtDatabase (dpy), name, class_);
|
428
|
179
|
|
180 /* destroy callback for im */
|
444
|
181 ximcallback.callback = (XIMProc) IMDestroyCallback;
|
428
|
182 ximcallback.client_data = (XPointer) d;
|
|
183 XSetIMValues (xim, XNDestroyCallback, &ximcallback, NULL);
|
|
184 }
|
|
185
|
|
186 /* activate XIC on all the X frames... */
|
|
187 DEVICE_FRAME_LOOP (tail, d)
|
|
188 {
|
|
189 struct frame *target_frame = XFRAME (XCAR (tail));
|
|
190 if (FRAME_X_P (target_frame) && !FRAME_X_XIC (target_frame))
|
|
191 {
|
|
192 XIM_init_frame (target_frame);
|
|
193 }
|
|
194 }
|
|
195 return;
|
|
196 }
|
444
|
197 #endif /* HAVE_XREGISTERIMINSTANTIATECALLBACK */
|
428
|
198
|
|
199 /* Initialize XIM for X device.
|
|
200 Register the use of XIM using XRegisterIMInstantiateCallback. */
|
|
201 void
|
|
202 XIM_init_device (struct device *d)
|
|
203 {
|
444
|
204 #ifdef HAVE_XREGISTERIMINSTANTIATECALLBACK /* X11R6+ */
|
428
|
205 DEVICE_X_XIM (d) = NULL;
|
|
206 XRegisterIMInstantiateCallback (DEVICE_X_DISPLAY (d), NULL, NULL, NULL,
|
444
|
207 #ifdef XREGISTERIMINSTANTIATECALLBACK_NONSTANDARD_PROTOTYPE
|
442
|
208 /* The sixth parameter is of type
|
|
209 XPointer in XFree86 but (XPointer *)
|
|
210 on most other X11's. */
|
444
|
211 (XIDProc) IMInstantiateCallback,
|
|
212 (XPointer) d
|
|
213 #else /* X Consortium prototype */
|
|
214 (XIMProc) IMInstantiateCallback,
|
|
215 (XPointer *) d
|
|
216 #endif /* XREGISTERIMINSTANTIATECALLBACK_NONSTANDARD_PROTOTYPE */
|
|
217 );
|
428
|
218 return;
|
444
|
219 #else /* pre-X11R6 */
|
428
|
220 Display *dpy = DEVICE_X_DISPLAY (d);
|
1204
|
221 char *name, *class_;
|
428
|
222 XIM xim;
|
|
223
|
1204
|
224 XtGetApplicationNameAndClass (dpy, &name, &class_);
|
|
225 DEVICE_X_XIM (d) = xim = XOpenIM (dpy, XtDatabase (dpy), name, class_);
|
428
|
226 if (xim == NULL)
|
|
227 {
|
793
|
228 warn_when_safe
|
|
229 (Qxintl, Qerror,
|
|
230 "Can't initialize XIM: XOpenIM() failed, no input server available");
|
428
|
231 return;
|
|
232 }
|
|
233 else
|
|
234 {
|
|
235 XGetIMValues (xim, XNQueryInputStyle, &DEVICE_X_XIM_STYLES (d), NULL);
|
|
236 return;
|
|
237 }
|
444
|
238 #endif /* HAVE_XREGISTERIMINSTANTIATECALLBACK */
|
428
|
239 }
|
|
240
|
|
241
|
|
242 /*
|
|
243 * For the frames
|
|
244 */
|
|
245
|
|
246 /* Callback for the deleting frame. */
|
|
247 static void
|
2286
|
248 XIM_delete_frame (Widget UNUSED (w), XtPointer client_data,
|
|
249 XtPointer UNUSED (call_data))
|
428
|
250 {
|
|
251 struct frame *f = (struct frame *) client_data;
|
|
252 struct device *d = XDEVICE (FRAME_DEVICE (f));
|
|
253
|
|
254 if (DEVICE_X_XIM (d))
|
|
255 {
|
|
256 if (FRAME_X_XIC (f))
|
|
257 {
|
|
258 XDestroyIC (FRAME_X_XIC (f));
|
|
259 FRAME_X_XIC (f) = NULL;
|
|
260 }
|
|
261 }
|
|
262 return;
|
|
263 }
|
|
264
|
|
265 /* Initialize XIC for new frame.
|
|
266 Create an X input context (XIC) for this frame. */
|
|
267 void
|
|
268 XIM_init_frame (struct frame *f)
|
|
269 {
|
|
270 struct device *d = XDEVICE (FRAME_DEVICE (f));
|
|
271 XIM xim;
|
|
272 Widget w = FRAME_X_TEXT_WIDGET (f);
|
|
273 Window win = XtWindow (w);
|
|
274 XRectangle p_area = {0,0,1,1}, s_area = {0,0,1,1};
|
|
275 XPoint spot = {0,0};
|
|
276 XIMStyle style;
|
|
277 XVaNestedList p_list, s_list;
|
|
278 typedef struct
|
|
279 {
|
|
280 XIMStyles styles;
|
|
281 XFontSet fontset;
|
|
282 Pixel fg;
|
|
283 Pixel bg;
|
|
284 char *inputmethod;
|
|
285 } xic_vars_t;
|
|
286 xic_vars_t xic_vars;
|
|
287 XIC xic;
|
|
288
|
1204
|
289 #define res(name, class_, representation, field, default_value) \
|
|
290 { name, class_, representation, sizeof(xic_vars.field), \
|
428
|
291 XtOffsetOf(xic_vars_t, field), XtRString, default_value }
|
|
292
|
|
293 static XtResource resources[] =
|
|
294 {
|
|
295 /* name class represent'n field default value */
|
|
296 res(XtNximStyles, XtCXimStyles, XtRXimStyles, styles, (XtPointer) DefaultXIMStyles),
|
|
297 res(XtNfontSet, XtCFontSet, XtRFontSet, fontset, (XtPointer) XtDefaultFontSet),
|
|
298 res(XtNximForeground, XtCForeground, XtRPixel, fg, (XtPointer) XtDefaultForeground),
|
|
299 res(XtNximBackground, XtCBackground, XtRPixel, bg, (XtPointer) XtDefaultBackground)
|
|
300 };
|
|
301
|
|
302
|
|
303 xim = DEVICE_X_XIM (d);
|
|
304
|
|
305 if (!xim)
|
|
306 {
|
|
307 return;
|
|
308 }
|
|
309
|
|
310 w = FRAME_X_TEXT_WIDGET (f);
|
|
311
|
|
312 /*
|
|
313 * initialize XIC
|
|
314 */
|
|
315 if (FRAME_X_XIC (f)) return;
|
|
316 XtGetApplicationResources (w, &xic_vars,
|
|
317 resources, XtNumber (resources),
|
|
318 NULL, 0);
|
|
319 if (!xic_vars.fontset)
|
|
320 {
|
793
|
321 warn_when_safe
|
|
322 (Qxintl, Qerror,
|
|
323 "Can't initialize XIM: Can't get fontset resource for Input Method");
|
428
|
324 FRAME_X_XIC (f) = NULL;
|
|
325 return;
|
|
326 }
|
|
327
|
|
328 /* construct xic */
|
|
329 XGetIMValues (xim, XNQueryInputStyle, &DEVICE_X_XIM_STYLES(d), NULL);
|
|
330 FRAME_X_XIC_STYLE (f) = style =
|
|
331 best_style (&xic_vars.styles, (XIMStyles *)DEVICE_X_XIM_STYLES(d));
|
|
332
|
|
333 p_list = XVaCreateNestedList (0,
|
|
334 XNArea, &p_area,
|
|
335 XNSpotLocation, &spot,
|
|
336 XNForeground, xic_vars.fg,
|
|
337 XNBackground, xic_vars.bg,
|
|
338 XNFontSet, xic_vars.fontset,
|
|
339 NULL);
|
|
340
|
|
341 s_list = XVaCreateNestedList (0,
|
|
342 XNArea, &s_area,
|
|
343 XNForeground, xic_vars.fg,
|
|
344 XNBackground, xic_vars.bg,
|
|
345 XNFontSet, xic_vars.fontset,
|
|
346 NULL);
|
|
347
|
|
348 FRAME_X_XIC (f) = xic =
|
|
349 XCreateIC (xim,
|
|
350 XNInputStyle, style,
|
|
351 XNClientWindow, win,
|
|
352 XNFocusWindow, win,
|
|
353 XNPreeditAttributes, p_list,
|
|
354 XNStatusAttributes, s_list,
|
|
355 NULL);
|
|
356 XFree (p_list);
|
|
357 XFree (s_list);
|
|
358
|
|
359 if (!xic)
|
|
360 {
|
793
|
361 warn_when_safe (Qxintl, Qerror,
|
|
362 "Can't initialize XIM: XCreateIC failed");
|
428
|
363 return;
|
|
364 }
|
|
365
|
|
366 if (style & XIMPreeditPosition)
|
|
367 {
|
|
368 XPoint *frame_spot = &(FRAME_X_XIC_SPOT(f));
|
|
369 frame_spot->x = frame_spot->y = -1;
|
|
370 }
|
|
371
|
|
372 XIM_SetGeometry (f);
|
|
373
|
|
374 XSetICFocus (xic);
|
|
375
|
444
|
376 #ifdef HAVE_XREGISTERIMINSTANTIATECALLBACK
|
428
|
377 /* when frame is going to be destroyed (closed) */
|
793
|
378 XtAddCallback (FRAME_X_TEXT_WIDGET (f), XNDestroyCallback,
|
|
379 XIM_delete_frame, (XtPointer)f );
|
428
|
380 #endif
|
|
381 }
|
|
382
|
|
383
|
|
384 void
|
|
385 XIM_SetGeometry (struct frame *f)
|
|
386 {
|
|
387 XIC xic = FRAME_X_XIC (f);
|
|
388 XIMStyle style = FRAME_X_XIC_STYLE (f);
|
|
389 XRectangle area;
|
|
390
|
|
391 if (!xic || !f)
|
|
392 return;
|
|
393
|
|
394 if (style & XIMStatusArea)
|
|
395 {
|
|
396 /* Place Status Area in bottom right corner */
|
|
397 /* Negotiate geometry of status area */
|
|
398 /* See O'Reilly Xlib XIM chapter (but beware, it's buggy) */
|
|
399 XRectangle *needed;
|
|
400
|
|
401 /* If input method has existing status area, use its current size */
|
|
402 /* The following at least works for Sun's htt */
|
|
403 area.x = area.y = area.width = area.height = 0;
|
|
404 XIC_Value (Set, xic, XNStatusAttributes, XNAreaNeeded, &area);
|
|
405 XIC_Value (Get, xic, XNStatusAttributes, XNAreaNeeded, &needed);
|
|
406 if (needed->width == 0) /* Use XNArea instead of XNAreaNeeded */
|
|
407 XIC_Value (Get, xic, XNStatusAttributes, XNArea, &needed);
|
|
408
|
|
409 area.width = needed->width;
|
|
410 area.height = needed->height;
|
|
411 area.x = FRAME_RIGHT_BORDER_START (f) - area.width;
|
|
412 area.y = FRAME_BOTTOM_BORDER_START (f) - area.height;
|
|
413
|
|
414 #ifdef DEBUG_XIM
|
|
415 stderr_out ("Putting StatusArea in x=%d y=%d w=%d h=%d\n",
|
|
416 area.x, area.y, area.width, area.height);
|
|
417 #endif /* DEBUG_XIM */
|
|
418
|
|
419 XIC_Value (Set, xic, XNStatusAttributes, XNArea, &area);
|
|
420 }
|
|
421
|
|
422 if (style & XIMPreeditPosition)
|
|
423 {
|
|
424 /* Set Preedit Area to whole frame size (sans border) */
|
|
425 /* We include the border because Preedit window might be larger
|
|
426 than display line at edge. #### FIX: we should adjust to make
|
|
427 sure that there is always room for the spot sub-window */
|
|
428 area.x = FRAME_LEFT_BORDER_START (f);
|
|
429 area.y = FRAME_TOP_BORDER_START (f);
|
|
430 area.width = FRAME_RIGHT_BORDER_END (f) - area.x;
|
|
431 area.height = FRAME_BOTTOM_BORDER_END (f) - area.y;
|
|
432 XIC_Value(Set, xic, XNPreeditAttributes, XNArea, &area);
|
|
433 }
|
|
434
|
|
435 #ifdef DEBUG_XIM
|
|
436 describe_XIC (xic);
|
|
437 #endif
|
|
438 }
|
|
439
|
|
440 void
|
|
441 XIM_SetSpotLocation (struct frame *f, int x, int y)
|
|
442 {
|
|
443 XIC xic = FRAME_X_XIC (f);
|
|
444 XPoint *spot = &(FRAME_X_XIC_SPOT (f));
|
|
445
|
|
446 /* Only care if we have a valid XIC using Over the Spot in
|
|
447 * a different location */
|
|
448 if (!xic ||
|
|
449 !(FRAME_X_XIC_STYLE (f) & XIMPreeditPosition) ||
|
|
450 (spot->x == (short) x &&
|
|
451 spot->y == (short) y))
|
|
452 return;
|
|
453
|
|
454 spot->x = (short) x;
|
|
455 spot->y = (short) y;
|
|
456
|
440
|
457 /* #### FIX: Must make sure spot fits within Preedit Area */
|
428
|
458 XIC_Value (Set, xic, XNPreeditAttributes, XNSpotLocation, spot);
|
|
459 #ifdef DEBUG_XIM
|
|
460 stderr_out ("Spot: %d %d\n", spot->x, spot->y);
|
|
461 #endif
|
|
462 }
|
|
463
|
|
464 void
|
|
465 XIM_focus_event (struct frame *f, int in_p)
|
|
466 {
|
|
467 if (FRAME_X_XIC (f) /* && FRAME_X_XIM_REGISTERED(f) */)
|
|
468 (in_p ? XSetICFocus : XUnsetICFocus) (FRAME_X_XIC (f));
|
|
469 }
|
|
470
|
|
471 #if 0
|
|
472 #define XIM_Composed_Text_BUFSIZE 64
|
|
473 typedef struct XIM_Composed_Text
|
|
474 {
|
|
475 int size;
|
|
476 wchar_t data [XIM_Composed_Text_BUFSIZE];
|
|
477 } XIM_Composed_Text;
|
|
478
|
|
479 static XIM_Composed_Text composed_input_buf = {XIM_Composed_Text_BUFSIZE, {0}};
|
|
480 Window main_window;
|
|
481
|
|
482 /* get_XIM_input -- Process results of input method composition.
|
|
483
|
|
484 This function copies the results of the input method composition to
|
|
485 composed_input_buf. Then for each character, a custom event of type
|
|
486 wc_atom is sent with the character as its data.
|
|
487
|
|
488 It is probably more efficient to copy the composition results to some
|
|
489 allocated memory and send a single event pointing to that memory.
|
|
490 That would cut down on the event processing as well as allow quick
|
|
491 insertion into the buffer of the whole string. It might require some
|
|
492 care, though, to avoid fragmenting memory through the allocation and
|
|
493 freeing of many small chunks. Maybe the existing system for
|
|
494 (single-byte) string allocation can be used, multiplying the length by
|
|
495 sizeof (wchar_t) to get the right size.
|
|
496 */
|
|
497 void
|
|
498 get_XIM_input (XKeyPressedEvent *x_key_event, XIC ic, Display *dpy)
|
|
499 {
|
|
500 KeySym keysym;
|
|
501 Status status;
|
|
502 int len;
|
|
503 int i;
|
|
504 XClientMessageEvent new_event;
|
|
505
|
|
506 retry:
|
|
507 len = XwcLookupString (ic, x_key_event, composed_input_buf.data,
|
|
508 composed_input_buf.size, &keysym, &status);
|
|
509 switch (status)
|
|
510 {
|
|
511 case XBufferOverflow:
|
|
512 /* GROW_WC_STRING (&composed_input_buf, 32); mrb */
|
|
513 goto retry;
|
|
514 case XLookupChars:
|
|
515 break;
|
|
516 default:
|
2500
|
517 ABORT ();
|
428
|
518 }
|
|
519
|
|
520 new_event.type = ClientMessage;
|
|
521 new_event.display = x_key_event->display;
|
|
522 new_event.window = x_key_event->window;
|
|
523 new_event.message_type = wc_atom;
|
|
524 new_event.format = 32; /* 32-bit wide data */
|
|
525 new_event.data.l[2] = new_event.data.l[3] = new_event.data.l[4] = 0L;
|
|
526 new_event.data.l[0] = x_key_event->time;
|
|
527 for (i = 0; i < len; i++)
|
|
528 {
|
|
529 new_event.data.l[1] = ((wchar_t *) composed_input_buf.data)[i];
|
|
530 XSendEvent (display, main_window, False, 0L, (XEvent *) &new_event);
|
|
531 }
|
|
532 }
|
|
533 #endif /* 0 */
|
|
534
|
|
535 /* ============================================================== */
|
|
536 /* X input method style determination */
|
|
537 /* ============================================================== */
|
|
538
|
|
539 #if 0
|
|
540 #define done(type, value) \
|
|
541 if (toVal->addr != NULL) { \
|
|
542 if (toVal->size < sizeof(type)) { \
|
|
543 toVal->size = sizeof(type); \
|
|
544 return False; \
|
|
545 } \
|
|
546 *(type*)toVal->addr = (value); \
|
|
547 } else { \
|
|
548 static type static_val; \
|
|
549 static_val = (value); \
|
|
550 toVal->addr = (XPointer)&static_val; \
|
|
551 } \
|
|
552 toVal->size = sizeof(type); \
|
|
553 return True /* Caller supplies `;' */
|
|
554 #endif /* 0 */
|
|
555
|
|
556 /*
|
|
557 * This is a standard Xt type converter, except that the caller MUST
|
|
558 * supply a proper non-NULL toVal XIMStyles structure that we will
|
|
559 * fill in.
|
|
560 *
|
|
561 * fromVal points to a string like
|
|
562 *
|
|
563 "XIMPreeditPosition|XIMStatusArea,
|
|
564 XIMPreeditPosition|XIMStatusNothing
|
|
565 XIMPreeditNothing|XIMStatusNothing"
|
|
566 *
|
|
567 * This is converted in the obvious way to a XIMStyles structure.
|
|
568 *
|
|
569 * mrb: #### Fix this to handle Motif-style specifications for
|
|
570 * XIMStyles as well: overTheSpot, rootWindow, none */
|
|
571
|
|
572 /* XtTypeConverter */
|
|
573 Boolean
|
|
574 EmacsXtCvtStringToXIMStyles (
|
|
575 Display *dpy,
|
|
576 XrmValuePtr args,
|
|
577 Cardinal *num_args,
|
|
578 XrmValuePtr fromVal,
|
|
579 XrmValuePtr toVal,
|
|
580 XtPointer *converter_data)
|
|
581 {
|
|
582 #define STYLE_INFO(style) { style, #style, sizeof(#style) }
|
|
583 static struct XIMStyleInfo
|
|
584 {
|
442
|
585 const XIMStyle style;
|
|
586 const char * const name;
|
|
587 const int namelen;
|
428
|
588 } emacs_XIMStyleInfo[] = {
|
|
589 STYLE_INFO (XIMPreeditPosition|XIMStatusArea),
|
|
590 STYLE_INFO (XIMPreeditPosition|XIMStatusNothing),
|
|
591 STYLE_INFO (XIMPreeditPosition|XIMStatusNone),
|
|
592 STYLE_INFO (XIMPreeditNothing|XIMStatusArea),
|
|
593 STYLE_INFO (XIMPreeditNothing|XIMStatusNothing),
|
|
594 STYLE_INFO (XIMPreeditNothing|XIMStatusNone),
|
|
595 STYLE_INFO (XIMPreeditNone|XIMStatusArea),
|
|
596 STYLE_INFO (XIMPreeditNone|XIMStatusNothing),
|
|
597 STYLE_INFO (XIMPreeditNone|XIMStatusNone)
|
|
598 };
|
|
599 #undef STYLE_INFO
|
|
600
|
|
601 char *s = (char *) fromVal->addr;
|
|
602 char *end = s + fromVal->size;
|
442
|
603 XIMStyles * const p = (XIMStyles *) toVal->addr;
|
|
604 const char * const delimiter = " \t\n\r:;," ;
|
|
605 const int max_styles = XtNumber(emacs_XIMStyleInfo);
|
428
|
606 int i;
|
|
607 char *c;
|
|
608
|
|
609 #ifdef DEBUG_XIM
|
|
610 stderr_out ("EmacsCvtStringToXIMStyles called with size=%d, string=\"%s\"\n",
|
|
611 fromVal->size, (char *) fromVal->addr);
|
|
612 #endif /* DEBUG_XIM */
|
|
613
|
|
614 if (*num_args != 0)
|
|
615 {
|
|
616 XtAppContext the_app_con = XtDisplayToApplicationContext (dpy);
|
|
617 XtAppWarningMsg(the_app_con, "wrongParameters", "cvtStringToXIMStyle",
|
|
618 "XtToolkitError",
|
|
619 "String to XIMStyle conversion requires exactly 0 parameters",
|
|
620 (String *)NULL, (Cardinal *)NULL);
|
|
621 return False;
|
|
622 }
|
|
623
|
|
624 #ifdef DEBUG_XEMACS
|
|
625 /* Make sure caller is giving us good data */
|
|
626 assert (fromVal->addr != NULL);
|
|
627 assert (fromVal->size == strlen(fromVal->addr)+1);
|
|
628 assert (toVal->addr != NULL);
|
|
629 assert (toVal->size == sizeof(XIMStyles));
|
|
630 #endif /* DEBUG_XEMACS */
|
|
631
|
|
632 p->count_styles = 0;
|
|
633 p->supported_styles = xnew_array (XIMStyle, max_styles);
|
|
634
|
|
635 /*
|
|
636 * The following routine assumes that the style name resource is
|
|
637 * identical with the programmatic name of style. For example,
|
|
638 * "XIMPreeditPosition|XIMStatusArea" means the
|
|
639 * XIMPreeditPosition|XIMStatusArea value is specified. If the
|
|
640 * style name is changed, such as "OverTheSpot|imDisplaysInClient",
|
|
641 * the parsing logic below should be modified as well. */
|
|
642
|
|
643 if ((c = strtok(s, delimiter)) == NULL)
|
|
644 c = end;
|
|
645
|
|
646 while (c < end)
|
|
647 {
|
|
648 for(i=0 ; i<max_styles ; i++)
|
|
649 {
|
|
650 struct XIMStyleInfo *rec = emacs_XIMStyleInfo + i;
|
|
651 if(!strncmp(c, rec->name, rec->namelen - 1)) {
|
|
652 p->supported_styles[p->count_styles] = rec->style;
|
|
653 p->count_styles++;
|
|
654 break;
|
|
655 }
|
|
656 }
|
|
657 if((c = strtok(NULL, delimiter)) == NULL) {
|
|
658 break ;
|
|
659 }
|
|
660 }
|
|
661
|
|
662 if (p->count_styles == 0)
|
|
663 { /* No valid styles? */
|
2367
|
664 /* !!#### */
|
|
665 char *buf = (char *) ALLOCA (strlen (fromVal->addr)
|
|
666 + strlen (DefaultXIMStyles)
|
|
667 + 100);
|
428
|
668 XrmValue new_from;
|
|
669 XtAppContext the_app_con = XtDisplayToApplicationContext (dpy);
|
|
670
|
|
671 sprintf(buf, "Cannot convert string \"%s\" to type XIMStyles.\n"
|
|
672 "Using default string \"%s\" instead.\n",
|
|
673 fromVal->addr, DefaultXIMStyles);
|
|
674 XtAppWarningMsg(the_app_con, "wrongParameters", "cvtStringToXIMStyle",
|
|
675 "XtToolkitError",
|
|
676 buf, (String *)NULL, (Cardinal *)NULL);
|
|
677 new_from.addr = DefaultXIMStyles;
|
|
678 new_from.size = sizeof(DefaultXIMStyles);
|
|
679 return EmacsXtCvtStringToXIMStyles (dpy, args, num_args,
|
|
680 &new_from, toVal, converter_data);
|
|
681 }
|
|
682 XREALLOC_ARRAY (p->supported_styles, XIMStyle, p->count_styles);
|
|
683 *converter_data = (char *) True;
|
|
684 return True;
|
|
685 }
|
|
686
|
|
687 /* XtDestructor */
|
|
688 void
|
|
689 EmacsFreeXIMStyles (
|
|
690 XtAppContext app,
|
|
691 XrmValuePtr toVal,
|
|
692 XtPointer converter_data,
|
2286
|
693 XrmValuePtr UNUSED (args),
|
428
|
694 Cardinal *num_args)
|
|
695 {
|
|
696 #ifdef DEBUG_XIM
|
|
697 stderr_out ("Converter data: %x\n", converter_data);
|
|
698 stderr_out ("EmacsFreeXIMStyles called\n");
|
|
699 #endif /* DEBUG_XIM */
|
|
700
|
|
701 if (*num_args != 0)
|
|
702 {
|
|
703 XtAppWarningMsg(app, "wrongParameters","freeXIMStyles","XtToolkitError",
|
|
704 "Freeing an XIMStyles requires that zero arguments be passwd",
|
|
705 (String *)NULL, (Cardinal *)NULL);
|
|
706 return;
|
|
707 }
|
|
708
|
|
709 if (converter_data)
|
|
710 {
|
|
711 Boolean free_p = (Boolean) (int) converter_data;
|
|
712 XIMStyles *styles = (XIMStyles *) toVal->addr;
|
|
713 if (free_p)
|
|
714 XFree ( styles->supported_styles );
|
|
715 }
|
|
716 }
|
|
717
|
|
718 #if 0
|
|
719 /* O'Reilly XLib Programming Manual, pg. 371 */
|
|
720 /* Much nicer implementation than O'Reilly */
|
|
721 /* Choose the more `complicated', hence nicer, XIM input style */
|
|
722 static XIMStyle
|
|
723 BetterStyle (XIMStyle s, XIMStyle t)
|
|
724 {
|
|
725 #define CHECK_XIMStyle_BIT(bit) \
|
|
726 if ((s ^ t) & bit) { return (s & bit) ? s : t; }
|
|
727
|
|
728 CHECK_XIMStyle_BIT (XIMPreeditCallbacks);
|
|
729 CHECK_XIMStyle_BIT (XIMPreeditPosition);
|
|
730 CHECK_XIMStyle_BIT (XIMPreeditArea);
|
|
731 CHECK_XIMStyle_BIT (XIMPreeditNothing);
|
|
732 CHECK_XIMStyle_BIT (XIMStatusCallbacks);
|
|
733 CHECK_XIMStyle_BIT (XIMStatusArea);
|
|
734 CHECK_XIMStyle_BIT (XIMStatusNothing);
|
|
735 #undef CHECK_XIMStyle_BIT
|
|
736 return s ? s : t ;
|
|
737 }
|
|
738 #endif /* 0 */
|
|
739
|
|
740 /* Choose the best style, given:
|
|
741 * - user preferences (already checked to be supported by XEmacs)
|
|
742 * - styles supported by the input method */
|
|
743 #define DEFAULTStyle (XIMPreeditNothing|XIMStatusNothing)
|
|
744 static XIMStyle
|
|
745 best_style (XIMStyles *user, XIMStyles *xim)
|
|
746 {
|
|
747 REGISTER int i, j;
|
|
748 for (i=0 ; i<user->count_styles ; i++)
|
|
749 {
|
|
750 for (j=0 ; j<xim->count_styles ; j++)
|
|
751 {
|
|
752 if (user->supported_styles[i] == xim->supported_styles[j])
|
|
753 return user->supported_styles[i];
|
|
754 }
|
|
755 }
|
|
756 return DEFAULTStyle; /* Default Style */
|
|
757 }
|
|
758
|
|
759 /* These lisp-callable functions will be sealed until xim-leim is needed.
|
|
760 Oct 22 1999 - kazz */
|
|
761 #if 0
|
|
762 /*
|
|
763 * External callable function for XIM
|
|
764 */
|
|
765 DEFUN ("x-open-xim", Fx_open_xim, 1, 1, 0, /*
|
|
766 Open the XIC on the frame if XIM is available.
|
|
767 Commonly, use this as \(x-open-xim \(selected-frame)).
|
|
768 If the frame is not on X device, return signal.
|
|
769 If XIC is created successfully return t. If not return nil.
|
|
770 */
|
|
771 (frame))
|
|
772 {
|
|
773 struct frame *f;
|
|
774
|
|
775 CHECK_LIVE_FRAME (frame);
|
|
776 f = XFRAME (frame);
|
|
777 if (!FRAME_X_P (f))
|
563
|
778 invalid_argument ("This frame is not on X device", frame);
|
428
|
779
|
|
780 XIM_init_frame (f);
|
|
781 return FRAME_X_XIC (f) ? Qt : Qnil;
|
|
782 }
|
|
783
|
|
784 DEFUN ("x-close-xim", Fx_close_xim, 1, 1, 0, /*
|
|
785 Close the XIC on the frame if it exists.
|
|
786 Commonly, use this as \(x-close-xim \(selected-frame)).
|
|
787 If the frame is not on X device, return signal.
|
|
788 Otherwise, it destroys the XIC if it exists, then returns t anyway.
|
|
789 */
|
|
790 (frame))
|
|
791 {
|
|
792 struct frame *f;
|
|
793 struct device *d;
|
|
794
|
|
795 CHECK_LIVE_FRAME (frame);
|
|
796 f = XFRAME (frame);
|
|
797 if (!FRAME_X_P (f))
|
563
|
798 invalid_argument ("This frame is not on X device", frame);
|
428
|
799
|
|
800 d = XDEVICE (FRAME_DEVICE (f));
|
|
801 if (DEVICE_X_XIM (d)) {
|
|
802 /* XDestroyIC (FRAME_X_XIC (XFRAME (f))); */
|
|
803 FRAME_X_XIC (XFRAME (f)) = NULL;
|
|
804 }
|
|
805 return Qt;
|
|
806 }
|
|
807 #endif /* if 0 */
|
|
808
|
|
809 void
|
|
810 syms_of_input_method_xlib (void)
|
|
811 {
|
|
812 #if 0 /* see above */
|
|
813 DEFSUBR (Fx_open_xim);
|
|
814 DEFSUBR (Fx_close_xim);
|
|
815 #endif
|
|
816 }
|
|
817
|
|
818 void
|
|
819 vars_of_input_method_xlib (void)
|
|
820 {
|
|
821 Fprovide (intern ("xim"));
|
|
822 }
|
|
823
|
|
824
|
|
825 /* ====================================================================== */
|
|
826 /* Internal Debugging Routines */
|
|
827 /* ====================================================================== */
|
|
828 #ifdef DEBUG_XEMACS
|
|
829
|
|
830 void
|
|
831 describe_XIM (XIM xim)
|
|
832 {
|
|
833 XIMStyles *styles;
|
|
834
|
|
835 /* Print locale of XIM */
|
|
836 stderr_out ("\nXIM Locale of IM: %s\n", XLocaleOfIM(xim));
|
|
837
|
|
838 /* List supported input method styles */
|
|
839 XGetIMValues(xim, XNQueryInputStyle, &styles, NULL);
|
|
840
|
|
841 stderr_out ("\n%d input style(s) supported by input method.\n",
|
|
842 styles->count_styles);
|
|
843
|
|
844 #ifdef DEBUG_XIM
|
|
845 {
|
|
846 int i;
|
|
847 for (i=0; i < styles->count_styles; i++)
|
|
848 describe_XIMStyle (styles->supported_styles[i]);
|
|
849 }
|
|
850 #endif /* DEBUG_XIM */
|
|
851 XFree(styles);
|
|
852 }
|
|
853
|
|
854 void
|
|
855 describe_XFontSet (XFontSet fontset)
|
|
856 {
|
|
857 XFontStruct **font_struct_list;
|
|
858 char **font_name_list;
|
|
859 int count, i;
|
|
860
|
|
861 if (fontset == NULL)
|
|
862 {
|
|
863 stderr_out ("NULL\n");
|
|
864 return;
|
|
865 }
|
|
866
|
|
867 count = XFontsOfFontSet (fontset, &font_struct_list, &font_name_list);
|
|
868 stderr_out ( "%d font(s) available:\n", count);
|
|
869 for (i=0 ; i < count ; i++)
|
|
870 stderr_out ("Font: %s\n", *(font_name_list+i));
|
|
871 }
|
|
872
|
|
873 void
|
|
874 describe_Status (Status status)
|
|
875 {
|
|
876 #define DESCRIBE_STATUS(value) \
|
|
877 if (status == value) stderr_out ("Status: " #value "\n")
|
|
878
|
|
879 DESCRIBE_STATUS (XBufferOverflow);
|
|
880 DESCRIBE_STATUS (XLookupNone);
|
|
881 DESCRIBE_STATUS (XLookupKeySym);
|
|
882 DESCRIBE_STATUS (XLookupBoth);
|
|
883 DESCRIBE_STATUS (XLookupChars);
|
|
884 #undef DESCRIBE_STATUS
|
|
885 }
|
|
886
|
|
887 void
|
|
888 describe_Window (Window win)
|
|
889 {
|
|
890 char xwincmd[128];
|
|
891 sprintf (xwincmd, "xwininfo -id 0x%x >&2; xwininfo -events -id 0x%x >&2",
|
|
892 (int) win, (int) win);
|
|
893 system (xwincmd);
|
|
894 }
|
|
895
|
|
896 void
|
|
897 describe_XIC (XIC xic)
|
|
898 {
|
|
899 XIMStyle style;
|
|
900 Window client_win=0, focus_win=0;
|
|
901 char *resourceName = NULL;
|
|
902 char *resourceClass = NULL;
|
|
903 char *bad_arg = NULL;
|
|
904 unsigned long filter_mask = NoEventMask;
|
|
905 XVaNestedList p_list, s_list;
|
|
906 XFontSet p_fontset = NULL, s_fontset = NULL;
|
|
907 Pixel p_fg=0, p_bg = 0, s_fg=0, s_bg = 0;
|
|
908 XRectangle *p_area = NULL, *s_area = NULL;
|
|
909 XRectangle *p_needed = NULL, *s_needed = NULL;
|
|
910 XPoint *p_spot = NULL;
|
|
911
|
|
912 /* Check for valid input context and method */
|
|
913 if (!xic)
|
|
914 stderr_out ("Input method is NULL\n");
|
|
915
|
|
916 if (!XIMOfIC(xic))
|
|
917 stderr_out ("XIMOfIC() returns NULL\n");
|
|
918
|
|
919 /* Print out Input Context Attributes */
|
|
920 p_list = XVaCreateNestedList (0,
|
|
921 XNFontSet, &p_fontset,
|
|
922 XNArea, &p_area,
|
|
923 XNAreaNeeded, &p_needed,
|
|
924 XNSpotLocation, &p_spot,
|
|
925 XNForeground, &p_fg,
|
|
926 XNBackground, &p_bg,
|
|
927 NULL);
|
|
928
|
|
929 s_list = XVaCreateNestedList (0,
|
|
930 XNFontSet, &s_fontset,
|
|
931 XNArea, &s_area,
|
|
932 XNAreaNeeded, &s_needed,
|
|
933 XNForeground, &s_fg,
|
|
934 XNBackground, &s_bg,
|
|
935 NULL);
|
|
936
|
|
937 bad_arg = XGetICValues(xic,
|
|
938 XNInputStyle, &style,
|
|
939 XNFilterEvents, &filter_mask,
|
|
940 XNClientWindow, &client_win,
|
|
941 XNFocusWindow, &focus_win,
|
|
942 XNResourceName, &resourceName,
|
|
943 XNResourceClass, &resourceClass,
|
|
944 XNPreeditAttributes, p_list,
|
|
945 XNStatusAttributes, s_list,
|
|
946 NULL);
|
|
947 XFree(p_list);
|
|
948 XFree(s_list);
|
|
949
|
|
950 if (bad_arg != NULL)
|
|
951 stderr_out ("Couldn't get IC value: %s\n", bad_arg);
|
|
952
|
|
953 stderr_out ("\nInput method context attributes:\n");
|
|
954 stderr_out ("Style: "); describe_XIMStyle (style);
|
|
955 stderr_out ("Client window: %lx\n", (unsigned long int)client_win);
|
|
956 stderr_out ("Focus window: %lx\n", (unsigned long int)focus_win);
|
|
957 stderr_out ("Preedit:\n");
|
|
958 describe_XRectangle (" Area", p_area);
|
|
959 describe_XRectangle (" Area needed", p_needed);
|
|
960 stderr_out (" foreground: %lx\n", (unsigned long int)p_fg);
|
|
961 stderr_out (" background: %lx\n", (unsigned long int)p_bg);
|
|
962 stderr_out (" fontset: "); describe_XFontSet (p_fontset);
|
|
963 stderr_out ("Status:\n");
|
|
964 describe_XRectangle (" Area", s_area);
|
|
965 describe_XRectangle (" Area needed", s_needed);
|
|
966 stderr_out (" foreground: %lx\n", (unsigned long int)s_fg);
|
|
967 stderr_out (" background: %lx\n", (unsigned long int)s_bg);
|
|
968 stderr_out (" fontset: \n"); describe_XFontSet (s_fontset);
|
|
969 stderr_out ("XNResourceName: %s\n", resourceName ? resourceName : "NULL");
|
|
970 stderr_out ("XNResourceClass: %s\n", resourceClass ? resourceClass : "NULL");
|
|
971 stderr_out ("XNFilterEvents: "); describe_event_mask (filter_mask);
|
|
972 }
|
|
973
|
|
974 void
|
|
975 describe_XRectangle (char *name, XRectangle *r)
|
|
976 {
|
|
977 if (r == NULL)
|
|
978 stderr_out ("%s: NULL\n", name);
|
|
979 else
|
|
980 stderr_out ("%s: x=%d y=%d w=%d h=%d\n",
|
|
981 name, r->x, r->y, r->width, r->height);
|
|
982 }
|
|
983
|
|
984 /* Print out elements of Event mask */
|
|
985 /* Defines from X11/X.h */
|
|
986 void
|
|
987 describe_event_mask (unsigned long mask)
|
|
988 {
|
|
989 #define DESCRIBE_EVENT_MASK(bit) if ((bit) & mask) stderr_out (#bit " ")
|
|
990 DESCRIBE_EVENT_MASK (NoEventMask);
|
|
991 DESCRIBE_EVENT_MASK (KeyPressMask);
|
|
992 DESCRIBE_EVENT_MASK (KeyReleaseMask);
|
|
993 DESCRIBE_EVENT_MASK (ButtonPressMask);
|
|
994 DESCRIBE_EVENT_MASK (ButtonReleaseMask);
|
|
995 DESCRIBE_EVENT_MASK (EnterWindowMask);
|
|
996 DESCRIBE_EVENT_MASK (LeaveWindowMask);
|
|
997 DESCRIBE_EVENT_MASK (PointerMotionMask);
|
|
998 DESCRIBE_EVENT_MASK (PointerMotionHintMask);
|
|
999 DESCRIBE_EVENT_MASK (Button1MotionMask);
|
|
1000 DESCRIBE_EVENT_MASK (Button2MotionMask);
|
|
1001 DESCRIBE_EVENT_MASK (Button3MotionMask);
|
|
1002 DESCRIBE_EVENT_MASK (Button4MotionMask);
|
|
1003 DESCRIBE_EVENT_MASK (Button5MotionMask);
|
|
1004 DESCRIBE_EVENT_MASK (ButtonMotionMask);
|
|
1005 DESCRIBE_EVENT_MASK (KeymapStateMask);
|
|
1006 DESCRIBE_EVENT_MASK (ExposureMask);
|
|
1007 DESCRIBE_EVENT_MASK (VisibilityChangeMask);
|
|
1008 DESCRIBE_EVENT_MASK (StructureNotifyMask);
|
|
1009 DESCRIBE_EVENT_MASK (ResizeRedirectMask);
|
|
1010 DESCRIBE_EVENT_MASK (SubstructureNotifyMask);
|
|
1011 DESCRIBE_EVENT_MASK (SubstructureRedirectMask);
|
|
1012 DESCRIBE_EVENT_MASK (FocusChangeMask);
|
|
1013 DESCRIBE_EVENT_MASK (PropertyChangeMask);
|
|
1014 DESCRIBE_EVENT_MASK (ColormapChangeMask);
|
|
1015 DESCRIBE_EVENT_MASK (OwnerGrabButtonMask);
|
|
1016 #undef DESCRIBE_EVENT_MASK
|
|
1017 stderr_out("\n");
|
|
1018 }
|
|
1019
|
|
1020 void
|
|
1021 describe_XIMStyle (XIMStyle style)
|
|
1022 {
|
|
1023 #define DESCRIBE_STYLE(bit) \
|
|
1024 if (bit & style) \
|
|
1025 stderr_out (#bit " ");
|
|
1026
|
|
1027 DESCRIBE_STYLE (XIMPreeditArea);
|
|
1028 DESCRIBE_STYLE (XIMPreeditCallbacks);
|
|
1029 DESCRIBE_STYLE (XIMPreeditPosition);
|
|
1030 DESCRIBE_STYLE (XIMPreeditNothing);
|
|
1031 DESCRIBE_STYLE (XIMPreeditNone);
|
|
1032 DESCRIBE_STYLE (XIMStatusArea);
|
|
1033 DESCRIBE_STYLE (XIMStatusCallbacks);
|
|
1034 DESCRIBE_STYLE (XIMStatusNothing);
|
|
1035 DESCRIBE_STYLE (XIMStatusNone);
|
|
1036 #undef DESCRIBE_STYLE
|
|
1037 stderr_out("\n");
|
|
1038 }
|
|
1039
|
|
1040 void
|
|
1041 describe_XIMStyles (XIMStyles *p)
|
|
1042 {
|
|
1043 int i;
|
|
1044 stderr_out ("%d Style(s):\n", p->count_styles);
|
|
1045 for (i=0; i<p->count_styles ; i++)
|
|
1046 {
|
|
1047 describe_XIMStyle (p->supported_styles[i]);
|
|
1048 }
|
|
1049 }
|
|
1050
|
|
1051 #endif /* DEBUG_XEMACS */
|
|
1052
|
|
1053 /* Random cruft follows */
|
|
1054
|
|
1055 #if 0
|
|
1056 static void
|
|
1057 Unit_Test (struct frame *f, char * s)
|
|
1058 /* mrb unit testing */
|
|
1059 {
|
|
1060 XrmValue fromVal, toVal;
|
|
1061
|
|
1062 fromVal.addr = s;
|
|
1063 fromVal.size = strlen (s);
|
|
1064 toVal.addr = (XtPointer) &user_preferred_XIMStyles;
|
|
1065 toVal.size = sizeof (XIMStyles);
|
|
1066
|
|
1067 if (XtConvertAndStore (FRAME_X_TEXT_WIDGET (f), XtRString, &fromVal,
|
|
1068 XtRXimStyles, &toVal) != False)
|
|
1069 {
|
|
1070 stderr_out ("Unit_Test: fromVal.addr=0x%x\n",fromVal.addr);
|
|
1071 stderr_out ("Unit_Test: fromVal.size=%d\n", fromVal.size);
|
|
1072 stderr_out ("Unit_Test: toVal.addr=0x%x\n", toVal.addr);
|
|
1073 stderr_out ("Unit_Test: toVal.size=%d\n", toVal.size);
|
|
1074 describe_XIMStyles ((XIMStyles *) toVal.addr);
|
|
1075 }
|
|
1076 }
|
|
1077 #endif
|
448
|
1078 #endif /* XIM_XLIB only */
|
428
|
1079
|
|
1080 #if 0
|
|
1081 /* Get a fontset for IM to use */
|
|
1082 void
|
|
1083 x_init_fontset (struct device *d)
|
|
1084 {
|
|
1085 Display *dpy = DEVICE_X_DISPLAY (d);
|
|
1086 XFontSet fontset;
|
|
1087 char ** missing_charsets;
|
|
1088 int num_missing_charsets;
|
|
1089 char * default_string;
|
|
1090 /* char * font_set_string = "-dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*";*/
|
|
1091 char * font_set_string = "-dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*, -misc-fixed-medium-r-normal--14-130-75-75-c-70-jisx0201.1976-0,-misc-fixed-medium-r-normal--14-130-75-75-c-140-jisx0208.1983-0, -misc-fixed-medium-r-normal--14-130-75-75-c-70-jisx0201.1976-0" ;
|
|
1092
|
|
1093 DEVICE_X_FONTSET (d) = fontset =
|
|
1094 XCreateFontSet (dpy,
|
|
1095 font_set_string,
|
|
1096 &missing_charsets,
|
|
1097 &num_missing_charsets,
|
|
1098 &default_string);
|
|
1099
|
|
1100 if (fontset == NULL)
|
|
1101 {
|
|
1102 stderr_out ("Unable to create fontset from string:\n%s\n", font_set_string);
|
|
1103 return;
|
|
1104 }
|
|
1105 if (num_missing_charsets > 0)
|
|
1106 {
|
|
1107 int i;
|
|
1108 stderr_out ("\nMissing charsets for fontset %s:\n", font_set_string);
|
|
1109 for (i=0; i < num_missing_charsets; i++)
|
|
1110 {
|
|
1111 stderr_out ("%s\n", missing_charsets[i]);
|
|
1112 }
|
|
1113 XFreeStringList (missing_charsets);
|
|
1114 stderr_out ("Default string: %s\n", default_string);
|
|
1115 }
|
|
1116
|
|
1117 #ifdef DEBUG_XIM
|
|
1118 describe_XFontSet (fontset);
|
|
1119 #endif
|
|
1120 }
|
|
1121 #endif /* 0 */
|