1 /******************************************************************
3 Copyright 1994, 1995 by Sun Microsystems, Inc.
4 Copyright 1993, 1994 by Hewlett-Packard Company
6 Permission to use, copy, modify, distribute, and sell this software
7 and its documentation for any purpose is hereby granted without fee,
8 provided that the above copyright notice appear in all copies and
9 that both that copyright notice and this permission notice appear
10 in supporting documentation, and that the name of Sun Microsystems, Inc.
11 and Hewlett-Packard not be used in advertising or publicity pertaining to
12 distribution of the software without specific, written prior permission.
13 Sun Microsystems, Inc. and Hewlett-Packard make no representations about
14 the suitability of this software for any purpose. It is provided "as is"
15 without express or implied warranty.
17 SUN MICROSYSTEMS INC. AND HEWLETT-PACKARD COMPANY DISCLAIMS ALL
18 WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
20 SUN MICROSYSTEMS, INC. AND HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY
21 SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
22 RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
23 CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
24 IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26 Author: Hidetoshi Tajima(tajima@Eng.Sun.COM) Sun Microsystems, Inc.
28 This version tidied and debugged by Steve Underwood May 1999
30 ******************************************************************/
33 #include <X11/Xresource.h>
51 IMListOfAttr Default_IMattr[] =
53 {XNQueryInputStyle, XimType_XIMStyles},
54 /* {XNQueryIMValuesList, XimType_XIMValuesList}, */
55 {(char *) NULL, (CARD16) 0}
58 IMListOfAttr Default_ICattr[] =
60 {XNInputStyle, XimType_CARD32},
61 {XNClientWindow, XimType_Window},
62 {XNFocusWindow, XimType_Window},
63 {XNFilterEvents, XimType_CARD32},
64 {XNPreeditAttributes, XimType_NEST},
65 {XNStatusAttributes, XimType_NEST},
66 {XNFontSet, XimType_XFontSet},
67 {XNArea, XimType_XRectangle},
68 {XNAreaNeeded, XimType_XRectangle},
69 {XNColormap, XimType_CARD32},
70 {XNStdColormap, XimType_CARD32},
71 {XNForeground, XimType_CARD32},
72 {XNBackground, XimType_CARD32},
73 {XNBackgroundPixmap, XimType_CARD32},
74 {XNSpotLocation, XimType_XPoint},
75 {XNLineSpace, XimType_CARD32},
76 {XNPreeditState, XimType_CARD32},
77 {XNSeparatorofNestedList, XimType_SeparatorOfNestedList},
81 IMExtList Default_Extension[] =
83 {"XIM_EXT_MOVE", XIM_EXTENSION, XIM_EXT_MOVE},
84 {"XIM_EXT_SET_EVENT_MASK", XIM_EXTENSION, XIM_EXT_SET_EVENT_MASK},
85 {"XIM_EXT_FORWARD_KEYEVENT", XIM_EXTENSION, XIM_EXT_FORWARD_KEYEVENT},
89 static void CountAttrList(IMListOfAttr *attr, int *total_count)
93 while (attr->name != NULL)
100 static XIMAttr *CreateAttrList (Xi18n i18n_core,
105 unsigned int buf_size;
107 CountAttrList(attr, total_count);
109 buf_size = (unsigned) (*total_count + 1)*sizeof (XIMAttr);
110 args = (XIMAttr *) malloc (buf_size);
112 return (XIMAttr *) NULL;
114 memset (args, 0, buf_size);
116 for (p = args; attr->name != NULL; attr++, p++)
118 p->name = attr->name;
119 p->length = strlen (attr->name);
120 p->type = (CARD16) attr->type;
121 p->attribute_id = XrmStringToQuark (p->name);
122 if (strcmp (p->name, XNPreeditAttributes) == 0)
123 i18n_core->address.preeditAttr_id = p->attribute_id;
124 else if (strcmp (p->name, XNStatusAttributes) == 0)
125 i18n_core->address.statusAttr_id = p->attribute_id;
126 else if (strcmp (p->name, XNSeparatorofNestedList) == 0)
127 i18n_core->address.separatorAttr_id = p->attribute_id;
131 p->name = (char *) NULL;
136 void _Xi18nInitAttrList (Xi18n i18n_core)
141 /* init IMAttr list */
142 if (i18n_core->address.xim_attr)
143 XFree ((char *)i18n_core->address.xim_attr);
145 args = CreateAttrList (i18n_core, Default_IMattr, &total_count);
147 i18n_core->address.im_attr_num = total_count;
148 i18n_core->address.xim_attr = (XIMAttr *)args;
150 /* init ICAttr list */
151 if (i18n_core->address.xic_attr)
152 XFree ((char *) i18n_core->address.xic_attr);
154 args = CreateAttrList (i18n_core, Default_ICattr, &total_count);
156 i18n_core->address.ic_attr_num = total_count;
157 i18n_core->address.xic_attr = (XICAttr *) args;
160 void _Xi18nInitExtension(Xi18n i18n_core)
163 IMExtList *extensions = (IMExtList *) Default_Extension;
164 XIMExt *ext_list = (XIMExt *) i18n_core->address.extension;
166 for (i = 0; extensions->name; i++, ext_list++, extensions++)
168 ext_list->major_opcode = extensions->major_opcode;
169 ext_list->minor_opcode = extensions->minor_opcode;
170 ext_list->name = extensions->name;
171 ext_list->length = strlen(ext_list->name);
174 i18n_core->address.ext_num = i;