imRm.c revision 61b2299d
1/* $Xorg: imRm.c,v 1.4 2000/08/17 19:45:14 cpqbld Exp $ */ 2/****************************************************************** 3 4 Copyright 1990, 1991, 1992,1993, 1994 by FUJITSU LIMITED 5 Copyright 1994 by Sony Corporation 6 7Permission to use, copy, modify, distribute, and sell this software 8and its documentation for any purpose is hereby granted without fee, 9provided that the above copyright notice appear in all copies and 10that both that copyright notice and this permission notice appear 11in supporting documentation, and that the name of FUJITSU LIMITED 12and Sony Corporation not be used in advertising or publicity 13pertaining to distribution of the software without specific, 14written prior permission. FUJITSU LIMITED and Sony Corporation make 15no representations about the suitability of this software for any 16purpose. It is provided "as is" without express or implied warranty. 17 18FUJITSU LIMITED AND SONY CORPORATION DISCLAIM ALL WARRANTIES WITH 19REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF 20MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJITSU LIMITED AND 21SONY CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 22DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 23PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 24TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 25PERFORMANCE OF THIS SOFTWARE. 26 27 Author: Takashi Fujiwara FUJITSU LIMITED 28 fujiwara@a80.tech.yk.fujitsu.co.jp 29 Modifier: Makoto Wakamatsu Sony Corporation 30 makoto@sm.sony.co.jp 31 32******************************************************************/ 33/* $XFree86: xc/lib/X11/imRm.c,v 3.12 2003/04/13 19:22:21 dawes Exp $ */ 34 35#ifdef HAVE_CONFIG_H 36#include <config.h> 37#endif 38#include <stdio.h> 39#include <X11/Xlib.h> 40#include "Xlibint.h" 41#include "Xlcint.h" 42#include "Ximint.h" 43#include "Xresource.h" 44 45#define GET_NAME(x) name_table + x.name_offset 46 47typedef struct _XimValueOffsetInfo { 48 unsigned short name_offset; 49 XrmQuark quark; 50 unsigned int offset; 51 Bool (*defaults)( 52 struct _XimValueOffsetInfo *, XPointer, XPointer, unsigned long 53 ); 54 Bool (*encode)( 55 struct _XimValueOffsetInfo *, XPointer, XPointer 56 ); 57 Bool (*decode)( 58 struct _XimValueOffsetInfo *, XPointer, XPointer 59 ); 60} XimValueOffsetInfoRec, *XimValueOffsetInfo; 61 62#ifdef XIM_CONNECTABLE 63Private Bool 64_XimCheckBool(str) 65 char *str; 66{ 67 if(!strcmp(str, "True") || !strcmp(str, "true") || 68 !strcmp(str, "Yes") || !strcmp(str, "yes") || 69 !strcmp(str, "ON") || !strcmp(str, "on")) 70 return True; 71 return False; 72} 73 74Public void 75_XimSetProtoResource(im) 76 Xim im; 77{ 78 char res_name_buf[256]; 79 char* res_name; 80 char res_class_buf[256]; 81 char* res_class; 82 char* str_type; 83 XrmValue value; 84 XIMStyle preedit_style = 0; 85 XIMStyle status_style = 0; 86 XIMStyles* imstyles; 87 char* dotximdot = ".xim."; 88 char* ximdot = "xim."; 89 char* dotXimdot = ".Xim."; 90 char* Ximdot = "Xim."; 91 92 if (!im->core.rdb) 93 return; 94 95 if (strlen (im->core.res_name) < 200) res_name = res_name_buf; 96 else res_name = Xmalloc (strlen (im->core.res_name) + 50); 97 if (strlen (im->core.res_class) < 200) res_class = res_class_buf; 98 else res_class = Xmalloc (strlen (im->core.res_class) + 50); 99 /* pretend malloc always works */ 100 101 (void) sprintf (res_name, "%s%s%s", 102 im->core.res_name != NULL ? im->core.res_name : "*", 103 im->core.res_name != NULL ? dotximdot : ximdot, 104 "useAuth"); 105 (void) sprintf (res_class, "%s%s%s", 106 im->core.res_class != NULL ? im->core.res_class : "*", 107 im->core.res_class != NULL ? dotXimdot : Ximdot, 108 "UseAuth"); 109 bzero(&value, sizeof(XrmValue)); 110 if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) { 111 if(_XimCheckBool(value.addr)) { 112 MARK_USE_AUTHORIZATION_FUNC(im); 113 } 114 } 115 116 (void) sprintf (res_name, "%s%s%s", 117 im->core.res_name != NULL ? im->core.res_name : "*", 118 im->core.res_name != NULL ? dotximdot : ximdot, 119 "delaybinding"); 120 (void) sprintf (res_class, "%s%s%s", 121 im->core.res_class != NULL ? im->core.res_class : "*", 122 im->core.res_class != NULL ? dotXimdot : Ximdot, 123 "Delaybinding"); 124 bzero(&value, sizeof(XrmValue)); 125 if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) { 126 if(_XimCheckBool(value.addr)) { 127 MARK_DELAYBINDABLE(im); 128 } 129 } 130 131 (void) sprintf (res_name, "%s%s%s", 132 im->core.res_name != NULL ? im->core.res_name : "*", 133 im->core.res_name != NULL ? dotximdot : ximdot, 134 "reconnect"); 135 (void) sprintf (res_class, "%s%s%s", 136 im->core.res_class != NULL ? im->core.res_class : "*", 137 im->core.res_class != NULL ? dotXimdot : Ximdot, 138 "Reconnect"); 139 bzero(&value, sizeof(XrmValue)); 140 if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) { 141 if(_XimCheckBool(value.addr)) { 142 MARK_RECONNECTABLE(im); 143 } 144 } 145 146 if(!IS_CONNECTABLE(im)) { 147 if (res_name != res_name_buf) Xfree (res_name); 148 if (res_class != res_class_buf) Xfree (res_class); 149 return; 150 } 151 152 (void) sprintf (res_name, "%s%s%s", 153 im->core.res_name != NULL ? im->core.res_name : "*", 154 im->core.res_name != NULL ? dotximdot : ximdot, 155 "preeditDefaultStyle"); 156 (void) sprintf (res_class, "%s%s%s", 157 im->core.res_class != NULL ? im->core.res_class : "*", 158 im->core.res_class != NULL ? dotXimdot : Ximdot, 159 "PreeditDefaultStyle"); 160 if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) { 161 if(!strcmp(value.addr, "XIMPreeditArea")) 162 preedit_style = XIMPreeditArea; 163 else if(!strcmp(value.addr, "XIMPreeditCallbacks")) 164 preedit_style = XIMPreeditCallbacks; 165 else if(!strcmp(value.addr, "XIMPreeditPosition")) 166 preedit_style = XIMPreeditPosition; 167 else if(!strcmp(value.addr, "XIMPreeditNothing")) 168 preedit_style = XIMPreeditNothing; 169 else if(!strcmp(value.addr, "XIMPreeditNone")) 170 preedit_style = XIMPreeditNone; 171 } 172 if(!preedit_style) 173 preedit_style = XIMPreeditNothing; 174 175 (void) sprintf (res_name, "%s%s%s", 176 im->core.res_name != NULL ? im->core.res_name : "*", 177 im->core.res_name != NULL ? dotximdot : ximdot, 178 "statusDefaultStyle"); 179 (void) sprintf (res_class, "%s%s%s", 180 im->core.res_class != NULL ? im->core.res_class : "*", 181 im->core.res_class != NULL ? dotXimdot : Ximdot, 182 "StatusDefaultStyle"); 183 if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) { 184 if(!strcmp(value.addr, "XIMStatusArea")) 185 status_style = XIMStatusArea; 186 else if(!strcmp(value.addr, "XIMStatusCallbacks")) 187 status_style = XIMStatusCallbacks; 188 else if(!strcmp(value.addr, "XIMStatusNothing")) 189 status_style = XIMStatusNothing; 190 else if(!strcmp(value.addr, "XIMStatusNone")) 191 status_style = XIMStatusNone; 192 } 193 if(!status_style) 194 status_style = XIMStatusNothing; 195 196 if(!(imstyles = (XIMStyles *)Xmalloc(sizeof(XIMStyles) + sizeof(XIMStyle)))){ 197 if (res_name != res_name_buf) Xfree (res_name); 198 if (res_class != res_class_buf) Xfree (res_class); 199 return; 200 } 201 imstyles->count_styles = 1; 202 imstyles->supported_styles = 203 (XIMStyle *)((char *)imstyles + sizeof(XIMStyles)); 204 imstyles->supported_styles[0] = preedit_style | status_style; 205 im->private.proto.default_styles = imstyles; 206 if (res_name != res_name_buf) Xfree (res_name); 207 if (res_class != res_class_buf) Xfree (res_class); 208} 209#endif /* XIM_CONNECTABLE */ 210 211static const char name_table[] = 212 /* 0 */ XNQueryInputStyle"\0" 213 /* 16 */ XNClientWindow"\0" 214 /* 29 */ XNInputStyle"\0" 215 /* 40 */ XNFocusWindow"\0" 216 /* 52 */ XNResourceName"\0" 217 /* 65 */ XNResourceClass"\0" 218 /* 79 */ XNGeometryCallback"\0" 219 /* 96 */ XNDestroyCallback"\0" 220 /* 112 */ XNFilterEvents"\0" 221 /* 125 */ XNPreeditStartCallback"\0" 222 /* 146 */ XNPreeditDoneCallback"\0" 223 /* 166 */ XNPreeditDrawCallback"\0" 224 /* 186 */ XNPreeditCaretCallback"\0" 225 /* 207 */ XNPreeditStateNotifyCallback"\0" 226 /* 234 */ XNPreeditAttributes"\0" 227 /* 252 */ XNStatusStartCallback"\0" 228 /* 272 */ XNStatusDoneCallback"\0" 229 /* 291 */ XNStatusDrawCallback"\0" 230 /* 310 */ XNStatusAttributes"\0" 231 /* 327 */ XNArea"\0" 232 /* 332 */ XNAreaNeeded"\0" 233 /* 343 */ XNSpotLocation"\0" 234 /* 356 */ XNColormap"\0" 235 /* 365 */ XNStdColormap"\0" 236 /* 377 */ XNForeground"\0" 237 /* 388 */ XNBackground"\0" 238 /* 399 */ XNBackgroundPixmap"\0" 239 /* 416 */ XNFontSet"\0" 240 /* 424 */ XNLineSpace"\0" 241 /* 434 */ XNCursor"\0" 242 /* 441 */ XNQueryIMValuesList"\0" 243 /* 459 */ XNQueryICValuesList"\0" 244 /* 477 */ XNVisiblePosition"\0" 245 /* 493 */ XNStringConversionCallback"\0" 246 /* 518 */ XNStringConversion"\0" 247 /* 535 */ XNResetState"\0" 248 /* 546 */ XNHotKey"\0" 249 /* 553 */ XNHotKeyState"\0" 250 /* 565 */ XNPreeditState 251; 252 253#define OFFSET_XNQUERYINPUTSTYLE 0 254#define OFFSET_XNCLIENTWINDOW 16 255#define OFFSET_XNINPUTSTYLE 29 256#define OFFSET_XNFOCUSWINDOW 40 257#define OFFSET_XNRESOURCENAME 52 258#define OFFSET_XNRESOURCECLASS 65 259#define OFFSET_XNGEOMETRYCALLBACK 79 260#define OFFSET_XNDESTROYCALLBACK 96 261#define OFFSET_XNFILTEREVENTS 112 262#define OFFSET_XNPREEDITSTARTCALLBACK 125 263#define OFFSET_XNPREEDITDONECALLBACK 146 264#define OFFSET_XNPREEDITDRAWCALLBACK 166 265#define OFFSET_XNPREEDITCARETCALLBACK 186 266#define OFFSET_XNPREEDITSTATENOTIFYCALLBACK 207 267#define OFFSET_XNPREEDITATTRIBUTES 234 268#define OFFSET_XNSTATUSSTARTCALLBACK 252 269#define OFFSET_XNSTATUSDONECALLBACK 272 270#define OFFSET_XNSTATUSDRAWCALLBACK 291 271#define OFFSET_XNSTATUSATTRIBUTES 310 272#define OFFSET_XNAREA 327 273#define OFFSET_XNAREANEEDED 332 274#define OFFSET_XNSPOTLOCATION 343 275#define OFFSET_XNCOLORMAP 356 276#define OFFSET_XNSTDCOLORMAP 365 277#define OFFSET_XNFOREGROUND 377 278#define OFFSET_XNBACKGROUND 388 279#define OFFSET_XNBACKGROUNDPIXMAP 399 280#define OFFSET_XNFONTSET 416 281#define OFFSET_XNLINESPACE 424 282#define OFFSET_XNCURSOR 434 283#define OFFSET_XNQUERYIMVALUESLIST 441 284#define OFFSET_XNQUERYICVALUESLIST 459 285#define OFFSET_XNVISIBLEPOSITION 477 286#define OFFSET_XNSTRINGCONVERSIONCALLBACK 493 287#define OFFSET_XNSTRINGCONVERSION 518 288#define OFFSET_XNRESETSTATE 535 289#define OFFSET_XNHOTKEY 546 290#define OFFSET_XNHOTKEYSTATE 553 291#define OFFSET_XNPREEDITSTATE 565 292 293/* offsets into name_table */ 294static const unsigned short supported_local_im_values_list[] = { 295 OFFSET_XNQUERYINPUTSTYLE, 296 OFFSET_XNRESOURCENAME, 297 OFFSET_XNRESOURCECLASS, 298 OFFSET_XNDESTROYCALLBACK, 299 OFFSET_XNQUERYIMVALUESLIST, 300 OFFSET_XNQUERYICVALUESLIST, 301 OFFSET_XNVISIBLEPOSITION 302}; 303 304/* offsets into name_table */ 305static const unsigned short supported_local_ic_values_list[] = { 306 OFFSET_XNINPUTSTYLE, 307 OFFSET_XNCLIENTWINDOW, 308 OFFSET_XNFOCUSWINDOW, 309 OFFSET_XNRESOURCENAME, 310 OFFSET_XNRESOURCECLASS, 311 OFFSET_XNGEOMETRYCALLBACK, 312 OFFSET_XNFILTEREVENTS, 313 OFFSET_XNDESTROYCALLBACK, 314 OFFSET_XNSTRINGCONVERSIONCALLBACK, 315 OFFSET_XNSTRINGCONVERSIONCALLBACK, 316 OFFSET_XNRESETSTATE, 317 OFFSET_XNHOTKEY, 318 OFFSET_XNHOTKEYSTATE, 319 OFFSET_XNPREEDITATTRIBUTES, 320 OFFSET_XNSTATUSATTRIBUTES, 321 OFFSET_XNAREA, 322 OFFSET_XNAREANEEDED, 323 OFFSET_XNSPOTLOCATION, 324 OFFSET_XNCOLORMAP, 325 OFFSET_XNSTDCOLORMAP, 326 OFFSET_XNFOREGROUND, 327 OFFSET_XNBACKGROUND, 328 OFFSET_XNBACKGROUNDPIXMAP, 329 OFFSET_XNFONTSET, 330 OFFSET_XNLINESPACE, 331 OFFSET_XNCURSOR, 332 OFFSET_XNPREEDITSTARTCALLBACK, 333 OFFSET_XNPREEDITDONECALLBACK, 334 OFFSET_XNPREEDITDRAWCALLBACK, 335 OFFSET_XNPREEDITCARETCALLBACK, 336 OFFSET_XNSTATUSSTARTCALLBACK, 337 OFFSET_XNSTATUSDONECALLBACK, 338 OFFSET_XNSTATUSDRAWCALLBACK, 339 OFFSET_XNPREEDITSTATE, 340 OFFSET_XNPREEDITSTATENOTIFYCALLBACK 341}; 342 343static XIMStyle const supported_local_styles[] = { 344 XIMPreeditNone | XIMStatusNone, 345 XIMPreeditNothing | XIMStatusNothing, 346 0 /* dummy */ 347}; 348 349Private Bool 350_XimDefaultStyles( 351 XimValueOffsetInfo info, 352 XPointer top, 353 XPointer parm, /* unused */ 354 unsigned long mode) /* unused */ 355{ 356 XIMStyles *styles; 357 XIMStyles **out; 358 register int i; 359 unsigned int n; 360 int len; 361 XPointer tmp; 362 363 n = XIMNumber(supported_local_styles) - 1; 364 len = sizeof(XIMStyles) + sizeof(XIMStyle) * n; 365 if(!(tmp = (XPointer)Xmalloc(len))) { 366 return False; 367 } 368 bzero(tmp, len); 369 370 styles = (XIMStyles *)tmp; 371 if (n > 0) { 372 styles->count_styles = (unsigned short)n; 373 styles->supported_styles = 374 (XIMStyle *)((char *)tmp + sizeof(XIMStyles)); 375 for(i = 0; i < n; i++) { 376 styles->supported_styles[i] = supported_local_styles[i]; 377 } 378 } 379 380 out = (XIMStyles **)((char *)top + info->offset); 381 *out = styles; 382 return True; 383} 384 385Private Bool 386_XimDefaultIMValues( 387 XimValueOffsetInfo info, 388 XPointer top, 389 XPointer parm, /* unused */ 390 unsigned long mode) /* unused */ 391{ 392 XIMValuesList *values_list; 393 XIMValuesList **out; 394 register int i; 395 unsigned int n; 396 int len; 397 XPointer tmp; 398 399 n = XIMNumber(supported_local_im_values_list); 400 len = sizeof(XIMValuesList) + sizeof(char **) * n; 401 if(!(tmp = (XPointer)Xmalloc(len))) { 402 return False; 403 } 404 bzero(tmp, len); 405 406 values_list = (XIMValuesList *)tmp; 407 if (n > 0) { 408 values_list->count_values = (unsigned short)n; 409 values_list->supported_values 410 = (char **)((char *)tmp + sizeof(XIMValuesList)); 411 for(i = 0; i < n; i++) { 412 values_list->supported_values[i] = 413 (char *)name_table + supported_local_im_values_list[i]; 414 } 415 } 416 417 out = (XIMValuesList **)((char *)top + info->offset); 418 *out = values_list; 419 return True; 420} 421 422Private Bool 423_XimDefaultICValues( 424 XimValueOffsetInfo info, 425 XPointer top, 426 XPointer parm, /* unused */ 427 unsigned long mode) /* unused */ 428{ 429 XIMValuesList *values_list; 430 XIMValuesList **out; 431 register int i; 432 unsigned int n; 433 int len; 434 XPointer tmp; 435 436 n = XIMNumber(supported_local_ic_values_list); 437 len = sizeof(XIMValuesList) + sizeof(char **) * n; 438 if(!(tmp = (XPointer)Xmalloc(len))) { 439 return False; 440 } 441 bzero(tmp, len); 442 443 values_list = (XIMValuesList *)tmp; 444 if (n > 0) { 445 values_list->count_values = (unsigned short)n; 446 values_list->supported_values 447 = (char **)((char *)tmp + sizeof(XIMValuesList)); 448 for(i = 0; i < n; i++) { 449 values_list->supported_values[i] = 450 (char *)name_table + supported_local_ic_values_list[i]; 451 } 452 } 453 454 out = (XIMValuesList **)((char *)top + info->offset); 455 *out = values_list; 456 return True; 457} 458 459Private Bool 460_XimDefaultVisiblePos( 461 XimValueOffsetInfo info, 462 XPointer top, 463 XPointer parm, /* unused */ 464 unsigned long mode) /* unused */ 465{ 466 Bool *out; 467 468 out = (Bool *)((char *)top + info->offset); 469 *out = False; 470 return True; 471} 472 473Private Bool 474_XimDefaultFocusWindow( 475 XimValueOffsetInfo info, 476 XPointer top, 477 XPointer parm, 478 unsigned long mode) 479{ 480 Xic ic = (Xic)parm; 481 Window *out; 482 483 if(ic->core.client_window == (Window)NULL) { 484 return True; 485 } 486 487 out = (Window *)((char *)top + info->offset); 488 *out = ic->core.client_window; 489 return True; 490} 491 492Private Bool 493_XimDefaultResName( 494 XimValueOffsetInfo info, 495 XPointer top, 496 XPointer parm, 497 unsigned long mode) 498{ 499 Xic ic = (Xic)parm; 500 Xim im = (Xim)ic->core.im; 501 char **out; 502 503 if(im->core.res_name == (char *)NULL) { 504 return True; 505 } 506 507 out = (char **)((char *)top + info->offset); 508 *out = im->core.res_name; 509 return True; 510} 511 512Private Bool 513_XimDefaultResClass( 514 XimValueOffsetInfo info, 515 XPointer top, 516 XPointer parm, 517 unsigned long mode) 518{ 519 Xic ic = (Xic)parm; 520 Xim im = (Xim)ic->core.im; 521 char **out; 522 523 if(im->core.res_class == (char *)NULL) { 524 return True; 525 } 526 527 out = (char **)((char *)top + info->offset); 528 *out = im->core.res_class; 529 return True; 530} 531 532Private Bool 533_XimDefaultDestroyCB( 534 XimValueOffsetInfo info, 535 XPointer top, 536 XPointer parm, 537 unsigned long mode) 538{ 539 Xic ic = (Xic)parm; 540 Xim im = (Xim)ic->core.im; 541 XIMCallback *out; 542 543 out = (XIMCallback *)((char *)top + info->offset); 544 *out = im->core.destroy_callback; 545 return True; 546} 547 548Private Bool 549_XimDefaultResetState( 550 XimValueOffsetInfo info, 551 XPointer top, 552 XPointer parm, 553 unsigned long mode) 554{ 555 XIMResetState *out; 556 557 out = (XIMResetState *)((char *)top + info->offset); 558 *out = XIMInitialState; 559 return True; 560} 561 562Private Bool 563_XimDefaultHotKeyState( 564 XimValueOffsetInfo info, 565 XPointer top, 566 XPointer parm, 567 unsigned long mode) 568{ 569 XIMHotKeyState *out; 570 571 out = (XIMHotKeyState *)((char *)top + info->offset); 572 *out = XIMHotKeyStateOFF; 573 return True; 574} 575 576Private Bool 577_XimDefaultArea( 578 XimValueOffsetInfo info, 579 XPointer top, 580 XPointer parm, 581 unsigned long mode) 582{ 583 Xic ic = (Xic)parm; 584 Xim im = (Xim)ic->core.im; 585 Window root_return; 586 int x_return, y_return; 587 unsigned int width_return, height_return; 588 unsigned int border_width_return; 589 unsigned int depth_return; 590 XRectangle area; 591 XRectangle *out; 592 593 if(ic->core.focus_window == (Window)NULL) { 594 return True; 595 } 596 if(XGetGeometry(im->core.display, (Drawable)ic->core.focus_window, 597 &root_return, &x_return, &y_return, &width_return, 598 &height_return, &border_width_return, &depth_return) 599 == (Status)NULL) { 600 return True; 601 } 602 area.x = 0; 603 area.y = 0; 604 area.width = width_return; 605 area.height = height_return; 606 607 out = (XRectangle *)((char *)top + info->offset); 608 *out = area; 609 return True; 610} 611 612Private Bool 613_XimDefaultColormap( 614 XimValueOffsetInfo info, 615 XPointer top, 616 XPointer parm, 617 unsigned long mode) 618{ 619 Xic ic = (Xic)parm; 620 Xim im = (Xim)ic->core.im; 621 XWindowAttributes win_attr; 622 Colormap *out; 623 624 if(ic->core.client_window == (Window)NULL) { 625 return True; 626 } 627 if(XGetWindowAttributes(im->core.display, ic->core.client_window, 628 &win_attr) == (Status)NULL) { 629 return True; 630 } 631 632 out = (Colormap *)((char *)top + info->offset); 633 *out = win_attr.colormap; 634 return True; 635} 636 637Private Bool 638_XimDefaultStdColormap( 639 XimValueOffsetInfo info, 640 XPointer top, 641 XPointer parm, 642 unsigned long mode) 643{ 644 Atom *out; 645 646 out = (Atom *)((char *)top + info->offset); 647 *out = (Atom)0; 648 return True; 649} 650 651Private Bool 652_XimDefaultFg( 653 XimValueOffsetInfo info, 654 XPointer top, 655 XPointer parm, 656 unsigned long mode) 657{ 658 Xic ic = (Xic)parm; 659 Xim im = (Xim)ic->core.im; 660 unsigned long fg; 661 unsigned long *out; 662 663 fg = WhitePixel(im->core.display, DefaultScreen(im->core.display)); 664 out = (unsigned long *)((char *)top + info->offset); 665 *out = fg; 666 return True; 667} 668 669Private Bool 670_XimDefaultBg( 671 XimValueOffsetInfo info, 672 XPointer top, 673 XPointer parm, 674 unsigned long mode) 675{ 676 Xic ic = (Xic)parm; 677 Xim im = (Xim)ic->core.im; 678 unsigned long bg; 679 unsigned long *out; 680 681 bg = BlackPixel(im->core.display, DefaultScreen(im->core.display)); 682 out = (unsigned long *)((char *)top + info->offset); 683 *out = bg; 684 return True; 685} 686 687Private Bool 688_XimDefaultBgPixmap( 689 XimValueOffsetInfo info, 690 XPointer top, 691 XPointer parm, 692 unsigned long mode) 693{ 694 Pixmap *out; 695 696 out = (Pixmap *)((char *)top + info->offset); 697 *out = (Pixmap)0; 698 return True; 699} 700 701Private Bool 702_XimDefaultFontSet( 703 XimValueOffsetInfo info, 704 XPointer top, 705 XPointer parm, 706 unsigned long mode) 707{ 708 XFontSet *out; 709 710 out = (XFontSet *)((char *)top + info->offset); 711 *out = 0; 712 return True; 713} 714 715Private Bool 716_XimDefaultLineSpace( 717 XimValueOffsetInfo info, 718 XPointer top, 719 XPointer parm, 720 unsigned long mode) 721{ 722 Xic ic = (Xic)parm; 723 XFontSet fontset; 724 XFontSetExtents *fset_extents; 725 int line_space = 0; 726 int *out; 727 728 if(mode & XIM_PREEDIT_ATTR) { 729 fontset = ic->core.preedit_attr.fontset; 730 } else if(mode & XIM_STATUS_ATTR) { 731 fontset = ic->core.status_attr.fontset; 732 } else { 733 return True; 734 } 735 if (fontset) { 736 fset_extents = XExtentsOfFontSet(fontset); 737 line_space = fset_extents->max_logical_extent.height; 738 } 739 out = (int *)((char *)top + info->offset); 740 *out = line_space; 741 return True; 742} 743 744Private Bool 745_XimDefaultCursor( 746 XimValueOffsetInfo info, 747 XPointer top, 748 XPointer parm, 749 unsigned long mode) 750{ 751 Cursor *out; 752 753 out = (Cursor *)((char *)top + info->offset); 754 *out = (Cursor)0; 755 return True; 756} 757 758Private Bool 759_XimDefaultPreeditState( 760 XimValueOffsetInfo info, 761 XPointer top, 762 XPointer parm, 763 unsigned long mode) 764{ 765 XIMPreeditState *out; 766 767 out = (XIMPreeditState *)((char *)top + info->offset); 768 *out = XIMPreeditDisable; 769 return True; 770} 771 772Private Bool 773_XimDefaultNest( 774 XimValueOffsetInfo info, 775 XPointer top, 776 XPointer parm, 777 unsigned long mode) 778{ 779 return True; 780} 781 782Private Bool 783_XimEncodeCallback( 784 XimValueOffsetInfo info, 785 XPointer top, 786 XPointer val) 787{ 788 XIMCallback *out; 789 790 out = (XIMCallback *)((char *)top + info->offset); 791 *out = *((XIMCallback *)val); 792 return True; 793} 794 795Private Bool 796_XimEncodeString( 797 XimValueOffsetInfo info, 798 XPointer top, 799 XPointer val) 800{ 801 int len; 802 char *string; 803 char **out; 804 805 if(val == (XPointer)NULL) { 806 return False; 807 } 808 len = strlen((char *)val); 809 if(!(string = (char *)Xmalloc(len + 1))) { 810 return False; 811 } 812 (void)strcpy(string, (char *)val); 813 string[len] = '\0'; 814 815 out = (char **)((char *)top + info->offset); 816 if(*out) { 817 Xfree(*out); 818 } 819 *out = string; 820 return True; 821} 822 823Private Bool 824_XimEncodeStyle( 825 XimValueOffsetInfo info, 826 XPointer top, 827 XPointer val) 828{ 829 XIMStyle *out; 830 831 out = (XIMStyle *)((char *)top + info->offset); 832 *out = (XIMStyle)val; 833 return True; 834} 835 836Private Bool 837_XimEncodeWindow( 838 XimValueOffsetInfo info, 839 XPointer top, 840 XPointer val) 841{ 842 Window *out; 843 844 out = (Window *)((char *)top + info->offset); 845 *out = (Window)val; 846 return True; 847} 848 849Private Bool 850_XimEncodeStringConv( 851 XimValueOffsetInfo info, 852 XPointer top, 853 XPointer val) 854{ 855 /* 856 * Not yet 857 */ 858 return True; 859} 860 861Private Bool 862_XimEncodeResetState( 863 XimValueOffsetInfo info, 864 XPointer top, 865 XPointer val) 866{ 867 XIMResetState *out; 868 869 out = (XIMResetState *)((char *)top + info->offset); 870 *out = (XIMResetState)val; 871 return True; 872} 873 874Private Bool 875_XimEncodeHotKey( 876 XimValueOffsetInfo info, 877 XPointer top, 878 XPointer val) 879{ 880 XIMHotKeyTriggers *hotkey = (XIMHotKeyTriggers *)val; 881 XIMHotKeyTriggers **out; 882 XIMHotKeyTriggers *key_list; 883 XIMHotKeyTrigger *key; 884 XPointer tmp; 885 int num; 886 int len; 887 register int i; 888 889 if(hotkey == (XIMHotKeyTriggers *)NULL) { 890 return True; 891 } 892 893 if((num = hotkey->num_hot_key) == 0) { 894 return True; 895 } 896 897 len = sizeof(XIMHotKeyTriggers) + sizeof(XIMHotKeyTrigger) * num; 898 if(!(tmp = (XPointer)Xmalloc(len))) { 899 return False; 900 } 901 902 key_list = (XIMHotKeyTriggers *)tmp; 903 key = (XIMHotKeyTrigger *)((char *)tmp + sizeof(XIMHotKeyTriggers)); 904 905 for(i = 0; i < num; i++) { 906 key[i] = hotkey->key[i]; 907 } 908 909 key_list->num_hot_key = num; 910 key_list->key = key; 911 912 out = (XIMHotKeyTriggers **)((char *)top + info->offset); 913 *out = key_list; 914 return True; 915} 916 917Private Bool 918_XimEncodeHotKetState( 919 XimValueOffsetInfo info, 920 XPointer top, 921 XPointer val) 922{ 923 XIMHotKeyState *out; 924 925 out = (XIMHotKeyState *)((char *)top + info->offset); 926 *out = (XIMHotKeyState)val; 927 return True; 928} 929 930Private Bool 931_XimEncodeRectangle( 932 XimValueOffsetInfo info, 933 XPointer top, 934 XPointer val) 935{ 936 XRectangle *out; 937 938 out = (XRectangle *)((char *)top + info->offset); 939 *out = *((XRectangle *)val); 940 return True; 941} 942 943Private Bool 944_XimEncodeSpot( 945 XimValueOffsetInfo info, 946 XPointer top, 947 XPointer val) 948{ 949 XPoint *out; 950 951 out = (XPoint *)((char *)top + info->offset); 952 *out = *((XPoint *)val); 953 return True; 954} 955 956Private Bool 957_XimEncodeColormap( 958 XimValueOffsetInfo info, 959 XPointer top, 960 XPointer val) 961{ 962 Colormap *out; 963 964 out = (Colormap *)((char *)top + info->offset); 965 *out = (Colormap)val; 966 return True; 967} 968 969Private Bool 970_XimEncodeStdColormap( 971 XimValueOffsetInfo info, 972 XPointer top, 973 XPointer val) 974{ 975 Atom *out; 976 977 out = (Atom *)((char *)top + info->offset); 978 *out = (Atom)val; 979 return True; 980} 981 982Private Bool 983_XimEncodeLong( 984 XimValueOffsetInfo info, 985 XPointer top, 986 XPointer val) 987{ 988 unsigned long *out; 989 990 out = (unsigned long *)((char *)top + info->offset); 991 *out = (unsigned long)val; 992 return True; 993} 994 995Private Bool 996_XimEncodeBgPixmap( 997 XimValueOffsetInfo info, 998 XPointer top, 999 XPointer val) 1000{ 1001 Pixmap *out; 1002 1003 out = (Pixmap *)((char *)top + info->offset); 1004 *out = (Pixmap)val; 1005 return True; 1006} 1007 1008Private Bool 1009_XimEncodeFontSet( 1010 XimValueOffsetInfo info, 1011 XPointer top, 1012 XPointer val) 1013{ 1014 XFontSet *out; 1015 1016 out = (XFontSet *)((char *)top + info->offset); 1017 *out = (XFontSet)val; 1018 return True; 1019} 1020 1021Private Bool 1022_XimEncodeLineSpace( 1023 XimValueOffsetInfo info, 1024 XPointer top, 1025 XPointer val) 1026{ 1027 int *out; 1028 1029 out = (int *)((char *)top + info->offset); 1030 *out = (long)val; 1031 return True; 1032} 1033 1034Private Bool 1035_XimEncodeCursor( 1036 XimValueOffsetInfo info, 1037 XPointer top, 1038 XPointer val) 1039{ 1040 Cursor *out; 1041 1042 out = (Cursor *)((char *)top + info->offset); 1043 *out = (Cursor)val; 1044 return True; 1045} 1046 1047Private Bool 1048_XimEncodePreeditState( 1049 XimValueOffsetInfo info, 1050 XPointer top, 1051 XPointer val) 1052{ 1053 XIMPreeditState *out; 1054 1055 out = (XIMPreeditState *)((char *)top + info->offset); 1056 *out = (XIMPreeditState)val; 1057 return True; 1058} 1059 1060Private Bool 1061_XimEncodeNest( 1062 XimValueOffsetInfo info, 1063 XPointer top, 1064 XPointer val) 1065{ 1066 return True; 1067} 1068 1069Private Bool 1070_XimDecodeStyles( 1071 XimValueOffsetInfo info, 1072 XPointer top, 1073 XPointer val) 1074{ 1075 XIMStyles *styles; 1076 XIMStyles *out; 1077 register int i; 1078 unsigned int num; 1079 int len; 1080 XPointer tmp; 1081 1082 if(val == (XPointer)NULL) { 1083 return False; 1084 } 1085 1086 styles = *((XIMStyles **)((char *)top + info->offset)); 1087 num = styles->count_styles; 1088 1089 len = sizeof(XIMStyles) + sizeof(XIMStyle) * num; 1090 if(!(tmp = (XPointer)Xmalloc(len))) { 1091 return False; 1092 } 1093 bzero(tmp, len); 1094 1095 out = (XIMStyles *)tmp; 1096 if(num >0) { 1097 out->count_styles = (unsigned short)num; 1098 out->supported_styles = (XIMStyle *)((char *)tmp + sizeof(XIMStyles)); 1099 1100 for(i = 0; i < num; i++) { 1101 out->supported_styles[i] = styles->supported_styles[i]; 1102 } 1103 } 1104 *((XIMStyles **)val) = out; 1105 return True; 1106} 1107 1108Private Bool 1109_XimDecodeValues( 1110 XimValueOffsetInfo info, 1111 XPointer top, 1112 XPointer val) 1113{ 1114 XIMValuesList *values_list; 1115 XIMValuesList *out; 1116 register int i; 1117 unsigned int num; 1118 int len; 1119 XPointer tmp; 1120 1121 if(val == (XPointer)NULL) { 1122 return False; 1123 } 1124 1125 values_list = *((XIMValuesList **)((char *)top + info->offset)); 1126 num = values_list->count_values; 1127 1128 len = sizeof(XIMValuesList) + sizeof(char **) * num; 1129 if(!(tmp = (char *)Xmalloc(len))) { 1130 return False; 1131 } 1132 bzero(tmp, len); 1133 1134 out = (XIMValuesList *)tmp; 1135 if(num) { 1136 out->count_values = (unsigned short)num; 1137 out->supported_values = (char **)((char *)tmp + sizeof(XIMValuesList)); 1138 1139 for(i = 0; i < num; i++) { 1140 out->supported_values[i] = values_list->supported_values[i]; 1141 } 1142 } 1143 *((XIMValuesList **)val) = out; 1144 return True; 1145} 1146 1147Private Bool 1148_XimDecodeCallback( 1149 XimValueOffsetInfo info, 1150 XPointer top, 1151 XPointer val) 1152{ 1153 XIMCallback *in; 1154 XIMCallback *callback; 1155 1156 in = (XIMCallback *)((char *)top + info->offset); 1157 if(!(callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback)))) { 1158 return False; 1159 } 1160 callback->client_data = in->client_data; 1161 callback->callback = in->callback; 1162 1163 *((XIMCallback **)val) = callback; 1164 return True; 1165} 1166 1167Private Bool 1168_XimDecodeString( 1169 XimValueOffsetInfo info, 1170 XPointer top, 1171 XPointer val) 1172{ 1173 int len = 0; 1174 char *in; 1175 char *string; 1176 1177 in = *((char **)((char *)top + info->offset)); 1178 if(in != (char *)NULL) { 1179 len = strlen(in); 1180 } 1181 if(!(string = (char *)Xmalloc(len + 1))) { 1182 return False; 1183 } 1184 if(in != (char *)NULL) { 1185 (void)strcpy(string, in); 1186 } 1187 string[len] = '\0'; 1188 *((char **)val) = string; 1189 return True; 1190} 1191 1192Private Bool 1193_XimDecodeBool( 1194 XimValueOffsetInfo info, 1195 XPointer top, 1196 XPointer val) 1197{ 1198 Bool *in; 1199 1200 in = (Bool *)((char *)top + info->offset); 1201 *((Bool *)val) = *in; 1202 return True; 1203} 1204 1205Private Bool 1206_XimDecodeStyle( 1207 XimValueOffsetInfo info, 1208 XPointer top, 1209 XPointer val) 1210{ 1211 XIMStyle *in; 1212 1213 in = (XIMStyle *)((char *)top + info->offset); 1214 *((XIMStyle *)val) = *in; 1215 return True; 1216} 1217 1218Private Bool 1219_XimDecodeWindow( 1220 XimValueOffsetInfo info, 1221 XPointer top, 1222 XPointer val) 1223{ 1224 Window *in; 1225 1226 in = (Window *)((char *)top + info->offset); 1227 *((Window *)val) = *in; 1228 return True; 1229} 1230 1231Private Bool 1232_XimDecodeStringConv( 1233 XimValueOffsetInfo info, 1234 XPointer top, 1235 XPointer val) 1236{ 1237 /* 1238 * Not yet 1239 */ 1240 return True; 1241} 1242 1243Private Bool 1244_XimDecodeResetState( 1245 XimValueOffsetInfo info, 1246 XPointer top, 1247 XPointer val) 1248{ 1249 XIMResetState *in; 1250 1251 in = (XIMResetState *)((char *)top + info->offset); 1252 *((XIMResetState *)val) = *in; 1253 return True; 1254} 1255 1256Private Bool 1257_XimDecodeHotKey( 1258 XimValueOffsetInfo info, 1259 XPointer top, 1260 XPointer val) 1261{ 1262 XIMHotKeyTriggers *in; 1263 XIMHotKeyTriggers *hotkey; 1264 XIMHotKeyTrigger *key; 1265 XPointer tmp; 1266 int num; 1267 int len; 1268 register int i; 1269 1270 in = *((XIMHotKeyTriggers **)((char *)top + info->offset)); 1271 num = in->num_hot_key; 1272 len = sizeof(XIMHotKeyTriggers) + sizeof(XIMHotKeyTrigger) * num; 1273 if(!(tmp = (XPointer)Xmalloc(len))) { 1274 return False; 1275 } 1276 1277 hotkey = (XIMHotKeyTriggers *)tmp; 1278 key = (XIMHotKeyTrigger *)((char *)tmp + sizeof(XIMHotKeyTriggers)); 1279 1280 for(i = 0; i < num; i++) { 1281 key[i] = in->key[i]; 1282 } 1283 hotkey->num_hot_key = num; 1284 hotkey->key = key; 1285 1286 *((XIMHotKeyTriggers **)val) = hotkey; 1287 return True; 1288} 1289 1290Private Bool 1291_XimDecodeHotKetState( 1292 XimValueOffsetInfo info, 1293 XPointer top, 1294 XPointer val) 1295{ 1296 XIMHotKeyState *in; 1297 1298 in = (XIMHotKeyState *)((char *)top + info->offset); 1299 *((XIMHotKeyState *)val) = *in; 1300 return True; 1301} 1302 1303Private Bool 1304_XimDecodeRectangle( 1305 XimValueOffsetInfo info, 1306 XPointer top, 1307 XPointer val) 1308{ 1309 XRectangle *in; 1310 XRectangle *rect; 1311 1312 in = (XRectangle *)((char *)top + info->offset); 1313 if(!(rect = (XRectangle *)Xmalloc(sizeof(XRectangle)))) { 1314 return False; 1315 } 1316 *rect = *in; 1317 *((XRectangle **)val) = rect; 1318 return True; 1319} 1320 1321Private Bool 1322_XimDecodeSpot( 1323 XimValueOffsetInfo info, 1324 XPointer top, 1325 XPointer val) 1326{ 1327 XPoint *in; 1328 XPoint *spot; 1329 1330 in = (XPoint *)((char *)top + info->offset); 1331 if(!(spot = (XPoint *)Xmalloc(sizeof(XPoint)))) { 1332 return False; 1333 } 1334 *spot = *in; 1335 *((XPoint **)val) = spot; 1336 return True; 1337} 1338 1339Private Bool 1340_XimDecodeColormap( 1341 XimValueOffsetInfo info, 1342 XPointer top, 1343 XPointer val) 1344{ 1345 Colormap *in; 1346 1347 in = (Colormap *)((char *)top + info->offset); 1348 *((Colormap *)val) = *in; 1349 return True; 1350} 1351 1352Private Bool 1353_XimDecodeStdColormap( 1354 XimValueOffsetInfo info, 1355 XPointer top, 1356 XPointer val) 1357{ 1358 Atom *in; 1359 1360 in = (Atom *)((char *)top + info->offset); 1361 *((Atom *)val) = *in; 1362 return True; 1363} 1364 1365Private Bool 1366_XimDecodeLong( 1367 XimValueOffsetInfo info, 1368 XPointer top, 1369 XPointer val) 1370{ 1371 unsigned long *in; 1372 1373 in = (unsigned long *)((char *)top + info->offset); 1374 *((unsigned long *)val) = *in; 1375 return True; 1376} 1377 1378Private Bool 1379_XimDecodeBgPixmap( 1380 XimValueOffsetInfo info, 1381 XPointer top, 1382 XPointer val) 1383{ 1384 Pixmap *in; 1385 1386 in = (Pixmap *)((char *)top + info->offset); 1387 *((Pixmap *)val) = *in; 1388 return True; 1389} 1390 1391Private Bool 1392_XimDecodeFontSet( 1393 XimValueOffsetInfo info, 1394 XPointer top, 1395 XPointer val) 1396{ 1397 XFontSet *in; 1398 1399 in = (XFontSet *)((char *)top + info->offset); 1400 *((XFontSet *)val) = *in; 1401 return True; 1402} 1403 1404Private Bool 1405_XimDecodeLineSpace( 1406 XimValueOffsetInfo info, 1407 XPointer top, 1408 XPointer val) 1409{ 1410 int *in; 1411 1412 in = (int *)((char *)top + info->offset); 1413 *((int *)val) = *in; 1414 return True; 1415} 1416 1417Private Bool 1418_XimDecodeCursor( 1419 XimValueOffsetInfo info, 1420 XPointer top, 1421 XPointer val) 1422{ 1423 Cursor *in; 1424 1425 in = (Cursor *)((char *)top + info->offset); 1426 *((Cursor *)val) = *in; 1427 return True; 1428} 1429 1430Private Bool 1431_XimDecodePreeditState( 1432 XimValueOffsetInfo info, 1433 XPointer top, 1434 XPointer val) 1435{ 1436 XIMPreeditState *in; 1437 1438 in = (XIMPreeditState *)((char *)top + info->offset); 1439 *((XIMPreeditState *)val) = *in; 1440 return True; 1441} 1442 1443Private Bool 1444_XimDecodeNest( 1445 XimValueOffsetInfo info, 1446 XPointer top, 1447 XPointer val) 1448{ 1449 return True; 1450} 1451 1452static XIMResource im_resources[] = { 1453 {XNQueryInputStyle, 0, XimType_XIMStyles, 0, 0, 0}, 1454 {XNDestroyCallback, 0, 0, 0, 0, 0}, 1455 {XNResourceName, 0, XimType_STRING8, 0, 0, 0}, 1456 {XNResourceClass, 0, XimType_STRING8, 0, 0, 0}, 1457 {XNQueryIMValuesList, 0, 0, 0, 0, 0}, 1458 {XNQueryICValuesList, 0, 0, 0, 0, 0}, 1459 {XNVisiblePosition, 0, 0, 0, 0, 0} 1460}; 1461 1462static XIMResource im_inner_resources[] = { 1463 {XNDestroyCallback, 0, 0, 0, 0, 0}, 1464 {XNResourceName, 0, XimType_STRING8, 0, 0, 0}, 1465 {XNResourceClass, 0, XimType_STRING8, 0, 0, 0}, 1466 {XNQueryIMValuesList, 0, 0, 0, 0, 0}, 1467 {XNQueryICValuesList, 0, 0, 0, 0, 0}, 1468 {XNVisiblePosition, 0, 0, 0, 0, 0} 1469}; 1470 1471static XIMResource ic_resources[] = { 1472 {XNInputStyle, 0, XimType_CARD32, 0, 0, 0}, 1473 {XNClientWindow, 0, XimType_Window, 0, 0, 0}, 1474 {XNFocusWindow, 0, XimType_Window, 0, 0, 0}, 1475 {XNResourceName, 0, XimType_STRING8, 0, 0, 0}, 1476 {XNResourceClass, 0, XimType_STRING8, 0, 0, 0}, 1477 {XNGeometryCallback, 0, 0, 0, 0, 0}, 1478 {XNFilterEvents, 0, XimType_CARD32, 0, 0, 0}, 1479 {XNDestroyCallback, 0, 0, 0, 0, 0}, 1480 {XNStringConversionCallback, 0, 0, 0, 0, 0}, 1481 {XNStringConversion, 0, XimType_XIMStringConversion,0, 0, 0}, 1482 {XNResetState, 0, 0, 0, 0, 0}, 1483 {XNHotKey, 0, XimType_XIMHotKeyTriggers,0, 0, 0}, 1484 {XNHotKeyState, 0, XimType_XIMHotKeyState, 0, 0, 0}, 1485 {XNPreeditAttributes, 0, XimType_NEST, 0, 0, 0}, 1486 {XNStatusAttributes, 0, XimType_NEST, 0, 0, 0}, 1487 {XNArea, 0, XimType_XRectangle, 0, 0, 0}, 1488 {XNAreaNeeded, 0, XimType_XRectangle, 0, 0, 0}, 1489 {XNSpotLocation, 0, XimType_XPoint, 0, 0, 0}, 1490 {XNColormap, 0, XimType_CARD32, 0, 0, 0}, 1491 {XNStdColormap, 0, XimType_CARD32, 0, 0, 0}, 1492 {XNForeground, 0, XimType_CARD32, 0, 0, 0}, 1493 {XNBackground, 0, XimType_CARD32, 0, 0, 0}, 1494 {XNBackgroundPixmap, 0, XimType_CARD32, 0, 0, 0}, 1495 {XNFontSet, 0, XimType_XFontSet, 0, 0, 0}, 1496 {XNLineSpace, 0, XimType_CARD32, 0, 0, 0}, 1497 {XNCursor, 0, XimType_CARD32, 0, 0, 0}, 1498 {XNPreeditStartCallback, 0, 0, 0, 0, 0}, 1499 {XNPreeditDoneCallback, 0, 0, 0, 0, 0}, 1500 {XNPreeditDrawCallback, 0, 0, 0, 0, 0}, 1501 {XNPreeditCaretCallback, 0, 0, 0, 0, 0}, 1502 {XNStatusStartCallback, 0, 0, 0, 0, 0}, 1503 {XNStatusDoneCallback, 0, 0, 0, 0, 0}, 1504 {XNStatusDrawCallback, 0, 0, 0, 0, 0}, 1505 {XNPreeditState, 0, 0, 0, 0, 0}, 1506 {XNPreeditStateNotifyCallback, 0, 0, 0, 0, 0}, 1507}; 1508 1509static XIMResource ic_inner_resources[] = { 1510 {XNResourceName, 0, XimType_STRING8, 0, 0, 0}, 1511 {XNResourceClass, 0, XimType_STRING8, 0, 0, 0}, 1512 {XNGeometryCallback, 0, 0, 0, 0, 0}, 1513 {XNDestroyCallback, 0, 0, 0, 0, 0}, 1514 {XNStringConversionCallback, 0, 0, 0, 0, 0}, 1515 {XNPreeditStartCallback, 0, 0, 0, 0, 0}, 1516 {XNPreeditDoneCallback, 0, 0, 0, 0, 0}, 1517 {XNPreeditDrawCallback, 0, 0, 0, 0, 0}, 1518 {XNPreeditCaretCallback, 0, 0, 0, 0, 0}, 1519 {XNStatusStartCallback, 0, 0, 0, 0, 0}, 1520 {XNStatusDoneCallback, 0, 0, 0, 0, 0}, 1521 {XNStatusDrawCallback, 0, 0, 0, 0, 0}, 1522 {XNPreeditStateNotifyCallback, 0, 0, 0, 0, 0}, 1523}; 1524 1525static XimValueOffsetInfoRec im_attr_info[] = { 1526 {OFFSET_XNQUERYINPUTSTYLE, 0, 1527 XOffsetOf(XimDefIMValues, styles), 1528 _XimDefaultStyles, NULL, _XimDecodeStyles}, 1529 1530 {OFFSET_XNDESTROYCALLBACK, 0, 1531 XOffsetOf(XimDefIMValues, destroy_callback), 1532 NULL, _XimEncodeCallback, _XimDecodeCallback}, 1533 1534 {OFFSET_XNRESOURCENAME, 0, 1535 XOffsetOf(XimDefIMValues, res_name), 1536 NULL, _XimEncodeString, _XimDecodeString}, 1537 1538 {OFFSET_XNRESOURCECLASS, 0, 1539 XOffsetOf(XimDefIMValues, res_class), 1540 NULL, _XimEncodeString, _XimDecodeString}, 1541 1542 {OFFSET_XNQUERYIMVALUESLIST, 0, 1543 XOffsetOf(XimDefIMValues, im_values_list), 1544 _XimDefaultIMValues, NULL, _XimDecodeValues}, 1545 1546 {OFFSET_XNQUERYICVALUESLIST, 0, 1547 XOffsetOf(XimDefIMValues, ic_values_list), 1548 _XimDefaultICValues, NULL, _XimDecodeValues}, 1549 1550 {OFFSET_XNVISIBLEPOSITION, 0, 1551 XOffsetOf(XimDefIMValues, visible_position), 1552 _XimDefaultVisiblePos, NULL, _XimDecodeBool} 1553}; 1554 1555static XimValueOffsetInfoRec ic_attr_info[] = { 1556 {OFFSET_XNINPUTSTYLE, 0, 1557 XOffsetOf(XimDefICValues, input_style), 1558 NULL, _XimEncodeStyle, _XimDecodeStyle}, 1559 1560 {OFFSET_XNCLIENTWINDOW, 0, 1561 XOffsetOf(XimDefICValues, client_window), 1562 NULL, _XimEncodeWindow, _XimDecodeWindow}, 1563 1564 {OFFSET_XNFOCUSWINDOW, 0, 1565 XOffsetOf(XimDefICValues, focus_window), 1566 _XimDefaultFocusWindow, _XimEncodeWindow, _XimDecodeWindow}, 1567 1568 {OFFSET_XNRESOURCENAME, 0, 1569 XOffsetOf(XimDefICValues, res_name), 1570 _XimDefaultResName, _XimEncodeString, _XimDecodeString}, 1571 1572 {OFFSET_XNRESOURCECLASS, 0, 1573 XOffsetOf(XimDefICValues, res_class), 1574 _XimDefaultResClass, _XimEncodeString, _XimDecodeString}, 1575 1576 {OFFSET_XNGEOMETRYCALLBACK, 0, 1577 XOffsetOf(XimDefICValues, geometry_callback), 1578 NULL, _XimEncodeCallback, _XimDecodeCallback}, 1579 1580 {OFFSET_XNFILTEREVENTS, 0, 1581 XOffsetOf(XimDefICValues, filter_events), 1582 NULL, NULL, _XimDecodeLong}, 1583 1584 {OFFSET_XNDESTROYCALLBACK, 0, 1585 XOffsetOf(XimDefICValues, destroy_callback), 1586 _XimDefaultDestroyCB, _XimEncodeCallback, _XimDecodeCallback}, 1587 1588 {OFFSET_XNSTRINGCONVERSIONCALLBACK, 0, 1589 XOffsetOf(XimDefICValues, string_conversion_callback), 1590 NULL, _XimEncodeCallback, _XimDecodeCallback}, 1591 1592 {OFFSET_XNSTRINGCONVERSION, 0, 1593 XOffsetOf(XimDefICValues, string_conversion), 1594 NULL, _XimEncodeStringConv, _XimDecodeStringConv}, 1595 1596 {OFFSET_XNRESETSTATE, 0, 1597 XOffsetOf(XimDefICValues, reset_state), 1598 _XimDefaultResetState, _XimEncodeResetState, _XimDecodeResetState}, 1599 1600 {OFFSET_XNHOTKEY, 0, 1601 XOffsetOf(XimDefICValues, hotkey), 1602 NULL, _XimEncodeHotKey, _XimDecodeHotKey}, 1603 1604 {OFFSET_XNHOTKEYSTATE, 0, 1605 XOffsetOf(XimDefICValues, hotkey_state), 1606 _XimDefaultHotKeyState, _XimEncodeHotKetState, _XimDecodeHotKetState}, 1607 1608 {OFFSET_XNPREEDITATTRIBUTES, 0, 1609 XOffsetOf(XimDefICValues, preedit_attr), 1610 _XimDefaultNest, _XimEncodeNest, _XimDecodeNest}, 1611 1612 {OFFSET_XNSTATUSATTRIBUTES, 0, 1613 XOffsetOf(XimDefICValues, status_attr), 1614 _XimDefaultNest, _XimEncodeNest, _XimDecodeNest}, 1615}; 1616 1617static XimValueOffsetInfoRec ic_pre_attr_info[] = { 1618 {OFFSET_XNAREA, 0, 1619 XOffsetOf(ICPreeditAttributes, area), 1620 _XimDefaultArea, _XimEncodeRectangle, _XimDecodeRectangle}, 1621 1622 {OFFSET_XNAREANEEDED, 0, 1623 XOffsetOf(ICPreeditAttributes, area_needed), 1624 NULL, _XimEncodeRectangle, _XimDecodeRectangle}, 1625 1626 {OFFSET_XNSPOTLOCATION, 0, 1627 XOffsetOf(ICPreeditAttributes, spot_location), 1628 NULL, _XimEncodeSpot, _XimDecodeSpot}, 1629 1630 {OFFSET_XNCOLORMAP, 0, 1631 XOffsetOf(ICPreeditAttributes, colormap), 1632 _XimDefaultColormap, _XimEncodeColormap, _XimDecodeColormap}, 1633 1634 {OFFSET_XNSTDCOLORMAP, 0, 1635 XOffsetOf(ICPreeditAttributes, std_colormap), 1636 _XimDefaultStdColormap, _XimEncodeStdColormap, _XimDecodeStdColormap}, 1637 1638 {OFFSET_XNFOREGROUND, 0, 1639 XOffsetOf(ICPreeditAttributes, foreground), 1640 _XimDefaultFg, _XimEncodeLong, _XimDecodeLong}, 1641 1642 {OFFSET_XNBACKGROUND, 0, 1643 XOffsetOf(ICPreeditAttributes, background), 1644 _XimDefaultBg, _XimEncodeLong, _XimDecodeLong}, 1645 1646 {OFFSET_XNBACKGROUNDPIXMAP, 0, 1647 XOffsetOf(ICPreeditAttributes, background_pixmap), 1648 _XimDefaultBgPixmap, _XimEncodeBgPixmap, _XimDecodeBgPixmap}, 1649 1650 {OFFSET_XNFONTSET, 0, 1651 XOffsetOf(ICPreeditAttributes, fontset), 1652 _XimDefaultFontSet, _XimEncodeFontSet, _XimDecodeFontSet}, 1653 1654 {OFFSET_XNLINESPACE, 0, 1655 XOffsetOf(ICPreeditAttributes, line_spacing), 1656 _XimDefaultLineSpace, _XimEncodeLineSpace, _XimDecodeLineSpace}, 1657 1658 {OFFSET_XNCURSOR, 0, 1659 XOffsetOf(ICPreeditAttributes, cursor), 1660 _XimDefaultCursor, _XimEncodeCursor, _XimDecodeCursor}, 1661 1662 {OFFSET_XNPREEDITSTARTCALLBACK, 0, 1663 XOffsetOf(ICPreeditAttributes, start_callback), 1664 NULL, _XimEncodeCallback, _XimDecodeCallback}, 1665 1666 {OFFSET_XNPREEDITDONECALLBACK, 0, 1667 XOffsetOf(ICPreeditAttributes, done_callback), 1668 NULL, _XimEncodeCallback, _XimDecodeCallback}, 1669 1670 {OFFSET_XNPREEDITDRAWCALLBACK, 0, 1671 XOffsetOf(ICPreeditAttributes, draw_callback), 1672 NULL, _XimEncodeCallback, _XimDecodeCallback}, 1673 1674 {OFFSET_XNPREEDITCARETCALLBACK, 0, 1675 XOffsetOf(ICPreeditAttributes, caret_callback), 1676 NULL, _XimEncodeCallback, _XimDecodeCallback}, 1677 1678 {OFFSET_XNPREEDITSTATE, 0, 1679 XOffsetOf(ICPreeditAttributes, preedit_state), 1680 _XimDefaultPreeditState, _XimEncodePreeditState,_XimDecodePreeditState}, 1681 1682 {OFFSET_XNPREEDITSTATENOTIFYCALLBACK, 0, 1683 XOffsetOf(ICPreeditAttributes, state_notify_callback), 1684 NULL, _XimEncodeCallback, _XimDecodeCallback}, 1685}; 1686 1687static XimValueOffsetInfoRec ic_sts_attr_info[] = { 1688 {OFFSET_XNAREA, 0, 1689 XOffsetOf(ICStatusAttributes, area), 1690 _XimDefaultArea, _XimEncodeRectangle, _XimDecodeRectangle}, 1691 1692 {OFFSET_XNAREANEEDED, 0, 1693 XOffsetOf(ICStatusAttributes, area_needed), 1694 NULL, _XimEncodeRectangle, _XimDecodeRectangle}, 1695 1696 {OFFSET_XNCOLORMAP, 0, 1697 XOffsetOf(ICStatusAttributes, colormap), 1698 _XimDefaultColormap, _XimEncodeColormap, _XimDecodeColormap}, 1699 1700 {OFFSET_XNSTDCOLORMAP, 0, 1701 XOffsetOf(ICStatusAttributes, std_colormap), 1702 _XimDefaultStdColormap, _XimEncodeStdColormap, _XimDecodeStdColormap}, 1703 1704 {OFFSET_XNFOREGROUND, 0, 1705 XOffsetOf(ICStatusAttributes, foreground), 1706 _XimDefaultFg, _XimEncodeLong, _XimDecodeLong}, 1707 1708 {OFFSET_XNBACKGROUND, 0, 1709 XOffsetOf(ICStatusAttributes, background), 1710 _XimDefaultBg, _XimEncodeLong, _XimDecodeLong}, 1711 1712 {OFFSET_XNBACKGROUNDPIXMAP, 0, 1713 XOffsetOf(ICStatusAttributes, background_pixmap), 1714 _XimDefaultBgPixmap, _XimEncodeBgPixmap, _XimDecodeBgPixmap}, 1715 1716 {OFFSET_XNFONTSET, 0, 1717 XOffsetOf(ICStatusAttributes, fontset), 1718 _XimDefaultFontSet, _XimEncodeFontSet, _XimDecodeFontSet}, 1719 1720 {OFFSET_XNLINESPACE, 0, 1721 XOffsetOf(ICStatusAttributes, line_spacing), 1722 _XimDefaultLineSpace, _XimEncodeLineSpace, _XimDecodeLineSpace}, 1723 1724 {OFFSET_XNCURSOR, 0, 1725 XOffsetOf(ICStatusAttributes, cursor), 1726 _XimDefaultCursor, _XimEncodeCursor, _XimDecodeCursor}, 1727 1728 {OFFSET_XNSTATUSSTARTCALLBACK, 0, 1729 XOffsetOf(ICStatusAttributes, start_callback), 1730 NULL, _XimEncodeCallback, _XimDecodeCallback}, 1731 1732 {OFFSET_XNSTATUSDONECALLBACK, 0, 1733 XOffsetOf(ICStatusAttributes, done_callback), 1734 NULL, _XimEncodeCallback, _XimDecodeCallback}, 1735 1736 {OFFSET_XNSTATUSDRAWCALLBACK, 0, 1737 XOffsetOf(ICStatusAttributes, draw_callback), 1738 NULL, _XimEncodeCallback, _XimDecodeCallback} 1739}; 1740 1741typedef struct _XimIMMode { 1742 unsigned short name_offset; 1743 unsigned short mode; 1744} XimIMMode; 1745 1746static const XimIMMode im_mode[] = { 1747 {OFFSET_XNQUERYINPUTSTYLE, 1748 (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)}, 1749 {OFFSET_XNDESTROYCALLBACK, 1750 (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_SET | XIM_MODE_IM_GET)}, 1751 {OFFSET_XNRESOURCENAME, 1752 (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_SET | XIM_MODE_IM_GET)}, 1753 {OFFSET_XNRESOURCECLASS, 1754 (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_SET | XIM_MODE_IM_GET)}, 1755 {OFFSET_XNQUERYIMVALUESLIST, 1756 (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)}, 1757 {OFFSET_XNQUERYICVALUESLIST, 1758 (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)}, 1759 {OFFSET_XNVISIBLEPOSITION, 1760 (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)} 1761}; 1762 1763typedef struct _XimICMode { 1764 unsigned short name_offset; 1765 unsigned short preedit_callback_mode; 1766 unsigned short preedit_position_mode; 1767 unsigned short preedit_area_mode; 1768 unsigned short preedit_nothing_mode; 1769 unsigned short preedit_none_mode; 1770 unsigned short status_callback_mode; 1771 unsigned short status_area_mode; 1772 unsigned short status_nothing_mode; 1773 unsigned short status_none_mode; 1774} XimICMode; 1775 1776static const XimICMode ic_mode[] = { 1777 {OFFSET_XNINPUTSTYLE, 1778 (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET), 1779 (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET), 1780 (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET), 1781 (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET), 1782 (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET), 1783 (XIM_MODE_STS_CREATE | XIM_MODE_STS_GET), 1784 (XIM_MODE_STS_CREATE | XIM_MODE_STS_GET), 1785 (XIM_MODE_STS_CREATE | XIM_MODE_STS_GET), 1786 (XIM_MODE_STS_CREATE | XIM_MODE_STS_GET)}, 1787 {OFFSET_XNCLIENTWINDOW, 1788 (XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET), 1789 (XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET), 1790 (XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET), 1791 (XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET), 1792 0, 1793 (XIM_MODE_STS_ONCE | XIM_MODE_STS_GET), 1794 (XIM_MODE_STS_ONCE | XIM_MODE_STS_GET), 1795 (XIM_MODE_STS_ONCE | XIM_MODE_STS_GET), 1796 0}, 1797 {OFFSET_XNFOCUSWINDOW, 1798 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1799 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1800 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1801 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1802 0, 1803 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 1804 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 1805 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 1806 0}, 1807 {OFFSET_XNRESOURCENAME, 1808 0, 1809 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1810 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1811 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1812 0, 1813 0, 1814 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 1815 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 1816 0}, 1817 {OFFSET_XNRESOURCECLASS, 1818 0, 1819 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1820 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1821 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1822 0, 1823 0, 1824 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 1825 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 1826 0}, 1827 {OFFSET_XNGEOMETRYCALLBACK, 1828 0, 1829 0, 1830 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1831 0, 1832 0, 1833 0, 1834 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 1835 0, 1836 0}, 1837 {OFFSET_XNFILTEREVENTS, 1838 XIM_MODE_PRE_GET, 1839 XIM_MODE_PRE_GET, 1840 XIM_MODE_PRE_GET, 1841 XIM_MODE_PRE_GET, 1842 0, 1843 XIM_MODE_STS_GET, 1844 XIM_MODE_STS_GET, 1845 XIM_MODE_STS_GET, 1846 XIM_MODE_STS_GET}, 1847 {OFFSET_XNDESTROYCALLBACK, 1848 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1849 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1850 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1851 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1852 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1853 0, 1854 0, 1855 0, 1856 0}, 1857 {OFFSET_XNSTRINGCONVERSIONCALLBACK, 1858 (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1859 (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1860 (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1861 (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1862 (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1863 0, 1864 0, 1865 0, 1866 0}, 1867 {OFFSET_XNSTRINGCONVERSION, 1868 XIM_MODE_PRE_SET, 1869 XIM_MODE_PRE_SET, 1870 XIM_MODE_PRE_SET, 1871 XIM_MODE_PRE_SET, 1872 XIM_MODE_PRE_SET, 1873 0, 1874 0, 1875 0, 1876 0}, 1877 {OFFSET_XNRESETSTATE, 1878 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1879 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1880 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1881 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1882 0, 1883 0, 1884 0, 1885 0, 1886 0}, 1887 {OFFSET_XNHOTKEY, 1888 (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1889 (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1890 (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1891 (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1892 0, 1893 0, 1894 0, 1895 0, 1896 0}, 1897 {OFFSET_XNHOTKEYSTATE, 1898 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1899 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1900 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1901 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1902 0, 1903 0, 1904 0, 1905 0, 1906 0}, 1907 {OFFSET_XNPREEDITATTRIBUTES, 1908 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1909 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1910 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1911 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1912 0, 1913 0, 1914 0, 1915 0, 1916 0}, 1917 {OFFSET_XNSTATUSATTRIBUTES, 1918 0, 1919 0, 1920 0, 1921 0, 1922 0, 1923 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 1924 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 1925 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 1926 0}, 1927 {OFFSET_XNAREA, 1928 0, 1929 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1930 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1931 0, 1932 0, 1933 0, 1934 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 1935 0, 1936 0}, 1937 {OFFSET_XNAREANEEDED, 1938 0, 1939 0, 1940 (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1941 0, 1942 0, 1943 0, 1944 (XIM_MODE_STS_SET | XIM_MODE_STS_GET), 1945 0, 1946 0}, 1947 {OFFSET_XNSPOTLOCATION, 1948 0, /*(XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),*/ 1949 (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1950 0, 1951 (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1952 (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1953 0, 1954 0, 1955 0, 1956 0}, 1957 {OFFSET_XNCOLORMAP, 1958 0, 1959 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1960 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1961 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1962 0, 1963 0, 1964 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 1965 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 1966 0}, 1967 {OFFSET_XNSTDCOLORMAP, 1968 0, 1969 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1970 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1971 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1972 0, 1973 0, 1974 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 1975 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 1976 0}, 1977 {OFFSET_XNFOREGROUND, 1978 0, 1979 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1980 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1981 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1982 0, 1983 0, 1984 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 1985 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 1986 0}, 1987 {OFFSET_XNBACKGROUND, 1988 0, 1989 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1990 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1991 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 1992 0, 1993 0, 1994 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 1995 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 1996 0}, 1997 {OFFSET_XNBACKGROUNDPIXMAP, 1998 0, 1999 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2000 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2001 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2002 0, 2003 0, 2004 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 2005 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 2006 0}, 2007 {OFFSET_XNFONTSET, 2008 0, 2009 (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2010 (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2011 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2012 0, 2013 0, 2014 (XIM_MODE_STS_CREATE | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 2015 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 2016 0}, 2017 {OFFSET_XNLINESPACE, 2018 0, 2019 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2020 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2021 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2022 0, 2023 0, 2024 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 2025 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 2026 0}, 2027 {OFFSET_XNCURSOR, 2028 0, 2029 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2030 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2031 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2032 0, 2033 0, 2034 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 2035 (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 2036 0}, 2037 {OFFSET_XNPREEDITSTARTCALLBACK, 2038 (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2039 0, 2040 0, 2041 0, 2042 0, 2043 0, 2044 0, 2045 0, 2046 0}, 2047 {OFFSET_XNPREEDITDONECALLBACK, 2048 (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2049 0, 2050 0, 2051 0, 2052 0, 2053 0, 2054 0, 2055 0, 2056 0}, 2057 {OFFSET_XNPREEDITDRAWCALLBACK, 2058 (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2059 0, 2060 0, 2061 0, 2062 0, 2063 0, 2064 0, 2065 0, 2066 0}, 2067 {OFFSET_XNPREEDITCARETCALLBACK, 2068 (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2069 0, 2070 0, 2071 0, 2072 0, 2073 0, 2074 0, 2075 0, 2076 0}, 2077 {OFFSET_XNPREEDITSTATE, 2078 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2079 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2080 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2081 (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2082 0, 2083 0, 2084 0, 2085 0, 2086 0}, 2087 {OFFSET_XNPREEDITSTATENOTIFYCALLBACK, 2088 (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2089 (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2090 (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2091 (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 2092 0, 2093 0, 2094 0, 2095 0, 2096 0}, 2097 {OFFSET_XNSTATUSSTARTCALLBACK, 2098 0, 2099 0, 2100 0, 2101 0, 2102 0, 2103 (XIM_MODE_STS_CREATE | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 2104 0, 2105 0, 2106 0}, 2107 {OFFSET_XNSTATUSDONECALLBACK, 2108 0, 2109 0, 2110 0, 2111 0, 2112 0, 2113 (XIM_MODE_STS_CREATE | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 2114 0, 2115 0, 2116 0}, 2117 {OFFSET_XNSTATUSDRAWCALLBACK, 2118 0, 2119 0, 2120 0, 2121 0, 2122 0, 2123 (XIM_MODE_STS_CREATE | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 2124 0, 2125 0, 2126 0} 2127}; 2128 2129/* the quarks are separated from im_mode/ic_mode so those arrays 2130 * can be const. 2131 */ 2132static XrmQuark im_mode_quark[sizeof(im_mode) / sizeof(im_mode[0])]; 2133static XrmQuark ic_mode_quark[sizeof(ic_mode) / sizeof(ic_mode[0])]; 2134 2135Private Bool 2136_XimSetResourceList( 2137 XIMResourceList *res_list, 2138 unsigned int *list_num, 2139 XIMResourceList resource, 2140 unsigned int num_resource, 2141 unsigned short id) 2142{ 2143 register int i; 2144 int len; 2145 XIMResourceList res; 2146 2147 len = sizeof(XIMResource) * num_resource; 2148 if(!(res = (XIMResourceList)Xmalloc(len))) { 2149 return False; 2150 } 2151 bzero((char *)res, len); 2152 2153 for(i = 0; i < num_resource; i++, id++) { 2154 res[i] = resource[i]; 2155 res[i].id = id; 2156 } 2157 2158 _XIMCompileResourceList(res, num_resource); 2159 *res_list = res; 2160 *list_num = num_resource; 2161 return True; 2162} 2163 2164Public Bool 2165_XimSetIMResourceList( 2166 XIMResourceList *res_list, 2167 unsigned int *list_num) 2168{ 2169 return _XimSetResourceList(res_list, list_num, 2170 im_resources, XIMNumber(im_resources), 100); 2171} 2172 2173Public Bool 2174_XimSetICResourceList( 2175 XIMResourceList *res_list, 2176 unsigned int *list_num) 2177{ 2178 return _XimSetResourceList(res_list, list_num, 2179 ic_resources, XIMNumber(ic_resources), 200); 2180} 2181 2182Public Bool 2183_XimSetInnerIMResourceList( 2184 XIMResourceList *res_list, 2185 unsigned int *list_num) 2186{ 2187 return _XimSetResourceList(res_list, list_num, 2188 im_inner_resources, XIMNumber(im_inner_resources), 100); 2189} 2190 2191Public Bool 2192_XimSetInnerICResourceList( 2193 XIMResourceList *res_list, 2194 unsigned int *list_num) 2195{ 2196 return _XimSetResourceList(res_list, list_num, 2197 ic_inner_resources, XIMNumber(ic_inner_resources), 200); 2198} 2199 2200Private XIMResourceList 2201_XimGetResourceListRecByMode( 2202 XIMResourceList res_list, 2203 unsigned int list_num, 2204 unsigned short mode) 2205{ 2206 register int i; 2207 2208 for(i = 0; i < list_num; i++) { 2209 if (res_list[i].mode & mode) { 2210 return (XIMResourceList)&res_list[i]; 2211 } 2212 } 2213 return (XIMResourceList)NULL; 2214} 2215 2216Public Bool 2217_XimCheckCreateICValues( 2218 XIMResourceList res_list, 2219 unsigned int list_num) 2220{ 2221 if (!_XimGetResourceListRecByMode(res_list, list_num, XIM_MODE_IC_CREATE)) { 2222 return True; 2223 } 2224 return False; 2225} 2226 2227Public XIMResourceList 2228_XimGetResourceListRecByQuark( 2229 XIMResourceList res_list, 2230 unsigned int list_num, 2231 XrmQuark quark) 2232{ 2233 register int i; 2234 2235 for(i = 0; i < list_num; i++) { 2236 if (res_list[i].xrm_name == quark) { 2237 return (XIMResourceList)&res_list[i]; 2238 } 2239 } 2240 return (XIMResourceList)NULL; 2241} 2242 2243Public XIMResourceList 2244_XimGetResourceListRec( 2245 XIMResourceList res_list, 2246 unsigned int list_num, 2247 const char *name) 2248{ 2249 XrmQuark quark = XrmStringToQuark(name); 2250 2251 return _XimGetResourceListRecByQuark(res_list, list_num, quark); 2252} 2253 2254Public char * 2255_XimSetIMValueData( 2256 Xim im, 2257 XPointer top, 2258 XIMArg *values, 2259 XIMResourceList res_list, 2260 unsigned int list_num) 2261{ 2262 register XIMArg *p; 2263 XIMResourceList res; 2264 int check; 2265 2266 for(p = values; p->name != NULL; p++) { 2267 if(!(res = _XimGetResourceListRec(res_list, list_num, p->name))) { 2268 return p->value; 2269 } 2270 check = _XimCheckIMMode(res, XIM_SETIMVALUES); 2271 if(check == XIM_CHECK_INVALID) { 2272 continue; 2273 } else if (check == XIM_CHECK_ERROR) { 2274 return p->value; 2275 } 2276 2277 if(!_XimEncodeLocalIMAttr(res, top, p->value)) { 2278 return p->value; 2279 } 2280 } 2281 return NULL; 2282} 2283 2284Public char * 2285_XimGetIMValueData( 2286 Xim im, 2287 XPointer top, 2288 XIMArg *values, 2289 XIMResourceList res_list, 2290 unsigned int list_num) 2291{ 2292 register XIMArg *p; 2293 XIMResourceList res; 2294 int check; 2295 2296 for(p = values; p->name != NULL; p++) { 2297 if(!(res = _XimGetResourceListRec(res_list, list_num, p->name))) { 2298 return p->value; 2299 } 2300 check = _XimCheckIMMode(res, XIM_GETIMVALUES); 2301 if(check == XIM_CHECK_INVALID) { 2302 continue; 2303 } else if (check == XIM_CHECK_ERROR) { 2304 return p->value; 2305 } 2306 2307 if(!_XimDecodeLocalIMAttr(res, top, p->value)) { 2308 return p->value; 2309 } 2310 } 2311 return NULL; 2312} 2313 2314Public void 2315_XimSetIMMode( 2316 XIMResourceList res_list, 2317 unsigned int list_num) 2318{ 2319 XIMResourceList res; 2320 unsigned int n = XIMNumber(im_mode); 2321 register int i; 2322 2323 for(i = 0; i < n; i++) { 2324 if(!(res = _XimGetResourceListRecByQuark(res_list, 2325 list_num, im_mode_quark[i]))) { 2326 continue; 2327 } 2328 res->mode = im_mode[i].mode; 2329 } 2330 return; 2331} 2332 2333Private int 2334_XimCheckSetIMDefaultsMode( 2335 XIMResourceList res) 2336{ 2337 if(res->mode & XIM_MODE_IM_DEFAULT) { 2338 return XIM_CHECK_VALID; 2339 } 2340 return XIM_CHECK_INVALID; 2341} 2342 2343Private int 2344_XimCheckSetIMValuesMode( 2345 XIMResourceList res) 2346{ 2347 if(res->mode & XIM_MODE_IM_SET) { 2348 return XIM_CHECK_VALID; 2349 } 2350 return XIM_CHECK_INVALID; 2351} 2352 2353Private int 2354 _XimCheckGetIMValuesMode( 2355 XIMResourceList res) 2356{ 2357 if(res->mode & XIM_MODE_IM_GET) { 2358 return XIM_CHECK_VALID; 2359 } 2360 return XIM_CHECK_INVALID; 2361} 2362 2363Public int 2364 _XimCheckIMMode( 2365 XIMResourceList res, 2366 unsigned long mode) 2367{ 2368 if(res->mode == 0) { 2369 return XIM_CHECK_INVALID; 2370 } 2371 if(mode & XIM_SETIMDEFAULTS) { 2372 return _XimCheckSetIMDefaultsMode(res); 2373 } else if (mode & XIM_SETIMVALUES) { 2374 return _XimCheckSetIMValuesMode(res); 2375 } else if (mode & XIM_GETIMVALUES) { 2376 return _XimCheckGetIMValuesMode(res); 2377 } else { 2378 return XIM_CHECK_ERROR; 2379 } 2380} 2381 2382Public void 2383_XimSetICMode(XIMResourceList res_list, unsigned int list_num, XIMStyle style) 2384{ 2385 XIMResourceList res; 2386 unsigned int n = XIMNumber(ic_mode); 2387 register int i; 2388 unsigned int pre_offset; 2389 unsigned int sts_offset; 2390 2391 if(style & XIMPreeditArea) { 2392 pre_offset = XOffsetOf(XimICMode, preedit_area_mode); 2393 } else if(style & XIMPreeditCallbacks) { 2394 pre_offset = XOffsetOf(XimICMode, preedit_callback_mode); 2395 } else if(style & XIMPreeditPosition) { 2396 pre_offset = XOffsetOf(XimICMode, preedit_position_mode); 2397 } else if(style & XIMPreeditNothing) { 2398 pre_offset = XOffsetOf(XimICMode, preedit_nothing_mode); 2399 } else { 2400 pre_offset = XOffsetOf(XimICMode, preedit_none_mode); 2401 } 2402 2403 if(style & XIMStatusArea) { 2404 sts_offset = XOffsetOf(XimICMode, status_area_mode); 2405 } else if(style & XIMStatusCallbacks) { 2406 sts_offset = XOffsetOf(XimICMode, status_callback_mode); 2407 } else if(style & XIMStatusNothing) { 2408 sts_offset = XOffsetOf(XimICMode, status_nothing_mode); 2409 } else { 2410 sts_offset = XOffsetOf(XimICMode, status_none_mode); 2411 } 2412 2413 for(i = 0; i < n; i++) { 2414 if(!(res = _XimGetResourceListRecByQuark(res_list, 2415 list_num, ic_mode_quark[i]))) { 2416 continue; 2417 } 2418 res->mode = ( (*(unsigned short *)((char *)&ic_mode[i] + pre_offset)) 2419 | (*(unsigned short *)((char *)&ic_mode[i] + sts_offset))); 2420 } 2421 return; 2422} 2423 2424Private int 2425_XimCheckSetICDefaultsMode( 2426 XIMResourceList res, 2427 unsigned long mode) 2428{ 2429 if(mode & XIM_PREEDIT_ATTR) { 2430 if(!(res->mode & XIM_MODE_PRE_MASK)) { 2431 return XIM_CHECK_INVALID; 2432 } 2433 2434 if(res->mode & XIM_MODE_PRE_CREATE) { 2435 return XIM_CHECK_ERROR; 2436 } else if (!(res->mode & XIM_MODE_PRE_DEFAULT)) { 2437 return XIM_CHECK_INVALID; 2438 } 2439 2440 } else if(mode & XIM_STATUS_ATTR) { 2441 if(!(res->mode & XIM_MODE_STS_MASK)) { 2442 return XIM_CHECK_INVALID; 2443 } 2444 2445 if(res->mode & XIM_MODE_STS_CREATE) { 2446 return XIM_CHECK_ERROR; 2447 } 2448 if(!(res->mode & XIM_MODE_STS_DEFAULT)) { 2449 return XIM_CHECK_INVALID; 2450 } 2451 2452 } else { 2453 if(!res->mode) { 2454 return XIM_CHECK_INVALID; 2455 } 2456 2457 if(res->mode & XIM_MODE_IC_CREATE) { 2458 return XIM_CHECK_ERROR; 2459 } 2460 if(!(res->mode & XIM_MODE_IC_DEFAULT)) { 2461 return XIM_CHECK_INVALID; 2462 } 2463 } 2464 return XIM_CHECK_VALID; 2465} 2466 2467Private int 2468_XimCheckCreateICMode( 2469 XIMResourceList res, 2470 unsigned long mode) 2471{ 2472 if(mode & XIM_PREEDIT_ATTR) { 2473 if(!(res->mode & XIM_MODE_PRE_MASK)) { 2474 return XIM_CHECK_INVALID; 2475 } 2476 2477 if(res->mode & XIM_MODE_PRE_CREATE) { 2478 res->mode &= ~XIM_MODE_PRE_CREATE; 2479 } else if(res->mode & XIM_MODE_PRE_ONCE) { 2480 res->mode &= ~XIM_MODE_PRE_ONCE; 2481 } else if(res->mode & XIM_MODE_PRE_DEFAULT) { 2482 res->mode &= ~XIM_MODE_PRE_DEFAULT; 2483 } else if (!(res->mode & XIM_MODE_PRE_SET)) { 2484 return XIM_CHECK_ERROR; 2485 } 2486 2487 } else if(mode & XIM_STATUS_ATTR) { 2488 if(!(res->mode & XIM_MODE_STS_MASK)) { 2489 return XIM_CHECK_INVALID; 2490 } 2491 2492 if(res->mode & XIM_MODE_STS_CREATE) { 2493 res->mode &= ~XIM_MODE_STS_CREATE; 2494 } else if(res->mode & XIM_MODE_STS_ONCE) { 2495 res->mode &= ~XIM_MODE_STS_ONCE; 2496 } else if(res->mode & XIM_MODE_STS_DEFAULT) { 2497 res->mode &= ~XIM_MODE_STS_DEFAULT; 2498 } else if (!(res->mode & XIM_MODE_STS_SET)) { 2499 return XIM_CHECK_ERROR; 2500 } 2501 2502 } else { 2503 if(!res->mode) { 2504 return XIM_CHECK_INVALID; 2505 } 2506 2507 if(res->mode & XIM_MODE_IC_CREATE) { 2508 res->mode &= ~XIM_MODE_IC_CREATE; 2509 } else if(res->mode & XIM_MODE_IC_ONCE) { 2510 res->mode &= ~XIM_MODE_IC_ONCE; 2511 } else if(res->mode & XIM_MODE_IC_DEFAULT) { 2512 res->mode &= ~XIM_MODE_IC_DEFAULT; 2513 } else if (!(res->mode & XIM_MODE_IC_SET)) { 2514 return XIM_CHECK_ERROR; 2515 } 2516 } 2517 return XIM_CHECK_VALID; 2518} 2519 2520Private int 2521_XimCheckSetICValuesMode( 2522 XIMResourceList res, 2523 unsigned long mode) 2524{ 2525 if(mode & XIM_PREEDIT_ATTR) { 2526 if(!(res->mode & XIM_MODE_PRE_MASK)) { 2527 return XIM_CHECK_INVALID; 2528 } 2529 2530 if(res->mode & XIM_MODE_PRE_ONCE) { 2531 res->mode &= ~XIM_MODE_PRE_ONCE; 2532 } else if(!(res->mode & XIM_MODE_PRE_SET)) { 2533 return XIM_CHECK_ERROR; 2534 } 2535 2536 } else if(mode & XIM_STATUS_ATTR) { 2537 if(!(res->mode & XIM_MODE_STS_MASK)) { 2538 return XIM_CHECK_INVALID; 2539 } 2540 2541 if(res->mode & XIM_MODE_STS_ONCE) { 2542 res->mode &= ~XIM_MODE_STS_ONCE; 2543 } else if(!(res->mode & XIM_MODE_STS_SET)) { 2544 return XIM_CHECK_ERROR; 2545 } 2546 2547 } else { 2548 if(!res->mode) { 2549 return XIM_CHECK_INVALID; 2550 } 2551 2552 if(res->mode & XIM_MODE_IC_ONCE) { 2553 res->mode &= ~XIM_MODE_IC_ONCE; 2554 } else if(!(res->mode & XIM_MODE_IC_SET)) { 2555 return XIM_CHECK_ERROR; 2556 } 2557 } 2558 return XIM_CHECK_VALID; 2559} 2560 2561Private int 2562_XimCheckGetICValuesMode( 2563 XIMResourceList res, 2564 unsigned long mode) 2565{ 2566 if(mode & XIM_PREEDIT_ATTR) { 2567 if(!(res->mode & XIM_MODE_PRE_MASK)) { 2568 return XIM_CHECK_INVALID; 2569 } 2570 2571 if(!(res->mode & XIM_MODE_PRE_GET)) { 2572 return XIM_CHECK_ERROR; 2573 } 2574 2575 } else if(mode & XIM_STATUS_ATTR) { 2576 if(!(res->mode & XIM_MODE_STS_MASK)) { 2577 return XIM_CHECK_INVALID; 2578 } 2579 2580 if(!(res->mode & XIM_MODE_STS_GET)) { 2581 return XIM_CHECK_ERROR; 2582 } 2583 2584 } else { 2585 if(!res->mode) { 2586 return XIM_CHECK_INVALID; 2587 } 2588 2589 if(!(res->mode & XIM_MODE_IC_GET)) { 2590 return XIM_CHECK_ERROR; 2591 } 2592 } 2593 return XIM_CHECK_VALID; 2594} 2595 2596Public int 2597 _XimCheckICMode( 2598 XIMResourceList res, 2599 unsigned long mode) 2600{ 2601 if(mode &XIM_SETICDEFAULTS) { 2602 return _XimCheckSetICDefaultsMode(res, mode); 2603 } else if (mode & XIM_CREATEIC) { 2604 return _XimCheckCreateICMode(res, mode); 2605 } else if (mode & XIM_SETICVALUES) { 2606 return _XimCheckSetICValuesMode(res, mode); 2607 } else if (mode & XIM_GETICVALUES) { 2608 return _XimCheckGetICValuesMode(res, mode); 2609 } else { 2610 return XIM_CHECK_ERROR; 2611 } 2612} 2613 2614Public Bool 2615_XimSetLocalIMDefaults( 2616 Xim im, 2617 XPointer top, 2618 XIMResourceList res_list, 2619 unsigned int list_num) 2620{ 2621 XimValueOffsetInfo info; 2622 unsigned int num; 2623 register int i; 2624 XIMResourceList res; 2625 int check; 2626 2627 info = im_attr_info; 2628 num = XIMNumber(im_attr_info); 2629 2630 for(i = 0; i < num; i++) { 2631 if((res = _XimGetResourceListRecByQuark( res_list, list_num, 2632 info[i].quark)) == (XIMResourceList)NULL) { 2633 return False; 2634 } 2635 2636 check = _XimCheckIMMode(res, XIM_SETIMDEFAULTS); 2637 if(check == XIM_CHECK_INVALID) { 2638 continue; 2639 } else if (check == XIM_CHECK_ERROR) { 2640 return False; 2641 } 2642 2643 if(!info[i].defaults) { 2644 continue; 2645 } 2646 if(!(info[i].defaults(&info[i], top, (XPointer)NULL, 0))) { 2647 return False; 2648 } 2649 } 2650 return True; 2651} 2652 2653Public Bool 2654_XimSetICDefaults( 2655 Xic ic, 2656 XPointer top, 2657 unsigned long mode, 2658 XIMResourceList res_list, 2659 unsigned int list_num) 2660{ 2661 unsigned int num; 2662 XimValueOffsetInfo info; 2663 register int i; 2664 XIMResourceList res; 2665 int check; 2666 XrmQuark pre_quark; 2667 XrmQuark sts_quark; 2668 2669 pre_quark = XrmStringToQuark(XNPreeditAttributes); 2670 sts_quark = XrmStringToQuark(XNStatusAttributes); 2671 2672 if(mode & XIM_PREEDIT_ATTR) { 2673 info = ic_pre_attr_info; 2674 num = XIMNumber(ic_pre_attr_info); 2675 } else if(mode & XIM_STATUS_ATTR) { 2676 info = ic_sts_attr_info; 2677 num = XIMNumber(ic_sts_attr_info); 2678 } else { 2679 info = ic_attr_info; 2680 num = XIMNumber(ic_attr_info); 2681 } 2682 2683 for(i = 0; i < num; i++) { 2684 if(info[i].quark == pre_quark) { 2685 if(!_XimSetICDefaults(ic, (XPointer)((char *)top + info[i].offset), 2686 (mode | XIM_PREEDIT_ATTR), res_list, list_num)) { 2687 return False; 2688 } 2689 } else if (info[i].quark == sts_quark) { 2690 if(!_XimSetICDefaults(ic, (XPointer)((char *)top + info[i].offset), 2691 (mode | XIM_STATUS_ATTR), res_list, list_num)) { 2692 return False; 2693 } 2694 } else { 2695 if(!(res = _XimGetResourceListRecByQuark(res_list, list_num, 2696 info[i].quark))) { 2697 return False; 2698 } 2699 2700 check = _XimCheckICMode(res, mode); 2701 if (check == XIM_CHECK_INVALID) { 2702 continue; 2703 } else if (check == XIM_CHECK_ERROR) { 2704 return False; 2705 } 2706 2707 if (!info[i].defaults) { 2708 continue; 2709 } 2710 if (!(info[i].defaults(&info[i], top, (XPointer)ic, mode))) { 2711 return False; 2712 } 2713 } 2714 } 2715 return True; 2716} 2717 2718Private Bool 2719_XimEncodeAttr( 2720 XimValueOffsetInfo info, 2721 unsigned int num, 2722 XIMResourceList res, 2723 XPointer top, 2724 XPointer val) 2725{ 2726 register int i; 2727 2728 for(i = 0; i < num; i++ ) { 2729 if(info[i].quark == res->xrm_name) { 2730 if(!info[i].encode) { 2731 return False; 2732 } 2733 return (*info[i].encode)(&info[i], top, val); 2734 } 2735 } 2736 return False; 2737} 2738 2739Public Bool 2740_XimEncodeLocalIMAttr( 2741 XIMResourceList res, 2742 XPointer top, 2743 XPointer val) 2744{ 2745 return _XimEncodeAttr(im_attr_info, XIMNumber(im_attr_info), 2746 res, top, val); 2747} 2748 2749Public Bool 2750_XimEncodeLocalICAttr( 2751 Xic ic, 2752 XIMResourceList res, 2753 XPointer top, 2754 XIMArg *arg, 2755 unsigned long mode) 2756{ 2757 unsigned int num; 2758 XimValueOffsetInfo info; 2759 2760 if(mode & XIM_PREEDIT_ATTR) { 2761 info = ic_pre_attr_info; 2762 num = XIMNumber(ic_pre_attr_info); 2763 } else if(mode & XIM_STATUS_ATTR) { 2764 info = ic_sts_attr_info; 2765 num = XIMNumber(ic_sts_attr_info); 2766 } else { 2767 info = ic_attr_info; 2768 num = XIMNumber(ic_attr_info); 2769 } 2770 2771 return _XimEncodeAttr(info, num, res, top, arg->value); 2772} 2773 2774Private Bool 2775_XimEncodeLocalTopValue( 2776 Xic ic, 2777 XIMResourceList res, 2778 XPointer val, 2779 Bool flag) 2780{ 2781 XIMArg *p = (XIMArg *)val; 2782 2783 if (res->xrm_name == XrmStringToQuark(XNClientWindow)) { 2784 ic->core.client_window = (Window)p->value; 2785 if (ic->core.focus_window == (Window)0) 2786 ic->core.focus_window = ic->core.client_window; 2787 if (flag) { 2788 _XRegisterFilterByType(ic->core.im->core.display, 2789 ic->core.focus_window, 2790 KeyPress, KeyRelease, _XimLocalFilter, (XPointer)ic); 2791 } 2792 } else if (res->xrm_name == XrmStringToQuark(XNFocusWindow)) { 2793 if (ic->core.client_window) { 2794 if (flag) { 2795 _XUnregisterFilter(ic->core.im->core.display, 2796 ic->core.focus_window, _XimLocalFilter, (XPointer)ic); 2797 } 2798 ic->core.focus_window = (Window)p->value; 2799 if (flag) { 2800 _XRegisterFilterByType(ic->core.im->core.display, 2801 ic->core.focus_window, KeyPress, KeyRelease, 2802 _XimLocalFilter, (XPointer)ic); 2803 } 2804 } else 2805 ic->core.focus_window = (Window)p->value; 2806 } 2807 return True; 2808} 2809 2810Private Bool 2811_XimEncodeLocalPreeditValue( 2812 Xic ic, 2813 XIMResourceList res, 2814 XPointer val) 2815{ 2816 XIMArg *p = (XIMArg *)val; 2817 2818 if (res->xrm_name == XrmStringToQuark(XNStdColormap)) { 2819 XStandardColormap *colormap_ret; 2820 int count; 2821 2822 if (!(XGetRGBColormaps(ic->core.im->core.display, 2823 ic->core.focus_window, &colormap_ret, 2824 &count, (Atom)p->value))) 2825 return False; 2826 } 2827 return True; 2828} 2829 2830Private Bool 2831_XimEncodeLocalStatusValue( 2832 Xic ic, 2833 XIMResourceList res, 2834 XPointer val) 2835{ 2836 XIMArg *p = (XIMArg *)val; 2837 2838 if (res->xrm_name == XrmStringToQuark(XNStdColormap)) { 2839 XStandardColormap *colormap_ret; 2840 int count; 2841 2842 if (!(XGetRGBColormaps(ic->core.im->core.display, 2843 ic->core.focus_window, &colormap_ret, 2844 &count, (Atom)p->value))) 2845 return False; 2846 } 2847 return True; 2848} 2849 2850Public char * 2851_XimSetICValueData( 2852 Xic ic, 2853 XPointer top, 2854 XIMResourceList res_list, 2855 unsigned int list_num, 2856 XIMArg *values, 2857 unsigned long mode, 2858 Bool flag) 2859{ 2860 register XIMArg *p; 2861 XIMResourceList res; 2862 char *name; 2863 int check; 2864 XrmQuark pre_quark; 2865 XrmQuark sts_quark; 2866 2867 pre_quark = XrmStringToQuark(XNPreeditAttributes); 2868 sts_quark = XrmStringToQuark(XNStatusAttributes); 2869 2870 for(p = values; p->name != NULL; p++) { 2871 if((res = _XimGetResourceListRec(res_list, list_num, 2872 p->name)) == (XIMResourceList)NULL) { 2873 return p->name; 2874 } 2875 if(res->xrm_name == pre_quark) { 2876 if(((name = _XimSetICValueData(ic, 2877 (XPointer)(&((XimDefICValues *)top)->preedit_attr), 2878 res_list, list_num, (XIMArg *)p->value, 2879 (mode | XIM_PREEDIT_ATTR), flag)))) { 2880 return name; 2881 } 2882 } else if(res->xrm_name == sts_quark) { 2883 if(((name = _XimSetICValueData(ic, 2884 (XPointer)(&((XimDefICValues *)top)->status_attr), 2885 res_list, list_num, (XIMArg *)p->value, 2886 (mode | XIM_STATUS_ATTR), flag)))) { 2887 return name; 2888 } 2889 } else { 2890 check = _XimCheckICMode(res, mode); 2891 if(check == XIM_CHECK_INVALID) { 2892 continue; 2893 } else if(check == XIM_CHECK_ERROR) { 2894 return p->name; 2895 } 2896 2897 if(mode & XIM_PREEDIT_ATTR) { 2898 if (!_XimEncodeLocalPreeditValue(ic, res, (XPointer)p)) 2899 return False; 2900 } else if(mode & XIM_STATUS_ATTR) { 2901 if (!_XimEncodeLocalStatusValue(ic, res, (XPointer)p)) 2902 return False; 2903 } else { 2904 if (!_XimEncodeLocalTopValue(ic, res, (XPointer)p, flag)) 2905 return False; 2906 } 2907 if(_XimEncodeLocalICAttr(ic, res, top, p, mode) == False) { 2908 return p->name; 2909 } 2910 } 2911 } 2912 return NULL; 2913} 2914 2915Private Bool 2916_XimCheckInputStyle( 2917 XIMStyles *styles, 2918 XIMStyle style) 2919{ 2920 int num = styles->count_styles; 2921 register int i; 2922 2923 for(i = 0; i < num; i++) { 2924 if(styles->supported_styles[i] == style) { 2925 return True; 2926 } 2927 } 2928 return False; 2929} 2930 2931Public Bool 2932_XimCheckLocalInputStyle( 2933 Xic ic, 2934 XPointer top, 2935 XIMArg *values, 2936 XIMStyles *styles, 2937 XIMResourceList res_list, 2938 unsigned int list_num) 2939{ 2940 XrmQuark quark = XrmStringToQuark(XNInputStyle); 2941 register XIMArg *p; 2942 XIMResourceList res; 2943 2944 for(p = values; p && p->name != NULL; p++) { 2945 if(quark == XrmStringToQuark(p->name)) { 2946 if(!(res = _XimGetResourceListRec(res_list, list_num, p->name))) { 2947 return False; 2948 } 2949 if(!_XimEncodeLocalICAttr(ic, res, top, p, 0)) { 2950 return False; 2951 } 2952 if (_XimCheckInputStyle(styles, 2953 ((XimDefICValues *)top)->input_style)) { 2954 return True; 2955 } 2956 return False; 2957 } 2958 } 2959 return False; 2960} 2961 2962Private Bool 2963_XimDecodeAttr( 2964 XimValueOffsetInfo info, 2965 unsigned int num, 2966 XIMResourceList res, 2967 XPointer top, 2968 XPointer val) 2969{ 2970 register int i; 2971 2972 for(i = 0; i < num; i++ ) { 2973 if(info[i].quark == res->xrm_name) { 2974 if(!info[i].decode) { 2975 return False; 2976 } 2977 return (*info[i].decode)(&info[i], top, val); 2978 } 2979 } 2980 return False; 2981} 2982 2983Public Bool 2984_XimDecodeLocalIMAttr( 2985 XIMResourceList res, 2986 XPointer top, 2987 XPointer val) 2988{ 2989 return _XimDecodeAttr(im_attr_info, XIMNumber(im_attr_info), 2990 res, top, val); 2991} 2992 2993Public Bool 2994_XimDecodeLocalICAttr( 2995 XIMResourceList res, 2996 XPointer top, 2997 XPointer val, 2998 unsigned long mode) 2999{ 3000 unsigned int num; 3001 XimValueOffsetInfo info; 3002 3003 if(mode & XIM_PREEDIT_ATTR) { 3004 info = ic_pre_attr_info; 3005 num = XIMNumber(ic_pre_attr_info); 3006 } else if(mode & XIM_STATUS_ATTR) { 3007 info = ic_sts_attr_info; 3008 num = XIMNumber(ic_sts_attr_info); 3009 } else { 3010 info = ic_attr_info; 3011 num = XIMNumber(ic_attr_info); 3012 } 3013 3014 return _XimDecodeAttr(info, num, res, top, val); 3015} 3016 3017Public char * 3018_XimGetICValueData(Xic ic, XPointer top, XIMResourceList res_list, 3019 unsigned int list_num, XIMArg *values, unsigned long mode) 3020{ 3021 register XIMArg *p; 3022 XIMResourceList res; 3023 char *name; 3024 int check; 3025 XrmQuark pre_quark; 3026 XrmQuark sts_quark; 3027 3028 pre_quark = XrmStringToQuark(XNPreeditAttributes); 3029 sts_quark = XrmStringToQuark(XNStatusAttributes); 3030 3031 for(p = values; p->name != NULL; p++) { 3032 if((res = _XimGetResourceListRec(res_list, list_num, 3033 p->name)) == (XIMResourceList)NULL) { 3034 return p->name; 3035 } 3036 if(res->xrm_name == pre_quark) { 3037 if((name = _XimGetICValueData(ic, 3038 (XPointer)(&((XimDefICValues *)top)->preedit_attr), 3039 res_list, list_num, (XIMArg *)p->value, 3040 (mode | XIM_PREEDIT_ATTR)))) { 3041 return name; 3042 } 3043 } else if(res->xrm_name == sts_quark) { 3044 if((name = _XimGetICValueData(ic, 3045 (XPointer)(&((XimDefICValues *)top)->status_attr), 3046 res_list, list_num, (XIMArg *)p->value, 3047 (mode | XIM_STATUS_ATTR)))) { 3048 return name; 3049 } 3050 } else { 3051 check = _XimCheckICMode(res, mode); 3052 if(check == XIM_CHECK_INVALID) { 3053 continue; 3054 } else if(check == XIM_CHECK_ERROR) { 3055 return p->name; 3056 } 3057 3058 if(_XimDecodeLocalICAttr(res, top, p->value, mode) == False) { 3059 return p->name; 3060 } 3061 } 3062 } 3063 return NULL; 3064} 3065 3066Public void 3067_XimGetCurrentIMValues(Xim im, XimDefIMValues *im_values) 3068{ 3069 bzero((char *)im_values, sizeof(XimDefIMValues)); 3070 3071 im_values->styles = im->core.styles; 3072 im_values->im_values_list = im->core.im_values_list; 3073 im_values->ic_values_list = im->core.ic_values_list; 3074 im_values->destroy_callback = im->core.destroy_callback; 3075 im_values->res_name = im->core.res_name; 3076 im_values->res_class = im->core.res_class; 3077 im_values->visible_position = im->core.visible_position; 3078} 3079 3080Public void 3081_XimSetCurrentIMValues(Xim im, XimDefIMValues *im_values) 3082{ 3083 im->core.styles = im_values->styles; 3084 im->core.im_values_list = im_values->im_values_list; 3085 im->core.ic_values_list = im_values->ic_values_list; 3086 im->core.destroy_callback = im_values->destroy_callback; 3087 im->core.res_name = im_values->res_name; 3088 im->core.res_class = im_values->res_class; 3089 im->core.visible_position = im_values->visible_position; 3090} 3091 3092Public void 3093_XimGetCurrentICValues(Xic ic, XimDefICValues *ic_values) 3094{ 3095 bzero((char *)ic_values, sizeof(XimDefICValues)); 3096 3097 ic_values->input_style = ic->core.input_style; 3098 ic_values->client_window = ic->core.client_window; 3099 ic_values->focus_window = ic->core.focus_window; 3100 ic_values->filter_events = ic->core.filter_events; 3101 ic_values->geometry_callback = ic->core.geometry_callback; 3102 ic_values->res_name = ic->core.res_name; 3103 ic_values->res_class = ic->core.res_class; 3104 ic_values->destroy_callback = ic->core.destroy_callback; 3105 ic_values->string_conversion_callback 3106 = ic->core.string_conversion_callback; 3107 ic_values->string_conversion = ic->core.string_conversion; 3108 ic_values->reset_state = ic->core.reset_state; 3109 ic_values->hotkey = ic->core.hotkey; 3110 ic_values->hotkey_state = ic->core.hotkey_state; 3111 ic_values->preedit_attr = ic->core.preedit_attr; 3112 ic_values->status_attr = ic->core.status_attr; 3113} 3114 3115Public void 3116_XimSetCurrentICValues( 3117 Xic ic, 3118 XimDefICValues *ic_values) 3119{ 3120 ic->core.input_style = ic_values->input_style; 3121 ic->core.client_window = ic_values->client_window; 3122 if (ic_values->focus_window) 3123 ic->core.focus_window = ic_values->focus_window; 3124 ic->core.filter_events = ic_values->filter_events; 3125 ic->core.geometry_callback = ic_values->geometry_callback; 3126 ic->core.res_name = ic_values->res_name; 3127 ic->core.res_class = ic_values->res_class; 3128 ic->core.destroy_callback = ic_values->destroy_callback; 3129 ic->core.string_conversion_callback 3130 = ic_values->string_conversion_callback; 3131 ic->core.string_conversion = ic_values->string_conversion; 3132 ic->core.reset_state = ic_values->reset_state; 3133 ic->core.hotkey = ic_values->hotkey; 3134 ic->core.hotkey_state = ic_values->hotkey_state; 3135 ic->core.preedit_attr = ic_values->preedit_attr; 3136 ic->core.status_attr = ic_values->status_attr; 3137} 3138 3139Private void 3140_XimInitialIMOffsetInfo(void) 3141{ 3142 unsigned int n = XIMNumber(im_attr_info); 3143 register int i; 3144 3145 for(i = 0; i < n; i++) { 3146 im_attr_info[i].quark = XrmStringToQuark(GET_NAME(im_attr_info[i])); 3147 } 3148} 3149 3150Private void 3151_XimInitialICOffsetInfo(void) 3152{ 3153 unsigned int n; 3154 register int i; 3155 3156 n = XIMNumber(ic_attr_info); 3157 for(i = 0; i < n; i++) { 3158 ic_attr_info[i].quark = XrmStringToQuark(GET_NAME(ic_attr_info[i])); 3159 } 3160 3161 n = XIMNumber(ic_pre_attr_info); 3162 for(i = 0; i < n; i++) { 3163 ic_pre_attr_info[i].quark = XrmStringToQuark(GET_NAME(ic_pre_attr_info[i])); 3164 } 3165 3166 n = XIMNumber(ic_sts_attr_info); 3167 for(i = 0; i < n; i++) { 3168 ic_sts_attr_info[i].quark = XrmStringToQuark(GET_NAME(ic_sts_attr_info[i])); 3169 } 3170} 3171 3172Private void 3173_XimInitialIMMode(void) 3174{ 3175 unsigned int n = XIMNumber(im_mode); 3176 register int i; 3177 3178 for(i = 0; i < n; i++) { 3179 im_mode_quark[i] = XrmStringToQuark(GET_NAME(im_mode[i])); 3180 } 3181} 3182 3183Private void 3184_XimInitialICMode(void) 3185{ 3186 unsigned int n = XIMNumber(ic_mode); 3187 register int i; 3188 3189 for(i = 0; i < n; i++) { 3190 ic_mode_quark[i] = XrmStringToQuark(GET_NAME(ic_mode[i])); 3191 } 3192} 3193 3194Public void 3195_XimInitialResourceInfo(void) 3196{ 3197 static Bool init_flag = False; 3198 3199 if(init_flag == True) { 3200 return; 3201 } 3202 _XimInitialIMOffsetInfo(); 3203 _XimInitialICOffsetInfo(); 3204 _XimInitialIMMode(); 3205 _XimInitialICMode(); 3206 init_flag = True; 3207} 3208