749N/A/* $XConsortium: Vendor.c,v 1.27 94/04/17 20:13:25 kaleb Exp $ */
749N/A
749N/A/***********************************************************
749N/A
749N/ACopyright (c) 1987, 1988, 1994 X Consortium
749N/A
749N/APermission is hereby granted, free of charge, to any person obtaining a copy
749N/Aof this software and associated documentation files (the "Software"), to deal
749N/Ain the Software without restriction, including without limitation the rights
749N/Ato use, copy, modify, merge, publish, distribute, sublicense, and/or sell
749N/Acopies of the Software, and to permit persons to whom the Software is
749N/Afurnished to do so, subject to the following conditions:
749N/A
749N/AThe above copyright notice and this permission notice shall be included in
749N/Aall copies or substantial portions of the Software.
749N/A
749N/ATHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
749N/AIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
749N/AFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
749N/AX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
749N/AAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
749N/ACONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
749N/A
749N/AExcept as contained in this notice, the name of the X Consortium shall not be
749N/Aused in advertising or otherwise to promote the sale, use or other dealings
749N/Ain this Software without prior written authorization from the X Consortium.
749N/A
749N/A
749N/ACopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
749N/A
749N/A All Rights Reserved
749N/A
749N/APermission to use, copy, modify, and distribute this software and its
749N/Adocumentation for any purpose and without fee is hereby granted,
749N/Aprovided that the above copyright notice appear in all copies and that
749N/Aboth that copyright notice and this permission notice appear in
749N/Asupporting documentation, and that the name of Digital not be
749N/Aused in advertising or publicity pertaining to distribution of the
749N/Asoftware without specific, written prior permission.
749N/A
749N/ADIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
749N/AALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
749N/ADIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
749N/AANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
749N/AWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
749N/AARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
749N/ASOFTWARE.
749N/A
749N/A******************************************************************/
749N/A
749N/A/*
749N/A * This is a copy of Xt/Vendor.c with an additional ClassInitialize
749N/A * procedure to register Xmu resource type converters, and all the
749N/A * monkey business associated with input methods...
749N/A *
749N/A */
749N/A
749N/A/* Make sure all wm properties can make it out of the resource manager */
749N/A
749N/A#include <stdio.h>
749N/A#include <X11/IntrinsicP.h>
749N/A#include <X11/StringDefs.h>
749N/A#include <X11/ShellP.h>
749N/A#include <X11/VendorP.h>
749N/A#include <X11/Xmu/Converters.h>
749N/A#include <X11/Xmu/Atoms.h>
749N/A#include <X11/Xmu/Editres.h>
749N/A#include <X11/Xmu/ExtAgent.h>
749N/A
749N/A/* The following two headers are for the input method. */
749N/A
749N/A#include <X11/Xaw/VendorEP.h>
749N/A#include <X11/Xaw/XawImP.h>
749N/A
749N/A
749N/Astatic XtResource resources[] = {
749N/A {XtNinput, XtCInput, XtRBool, sizeof(Bool),
749N/A XtOffsetOf(VendorShellRec, wm.wm_hints.input),
749N/A XtRImmediate, (XtPointer)True}
749N/A};
749N/A
749N/A/***************************************************************************
749N/A *
749N/A * Vendor shell class record
749N/A *
749N/A ***************************************************************************/
749N/A
749N/Astatic void XawVendorShellClassInitialize();
749N/Astatic void XawVendorShellClassPartInit();
749N/Astatic void XawVendorShellInitialize();
749N/Astatic Boolean XawVendorShellSetValues();
749N/Astatic void Realize(), ChangeManaged();
749N/Astatic XtGeometryResult GeometryManager();
749N/Avoid XawVendorShellExtResize();
749N/A
749N/Astatic CompositeClassExtensionRec vendorCompositeExt = {
749N/A /* next_extension */ NULL,
749N/A /* record_type */ NULLQUARK,
749N/A /* version */ XtCompositeExtensionVersion,
749N/A /* record_size */ sizeof (CompositeClassExtensionRec),
749N/A /* accepts_objects */ TRUE,
749N/A /* allows_change_managed_set */ FALSE
749N/A};
749N/A
749N/A#define SuperClass (&wmShellClassRec)
749N/Aexternaldef(vendorshellclassrec) VendorShellClassRec vendorShellClassRec = {
749N/A {
749N/A /* superclass */ (WidgetClass)SuperClass,
749N/A /* class_name */ "VendorShell",
749N/A /* size */ sizeof(VendorShellRec),
749N/A /* class_initialize */ XawVendorShellClassInitialize,
749N/A /* class_part_init */ XawVendorShellClassPartInit,
749N/A /* Class init'ed ? */ FALSE,
749N/A /* initialize */ XawVendorShellInitialize,
749N/A /* initialize_hook */ NULL,
749N/A /* realize */ Realize,
749N/A /* actions */ NULL,
749N/A /* num_actions */ 0,
749N/A /* resources */ resources,
749N/A /* resource_count */ XtNumber(resources),
749N/A /* xrm_class */ NULLQUARK,
749N/A /* compress_motion */ FALSE,
749N/A /* compress_exposure */ TRUE,
749N/A /* compress_enterleave*/ FALSE,
749N/A /* visible_interest */ FALSE,
749N/A /* destroy */ NULL,
749N/A /* resize */ XawVendorShellExtResize,
749N/A /* expose */ NULL,
749N/A /* set_values */ XawVendorShellSetValues,
749N/A /* set_values_hook */ NULL,
749N/A /* set_values_almost */ XtInheritSetValuesAlmost,
749N/A /* get_values_hook */ NULL,
749N/A /* accept_focus */ NULL,
749N/A /* intrinsics version */ XtVersion,
749N/A /* callback offsets */ NULL,
749N/A /* tm_table */ NULL,
749N/A /* query_geometry */ NULL,
749N/A /* display_accelerator*/ NULL,
749N/A /* extension */ NULL
749N/A },{
749N/A /* geometry_manager */ GeometryManager,
749N/A /* change_managed */ ChangeManaged,
749N/A /* insert_child */ XtInheritInsertChild,
749N/A /* delete_child */ XtInheritDeleteChild,
749N/A /* extension */ (XtPointer) &vendorCompositeExt
749N/A },{
749N/A /* extension */ NULL
749N/A },{
749N/A /* extension */ NULL
749N/A },{
749N/A /* extension */ NULL
749N/A }
749N/A};
749N/A
749N/Aexternaldef(vendorshellwidgetclass) WidgetClass vendorShellWidgetClass =
749N/A (WidgetClass) (&vendorShellClassRec);
749N/A
749N/A
749N/A/***************************************************************************
749N/A *
749N/A * The following section is for the Vendor shell Extension class record
749N/A *
749N/A ***************************************************************************/
749N/A
749N/Astatic XtResource ext_resources[] = {
749N/A {XtNinputMethod, XtCInputMethod, XtRString, sizeof(String),
749N/A XtOffsetOf(XawVendorShellExtRec, vendor_ext.im.input_method),
749N/A XtRString, (XtPointer)NULL},
749N/A {XtNpreeditType, XtCPreeditType, XtRString, sizeof(String),
749N/A XtOffsetOf(XawVendorShellExtRec, vendor_ext.im.preedit_type),
749N/A XtRString, (XtPointer)"OverTheSpot,OffTheSpot,Root"},
749N/A {XtNopenIm, XtCOpenIm, XtRBoolean, sizeof(Boolean),
749N/A XtOffsetOf(XawVendorShellExtRec, vendor_ext.im.open_im),
749N/A XtRImmediate, (XtPointer)TRUE},
749N/A {XtNsharedIc, XtCSharedIc, XtRBoolean, sizeof(Boolean),
749N/A XtOffsetOf(XawVendorShellExtRec, vendor_ext.ic.shared_ic),
749N/A XtRImmediate, (XtPointer)FALSE}
749N/A};
749N/A
749N/Astatic void XawVendorShellExtClassInitialize();
749N/Astatic void XawVendorShellExtInitialize();
749N/Astatic void XawVendorShellExtDestroy();
749N/Astatic Boolean XawVendorShellExtSetValues();
749N/A
749N/Aexternaldef(vendorshellextclassrec) XawVendorShellExtClassRec
749N/A xawvendorShellExtClassRec = {
749N/A {
749N/A /* superclass */ (WidgetClass)&objectClassRec,
749N/A /* class_name */ "VendorShellExt",
749N/A /* size */ sizeof(XawVendorShellExtRec),
749N/A /* class_initialize */ XawVendorShellExtClassInitialize,
749N/A /* class_part_initialize*/ NULL,
749N/A /* Class init'ed ? */ FALSE,
749N/A /* initialize */ XawVendorShellExtInitialize,
749N/A /* initialize_hook */ NULL,
749N/A /* pad */ NULL,
749N/A /* pad */ NULL,
749N/A /* pad */ 0,
749N/A /* resources */ ext_resources,
749N/A /* resource_count */ XtNumber(ext_resources),
749N/A /* xrm_class */ NULLQUARK,
749N/A /* pad */ FALSE,
749N/A /* pad */ FALSE,
749N/A /* pad */ FALSE,
749N/A /* pad */ FALSE,
749N/A /* destroy */ XawVendorShellExtDestroy,
749N/A /* pad */ NULL,
749N/A /* pad */ NULL,
749N/A /* set_values */ XawVendorShellExtSetValues,
749N/A /* set_values_hook */ NULL,
749N/A /* pad */ NULL,
749N/A /* get_values_hook */ NULL,
749N/A /* pad */ NULL,
749N/A /* version */ XtVersion,
749N/A /* callback_offsets */ NULL,
749N/A /* pad */ NULL,
749N/A /* pad */ NULL,
749N/A /* pad */ NULL,
749N/A /* extension */ NULL
749N/A },{
749N/A /* extension */ NULL
749N/A }
749N/A};
749N/A
749N/Aexternaldef(xawvendorshellwidgetclass) WidgetClass
749N/A xawvendorShellExtWidgetClass = (WidgetClass) (&xawvendorShellExtClassRec);
749N/A
749N/A
749N/A/*ARGSUSED*/
749N/Astatic Boolean
749N/AXawCvtCompoundTextToString(dpy, args, num_args, fromVal, toVal, cvt_data)
749N/ADisplay *dpy;
749N/AXrmValuePtr args;
749N/ACardinal *num_args;
749N/AXrmValue *fromVal;
749N/AXrmValue *toVal;
749N/AXtPointer *cvt_data;
749N/A{
749N/A XTextProperty prop;
749N/A char **list;
749N/A int count;
749N/A static char *mbs = NULL;
749N/A int len;
749N/A
749N/A prop.value = (unsigned char *)fromVal->addr;
749N/A prop.encoding = XA_COMPOUND_TEXT(dpy);
749N/A prop.format = 8;
749N/A prop.nitems = fromVal->size;
749N/A
749N/A if(XmbTextPropertyToTextList(dpy, &prop, &list, &count) < Success) {
749N/A XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
749N/A "converter", "XmbTextPropertyToTextList", "XawError",
749N/A "conversion from CT to MB failed.", NULL, 0);
749N/A return False;
749N/A }
749N/A len = strlen(*list);
749N/A toVal->size = len;
749N/A mbs = XtRealloc(mbs, len + 1); /* keep buffer because no one call free :( */
749N/A strcpy(mbs, *list);
749N/A XFreeStringList(list);
749N/A toVal->addr = (XtPointer)mbs;
749N/A return True;
749N/A}
749N/A
749N/Astatic void XawVendorShellClassInitialize()
749N/A{
749N/A static XtConvertArgRec screenConvertArg[] = {
749N/A {XtWidgetBaseOffset, (XtPointer) XtOffsetOf(WidgetRec, core.screen),
749N/A sizeof(Screen *)}
749N/A };
749N/A
749N/A XtAddConverter(XtRString, XtRCursor, XmuCvtStringToCursor,
749N/A screenConvertArg, XtNumber(screenConvertArg));
749N/A
749N/A XtAddConverter(XtRString, XtRBitmap, XmuCvtStringToBitmap,
749N/A screenConvertArg, XtNumber(screenConvertArg));
749N/A
749N/A XtSetTypeConverter("CompoundText", XtRString, XawCvtCompoundTextToString,
749N/A NULL, 0, XtCacheNone, NULL);
749N/A}
749N/A
749N/Astatic void XawVendorShellClassPartInit(class)
749N/A WidgetClass class;
749N/A{
749N/A CompositeClassExtension ext;
749N/A VendorShellWidgetClass vsclass = (VendorShellWidgetClass) class;
749N/A
749N/A if ((ext = (CompositeClassExtension)
749N/A XtGetClassExtension (class,
749N/A XtOffsetOf(CompositeClassRec,
749N/A composite_class.extension),
749N/A NULLQUARK, 1L, (Cardinal) 0)) == NULL) {
749N/A ext = (CompositeClassExtension) XtNew (CompositeClassExtensionRec);
749N/A if (ext != NULL) {
749N/A ext->next_extension = vsclass->composite_class.extension;
749N/A ext->record_type = NULLQUARK;
749N/A ext->version = XtCompositeExtensionVersion;
749N/A ext->record_size = sizeof (CompositeClassExtensionRec);
749N/A ext->accepts_objects = TRUE;
749N/A ext->allows_change_managed_set = FALSE;
749N/A vsclass->composite_class.extension = (XtPointer) ext;
749N/A }
749N/A }
749N/A}
749N/A
749N/A#ifdef __osf__
749N/A/* stupid OSF/1 shared libraries have the wrong semantics */
749N/A/* symbols do not get resolved external to the shared library */
749N/Avoid _XawFixupVendorShell()
749N/A{
749N/A transientShellWidgetClass->core_class.superclass =
749N/A (WidgetClass) &vendorShellClassRec;
749N/A topLevelShellWidgetClass->core_class.superclass =
749N/A (WidgetClass) &vendorShellClassRec;
749N/A}
749N/A#endif
749N/A
749N/A/* ARGSUSED */
749N/Astatic void XawVendorShellInitialize(req, new, args, num_args)
749N/A Widget req, new;
749N/A ArgList args;
749N/A Cardinal *num_args;
749N/A{
749N/A XtAddEventHandler(new, (EventMask) 0, TRUE, _XEditResCheckMessages, NULL);
749N/A XtAddEventHandler(new, (EventMask) 0, TRUE, XmuRegisterExternalAgent, NULL);
749N/A XtCreateWidget("shellext", xawvendorShellExtWidgetClass,
749N/A new, args, *num_args);
749N/A}
749N/A
749N/A/* ARGSUSED */
749N/Astatic Boolean XawVendorShellSetValues(old, ref, new)
749N/A Widget old, ref, new;
749N/A{
749N/A return FALSE;
749N/A}
749N/A
749N/Astatic void Realize(wid, vmask, attr)
749N/A Widget wid;
749N/A Mask *vmask;
749N/A XSetWindowAttributes *attr;
749N/A{
749N/A WidgetClass super = wmShellWidgetClass;
749N/A
749N/A /* Make my superclass do all the dirty work */
749N/A
749N/A (*super->core_class.realize) (wid, vmask, attr);
749N/A _XawImRealize(wid);
749N/A}
749N/A
749N/A
749N/Astatic void XawVendorShellExtClassInitialize()
749N/A{
749N/A}
749N/A
749N/A/* ARGSUSED */
749N/Astatic void XawVendorShellExtInitialize(req, new)
749N/A Widget req, new;
749N/A{
749N/A _XawImInitialize(new->core.parent, new);
749N/A}
749N/A
749N/A/* ARGSUSED */
749N/Astatic void XawVendorShellExtDestroy( w )
749N/A Widget w;
749N/A{
749N/A _XawImDestroy( w->core.parent, w );
749N/A}
749N/A
749N/A/* ARGSUSED */
749N/Astatic Boolean XawVendorShellExtSetValues(old, ref, new)
749N/A Widget old, ref, new;
749N/A{
749N/A return FALSE;
749N/A}
749N/A
749N/Avoid XawVendorShellExtResize( w )
749N/A Widget w;
749N/A{
749N/A ShellWidget sw = (ShellWidget) w;
749N/A Widget childwid;
749N/A int i;
749N/A int core_height;
749N/A
749N/A _XawImResizeVendorShell( w );
749N/A core_height = _XawImGetShellHeight( w );
749N/A for( i = 0; i < sw->composite.num_children; i++ ) {
749N/A if( XtIsManaged( sw->composite.children[ i ] ) ) {
749N/A childwid = sw->composite.children[ i ];
749N/A XtResizeWidget( childwid, sw->core.width, core_height,
749N/A childwid->core.border_width );
749N/A }
749N/A }
749N/A}
749N/A
749N/A/*ARGSUSED*/
749N/Astatic XtGeometryResult GeometryManager( wid, request, reply )
749N/A Widget wid;
749N/A XtWidgetGeometry *request;
749N/A XtWidgetGeometry *reply;
749N/A{
749N/A ShellWidget shell = (ShellWidget)(wid->core.parent);
749N/A XtWidgetGeometry my_request;
749N/A
749N/A if(shell->shell.allow_shell_resize == FALSE && XtIsRealized(wid))
749N/A return(XtGeometryNo);
749N/A
749N/A if (request->request_mode & (CWX | CWY))
749N/A return(XtGeometryNo);
749N/A
749N/A /* %%% worry about XtCWQueryOnly */
749N/A my_request.request_mode = 0;
749N/A if (request->request_mode & CWWidth) {
749N/A my_request.width = request->width;
749N/A my_request.request_mode |= CWWidth;
749N/A }
749N/A if (request->request_mode & CWHeight) {
749N/A my_request.height = request->height
749N/A + _XawImGetImAreaHeight( wid );
749N/A my_request.request_mode |= CWHeight;
749N/A }
749N/A if (request->request_mode & CWBorderWidth) {
749N/A my_request.border_width = request->border_width;
749N/A my_request.request_mode |= CWBorderWidth;
749N/A }
749N/A if (XtMakeGeometryRequest((Widget)shell, &my_request, NULL)
749N/A == XtGeometryYes) {
749N/A /* assert: if (request->request_mode & CWWidth) then
749N/A * shell->core.width == request->width
749N/A * assert: if (request->request_mode & CWHeight) then
749N/A * shell->core.height == request->height
749N/A *
749N/A * so, whatever the WM sized us to (if the Shell requested
749N/A * only one of the two) is now the correct child size
749N/A */
749N/A
749N/A wid->core.width = shell->core.width;
749N/A wid->core.height = shell->core.height;
749N/A if (request->request_mode & CWBorderWidth) {
749N/A wid->core.x = wid->core.y = -request->border_width;
749N/A }
749N/A _XawImCallVendorShellExtResize(wid);
749N/A return XtGeometryYes;
749N/A } else return XtGeometryNo;
749N/A}
749N/A
749N/Astatic void ChangeManaged(wid)
749N/A Widget wid;
749N/A{
749N/A ShellWidget w = (ShellWidget) wid;
749N/A Widget* childP;
749N/A int i;
749N/A
749N/A (*SuperClass->composite_class.change_managed)(wid);
749N/A for (i = w->composite.num_children, childP = w->composite.children;
749N/A i; i--, childP++) {
749N/A if (XtIsManaged(*childP)) {
749N/A XtSetKeyboardFocus(wid, *childP);
749N/A break;
749N/A }
749N/A }
749N/A}