Mercurial > hg > xemacs-beta
comparison src/input-method-xlib.c @ 185:3d6bfa290dbd r20-3b19
Import from CVS: tag r20-3b19
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:55:28 +0200 |
parents | 9ad43877534d |
children | 850242ba4a81 |
comparison
equal
deleted
inserted
replaced
184:bcd2674570bf | 185:3d6bfa290dbd |
---|---|
76 | 76 |
77 void | 77 void |
78 Initialize_Locale (void) | 78 Initialize_Locale (void) |
79 { | 79 { |
80 char *locale; | 80 char *locale; |
81 | 81 |
82 XtSetLanguageProc (NULL, (XtLanguageProc) NULL, NULL); | 82 XtSetLanguageProc (NULL, (XtLanguageProc) NULL, NULL); |
83 if ((locale = setlocale (LC_ALL, "")) == NULL) | 83 if ((locale = setlocale (LC_ALL, "")) == NULL) |
84 { | 84 { |
85 stderr_out ("Can't set locale.\n"); | 85 stderr_out ("Can't set locale.\n"); |
86 stderr_out ("Using C locale instead.\n"); | 86 stderr_out ("Using C locale instead.\n"); |
108 { | 108 { |
109 stderr_out ("X Windows does not even support locale `C'!\n"); | 109 stderr_out ("X Windows does not even support locale `C'!\n"); |
110 return; | 110 return; |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 if (XSetLocaleModifiers ("") == NULL) | 114 if (XSetLocaleModifiers ("") == NULL) |
115 { | 115 { |
116 stderr_out ("XSetLocaleModifiers(\"\") failed\n"); | 116 stderr_out ("XSetLocaleModifiers(\"\") failed\n"); |
117 stderr_out ("Check the value of the XMODIFIERS environment variable.\n"); | 117 stderr_out ("Check the value of the XMODIFIERS environment variable.\n"); |
118 } | 118 } |
125 Display *dpy = DEVICE_X_DISPLAY (d); | 125 Display *dpy = DEVICE_X_DISPLAY (d); |
126 char *name, *class; | 126 char *name, *class; |
127 XIM xim; | 127 XIM xim; |
128 | 128 |
129 XtGetApplicationNameAndClass (dpy, &name, &class); | 129 XtGetApplicationNameAndClass (dpy, &name, &class); |
130 | 130 |
131 DEVICE_X_XIM (d) = xim = XOpenIM (dpy, XtDatabase (dpy), name, class); | 131 DEVICE_X_XIM (d) = xim = XOpenIM (dpy, XtDatabase (dpy), name, class); |
132 | 132 |
133 if (xim == NULL) | 133 if (xim == NULL) |
134 { | 134 { |
135 stderr_out ("Warning: XOpenIM() failed...no input server available\n"); | 135 stderr_out ("Warning: XOpenIM() failed...no input server available\n"); |
136 return; | 136 return; |
137 } | 137 } |
166 Pixel fg; | 166 Pixel fg; |
167 Pixel bg; | 167 Pixel bg; |
168 } xic_vars_t; | 168 } xic_vars_t; |
169 | 169 |
170 xic_vars_t xic_vars; | 170 xic_vars_t xic_vars; |
171 | 171 |
172 /* mrb: #### Fix so that background and foreground is set from | 172 /* mrb: #### Fix so that background and foreground is set from |
173 default face, rather than foreground and background resources, or | 173 default face, rather than foreground and background resources, or |
174 that the user can use set-frame-parameters to set xic attributes */ | 174 that the user can use set-frame-parameters to set xic attributes */ |
175 | 175 |
176 #define res(name, class, representation, field, default_value) \ | 176 #define res(name, class, representation, field, default_value) \ |
185 res(XtNximForeground, XtCForeground, XtRPixel, fg, XtDefaultForeground), | 185 res(XtNximForeground, XtCForeground, XtRPixel, fg, XtDefaultForeground), |
186 res(XtNximBackground, XtCBackground, XtRPixel, bg, XtDefaultBackground) | 186 res(XtNximBackground, XtCBackground, XtRPixel, bg, XtDefaultBackground) |
187 }; | 187 }; |
188 | 188 |
189 assert (win != 0 && w != NULL && d != NULL); | 189 assert (win != 0 && w != NULL && d != NULL); |
190 | 190 |
191 if (!xim) | 191 if (!xim) |
192 { /* No input method? */ | 192 { /* No input method? */ |
193 FRAME_X_XIC (f) = NULL; | 193 FRAME_X_XIC (f) = NULL; |
194 return; | 194 return; |
195 } | 195 } |
196 | 196 |
197 XtGetApplicationResources (w, &xic_vars, | 197 XtGetApplicationResources (w, &xic_vars, |
198 resources, XtNumber (resources), | 198 resources, XtNumber (resources), |
199 NULL, 0); | 199 NULL, 0); |
200 | 200 |
201 if (!xic_vars.fontset) | 201 if (!xic_vars.fontset) |
202 { | 202 { |
203 stderr_out ("Can't get fontset resource for Input Method\n"); | 203 stderr_out ("Can't get fontset resource for Input Method\n"); |
204 FRAME_X_XIC (f) = NULL; | 204 FRAME_X_XIC (f) = NULL; |
205 return; | 205 return; |
206 } | 206 } |
207 | 207 |
208 FRAME_X_XIC_STYLE (f) = style = | 208 FRAME_X_XIC_STYLE (f) = style = |
209 best_style (&xic_vars.styles, DEVICE_X_XIM_STYLES (d)); | 209 best_style (&xic_vars.styles, DEVICE_X_XIM_STYLES (d)); |
210 | 210 |
211 /* Hopefully we don't have to conditionalize the following based on | 211 /* Hopefully we don't have to conditionalize the following based on |
212 style; the IM should ignore values it doesn't use */ | 212 style; the IM should ignore values it doesn't use */ |
213 p_list = XVaCreateNestedList (0, | 213 p_list = XVaCreateNestedList (0, |
214 XNArea, &p_area, | 214 XNArea, &p_area, |
215 XNSpotLocation, &spot, | 215 XNSpotLocation, &spot, |
232 XNPreeditAttributes, p_list, | 232 XNPreeditAttributes, p_list, |
233 XNStatusAttributes, s_list, | 233 XNStatusAttributes, s_list, |
234 NULL); | 234 NULL); |
235 XFree (p_list); | 235 XFree (p_list); |
236 XFree (s_list); | 236 XFree (s_list); |
237 | 237 |
238 if (!xic) | 238 if (!xic) |
239 { | 239 { |
240 stderr_out ("Warning: XCreateIC failed\n"); | 240 stderr_out ("Warning: XCreateIC failed\n"); |
241 return; | 241 return; |
242 } | 242 } |
246 XPoint *spot = &(FRAME_X_XIC_SPOT (f)); | 246 XPoint *spot = &(FRAME_X_XIC_SPOT (f)); |
247 spot->x = spot->y = -1; | 247 spot->x = spot->y = -1; |
248 } | 248 } |
249 | 249 |
250 XIM_SetGeometry (f); | 250 XIM_SetGeometry (f); |
251 | 251 |
252 XSetICFocus (xic); | 252 XSetICFocus (xic); |
253 | 253 |
254 #ifdef DEBUG_XIM | 254 #ifdef DEBUG_XIM |
255 describe_XIC (xic); | 255 describe_XIC (xic); |
256 #endif | 256 #endif |
260 XIM_SetGeometry (struct frame *f) | 260 XIM_SetGeometry (struct frame *f) |
261 { | 261 { |
262 XIC xic = FRAME_X_XIC (f); | 262 XIC xic = FRAME_X_XIC (f); |
263 XIMStyle style = FRAME_X_XIC_STYLE (f); | 263 XIMStyle style = FRAME_X_XIC_STYLE (f); |
264 XRectangle area; | 264 XRectangle area; |
265 | 265 |
266 if (!xic || !f) | 266 if (!xic || !f) |
267 return; | 267 return; |
268 | 268 |
269 if (style & XIMStatusArea) | 269 if (style & XIMStatusArea) |
270 { | 270 { |
271 /* Place Status Area in bottom right corner */ | 271 /* Place Status Area in bottom right corner */ |
272 /* Negotiate geometry of status area */ | 272 /* Negotiate geometry of status area */ |
273 /* See O'Reilly Xlib XIM chapter (but beware, it's buggy) */ | 273 /* See O'Reilly Xlib XIM chapter (but beware, it's buggy) */ |
274 XRectangle *needed; | 274 XRectangle *needed; |
275 | 275 |
276 /* If input method has existing status area, use its current size */ | 276 /* If input method has existing status area, use its current size */ |
277 /* The following at least works for Sun's htt */ | 277 /* The following at least works for Sun's htt */ |
278 area.x = area.y = area.width = area.height = 0; | 278 area.x = area.y = area.width = area.height = 0; |
279 XIC_Value (Set, xic, XNStatusAttributes, XNAreaNeeded, &area); | 279 XIC_Value (Set, xic, XNStatusAttributes, XNAreaNeeded, &area); |
280 XIC_Value (Get, xic, XNStatusAttributes, XNAreaNeeded, &needed); | 280 XIC_Value (Get, xic, XNStatusAttributes, XNAreaNeeded, &needed); |
281 if (needed->width == 0) /* Use XNArea instead of XNAreaNeeded */ | 281 if (needed->width == 0) /* Use XNArea instead of XNAreaNeeded */ |
282 XIC_Value (Get, xic, XNStatusAttributes, XNArea, &needed); | 282 XIC_Value (Get, xic, XNStatusAttributes, XNArea, &needed); |
283 | 283 |
284 area.width = needed->width; | 284 area.width = needed->width; |
285 area.height = needed->height; | 285 area.height = needed->height; |
286 area.x = FRAME_RIGHT_BORDER_START (f) - area.width; | 286 area.x = FRAME_RIGHT_BORDER_START (f) - area.width; |
287 area.y = FRAME_BOTTOM_BORDER_START (f) - area.height; | 287 area.y = FRAME_BOTTOM_BORDER_START (f) - area.height; |
288 | 288 |
289 #ifdef DEBUG_XIM | 289 #ifdef DEBUG_XIM |
290 stderr_out ("Putting StatusArea in x=%d y=%d w=%d h=%d\n", | 290 stderr_out ("Putting StatusArea in x=%d y=%d w=%d h=%d\n", |
291 area.x, area.y, area.width, area.height); | 291 area.x, area.y, area.width, area.height); |
292 #endif /* DEBUG_XIM */ | 292 #endif /* DEBUG_XIM */ |
293 | 293 |
294 XIC_Value (Set, xic, XNStatusAttributes, XNArea, &area); | 294 XIC_Value (Set, xic, XNStatusAttributes, XNArea, &area); |
295 } | 295 } |
296 | 296 |
297 if (style & XIMPreeditPosition) | 297 if (style & XIMPreeditPosition) |
298 { | 298 { |
304 area.y = FRAME_TOP_BORDER_START (f); | 304 area.y = FRAME_TOP_BORDER_START (f); |
305 area.width = FRAME_RIGHT_BORDER_END (f) - area.x; | 305 area.width = FRAME_RIGHT_BORDER_END (f) - area.x; |
306 area.height = FRAME_BOTTOM_BORDER_END (f) - area.y; | 306 area.height = FRAME_BOTTOM_BORDER_END (f) - area.y; |
307 XIC_Value(Set, xic, XNPreeditAttributes, XNArea, &area); | 307 XIC_Value(Set, xic, XNPreeditAttributes, XNArea, &area); |
308 } | 308 } |
309 | 309 |
310 #ifdef DEBUG_XIM | 310 #ifdef DEBUG_XIM |
311 describe_XIC (xic); | 311 describe_XIC (xic); |
312 #endif | 312 #endif |
313 } | 313 } |
314 | 314 |
323 if (!xic || | 323 if (!xic || |
324 !(FRAME_X_XIC_STYLE (f) & XIMPreeditPosition) || | 324 !(FRAME_X_XIC_STYLE (f) & XIMPreeditPosition) || |
325 (spot->x == (short) x && | 325 (spot->x == (short) x && |
326 spot->y == (short) y)) | 326 spot->y == (short) y)) |
327 return; | 327 return; |
328 | 328 |
329 spot->x = (short) x; | 329 spot->x = (short) x; |
330 spot->y = (short) y; | 330 spot->y = (short) y; |
331 | 331 |
332 /* ### FIX: Must make sure spot fits within Preedit Area */ | 332 /* ### FIX: Must make sure spot fits within Preedit Area */ |
333 XIC_Value (Set, xic, XNPreeditAttributes, XNSpotLocation, spot); | 333 XIC_Value (Set, xic, XNPreeditAttributes, XNSpotLocation, spot); |
375 KeySym keysym; | 375 KeySym keysym; |
376 Status status; | 376 Status status; |
377 int len; | 377 int len; |
378 int i; | 378 int i; |
379 XClientMessageEvent new_event; | 379 XClientMessageEvent new_event; |
380 | 380 |
381 try_again: | 381 try_again: |
382 len = XwcLookupString (ic, x_key_event, composed_input_buf.data, | 382 len = XwcLookupString (ic, x_key_event, composed_input_buf.data, |
383 composed_input_buf.size, &keysym, &status); | 383 composed_input_buf.size, &keysym, &status); |
384 switch (status) | 384 switch (status) |
385 { | 385 { |
389 case XLookupChars: | 389 case XLookupChars: |
390 break; | 390 break; |
391 default: | 391 default: |
392 abort (); | 392 abort (); |
393 } | 393 } |
394 | 394 |
395 new_event.type = ClientMessage; | 395 new_event.type = ClientMessage; |
396 new_event.display = x_key_event->display; | 396 new_event.display = x_key_event->display; |
397 new_event.window = x_key_event->window; | 397 new_event.window = x_key_event->window; |
398 new_event.message_type = wc_atom; | 398 new_event.message_type = wc_atom; |
399 new_event.format = 32; /* 32-bit wide data */ | 399 new_event.format = 32; /* 32-bit wide data */ |
470 STYLE_INFO (XIMPreeditNone|XIMStatusArea), | 470 STYLE_INFO (XIMPreeditNone|XIMStatusArea), |
471 STYLE_INFO (XIMPreeditNone|XIMStatusNothing), | 471 STYLE_INFO (XIMPreeditNone|XIMStatusNothing), |
472 STYLE_INFO (XIMPreeditNone|XIMStatusNone) | 472 STYLE_INFO (XIMPreeditNone|XIMStatusNone) |
473 }; | 473 }; |
474 #undef STYLE_INFO | 474 #undef STYLE_INFO |
475 | 475 |
476 CONST char *s = (char *) fromVal->addr; | 476 CONST char *s = (char *) fromVal->addr; |
477 CONST char *end = s + fromVal->size; | 477 CONST char *end = s + fromVal->size; |
478 XIMStyles * CONST p = (XIMStyles *) toVal->addr; | 478 XIMStyles * CONST p = (XIMStyles *) toVal->addr; |
479 CONST char * CONST delimiter = " \t\n\r:;," ; | 479 CONST char * CONST delimiter = " \t\n\r:;," ; |
480 CONST int max_styles = XtNumber(emacs_XIMStyleInfo); | 480 CONST int max_styles = XtNumber(emacs_XIMStyleInfo); |
483 | 483 |
484 #ifdef DEBUG_XIM | 484 #ifdef DEBUG_XIM |
485 stderr_out ("EmacsCvtStringToXIMStyles called with size=%d, string=\"%s\"\n", | 485 stderr_out ("EmacsCvtStringToXIMStyles called with size=%d, string=\"%s\"\n", |
486 fromVal->size, (char *) fromVal->addr); | 486 fromVal->size, (char *) fromVal->addr); |
487 #endif /* DEBUG_XIM */ | 487 #endif /* DEBUG_XIM */ |
488 | 488 |
489 if (*num_args != 0) | 489 if (*num_args != 0) |
490 { | 490 { |
491 XtAppContext the_app_con = XtDisplayToApplicationContext (dpy); | 491 XtAppContext the_app_con = XtDisplayToApplicationContext (dpy); |
492 XtAppWarningMsg(the_app_con, "wrongParameters", "cvtStringToXIMStyle", | 492 XtAppWarningMsg(the_app_con, "wrongParameters", "cvtStringToXIMStyle", |
493 "XtToolkitError", | 493 "XtToolkitError", |
503 assert (toVal->addr != NULL); | 503 assert (toVal->addr != NULL); |
504 assert (toVal->size == sizeof(XIMStyles)); | 504 assert (toVal->size == sizeof(XIMStyles)); |
505 #endif /* DEBUG_XEMACS */ | 505 #endif /* DEBUG_XEMACS */ |
506 | 506 |
507 p->count_styles = 0; | 507 p->count_styles = 0; |
508 p->supported_styles = xmalloc (max_styles * sizeof (XIMStyle)); | 508 p->supported_styles = xnew_array (XIMStyle, max_styles); |
509 | 509 |
510 /* | 510 /* |
511 * The following routine assumes that the style name resource is | 511 * The following routine assumes that the style name resource is |
512 * identical with the programmatic name of style. For example, | 512 * identical with the programmatic name of style. For example, |
513 * "XIMPreeditPosition|XIMStatusArea" means the | 513 * "XIMPreeditPosition|XIMStatusArea" means the |
515 * style name is changed, such as "OverTheSpot|imDisplaysInClient", | 515 * style name is changed, such as "OverTheSpot|imDisplaysInClient", |
516 * the parsing logic below should be modified as well. */ | 516 * the parsing logic below should be modified as well. */ |
517 | 517 |
518 if ((c = strtok(s, delimiter)) == NULL) | 518 if ((c = strtok(s, delimiter)) == NULL) |
519 c = end; | 519 c = end; |
520 | 520 |
521 while (c < end) | 521 while (c < end) |
522 { | 522 { |
523 for(i=0 ; i<max_styles ; i++) | 523 for(i=0 ; i<max_styles ; i++) |
524 { | 524 { |
525 struct XIMStyleInfo *rec = emacs_XIMStyleInfo + i; | 525 struct XIMStyleInfo *rec = emacs_XIMStyleInfo + i; |
531 } | 531 } |
532 if((c = strtok(NULL, delimiter)) == NULL) { | 532 if((c = strtok(NULL, delimiter)) == NULL) { |
533 break ; | 533 break ; |
534 } | 534 } |
535 } | 535 } |
536 | 536 |
537 if (p->count_styles == 0) | 537 if (p->count_styles == 0) |
538 { /* No valid styles? */ | 538 { /* No valid styles? */ |
539 char buf[1024]; | 539 char buf[1024]; |
540 XrmValue new_from; | 540 XrmValue new_from; |
541 XtAppContext the_app_con = XtDisplayToApplicationContext (dpy); | 541 XtAppContext the_app_con = XtDisplayToApplicationContext (dpy); |
542 | 542 |
543 sprintf(buf, "Cannot convert string \"%s\" to type XIMStyles.\n" | 543 sprintf(buf, "Cannot convert string \"%s\" to type XIMStyles.\n" |
544 "Using default string \"%s\" instead.\n", | 544 "Using default string \"%s\" instead.\n", |
545 fromVal->addr, DefaultXIMStyles); | 545 fromVal->addr, DefaultXIMStyles); |
546 XtAppWarningMsg(the_app_con, "wrongParameters", "cvtStringToXIMStyle", | 546 XtAppWarningMsg(the_app_con, "wrongParameters", "cvtStringToXIMStyle", |
547 "XtToolkitError", | 547 "XtToolkitError", |
549 new_from.addr = DefaultXIMStyles; | 549 new_from.addr = DefaultXIMStyles; |
550 new_from.size = sizeof(DefaultXIMStyles); | 550 new_from.size = sizeof(DefaultXIMStyles); |
551 return EmacsXtCvtStringToXIMStyles (dpy, args, num_args, | 551 return EmacsXtCvtStringToXIMStyles (dpy, args, num_args, |
552 &new_from, toVal, converter_data); | 552 &new_from, toVal, converter_data); |
553 } | 553 } |
554 p->supported_styles = xrealloc (p->supported_styles, | 554 XREALLOC_ARRAY (p->supported_styles, XIMStyle, p->count_styles); |
555 p->count_styles * sizeof(XIMStyle)); | |
556 *converter_data = (char *) True; | 555 *converter_data = (char *) True; |
557 return True; | 556 return True; |
558 } | 557 } |
559 | 558 |
560 /* XtDestructor */ | 559 /* XtDestructor */ |
568 { | 567 { |
569 #ifdef DEBUG_XIM | 568 #ifdef DEBUG_XIM |
570 stderr_out ("Converter data: %x\n", converter_data); | 569 stderr_out ("Converter data: %x\n", converter_data); |
571 stderr_out ("EmacsFreeXIMStyles called\n"); | 570 stderr_out ("EmacsFreeXIMStyles called\n"); |
572 #endif /* DEBUG_XIM */ | 571 #endif /* DEBUG_XIM */ |
573 | 572 |
574 if (*num_args != 0) | 573 if (*num_args != 0) |
575 { | 574 { |
576 XtAppWarningMsg(app, "wrongParameters","freeXIMStyles","XtToolkitError", | 575 XtAppWarningMsg(app, "wrongParameters","freeXIMStyles","XtToolkitError", |
577 "Freeing an XIMStyles requires that zero arguments be passwd", | 576 "Freeing an XIMStyles requires that zero arguments be passwd", |
578 (String *)NULL, (Cardinal *)NULL); | 577 (String *)NULL, (Cardinal *)NULL); |
579 return; | 578 return; |
580 } | 579 } |
581 | 580 |
582 if (converter_data) | 581 if (converter_data) |
583 { | 582 { |
584 Boolean free_p = (Boolean) (int) converter_data; | 583 Boolean free_p = (Boolean) (int) converter_data; |
585 XIMStyles *styles = (XIMStyles *) toVal->addr; | 584 XIMStyles *styles = (XIMStyles *) toVal->addr; |
586 if (free_p) | 585 if (free_p) |
595 static XIMStyle | 594 static XIMStyle |
596 BetterStyle (XIMStyle s, XIMStyle t) | 595 BetterStyle (XIMStyle s, XIMStyle t) |
597 { | 596 { |
598 #define CHECK_XIMStyle_BIT(bit) \ | 597 #define CHECK_XIMStyle_BIT(bit) \ |
599 if ((s ^ t) & bit) { return (s & bit) ? s : t; } | 598 if ((s ^ t) & bit) { return (s & bit) ? s : t; } |
600 | 599 |
601 CHECK_XIMStyle_BIT (XIMPreeditCallbacks); | 600 CHECK_XIMStyle_BIT (XIMPreeditCallbacks); |
602 CHECK_XIMStyle_BIT (XIMPreeditPosition); | 601 CHECK_XIMStyle_BIT (XIMPreeditPosition); |
603 CHECK_XIMStyle_BIT (XIMPreeditArea); | 602 CHECK_XIMStyle_BIT (XIMPreeditArea); |
604 CHECK_XIMStyle_BIT (XIMPreeditNothing); | 603 CHECK_XIMStyle_BIT (XIMPreeditNothing); |
605 CHECK_XIMStyle_BIT (XIMStatusCallbacks); | 604 CHECK_XIMStyle_BIT (XIMStatusCallbacks); |
676 if (fontset == NULL) | 675 if (fontset == NULL) |
677 { | 676 { |
678 stderr_out ("NULL\n"); | 677 stderr_out ("NULL\n"); |
679 return; | 678 return; |
680 } | 679 } |
681 | 680 |
682 count = XFontsOfFontSet (fontset, &font_struct_list, &font_name_list); | 681 count = XFontsOfFontSet (fontset, &font_struct_list, &font_name_list); |
683 stderr_out ( "%d font(s) available:\n", count); | 682 stderr_out ( "%d font(s) available:\n", count); |
684 for (i=0 ; i < count ; i++) | 683 for (i=0 ; i < count ; i++) |
685 stderr_out ("Font: %s\n", *(font_name_list+i)); | 684 stderr_out ("Font: %s\n", *(font_name_list+i)); |
686 } | 685 } |
688 void | 687 void |
689 describe_Status (Status status) | 688 describe_Status (Status status) |
690 { | 689 { |
691 #define DESCRIBE_STATUS(value) \ | 690 #define DESCRIBE_STATUS(value) \ |
692 if (status == value) stderr_out ("Status: " #value "\n") | 691 if (status == value) stderr_out ("Status: " #value "\n") |
693 | 692 |
694 DESCRIBE_STATUS (XBufferOverflow); | 693 DESCRIBE_STATUS (XBufferOverflow); |
695 DESCRIBE_STATUS (XLookupNone); | 694 DESCRIBE_STATUS (XLookupNone); |
696 DESCRIBE_STATUS (XLookupKeySym); | 695 DESCRIBE_STATUS (XLookupKeySym); |
697 DESCRIBE_STATUS (XLookupBoth); | 696 DESCRIBE_STATUS (XLookupBoth); |
698 DESCRIBE_STATUS (XLookupChars); | 697 DESCRIBE_STATUS (XLookupChars); |
699 #undef DESCRIBE_STATUS | 698 #undef DESCRIBE_STATUS |
700 } | 699 } |
701 | 700 |
702 void | 701 void |
703 describe_Window (Window win) | 702 describe_Window (Window win) |
704 { | 703 { |
705 char xwincmd[64]; | 704 char xwincmd[64]; |
706 sprintf (xwincmd, "xwininfo -id 0x%x >&2; xwininfo -events -id 0x%x >&2", | 705 sprintf (xwincmd, "xwininfo -id 0x%x >&2; xwininfo -events -id 0x%x >&2", |
707 (int) win, (int) win); | 706 (int) win, (int) win); |
708 system (xwincmd); | 707 system (xwincmd); |
725 XPoint *p_spot = NULL; | 724 XPoint *p_spot = NULL; |
726 | 725 |
727 /* Check for valid input context and method */ | 726 /* Check for valid input context and method */ |
728 if (!xic) | 727 if (!xic) |
729 stderr_out ("Input method is NULL\n"); | 728 stderr_out ("Input method is NULL\n"); |
730 | 729 |
731 if (!XIMOfIC(xic)) | 730 if (!XIMOfIC(xic)) |
732 stderr_out ("XIMOfIC() returns NULL\n"); | 731 stderr_out ("XIMOfIC() returns NULL\n"); |
733 | 732 |
734 /* Print out Input Context Attributes */ | 733 /* Print out Input Context Attributes */ |
735 p_list = XVaCreateNestedList (0, | 734 p_list = XVaCreateNestedList (0, |
736 XNFontSet, &p_fontset, | 735 XNFontSet, &p_fontset, |
737 XNArea, &p_area, | 736 XNArea, &p_area, |
738 XNAreaNeeded, &p_needed, | 737 XNAreaNeeded, &p_needed, |
746 XNArea, &s_area, | 745 XNArea, &s_area, |
747 XNAreaNeeded, &s_needed, | 746 XNAreaNeeded, &s_needed, |
748 XNForeground, &s_fg, | 747 XNForeground, &s_fg, |
749 XNBackground, &s_bg, | 748 XNBackground, &s_bg, |
750 NULL); | 749 NULL); |
751 | 750 |
752 bad_arg = XGetICValues(xic, | 751 bad_arg = XGetICValues(xic, |
753 XNInputStyle, &style, | 752 XNInputStyle, &style, |
754 XNFilterEvents, &filter_mask, | 753 XNFilterEvents, &filter_mask, |
755 XNClientWindow, &client_win, | 754 XNClientWindow, &client_win, |
756 XNFocusWindow, &focus_win, | 755 XNFocusWindow, &focus_win, |
759 XNPreeditAttributes, p_list, | 758 XNPreeditAttributes, p_list, |
760 XNStatusAttributes, s_list, | 759 XNStatusAttributes, s_list, |
761 NULL); | 760 NULL); |
762 XFree(p_list); | 761 XFree(p_list); |
763 XFree(s_list); | 762 XFree(s_list); |
764 | 763 |
765 if (bad_arg != NULL) | 764 if (bad_arg != NULL) |
766 stderr_out ("Couldn't get IC value: %s\n", bad_arg); | 765 stderr_out ("Couldn't get IC value: %s\n", bad_arg); |
767 | 766 |
768 stderr_out ("\nInput method context attributes:\n"); | 767 stderr_out ("\nInput method context attributes:\n"); |
769 stderr_out ("Style: "); describe_XIMStyle (style); | 768 stderr_out ("Style: "); describe_XIMStyle (style); |
770 stderr_out ("Client window: %x\n", client_win); | 769 stderr_out ("Client window: %x\n", client_win); |
771 stderr_out ("Focus window: %x\n", focus_win); | 770 stderr_out ("Focus window: %x\n", focus_win); |
772 stderr_out ("Preedit:\n"); | 771 stderr_out ("Preedit:\n"); |
836 describe_XIMStyle (XIMStyle style) | 835 describe_XIMStyle (XIMStyle style) |
837 { | 836 { |
838 #define DESCRIBE_STYLE(bit) \ | 837 #define DESCRIBE_STYLE(bit) \ |
839 if (bit & style) \ | 838 if (bit & style) \ |
840 stderr_out (#bit " "); | 839 stderr_out (#bit " "); |
841 | 840 |
842 DESCRIBE_STYLE (XIMPreeditArea); | 841 DESCRIBE_STYLE (XIMPreeditArea); |
843 DESCRIBE_STYLE (XIMPreeditCallbacks); | 842 DESCRIBE_STYLE (XIMPreeditCallbacks); |
844 DESCRIBE_STYLE (XIMPreeditPosition); | 843 DESCRIBE_STYLE (XIMPreeditPosition); |
845 DESCRIBE_STYLE (XIMPreeditNothing); | 844 DESCRIBE_STYLE (XIMPreeditNothing); |
846 DESCRIBE_STYLE (XIMPreeditNone); | 845 DESCRIBE_STYLE (XIMPreeditNone); |
876 | 875 |
877 fromVal.addr = s; | 876 fromVal.addr = s; |
878 fromVal.size = strlen (s); | 877 fromVal.size = strlen (s); |
879 toVal.addr = (XtPointer) &user_preferred_XIMStyles; | 878 toVal.addr = (XtPointer) &user_preferred_XIMStyles; |
880 toVal.size = sizeof (XIMStyles); | 879 toVal.size = sizeof (XIMStyles); |
881 | 880 |
882 if (XtConvertAndStore (FRAME_X_TEXT_WIDGET (f), XtRString, &fromVal, | 881 if (XtConvertAndStore (FRAME_X_TEXT_WIDGET (f), XtRString, &fromVal, |
883 XtRXimStyles, &toVal) != False) | 882 XtRXimStyles, &toVal) != False) |
884 { | 883 { |
885 stderr_out ("Unit_Test: fromVal.addr=0x%x\n",fromVal.addr); | 884 stderr_out ("Unit_Test: fromVal.addr=0x%x\n",fromVal.addr); |
886 stderr_out ("Unit_Test: fromVal.size=%d\n", fromVal.size); | 885 stderr_out ("Unit_Test: fromVal.size=%d\n", fromVal.size); |
901 char ** missing_charsets; | 900 char ** missing_charsets; |
902 int num_missing_charsets; | 901 int num_missing_charsets; |
903 char * default_string; | 902 char * default_string; |
904 /* char * font_set_string = "-dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*";*/ | 903 /* char * font_set_string = "-dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*";*/ |
905 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" ; | 904 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" ; |
906 | 905 |
907 DEVICE_X_FONTSET (d) = fontset = | 906 DEVICE_X_FONTSET (d) = fontset = |
908 XCreateFontSet (dpy, | 907 XCreateFontSet (dpy, |
909 font_set_string, | 908 font_set_string, |
910 &missing_charsets, | 909 &missing_charsets, |
911 &num_missing_charsets, | 910 &num_missing_charsets, |
925 stderr_out ("%s\n", missing_charsets[i]); | 924 stderr_out ("%s\n", missing_charsets[i]); |
926 } | 925 } |
927 XFreeStringList (missing_charsets); | 926 XFreeStringList (missing_charsets); |
928 stderr_out ("Default string: %s\n", default_string); | 927 stderr_out ("Default string: %s\n", default_string); |
929 } | 928 } |
930 | 929 |
931 #ifdef DEBUG_XIM | 930 #ifdef DEBUG_XIM |
932 describe_XFontSet (fontset); | 931 describe_XFontSet (fontset); |
933 #endif | 932 #endif |
934 } | 933 } |
935 #endif /* 0 */ | 934 #endif /* 0 */ |