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