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