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