1 /* Masanao Izumo <mo@goice.co.jp>:
2  *
3  * There is problem if both -lXm and -lXaw are linked.
4  * This source code to re-define XAW vendorShell.
5  * To change motif vendorShell to XAW vendorShell in runtime.
6  *
7  * #define vendorShellClassRec xaw_vendorShellClassRec
8  * #define vendorShellWidgetClass xaw_vendorShellWidgetClass
9  * #include "xaw_redef.c"
10  * #undef vendorShellClassRec
11  * #undef vendorShellWidgetClass
12  * extern WidgetClass vendorShellWidgetClass;
13  * extern VendorShellClassRec vendorShellClassRec;
14  * static void xaw_vendor_setup(void)
15  * {
16  *     memcpy(&vendorShellClassRec, &xaw_vendorShellClassRec,
17  * 	   sizeof(VendorShellClassRec));
18  *     vendorShellWidgetClass = (WidgetClass)&xaw_vendorShellWidgetClass;
19  * }
20  */
21 
22 /* $XConsortium: Vendor.c,v 1.27 94/04/17 20:13:25 kaleb Exp $ */
23 
24 /***********************************************************
25 
26 Copyright (c) 1987, 1988, 1994  X Consortium
27 
28 Permission is hereby granted, free of charge, to any person obtaining a copy
29 of this software and associated documentation files (the "Software"), to deal
30 in the Software without restriction, including without limitation the rights
31 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
32 copies of the Software, and to permit persons to whom the Software is
33 furnished to do so, subject to the following conditions:
34 
35 The above copyright notice and this permission notice shall be included in
36 all copies or substantial portions of the Software.
37 
38 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
39 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
40 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
41 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
42 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
43 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
44 
45 Except as contained in this notice, the name of the X Consortium shall not be
46 used in advertising or otherwise to promote the sale, use or other dealings
47 in this Software without prior written authorization from the X Consortium.
48 
49 
50 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
51 
52                         All Rights Reserved
53 
54 Permission to use, copy, modify, and distribute this software and its
55 documentation for any purpose and without fee is hereby granted,
56 provided that the above copyright notice appear in all copies and that
57 both that copyright notice and this permission notice appear in
58 supporting documentation, and that the name of Digital not be
59 used in advertising or publicity pertaining to distribution of the
60 software without specific, written prior permission.
61 
62 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
63 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
64 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
65 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
66 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
67 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
68 SOFTWARE.
69 
70 ******************************************************************/
71 
72 /*
73  * This is a copy of Xt/Vendor.c with an additional ClassInitialize
74  * procedure to register Xmu resource type converters, and all the
75  * monkey business associated with input methods...
76  *
77  */
78 
79 /* Make sure all wm properties can make it out of the resource manager */
80 
81 #include <stdio.h>
82 #include <X11/IntrinsicP.h>
83 #include <X11/StringDefs.h>
84 #include <X11/ShellP.h>
85 #include <X11/VendorP.h>
86 #include <X11/Xmu/Converters.h>
87 #include <X11/Xmu/Atoms.h>
88 #include <X11/Xmu/Editres.h>
89 
90 
91 #ifdef HAVE_XMUREGISTEREXTERNALAGENT
92 #ifdef HAVE_X11_XMU_EXTAGENT_H
93 #include <X11/Xmu/ExtAgent.h>
94 #else
95 /* There is no ExtAgent.h in openwin package, but XmuRegisterExternalAgent
96  * is surely defined in libXmu on Solaris 7.
97  */
98 extern void XmuRegisterExternalAgent(
99 #if NeedFunctionPrototypes
100     Widget /* w */,
101     XtPointer /* data */,
102     XEvent* /* event */,
103     Boolean* /* cont */
104 #endif
105 );
106 #endif /* HAVE_X11_XMU_EXTAGENT_H */
107 #endif /* HAVE_XMUREGISTEREXTERNALAGENT */
108 
109 
110 /* The following two headers are for the input method. */
111 
112 /* $XConsortium: VendorEP.h,v 1.2 94/04/17 20:13:25 kaleb Exp $ */
113 
114 /*
115  * Copyright 1991 by OMRON Corporation
116  *
117  * Permission to use, copy, modify, distribute, and sell this software and its
118  * documentation for any purpose is hereby granted without fee, provided that
119  * the above copyright notice appear in all copies and that both that
120  * copyright notice and this permission notice appear in supporting
121  * documentation, and that the name of OMRON not be used in advertising or
122  * publicity pertaining to distribution of the software without specific,
123  * written prior permission.  OMRON makes no representations about the
124  * suitability of this software for any purpose.  It is provided "as is"
125  * without express or implied warranty.
126  *
127  * OMRON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
128  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
129  * OMRON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
130  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
131  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION,
132  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
133  * SOFTWARE.
134  *
135  *	Author:	Seiji Kuwari	OMRON Corporation
136  *				kuwa@omron.co.jp
137  *				kuwa%omron.co.jp@uunet.uu.net
138  */
139 
140 /*
141 
142 Copyright (c) 1994  X Consortium
143 
144 Permission is hereby granted, free of charge, to any person obtaining a copy
145 of this software and associated documentation files (the "Software"), to deal
146 in the Software without restriction, including without limitation the rights
147 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
148 copies of the Software, and to permit persons to whom the Software is
149 furnished to do so, subject to the following conditions:
150 
151 The above copyright notice and this permission notice shall be included in
152 all copies or substantial portions of the Software.
153 
154 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
155 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
156 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
157 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
158 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
159 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
160 
161 Except as contained in this notice, the name of the X Consortium shall not be
162 used in advertising or otherwise to promote the sale, use or other dealings
163 in this Software without prior written authorization from the X Consortium.
164 
165 */
166 
167 #ifndef _VendorEP_h
168 #define _VendorEP_h
169 
170 /* $XConsortium: XawImP.h,v 1.4 95/06/06 20:50:30 kaleb Exp $ */
171 
172 /*
173  * Copyright 1991 by OMRON Corporation
174  *
175  * Permission to use, copy, modify, distribute, and sell this software and its
176  * documentation for any purpose is hereby granted without fee, provided that
177  * the above copyright notice appear in all copies and that both that
178  * copyright notice and this permission notice appear in supporting
179  * documentation, and that the name of OMRON not be used in advertising or
180  * publicity pertaining to distribution of the software without specific,
181  * written prior permission.  OMRON makes no representations about the
182  * suitability of this software for any purpose.  It is provided "as is"
183  * without express or implied warranty.
184  *
185  * OMRON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
186  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
187  * OMRON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
188  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
189  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION,
190  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
191  * SOFTWARE.
192  *
193  *	Author:	Seiji Kuwari	OMRON Corporation
194  *				kuwa@omron.co.jp
195  *				kuwa%omron.co.jp@uunet.uu.net
196  */
197 
198 /*
199 
200 Copyright (c) 1994  X Consortium
201 
202 Permission is hereby granted, free of charge, to any person obtaining a copy
203 of this software and associated documentation files (the "Software"), to deal
204 in the Software without restriction, including without limitation the rights
205 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
206 copies of the Software, and to permit persons to whom the Software is
207 furnished to do so, subject to the following conditions:
208 
209 The above copyright notice and this permission notice shall be included in
210 all copies or substantial portions of the Software.
211 
212 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
213 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
214 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
215 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
216 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
217 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
218 
219 Except as contained in this notice, the name of the X Consortium shall not be
220 used in advertising or otherwise to promote the sale, use or other dealings
221 in this Software without prior written authorization from the X Consortium.
222 
223 */
224 
225 #ifndef _XawImP_h
226 #define _XawImP_h
227 
228 #define XtNinputMethod		"inputMethod"
229 #define XtCInputMethod		"InputMethod"
230 #define XtNpreeditType		"preeditType"
231 #define XtCPreeditType		"PreeditType"
232 #define XtNopenIm		"openIm"
233 #define XtCOpenIm		"OpenIm"
234 #define XtNsharedIc		"sharedIc"
235 #define XtCSharedIc		"SharedIc"
236 
237 #include <X11/Xaw/Text.h>
238 
239 #define	CIICFocus	(1 << 0)
240 #define	CIFontSet	(1 << 1)
241 #define	CIFg		(1 << 2)
242 #define	CIBg		(1 << 3)
243 #define	CIBgPixmap	(1 << 4)
244 #define	CICursorP	(1 << 5)
245 #define	CILineS		(1 << 6)
246 
247 typedef	struct _XawImPart
248 {
249     XIM			xim;
250     XrmResourceList	resources;
251     Cardinal		num_resources;
252     Boolean		open_im;
253     Boolean		initialized;
254     Dimension		area_height;
255     String		input_method;
256     String		preedit_type;
257 } XawImPart;
258 
259 typedef struct _XawIcTablePart
260 {
261     Widget		widget;
262     XIC			xic;
263     XIMStyle		input_style;
264     unsigned long	flg;
265     unsigned long	prev_flg;
266     Boolean		ic_focused;
267     XFontSet		font_set;
268     Pixel		foreground;
269     Pixel		background;
270     Pixmap		bg_pixmap;
271     XawTextPosition	cursor_position;
272     unsigned long	line_spacing;
273     Boolean		openic_error;
274     struct _XawIcTablePart *next;
275 } XawIcTablePart, *XawIcTableList;
276 
277 typedef	struct _XawIcPart
278 {
279     XIMStyle		input_style;
280     Boolean		shared_ic;
281     XawIcTableList	shared_ic_table;
282     XawIcTableList	current_ic_table;
283     XawIcTableList	ic_table;
284 } XawIcPart;
285 
286 typedef	struct _contextDataRec
287 {
288     Widget		parent;
289     Widget		ve;
290 } contextDataRec;
291 
292 typedef	struct _contextErrDataRec
293 {
294     Widget		widget;
295     XIM			xim;
296 } contextErrDataRec;
297 
298 void _XawImResizeVendorShell(
299 #if NeedFunctionPrototypes
300     Widget /* w */
301 #endif
302 );
303 
304 Dimension _XawImGetShellHeight(
305 #if NeedFunctionPrototypes
306     Widget /* w */
307 #endif
308 );
309 
310 void _XawImRealize(
311 #if NeedFunctionPrototypes
312     Widget /* w */
313 #endif
314 );
315 
316 void _XawImInitialize(
317 #if NeedFunctionPrototypes
318     Widget, /* w */
319     Widget  /* ext */
320 #endif
321 );
322 
323 void _XawImReconnect(
324 #if NeedFunctionPrototypes
325     Widget  /* w */
326 #endif
327 );
328 
329 void _XawImRegister(
330 #if NeedFunctionPrototypes
331     Widget  /* w */
332 #endif
333 );
334 
335 void _XawImUnregister(
336 #if NeedFunctionPrototypes
337     Widget  /* w */
338 #endif
339 );
340 
341 void _XawImSetValues(
342 #if NeedFunctionPrototypes
343     Widget,  /* w */
344     ArgList, /* args */
345     Cardinal /* num_args */
346 #endif
347 );
348 
349 /* DON'T USE THIS FUNCTION -- it's going away in the next release */
350 void _XawImVASetValues(
351 #if NeedVarargsPrototypes
352     Widget,  /* w */
353     ...
354 #endif
355 );
356 
357 void _XawImSetFocusValues(
358 #if NeedFunctionPrototypes
359     Widget,  /* w */
360     ArgList, /* args */
361     Cardinal /* num_args */
362 #endif
363 );
364 
365 /* DON'T USE THIS FUNCTION -- it's going away in the next release */
366 void _XawImVASetFocusValues(
367 #if NeedVarargsPrototypes
368     Widget,  /* w */
369     ...
370 #endif
371 );
372 
373 void _XawImUnsetFocus(
374 #if NeedFunctionPrototypes
375     Widget  /* w */
376 #endif
377 );
378 
379 int  _XawImWcLookupString(
380 #if NeedFunctionPrototypes
381     Widget,   /* w */
382     XKeyPressedEvent*, /* event */
383     wchar_t*, /* buffer_return */
384     int,      /* bytes_buffer */
385     KeySym*,  /* keysym_return */
386     Status*   /* status return */
387 #endif
388 );
389 
390 int  _XawImGetImAreaHeight(
391 #if NeedFunctionPrototypes
392     Widget  /* w */
393 #endif
394 );
395 
396 void _XawImCallVendorShellExtResize(
397 #if NeedFunctionPrototypes
398     Widget  /* w */
399 #endif
400 );
401 
402 void _XawImDestroy(
403 #if NeedFunctionPrototypes
404     Widget,  /* w */
405     Widget   /* ext */
406 #endif
407 );
408 
409 #endif	/* _XawImP_h */
410 
411 
412 typedef struct {
413     XtPointer	extension;
414 } XawVendorShellExtClassPart;
415 
416 typedef	struct _VendorShellExtClassRec {
417     ObjectClassPart	object_class;
418     XawVendorShellExtClassPart	vendor_shell_ext_class;
419 } XawVendorShellExtClassRec;
420 
421 typedef struct {
422     Widget	parent;
423     XawImPart	im;
424     XawIcPart	ic;
425 } XawVendorShellExtPart;
426 
427 typedef	struct XawVendorShellExtRec {
428     ObjectPart	object;
429     XawVendorShellExtPart	vendor_ext;
430 } XawVendorShellExtRec, *XawVendorShellExtWidget;
431 
432 #endif	/* _VendorEP_h */
433 
434 
435 
436 static XtResource resources[] = {
437   {XtNinput, XtCInput, XtRBool, sizeof(Bool),
438 		XtOffsetOf(VendorShellRec, wm.wm_hints.input),
439 		XtRImmediate, (XtPointer)True}
440 };
441 
442 /***************************************************************************
443  *
444  * Vendor shell class record
445  *
446  ***************************************************************************/
447 
448 static void XawVendorShellClassInitialize();
449 static void XawVendorShellClassPartInit();
450 static void XawVendorShellInitialize();
451 static Boolean XawVendorShellSetValues();
452 static void Realize(), ChangeManaged();
453 static XtGeometryResult GeometryManager();
454 void XawVendorShellExtResize();
455 
456 static CompositeClassExtensionRec vendorCompositeExt = {
457     /* next_extension     */	NULL,
458     /* record_type        */    NULLQUARK,
459     /* version            */    XtCompositeExtensionVersion,
460     /* record_size        */    sizeof (CompositeClassExtensionRec),
461     /* accepts_objects    */    TRUE,
462     /* allows_change_managed_set */ FALSE
463 };
464 
465 #define SuperClass (&wmShellClassRec)
466 externaldef(vendorshellclassrec) VendorShellClassRec vendorShellClassRec = {
467   {
468     /* superclass	  */	(WidgetClass)SuperClass,
469     /* class_name	  */	"VendorShell",
470     /* size		  */	sizeof(VendorShellRec),
471     /* class_initialize	  */	XawVendorShellClassInitialize,
472     /* class_part_init	  */	XawVendorShellClassPartInit,
473     /* Class init'ed ?	  */	FALSE,
474     /* initialize         */	XawVendorShellInitialize,
475     /* initialize_hook	  */	NULL,
476     /* realize		  */	Realize,
477     /* actions		  */	NULL,
478     /* num_actions	  */	0,
479     /* resources	  */	resources,
480     /* resource_count	  */	XtNumber(resources),
481     /* xrm_class	  */	NULLQUARK,
482     /* compress_motion	  */	FALSE,
483     /* compress_exposure  */	TRUE,
484     /* compress_enterleave*/	FALSE,
485     /* visible_interest	  */	FALSE,
486     /* destroy		  */	NULL,
487     /* resize		  */	XawVendorShellExtResize,
488     /* expose		  */	NULL,
489     /* set_values	  */	XawVendorShellSetValues,
490     /* set_values_hook	  */	NULL,
491     /* set_values_almost  */	XtInheritSetValuesAlmost,
492     /* get_values_hook	  */	NULL,
493     /* accept_focus	  */	NULL,
494     /* intrinsics version */	XtVersion,
495     /* callback offsets	  */	NULL,
496     /* tm_table		  */	NULL,
497     /* query_geometry	  */	NULL,
498     /* display_accelerator*/	NULL,
499     /* extension	  */	NULL
500   },{
501     /* geometry_manager	  */	GeometryManager,
502     /* change_managed	  */	ChangeManaged,
503     /* insert_child	  */	XtInheritInsertChild,
504     /* delete_child	  */	XtInheritDeleteChild,
505     /* extension	  */	(XtPointer) &vendorCompositeExt
506   },{
507     /* extension	  */	NULL
508   },{
509     /* extension	  */	NULL
510   },{
511     /* extension	  */	NULL
512   }
513 };
514 
515 externaldef(vendorshellwidgetclass) WidgetClass vendorShellWidgetClass =
516 	(WidgetClass) (&vendorShellClassRec);
517 
518 
519 /***************************************************************************
520  *
521  * The following section is for the Vendor shell Extension class record
522  *
523  ***************************************************************************/
524 
525 static XtResource ext_resources[] = {
526   {XtNinputMethod, XtCInputMethod, XtRString, sizeof(String),
527 		XtOffsetOf(XawVendorShellExtRec, vendor_ext.im.input_method),
528 		XtRString, (XtPointer)NULL},
529   {XtNpreeditType, XtCPreeditType, XtRString, sizeof(String),
530 		XtOffsetOf(XawVendorShellExtRec, vendor_ext.im.preedit_type),
531 		XtRString, (XtPointer)"OverTheSpot,OffTheSpot,Root"},
532   {XtNopenIm, XtCOpenIm, XtRBoolean, sizeof(Boolean),
533 		XtOffsetOf(XawVendorShellExtRec, vendor_ext.im.open_im),
534 		XtRImmediate, (XtPointer)TRUE},
535   {XtNsharedIc, XtCSharedIc, XtRBoolean, sizeof(Boolean),
536 		XtOffsetOf(XawVendorShellExtRec, vendor_ext.ic.shared_ic),
537 		XtRImmediate, (XtPointer)FALSE}
538 };
539 
540 static void XawVendorShellExtClassInitialize();
541 static void XawVendorShellExtInitialize();
542 static void XawVendorShellExtDestroy();
543 static Boolean XawVendorShellExtSetValues();
544 
545 externaldef(vendorshellextclassrec) XawVendorShellExtClassRec
546        xawvendorShellExtClassRec = {
547   {
548     /* superclass	  */	(WidgetClass)&objectClassRec,
549     /* class_name	  */	"VendorShellExt",
550     /* size		  */	sizeof(XawVendorShellExtRec),
551     /* class_initialize	  */	XawVendorShellExtClassInitialize,
552     /* class_part_initialize*/	NULL,
553     /* Class init'ed ?	  */	FALSE,
554     /* initialize	  */	XawVendorShellExtInitialize,
555     /* initialize_hook	  */	NULL,
556     /* pad		  */	NULL,
557     /* pad		  */	NULL,
558     /* pad		  */	0,
559     /* resources	  */	ext_resources,
560     /* resource_count	  */	XtNumber(ext_resources),
561     /* xrm_class	  */	NULLQUARK,
562     /* pad		  */	FALSE,
563     /* pad		  */	FALSE,
564     /* pad		  */	FALSE,
565     /* pad		  */	FALSE,
566     /* destroy		  */	XawVendorShellExtDestroy,
567     /* pad		  */	NULL,
568     /* pad		  */	NULL,
569     /* set_values	  */	XawVendorShellExtSetValues,
570     /* set_values_hook	  */	NULL,
571     /* pad		  */	NULL,
572     /* get_values_hook	  */	NULL,
573     /* pad		  */	NULL,
574     /* version		  */	XtVersion,
575     /* callback_offsets	  */	NULL,
576     /* pad		  */	NULL,
577     /* pad		  */	NULL,
578     /* pad		  */	NULL,
579     /* extension	  */	NULL
580   },{
581     /* extension	  */	NULL
582   }
583 };
584 
585 externaldef(xawvendorshellwidgetclass) WidgetClass
586      xawvendorShellExtWidgetClass = (WidgetClass) (&xawvendorShellExtClassRec);
587 
588 
589 /*ARGSUSED*/
590 static Boolean
XawCvtCompoundTextToString(dpy,args,num_args,fromVal,toVal,cvt_data)591 XawCvtCompoundTextToString(dpy, args, num_args, fromVal, toVal, cvt_data)
592 Display *dpy;
593 XrmValuePtr args;
594 Cardinal    *num_args;
595 XrmValue *fromVal;
596 XrmValue *toVal;
597 XtPointer *cvt_data;
598 {
599     XTextProperty prop;
600     char **list;
601     int count;
602     static char *mbs = NULL;
603     int len;
604 
605     prop.value = (unsigned char *)fromVal->addr;
606     prop.encoding = XA_COMPOUND_TEXT(dpy);
607     prop.format = 8;
608     prop.nitems = fromVal->size;
609 
610     if(XmbTextPropertyToTextList(dpy, &prop, &list, &count) < Success) {
611 	XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
612 	"converter", "XmbTextPropertyToTextList", "XawError",
613 	"conversion from CT to MB failed.", NULL, 0);
614 	return False;
615     }
616     len = strlen(*list);
617     toVal->size = len;
618     mbs = XtRealloc(mbs, len + 1); /* keep buffer because no one call free :( */
619     strcpy(mbs, *list);
620     XFreeStringList(list);
621     toVal->addr = (XtPointer)mbs;
622     return True;
623 }
624 
XawVendorShellClassInitialize()625 static void XawVendorShellClassInitialize()
626 {
627     static XtConvertArgRec screenConvertArg[] = {
628         {XtWidgetBaseOffset, (XtPointer) XtOffsetOf(WidgetRec, core.screen),
629 	     sizeof(Screen *)}
630     };
631 
632     XtAddConverter(XtRString, XtRCursor, XmuCvtStringToCursor,
633 		   screenConvertArg, XtNumber(screenConvertArg));
634 
635     XtAddConverter(XtRString, XtRBitmap, XmuCvtStringToBitmap,
636 		   screenConvertArg, XtNumber(screenConvertArg));
637 
638     XtSetTypeConverter("CompoundText", XtRString, XawCvtCompoundTextToString,
639 			NULL, 0, XtCacheNone, NULL);
640 }
641 
XawVendorShellClassPartInit(class)642 static void XawVendorShellClassPartInit(class)
643     WidgetClass class;
644 {
645     CompositeClassExtension ext;
646     VendorShellWidgetClass vsclass = (VendorShellWidgetClass) class;
647 
648     if ((ext = (CompositeClassExtension)
649 	    XtGetClassExtension (class,
650 				 XtOffsetOf(CompositeClassRec,
651 					    composite_class.extension),
652 				 NULLQUARK, 1L, (Cardinal) 0)) == NULL) {
653 	ext = (CompositeClassExtension) XtNew (CompositeClassExtensionRec);
654 	if (ext != NULL) {
655 	    ext->next_extension = vsclass->composite_class.extension;
656 	    ext->record_type = NULLQUARK;
657 	    ext->version = XtCompositeExtensionVersion;
658 	    ext->record_size = sizeof (CompositeClassExtensionRec);
659 	    ext->accepts_objects = TRUE;
660 	    ext->allows_change_managed_set = FALSE;
661 	    vsclass->composite_class.extension = (XtPointer) ext;
662 	}
663     }
664 }
665 
666 #ifdef __osf__
667 /* stupid OSF/1 shared libraries have the wrong semantics */
668 /* symbols do not get resolved external to the shared library */
_XawFixupVendorShell()669 void _XawFixupVendorShell()
670 {
671     transientShellWidgetClass->core_class.superclass =
672         (WidgetClass) &vendorShellClassRec;
673     topLevelShellWidgetClass->core_class.superclass =
674         (WidgetClass) &vendorShellClassRec;
675 }
676 #endif
677 
678 /* ARGSUSED */
XawVendorShellInitialize(req,new,args,num_args)679 static void XawVendorShellInitialize(req, new, args, num_args)
680 	Widget req, new;
681 	ArgList     args;
682 	Cardinal    *num_args;
683 {
684     XtAddEventHandler(new, (EventMask) 0, TRUE, _XEditResCheckMessages, NULL);
685 #ifdef HAVE_XMUREGISTEREXTERNALAGENT
686     XtAddEventHandler(new, (EventMask) 0, TRUE, XmuRegisterExternalAgent, NULL);
687 #endif /* HAVE_XMUREGISTEREXTERNALAGENT */
688 
689     XtCreateWidget("shellext", xawvendorShellExtWidgetClass,
690 		   new, args, *num_args);
691 }
692 
693 /* ARGSUSED */
XawVendorShellSetValues(old,ref,new)694 static Boolean XawVendorShellSetValues(old, ref, new)
695 	Widget old, ref, new;
696 {
697 	return FALSE;
698 }
699 
Realize(wid,vmask,attr)700 static void Realize(wid, vmask, attr)
701 	Widget wid;
702 	Mask *vmask;
703 	XSetWindowAttributes *attr;
704 {
705 	WidgetClass super = wmShellWidgetClass;
706 
707 	/* Make my superclass do all the dirty work */
708 
709 	(*super->core_class.realize) (wid, vmask, attr);
710 	_XawImRealize(wid);
711 }
712 
713 
XawVendorShellExtClassInitialize()714 static void XawVendorShellExtClassInitialize()
715 {
716 }
717 
718 /* ARGSUSED */
XawVendorShellExtInitialize(req,new)719 static void XawVendorShellExtInitialize(req, new)
720         Widget req, new;
721 {
722     _XawImInitialize(new->core.parent, new);
723 }
724 
725 /* ARGSUSED */
XawVendorShellExtDestroy(w)726 static void XawVendorShellExtDestroy( w )
727         Widget w;
728 {
729     _XawImDestroy( w->core.parent, w );
730 }
731 
732 /* ARGSUSED */
XawVendorShellExtSetValues(old,ref,new)733 static Boolean XawVendorShellExtSetValues(old, ref, new)
734 	Widget old, ref, new;
735 {
736 	return FALSE;
737 }
738 
XawVendorShellExtResize(w)739 void XawVendorShellExtResize( w )
740     Widget w;
741 {
742 	ShellWidget sw = (ShellWidget) w;
743 	Widget childwid;
744 	int i;
745 	int core_height;
746 
747 	_XawImResizeVendorShell( w );
748 	core_height = _XawImGetShellHeight( w );
749 	for( i = 0; i < sw->composite.num_children; i++ ) {
750 	    if( XtIsManaged( sw->composite.children[ i ] ) ) {
751 		childwid = sw->composite.children[ i ];
752 		XtResizeWidget( childwid, sw->core.width, core_height,
753 			       childwid->core.border_width );
754 	    }
755 	}
756 }
757 
758 /*ARGSUSED*/
GeometryManager(wid,request,reply)759 static XtGeometryResult GeometryManager( wid, request, reply )
760 	Widget wid;
761 	XtWidgetGeometry *request;
762 	XtWidgetGeometry *reply;
763 {
764 	ShellWidget shell = (ShellWidget)(wid->core.parent);
765 	XtWidgetGeometry my_request;
766 
767 	if(shell->shell.allow_shell_resize == FALSE && XtIsRealized(wid))
768 		return(XtGeometryNo);
769 
770 	if (request->request_mode & (CWX | CWY))
771 	    return(XtGeometryNo);
772 
773 	/* %%% worry about XtCWQueryOnly */
774 	my_request.request_mode = 0;
775 	if (request->request_mode & CWWidth) {
776 	    my_request.width = request->width;
777 	    my_request.request_mode |= CWWidth;
778 	}
779 	if (request->request_mode & CWHeight) {
780 	    my_request.height = request->height
781 			      + _XawImGetImAreaHeight( wid );
782 	    my_request.request_mode |= CWHeight;
783 	}
784 	if (request->request_mode & CWBorderWidth) {
785 	    my_request.border_width = request->border_width;
786 	    my_request.request_mode |= CWBorderWidth;
787 	}
788 	if (XtMakeGeometryRequest((Widget)shell, &my_request, NULL)
789 		== XtGeometryYes) {
790 	    /* assert: if (request->request_mode & CWWidth) then
791 	     * 		  shell->core.width == request->width
792 	     * assert: if (request->request_mode & CWHeight) then
793 	     * 		  shell->core.height == request->height
794 	     *
795 	     * so, whatever the WM sized us to (if the Shell requested
796 	     * only one of the two) is now the correct child size
797 	     */
798 
799 	    wid->core.width = shell->core.width;
800 	    wid->core.height = shell->core.height;
801 	    if (request->request_mode & CWBorderWidth) {
802 		wid->core.x = wid->core.y = -request->border_width;
803 	    }
804 	    _XawImCallVendorShellExtResize(wid);
805 	    return XtGeometryYes;
806 	} else return XtGeometryNo;
807 }
808 
ChangeManaged(wid)809 static void ChangeManaged(wid)
810 	Widget wid;
811 {
812 	ShellWidget w = (ShellWidget) wid;
813 	Widget* childP;
814 	int i;
815 
816 	(*SuperClass->composite_class.change_managed)(wid);
817 	for (i = w->composite.num_children, childP = w->composite.children;
818 	     i; i--, childP++) {
819 	    if (XtIsManaged(*childP)) {
820 		XtSetKeyboardFocus(wid, *childP);
821 		break;
822 	    }
823 	}
824 }
825