Bug Summary

File:XawIm.c
Location:line 816, column 12
Description:Function call argument is an uninitialized value

Annotated Source Code

1/*
2 * Copyright 1991 by OMRON Corporation
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of OMRON not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. OMRON makes no representations about the
11 * suitability of this software for any purpose. It is provided "as is"
12 * without express or implied warranty.
13 *
14 * OMRON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
15 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
16 * OMRON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
17 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION,
19 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
20 * SOFTWARE.
21 *
22 * Author: Seiji Kuwari OMRON Corporation
23 * kuwa@omron.co.jp
24 * kuwa%omron.co.jp@uunet.uu.net
25 */
26
27
28/*
29
30Copyright (c) 1994 X Consortium
31
32Permission is hereby granted, free of charge, to any person obtaining a copy
33of this software and associated documentation files (the "Software"), to deal
34in the Software without restriction, including without limitation the rights
35to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
36copies of the Software, and to permit persons to whom the Software is
37furnished to do so, subject to the following conditions:
38
39The above copyright notice and this permission notice shall be included in
40all copies or substantial portions of the Software.
41
42THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
46AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
47CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
48
49Except as contained in this notice, the name of the X Consortium shall not be
50used in advertising or otherwise to promote the sale, use or other dealings
51in this Software without prior written authorization from the X Consortium.
52
53*/
54
55#ifdef HAVE_CONFIG_H1
56#include "config.h"
57#endif
58#include <X11/IntrinsicP.h>
59#include <X11/StringDefs.h>
60#include <X11/Xos.h>
61#include <X11/Xfuncs.h>
62#include <X11/ShellP.h>
63#include <X11/Xaw3d/TextP.h>
64#include <X11/Xaw3d/MultiSrc.h>
65#include <X11/Xaw3d/MultiSinkP.h>
66#include <X11/Xaw3d/XawImP.h>
67#include <X11/Xaw3d/VendorEP.h>
68#include <X11/ResourceI.h>
69#include <X11/VarargsI.h>
70#include "XawI18n.h"
71#include <ctype.h>
72
73# include <stdarg.h>
74# define Va_start(a,b)__builtin_va_start(a, b) va_start(a,b)__builtin_va_start(a, b)
75
76#define maxAscentOfFontSet(fontset)( - (XExtentsOfFontSet((fontset)))->max_logical_extent.y) \
77 ( - (XExtentsOfFontSet((fontset)))->max_logical_extent.y)
78
79#define maxHeightOfFontSet(fontset)((XExtentsOfFontSet((fontset)))->max_logical_extent.height
)
\
80 ((XExtentsOfFontSet((fontset)))->max_logical_extent.height)
81
82#define maxDescentOfFontSet(fontset)(((XExtentsOfFontSet((fontset)))->max_logical_extent.height
) - ( - (XExtentsOfFontSet((fontset)))->max_logical_extent
.y))
\
83 (maxHeightOfFontSet(fontset)((XExtentsOfFontSet((fontset)))->max_logical_extent.height
)
- maxAscentOfFontSet(fontset)( - (XExtentsOfFontSet((fontset)))->max_logical_extent.y))
84
85#define Offset(field) (XtOffsetOf(XawIcTablePart, field)__builtin_offsetof(XawIcTablePart, field))
86
87/*****************************************************
88 *
89 * Forward reference prototypes
90 *
91 *****************************************************/
92
93extern void XawVendorShellExtResize(Widget);
94
95static XawIcTableList CurrentSharedIcTable(
96 XawVendorShellExtPart* /* ve */
97);
98
99static void DestroyIC(
100 Widget /* w */,
101 XawVendorShellExtPart* /* ve */
102);
103
104static XtResource resources[] =
105{
106 {
107 XtNfontSet((char*)&XtStrings[2018]), XtCFontSet((char*)&XtStrings[2034]), XtRFontSet((char*)&XtStrings[2026]), sizeof(XFontSet),
108 Offset (font_set), XtRString((char*)&XtStrings[1797]), XtDefaultFontSet"XtDefaultFontSet"
109 },
110 {
111 XtNforeground((char*)&XtStrings[214]), XtCForeground((char*)&XtStrings[1022]), XtRPixel((char*)&XtStrings[1754]), sizeof(Pixel),
112 Offset (foreground), XtRString((char*)&XtStrings[1797]), (XtPointer)"XtDefaultForeground"
113 },
114 {
115 XtNbackground((char*)&XtStrings[52]), XtCBackground((char*)&XtStrings[902]), XtRPixel((char*)&XtStrings[1754]), sizeof(Pixel),
116 Offset (background), XtRString((char*)&XtStrings[1797]), (XtPointer)"XtDefaultBackground"
117 },
118 {
119 XtNbackgroundPixmap((char*)&XtStrings[63]), XtCPixmap((char*)&XtStrings[1228]), XtRPixmap((char*)&XtStrings[1760]), sizeof(Pixmap),
120 Offset (bg_pixmap), XtRImmediate((char*)&XtStrings[1695]), (XtPointer) XtUnspecifiedPixmap((Pixmap)2)
121 },
122 {
123 XtNinsertPosition((char*)&XtStrings[326]), XtCTextPosition((char*)&XtStrings[1435]), XtRInt((char*)&XtStrings[1718]), sizeof (XawTextPosition),
124 Offset (cursor_position), XtRImmediate((char*)&XtStrings[1695]), (XtPointer) 0
125 }
126};
127#undef Offset
128
129
130static void
131SetVaArg(XPointer *arg, XPointer value)
132{
133 *arg = value;
134}
135
136static VendorShellWidget
137SearchVendorShell(Widget w)
138{
139 while(w && !XtIsShell(w)(((Object)(w))->object.widget_class->core_class.class_inited
& 0x20)
) w = XtParent(w)((w)->core.parent);
140 if (w && XtIsVendorShell(w)(_XtIsSubclassOf(w, (WidgetClass)vendorShellWidgetClass, (WidgetClass
)wmShellWidgetClass, (XtEnum)0x40))
) return((VendorShellWidget)w);
141 return(NULL((void*)0));
142}
143
144static XContext extContext = (XContext)0;
145
146static XawVendorShellExtPart *
147SetExtPart(VendorShellWidget w, XawVendorShellExtWidget vew)
148{
149 contextDataRec *contextData;
150
151 if (extContext == (XContext)0) extContext = XUniqueContext()((XContext) XrmUniqueQuark());
152
153 contextData = XtNew(contextDataRec)((contextDataRec *) XtMalloc((unsigned) sizeof(contextDataRec
)))
;
154 contextData->parent = (Widget)w;
155 contextData->ve = (Widget)vew;
156 if (XSaveContext(XtDisplay(w)(((w)->core.screen)->display), (Window)w, extContext, (char *)contextData)) {
157 return(NULL((void*)0));
158 }
159 return(&(vew->vendor_ext));
160}
161
162static XawVendorShellExtPart *
163GetExtPart(VendorShellWidget w)
164{
165 contextDataRec *contextData;
166 XawVendorShellExtWidget vew;
167
168 if (XFindContext(XtDisplay(w)(((w)->core.screen)->display), (Window)w, extContext,
169 (XPointer*)&contextData)) {
170 return(NULL((void*)0));
171 }
172 vew = (XawVendorShellExtWidget)contextData->ve;
173 return(&(vew->vendor_ext));
174}
175
176static Boolean
177IsSharedIC(XawVendorShellExtPart *ve)
178{
179 return( ve->ic.shared_ic );
180}
181
182static XawIcTableList
183GetIcTableShared(Widget w, XawVendorShellExtPart *ve)
184{
185 XawIcTableList p;
186
187 for (p = ve->ic.ic_table; p; p = p->next) {
188 if (p->widget == w) {
189 if (IsSharedIC(ve)) {
190 return(ve->ic.shared_ic_table);
191 } else {
192 return(p);
193 }
194 }
195 }
196 return(NULL((void*)0));
197}
198
199static XawIcTableList
200GetIcTable(Widget w, XawVendorShellExtPart *ve)
201{
202 XawIcTableList p;
203
204 for (p = ve->ic.ic_table; p; p = p->next) {
205 if (p->widget == w) {
206 return(p);
207 }
208 }
209 return(NULL((void*)0));
210}
211
212static XIMStyle
213GetInputStyleOfIC(XawVendorShellExtPart *ve)
214{
215
216 if (!ve) return((XIMStyle)0);
217 return(ve->ic.input_style);
218}
219
220static void
221ConfigureCB(Widget w, XtPointer closure, XEvent *event)
222{
223 XawIcTableList p;
224 XawVendorShellExtPart *ve;
225 VendorShellWidget vw;
226 XVaNestedList pe_attr;
227 XRectangle pe_area;
228 XawTextMargin *margin;
229
230 if (event->type != ConfigureNotify22) return;
231
232 if ((vw = SearchVendorShell(w)) == NULL((void*)0)) return;
233
234 if ((ve = GetExtPart(vw))) {
235 if (IsSharedIC(ve)) return;
236 if ((ve->im.xim == NULL((void*)0)) ||
237 ((p = GetIcTableShared(w, ve)) == NULL((void*)0)) ||
238 (p->xic == NULL((void*)0)) || !(p->input_style & XIMPreeditPosition0x0004L)) return;
239 pe_area.x = 0;
240 pe_area.y = 0;
241 pe_area.width = w->core.width;
242 pe_area.height = w->core.height;
243 margin = &(((TextWidget)w)->text.margin);
244 pe_area.x += margin->left;
245 pe_area.y += margin->top;
246 pe_area.width -= (margin->left + margin->right - 1);
247 pe_area.height -= (margin->top + margin->bottom - 1);
248
249 pe_attr = XVaCreateNestedList(0, XNArea"area", &pe_area, NULL((void*)0));
250 XSetICValues(p->xic, XNPreeditAttributes"preeditAttributes", pe_attr, NULL((void*)0));
251 XtFree(pe_attr);
252 }
253}
254
255static XContext errContext = (XContext)0;
256
257static Widget
258SetErrCnxt(Widget w, XIM xim)
259{
260 contextErrDataRec *contextErrData;
261
262 if (errContext == (XContext)0) errContext = XUniqueContext()((XContext) XrmUniqueQuark());
263
264 contextErrData = XtNew(contextErrDataRec)((contextErrDataRec *) XtMalloc((unsigned) sizeof(contextErrDataRec
)))
;
265 contextErrData->widget = w;
266 contextErrData->xim = xim;
267 if (XSaveContext(XtDisplay(w)(((w)->core.screen)->display), (Window)xim, errContext,
268 (char *)contextErrData)) {
269 return(NULL((void*)0));
270 }
271 return(contextErrData->widget);
272}
273
274static void
275CloseIM(XawVendorShellExtPart *ve)
276{
277 if (ve->im.xim)
278 XCloseIM(ve->im.xim);
279}
280
281static Dimension
282SetVendorShellHeight(XawVendorShellExtPart *ve, Dimension height)
283{
284 Arg args[2];
285 Cardinal i = 0;
286
287 if (ve->im.area_height < height || height == 0) {
288 XtSetArg(args[i], XtNheight,((void)( (args[i]).name = (((char*)&XtStrings[234])), (args
[i]).value = (XtArgVal)((ve->parent->core.height + height
- ve->im.area_height)) ))
289 (ve->parent->core.height + height - ve->im.area_height))((void)( (args[i]).name = (((char*)&XtStrings[234])), (args
[i]).value = (XtArgVal)((ve->parent->core.height + height
- ve->im.area_height)) ))
;
290 ve->im.area_height = height;
291 XtSetValues(ve->parent, args, 1);
292 }
293 return(ve->im.area_height);
294}
295
296static void
297DestroyAllIM(XawVendorShellExtPart *ve)
298{
299 XawIcTableList p;
300 contextErrDataRec *contextErrData;
301
302 /*
303 * Destory all ICs
304 */
305 if (IsSharedIC(ve)) {
306 if ((p = ve->ic.shared_ic_table) && p->xic) {
307 DestroyIC(p->widget, ve);
308 p->xic = NULL((void*)0);
309 p->ic_focused = FALSE0;
310 }
311 } else {
312 for (p = ve->ic.ic_table; p; p = p->next) {
313 if (p->xic == NULL((void*)0)) continue;
314 DestroyIC(p->widget, ve);
315 p->xic = NULL((void*)0);
316 p->ic_focused = FALSE0;
317 }
318 }
319 if (!ve->im.xim) return;
320 /*
321 * Close Input Method
322 */
323 if (!XFindContext(XDisplayOfIM(ve->im.xim), (Window)ve->im.xim, errContext,
324 (XPointer*)&contextErrData)) {
325 if (contextErrData) XtFree((char *)contextErrData);
326 }
327 XDeleteContext(XDisplayOfIM(ve->im.xim), (Window)ve->im.xim, errContext);
328 CloseIM(ve);
329 ve->im.xim = NULL((void*)0);
330
331 /*
332 * resize vendor shell to core size
333 */
334 (void) SetVendorShellHeight(ve, 0);
335 /*
336 XawVendorShellExtResize(vw);
337 */
338 return;
339}
340
341static void
342FreeAllDataOfVendorShell(XawVendorShellExtPart *ve, VendorShellWidget vw)
343{
344 XawIcTableList p, next;
345 contextErrDataRec *contextErrData;
346
347 if (!XFindContext(XtDisplay(vw)(((vw)->core.screen)->display), (Window)vw, extContext,
348 (XPointer*)&contextErrData)) {
349 if (contextErrData) XtFree((char *)contextErrData);
350 }
351 XDeleteContext(XtDisplay(vw)(((vw)->core.screen)->display), (Window)vw, extContext);
352 if (ve->ic.shared_ic_table)
353 XtFree((char *)ve->ic.shared_ic_table);
354 if (ve->im.resources) XtFree((char *)ve->im.resources);
355 for (p = ve->ic.ic_table; p; p = next) {
356 next = p->next;
357 XtFree((char *)p);
358 }
359}
360
361static void
362VendorShellDestroyed(Widget w, XtPointer cl_data, XtPointer ca_data)
363{
364 XawVendorShellExtPart *ve;
365
366 if ( ( ve = GetExtPart( (VendorShellWidget) w ) ) == NULL((void*)0) ) return;
367 DestroyAllIM( ve );
368 FreeAllDataOfVendorShell( ve, (VendorShellWidget) w );
369 return;
370}
371
372/*
373 * Attempt to open an input method
374 */
375
376static void
377OpenIM(XawVendorShellExtPart *ve)
378{
379 int i;
380 char *p, *s, *ns, *end, *pbuf, buf[32];
381 XIM xim = NULL((void*)0);
382 XIMStyles *xim_styles;
383 XIMStyle input_style = 0;
384 Boolean found;
385
386 if (ve->im.open_im == False0) return;
387 ve->im.xim = NULL((void*)0);
388 if (ve->im.input_method == NULL((void*)0)) {
389 if ((p = XSetLocaleModifiers("@im=none")) != NULL((void*)0) && *p)
390 xim = XOpenIM(XtDisplay(ve->parent)(((ve->parent)->core.screen)->display), NULL((void*)0), NULL((void*)0), NULL((void*)0));
391 } else {
392 /* no fragment can be longer than the whole string */
393 int len = strlen (ve->im.input_method) + 5;
394
395 if (len < sizeof buf) pbuf = buf;
396 else pbuf = XtMalloc (len);
397
398 if (pbuf == NULL((void*)0)) return;
399
400 for(ns=s=ve->im.input_method; ns && *s;) {
401 /* skip any leading blanks */
402 while (*s && isspace(*s)) s++;
403 if (!*s) break;
404 if ((ns = end = strchr(s, ',')) == NULL((void*)0))
405 end = s + strlen(s);
406 /* strip any trailing blanks */
407 while (isspace(*end)) end--;
408
409 strcpy (pbuf, "@im=")__builtin___strcpy_chk (pbuf, "@im=", __builtin_object_size (
pbuf, 2 > 1 ? 1 : 0))
;
410 strncat (pbuf, s, end - s)__builtin___strncat_chk (pbuf, s, end - s, __builtin_object_size
(pbuf, 2 > 1 ? 1 : 0))
;
411 pbuf[end - s + 4] = '\0';
412
413 if ((p = XSetLocaleModifiers(pbuf)) != NULL((void*)0) && *p
414 && (xim = XOpenIM(XtDisplay(ve->parent)(((ve->parent)->core.screen)->display), NULL((void*)0), NULL((void*)0), NULL((void*)0))) != NULL((void*)0))
415 break;
416
417 s = ns + 1;
418 }
419
420 if (pbuf != buf) XtFree (pbuf);
421 }
422 if (xim == NULL((void*)0)) {
423 if ((p = XSetLocaleModifiers("")) != NULL((void*)0)) {
424 xim = XOpenIM(XtDisplay(ve->parent)(((ve->parent)->core.screen)->display), NULL((void*)0), NULL((void*)0), NULL((void*)0));
425 }
426 }
427 if (xim == NULL((void*)0)) {
428 XtAppWarning(XtWidgetToApplicationContext(ve->parent),
429 "Input Method Open Failed");
430 return;
431 }
432 if (XGetIMValues(xim, XNQueryInputStyle"queryInputStyle", &xim_styles, NULL((void*)0))
433 || !xim_styles) {
434 XtAppWarning(XtWidgetToApplicationContext(ve->parent),
435 "input method doesn't support any style");
436 XCloseIM(xim);
437 return;
438 }
439 found = False0;
440 for(ns = s = ve->im.preedit_type; s && !found;) {
441 while (*s && isspace(*s)) s++;
442 if (!*s) break;
443 if ((ns = end = strchr(s, ',')) == NULL((void*)0))
444 end = s + strlen(s);
445 while (isspace(*end)) end--;
446
447 if (!strncmp(s, "OverTheSpot", end - s)) {
448 input_style = (XIMPreeditPosition0x0004L | XIMStatusArea0x0100L);
449 } else if (!strncmp(s, "OffTheSpot", end - s)) {
450 input_style = (XIMPreeditArea0x0001L | XIMStatusArea0x0100L);
451 } else if (!strncmp(s, "Root", end - s)) {
452 input_style = (XIMPreeditNothing0x0008L | XIMStatusNothing0x0400L);
453 }
454 for (i = 0; (unsigned short)i < xim_styles->count_styles; i++)
455 if (input_style == xim_styles->supported_styles[i]) {
456 ve->ic.input_style = input_style;
457 SetErrCnxt(ve->parent, xim);
458 ve->im.xim = xim;
459 found = True1;
460 break;
461 }
462
463 s = ns + 1;
464 }
465 XFree(xim_styles);
466
467 if (!found) {
468 XCloseIM(xim);
469 XtAppWarning(XtWidgetToApplicationContext(ve->parent),
470 "input method doesn't support my input style");
471 }
472}
473
474static Boolean
475ResizeVendorShell_Core(VendorShellWidget vw, XawVendorShellExtPart *ve, XawIcTableList p)
476{
477 XVaNestedList pe_attr, st_attr;
478 XRectangle pe_area, st_area;
479 XRectangle *get_pe_area = NULL((void*)0), *get_st_area = NULL((void*)0);
480
481 st_area.width = 0;
482 if (p->input_style & XIMStatusArea0x0100L) {
483 st_attr = XVaCreateNestedList(0, XNArea"area", &get_st_area, NULL((void*)0));
484 XGetICValues(p->xic, XNStatusAttributes"statusAttributes", st_attr, NULL((void*)0));
485 XFree(st_attr);
486 if (p->xic == NULL((void*)0)) {
487 return(FALSE0);
488 }
489 st_area.x = 0;
490 st_area.y = vw->core.height - ve->im.area_height;
491 st_area.width = get_st_area->width;
492 st_area.height = get_st_area->height;
493 XFree(get_st_area);
494 st_attr = XVaCreateNestedList(0, XNArea"area", &st_area, NULL((void*)0));
495 XSetICValues(p->xic, XNStatusAttributes"statusAttributes", st_attr, NULL((void*)0));
496 XFree(st_attr);
497 if (p->xic == NULL((void*)0)) {
498 return(FALSE0);
499 }
500 }
501 if (p->input_style & XIMPreeditArea0x0001L) {
502 pe_attr = XVaCreateNestedList(0, XNArea"area", &get_pe_area, NULL((void*)0));
503 XGetICValues(p->xic, XNPreeditAttributes"preeditAttributes", pe_attr, NULL((void*)0));
504 XFree(pe_attr);
505 if (p->xic == NULL((void*)0)) {
506 return(FALSE0);
507 }
508 pe_area.x = st_area.width;
509 pe_area.y = vw->core.height - ve->im.area_height;
510 pe_area.width = vw->core.width;
511 pe_area.height = get_pe_area->height;
512 if (p->input_style & XIMStatusArea0x0100L) {
513 pe_area.width -= st_area.width;
514 }
515 XFree(get_pe_area);
516 pe_attr = XVaCreateNestedList(0, XNArea"area", &pe_area, NULL((void*)0));
517 XSetICValues(p->xic, XNPreeditAttributes"preeditAttributes", pe_attr, NULL((void*)0));
518 XFree(pe_attr);
519 }
520 return(TRUE1);
521}
522
523static void
524ResizeVendorShell(VendorShellWidget vw, XawVendorShellExtPart *ve)
525{
526 XawIcTableList p;
527
528 if (IsSharedIC(ve)) {
529 p = ve->ic.shared_ic_table;
530 if (p->xic == NULL((void*)0)) return;
531 ResizeVendorShell_Core(vw, ve, p);
532 return;
533 }
534 for (p = ve->ic.ic_table; p; p = p->next) {
535 if (p->xic == NULL((void*)0)) continue;
536 if (ResizeVendorShell_Core(vw, ve, p) == FALSE0) return;
537 }
538}
539
540static XawIcTableList
541CreateIcTable(Widget w, XawVendorShellExtPart *ve)
542{
543 XawIcTableList table;
544
545 table = (XawIcTableList) XtMalloc(sizeof(XawIcTablePart));
546 if (table == NULL((void*)0)) return(NULL((void*)0));
547 table->widget = w;
548 table->xic = NULL((void*)0);
549 table->flg = table->prev_flg = 0;
550 table->font_set = NULL((void*)0);
551 table->foreground = table->background = 0xffffffff;
552 table->bg_pixmap = 0;
553 table->cursor_position = 0xffff;
554 table->line_spacing = 0;
555 table->ic_focused = FALSE0;
556 table->openic_error = FALSE0;
557 return(table);
558}
559
560static Boolean
561RegisterToVendorShell(Widget w, XawVendorShellExtPart *ve)
562{
563 XawIcTableList table;
564
565 if ((table = CreateIcTable(w, ve)) == NULL((void*)0)) return(FALSE0);
566 table->next = ve->ic.ic_table;
567 ve->ic.ic_table = table;
568 return(TRUE1);
569}
570
571static void
572UnregisterFromVendorShell(Widget w, XawVendorShellExtPart *ve)
573{
574 XawIcTableList *prev, p;
575
576 for (prev = &ve->ic.ic_table; (p = *prev); prev = &p->next) {
577 if (p->widget == w) {
578 *prev = p->next;
579 XtFree((char *)p);
580 break;
581 }
582 }
583 return;
584}
585
586static void
587SetICValuesShared(Widget w, XawVendorShellExtPart *ve, XawIcTableList p, Boolean check)
588{
589 XawIcTableList pp;
590
591 if ((pp = GetIcTable(w, ve)) == NULL((void*)0)) return;
592 if (check == TRUE1 && CurrentSharedIcTable(ve) != pp) return;
593
594 if (pp->prev_flg & CICursorP(1 << 5) && p->cursor_position != pp->cursor_position) {
595 p->cursor_position = pp->cursor_position;
596 p->flg |= CICursorP(1 << 5);
597 }
598 if (pp->prev_flg & CIFontSet(1 << 1) && p->font_set != pp->font_set) {
599 p->font_set = pp->font_set;
600 p->flg |= (CIFontSet(1 << 1)|CICursorP(1 << 5));
601 }
602 if (pp->prev_flg & CIFg(1 << 2) && p->foreground != pp->foreground) {
603 p->foreground = pp->foreground;
604 p->flg |= CIFg(1 << 2);
605 }
606 if (pp->prev_flg & CIBg(1 << 3) && p->background != pp->background) {
607 p->background = pp->background;
608 p->flg |= CIBg(1 << 3);
609 }
610 if (pp->prev_flg & CIBgPixmap(1 << 4) && p->bg_pixmap != pp->bg_pixmap) {
611 p->bg_pixmap = pp->bg_pixmap;
612 p->flg |= CIBgPixmap(1 << 4);
613 }
614 if (pp->prev_flg & CILineS(1 << 6) && p->line_spacing != pp->line_spacing) {
615 p->line_spacing = pp->line_spacing;
616 p->flg |= CILineS(1 << 6);
617 }
618}
619
620static Boolean
621IsCreatedIC(Widget w, XawVendorShellExtPart *ve)
622{
623 XawIcTableList p;
624
625 if (ve->im.xim == NULL((void*)0)) return(FALSE0);
626 if ((p = GetIcTableShared(w, ve)) == NULL((void*)0)) return(FALSE0);
627 if (p->xic == NULL((void*)0)) return(FALSE0);
628 return(TRUE1);
629}
630
631static void
632SizeNegotiation(XawIcTableList p, Dimension width, Dimension height)
633{
634 XRectangle pe_area, st_area;
635 XVaNestedList pe_attr = NULL((void*)0), st_attr = NULL((void*)0);
636 int ic_cnt = 0, pe_cnt = 0, st_cnt = 0;
637 XRectangle *pe_area_needed = NULL((void*)0), *st_area_needed = NULL((void*)0);
638 XPointer ic_a[5];
639
640 if (p->input_style & XIMPreeditArea0x0001L) {
641 pe_attr = XVaCreateNestedList(0, XNAreaNeeded"areaNeeded", &pe_area_needed, NULL((void*)0));
642 SetVaArg( &ic_a[ic_cnt], (XPointer) XNPreeditAttributes"preeditAttributes"); ic_cnt++;
643 SetVaArg( &ic_a[ic_cnt], (XPointer) pe_attr); ic_cnt++;
644 }
645 if (p->input_style & XIMStatusArea0x0100L) {
646 st_attr = XVaCreateNestedList(0, XNAreaNeeded"areaNeeded", &st_area_needed, NULL((void*)0));
647 SetVaArg( &ic_a[ic_cnt], (XPointer) XNStatusAttributes"statusAttributes"); ic_cnt++;
648 SetVaArg( &ic_a[ic_cnt], (XPointer) st_attr); ic_cnt++;
649 }
650 SetVaArg( &ic_a[ic_cnt], (XPointer) NULL((void*)0));
651
652 if (ic_cnt > 0) {
653 XGetICValues(p->xic, ic_a[0], ic_a[1], ic_a[2], ic_a[3], ic_a[4], NULL((void*)0));
654 if (pe_attr) XFree(pe_attr);
655 if (st_attr) XFree(st_attr);
656 if (p->xic == NULL((void*)0)) {
657 p->openic_error = True1;
658 return;
659 }
660 pe_attr = st_attr = NULL((void*)0);
661 ic_cnt = pe_cnt = st_cnt = 0;
662 if (p->input_style & XIMStatusArea0x0100L) {
663 st_area.height = st_area_needed->height;
664 st_area.x = 0;
665 st_area.y = height - st_area.height;
666 if (p->input_style & XIMPreeditArea0x0001L) {
667 st_area.width = st_area_needed->width;
668 } else {
669 st_area.width = width;
670 }
671
672 XFree(st_area_needed);
673 st_attr = XVaCreateNestedList(0, XNArea"area", &st_area, NULL((void*)0));
674 SetVaArg( &ic_a[ic_cnt], (XPointer) XNStatusAttributes"statusAttributes"); ic_cnt++;
675 SetVaArg( &ic_a[ic_cnt], (XPointer) st_attr); ic_cnt++;
676 }
677 if (p->input_style & XIMPreeditArea0x0001L) {
678 if (p->input_style & XIMStatusArea0x0100L) {
679 pe_area.x = st_area.width;
680 pe_area.width = width - st_area.width;
681 } else {
682 pe_area.x = 0;
683 pe_area.width = width;
684 }
685 pe_area.height = pe_area_needed->height;
686 XFree(pe_area_needed);
687 pe_area.y = height - pe_area.height;
688 pe_attr = XVaCreateNestedList(0, XNArea"area", &pe_area, NULL((void*)0));
689 SetVaArg( &ic_a[ic_cnt], (XPointer) XNPreeditAttributes"preeditAttributes"); ic_cnt++;
690 SetVaArg( &ic_a[ic_cnt], (XPointer) pe_attr); ic_cnt++;
691 }
692 SetVaArg( &ic_a[ic_cnt], (XPointer) NULL((void*)0));
693 XSetICValues(p->xic, ic_a[0], ic_a[1], ic_a[2], ic_a[3], ic_a[4], NULL((void*)0));
694 if (pe_attr) XFree(pe_attr);
695 if (st_attr) XFree(st_attr);
696 if (p->xic == NULL((void*)0)) {
697 p->openic_error = True1;
698 return;
699 }
700 }
701}
702
703static void
704CreateIC(Widget w, XawVendorShellExtPart *ve)
705{
706 XawIcTableList p;
707 XPoint position;
708 XRectangle pe_area, st_area;
709 XVaNestedList pe_attr = NULL((void*)0), st_attr = NULL((void*)0);
710 XPointer ic_a[20], pe_a[20], st_a[20];
711 Dimension height = 0;
712 int ic_cnt = 0, pe_cnt = 0, st_cnt = 0;
713 XawTextMargin *margin;
714
715 if (!XtIsRealized(w)(XtWindowOfObject(w) != 0L)) return;
11
Taking false branch
716 if (((ve->im.xim == NULL((void*)0)) || (p = GetIcTableShared(w, ve)) == NULL((void*)0)) ||
12
Taking false branch
717 p->xic || (p->openic_error != FALSE0)) return;
718
719 p->input_style = GetInputStyleOfIC(ve);
720
721 if (IsSharedIC(ve)) SetICValuesShared(w, ve, p, FALSE0);
13
Taking false branch
722 XFlush(XtDisplay(w)(((w)->core.screen)->display));
723
724 if (p->input_style & (XIMPreeditArea0x0001L|XIMPreeditPosition0x0004L|XIMStatusArea0x0100L)) {
14
Taking false branch
725 if (p->flg & CIFontSet(1 << 1)) {
726 SetVaArg( &pe_a[pe_cnt], (XPointer) XNFontSet"fontSet"); pe_cnt++;
727 SetVaArg( &pe_a[pe_cnt], (XPointer) p->font_set); pe_cnt++;
728 SetVaArg( &st_a[st_cnt], (XPointer) XNFontSet"fontSet"); st_cnt++;
729 SetVaArg( &st_a[st_cnt], (XPointer) p->font_set); st_cnt++;
730 height = maxAscentOfFontSet(p->font_set)( - (XExtentsOfFontSet((p->font_set)))->max_logical_extent
.y)
731 + maxDescentOfFontSet(p->font_set)(((XExtentsOfFontSet((p->font_set)))->max_logical_extent
.height) - ( - (XExtentsOfFontSet((p->font_set)))->max_logical_extent
.y))
;
732 height = SetVendorShellHeight(ve, height);
733 }
734 if (p->flg & CIFg(1 << 2)) {
735 SetVaArg( &pe_a[pe_cnt], (XPointer) XNForeground"foreground"); pe_cnt++;
736 SetVaArg( &pe_a[pe_cnt], (XPointer) p->foreground); pe_cnt++;
737 SetVaArg( &st_a[st_cnt], (XPointer) XNForeground"foreground"); st_cnt++;
738 SetVaArg( &st_a[st_cnt], (XPointer) p->foreground); st_cnt++;
739 }
740 if (p->flg & CIBg(1 << 3)) {
741 SetVaArg( &pe_a[pe_cnt], (XPointer) XNBackground"background"); pe_cnt++;
742 SetVaArg( &pe_a[pe_cnt], (XPointer) p->background); pe_cnt++;
743 SetVaArg( &st_a[st_cnt], (XPointer) XNBackground"background"); st_cnt++;
744 SetVaArg( &st_a[st_cnt], (XPointer) p->background); st_cnt++;
745 }
746 if (p->flg & CIBgPixmap(1 << 4)) {
747 SetVaArg( &pe_a[pe_cnt], (XPointer) XNBackgroundPixmap"backgroundPixmap"); pe_cnt++;
748 SetVaArg( &pe_a[pe_cnt], (XPointer) p->bg_pixmap); pe_cnt++;
749 SetVaArg( &st_a[st_cnt], (XPointer) XNBackgroundPixmap"backgroundPixmap"); st_cnt++;
750 SetVaArg( &st_a[st_cnt], (XPointer) p->bg_pixmap); st_cnt++;
751 }
752 if (p->flg & CILineS(1 << 6)) {
753 SetVaArg( &pe_a[pe_cnt], (XPointer) XNLineSpace"lineSpace"); pe_cnt++;
754 SetVaArg( &pe_a[pe_cnt], (XPointer) p->line_spacing); pe_cnt++;
755 SetVaArg( &st_a[st_cnt], (XPointer) XNLineSpace"lineSpace"); st_cnt++;
756 SetVaArg( &st_a[st_cnt], (XPointer) p->line_spacing); st_cnt++;
757 }
758 }
759 if (p->input_style & XIMPreeditArea0x0001L) {
15
Taking false branch
760 pe_area.x = 0;
761 pe_area.y = ve->parent->core.height - height;
762 pe_area.width = ve->parent->core.width;
763 pe_area.height = height;
764 SetVaArg( &pe_a[pe_cnt], (XPointer) XNArea"area"); pe_cnt++;
765 SetVaArg( &pe_a[pe_cnt], (XPointer) &pe_area); pe_cnt++;
766 }
767 if (p->input_style & XIMPreeditPosition0x0004L) {
16
Taking false branch
768 pe_area.x = 0;
769 pe_area.y = 0;
770 pe_area.width = w->core.width;
771 pe_area.height = w->core.height;
772 margin = &(((TextWidget)w)->text.margin);
773 pe_area.x += margin->left;
774 pe_area.y += margin->top;
775 pe_area.width -= (margin->left + margin->right - 1);
776 pe_area.height -= (margin->top + margin->bottom - 1);
777 SetVaArg( &pe_a[pe_cnt], (XPointer) XNArea"area"); pe_cnt++;
778 SetVaArg( &pe_a[pe_cnt], (XPointer) &pe_area); pe_cnt++;
779 if (p->flg & CICursorP(1 << 5)) {
780 _XawMultiSinkPosToXY(w, p->cursor_position, &position.x, &position.y);
781 } else {
782 position.x = position.y = 0;
783 }
784 SetVaArg( &pe_a[pe_cnt], (XPointer) XNSpotLocation"spotLocation"); pe_cnt++;
785 SetVaArg( &pe_a[pe_cnt], (XPointer) &position); pe_cnt++;
786 }
787 if (p->input_style & XIMStatusArea0x0100L) {
17
Taking true branch
788 st_area.x = 0;
789 st_area.y = ve->parent->core.height - height;
790 st_area.width = ve->parent->core.width;
791 st_area.height = height;
792 SetVaArg( &st_a[st_cnt], (XPointer) XNArea"area"); st_cnt++;
793 SetVaArg( &st_a[st_cnt], (XPointer) &st_area); st_cnt++;
794 }
795
796 SetVaArg( &ic_a[ic_cnt], (XPointer) XNInputStyle"inputStyle"); ic_cnt++;
797 SetVaArg( &ic_a[ic_cnt], (XPointer) p->input_style); ic_cnt++;
798 SetVaArg( &ic_a[ic_cnt], (XPointer) XNClientWindow"clientWindow"); ic_cnt++;
799 SetVaArg( &ic_a[ic_cnt], (XPointer) XtWindow(ve->parent)((ve->parent)->core.window)); ic_cnt++;
800 SetVaArg( &ic_a[ic_cnt], (XPointer) XNFocusWindow"focusWindow"); ic_cnt++;
801 SetVaArg( &ic_a[ic_cnt], (XPointer) XtWindow(w)((w)->core.window)); ic_cnt++;
802
803 if (pe_cnt > 0) {
18
Taking false branch
804 SetVaArg( &pe_a[pe_cnt], (XPointer) NULL((void*)0));
805 pe_attr = XVaCreateNestedList(0, pe_a[0], pe_a[1], pe_a[2], pe_a[3],
806 pe_a[4], pe_a[5], pe_a[6], pe_a[7], pe_a[8],
807 pe_a[9], pe_a[10], pe_a[11], pe_a[12],
808 pe_a[13], pe_a[14], pe_a[15], pe_a[16],
809 pe_a[17], pe_a[18], pe_a[19], NULL((void*)0));
810 SetVaArg( &ic_a[ic_cnt], (XPointer) XNPreeditAttributes"preeditAttributes"); ic_cnt++;
811 SetVaArg( &ic_a[ic_cnt], (XPointer) pe_attr); ic_cnt++;
812 }
813
814 if (st_cnt > 0) {
19
Taking true branch
815 SetVaArg( &st_a[st_cnt], (XPointer) NULL((void*)0));
816 st_attr = XVaCreateNestedList(0, st_a[0], st_a[1], st_a[2], st_a[3],
20
Function call argument is an uninitialized value
817 st_a[4], st_a[5], st_a[6], st_a[7], st_a[8],
818 st_a[9], st_a[10], st_a[11], st_a[12],
819 st_a[13], st_a[14], st_a[15], st_a[16],
820 st_a[17], st_a[18], st_a[19], NULL((void*)0));
821 SetVaArg( &ic_a[ic_cnt], (XPointer) XNStatusAttributes"statusAttributes"); ic_cnt++;
822 SetVaArg( &ic_a[ic_cnt], (XPointer) st_attr); ic_cnt++;
823 }
824 SetVaArg( &ic_a[ic_cnt], (XPointer) NULL((void*)0));
825
826 p->xic = XCreateIC(ve->im.xim, ic_a[0], ic_a[1], ic_a[2], ic_a[3],
827 ic_a[4], ic_a[5], ic_a[6], ic_a[7], ic_a[8], ic_a[9],
828 ic_a[10], ic_a[11], ic_a[12], ic_a[13], ic_a[14],
829 ic_a[15], ic_a[16], ic_a[17], ic_a[18], ic_a[19], NULL((void*)0));
830 if (pe_attr) XtFree(pe_attr);
831 if (st_attr) XtFree(st_attr);
832
833 if (p->xic == NULL((void*)0)) {
834 p->openic_error = True1;
835 return;
836 }
837
838 SizeNegotiation(p, ve->parent->core.width, ve->parent->core.height);
839
840 p->flg &= ~(CIFontSet(1 << 1) | CIFg(1 << 2) | CIBg(1 << 3) | CIBgPixmap(1 << 4) | CICursorP(1 << 5) | CILineS(1 << 6));
841
842 if (!IsSharedIC(ve)) {
843 if (p->input_style & XIMPreeditPosition0x0004L) {
844 XtAddEventHandler(w, (EventMask)StructureNotifyMask(1L<<17), FALSE0,
845 (XtEventHandler)ConfigureCB, (Opaque)NULL((void*)0));
846 }
847 }
848}
849
850static void
851SetICValues(Widget w, XawVendorShellExtPart *ve, Boolean focus)
852{
853 XawIcTableList p;
854 XPoint position;
855 XRectangle pe_area;
856 XVaNestedList pe_attr = NULL((void*)0), st_attr = NULL((void*)0);
857 XPointer ic_a[20], pe_a[20], st_a[20];
858 int ic_cnt = 0, pe_cnt = 0, st_cnt = 0;
859 XawTextMargin *margin;
860 int height;
861
862 if ((ve->im.xim == NULL((void*)0)) || ((p = GetIcTableShared(w, ve)) == NULL((void*)0)) ||
863 (p->xic == NULL((void*)0))) return;
864
865 if (IsSharedIC(ve)) SetICValuesShared(w, ve, p, TRUE1);
866 XFlush(XtDisplay(w)(((w)->core.screen)->display));
867 if (focus == FALSE0 &&
868 !(p->flg & (CIFontSet(1 << 1) | CIFg(1 << 2) | CIBg(1 << 3) |
869 CIBgPixmap(1 << 4) | CICursorP(1 << 5) | CILineS(1 << 6)))) return;
870#ifdef SPOT
871 if ((p->input_style & XIMPreeditPosition0x0004L)
872 && ((!IsSharedIC(ve) && ((p->flg & ~CIICFocus(1 << 0)) == CICursorP(1 << 5)))
873 || (IsSharedIC(ve) && p->flg == CICursorP(1 << 5)))) {
874 _XawMultiSinkPosToXY(w, p->cursor_position, &position.x, &position.y);
875 _XipChangeSpot(p->xic, position.x, position.y);
876 p->flg &= ~CICursorP(1 << 5);
877 return;
878 }
879#endif
880
881 if (p->input_style & (XIMPreeditArea0x0001L|XIMPreeditPosition0x0004L|XIMStatusArea0x0100L)) {
882 if (p->flg & CIFontSet(1 << 1)) {
883 SetVaArg( &pe_a[pe_cnt], (XPointer) XNFontSet"fontSet"); pe_cnt++;
884 SetVaArg( &pe_a[pe_cnt], (XPointer) p->font_set); pe_cnt++;
885 SetVaArg( &st_a[st_cnt], (XPointer) XNFontSet"fontSet"); st_cnt++;
886 SetVaArg( &st_a[st_cnt], (XPointer) p->font_set); st_cnt++;
887 height = maxAscentOfFontSet(p->font_set)( - (XExtentsOfFontSet((p->font_set)))->max_logical_extent
.y)
888 + maxDescentOfFontSet(p->font_set)(((XExtentsOfFontSet((p->font_set)))->max_logical_extent
.height) - ( - (XExtentsOfFontSet((p->font_set)))->max_logical_extent
.y))
;
889 height = SetVendorShellHeight(ve, height);
890 }
891 if (p->flg & CIFg(1 << 2)) {
892 SetVaArg( &pe_a[pe_cnt], (XPointer) XNForeground"foreground"); pe_cnt++;
893 SetVaArg( &pe_a[pe_cnt], (XPointer) p->foreground); pe_cnt++;
894 SetVaArg( &st_a[st_cnt], (XPointer) XNForeground"foreground"); st_cnt++;
895 SetVaArg( &st_a[st_cnt], (XPointer) p->foreground); st_cnt++;
896 }
897 if (p->flg & CIBg(1 << 3)) {
898 SetVaArg( &pe_a[pe_cnt], (XPointer) XNBackground"background"); pe_cnt++;
899 SetVaArg( &pe_a[pe_cnt], (XPointer) p->background); pe_cnt++;
900 SetVaArg( &st_a[st_cnt], (XPointer) XNBackground"background"); st_cnt++;
901 SetVaArg( &st_a[st_cnt], (XPointer) p->background); st_cnt++;
902 }
903 if (p->flg & CIBgPixmap(1 << 4)) {
904 SetVaArg( &pe_a[pe_cnt], (XPointer) XNBackgroundPixmap"backgroundPixmap"); pe_cnt++;
905 SetVaArg( &pe_a[pe_cnt], (XPointer) p->bg_pixmap); pe_cnt++;
906 SetVaArg( &st_a[st_cnt], (XPointer) XNBackgroundPixmap"backgroundPixmap"); st_cnt++;
907 SetVaArg( &st_a[st_cnt], (XPointer) p->bg_pixmap); st_cnt++;
908 }
909 if (p->flg & CILineS(1 << 6)) {
910 SetVaArg( &pe_a[pe_cnt], (XPointer) XNLineSpace"lineSpace"); pe_cnt++;
911 SetVaArg( &pe_a[pe_cnt], (XPointer) p->line_spacing); pe_cnt++;
912 SetVaArg( &st_a[st_cnt], (XPointer) XNLineSpace"lineSpace"); st_cnt++;
913 SetVaArg( &st_a[st_cnt], (XPointer) p->line_spacing); st_cnt++;
914 }
915 }
916 if (p->input_style & XIMPreeditPosition0x0004L) {
917 if (p->flg & CICursorP(1 << 5)) {
918 _XawMultiSinkPosToXY(w, p->cursor_position, &position.x, &position.y);
919 SetVaArg( &pe_a[pe_cnt], (XPointer) XNSpotLocation"spotLocation"); pe_cnt++;
920 SetVaArg( &pe_a[pe_cnt], (XPointer) &position); pe_cnt++;
921 }
922 }
923 if (IsSharedIC(ve)) {
924 if (p->input_style & XIMPreeditPosition0x0004L) {
925 pe_area.x = 0;
926 pe_area.y = 0;
927 pe_area.width = w->core.width;
928 pe_area.height = w->core.height;
929 margin = &(((TextWidget)w)->text.margin);
930 pe_area.x += margin->left;
931 pe_area.y += margin->top;
932 pe_area.width -= (margin->left + margin->right - 1);
933 pe_area.height -= (margin->top + margin->bottom - 1);
934 SetVaArg( &pe_a[pe_cnt], (XPointer) XNArea"area"); pe_cnt++;
935 SetVaArg( &pe_a[pe_cnt], (XPointer) &pe_area); pe_cnt++;
936 }
937 }
938
939 if (pe_cnt > 0) {
940 SetVaArg( &pe_a[pe_cnt], (XPointer) NULL((void*)0));
941 pe_attr = XVaCreateNestedList(0, pe_a[0], pe_a[1], pe_a[2], pe_a[3],
942 pe_a[4], pe_a[5], pe_a[6], pe_a[7],
943 pe_a[8], pe_a[9], pe_a[10], pe_a[11],
944 pe_a[12], pe_a[13], pe_a[14], pe_a[15],
945 pe_a[16], pe_a[17], pe_a[18], pe_a[19], NULL((void*)0));
946 SetVaArg( &ic_a[ic_cnt], (XPointer) XNPreeditAttributes"preeditAttributes"); ic_cnt++;
947 SetVaArg( &ic_a[ic_cnt], (XPointer) pe_attr); ic_cnt++;
948 }
949 if (st_cnt > 0) {
950 SetVaArg( &st_a[st_cnt], (XPointer) NULL((void*)0));
951 st_attr = XVaCreateNestedList(0, st_a[0], st_a[1], st_a[2], st_a[3],
952 st_a[4], st_a[5], st_a[6], st_a[7],
953 st_a[8], st_a[9], st_a[10], st_a[11],
954 st_a[12], st_a[13], st_a[14], st_a[15],
955 st_a[16], st_a[17], st_a[18], st_a[19], NULL((void*)0));
956 SetVaArg( &ic_a[ic_cnt], (XPointer) XNStatusAttributes"statusAttributes"); ic_cnt++;
957 SetVaArg( &ic_a[ic_cnt], (XPointer) st_attr); ic_cnt++;
958 }
959 if (focus == TRUE1) {
960 SetVaArg( &ic_a[ic_cnt], (XPointer) XNFocusWindow"focusWindow"); ic_cnt++;
961 SetVaArg( &ic_a[ic_cnt], (XPointer) XtWindow(w)((w)->core.window)); ic_cnt++;
962 }
963 if (ic_cnt > 0) {
964 SetVaArg( &ic_a[ic_cnt], (XPointer) NULL((void*)0));
965 XSetICValues(p->xic, ic_a[0], ic_a[1], ic_a[2], ic_a[3], ic_a[4],
966 ic_a[5], ic_a[6], ic_a[7], ic_a[8], ic_a[9], ic_a[10],
967 ic_a[11], ic_a[12], ic_a[13], ic_a[14], ic_a[15],
968 ic_a[16], ic_a[17], ic_a[18], ic_a[19], NULL((void*)0));
969 if (pe_attr) XtFree(pe_attr);
970 if (st_attr) XtFree(st_attr);
971 }
972
973 if (IsSharedIC(ve) && p->flg & CIFontSet(1 << 1))
974 SizeNegotiation(p, ve->parent->core.width, ve->parent->core.height);
975
976 p->flg &= ~(CIFontSet(1 << 1) | CIFg(1 << 2) | CIBg(1 << 3) | CIBgPixmap(1 << 4) | CICursorP(1 << 5) | CILineS(1 << 6));
977}
978
979static void
980SharedICChangeFocusWindow(Widget w, XawVendorShellExtPart *ve, XawIcTableList p)
981{
982 XawIcTableList pp;
983
984 if (w == NULL((void*)0)) {
985 ve->ic.current_ic_table = NULL((void*)0);
986 return;
987 }
988 if ((pp = GetIcTable(w, ve)) == NULL((void*)0)) return;
989 ve->ic.current_ic_table = pp;
990 SetICValues(w, ve, TRUE1);
991}
992
993static XawIcTableList
994CurrentSharedIcTable(XawVendorShellExtPart *ve)
995{
996 return(ve->ic.current_ic_table);
997}
998
999static void
1000SetICFocus(Widget w, XawVendorShellExtPart *ve)
1001{
1002 XawIcTableList p, pp;
1003
1004 if ((ve->im.xim == NULL((void*)0)) || ((p = GetIcTableShared(w, ve)) == NULL((void*)0)) ||
1005 (p->xic == NULL((void*)0))) return;
1006
1007 if (IsSharedIC(ve)) {
1008 pp = CurrentSharedIcTable(ve);
1009 if (pp == NULL((void*)0) || pp->widget != w) {
1010 SharedICChangeFocusWindow(w, ve, p);
1011 }
1012 }
1013 if (p->flg & CIICFocus(1 << 0) && p->ic_focused == FALSE0) {
1014 p->ic_focused = TRUE1;
1015 XSetICFocus(p->xic);
1016 }
1017 p->flg &= ~CIICFocus(1 << 0);
1018}
1019
1020static void
1021UnsetICFocus(Widget w, XawVendorShellExtPart *ve)
1022{
1023 XawIcTableList p, pp;
1024
1025 if ((ve->im.xim == NULL((void*)0)) || ((p = GetIcTableShared(w, ve)) == NULL((void*)0)) ||
1026 (p->xic == NULL((void*)0))) return;
1027
1028 if (IsSharedIC(ve) && (pp = CurrentSharedIcTable(ve))) {
1029 if (pp->widget != w) {
1030 return;
1031 }
1032 SharedICChangeFocusWindow(NULL((void*)0), ve, p);
1033 }
1034 if (p->ic_focused == TRUE1) {
1035 XUnsetICFocus(p->xic);
1036 p->ic_focused = FALSE0;
1037 }
1038}
1039
1040static void
1041SetValues(Widget w, XawVendorShellExtPart *ve, ArgList args, Cardinal num_args)
1042{
1043 ArgList arg;
1044
1045 XrmName argName;
1046 XrmResourceList xrmres;
1047 int i;
1048 XawIcTablePart *p, save_tbl;
1049
1050 if ((p = GetIcTable(w, ve)) == NULL((void*)0)) return;
1051
1052 memcpy(&save_tbl, p, sizeof(XawIcTablePart))__builtin___memcpy_chk (&save_tbl, p, sizeof(XawIcTablePart
), __builtin_object_size (&save_tbl, 0))
;
1053
1054 for (arg = args ; num_args != 0; num_args--, arg++) {
1055 argName = XrmStringToName(arg->name)XrmStringToQuark(arg->name);
1056 for (xrmres = (XrmResourceList)ve->im.resources, i = 0;
1057 i < ve->im.num_resources; i++, xrmres++) {
1058 if (argName == xrmres->xrm_name) {
1059 _XtCopyFromArg(arg->value,
1060 (char *)p - xrmres->xrm_offset - 1,
1061 xrmres->xrm_size);
1062 break;
1063 }
1064 }
1065 }
1066 if (p->font_set != save_tbl.font_set) {
1067 p->flg |= CIFontSet(1 << 1);
1068 }
1069 if (p->foreground != save_tbl.foreground) {
1070 p->flg |= CIFg(1 << 2);
1071 }
1072 if (p->background !=save_tbl.background) {
1073 p->flg |= CIBg(1 << 3);
1074 }
1075 if (p->bg_pixmap != save_tbl.bg_pixmap) {
1076 p->flg |= CIBgPixmap(1 << 4);
1077 }
1078 if (p->cursor_position != save_tbl.cursor_position) {
1079 p->flg |= CICursorP(1 << 5);
1080 }
1081 if (p->line_spacing != save_tbl.line_spacing) {
1082 p->flg |= CILineS(1 << 6);
1083 }
1084 p->prev_flg |= p->flg;
1085}
1086
1087static void
1088SetFocus(Widget w, XawVendorShellExtPart *ve)
1089{
1090 XawIcTableList p;
1091 if ((p = GetIcTableShared(w, ve)) == NULL((void*)0)) return;
1092
1093 if ( p->ic_focused == FALSE0 || IsSharedIC(ve)) {
1094 p->flg |= CIICFocus(1 << 0);
1095 }
1096 p->prev_flg |= p->flg;
1097}
1098
1099static void
1100DestroyIC(Widget w, XawVendorShellExtPart *ve)
1101{
1102 XawIcTableList p;
1103
1104 if ((ve->im.xim == NULL((void*)0)) || ((p = GetIcTableShared(w, ve)) == NULL((void*)0)) ||
1105 (p->xic == NULL((void*)0))) return;
1106 if (IsSharedIC(ve)) {
1107 if (GetIcTable(w, ve) == ve->ic.current_ic_table) {
1108 UnsetICFocus(w, ve);
1109 }
1110 return;
1111 }
1112 XDestroyIC(p->xic);
1113 if (!IsSharedIC(ve)) {
1114 if (p->input_style & XIMPreeditPosition0x0004L) {
1115 XtRemoveEventHandler(w, (EventMask)StructureNotifyMask(1L<<17), FALSE0,
1116 (XtEventHandler)ConfigureCB, (Opaque)NULL((void*)0));
1117 }
1118 }
1119}
1120
1121static void
1122SetFocusValues(Widget inwidg, ArgList args, Cardinal num_args, Boolean focus)
1123{
1124 XawVendorShellExtPart *ve;
1125 VendorShellWidget vw;
1126
1127 if ((vw = SearchVendorShell(inwidg)) == NULL((void*)0)) return;
1128 if ((ve = GetExtPart(vw))) {
1129 if (num_args > 0) SetValues(inwidg, ve, args, num_args);
1130 if (focus) SetFocus(inwidg, ve);
1131 if (XtIsRealized((Widget)vw)(XtWindowOfObject((Widget)vw) != 0L) && ve->im.xim) {
1132 if (IsCreatedIC(inwidg, ve)) {
1133 SetICValues(inwidg, ve, FALSE0);
1134 if (focus) SetICFocus(inwidg, ve);
1135 } else {
1136 CreateIC(inwidg, ve);
1137 SetICFocus(inwidg, ve);
1138 }
1139 }
1140 }
1141}
1142
1143static void
1144UnsetFocus(Widget inwidg)
1145{
1146 XawVendorShellExtPart *ve;
1147 VendorShellWidget vw;
1148 XawIcTableList p;
1149
1150 if ((vw = SearchVendorShell(inwidg)) == NULL((void*)0)) return;
1151 if ((ve = GetExtPart(vw))) {
1152 if ((p = GetIcTableShared(inwidg, ve)) == NULL((void*)0)) return;
1153 if (p->flg & CIICFocus(1 << 0)) {
1154 p->flg &= ~CIICFocus(1 << 0);
1155 }
1156 p->prev_flg &= ~CIICFocus(1 << 0);
1157 if (ve->im.xim && XtIsRealized((Widget)vw)(XtWindowOfObject((Widget)vw) != 0L) && p->xic) {
1158 UnsetICFocus(inwidg, ve);
1159 }
1160 }
1161}
1162
1163static Boolean
1164IsRegistered(Widget w, XawVendorShellExtPart *ve)
1165{
1166 XawIcTableList p;
1167
1168 for (p = ve->ic.ic_table; p; p = p->next)
1169 {
1170 if (p->widget == w) return(TRUE1);
1171 }
1172 return(FALSE0);
1173}
1174
1175static void
1176Register(Widget inwidg, XawVendorShellExtPart *ve)
1177{
1178 if (ve->im.xim == NULL((void*)0))
5
Taking false branch
1179 {
1180 OpenIM(ve);
1181 }
1182
1183 if (IsRegistered(inwidg, ve)) return;
6
Taking false branch
1184
1185 if (RegisterToVendorShell(inwidg, ve) == FALSE0) return;
7
Taking false branch
1186
1187 if (ve->im.xim == NULL((void*)0)) return;
8
Taking false branch
1188
1189 if (XtIsRealized(ve->parent)(XtWindowOfObject(ve->parent) != 0L))
9
Taking true branch
1190 {
1191 CreateIC(inwidg, ve);
10
Calling 'CreateIC'
1192 SetICFocus(inwidg, ve);
1193 }
1194}
1195
1196static Boolean
1197NoRegistered(XawVendorShellExtPart *ve)
1198{
1199 if (ve->ic.ic_table == NULL((void*)0)) return(TRUE1);
1200 return(FALSE0);
1201}
1202
1203static void
1204Unregister(Widget inwidg, XawVendorShellExtPart *ve)
1205{
1206 if (!IsRegistered(inwidg, ve)) return;
1207
1208 DestroyIC(inwidg, ve);
1209
1210 UnregisterFromVendorShell(inwidg, ve);
1211
1212 if (NoRegistered(ve))
1213 {
1214 CloseIM(ve);
1215 ve->im.xim = NULL((void*)0);
1216 /*
1217 * resize vendor shell to core size
1218 */
1219 (void) SetVendorShellHeight(ve, 0);
1220 }
1221}
1222
1223static void
1224AllCreateIC(XawVendorShellExtPart *ve)
1225{
1226 XawIcTableList p;
1227
1228 if (ve->im.xim == NULL((void*)0)) return;
1229 if (IsSharedIC(ve) && ve->ic.ic_table[0].widget) {
1230 p = ve->ic.shared_ic_table;
1231 if (p->xic == NULL((void*)0))
1232 CreateIC(ve->ic.ic_table[0].widget, ve);
1233 SetICFocus(ve->ic.ic_table[0].widget, ve);
1234 return;
1235 }
1236 for (p = ve->ic.ic_table; p; p = p->next) {
1237 if (p->xic == NULL((void*)0))
1238 CreateIC(p->widget, ve);
1239 }
1240 for (p = ve->ic.ic_table; p; p = p->next) {
1241 SetICFocus(p->widget, ve);
1242 }
1243}
1244
1245
1246static void
1247Reconnect(XawVendorShellExtPart *ve)
1248{
1249 XawIcTableList p;
1250
1251 ve->im.open_im = True1;
1252 if (ve->im.xim == NULL((void*)0)) {
1253 OpenIM(ve);
1254 }
1255 if (ve->im.xim == NULL((void*)0)) return;
1256
1257 if (IsSharedIC(ve)) {
1258 p = ve->ic.shared_ic_table;
1259 p->flg = p->prev_flg;
1260 p->openic_error = FALSE0;
1261 } else {
1262 for (p = ve->ic.ic_table; p; p = p->next) {
1263 p->flg = p->prev_flg;
1264 p->openic_error = FALSE0;
1265 }
1266 }
1267 AllCreateIC(ve);
1268}
1269
1270
1271static void
1272CompileResourceList(XtResourceList res, unsigned int num_res)
1273{
1274 unsigned int count;
1275
1276#define xrmres ((XrmResourceList) res)
1277 for (count = 0; count < num_res; res++, count++) {
1278 xrmres->xrm_name = XrmPermStringToQuark(res->resource_name);
1279 xrmres->xrm_class = XrmPermStringToQuark(res->resource_class);
1280 xrmres->xrm_type = XrmPermStringToQuark(res->resource_type);
1281 xrmres->xrm_offset = -res->resource_offset - 1;
1282 xrmres->xrm_default_type = XrmPermStringToQuark(res->default_type);
1283 }
1284#undef xrmres
1285}
1286
1287static Boolean
1288Initialize(VendorShellWidget vw, XawVendorShellExtPart *ve)
1289{
1290 if (!XtIsVendorShell((Widget)vw)(_XtIsSubclassOf((Widget)vw, (WidgetClass)vendorShellWidgetClass
, (WidgetClass)wmShellWidgetClass, (XtEnum)0x40))
) return(FALSE0);
1291 ve->parent = (Widget)vw;
1292 ve->im.xim = NULL((void*)0);
1293 ve->im.area_height = 0;
1294 ve->im.resources = (XrmResourceList)XtMalloc(sizeof(resources));
1295 if (ve->im.resources == NULL((void*)0)) return(FALSE0);
1296 memcpy((char *)ve->im.resources, (char *)resources, sizeof(resources))__builtin___memcpy_chk ((char *)ve->im.resources, (char *)
resources, sizeof(resources), __builtin_object_size ((char *)
ve->im.resources, 0))
;
1297 ve->im.num_resources = XtNumber(resources)((Cardinal) (sizeof(resources) / sizeof(resources[0])));
1298 CompileResourceList( (XtResourceList) ve->im.resources,
1299 ve->im.num_resources );
1300 if ((ve->ic.shared_ic_table = CreateIcTable( (Widget)vw, ve)) == NULL((void*)0))
1301 return(FALSE0);
1302 ve->ic.current_ic_table = NULL((void*)0);
1303 ve->ic.ic_table = NULL((void*)0);
1304 return(TRUE1);
1305}
1306
1307
1308/* Destroy()
1309 *
1310 * This frees all (most?) of the resources malloced by XawIm.
1311 * It is called by _XawImDestroy, which is called by Vendor.c's
1312 * VendorExt's Destroy method. Sheeran, Omron KK, 93/08/05 */
1313
1314static void
1315Destroy(Widget w, XawVendorShellExtPart *ve)
1316{
1317 contextDataRec *contextData;
1318 contextErrDataRec *contextErrData;
1319
1320 if (!XtIsVendorShell( w )(_XtIsSubclassOf(w, (WidgetClass)vendorShellWidgetClass, (WidgetClass
)wmShellWidgetClass, (XtEnum)0x40))
)
1321 return;
1322 XtFree( (char*) ve->im.resources );
1323
1324 if (extContext != (XContext)0 &&
1325 !XFindContext (XtDisplay (w)(((w)->core.screen)->display), (Window)w,
1326 extContext, (XPointer*)&contextData))
1327 XtFree( (char*) contextData );
1328
1329 if (errContext != (XContext)0 &&
1330 !XFindContext (XDisplayOfIM( ve->im.xim ), (Window) ve->im.xim,
1331 errContext, (XPointer*) &contextErrData))
1332 XtFree( (char*) contextErrData );
1333}
1334
1335/*********************************************
1336 *
1337 * SEMI-PRIVATE FUNCTIONS
1338 * For use by other Xaw modules
1339 *
1340 ********************************************/
1341
1342void
1343_XawImResizeVendorShell(
1344 Widget w )
1345{
1346 XawVendorShellExtPart *ve;
1347
1348 if ( ( ve = GetExtPart( (VendorShellWidget) w ) ) && ve->im.xim ) {
1349 ResizeVendorShell( (VendorShellWidget) w, ve );
1350 }
1351}
1352
1353
1354Dimension
1355_XawImGetShellHeight(
1356 Widget w )
1357{
1358 XawVendorShellExtPart *ve;
1359
1360 if (!XtIsVendorShell( w )(_XtIsSubclassOf(w, (WidgetClass)vendorShellWidgetClass, (WidgetClass
)wmShellWidgetClass, (XtEnum)0x40))
) return( w->core.height );
1361 if ((ve = GetExtPart( (VendorShellWidget) w ))) {
1362 return( w->core.height - ve->im.area_height );
1363 }
1364 return( w->core.height );
1365}
1366
1367void
1368_XawImRealize(
1369 Widget w )
1370{
1371 XawVendorShellExtPart *ve;
1372
1373 if ( !XtIsRealized( w )(XtWindowOfObject(w) != 0L) || !XtIsVendorShell( w )(_XtIsSubclassOf(w, (WidgetClass)vendorShellWidgetClass, (WidgetClass
)wmShellWidgetClass, (XtEnum)0x40))
) return;
1374 if ((ve = GetExtPart( (VendorShellWidget) w ))) {
1375 XtAddEventHandler( w, (EventMask)StructureNotifyMask(1L<<17), FALSE0,
1376 XawVendorShellExtResize, (XtPointer)NULL((void*)0) );
1377 AllCreateIC(ve);
1378 }
1379}
1380
1381void
1382_XawImInitialize(
1383 Widget w,
1384 Widget ext )
1385{
1386 XawVendorShellExtPart *ve;
1387
1388 if ( !XtIsVendorShell( w )(_XtIsSubclassOf(w, (WidgetClass)vendorShellWidgetClass, (WidgetClass
)wmShellWidgetClass, (XtEnum)0x40))
) return;
1389 if ((ve = SetExtPart( (VendorShellWidget) w, (XawVendorShellExtWidget)ext)) ) {
1390 if ( Initialize( (VendorShellWidget) w, ve ) == FALSE0 ) return;
1391 XtAddCallback( w, XtNdestroyCallback((char*)&XtStrings[169]), VendorShellDestroyed,
1392 (XtPointer) NULL((void*)0) );
1393 }
1394}
1395
1396void
1397_XawImReconnect(
1398 Widget inwidg )
1399{
1400 XawVendorShellExtPart *ve;
1401 VendorShellWidget vw;
1402
1403 if ((vw = SearchVendorShell(inwidg)) == NULL((void*)0)) return;
1404 if ((ve = GetExtPart(vw))) {
1405 Reconnect(ve);
1406 }
1407}
1408
1409void
1410_XawImRegister(
1411 Widget inwidg)
1412{
1413 XawVendorShellExtPart *ve;
1414 VendorShellWidget vw;
1415
1416 if ((vw = SearchVendorShell(inwidg)) == NULL((void*)0)) return;
1
Taking false branch
1417 if ((ve = GetExtPart(vw))) {
2
Assuming 've' is not null
3
Taking true branch
1418 Register(inwidg, ve);
4
Calling 'Register'
1419 }
1420}
1421
1422void
1423_XawImUnregister(
1424 Widget inwidg)
1425{
1426 XawVendorShellExtPart *ve;
1427 VendorShellWidget vw;
1428
1429 if ((vw = SearchVendorShell(inwidg)) == NULL((void*)0)) return;
1430 if ((ve = GetExtPart(vw))) {
1431 Unregister(inwidg, ve);
1432 }
1433}
1434
1435void
1436_XawImSetValues(
1437 Widget inwidg,
1438 ArgList args,
1439 Cardinal num_args )
1440{
1441 SetFocusValues( inwidg, args, num_args, FALSE0 );
1442}
1443
1444void
1445_XawImVASetValues( Widget inwidg, ... )
1446{
1447 va_list var;
1448 ArgList args = NULL((void*)0);
1449 Cardinal num_args;
1450 int total_count, typed_count;
1451
1452 Va_start( var, inwidg )__builtin_va_start(var, inwidg);
1453 _XtCountVaList( var, &total_count, &typed_count );
1454 va_end( var )__builtin_va_end(var);
1455
1456 Va_start( var, inwidg )__builtin_va_start(var, inwidg);
1457
1458 _XtVaToArgList( inwidg, var, total_count, &args, &num_args );
1459 _XawImSetValues( inwidg, args, num_args );
1460 if ( args != NULL((void*)0) ) {
1461 XtFree( (XtPointer) args );
1462 }
1463 va_end( var )__builtin_va_end(var);
1464}
1465
1466void
1467_XawImSetFocusValues(
1468 Widget inwidg,
1469 ArgList args,
1470 Cardinal num_args)
1471{
1472 SetFocusValues(inwidg, args, num_args, TRUE1);
1473}
1474
1475void
1476_XawImVASetFocusValues(Widget inwidg, ...)
1477{
1478 va_list var;
1479 ArgList args = NULL((void*)0);
1480 Cardinal num_args;
1481 int total_count, typed_count;
1482
1483 Va_start(var, inwidg)__builtin_va_start(var, inwidg);
1484 _XtCountVaList(var, &total_count, &typed_count);
1485 va_end(var)__builtin_va_end(var);
1486
1487 Va_start(var,inwidg)__builtin_va_start(var, inwidg);
1488
1489 _XtVaToArgList(inwidg, var, total_count, &args, &num_args);
1490 _XawImSetFocusValues(inwidg, args, num_args);
1491 if (args != NULL((void*)0)) {
1492 XtFree((XtPointer)args);
1493 }
1494 va_end(var)__builtin_va_end(var);
1495}
1496
1497void
1498_XawImUnsetFocus(
1499 Widget inwidg)
1500{
1501 UnsetFocus(inwidg);
1502}
1503
1504int
1505_XawImWcLookupString(
1506 Widget inwidg,
1507 XKeyPressedEvent *event,
1508 wchar_t* buffer_return,
1509 int bytes_buffer,
1510 KeySym *keysym_return,
1511 Statusint *status_return)
1512{
1513 XawVendorShellExtPart* ve;
1514 VendorShellWidget vw;
1515 XawIcTableList p;
1516 int i, ret;
1517 char tmp_buf[64], *tmp_p;
1518 wchar_t* buf_p;
1519
1520 if ((vw = SearchVendorShell(inwidg)) && (ve = GetExtPart(vw)) &&
1521 ve->im.xim && (p = GetIcTableShared(inwidg, ve)) && p->xic) {
1522 return(XwcLookupString(p->xic, event, buffer_return, bytes_buffer,
1523 keysym_return, status_return));
1524 }
1525 ret = XLookupString( event, tmp_buf, 64, keysym_return,
1526 (XComposeStatus*) status_return );
1527 for ( i = 0, tmp_p = tmp_buf, buf_p = buffer_return; i < ret; i++ ) {
1528 *buf_p++ = _Xaw_atowc(*tmp_p++);
1529 }
1530 return( ret );
1531}
1532
1533int
1534_XawImGetImAreaHeight(
1535 Widget w)
1536{
1537 XawVendorShellExtPart *ve;
1538 VendorShellWidget vw;
1539
1540 if ((vw = SearchVendorShell(w)) && (ve = GetExtPart(vw))) {
1541 return(ve->im.area_height);
1542 }
1543 return(0);
1544}
1545
1546void
1547_XawImCallVendorShellExtResize(
1548 Widget w)
1549{
1550 VendorShellWidget vw;
1551
1552 if ((vw = SearchVendorShell(w)) && GetExtPart(vw)) {
1553 XawVendorShellExtResize((Widget)vw);
1554 }
1555}
1556
1557
1558/* _XawImDestroy()
1559 *
1560 * This should be called by the VendorExt from its
1561 * core Destroy method. Sheeran, Omron KK 93/08/05 */
1562
1563void
1564_XawImDestroy(
1565 Widget w,
1566 Widget ext )
1567{
1568 XawVendorShellExtPart *ve;
1569
1570 if ( !XtIsVendorShell( w )(_XtIsSubclassOf(w, (WidgetClass)vendorShellWidgetClass, (WidgetClass
)wmShellWidgetClass, (XtEnum)0x40))
) return;
1571 if ((ve = GetExtPart( (VendorShellWidget) w )))
1572 Destroy( w, ve );
1573}