2 * Copyright 1990, 1991 by OMRON Corporation, NTT Software Corporation,
3 * and Nippon Telegraph and Telephone Corporation
4 * Copyright 1991 by the Open Software Foundation
5 * Copyright 1993 by the FUJITSU LIMITED
7 * Permission to use, copy, modify, distribute, and sell this software and its
8 * documentation for any purpose is hereby granted without fee, provided that
9 * the above copyright notice appear in all copies and that both that
10 * copyright notice and this permission notice appear in supporting
11 * documentation, and that the names of OMRON, NTT Software, NTT, and
12 * Open Software Foundation not be used in advertising or publicity
13 * pertaining to distribution of the software without specific,
14 * written prior permission. OMRON, NTT Software, NTT, and Open Software
15 * Foundation make no representations about the suitability of this
16 * software for any purpose. It is provided "as is" without express or
19 * OMRON, NTT SOFTWARE, NTT, AND OPEN SOFTWARE FOUNDATION
20 * DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
21 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
22 * SHALL OMRON, NTT SOFTWARE, NTT, OR OPEN SOFTWARE FOUNDATION BE
23 * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
24 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
25 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
26 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
28 * Authors: Li Yuhong OMRON Corporation
29 * Tatsuya Kato NTT Software Corporation
30 * Hiroshi Kuribayashi OMRON Coproration
31 * Muneiyoshi Suzuki Nippon Telegraph and Telephone Co.
34 * Takashi Fujiwara FUJITSU LIMITED
38 Copyright 1991, 1998 The Open Group
40 Permission to use, copy, modify, distribute, and sell this software and its
41 documentation for any purpose is hereby granted without fee, provided that
42 the above copyright notice appear in all copies and that both that
43 copyright notice and this permission notice appear in supporting
46 The above copyright notice and this permission notice shall be included
47 in all copies or substantial portions of the Software.
49 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
50 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
51 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
52 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
53 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
54 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
55 OTHER DEALINGS IN THE SOFTWARE.
57 Except as contained in this notice, the name of The Open Group shall
58 not be used in advertising or otherwise to promote the sale, use or
59 other dealings in this Software without prior written authorization
71 _XIMNestedListToNestedList(
72 XIMArg *nlist, /* This is the new list */
73 XIMArg *list) /* The original list */
75 register XIMArg *ptr = list;
78 if (!strcmp(ptr->name, XNVaNestedList)) {
79 nlist += _XIMNestedListToNestedList(nlist, (XIMArg *)ptr->value);
81 nlist->name = ptr->name;
82 nlist->value = ptr->value;
95 for (; args->name; args++) {
96 if (!strcmp(args->name, XNVaNestedList))
97 _XIMCountNestedList((XIMArg *)args->value, total_count);
104 _XIMCountVaList(va_list var, int *total_count)
110 for (attr = va_arg(var, char*); attr; attr = va_arg(var, char*)) {
111 if (!strcmp(attr, XNVaNestedList)) {
112 _XIMCountNestedList(va_arg(var, XIMArg*), total_count);
114 (void)va_arg(var, XIMArg*);
121 _XIMVaToNestedList(va_list var, int max_count, XIMArg **args_return)
126 if (max_count <= 0) {
127 *args_return = (XIMArg *)NULL;
131 args = (XIMArg *)Xmalloc((unsigned)(max_count + 1) * sizeof(XIMArg));
135 for (attr = va_arg(var, char*); attr; attr = va_arg(var, char*)) {
136 if (!strcmp(attr, XNVaNestedList)) {
137 args += _XIMNestedListToNestedList(args, va_arg(var, XIMArg*));
140 args->value = va_arg(var, XPointer);
144 args->name = (char*)NULL;
149 XVaCreateNestedList(int dummy, ...)
155 va_start(var, dummy);
156 _XIMCountVaList(var, &total_count);
159 va_start(var, dummy);
160 _XIMVaToNestedList(var, total_count, &args);
163 return (XVaNestedList)args;
167 XSetIMValues(XIM im, ...)
175 * so count the stuff dangling here
178 _XIMCountVaList(var, &total_count);
182 * now package it up so we can send it along
185 _XIMVaToNestedList(var, total_count, &args);
188 ret = (*im->methods->set_values) (im, args);
189 if (args) Xfree((char *)args);
194 XGetIMValues(XIM im, ...)
202 * so count the stuff dangling here
205 _XIMCountVaList(var, &total_count);
209 * now package it up so we can send it along
212 _XIMVaToNestedList(var, total_count, &args);
215 ret = (*im->methods->get_values) (im, args);
216 if (args) Xfree((char *)args);
221 * Create an input context within the input method,
222 * and return a pointer to the input context.
226 XCreateIC(XIM im, ...)
234 * so count the stuff dangling here
237 _XIMCountVaList(var, &total_count);
241 * now package it up so we can send it along
244 _XIMVaToNestedList(var, total_count, &args);
247 ic = (XIC) (*im->methods->create_ic) (im, args);
248 if (args) Xfree((char *)args);
250 ic->core.next = im->core.ic_chain;
251 im->core.ic_chain = ic;
257 * Free the input context.
262 XIM im = ic->core.im;
265 (*ic->methods->destroy) (ic);
267 for (prev = &im->core.ic_chain; *prev; prev = &(*prev)->core.next) {
269 *prev = ic->core.next;
278 XGetICValues(XIC ic, ...)
286 return (char *) NULL;
289 * so count the stuff dangling here
292 _XIMCountVaList(var, &total_count);
296 * now package it up so we can send it along
299 _XIMVaToNestedList(var, total_count, &args);
302 ret = (*ic->methods->get_values) (ic, args);
303 if (args) Xfree((char *)args);
308 XSetICValues(XIC ic, ...)
316 return (char *) NULL;
319 * so count the stuff dangling here
322 _XIMCountVaList(var, &total_count);
326 * now package it up so we can send it along
329 _XIMVaToNestedList(var, total_count, &args);
332 ret = (*ic->methods->set_values) (ic, args);
333 if (args) Xfree((char *)args);
338 * Require the input manager to focus the focus window attached to the ic
344 if (ic && ic->core.im)
345 (*ic->methods->set_focus) (ic);
349 * Require the input manager to unfocus the focus window attached to the ic
353 XUnsetICFocus(XIC ic)
356 (*ic->methods->unset_focus) (ic);
360 * Return the XIM associated with the input context.
372 return (*ic->methods->mb_reset)(ic);
380 return (*ic->methods->wc_reset)(ic);
381 return (wchar_t *)NULL;
388 if (ic->methods->utf8_reset)
389 return (*ic->methods->utf8_reset)(ic);
390 else if (ic->methods->mb_reset)
391 return (*ic->methods->mb_reset)(ic);
397 XmbLookupString(XIC ic, XKeyEvent *ev, char *buffer, int nbytes,
398 KeySym *keysym, Status *status)
401 return (*ic->methods->mb_lookup_string) (ic, ev, buffer, nbytes,
407 XwcLookupString(XIC ic, XKeyEvent *ev, wchar_t *buffer, int nchars,
408 KeySym *keysym, Status *status)
411 return (*ic->methods->wc_lookup_string) (ic, ev, buffer, nchars,
417 Xutf8LookupString(XIC ic, XKeyEvent *ev, char *buffer, int nbytes,
418 KeySym *keysym, Status *status)
421 if (ic->methods->utf8_lookup_string)
422 return (*ic->methods->utf8_lookup_string) (ic, ev, buffer, nbytes,
424 else if (ic->methods->mb_lookup_string)
425 return (*ic->methods->mb_lookup_string) (ic, ev, buffer, nbytes,