XawIm.c revision 5ec34c4c
17a84e134Smrg/*
27a84e134Smrg * Copyright 1991 by OMRON Corporation
37a84e134Smrg *
47a84e134Smrg * Permission to use, copy, modify, distribute, and sell this software and its
57a84e134Smrg * documentation for any purpose is hereby granted without fee, provided that
67a84e134Smrg * the above copyright notice appear in all copies and that both that
77a84e134Smrg * copyright notice and this permission notice appear in supporting
87a84e134Smrg * documentation, and that the name of OMRON not be used in advertising or
97a84e134Smrg * publicity pertaining to distribution of the software without specific,
107a84e134Smrg * written prior permission.  OMRON makes no representations about the
117a84e134Smrg * suitability of this software for any purpose.  It is provided "as is"
127a84e134Smrg * without express or implied warranty.
137a84e134Smrg *
147a84e134Smrg * OMRON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
157a84e134Smrg * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
167a84e134Smrg * OMRON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
177a84e134Smrg * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
187a84e134Smrg * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION,
197a84e134Smrg * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
20421c997bSmrg * SOFTWARE.
217a84e134Smrg *
227a84e134Smrg *	Author:	Seiji Kuwari	OMRON Corporation
237a84e134Smrg *				kuwa@omron.co.jp
247a84e134Smrg *				kuwa%omron.co.jp@uunet.uu.net
25421c997bSmrg */
267a84e134Smrg
277a84e134Smrg
287a84e134Smrg/*
297a84e134Smrg
307a84e134SmrgCopyright 1994, 1998  The Open Group
317a84e134Smrg
327a84e134SmrgPermission to use, copy, modify, distribute, and sell this software and its
337a84e134Smrgdocumentation for any purpose is hereby granted without fee, provided that
347a84e134Smrgthe above copyright notice appear in all copies and that both that
357a84e134Smrgcopyright notice and this permission notice appear in supporting
367a84e134Smrgdocumentation.
377a84e134Smrg
387a84e134SmrgThe above copyright notice and this permission notice shall be included in
397a84e134Smrgall copies or substantial portions of the Software.
407a84e134Smrg
417a84e134SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
427a84e134SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
437a84e134SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
447a84e134SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
457a84e134SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
467a84e134SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
477a84e134Smrg
487a84e134SmrgExcept as contained in this notice, the name of The Open Group shall not be
497a84e134Smrgused in advertising or otherwise to promote the sale, use or other dealings
507a84e134Smrgin this Software without prior written authorization from The Open Group.
517a84e134Smrg
527a84e134Smrg*/
537a84e134Smrg
547a84e134Smrg#ifdef HAVE_CONFIG_H
557a84e134Smrg#include <config.h>
567a84e134Smrg#endif
577a84e134Smrg#include <X11/IntrinsicP.h>
587a84e134Smrg#include <X11/StringDefs.h>
597a84e134Smrg#include <X11/Xos.h>
607a84e134Smrg#include <X11/Xfuncs.h>
617a84e134Smrg#include <X11/ShellP.h>
627a84e134Smrg#include <X11/Xaw/TextP.h>
637a84e134Smrg#include <X11/Xaw/MultiSrc.h>
647a84e134Smrg#include <X11/Xaw/MultiSinkP.h>
657a84e134Smrg#include <X11/Xaw/XawImP.h>
667a84e134Smrg#include <X11/Xaw/VendorEP.h>
677a84e134Smrg#include "XawI18n.h"
687a84e134Smrg#include <ctype.h>
697a84e134Smrg
707a84e134Smrg#include <stdarg.h>
717a84e134Smrg
727a84e134Smrg#define maxAscentOfFontSet(fontset)     \
737a84e134Smrg        ( - (XExtentsOfFontSet((fontset)))->max_logical_extent.y)
747a84e134Smrg
757a84e134Smrg#define maxHeightOfFontSet(fontset) \
767a84e134Smrg        ((XExtentsOfFontSet((fontset)))->max_logical_extent.height)
777a84e134Smrg
787a84e134Smrg#define maxDescentOfFontSet(fontset) \
797a84e134Smrg        (maxHeightOfFontSet(fontset) - maxAscentOfFontSet(fontset))
807a84e134Smrg
817a84e134Smrg#define Offset(field) (XtOffsetOf(XawIcTablePart, field))
827a84e134Smrg
837a84e134Smrg/*****************************************************
847a84e134Smrg *
857a84e134Smrg * Forward reference prototypes
867a84e134Smrg *
877a84e134Smrg *****************************************************/
88421c997bSmrg
897a84e134Smrg/*
907a84e134Smrg * Prototypes
917a84e134Smrg */
927a84e134Smrgstatic void AllCreateIC(XawVendorShellExtPart*);
937a84e134Smrgstatic void CloseIM(XawVendorShellExtPart*);
947a84e134Smrgstatic void CompileResourceList(XtResourceList, unsigned int);
957a84e134Smrgstatic void ConfigureCB(Widget, XtPointer, XEvent*, Boolean*);
967a84e134Smrgstatic void CreateIC(Widget, XawVendorShellExtPart*);
977a84e134Smrgstatic XawIcTableList CreateIcTable(Widget, XawVendorShellExtPart*);
987a84e134Smrgstatic XawIcTableList CurrentSharedIcTable(XawVendorShellExtPart*);
997a84e134Smrgstatic void Destroy(Widget, XawVendorShellExtPart*);
1007a84e134Smrgstatic void DestroyAllIM(XawVendorShellExtPart*);
1017a84e134Smrgstatic void DestroyIC(Widget, XawVendorShellExtPart*);
1027a84e134Smrgstatic void FreeAllDataOfVendorShell(XawVendorShellExtPart*,
1037a84e134Smrg				     VendorShellWidget);
1047a84e134Smrgstatic XawVendorShellExtPart *GetExtPart(VendorShellWidget);
1057a84e134Smrgstatic XawIcTableList GetIcTable(Widget, XawVendorShellExtPart*);
1067a84e134Smrgstatic XawIcTableList GetIcTableShared(Widget, XawVendorShellExtPart*);
1077a84e134Smrgstatic XIMStyle GetInputStyleOfIC(XawVendorShellExtPart*);
1087a84e134Smrgstatic Bool Initialize(VendorShellWidget, XawVendorShellExtPart*);
1097a84e134Smrgstatic Bool IsCreatedIC(Widget, XawVendorShellExtPart*);
1107a84e134Smrgstatic Bool IsRegistered(Widget, XawVendorShellExtPart*);
1117a84e134Smrgstatic Bool IsSharedIC(XawVendorShellExtPart*);
1127a84e134Smrgstatic Bool NoRegistered(XawVendorShellExtPart*);
1137a84e134Smrgstatic void OpenIM(XawVendorShellExtPart*);
1147a84e134Smrgstatic void Reconnect(XawVendorShellExtPart*);
1157a84e134Smrgstatic void Register(Widget, XawVendorShellExtPart*);
1167a84e134Smrgstatic Bool RegisterToVendorShell(Widget, XawVendorShellExtPart*);
1177a84e134Smrgstatic void ResizeVendorShell(VendorShellWidget, XawVendorShellExtPart*);
1187a84e134Smrgstatic Bool ResizeVendorShell_Core(VendorShellWidget, XawVendorShellExtPart*,
1197a84e134Smrg				   XawIcTableList);
1207a84e134Smrgstatic VendorShellWidget SearchVendorShell(Widget);
1217a84e134Smrgstatic Widget SetErrCnxt(Widget, XIM);
1227a84e134Smrgstatic XawVendorShellExtPart *SetExtPart(VendorShellWidget,
1237a84e134Smrg					 XawVendorShellExtWidget);
1247a84e134Smrgstatic void SetFocus(Widget, XawVendorShellExtPart*);
1257a84e134Smrgstatic void SetFocusValues(Widget, ArgList, Cardinal, Bool);
1267a84e134Smrgstatic void SetICFocus(Widget, XawVendorShellExtPart*);
1277a84e134Smrgstatic void SetICValues(Widget, XawVendorShellExtPart*, Bool);
1287a84e134Smrgstatic void SetICValuesShared(Widget, XawVendorShellExtPart*, XawIcTableList,
1297a84e134Smrg			      Bool);
1307a84e134Smrgstatic void SetValues(Widget, XawVendorShellExtPart*, ArgList, Cardinal);
1317a84e134Smrgstatic unsigned int SetVendorShellHeight(XawVendorShellExtPart*,
1327a84e134Smrg					 unsigned int);
1337a84e134Smrgstatic void SharedICChangeFocusWindow(Widget, XawVendorShellExtPart*,
1347a84e134Smrg				      XawIcTableList);
1357a84e134Smrgstatic void SizeNegotiation(XawIcTableList, unsigned int, unsigned int);
1367a84e134Smrgstatic void Unregister(Widget, XawVendorShellExtPart*);
1377a84e134Smrgstatic void UnregisterFromVendorShell(Widget, XawVendorShellExtPart*);
1387a84e134Smrgstatic void UnsetFocus(Widget);
1397a84e134Smrgstatic void UnsetICFocus(Widget, XawVendorShellExtPart*);
1407a84e134Smrgstatic void VendorShellDestroyed(Widget, XtPointer, XtPointer);
1417a84e134Smrg
1427a84e134Smrg/*
1437a84e134Smrg * From Vendor.c
1447a84e134Smrg */
1457a84e134Smrgvoid XawVendorShellExtResize(Widget);
1467a84e134Smrgvoid XawVendorStructureNotifyHandler(Widget, XtPointer, XEvent*, Boolean*);
1477a84e134Smrg
1487a84e134Smrg
1497a84e134Smrg/*
1507a84e134Smrg * From Xt/Resources.c
1517a84e134Smrg */
1527a84e134Smrgvoid _XtCopyFromArg(XtArgVal src, char*, unsigned int);
1537a84e134Smrg
1547a84e134Smrgstatic XtResource resources[] =
1557a84e134Smrg{
1567a84e134Smrg    {
1577a84e134Smrg	XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet),
1585ec34c4cSmrg	Offset (font_set), XtRString, (XtPointer)XtDefaultFontSet
1597a84e134Smrg    },
1607a84e134Smrg    {
1617a84e134Smrg	XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
1627a84e134Smrg	Offset (foreground), XtRString, (XtPointer)"XtDefaultForeground"
1637a84e134Smrg    },
1647a84e134Smrg    {
1657a84e134Smrg	XtNbackground, XtCBackground, XtRPixel, sizeof(Pixel),
1667a84e134Smrg	Offset (background), XtRString, (XtPointer)"XtDefaultBackground"
1677a84e134Smrg    },
1687a84e134Smrg    {
1697a84e134Smrg	XtNbackgroundPixmap, XtCPixmap, XtRPixmap, sizeof(Pixmap),
1707a84e134Smrg	Offset (bg_pixmap), XtRImmediate, (XtPointer) XtUnspecifiedPixmap
1717a84e134Smrg    },
1727a84e134Smrg    {
1737a84e134Smrg	XtNinsertPosition, XtCTextPosition, XtRInt, sizeof (XawTextPosition),
1747a84e134Smrg	Offset (cursor_position), XtRImmediate, (XtPointer) 0
1757a84e134Smrg    }
1767a84e134Smrg};
1777a84e134Smrg#undef Offset
1787a84e134Smrg
1797a84e134Smrg
180ab902922Smrgstatic VendorShellWidget SearchVendorShell(Widget w)
1817a84e134Smrg{
1827a84e134Smrg    while(w && !XtIsShell(w)) w = XtParent(w);
1837a84e134Smrg    if (w && XtIsVendorShell(w)) return((VendorShellWidget)w);
1847a84e134Smrg    return(NULL);
1857a84e134Smrg}
1867a84e134Smrg
187421c997bSmrgstatic XContext extContext = (XContext)0;
1887a84e134Smrg
1897a84e134Smrgstatic XawVendorShellExtPart *
1907a84e134SmrgSetExtPart(VendorShellWidget w, XawVendorShellExtWidget vew)
1917a84e134Smrg{
1927a84e134Smrg    contextDataRec *contextData;
1937a84e134Smrg
194421c997bSmrg    if (extContext == (XContext)0) extContext = XUniqueContext();
1957a84e134Smrg
1967a84e134Smrg    contextData = XtNew(contextDataRec);
1977a84e134Smrg    contextData->parent = (Widget)w;
1987a84e134Smrg    contextData->ve = (Widget)vew;
1997a84e134Smrg    if (XSaveContext(XtDisplay(w), (Window)w, extContext, (char *)contextData)) {
2007a84e134Smrg	return(NULL);
2017a84e134Smrg    }
2027a84e134Smrg    return(&(vew->vendor_ext));
2037a84e134Smrg}
2047a84e134Smrg
2057a84e134Smrgstatic XawVendorShellExtPart *
2067a84e134SmrgGetExtPart(VendorShellWidget w)
2077a84e134Smrg{
2087a84e134Smrg    contextDataRec *contextData;
2097a84e134Smrg    XawVendorShellExtWidget vew;
2107a84e134Smrg
2117a84e134Smrg    if (XFindContext(XtDisplay(w), (Window)w, extContext,
2127a84e134Smrg		      (XPointer*)&contextData)) {
2137a84e134Smrg	return(NULL);
2147a84e134Smrg    }
2157a84e134Smrg    vew = (XawVendorShellExtWidget)contextData->ve;
2167a84e134Smrg    return(&(vew->vendor_ext));
2177a84e134Smrg}
2187a84e134Smrg
2197a84e134Smrgstatic Bool
2207a84e134SmrgIsSharedIC(XawVendorShellExtPart * ve)
2217a84e134Smrg{
2227a84e134Smrg    return( ve->ic.shared_ic );
2237a84e134Smrg}
2247a84e134Smrg
2257a84e134Smrgstatic XawIcTableList
2267a84e134SmrgGetIcTableShared(Widget w, XawVendorShellExtPart *ve)
2277a84e134Smrg{
2287a84e134Smrg    XawIcTableList	p;
2297a84e134Smrg
2307a84e134Smrg    for (p = ve->ic.ic_table; p; p = p->next) {
2317a84e134Smrg	if (p->widget == w) {
2327a84e134Smrg	    if (IsSharedIC(ve)) {
2337a84e134Smrg		return(ve->ic.shared_ic_table);
2347a84e134Smrg	    } else {
2357a84e134Smrg		return(p);
2367a84e134Smrg	    }
2377a84e134Smrg	}
2387a84e134Smrg    }
2397a84e134Smrg    return(NULL);
2407a84e134Smrg}
2417a84e134Smrg
2427a84e134Smrgstatic XawIcTableList
2437a84e134SmrgGetIcTable(Widget w, XawVendorShellExtPart *ve)
2447a84e134Smrg{
2457a84e134Smrg    XawIcTableList	p;
2467a84e134Smrg
2477a84e134Smrg    for (p = ve->ic.ic_table; p; p = p->next) {
2487a84e134Smrg	if (p->widget == w) {
2497a84e134Smrg	    return(p);
2507a84e134Smrg	}
2517a84e134Smrg    }
2527a84e134Smrg    return(NULL);
2537a84e134Smrg}
2547a84e134Smrg
2557a84e134Smrgstatic XIMStyle
2567a84e134SmrgGetInputStyleOfIC(XawVendorShellExtPart *ve)
2577a84e134Smrg{
2587a84e134Smrg
2597a84e134Smrg    if (!ve) return((XIMStyle)0);
2607a84e134Smrg    return(ve->ic.input_style);
2617a84e134Smrg}
2627a84e134Smrg
2637a84e134Smrg/*ARGSUSED*/
2647a84e134Smrgstatic void
2655ec34c4cSmrgConfigureCB(Widget w, XtPointer closure _X_UNUSED, XEvent *event, Boolean *unused _X_UNUSED)
2667a84e134Smrg{
2677a84e134Smrg    XawIcTableList		p;
2687a84e134Smrg    XawVendorShellExtPart	*ve;
2697a84e134Smrg    VendorShellWidget		vw;
2707a84e134Smrg    XVaNestedList		pe_attr;
2717a84e134Smrg    XRectangle			pe_area;
2727a84e134Smrg    XawTextMargin		*margin;
2737a84e134Smrg
2747a84e134Smrg    if (event->type != ConfigureNotify) return;
2757a84e134Smrg
2767a84e134Smrg    if ((vw = SearchVendorShell(w)) == NULL) return;
2777a84e134Smrg
2787a84e134Smrg    if ((ve = GetExtPart(vw)) != NULL) {
2797a84e134Smrg        if (IsSharedIC(ve)) return;
2807a84e134Smrg	if ((ve->im.xim == NULL) ||
2817a84e134Smrg	    ((p = GetIcTableShared(w, ve)) == NULL) ||
2827a84e134Smrg	    (p->xic == NULL) || !(p->input_style & XIMPreeditPosition)) return;
2837a84e134Smrg	pe_area.x = 0;
2847a84e134Smrg        pe_area.y = 0;
2857a84e134Smrg        pe_area.width = w->core.width;
2867a84e134Smrg        pe_area.height = w->core.height;
2877a84e134Smrg	margin = &(((TextWidget)w)->text.margin);
2885ec34c4cSmrg	pe_area.x = (short)(pe_area.x + margin->left);
2895ec34c4cSmrg	pe_area.y = (short)(pe_area.y + margin->top);
2905ec34c4cSmrg	pe_area.width = (unsigned short)(pe_area.width - (margin->left + margin->right - 1));
2915ec34c4cSmrg	pe_area.height = (unsigned short)(pe_area.height - (margin->top + margin->bottom - 1));
2927a84e134Smrg
2937a84e134Smrg	pe_attr = XVaCreateNestedList(0, XNArea, &pe_area, NULL);
2947a84e134Smrg	XSetICValues(p->xic, XNPreeditAttributes, pe_attr, NULL);
2957a84e134Smrg	XtFree(pe_attr);
2967a84e134Smrg    }
2977a84e134Smrg}
2987a84e134Smrg
299421c997bSmrgstatic XContext errContext = (XContext)0;
3007a84e134Smrg
3017a84e134Smrgstatic Widget SetErrCnxt(Widget w, XIM xim)
3027a84e134Smrg{
3037a84e134Smrg    contextErrDataRec *contextErrData;
3047a84e134Smrg
305421c997bSmrg    if (errContext == (XContext)0) errContext = XUniqueContext();
3067a84e134Smrg
3077a84e134Smrg    contextErrData = XtNew(contextErrDataRec);
3087a84e134Smrg    contextErrData->widget = w;
3097a84e134Smrg    contextErrData->xim = xim;
3107a84e134Smrg    if (XSaveContext(XtDisplay(w), (Window)xim, errContext,
3117a84e134Smrg	(char *)contextErrData)) {
3127a84e134Smrg	return(NULL);
3137a84e134Smrg    }
3147a84e134Smrg    return(contextErrData->widget);
3157a84e134Smrg}
3167a84e134Smrg
3177a84e134Smrg#if 0
3187a84e134Smrgstatic Widget
3197a84e134SmrgGetErrCnxt(XIM error_im)
3207a84e134Smrg{
3217a84e134Smrg    contextErrDataRec *contextErrData;
3227a84e134Smrg
3237a84e134Smrg    if (XFindContext(XDisplayOfIM(error_im), (Window)error_im, errContext,
3247a84e134Smrg		      (XPointer*)&contextErrData)) {
3257a84e134Smrg	return(NULL);
3267a84e134Smrg    }
3277a84e134Smrg    return(contextErrData->widget);
3287a84e134Smrg}
3297a84e134Smrg#endif
3307a84e134Smrg
3317a84e134Smrgstatic void
3327a84e134SmrgCloseIM(XawVendorShellExtPart *ve)
3337a84e134Smrg{
3347a84e134Smrg    if (ve->im.xim)
3357a84e134Smrg	XCloseIM(ve->im.xim);
3367a84e134Smrg}
3377a84e134Smrg
3387a84e134Smrgstatic unsigned int
3397a84e134SmrgSetVendorShellHeight(XawVendorShellExtPart* ve, unsigned int height)
3407a84e134Smrg{
3417a84e134Smrg    Arg			args[2];
3427a84e134Smrg    Cardinal		i = 0;
3437a84e134Smrg
3447a84e134Smrg   if (ve->im.area_height < height || height == 0) {
3457a84e134Smrg       XtSetArg(args[i], XtNheight,
3467a84e134Smrg		(ve->parent->core.height + height - ve->im.area_height));
3475ec34c4cSmrg       ve->im.area_height = (Dimension)height;
3487a84e134Smrg       XtSetValues(ve->parent, args, 1);
3497a84e134Smrg   }
3507a84e134Smrg   return(ve->im.area_height);
3517a84e134Smrg}
3527a84e134Smrg
3537a84e134Smrgstatic void
3547a84e134SmrgDestroyAllIM(XawVendorShellExtPart *ve)
3557a84e134Smrg{
3567a84e134Smrg    XawIcTableList	p;
3577a84e134Smrg    contextErrDataRec *contextErrData;
3587a84e134Smrg
3597a84e134Smrg    /*
3607a84e134Smrg     * Destory all ICs
3617a84e134Smrg     */
3627a84e134Smrg    if (IsSharedIC(ve)) {
3637a84e134Smrg        if ((p = ve->ic.shared_ic_table) && p->xic) {
3647a84e134Smrg            DestroyIC(p->widget, ve);
3657a84e134Smrg            p->xic = NULL;
3667a84e134Smrg            p->ic_focused = FALSE;
3677a84e134Smrg        }
3687a84e134Smrg    } else {
3697a84e134Smrg	for (p = ve->ic.ic_table; p; p = p->next) {
3707a84e134Smrg	    if (p->xic == NULL) continue;
3717a84e134Smrg	    DestroyIC(p->widget, ve);
3727a84e134Smrg	    p->xic = NULL;
3737a84e134Smrg	    p->ic_focused = FALSE;
3747a84e134Smrg	}
3757a84e134Smrg    }
3767a84e134Smrg    if (!ve->im.xim) return;
3777a84e134Smrg    /*
3787a84e134Smrg     * Close Input Method
3797a84e134Smrg     */
3807a84e134Smrg    if (!XFindContext(XDisplayOfIM(ve->im.xim), (Window)ve->im.xim, errContext,
3817a84e134Smrg		      (XPointer*)&contextErrData)) {
3827a84e134Smrg	if (contextErrData) XtFree((char *)contextErrData);
3837a84e134Smrg    }
3847a84e134Smrg    XDeleteContext(XDisplayOfIM(ve->im.xim), (Window)ve->im.xim, errContext);
3857a84e134Smrg    CloseIM(ve);
3867a84e134Smrg    ve->im.xim = NULL;
3877a84e134Smrg
3887a84e134Smrg    /*
3897a84e134Smrg     * resize vendor shell to core size
3907a84e134Smrg     */
3917a84e134Smrg    (void) SetVendorShellHeight(ve, 0);
3927a84e134Smrg    /*
3937a84e134Smrg    XawVendorShellExtResize(vw);
3947a84e134Smrg    */
3957a84e134Smrg    return;
3967a84e134Smrg}
3977a84e134Smrg
3987a84e134Smrgstatic void
3997a84e134SmrgFreeAllDataOfVendorShell(XawVendorShellExtPart *ve, VendorShellWidget vw)
4007a84e134Smrg{
4017a84e134Smrg    XawIcTableList       p, next;
4027a84e134Smrg    contextErrDataRec *contextErrData;
4037a84e134Smrg
4047a84e134Smrg    if (!XFindContext(XtDisplay(vw), (Window)vw, extContext,
4057a84e134Smrg		      (XPointer*)&contextErrData)) {
4067a84e134Smrg	if (contextErrData) XtFree((char *)contextErrData);
4077a84e134Smrg    }
4087a84e134Smrg    XDeleteContext(XtDisplay(vw), (Window)vw, extContext);
4097a84e134Smrg    if (ve->ic.shared_ic_table)
4107a84e134Smrg        XtFree((char *)ve->ic.shared_ic_table);
4117a84e134Smrg    if (ve->im.resources) XtFree((char *)ve->im.resources);
4127a84e134Smrg    for (p = ve->ic.ic_table; p; p = next) {
4137a84e134Smrg        next = p->next;
4147a84e134Smrg        XtFree((char *)p);
4157a84e134Smrg    }
4167a84e134Smrg}
4177a84e134Smrg
4187a84e134Smrgstatic void
4195ec34c4cSmrgVendorShellDestroyed(Widget w, XtPointer cl_data _X_UNUSED, XtPointer ca_data _X_UNUSED)
4207a84e134Smrg{
4217a84e134Smrg    XawVendorShellExtPart	*ve;
4227a84e134Smrg
4237a84e134Smrg    if ( ( ve = GetExtPart( (VendorShellWidget) w ) ) == NULL ) return;
4247a84e134Smrg    DestroyAllIM( ve );
4257a84e134Smrg    FreeAllDataOfVendorShell( ve, (VendorShellWidget) w );
4267a84e134Smrg    return;
4277a84e134Smrg}
4287a84e134Smrg
4297a84e134Smrg#if 0
4307a84e134Smrgstatic int
4317a84e134SmrgIOErrorHandler(XIM error_im)
4327a84e134Smrg{
4337a84e134Smrg    VendorShellWidget vw;
4347a84e134Smrg    XawVendorShellExtPart * ve;
4357a84e134Smrg
4367a84e134Smrg    if ((vw = (VendorShellWidget)GetErrCnxt(error_im)) == NULL
4377a84e134Smrg	|| (ve = GetExtPart(vw)) == NULL) return(0);
4387a84e134Smrg
4397a84e134Smrg    DestroyAllIM(ve);
4407a84e134Smrg    return(0);
4417a84e134Smrg}
4427a84e134Smrg#endif
4437a84e134Smrg
4447a84e134Smrg/*
4457a84e134Smrg * Attempt to open an input method
4467a84e134Smrg */
4477a84e134Smrg
4487a84e134Smrgstatic void
4497a84e134SmrgOpenIM(XawVendorShellExtPart *ve)
4507a84e134Smrg{
4517a84e134Smrg    int		i;
4525ec34c4cSmrg    _Xconst char *s, *ns, *end;
4535ec34c4cSmrg    char	*p, *pbuf, buf[32];
4547a84e134Smrg    XIM		xim = NULL;
4557a84e134Smrg    XIMStyles	*xim_styles;
4567a84e134Smrg    XIMStyle	input_style = 0;
4577a84e134Smrg    Boolean	found;
4587a84e134Smrg
4597a84e134Smrg    if (ve->im.open_im == False) return;
4607a84e134Smrg    ve->im.xim = NULL;
4617a84e134Smrg    if (ve->im.input_method == NULL) {
4627a84e134Smrg	if ((p = XSetLocaleModifiers("@im=none")) != NULL && *p)
4637a84e134Smrg	    xim = XOpenIM(XtDisplay(ve->parent), NULL, NULL, NULL);
4647a84e134Smrg    } else {
4657a84e134Smrg	/* no fragment can be longer than the whole string */
4665ec34c4cSmrg	Cardinal len = (Cardinal)strlen (ve->im.input_method) + 5;
4677a84e134Smrg
4687a84e134Smrg	if (len < sizeof buf) pbuf = buf;
4697a84e134Smrg	else pbuf = XtMalloc (len);
4707a84e134Smrg
4717a84e134Smrg	if (pbuf == NULL) return;
4727a84e134Smrg
4737a84e134Smrg	for(ns=s=ve->im.input_method; ns && *s;) {
4747a84e134Smrg	    /* skip any leading blanks */
4757a84e134Smrg	    while (*s && isspace(*s)) s++;
4767a84e134Smrg	    if (!*s) break;
4777a84e134Smrg	    if ((ns = end = strchr(s, ',')) == NULL)
4787a84e134Smrg		end = s + strlen(s);
4797a84e134Smrg	    /* If there is a spurious comma end can be the same as s */
4807a84e134Smrg	    if (end > s) {
4817a84e134Smrg		/* strip any trailing blanks */
4827a84e134Smrg		while (isspace(*(end - 1))) end--;
4837a84e134Smrg
4847a84e134Smrg		strcpy (pbuf, "@im=");
4855ec34c4cSmrg		strncat (pbuf, s, (size_t)(end - s));
4867a84e134Smrg		pbuf[end - s + 4] = '\0';
4877a84e134Smrg	    }
4887a84e134Smrg
4897a84e134Smrg	    if ((p = XSetLocaleModifiers(pbuf)) != NULL && *p
4907a84e134Smrg		&& (xim = XOpenIM(XtDisplay(ve->parent), NULL, NULL, NULL)) != NULL)
4917a84e134Smrg		break;
4927a84e134Smrg
4937a84e134Smrg	    s = ns + 1;
4947a84e134Smrg	}
4957a84e134Smrg
4967a84e134Smrg	if (pbuf != buf) XtFree (pbuf);
4977a84e134Smrg    }
4987a84e134Smrg    if (xim == NULL) {
4997a84e134Smrg	if ((p = XSetLocaleModifiers("")) != NULL) {
5007a84e134Smrg	    xim = XOpenIM(XtDisplay(ve->parent), NULL, NULL, NULL);
5017a84e134Smrg	}
5027a84e134Smrg    }
5037a84e134Smrg    if (xim == NULL) {
5047a84e134Smrg	XtAppWarning(XtWidgetToApplicationContext(ve->parent),
5057a84e134Smrg	    "Input Method Open Failed");
5067a84e134Smrg	return;
5077a84e134Smrg    }
5087a84e134Smrg    if (XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL)
5097a84e134Smrg	|| !xim_styles) {
510421c997bSmrg	XtAppWarning(XtWidgetToApplicationContext(ve->parent),
5117a84e134Smrg	    "input method doesn't support any style");
5127a84e134Smrg	XCloseIM(xim);
5137a84e134Smrg	return;
5147a84e134Smrg    }
5157a84e134Smrg    found = False;
5167a84e134Smrg    for(ns = s = ve->im.preedit_type; s && !found;) {
5177a84e134Smrg	while (*s && isspace(*s)) s++;
5187a84e134Smrg	if (!*s) break;
5197a84e134Smrg	if ((ns = end = strchr(s, ',')) == NULL)
5207a84e134Smrg	    end = s + strlen(s);
5217a84e134Smrg	else
5227a84e134Smrg	    ns++;
5237a84e134Smrg	if (end > s)
5247a84e134Smrg	    while (isspace(*(end - 1))) end--;
5257a84e134Smrg
5265ec34c4cSmrg	if (!strncmp(s, "OverTheSpot", (size_t)(end - s))) {
5277a84e134Smrg	    input_style = (XIMPreeditPosition | XIMStatusArea);
5285ec34c4cSmrg	} else if (!strncmp(s, "OffTheSpot", (size_t)(end - s))) {
5297a84e134Smrg	    input_style = (XIMPreeditArea | XIMStatusArea);
5305ec34c4cSmrg	} else if (!strncmp(s, "Root", (size_t)(end - s))) {
5317a84e134Smrg	    input_style = (XIMPreeditNothing | XIMStatusNothing);
5327a84e134Smrg	}
5337a84e134Smrg	for (i = 0; (unsigned short)i < xim_styles->count_styles; i++)
5347a84e134Smrg	    if (input_style == xim_styles->supported_styles[i]) {
5357a84e134Smrg		ve->ic.input_style = input_style;
5367a84e134Smrg		SetErrCnxt(ve->parent, xim);
5377a84e134Smrg		ve->im.xim = xim;
5387a84e134Smrg		found = True;
5397a84e134Smrg		break;
5407a84e134Smrg	    }
5417a84e134Smrg
5427a84e134Smrg	s = ns;
5437a84e134Smrg    }
5447a84e134Smrg    XFree(xim_styles);
5457a84e134Smrg
5467a84e134Smrg    if (!found) {
5477a84e134Smrg	XCloseIM(xim);
5487a84e134Smrg	XtAppWarning(XtWidgetToApplicationContext(ve->parent),
5497a84e134Smrg		     "input method doesn't support my input style");
5507a84e134Smrg    }
5517a84e134Smrg}
5527a84e134Smrg
5537a84e134Smrgstatic Bool
5547a84e134SmrgResizeVendorShell_Core(VendorShellWidget vw, XawVendorShellExtPart *ve,
5557a84e134Smrg		       XawIcTableList p)
5567a84e134Smrg{
5577a84e134Smrg    XVaNestedList		pe_attr, st_attr;
5587a84e134Smrg    XRectangle			pe_area, st_area;
5597a84e134Smrg    XRectangle			*get_pe_area = NULL, *get_st_area = NULL;
5607a84e134Smrg
5617a84e134Smrg    st_area.width = 0;
5627a84e134Smrg    if (p->input_style & XIMStatusArea) {
5637a84e134Smrg	st_attr = XVaCreateNestedList(0, XNArea, &get_st_area, NULL);
5647a84e134Smrg	XGetICValues(p->xic, XNStatusAttributes, st_attr, NULL);
5657a84e134Smrg	XFree(st_attr);
5667a84e134Smrg	if (p->xic == NULL) {
5677a84e134Smrg	    return(FALSE);
5687a84e134Smrg	}
5697a84e134Smrg	st_area.x = 0;
5705ec34c4cSmrg	st_area.y = (short)(vw->core.height - ve->im.area_height);
5717a84e134Smrg	st_area.width = get_st_area->width;
5727a84e134Smrg	st_area.height = get_st_area->height;
5737a84e134Smrg	XFree(get_st_area);
5747a84e134Smrg	st_attr = XVaCreateNestedList(0, XNArea, &st_area, NULL);
5757a84e134Smrg	XSetICValues(p->xic, XNStatusAttributes, st_attr, NULL);
5767a84e134Smrg	XFree(st_attr);
5777a84e134Smrg	if (p->xic == NULL) {
5787a84e134Smrg	    return(FALSE);
5797a84e134Smrg	}
5807a84e134Smrg    }
5817a84e134Smrg    if (p->input_style & XIMPreeditArea) {
5827a84e134Smrg	pe_attr = XVaCreateNestedList(0, XNArea, &get_pe_area, NULL);
5837a84e134Smrg	XGetICValues(p->xic, XNPreeditAttributes, pe_attr, NULL);
5847a84e134Smrg	XFree(pe_attr);
5857a84e134Smrg	if (p->xic == NULL) {
5867a84e134Smrg	    return(FALSE);
5877a84e134Smrg	}
5885ec34c4cSmrg	pe_area.x = (short)st_area.width;
5895ec34c4cSmrg	pe_area.y = (short)(vw->core.height - ve->im.area_height);
5907a84e134Smrg	pe_area.width = vw->core.width;
5917a84e134Smrg	pe_area.height = get_pe_area->height;
5927a84e134Smrg	if (p->input_style & XIMStatusArea) {
5935ec34c4cSmrg	    pe_area.width = (unsigned short)(pe_area.width - st_area.width);
5947a84e134Smrg	}
5957a84e134Smrg	XFree(get_pe_area);
5967a84e134Smrg	pe_attr = XVaCreateNestedList(0, XNArea, &pe_area, NULL);
5977a84e134Smrg	XSetICValues(p->xic, XNPreeditAttributes, pe_attr, NULL);
5987a84e134Smrg	XFree(pe_attr);
5997a84e134Smrg    }
6007a84e134Smrg    return(TRUE);
6017a84e134Smrg}
6027a84e134Smrg
6037a84e134Smrgstatic void
6047a84e134SmrgResizeVendorShell(VendorShellWidget vw, XawVendorShellExtPart *ve)
6057a84e134Smrg{
6067a84e134Smrg    XawIcTableList               p;
6077a84e134Smrg
6087a84e134Smrg    if (IsSharedIC(ve)) {
6097a84e134Smrg	p = ve->ic.shared_ic_table;
6107a84e134Smrg	if (p->xic == NULL) return;
6117a84e134Smrg	ResizeVendorShell_Core(vw, ve, p);
6127a84e134Smrg	return;
6137a84e134Smrg    }
6147a84e134Smrg    for (p = ve->ic.ic_table; p; p = p->next) {
6157a84e134Smrg	if (p->xic == NULL) continue;
6167a84e134Smrg	if (ResizeVendorShell_Core(vw, ve, p) == FALSE) return;
6177a84e134Smrg    }
6187a84e134Smrg}
6197a84e134Smrg
6207a84e134Smrgstatic XawIcTableList
6215ec34c4cSmrgCreateIcTable(Widget w, XawVendorShellExtPart *ve _X_UNUSED)
6227a84e134Smrg{
6237a84e134Smrg    XawIcTableList	table;
6247a84e134Smrg
6257a84e134Smrg    table = (XawIcTableList) XtMalloc(sizeof(XawIcTablePart));
6267a84e134Smrg    if (table == NULL) return(NULL);
6277a84e134Smrg    table->widget = w;
6287a84e134Smrg    table->xic = NULL;
6297a84e134Smrg    table->flg = table->prev_flg = 0;
6307a84e134Smrg    table->font_set = NULL;
6317a84e134Smrg    table->foreground = table->background = 0xffffffff;
6327a84e134Smrg    table->bg_pixmap = 0;
6337a84e134Smrg    table->cursor_position = 0xffff;
6347a84e134Smrg    table->line_spacing = 0;
6357a84e134Smrg    table->ic_focused = FALSE;
6367a84e134Smrg    table->openic_error = FALSE;
6377a84e134Smrg    return(table);
6387a84e134Smrg}
6397a84e134Smrg
6407a84e134Smrgstatic Bool
6417a84e134SmrgRegisterToVendorShell(Widget w, XawVendorShellExtPart *ve)
6427a84e134Smrg{
6437a84e134Smrg    XawIcTableList	table;
6447a84e134Smrg
6457a84e134Smrg    if ((table = CreateIcTable(w, ve)) == NULL) return(FALSE);
6467a84e134Smrg    table->next = ve->ic.ic_table;
6477a84e134Smrg    ve->ic.ic_table = table;
6487a84e134Smrg    return(TRUE);
6497a84e134Smrg}
6507a84e134Smrg
6517a84e134Smrgstatic void
6527a84e134SmrgUnregisterFromVendorShell(Widget w, XawVendorShellExtPart *ve)
6537a84e134Smrg{
6547a84e134Smrg    XawIcTableList	*prev, p;
6557a84e134Smrg
6567a84e134Smrg    for (prev = &ve->ic.ic_table; (p = *prev) != NULL; prev = &p->next) {
6577a84e134Smrg	if (p->widget == w) {
6587a84e134Smrg	    *prev = p->next;
6597a84e134Smrg	    XtFree((char *)p);
6607a84e134Smrg	    break;
6617a84e134Smrg	}
6627a84e134Smrg    }
6637a84e134Smrg    return;
6647a84e134Smrg}
6657a84e134Smrg
6667a84e134Smrgstatic void
6677a84e134SmrgSetICValuesShared(Widget w, XawVendorShellExtPart *ve,
6687a84e134Smrg		  XawIcTableList p, Bool check)
6697a84e134Smrg{
6707a84e134Smrg    XawIcTableList	pp;
6717a84e134Smrg
6727a84e134Smrg    if ((pp = GetIcTable(w, ve)) == NULL) return;
6737a84e134Smrg    if (check == TRUE && CurrentSharedIcTable(ve) != pp) return;
6747a84e134Smrg
6757a84e134Smrg    if (pp->prev_flg & CICursorP && p->cursor_position != pp->cursor_position) {
6767a84e134Smrg	p->cursor_position = pp->cursor_position;
6777a84e134Smrg	p->flg |= CICursorP;
6787a84e134Smrg    }
6797a84e134Smrg    if (pp->prev_flg & CIFontSet && p->font_set != pp->font_set) {
6807a84e134Smrg	p->font_set = pp->font_set;
6817a84e134Smrg	p->flg |= (CIFontSet|CICursorP);
6827a84e134Smrg    }
6837a84e134Smrg    if (pp->prev_flg & CIFg && p->foreground != pp->foreground) {
6847a84e134Smrg	p->foreground = pp->foreground;
6857a84e134Smrg	p->flg |= CIFg;
6867a84e134Smrg    }
6877a84e134Smrg    if (pp->prev_flg & CIBg && p->background != pp->background) {
6887a84e134Smrg	p->background = pp->background;
6897a84e134Smrg	p->flg |= CIBg;
6907a84e134Smrg    }
6917a84e134Smrg    if (pp->prev_flg & CIBgPixmap && p->bg_pixmap != pp->bg_pixmap) {
6927a84e134Smrg	p->bg_pixmap = pp->bg_pixmap;
6937a84e134Smrg	p->flg |= CIBgPixmap;
6947a84e134Smrg    }
6957a84e134Smrg    if (pp->prev_flg & CILineS && p->line_spacing != pp->line_spacing) {
6967a84e134Smrg	p->line_spacing = pp->line_spacing;
6977a84e134Smrg	p->flg |= CILineS;
6987a84e134Smrg    }
6997a84e134Smrg}
7007a84e134Smrg
7017a84e134Smrgstatic Bool
7027a84e134SmrgIsCreatedIC(Widget w, XawVendorShellExtPart *ve)
7037a84e134Smrg{
7047a84e134Smrg    XawIcTableList	p;
7057a84e134Smrg
7067a84e134Smrg    if (ve->im.xim == NULL) return(FALSE);
7077a84e134Smrg    if ((p = GetIcTableShared(w, ve)) == NULL) return(FALSE);
7087a84e134Smrg    if (p->xic == NULL) return(FALSE);
7097a84e134Smrg    return(TRUE);
7107a84e134Smrg}
7117a84e134Smrg
7127a84e134Smrgstatic void
7137a84e134SmrgSizeNegotiation(XawIcTableList p, unsigned int width, unsigned int height)
7147a84e134Smrg{
7157a84e134Smrg    XRectangle		pe_area, st_area;
7167a84e134Smrg    XVaNestedList	pe_attr = NULL, st_attr = NULL;
7177a84e134Smrg    int			ic_cnt = 0;
7187a84e134Smrg    XRectangle		*pe_area_needed = NULL, *st_area_needed = NULL;
7197a84e134Smrg    XPointer		ic_a[5];
7207a84e134Smrg
7217a84e134Smrg    if (p->input_style & XIMPreeditArea) {
7227a84e134Smrg	pe_attr = XVaCreateNestedList(0, XNAreaNeeded, &pe_area_needed, NULL);
7237a84e134Smrg	ic_a[ic_cnt] = (XPointer) XNPreeditAttributes; ic_cnt++;
7247a84e134Smrg	ic_a[ic_cnt] = (XPointer) pe_attr; ic_cnt++;
7257a84e134Smrg    }
7267a84e134Smrg    if (p->input_style & XIMStatusArea) {
7277a84e134Smrg	st_attr = XVaCreateNestedList(0, XNAreaNeeded, &st_area_needed, NULL);
7287a84e134Smrg	ic_a[ic_cnt] = (XPointer) XNStatusAttributes; ic_cnt++;
7297a84e134Smrg	ic_a[ic_cnt] = (XPointer) st_attr; ic_cnt++;
7307a84e134Smrg    }
7317a84e134Smrg    ic_a[ic_cnt] = (XPointer) NULL;
7327a84e134Smrg
7337a84e134Smrg    if (ic_cnt > 0) {
7347a84e134Smrg	XGetICValues(p->xic, ic_a[0], ic_a[1], ic_a[2], ic_a[3], NULL);
7357a84e134Smrg	if (pe_attr) XFree(pe_attr);
7367a84e134Smrg	if (st_attr) XFree(st_attr);
7377a84e134Smrg	if (p->xic == NULL) {
7387a84e134Smrg	    p->openic_error = True;
7397a84e134Smrg	    return;
7407a84e134Smrg	}
7417a84e134Smrg	pe_attr = st_attr = NULL;
7427a84e134Smrg	ic_cnt = 0;
7437a84e134Smrg	if (p->input_style & XIMStatusArea) {
7447a84e134Smrg	    st_area.height = st_area_needed->height;
7457a84e134Smrg	    st_area.x = 0;
7465ec34c4cSmrg	    st_area.y = (short)(height - st_area.height);
7477a84e134Smrg	    if (p->input_style & XIMPreeditArea) {
7487a84e134Smrg		st_area.width = st_area_needed->width;
7497a84e134Smrg	    } else {
7505ec34c4cSmrg		st_area.width = (unsigned short)width;
7517a84e134Smrg	    }
7527a84e134Smrg
7537a84e134Smrg	    XFree(st_area_needed);
7547a84e134Smrg	    st_attr = XVaCreateNestedList(0, XNArea, &st_area, NULL);
7557a84e134Smrg	    ic_a[ic_cnt] = (XPointer) XNStatusAttributes; ic_cnt++;
7567a84e134Smrg	    ic_a[ic_cnt] = (XPointer) st_attr; ic_cnt++;
7577a84e134Smrg	}
7587a84e134Smrg	if (p->input_style & XIMPreeditArea) {
7597a84e134Smrg	    if (p->input_style & XIMStatusArea) {
7605ec34c4cSmrg		pe_area.x = (short)st_area.width;
7615ec34c4cSmrg		pe_area.width = (unsigned short)(width - st_area.width);
7627a84e134Smrg	    } else {
7637a84e134Smrg		pe_area.x = 0;
7645ec34c4cSmrg		pe_area.width = (unsigned short)width;
7657a84e134Smrg	    }
7667a84e134Smrg	    pe_area.height = pe_area_needed->height;
7677a84e134Smrg	    XFree(pe_area_needed);
7685ec34c4cSmrg	    pe_area.y = (short)(height - pe_area.height);
7697a84e134Smrg	    pe_attr = XVaCreateNestedList(0, XNArea, &pe_area, NULL);
7707a84e134Smrg	    ic_a[ic_cnt] = (XPointer) XNPreeditAttributes; ic_cnt++;
7717a84e134Smrg	    ic_a[ic_cnt] = (XPointer) pe_attr; ic_cnt++;
7727a84e134Smrg	}
7737a84e134Smrg	ic_a[ic_cnt] = (XPointer) NULL;
7747a84e134Smrg	XSetICValues(p->xic, ic_a[0], ic_a[1], ic_a[2], ic_a[3], NULL);
7757a84e134Smrg	if (pe_attr) XFree(pe_attr);
7767a84e134Smrg	if (st_attr) XFree(st_attr);
7777a84e134Smrg	if (p->xic == NULL) {
7787a84e134Smrg	    p->openic_error = True;
7797a84e134Smrg	    return;
7807a84e134Smrg	}
7817a84e134Smrg    }
7827a84e134Smrg}
7837a84e134Smrg
7847a84e134Smrgstatic void
7857a84e134SmrgCreateIC(Widget w, XawVendorShellExtPart *ve)
7867a84e134Smrg{
7877a84e134Smrg    XawIcTableList	p;
7887a84e134Smrg    XPoint		position;
7897a84e134Smrg    XRectangle		pe_area, st_area;
7907a84e134Smrg    XVaNestedList	pe_attr = NULL, st_attr = NULL;
7917a84e134Smrg    XPointer		ic_a[20], pe_a[20], st_a[20];
7927a84e134Smrg    Dimension		height = 0;
7937a84e134Smrg    int			ic_cnt = 0, pe_cnt = 0, st_cnt = 0;
7947a84e134Smrg    XawTextMargin	*margin;
7957a84e134Smrg
7967a84e134Smrg    if (!XtIsRealized(w)) return;
7977a84e134Smrg    if (((ve->im.xim == NULL) || (p = GetIcTableShared(w, ve)) == NULL) ||
7987a84e134Smrg	p->xic || (p->openic_error != FALSE)) return;
7997a84e134Smrg
8007a84e134Smrg    p->input_style = GetInputStyleOfIC(ve);
8017a84e134Smrg
8027a84e134Smrg    if (IsSharedIC(ve)) SetICValuesShared(w, ve, p, FALSE);
8037a84e134Smrg    XFlush(XtDisplay(w));
804421c997bSmrg
8057a84e134Smrg    if (p->input_style & (XIMPreeditArea|XIMPreeditPosition|XIMStatusArea)) {
8067a84e134Smrg	if (p->flg & CIFontSet) {
8077a84e134Smrg	    pe_a[pe_cnt] = (XPointer) XNFontSet; pe_cnt++;
8087a84e134Smrg	    pe_a[pe_cnt] = (XPointer) p->font_set; pe_cnt++;
8097a84e134Smrg	    st_a[st_cnt] = (XPointer) XNFontSet; st_cnt++;
8107a84e134Smrg	    st_a[st_cnt] = (XPointer) p->font_set; st_cnt++;
8117a84e134Smrg	    if (p->font_set) {
8125ec34c4cSmrg		height = (Dimension)(maxAscentOfFontSet(p->font_set)
8135ec34c4cSmrg				     + maxDescentOfFontSet(p->font_set));
8147a84e134Smrg	    }
8155ec34c4cSmrg	    height = (Dimension)SetVendorShellHeight(ve, height);
8167a84e134Smrg	}
8177a84e134Smrg	if (p->flg & CIFg) {
8187a84e134Smrg	    pe_a[pe_cnt] = (XPointer) XNForeground; pe_cnt++;
8197a84e134Smrg	    pe_a[pe_cnt] = (XPointer) p->foreground; pe_cnt++;
8207a84e134Smrg	    st_a[st_cnt] = (XPointer) XNForeground; st_cnt++;
8217a84e134Smrg	    st_a[st_cnt] = (XPointer) p->foreground; st_cnt++;
8227a84e134Smrg	}
8237a84e134Smrg	if (p->flg & CIBg) {
8247a84e134Smrg	    pe_a[pe_cnt] = (XPointer) XNBackground; pe_cnt++;
8257a84e134Smrg	    pe_a[pe_cnt] = (XPointer) p->background; pe_cnt++;
8267a84e134Smrg	    st_a[st_cnt] = (XPointer) XNBackground; st_cnt++;
8277a84e134Smrg	    st_a[st_cnt] = (XPointer) p->background; st_cnt++;
8287a84e134Smrg	}
8297a84e134Smrg	if (p->flg & CIBgPixmap) {
8307a84e134Smrg	    pe_a[pe_cnt] = (XPointer) XNBackgroundPixmap; pe_cnt++;
8317a84e134Smrg	    pe_a[pe_cnt] = (XPointer) p->bg_pixmap; pe_cnt++;
8327a84e134Smrg	    st_a[st_cnt] = (XPointer) XNBackgroundPixmap; st_cnt++;
8337a84e134Smrg	    st_a[st_cnt] = (XPointer) p->bg_pixmap; st_cnt++;
8347a84e134Smrg	}
8357a84e134Smrg	if (p->flg & CILineS) {
8367a84e134Smrg	    pe_a[pe_cnt] = (XPointer) XNLineSpace; pe_cnt++;
8377a84e134Smrg	    pe_a[pe_cnt] = (XPointer) p->line_spacing; pe_cnt++;
8387a84e134Smrg	    st_a[st_cnt] = (XPointer) XNLineSpace; st_cnt++;
8397a84e134Smrg	    st_a[st_cnt] = (XPointer) p->line_spacing; st_cnt++;
8407a84e134Smrg	}
8417a84e134Smrg    }
8427a84e134Smrg    if (p->input_style & XIMPreeditArea) {
8437a84e134Smrg	pe_area.x = 0;
8445ec34c4cSmrg	pe_area.y = (short)(ve->parent->core.height - height);
8457a84e134Smrg	pe_area.width = ve->parent->core.width;
8467a84e134Smrg	pe_area.height = height;
8477a84e134Smrg	pe_a[pe_cnt] = (XPointer) XNArea; pe_cnt++;
8487a84e134Smrg	pe_a[pe_cnt] = (XPointer) &pe_area; pe_cnt++;
8497a84e134Smrg    }
8507a84e134Smrg    if (p->input_style & XIMPreeditPosition) {
8517a84e134Smrg	pe_area.x = 0;
8527a84e134Smrg	pe_area.y = 0;
8537a84e134Smrg	pe_area.width = w->core.width;
8547a84e134Smrg	pe_area.height = w->core.height;
8557a84e134Smrg	margin = &(((TextWidget)w)->text.margin);
8565ec34c4cSmrg	pe_area.x = (short)(pe_area.x + margin->left);
8575ec34c4cSmrg	pe_area.y = (short)(pe_area.y + margin->top);
8585ec34c4cSmrg	pe_area.width = (unsigned short)(pe_area.width - (margin->left + margin->right - 1));
8595ec34c4cSmrg	pe_area.height = (unsigned short)(pe_area.height - (margin->top + margin->bottom - 1));
8607a84e134Smrg	pe_a[pe_cnt] = (XPointer) XNArea; pe_cnt++;
8617a84e134Smrg	pe_a[pe_cnt] = (XPointer) &pe_area; pe_cnt++;
8627a84e134Smrg	if (p->flg & CICursorP) {
8637a84e134Smrg	    _XawMultiSinkPosToXY(w, p->cursor_position, &position.x, &position.y);
8647a84e134Smrg	} else {
8657a84e134Smrg	    position.x = position.y = 0;
8667a84e134Smrg	}
8677a84e134Smrg	pe_a[pe_cnt] = (XPointer) XNSpotLocation; pe_cnt++;
8687a84e134Smrg	pe_a[pe_cnt] = (XPointer) &position; pe_cnt++;
8697a84e134Smrg    }
8707a84e134Smrg    if (p->input_style & XIMStatusArea) {
8717a84e134Smrg	st_area.x = 0;
8725ec34c4cSmrg	st_area.y = (short)(ve->parent->core.height - height);
8737a84e134Smrg	st_area.width = ve->parent->core.width;
8747a84e134Smrg	st_area.height = height;
8757a84e134Smrg	st_a[st_cnt] = (XPointer) XNArea; st_cnt++;
8767a84e134Smrg	st_a[st_cnt] = (XPointer) &st_area; st_cnt++;
8777a84e134Smrg    }
8787a84e134Smrg
8797a84e134Smrg    ic_a[ic_cnt] = (XPointer) XNInputStyle; ic_cnt++;
8807a84e134Smrg    ic_a[ic_cnt] = (XPointer) p->input_style; ic_cnt++;
8817a84e134Smrg    ic_a[ic_cnt] = (XPointer) XNClientWindow; ic_cnt++;
8827a84e134Smrg    ic_a[ic_cnt] = (XPointer) XtWindow(ve->parent); ic_cnt++;
8837a84e134Smrg    ic_a[ic_cnt] = (XPointer) XNFocusWindow; ic_cnt++;
8847a84e134Smrg    ic_a[ic_cnt] = (XPointer) XtWindow(w); ic_cnt++;
8857a84e134Smrg
8867a84e134Smrg    if (pe_cnt > 0) {
8877a84e134Smrg	pe_a[pe_cnt] = (XPointer) NULL;
8887a84e134Smrg	pe_attr = XVaCreateNestedList(0, pe_a[0], pe_a[1], pe_a[2], pe_a[3],
8897a84e134Smrg				   pe_a[4], pe_a[5], pe_a[6], pe_a[7], pe_a[8],
8907a84e134Smrg				   pe_a[9], pe_a[10], pe_a[11], pe_a[12],
8917a84e134Smrg				   pe_a[13], pe_a[14], pe_a[15], pe_a[16],
8927a84e134Smrg				   pe_a[17], pe_a[18],  NULL);
8937a84e134Smrg	ic_a[ic_cnt] = (XPointer) XNPreeditAttributes; ic_cnt++;
8947a84e134Smrg	ic_a[ic_cnt] = (XPointer) pe_attr; ic_cnt++;
8957a84e134Smrg    }
8967a84e134Smrg
8977a84e134Smrg    if (st_cnt > 0) {
8987a84e134Smrg	st_a[st_cnt] = (XPointer) NULL;
8997a84e134Smrg	st_attr = XVaCreateNestedList(0, st_a[0], st_a[1], st_a[2], st_a[3],
9007a84e134Smrg				   st_a[4], st_a[5], st_a[6], st_a[7], st_a[8],
9017a84e134Smrg				   st_a[9], st_a[10], st_a[11], st_a[12],
9027a84e134Smrg				   st_a[13], st_a[14], st_a[15], st_a[16],
9037a84e134Smrg				   st_a[17], st_a[18],  NULL);
9047a84e134Smrg	ic_a[ic_cnt] = (XPointer) XNStatusAttributes; ic_cnt++;
9057a84e134Smrg	ic_a[ic_cnt] = (XPointer) st_attr; ic_cnt++;
9067a84e134Smrg    }
9077a84e134Smrg    ic_a[ic_cnt] = (XPointer) NULL;
9087a84e134Smrg
9097a84e134Smrg    p->xic = XCreateIC(ve->im.xim, ic_a[0], ic_a[1], ic_a[2], ic_a[3],
9107a84e134Smrg		       ic_a[4], ic_a[5], ic_a[6], ic_a[7], ic_a[8], ic_a[9],
9117a84e134Smrg		       ic_a[10], ic_a[11], ic_a[12], ic_a[13], ic_a[14],
9127a84e134Smrg		       ic_a[15], ic_a[16], ic_a[17], ic_a[18], NULL);
9137a84e134Smrg    if (pe_attr) XtFree(pe_attr);
9147a84e134Smrg    if (st_attr) XtFree(st_attr);
9157a84e134Smrg
9167a84e134Smrg    if (p->xic == NULL) {
9177a84e134Smrg	p->openic_error = True;
9187a84e134Smrg	return;
9197a84e134Smrg    }
9207a84e134Smrg
9217a84e134Smrg    SizeNegotiation(p, ve->parent->core.width, ve->parent->core.height);
9227a84e134Smrg
9235ec34c4cSmrg    p->flg &= (unsigned long)(~(CIFontSet | CIFg | CIBg | CIBgPixmap | CICursorP | CILineS));
9247a84e134Smrg
9257a84e134Smrg    if (!IsSharedIC(ve)) {
9267a84e134Smrg	if (p->input_style & XIMPreeditPosition) {
9277a84e134Smrg	    XtAddEventHandler(w, (EventMask)StructureNotifyMask, FALSE,
9287a84e134Smrg			      (XtEventHandler)ConfigureCB, (Opaque)NULL);
9297a84e134Smrg	}
9307a84e134Smrg    }
9317a84e134Smrg}
9327a84e134Smrg
9337a84e134Smrgstatic void
9347a84e134SmrgSetICValues(Widget w, XawVendorShellExtPart *ve, Bool focus)
9357a84e134Smrg{
9367a84e134Smrg    XawIcTableList	p;
9377a84e134Smrg    XPoint		position;
9387a84e134Smrg    XRectangle		pe_area;
9397a84e134Smrg    XVaNestedList	pe_attr = NULL, st_attr = NULL;
9407a84e134Smrg    XPointer		ic_a[20], pe_a[20], st_a[20];
9417a84e134Smrg    int			ic_cnt = 0, pe_cnt = 0, st_cnt = 0;
9427a84e134Smrg    XawTextMargin	*margin;
9437a84e134Smrg    int			height = 0;
9447a84e134Smrg
9457a84e134Smrg    if ((ve->im.xim == NULL) || ((p = GetIcTableShared(w, ve)) == NULL) ||
9467a84e134Smrg	(p->xic == NULL)) return;
9477a84e134Smrg
9487a84e134Smrg    if (IsSharedIC(ve)) SetICValuesShared(w, ve, p, TRUE);
9497a84e134Smrg    XFlush(XtDisplay(w));
9507a84e134Smrg    if (focus == FALSE &&
9517a84e134Smrg	!(p->flg & (CIFontSet | CIFg | CIBg |
9527a84e134Smrg		    CIBgPixmap | CICursorP | CILineS))) return;
9537a84e134Smrg#ifdef SPOT
9547a84e134Smrg    if ((p->input_style & XIMPreeditPosition)
9557a84e134Smrg	&& ((!IsSharedIC(ve) && ((p->flg & ~CIICFocus) == CICursorP))
9567a84e134Smrg	    || (IsSharedIC(ve) && p->flg == CICursorP))) {
9577a84e134Smrg	_XawMultiSinkPosToXY(w, p->cursor_position, &position.x, &position.y);
9587a84e134Smrg	_XipChangeSpot(p->xic, position.x, position.y);
9597a84e134Smrg	p->flg &= ~CICursorP;
9607a84e134Smrg	return;
9617a84e134Smrg    }
9627a84e134Smrg#endif
9637a84e134Smrg
9647a84e134Smrg    if (p->input_style & (XIMPreeditArea|XIMPreeditPosition|XIMStatusArea)) {
9657a84e134Smrg	if (p->flg & CIFontSet) {
9667a84e134Smrg	    pe_a[pe_cnt] = (XPointer) XNFontSet; pe_cnt++;
9677a84e134Smrg	    pe_a[pe_cnt] = (XPointer) p->font_set; pe_cnt++;
9687a84e134Smrg	    st_a[st_cnt] = (XPointer) XNFontSet; st_cnt++;
9697a84e134Smrg	    st_a[st_cnt] = (XPointer) p->font_set; st_cnt++;
9707a84e134Smrg	    if (p->font_set) {
9717a84e134Smrg		height = maxAscentOfFontSet(p->font_set)
9727a84e134Smrg		    + maxDescentOfFontSet(p->font_set);
9737a84e134Smrg	    }
9745ec34c4cSmrg	    height = (int)SetVendorShellHeight(ve, (unsigned)height);
9757a84e134Smrg	}
9767a84e134Smrg	if (p->flg & CIFg) {
9777a84e134Smrg	    pe_a[pe_cnt] = (XPointer) XNForeground; pe_cnt++;
9787a84e134Smrg	    pe_a[pe_cnt] = (XPointer) p->foreground; pe_cnt++;
9797a84e134Smrg	    st_a[st_cnt] = (XPointer) XNForeground; st_cnt++;
9807a84e134Smrg	    st_a[st_cnt] = (XPointer) p->foreground; st_cnt++;
9817a84e134Smrg	}
9827a84e134Smrg	if (p->flg & CIBg) {
9837a84e134Smrg	    pe_a[pe_cnt] = (XPointer) XNBackground; pe_cnt++;
9847a84e134Smrg	    pe_a[pe_cnt] = (XPointer) p->background; pe_cnt++;
9857a84e134Smrg	    st_a[st_cnt] = (XPointer) XNBackground; st_cnt++;
9867a84e134Smrg	    st_a[st_cnt] = (XPointer) p->background; st_cnt++;
9877a84e134Smrg	}
9887a84e134Smrg	if (p->flg & CIBgPixmap) {
9897a84e134Smrg	    pe_a[pe_cnt] = (XPointer) XNBackgroundPixmap; pe_cnt++;
9907a84e134Smrg	    pe_a[pe_cnt] = (XPointer) p->bg_pixmap; pe_cnt++;
9917a84e134Smrg	    st_a[st_cnt] = (XPointer) XNBackgroundPixmap; st_cnt++;
9927a84e134Smrg	    st_a[st_cnt] = (XPointer) p->bg_pixmap; st_cnt++;
9937a84e134Smrg	}
9947a84e134Smrg	if (p->flg & CILineS) {
9957a84e134Smrg	    pe_a[pe_cnt] = (XPointer) XNLineSpace; pe_cnt++;
9967a84e134Smrg	    pe_a[pe_cnt] = (XPointer) p->line_spacing; pe_cnt++;
9977a84e134Smrg	    st_a[st_cnt] = (XPointer) XNLineSpace; st_cnt++;
9987a84e134Smrg	    st_a[st_cnt] = (XPointer) p->line_spacing; st_cnt++;
9997a84e134Smrg	}
10007a84e134Smrg    }
10017a84e134Smrg    if (p->input_style & XIMPreeditPosition) {
10027a84e134Smrg	if (p->flg & CICursorP) {
10037a84e134Smrg	    _XawMultiSinkPosToXY(w, p->cursor_position, &position.x, &position.y);
10047a84e134Smrg	    pe_a[pe_cnt] = (XPointer) XNSpotLocation; pe_cnt++;
10057a84e134Smrg	    pe_a[pe_cnt] = (XPointer) &position; pe_cnt++;
10067a84e134Smrg	}
10077a84e134Smrg    }
10087a84e134Smrg    if (IsSharedIC(ve)) {
10097a84e134Smrg	if (p->input_style & XIMPreeditPosition) {
10107a84e134Smrg	    pe_area.x = 0;
10117a84e134Smrg	    pe_area.y = 0;
10127a84e134Smrg	    pe_area.width = w->core.width;
10137a84e134Smrg	    pe_area.height = w->core.height;
10147a84e134Smrg	    margin = &(((TextWidget)w)->text.margin);
10155ec34c4cSmrg	    pe_area.x = (short)(pe_area.x + margin->left);
10165ec34c4cSmrg	    pe_area.y = (short)(pe_area.y + margin->top);
10175ec34c4cSmrg	    pe_area.width = (unsigned short)(pe_area.width - (margin->left + margin->right - 1));
10185ec34c4cSmrg	    pe_area.height = (unsigned short)(pe_area.height - (margin->top + margin->bottom - 1));
10197a84e134Smrg	    pe_a[pe_cnt] = (XPointer) XNArea; pe_cnt++;
10207a84e134Smrg	    pe_a[pe_cnt] = (XPointer) &pe_area; pe_cnt++;
10217a84e134Smrg	}
10227a84e134Smrg    }
10237a84e134Smrg
10247a84e134Smrg    if (pe_cnt > 0) {
10257a84e134Smrg	pe_a[pe_cnt] = (XPointer) NULL;
10267a84e134Smrg	pe_attr = XVaCreateNestedList(0, pe_a[0], pe_a[1], pe_a[2], pe_a[3],
10277a84e134Smrg				      pe_a[4], pe_a[5], pe_a[6], pe_a[7],
10287a84e134Smrg				      pe_a[8], pe_a[9], pe_a[10], pe_a[11],
10297a84e134Smrg				      pe_a[12], pe_a[13], pe_a[14], pe_a[15],
10307a84e134Smrg				      pe_a[16], pe_a[17], pe_a[18],  NULL);
10317a84e134Smrg	ic_a[ic_cnt] = (XPointer) XNPreeditAttributes; ic_cnt++;
10327a84e134Smrg	ic_a[ic_cnt] = (XPointer) pe_attr; ic_cnt++;
10337a84e134Smrg    }
10347a84e134Smrg    if (st_cnt > 0) {
10357a84e134Smrg	st_a[st_cnt] = (XPointer) NULL;
10367a84e134Smrg	st_attr = XVaCreateNestedList(0, st_a[0], st_a[1], st_a[2], st_a[3],
10377a84e134Smrg				      st_a[4], st_a[5], st_a[6], st_a[7],
10387a84e134Smrg				      st_a[8], st_a[9], st_a[10], st_a[11],
10397a84e134Smrg				      st_a[12], st_a[13], st_a[14], st_a[15],
10407a84e134Smrg				      st_a[16], st_a[17], st_a[18],  NULL);
10417a84e134Smrg	ic_a[ic_cnt] = (XPointer) XNStatusAttributes; ic_cnt++;
10427a84e134Smrg	ic_a[ic_cnt] = (XPointer) st_attr; ic_cnt++;
10437a84e134Smrg    }
10447a84e134Smrg    if (focus == TRUE) {
10457a84e134Smrg	ic_a[ic_cnt] = (XPointer) XNFocusWindow; ic_cnt++;
10467a84e134Smrg	ic_a[ic_cnt] = (XPointer) XtWindow(w); ic_cnt++;
10477a84e134Smrg    }
10487a84e134Smrg    if (ic_cnt > 0) {
10497a84e134Smrg	ic_a[ic_cnt] = (XPointer) NULL;
10507a84e134Smrg	XSetICValues(p->xic, ic_a[0], ic_a[1], ic_a[2], ic_a[3], ic_a[4],
10517a84e134Smrg		     ic_a[5], ic_a[6], ic_a[7], ic_a[8], ic_a[9], ic_a[10],
10527a84e134Smrg		     ic_a[11], ic_a[12], ic_a[13], ic_a[14], ic_a[15],
10537a84e134Smrg		     ic_a[16], ic_a[17], ic_a[18], NULL);
10547a84e134Smrg	if (pe_attr) XtFree(pe_attr);
10557a84e134Smrg	if (st_attr) XtFree(st_attr);
10567a84e134Smrg    }
10577a84e134Smrg
10587a84e134Smrg    if (IsSharedIC(ve) && p->flg & CIFontSet)
10597a84e134Smrg	SizeNegotiation(p, ve->parent->core.width, ve->parent->core.height);
10607a84e134Smrg
10615ec34c4cSmrg    p->flg &= (unsigned long)(~(CIFontSet | CIFg | CIBg | CIBgPixmap | CICursorP | CILineS));
10627a84e134Smrg}
10637a84e134Smrg
10647a84e134Smrgstatic void
10657a84e134SmrgSharedICChangeFocusWindow(Widget w, XawVendorShellExtPart *ve,
10665ec34c4cSmrg			  XawIcTableList p _X_UNUSED)
10677a84e134Smrg{
10687a84e134Smrg    XawIcTableList	pp;
10697a84e134Smrg
10707a84e134Smrg    if (w == NULL) {
10717a84e134Smrg	ve->ic.current_ic_table = NULL;
10727a84e134Smrg	return;
10737a84e134Smrg    }
10747a84e134Smrg    if ((pp = GetIcTable(w, ve)) == NULL) return;
10757a84e134Smrg    ve->ic.current_ic_table = pp;
10767a84e134Smrg    SetICValues(w, ve, TRUE);
10777a84e134Smrg}
10787a84e134Smrg
10797a84e134Smrgstatic XawIcTableList
10807a84e134SmrgCurrentSharedIcTable(XawVendorShellExtPart *ve)
10817a84e134Smrg{
10827a84e134Smrg    return(ve->ic.current_ic_table);
10837a84e134Smrg}
10847a84e134Smrg
10857a84e134Smrgstatic void
10867a84e134SmrgSetICFocus(Widget w, XawVendorShellExtPart *ve)
10877a84e134Smrg{
10887a84e134Smrg    XawIcTableList	p, pp;
10897a84e134Smrg
10907a84e134Smrg    if ((ve->im.xim == NULL) || ((p = GetIcTableShared(w, ve)) == NULL) ||
10917a84e134Smrg	(p->xic == NULL)) return;
10927a84e134Smrg
10937a84e134Smrg    if (IsSharedIC(ve)) {
10947a84e134Smrg	pp = CurrentSharedIcTable(ve);
10957a84e134Smrg	if (pp == NULL || pp->widget != w) {
10967a84e134Smrg	    SharedICChangeFocusWindow(w, ve, p);
10977a84e134Smrg	}
10987a84e134Smrg    }
10997a84e134Smrg    if (p->flg & CIICFocus && p->ic_focused == FALSE) {
11007a84e134Smrg	p->ic_focused = TRUE;
11017a84e134Smrg	XSetICFocus(p->xic);
11027a84e134Smrg    }
11035ec34c4cSmrg    p->flg &= (unsigned long)(~CIICFocus);
11047a84e134Smrg}
11057a84e134Smrg
11067a84e134Smrgstatic void
11077a84e134SmrgUnsetICFocus(Widget w, XawVendorShellExtPart *ve)
11087a84e134Smrg{
11097a84e134Smrg    XawIcTableList	p, pp;
11107a84e134Smrg
11117a84e134Smrg    if ((ve->im.xim == NULL) || ((p = GetIcTableShared(w, ve)) == NULL) ||
11127a84e134Smrg	(p->xic == NULL)) return;
11137a84e134Smrg
11147a84e134Smrg    if (IsSharedIC(ve) && (pp = CurrentSharedIcTable(ve))) {
11157a84e134Smrg	if (pp->widget != w) {
11167a84e134Smrg	    return;
11177a84e134Smrg	}
11187a84e134Smrg	SharedICChangeFocusWindow(NULL, ve, p);
11197a84e134Smrg    }
11207a84e134Smrg    if (p->ic_focused == TRUE) {
11217a84e134Smrg	XUnsetICFocus(p->xic);
11227a84e134Smrg	p->ic_focused = FALSE;
11237a84e134Smrg    }
11247a84e134Smrg}
11257a84e134Smrg
11267a84e134Smrgstatic void
11277a84e134SmrgSetValues(Widget w, XawVendorShellExtPart *ve,
11287a84e134Smrg	  ArgList args, Cardinal num_args)
11297a84e134Smrg{
11307a84e134Smrg    ArgList	arg;
11317a84e134Smrg
11327a84e134Smrg    XrmName	argName;
11337a84e134Smrg    XrmResourceList	xrmres;
11347a84e134Smrg    Cardinal	i;
11357a84e134Smrg    XawIcTablePart	*p, save_tbl;
11367a84e134Smrg
11377a84e134Smrg    if ((p = GetIcTable(w, ve)) == NULL) return;
11387a84e134Smrg
11397a84e134Smrg    memcpy(&save_tbl, p, sizeof(XawIcTablePart));
11407a84e134Smrg
11417a84e134Smrg    for (arg = args ; num_args != 0; num_args--, arg++) {
11427a84e134Smrg	argName = XrmStringToName(arg->name);
11437a84e134Smrg	for (xrmres = (XrmResourceList)ve->im.resources, i = 0;
11447a84e134Smrg	     i < ve->im.num_resources; i++, xrmres++) {
11457a84e134Smrg            if (argName == xrmres->xrm_name) {
11467a84e134Smrg                _XtCopyFromArg(arg->value,
11477a84e134Smrg			       (char *)p - xrmres->xrm_offset - 1,
11487a84e134Smrg			       xrmres->xrm_size);
11497a84e134Smrg                break;
11507a84e134Smrg            }
11517a84e134Smrg        }
11527a84e134Smrg    }
11537a84e134Smrg    if (p->font_set != save_tbl.font_set) {
11547a84e134Smrg	p->flg |= CIFontSet;
11557a84e134Smrg    }
11567a84e134Smrg    if (p->foreground != save_tbl.foreground) {
11577a84e134Smrg	p->flg |= CIFg;
11587a84e134Smrg    }
11597a84e134Smrg    if (p->background !=save_tbl.background) {
11607a84e134Smrg	p->flg |= CIBg;
11617a84e134Smrg    }
11627a84e134Smrg    if (p->bg_pixmap != save_tbl.bg_pixmap) {
11637a84e134Smrg	p->flg |= CIBgPixmap;
11647a84e134Smrg    }
11657a84e134Smrg    if (p->cursor_position != save_tbl.cursor_position) {
11667a84e134Smrg	p->flg |= CICursorP;
11677a84e134Smrg    }
11687a84e134Smrg    if (p->line_spacing != save_tbl.line_spacing) {
11697a84e134Smrg	p->flg |= CILineS;
11707a84e134Smrg    }
11717a84e134Smrg    p->prev_flg |= p->flg;
11727a84e134Smrg}
11737a84e134Smrg
11747a84e134Smrgstatic void
11757a84e134SmrgSetFocus(Widget w, XawVendorShellExtPart *ve)
11767a84e134Smrg{
11777a84e134Smrg    XawIcTableList	p;
11787a84e134Smrg    if ((p = GetIcTableShared(w, ve)) == NULL) return;
11797a84e134Smrg
11807a84e134Smrg    if ( p->ic_focused == FALSE || IsSharedIC(ve)) {
11817a84e134Smrg	p->flg |= CIICFocus;
11827a84e134Smrg    }
11837a84e134Smrg    p->prev_flg |= p->flg;
11847a84e134Smrg}
11857a84e134Smrg
11867a84e134Smrgstatic void
11877a84e134SmrgDestroyIC(Widget w, XawVendorShellExtPart *ve)
11887a84e134Smrg{
11897a84e134Smrg    XawIcTableList	p;
11907a84e134Smrg
11917a84e134Smrg    if ((ve->im.xim == NULL) || ((p = GetIcTableShared(w, ve)) == NULL) ||
11927a84e134Smrg	(p->xic == NULL)) return;
11937a84e134Smrg    if (IsSharedIC(ve)) {
11947a84e134Smrg	if (GetIcTable(w, ve) == ve->ic.current_ic_table) {
11957a84e134Smrg	    UnsetICFocus(w, ve);
11967a84e134Smrg	}
11977a84e134Smrg        return;
11987a84e134Smrg    }
11997a84e134Smrg    XDestroyIC(p->xic);
12007a84e134Smrg    if (!IsSharedIC(ve)) {
12017a84e134Smrg	if (p->input_style & XIMPreeditPosition) {
12027a84e134Smrg	    XtRemoveEventHandler(w, (EventMask)StructureNotifyMask, FALSE,
12037a84e134Smrg				 (XtEventHandler)ConfigureCB, (Opaque)NULL);
12047a84e134Smrg	}
12057a84e134Smrg    }
12067a84e134Smrg}
12077a84e134Smrg
12087a84e134Smrgstatic void
12097a84e134SmrgSetFocusValues(Widget inwidg, ArgList args, Cardinal num_args, Bool focus)
12107a84e134Smrg{
12117a84e134Smrg    XawVendorShellExtPart	*ve;
12127a84e134Smrg    VendorShellWidget		vw;
12137a84e134Smrg
12147a84e134Smrg    if ((vw = SearchVendorShell(inwidg)) == NULL) return;
12157a84e134Smrg    if ((ve = GetExtPart(vw)) != NULL) {
12167a84e134Smrg	if (num_args > 0) SetValues(inwidg, ve, args, num_args);
12177a84e134Smrg	if (focus) SetFocus(inwidg, ve);
12187a84e134Smrg	if (XtIsRealized((Widget)vw) && ve->im.xim) {
12197a84e134Smrg	    if (IsCreatedIC(inwidg, ve)) {
12207a84e134Smrg		SetICValues(inwidg, ve, FALSE);
12217a84e134Smrg		if (focus) SetICFocus(inwidg, ve);
12227a84e134Smrg	    } else {
12237a84e134Smrg		CreateIC(inwidg, ve);
1224421c997bSmrg		SetICFocus(inwidg, ve);
12257a84e134Smrg	    }
12267a84e134Smrg	}
12277a84e134Smrg    }
12287a84e134Smrg}
12297a84e134Smrg
12307a84e134Smrgstatic void
12317a84e134SmrgUnsetFocus(Widget inwidg)
12327a84e134Smrg{
12337a84e134Smrg    XawVendorShellExtPart	*ve;
12347a84e134Smrg    VendorShellWidget		vw;
12357a84e134Smrg    XawIcTableList		p;
12367a84e134Smrg
12377a84e134Smrg    if ((vw = SearchVendorShell(inwidg)) == NULL) return;
12387a84e134Smrg    if ((ve = GetExtPart(vw)) != NULL) {
12397a84e134Smrg	if ((p = GetIcTableShared(inwidg, ve)) == NULL) return;
12407a84e134Smrg	if (p->flg & CIICFocus) {
12415ec34c4cSmrg	    p->flg &= (unsigned long)(~CIICFocus);
12427a84e134Smrg	}
12435ec34c4cSmrg	p->prev_flg &= (unsigned long)(~CIICFocus);
12447a84e134Smrg	if (ve->im.xim && XtIsRealized((Widget)vw) && p->xic) {
12457a84e134Smrg	    UnsetICFocus(inwidg, ve);
12467a84e134Smrg	}
12477a84e134Smrg    }
12487a84e134Smrg}
12497a84e134Smrg
12507a84e134Smrgstatic Bool
12517a84e134SmrgIsRegistered(Widget w, XawVendorShellExtPart* ve)
12527a84e134Smrg{
12537a84e134Smrg    XawIcTableList	p;
12547a84e134Smrg
12557a84e134Smrg    for (p = ve->ic.ic_table; p; p = p->next)
12567a84e134Smrg	{
12577a84e134Smrg	    if (p->widget == w) return(TRUE);
12587a84e134Smrg	}
12597a84e134Smrg    return(FALSE);
12607a84e134Smrg}
12617a84e134Smrg
12627a84e134Smrgstatic void
12637a84e134SmrgRegister(Widget inwidg, XawVendorShellExtPart* ve)
12647a84e134Smrg{
12657a84e134Smrg    if (ve->im.xim == NULL)
12667a84e134Smrg	{
12677a84e134Smrg	    OpenIM(ve);
12687a84e134Smrg	}
12697a84e134Smrg
12707a84e134Smrg    if (IsRegistered(inwidg, ve)) return;
12717a84e134Smrg
12727a84e134Smrg    if (RegisterToVendorShell(inwidg, ve) == FALSE) return;
12737a84e134Smrg
12747a84e134Smrg    if (ve->im.xim == NULL) return;
12757a84e134Smrg
12767a84e134Smrg    if (XtIsRealized(ve->parent))
12777a84e134Smrg	{
12787a84e134Smrg	    CreateIC(inwidg, ve);
12797a84e134Smrg	    SetICFocus(inwidg, ve);
12807a84e134Smrg	}
12817a84e134Smrg}
12827a84e134Smrg
12837a84e134Smrgstatic Bool
12847a84e134SmrgNoRegistered(XawVendorShellExtPart* ve)
12857a84e134Smrg{
12867a84e134Smrg    if (ve->ic.ic_table == NULL) return(TRUE);
12877a84e134Smrg    return(FALSE);
12887a84e134Smrg}
12897a84e134Smrg
12907a84e134Smrgstatic void
12917a84e134SmrgUnregister(Widget inwidg, XawVendorShellExtPart *ve)
12927a84e134Smrg{
12937a84e134Smrg    if (!IsRegistered(inwidg, ve)) return;
12947a84e134Smrg
12957a84e134Smrg    DestroyIC(inwidg, ve);
12967a84e134Smrg
12977a84e134Smrg    UnregisterFromVendorShell(inwidg, ve);
12987a84e134Smrg
12997a84e134Smrg    if (NoRegistered(ve))
13007a84e134Smrg	{
13017a84e134Smrg	    CloseIM(ve);
13027a84e134Smrg	    ve->im.xim = NULL;
13037a84e134Smrg	    /*
13047a84e134Smrg	     * resize vendor shell to core size
13057a84e134Smrg	    */
13067a84e134Smrg	    (void) SetVendorShellHeight(ve, 0);
13077a84e134Smrg	}
13087a84e134Smrg}
13097a84e134Smrg
13107a84e134Smrgstatic void
13117a84e134SmrgAllCreateIC(XawVendorShellExtPart *ve)
13127a84e134Smrg{
13137a84e134Smrg    XawIcTableList p;
13147a84e134Smrg
13157a84e134Smrg    if (ve->im.xim == NULL) return;
13167a84e134Smrg    if (IsSharedIC(ve) && ve->ic.ic_table[0].widget) {
13177a84e134Smrg	p = ve->ic.shared_ic_table;
13187a84e134Smrg	if (p->xic == NULL)
13197a84e134Smrg	    CreateIC(ve->ic.ic_table[0].widget, ve);
13207a84e134Smrg	SetICFocus(ve->ic.ic_table[0].widget, ve);
13217a84e134Smrg	return;
13227a84e134Smrg    }
13237a84e134Smrg    for (p = ve->ic.ic_table; p; p = p->next) {
13247a84e134Smrg	if (p->xic == NULL)
13257a84e134Smrg	    CreateIC(p->widget, ve);
13267a84e134Smrg    }
13277a84e134Smrg    for (p = ve->ic.ic_table; p; p = p->next) {
13287a84e134Smrg	SetICFocus(p->widget, ve);
13297a84e134Smrg    }
13307a84e134Smrg}
13317a84e134Smrg
13327a84e134Smrg
13337a84e134Smrgstatic void
13347a84e134SmrgReconnect(XawVendorShellExtPart *ve)
13357a84e134Smrg{
13367a84e134Smrg    XawIcTableList	p;
13377a84e134Smrg
13387a84e134Smrg    ve->im.open_im = True;
13397a84e134Smrg    if (ve->im.xim == NULL) {
13407a84e134Smrg	OpenIM(ve);
13417a84e134Smrg    }
13427a84e134Smrg    if (ve->im.xim == NULL) return;
13437a84e134Smrg
13447a84e134Smrg    if (IsSharedIC(ve)) {
13457a84e134Smrg	p = ve->ic.shared_ic_table;
13467a84e134Smrg	p->flg = p->prev_flg;
13477a84e134Smrg	p->openic_error = FALSE;
13487a84e134Smrg    } else {
13497a84e134Smrg	for (p = ve->ic.ic_table; p; p = p->next) {
13507a84e134Smrg	    p->flg = p->prev_flg;
13517a84e134Smrg	    p->openic_error = FALSE;
13527a84e134Smrg	}
13537a84e134Smrg    }
13547a84e134Smrg    AllCreateIC(ve);
13557a84e134Smrg}
13567a84e134Smrg
13577a84e134Smrg
13587a84e134Smrgstatic void
13597a84e134SmrgCompileResourceList(XtResourceList res, unsigned int num_res)
13607a84e134Smrg{
13617a84e134Smrg    unsigned int count;
13627a84e134Smrg
13637a84e134Smrg#define xrmres	((XrmResourceList) res)
13647a84e134Smrg    for (count = 0; count < num_res; res++, count++) {
13657a84e134Smrg	xrmres->xrm_name         = XrmPermStringToQuark(res->resource_name);
13667a84e134Smrg	xrmres->xrm_class        = XrmPermStringToQuark(res->resource_class);
13677a84e134Smrg	xrmres->xrm_type         = XrmPermStringToQuark(res->resource_type);
13685ec34c4cSmrg	xrmres->xrm_offset	 = (int)(-res->resource_offset - 1);
13697a84e134Smrg	xrmres->xrm_default_type = XrmPermStringToQuark(res->default_type);
13707a84e134Smrg    }
13717a84e134Smrg#undef xrmres
13727a84e134Smrg}
13737a84e134Smrg
13747a84e134Smrgstatic Bool
13757a84e134SmrgInitialize(VendorShellWidget vw, XawVendorShellExtPart *ve)
13767a84e134Smrg{
13777a84e134Smrg    if (!XtIsVendorShell((Widget)vw)) return(FALSE);
13787a84e134Smrg    ve->parent = (Widget)vw;
13797a84e134Smrg    ve->im.xim = NULL;
13807a84e134Smrg    ve->im.area_height = 0;
13817a84e134Smrg    ve->im.resources = (XrmResourceList)XtMalloc(sizeof(resources));
13827a84e134Smrg    if (ve->im.resources == NULL) return(FALSE);
13837a84e134Smrg    memcpy((char *)ve->im.resources, (char *)resources, sizeof(resources));
13847a84e134Smrg    ve->im.num_resources = XtNumber(resources);
13857a84e134Smrg    CompileResourceList( (XtResourceList) ve->im.resources,
13867a84e134Smrg			   ve->im.num_resources );
13877a84e134Smrg    if ((ve->ic.shared_ic_table = CreateIcTable( (Widget)vw, ve)) == NULL)
13887a84e134Smrg	return(FALSE);
13897a84e134Smrg    ve->ic.current_ic_table = NULL;
13907a84e134Smrg    ve->ic.ic_table = NULL;
13917a84e134Smrg    return(TRUE);
13927a84e134Smrg}
13937a84e134Smrg
13947a84e134Smrg
13957a84e134Smrg/* Destroy()
13967a84e134Smrg *
13977a84e134Smrg * This frees all (most?) of the resources malloced by XawIm.
13987a84e134Smrg * It is called by _XawImDestroy, which is called by Vendor.c's
13997a84e134Smrg * VendorExt's Destroy method.           Sheeran, Omron KK, 93/08/05 */
14007a84e134Smrg
14017a84e134Smrgstatic void
14027a84e134SmrgDestroy(Widget w, XawVendorShellExtPart *ve)
14037a84e134Smrg{
14047a84e134Smrg    contextDataRec *contextData;
14057a84e134Smrg    contextErrDataRec *contextErrData;
14067a84e134Smrg
14077a84e134Smrg    if (!XtIsVendorShell( w ) )
14087a84e134Smrg	return;
14097a84e134Smrg    XtFree( (char*) ve->im.resources );
14107a84e134Smrg
1411421c997bSmrg    if (extContext != (XContext)0 &&
1412421c997bSmrg	!XFindContext (XtDisplay (w), (Window)w,
14137a84e134Smrg		       extContext, (XPointer*)&contextData))
14147a84e134Smrg        XtFree( (char*) contextData );
14157a84e134Smrg
1416421c997bSmrg    if (errContext != (XContext)0 &&
1417421c997bSmrg	!XFindContext (XDisplayOfIM( ve->im.xim ), (Window) ve->im.xim,
14187a84e134Smrg		       errContext, (XPointer*) &contextErrData))
14197a84e134Smrg        XtFree( (char*) contextErrData );
14207a84e134Smrg}
14217a84e134Smrg
14227a84e134Smrg/*********************************************
14237a84e134Smrg *
14247a84e134Smrg * SEMI-PRIVATE FUNCTIONS
14257a84e134Smrg * For use by other Xaw modules
14267a84e134Smrg *
14277a84e134Smrg ********************************************/
14287a84e134Smrg
14297a84e134Smrgvoid
14307a84e134Smrg_XawImResizeVendorShell(Widget w)
14317a84e134Smrg{
14327a84e134Smrg    XawVendorShellExtPart *ve;
14337a84e134Smrg
14347a84e134Smrg    if ( ( ve = GetExtPart( (VendorShellWidget) w ) ) && ve->im.xim ) {
14357a84e134Smrg	ResizeVendorShell( (VendorShellWidget) w, ve );
14367a84e134Smrg    }
14377a84e134Smrg}
14387a84e134Smrg
14397a84e134Smrg
14407a84e134SmrgDimension
14417a84e134Smrg_XawImGetShellHeight(Widget w)
14427a84e134Smrg{
14437a84e134Smrg    XawVendorShellExtPart *ve;
14447a84e134Smrg
14457a84e134Smrg    if (!XtIsVendorShell( w ) ) return( w->core.height );
14467a84e134Smrg    if ( (ve = GetExtPart( (VendorShellWidget) w )) != NULL ) {
14475ec34c4cSmrg	return (Dimension)( w->core.height - ve->im.area_height );
14487a84e134Smrg    }
14497a84e134Smrg    return( w->core.height );
14507a84e134Smrg}
14517a84e134Smrg
14527a84e134Smrgvoid
14537a84e134Smrg_XawImRealize(Widget w)
14547a84e134Smrg{
14557a84e134Smrg    XawVendorShellExtPart	*ve;
14567a84e134Smrg
14577a84e134Smrg    if ( !XtIsRealized( w ) || !XtIsVendorShell( w ) ) return;
14587a84e134Smrg    if ( (ve = GetExtPart( (VendorShellWidget) w )) != NULL ) {
14597a84e134Smrg	XtAddEventHandler( w, (EventMask)StructureNotifyMask, FALSE,
14607a84e134Smrg			  XawVendorStructureNotifyHandler, (XtPointer)NULL );
14617a84e134Smrg	AllCreateIC(ve);
14627a84e134Smrg    }
14637a84e134Smrg}
14647a84e134Smrg
14657a84e134Smrgvoid
14667a84e134Smrg_XawImInitialize(Widget w, Widget ext)
14677a84e134Smrg{
14687a84e134Smrg    XawVendorShellExtPart	*ve;
14697a84e134Smrg
14707a84e134Smrg    if ( !XtIsVendorShell( w ) ) return;
14717a84e134Smrg    if ( (ve = SetExtPart( (VendorShellWidget) w, (XawVendorShellExtWidget)ext )) != NULL ) {
14727a84e134Smrg	if ( Initialize( (VendorShellWidget) w, ve ) == FALSE ) return;
14737a84e134Smrg	XtAddCallback( w, XtNdestroyCallback, VendorShellDestroyed,
14747a84e134Smrg		      (XtPointer) NULL );
14757a84e134Smrg    }
14767a84e134Smrg}
14777a84e134Smrg
14787a84e134Smrgvoid
14797a84e134Smrg_XawImReconnect(Widget inwidg)
14807a84e134Smrg{
14817a84e134Smrg    XawVendorShellExtPart	*ve;
14827a84e134Smrg    VendorShellWidget		vw;
14837a84e134Smrg
14847a84e134Smrg    if ((vw = SearchVendorShell(inwidg)) == NULL) return;
14857a84e134Smrg    if ((ve = GetExtPart(vw)) != NULL) {
14867a84e134Smrg	Reconnect(ve);
14877a84e134Smrg    }
14887a84e134Smrg}
14897a84e134Smrg
14907a84e134Smrgvoid
14917a84e134Smrg_XawImRegister(Widget inwidg)
14927a84e134Smrg{
14937a84e134Smrg    XawVendorShellExtPart	*ve;
14947a84e134Smrg    VendorShellWidget		vw;
14957a84e134Smrg
14967a84e134Smrg    if ((vw = SearchVendorShell(inwidg)) == NULL) return;
14977a84e134Smrg    if ((ve = GetExtPart(vw)) != NULL) {
14987a84e134Smrg	Register(inwidg, ve);
14997a84e134Smrg    }
15007a84e134Smrg}
15017a84e134Smrg
15027a84e134Smrgvoid
15037a84e134Smrg_XawImUnregister(Widget inwidg)
15047a84e134Smrg{
15057a84e134Smrg    XawVendorShellExtPart	*ve;
15067a84e134Smrg    VendorShellWidget		vw;
15077a84e134Smrg
15087a84e134Smrg    if ((vw = SearchVendorShell(inwidg)) == NULL) return;
15097a84e134Smrg    if ((ve = GetExtPart(vw)) != NULL) {
15107a84e134Smrg	Unregister(inwidg, ve);
15117a84e134Smrg    }
15127a84e134Smrg}
15137a84e134Smrg
15147a84e134Smrgvoid
15157a84e134Smrg_XawImSetValues(Widget inwidg, ArgList args, Cardinal num_args)
15167a84e134Smrg{
15177a84e134Smrg    SetFocusValues( inwidg, args, num_args, FALSE );
15187a84e134Smrg}
15197a84e134Smrg
15207a84e134Smrgvoid
15217a84e134Smrg_XawImSetFocusValues(Widget inwidg, ArgList args, Cardinal num_args)
15227a84e134Smrg{
15237a84e134Smrg    SetFocusValues(inwidg, args, num_args, TRUE);
15247a84e134Smrg}
15257a84e134Smrg
15267a84e134Smrgvoid
15277a84e134Smrg_XawImUnsetFocus(Widget inwidg)
15287a84e134Smrg{
15297a84e134Smrg    UnsetFocus(inwidg);
15307a84e134Smrg}
15317a84e134Smrg
15327a84e134Smrgint
15337a84e134Smrg_XawImWcLookupString(Widget inwidg, XKeyPressedEvent *event,
15347a84e134Smrg		     wchar_t* buffer_return, int bytes_buffer,
15357a84e134Smrg		     KeySym *keysym_return)
15367a84e134Smrg{
15377a84e134Smrg    XawVendorShellExtPart*	ve;
15387a84e134Smrg    VendorShellWidget		vw;
15397a84e134Smrg    XawIcTableList		p;
15407a84e134Smrg    int				i, ret;
15417a84e134Smrg    char			tmp_buf[64], *tmp_p;
15427a84e134Smrg    wchar_t*			buf_p;
15437a84e134Smrg
15447a84e134Smrg    if ((vw = SearchVendorShell(inwidg)) && (ve = GetExtPart(vw)) &&
15457a84e134Smrg	ve->im.xim && (p = GetIcTableShared(inwidg, ve)) && p->xic) {
15465ec34c4cSmrg	  return(XwcLookupString(p->xic, event, buffer_return,
15475ec34c4cSmrg				 (int)((size_t)bytes_buffer/sizeof(wchar_t)),
15487a84e134Smrg				 keysym_return, NULL));
15497a84e134Smrg    }
15507a84e134Smrg    ret = XLookupString( event, tmp_buf, sizeof(tmp_buf), keysym_return,
15517a84e134Smrg		         NULL );
15527a84e134Smrg    for ( i = 0, tmp_p = tmp_buf, buf_p = buffer_return; i < ret; i++ ) {
15535ec34c4cSmrg	*buf_p++ = _Xaw_atowc((unsigned char)*tmp_p++);
15547a84e134Smrg    }
15557a84e134Smrg    return( ret );
15567a84e134Smrg}
15577a84e134Smrg
15587a84e134Smrgint
15597a84e134Smrg_XawLookupString(Widget w, XKeyEvent *event, char *buffer_return, int buffer_size,
15607a84e134Smrg		 KeySym *keysym_return)
15617a84e134Smrg{
15627a84e134Smrg    XawVendorShellExtPart *ve;
15637a84e134Smrg    VendorShellWidget vw;
15647a84e134Smrg    XawIcTableList p;
15657a84e134Smrg
15667a84e134Smrg    if ((vw = SearchVendorShell(w)) && (ve = GetExtPart(vw))
15677a84e134Smrg	&& ve->im.xim && (p = GetIcTableShared(w, ve)) && p->xic)
15687a84e134Smrg	return (XmbLookupString(p->xic, event, buffer_return, buffer_size,
15697a84e134Smrg				keysym_return, NULL));
15707a84e134Smrg
15717a84e134Smrg    return (XLookupString(event, buffer_return, buffer_size,
15727a84e134Smrg			  keysym_return, NULL));
15737a84e134Smrg}
15747a84e134Smrg
15757a84e134Smrgint
15767a84e134Smrg_XawImGetImAreaHeight(Widget w)
15777a84e134Smrg{
15787a84e134Smrg    XawVendorShellExtPart	*ve;
15797a84e134Smrg    VendorShellWidget		vw;
15807a84e134Smrg
15817a84e134Smrg    if ((vw = SearchVendorShell(w)) && (ve = GetExtPart(vw))) {
15827a84e134Smrg	return(ve->im.area_height);
15837a84e134Smrg    }
15847a84e134Smrg    return(0);
15857a84e134Smrg}
15867a84e134Smrg
15877a84e134Smrgvoid
15887a84e134Smrg_XawImCallVendorShellExtResize(Widget w)
15897a84e134Smrg{
15907a84e134Smrg    VendorShellWidget		vw;
15917a84e134Smrg
15927a84e134Smrg    if ((vw = SearchVendorShell(w)) && GetExtPart(vw)) {
15937a84e134Smrg	XawVendorShellExtResize((Widget)vw);
15947a84e134Smrg    }
15957a84e134Smrg}
15967a84e134Smrg
15977a84e134Smrg
15987a84e134Smrg/* _XawImDestroy()
15997a84e134Smrg *
16007a84e134Smrg * This should be called by the VendorExt from its
16017a84e134Smrg * core Destroy method.  Sheeran, Omron KK 93/08/05 */
16027a84e134Smrg
16037a84e134Smrgvoid
16045ec34c4cSmrg_XawImDestroy(Widget w, Widget ext _X_UNUSED)
16057a84e134Smrg{
16067a84e134Smrg    XawVendorShellExtPart        *ve;
16077a84e134Smrg
16087a84e134Smrg    if ( !XtIsVendorShell( w ) ) return;
16097a84e134Smrg    if ( (ve = GetExtPart( (VendorShellWidget) w )) != NULL )
16107a84e134Smrg        Destroy( w, ve );
16117a84e134Smrg}
1612