Exemplo n.º 1
0
MsgList MakeNullMsgList()
{
    MsgList mlist;
    mlist = XtNew(MsgListRec);
    mlist->nummsgs = 0;
    mlist->msglist = XtNew(Msg);
    mlist->msglist[0] = NULL;
    return mlist;
}
Exemplo n.º 2
0
void
SFinitFont()
{
	TextData	*data;

	data = XtNew(TextData);

	XtGetApplicationResources(selFileForm, (XtPointer) data, textResources,
		XtNumber(textResources), (Arg *) NULL, ZERO);

	SFfont = XLoadQueryFont(SFdisplay, data->fontname);
	if (!SFfont) {
		SFfont = XLoadQueryFont(SFdisplay, SF_DEFAULT_FONT);
		if (!SFfont) {
			char	sbuf[256];

			(void) sprintf(sbuf, "XsraSelFile: can't get font %s",
				SF_DEFAULT_FONT);

			XtAppError(SFapp, sbuf);
		}
	}

	SFcharWidth = (SFfont->max_bounds.width + SFfont->min_bounds.width) / 2;
	SFcharAscent = SFfont->max_bounds.ascent;
	SFcharHeight = SFcharAscent + SFfont->max_bounds.descent;
	return;
}
Exemplo n.º 3
0
static void
InitAppLock(XtAppContext app)
{
    int ii;
    LockPtr app_lock;

    app->lock = AppLock;
    app->unlock = AppUnlock;
    app->yield_lock = YieldAppLock;
    app->restore_lock = RestoreAppLock;
    app->free_lock = FreeAppLock;

    app_lock = app->lock_info = XtNew(LockRec);
    app_lock->mutex = xmutex_malloc();
    xmutex_init(app_lock->mutex);
    app_lock->level = 0;
#ifndef _XMUTEX_NESTS
    app_lock->cond = xcondition_malloc();
    xcondition_init(app_lock->cond);
    xthread_clear_id(app_lock->holder);
#endif
    app_lock->stack.size = STACK_INCR;
    app_lock->stack.sp = -1;
    app_lock->stack.st =
	(struct _Tstack *)__XtMalloc(sizeof(struct _Tstack)*STACK_INCR);
    for (ii = 0; ii < STACK_INCR; ii++) {
	app_lock->stack.st[ii].c = xcondition_malloc();
	xcondition_init(app_lock->stack.st[ii].c);
    }
}
Exemplo n.º 4
0
void
SFinitFont()
{
#if ENABLE_NLS
	XFontSetExtents *fse = XExtentsOfFontSet(fontSet);
	SFcharWidth = fse->max_logical_extent.width;
	SFcharAscent = -fse->max_logical_extent.y;
	SFcharHeight = fse->max_logical_extent.height;
#else
	TextData	*data;

	data = XtNew(TextData);

	XtGetApplicationResources(selFileForm, (XtPointer) data, textResources,
		XtNumber(textResources), (Arg *) NULL, ZERO);

	SFfont = XLoadQueryFont(SFdisplay, data->fontname);
	if (!SFfont) {
		SFfont = XLoadQueryFont(SFdisplay, SF_DEFAULT_FONT);
		if (!SFfont) {
			char	sbuf[256];

			(void) sprintf(sbuf, "XsraSelFile: can't get font %s",
				SF_DEFAULT_FONT);

			XtAppError(SFapp, sbuf);
		}
	}

	SFcharWidth = (SFfont->max_bounds.width + SFfont->min_bounds.width) / 2;
	SFcharAscent = SFfont->max_bounds.ascent;
	SFcharHeight = SFcharAscent + SFfont->max_bounds.descent;
#endif
	return;
}
Exemplo n.º 5
0
static void 
CompileTranslations(StrokeStatePtr State)
{
	StrokeMapPtr NewMap;
	String StrokeName;
	String ActionName;
	int BytesRead;
	char *tmp;
	int i;

	i = 0;
	tmp = State->translations;
	StrokeName = XtNewString(tmp);
	ActionName = XtNewString(tmp);
	while (strlen(tmp) > 0)
	{
		StrokeName[0] = '\0';
		ActionName[0] = '\0';
		BytesRead = 0;
		sscanf(tmp, "%s %[^, \t]%n%*[, \t\n]%n", StrokeName, ActionName, &BytesRead, &BytesRead);
		NewMap = XtNew(StrokeMap);
		NewMap->Stroke = XtNewString(StrokeName);
		NewMap->Action = XtNewString(ActionName);
		State->Map = (StrokeMapPtr *) XtRealloc((char *)State->Map, (i + 2) * sizeof(StrokeMapPtr));
		State->Map[i] = NewMap;
		State->Map[i + 1] = NULL;
		tmp += BytesRead;
		i++;
	}
	XtFree(StrokeName);
	XtFree(ActionName);
}
Exemplo n.º 6
0
static void 
_StrokeInitialize(Widget W)
{
	StrokeStatePtr NewState;

	if (StrokeStateList == NULL)
	{
		NewState = XtNew(StrokeState_t);
		NewState->next = StrokeStateList;
		StrokeStateList = NewState;
		NewState->widget = W;
		NewState->InStroke = False;
		NewState->points = NULL;
		NewState->box = NULL;
		NewState->Map = NULL;
		NewState->npoints = 0;
		NewState->maxpoints = 0;
		NewState->gc = (GC)NULL;
		XtGetApplicationResources(W,
					  NewState,
					  resources, XtNumber(resources),
					  NULL, 0);
		if (NewState->slop < 3)
		{
			XtWarning("Stroke slop cannot be less than 3");
			NewState->slop = 3;
		}
	}
	XtAppAddActions(XtWidgetToApplicationContext(W),
			Actions, XtNumber(Actions));
}
Exemplo n.º 7
0
/*
 * Create and initialize a ScrollMgr
 */
SmScrollMgr
xbaeSmCreateScrollMgr()
{
    SmScrollMgr scrollMgr = XtNew(SmScrollMgrRec);

    scrollMgr->offset_x = 0;
    scrollMgr->offset_y = 0;
    scrollMgr->scroll_count = 0;
    scrollMgr->scroll_queue = NULL;
    scrollMgr->scrolling = False;

    return scrollMgr;
}
Exemplo n.º 8
0
static void
InitProcessLock(void)
{
    if(!process_lock) {
    	process_lock = XtNew(LockRec);
    	process_lock->mutex = xmutex_malloc();
    	xmutex_init(process_lock->mutex);
    	process_lock->level = 0;
#ifndef _XMUTEX_NESTS
    	process_lock->cond = xcondition_malloc();
    	xcondition_init(process_lock->cond);
    	xthread_clear_id(process_lock->holder);
#endif
    }
}
Exemplo n.º 9
0
static XawVendorShellExtPart *
SetExtPart(VendorShellWidget w, XawVendorShellExtWidget vew)
{
    contextDataRec *contextData;

    if (extContext == (XContext)0) extContext = XUniqueContext();

    contextData = XtNew(contextDataRec);
    contextData->parent = (Widget)w;
    contextData->ve = (Widget)vew;
    if (XSaveContext(XtDisplay(w), (Window)(((intptr_t)w)&0xffffffff), extContext, (char *)contextData)) {
	return(NULL);
    }
    return(&(vew->vendor_ext));
}
Exemplo n.º 10
0
static Widget SetErrCnxt(Widget w, XIM xim)
{
    contextErrDataRec *contextErrData;

    if (errContext == (XContext)0) errContext = XUniqueContext();

    contextErrData = XtNew(contextErrDataRec);
    contextErrData->widget = w;
    contextErrData->xim = xim;
    if (XSaveContext(XtDisplay(w), (Window)(uintptr_t)xim, errContext,
	(char *)contextErrData)) {
	return(NULL);
    }
    return(contextErrData->widget);
}
Exemplo n.º 11
0
Arquivo: bbox.c Projeto: aosm/X11
static void bboxAddButton(
    ButtonBox	buttonbox,
    char	*name,
    WidgetClass	kind,
    Boolean	enabled,
    Boolean	radio)
{
    Button	button;
    Cardinal	i;
    Widget	radio_group;
    Arg		args[5];

    buttonbox->numbuttons++;
    buttonbox->button = (Button *) 
	XtRealloc((char *) buttonbox->button,
		  (unsigned) buttonbox->numbuttons * sizeof(Button));
    button = buttonbox->button[buttonbox->numbuttons - 1] = XtNew(ButtonRec);
    button->buttonbox = buttonbox;
    button->name = XtNewString(name);
    button->menu = (Widget) NULL;

    i = 0;
    if (!enabled) {
	XtSetArg(args[i], XtNsensitive, False);		i++;
    }

    if (radio && kind == toggleWidgetClass) {
	if (buttonbox->numbuttons > 1)
	    radio_group = (button == buttonbox->button[0]) 
		? (buttonbox->button[1]->widget)
		: (buttonbox->button[0]->widget);
	else radio_group = NULL;
	XtSetArg(args[i], XtNradioGroup, radio_group);		i++;
	XtSetArg(args[i], XtNradioData, button->name);		i++;
    }

    /* Prevent the folder buttons from picking up labels from resources */

    if (buttonbox == buttonbox->scrn->folderbuttons) {
	XtSetArg(args[i], XtNlabel, button->name);	i++;
    }

    button->widget =
	XtCreateManagedWidget(name, kind, buttonbox->inner, args, i);

    if (radio)
	XtOverrideTranslations(button->widget, RadioButtonTranslations);
}
Exemplo n.º 12
0
static Bool
BeginPaint(Widget w)
{
    TextSinkObject sink = (TextSinkObject)w;

    if (sink->text_sink.paint != NULL)
	return (False);

    sink->text_sink.paint = XtNew(XawTextPaintList);
    sink->text_sink.paint->clip = XmuCreateArea();
    sink->text_sink.paint->hightabs = NULL;
    sink->text_sink.paint->paint = NULL;
    sink->text_sink.paint->bearings = NULL;

    return (True);
}
Exemplo n.º 13
0
static void * PH_popup_image( void * handle , MRI_IMAGE * im )
{
   PLUGIN_impopper * imp = (PLUGIN_impopper *) handle ;

   /*-- input image is NULL ==> popdown, if applicable --*/

   if( im == NULL ){
      if( imp != NULL )
         drive_MCW_imseq( imp->seq , isqDR_destroy , NULL ) ;

      return ((void *) imp) ;
   }

   /*-- input = no popper handle ==> create one --*/

   if( imp == NULL ){
      imp      = XtNew(PLUGIN_impopper) ;
      imp->seq = NULL ; imp->im  = NULL ;
   }

   /*-- input = non-null image ==> replace image --*/

   mri_free( imp->im ) ;                   /* toss old copy */
   imp->im = mri_to_mri( im->kind , im ) ; /* make new copy */

   /*-- input = inactive popper handle ==> activate it --*/

   if( imp->seq == NULL ){
      imp->seq = open_MCW_imseq( MAIN_dc ,
                                 PLUGIN_imseq_getim , (XtPointer) imp ) ;

      drive_MCW_imseq( imp->seq , isqDR_realize, NULL ) ;
      drive_MCW_imseq( imp->seq , isqDR_onoffwid , (XtPointer) isqDR_offwid ) ;

      XtVaSetValues( imp->seq->wtop ,
                       XmNmwmDecorations , MWM_DECOR_BORDER | MWM_DECOR_TITLE | MWM_DECOR_MENU ,
                       XmNmwmFunctions   , MWM_FUNC_MOVE | MWM_FUNC_CLOSE ,
                       XmNtitle          , "Xphace Images" ,
                     NULL ) ;

   }

   drive_MCW_imseq( imp->seq , isqDR_clearstat , NULL ) ;
   drive_MCW_imseq( imp->seq , isqDR_reimage , (XtPointer) 0 ) ;

   return ((void *) imp) ;
}
Exemplo n.º 14
0
static StrokeStatePtr 
StrokeGetMap(Widget W)
{
	StrokeStatePtr State;

	State = StrokeMapList;
	while (State != NULL)
	{
		if (State->widget == W)
		{
			break;
		}
		State = State->next;
	}
	if (State == NULL)
	{
		StrokeStatePtr NewState;

		NewState = XtNew(StrokeState_t);
		NewState->next = StrokeMapList;
		StrokeMapList = NewState;
		NewState->widget = W;
		NewState->InStroke = False;
		NewState->points = NULL;
		NewState->box = NULL;
		NewState->Map = NULL;
		NewState->npoints = 0;
		NewState->maxpoints = 0;
		NewState->gc = (GC)NULL;
		XtGetSubresources(XtParent(W),
				  NewState,
				  XtName(W),
				  XtClass(W)->core_class.class_name,
				  resources,
				  XtNumber(resources),
				  NULL,
				  0);
		CompileTranslations(NewState);
		State = NewState;
	}
	return (State);
}
Exemplo n.º 15
0
/*
 * Function:
 *	AllocNewPiece
 *
 * Parameters:
 *	src - AsciiSrc Widget
 *	prev - piece just before this one, or NULL
 *
 * Description:
 *	Allocates a new piece of memory.
 *
 * Returns:
 *	The allocated piece
 */
static Piece *
AllocNewPiece(AsciiSrcObject src, Piece *prev)
{
    Piece *piece = XtNew(Piece);

    if (prev == NULL) {
	src->ascii_src.first_piece = piece;
	piece->next = NULL;
    }
    else  {
	if (prev->next != NULL)
	    (prev->next)->prev = piece;
	piece->next = prev->next;
	prev->next = piece;
    }

    piece->prev = prev;

    return (piece);
}
Exemplo n.º 16
0
XtBlockHookId XtAppAddBlockHook(
    XtAppContext app,
    XtBlockHookProc proc,
    XtPointer closure)
{
    BlockHook hook = XtNew(BlockHookRec);
    LOCK_APP(app);
    hook->next = app->block_hook_list;
    hook->app = app;
    hook->proc = proc;
    hook->closure = closure;
    if (app->block_hook_list == NULL) {
	_XtAddCallback( &app->destroy_callbacks,
		        FreeBlockHookList,
		        (XtPointer)&app->block_hook_list
		      );
    }
    app->block_hook_list = hook;
    UNLOCK_APP(app);
    return (XtBlockHookId)hook;
}
Exemplo n.º 17
0
XtPointer PLUGIN_imseq_getim( int n , int type , XtPointer handle )
{
   PLUGIN_impopper * imp = (PLUGIN_impopper *) handle ;

   if( imp == NULL ) return(NULL) ;

   /*--- control info ---*/

   if( type == isqCR_getstatus ){
      MCW_imseq_status * stat = XtNew( MCW_imseq_status ) ;
      stat->num_total  = 1 ;
      stat->num_series = 1 ;
      stat->send_CB    = PLUGIN_seq_send_CB ;
      stat->parent     = (XtPointer) imp  ;
      stat->aux        = NULL ;

      stat->transforms0D = NULL ;
      stat->transforms2D = NULL ;
      stat->slice_proj   = NULL ;

      return((XtPointer) stat) ;
   }

   /*--- no overlay ---*/

   if( type == isqCR_getoverlay ) return(NULL) ;

   /*--- return a copy of the image
         (since the imseq will delete it when it is done) ---*/

   if( type == isqCR_getimage || type == isqCR_getqimage ){
      MRI_IMAGE * im = NULL ;
      if( imp->im != NULL ) im = mri_to_mri( imp->im->kind , imp->im ) ;
      return((XtPointer) im) ;
   }

   return(NULL) ;  /* should not occur, but who knows? */
}
Exemplo n.º 18
0
static Boolean
SendSel(Widget w, Atom *sel, Atom *target, Atom *rtype, XtPointer *ans,
		unsigned long *anslen, int *ansfmt)
{
	GwinWidget gw = (GwinWidget)w;
	static Atom targets = 0;
	XrmValue src, dst;
	char *s;

	if(*target == XA_STRING){
		s = gw->gwin.selection;
		if(!s)
			s = "";
		*rtype = XA_STRING;
		*ans = (XtPointer) XtNewString(s);
		*anslen = strlen(*ans);
		*ansfmt = 8;
		return TRUE;
	}
#ifndef R3
	if(targets == 0){
		src.addr = "TARGETS";
		src.size = strlen(src.addr)+1;
		dst.size = sizeof(Atom);
		dst.addr = (XtPointer) &targets;
		XtConvertAndStore(w, XtRString, &src, XtRAtom, &dst);
	}
	if(*target == targets){
		*rtype = XA_ATOM;
		*ans = (XtPointer) XtNew(Atom);
		*(Atom*) *ans = XA_STRING;
		*anslen = 1;
		*ansfmt = 32;
		return TRUE;
	}
#endif
	return FALSE;
}
Exemplo n.º 19
0
static void
XawVendorShellClassPartInit(WidgetClass cclass)
{
    CompositeClassExtension ext;
    VendorShellWidgetClass vsclass = (VendorShellWidgetClass)cclass;

    if ((ext = (CompositeClassExtension) 
	    XtGetClassExtension (cclass,
				 XtOffsetOf(CompositeClassRec, 
					    composite_class.extension),
				 NULLQUARK, 1L, (Cardinal) 0)) == NULL) {
	ext = (CompositeClassExtension) XtNew (CompositeClassExtensionRec);
	if (ext != NULL) {
	    ext->next_extension = vsclass->composite_class.extension;
	    ext->record_type = NULLQUARK;
	    ext->version = XtCompositeExtensionVersion;
	    ext->record_size = sizeof (CompositeClassExtensionRec);
	    ext->accepts_objects = TRUE;
	    ext->allows_change_managed_set = FALSE;
	    vsclass->composite_class.extension = (XtPointer) ext;
	}
    }
}
Exemplo n.º 20
0
Arquivo: bbox.c Projeto: aosm/X11
ButtonBox BBoxCreate(
    Scrn	scrn,
    char	*name)	/* name of the buttonbox widgets */
{
    Cardinal	n;
    ButtonBox	buttonbox = XtNew(ButtonBoxRec);
    Arg		args[5];

    n = 0;
    XtSetArg(args[n], XtNallowVert, True);	n++;
    XtSetArg(args[n], XtNskipAdjust, True);	n++;
    
    buttonbox->outer =
	XtCreateManagedWidget(name, viewportWidgetClass, scrn->widget,
			      args, n);
    buttonbox->inner =
	XtCreateManagedWidget(name, boxWidgetClass, buttonbox->outer,
			      args, (Cardinal) 0);
    buttonbox->numbuttons = 0;
    buttonbox->button = (Button *) NULL;
    buttonbox->scrn = scrn;
    return buttonbox;
}
Exemplo n.º 21
0
/*-------------------------------------------------------------------------*/
static void RegisterDerivedConstructor(
String parent_name, 
String name,
XmtWidgetConstructor constructor 
) {
   XmtWidgetType *parent_type;
   XmtWidgetType *type;

   parent_type = XmtLookupWidgetType(parent_name);

   if (!parent_type)
      return;

   type = XtNew(XmtWidgetType);  /* never free'd */
   type->name = name;
   type->wclass = NULL;
   type->constructor = constructor;
   type->set_value_proc = parent_type->set_value_proc;
   type->get_value_proc = parent_type->get_value_proc;
   type->popup = parent_type->popup;

   XmtRegisterWidgetTypes(type, 1);

}
Exemplo n.º 22
0
static XawTextProperty *
_XawTextSinkAddProperty(XawTextPropertyList *list, XawTextProperty *property,
			Bool replace)
{
    XawTextProperty *result;
    XColor color;
    char identifier[1024];
    char foreground[16];
    char background[16];
    char *foundry, *family, *weight, *slant, *setwidth, *addstyle, *pixel_size,
	 *point_size, *res_x, *res_y, *spacing, *avgwidth, *registry, *encoding;
    char *xlfd;
    static char *asterisk = "*", *null = "";
    XrmQuark quark;

    if (list == NULL || property == NULL)
	return (NULL);

    if (property->mask & XAW_TPROP_FOREGROUND) {
	color.pixel = property->foreground;
	XQueryColor(DisplayOfScreen(list->screen), list->colormap, &color);
	XmuSnprintf(foreground, sizeof(foreground), "%04x%04x%04x",
		    color.red, color.green, color.blue);
    }
    else
	strcpy(foreground, asterisk);
    if (property->mask & XAW_TPROP_BACKGROUND) {
	color.pixel = property->background;
	XQueryColor(DisplayOfScreen(list->screen), list->colormap, &color);
	XmuSnprintf(background, sizeof(background), "%04x%04x%04x",
		    color.red, color.green, color.blue);
    }
    else
	strcpy(background, asterisk);

    if (property->xlfd_mask & XAW_TPROP_FOUNDRY)
	foundry = XrmQuarkToString(property->foundry);
    else
	foundry = asterisk;

    /* use default, or what was requested */
    if (property->family != NULLQUARK)
	family = XrmQuarkToString(property->family);
    else
	family = asterisk;
    if (property->weight != NULLQUARK)
	weight = XrmQuarkToString(property->weight);
    else
	weight = asterisk;
    if (property->slant != NULLQUARK) {
	slant = XrmQuarkToString(property->slant);
	if (toupper(*slant) != 'R')
	    slant = asterisk;	/* X defaults to italics, so, don't
				   care in resolving between `I' and `O' */
    }
    else
	slant = asterisk;

    if (property->xlfd_mask & XAW_TPROP_SETWIDTH)
	setwidth = XrmQuarkToString(property->setwidth);
    else
	setwidth = asterisk;
    if (property->xlfd_mask & XAW_TPROP_ADDSTYLE)
	addstyle = XrmQuarkToString(property->addstyle);
    else
	addstyle = null;

    /* use default, or what was requested */
    if (!(property->mask & XAW_TPROP_POINTSIZE) &&
	property->pixel_size != NULLQUARK)
	pixel_size = XrmQuarkToString(property->pixel_size);
    else
	pixel_size = asterisk;

    if (property->xlfd_mask & XAW_TPROP_POINTSIZE)
	point_size = XrmQuarkToString(property->point_size);
    else
	point_size = asterisk;
    if (property->xlfd_mask & XAW_TPROP_RESX)
	res_x = XrmQuarkToString(property->res_x);
    else
	res_x = asterisk;
    if (property->xlfd_mask & XAW_TPROP_RESY)
	res_y = XrmQuarkToString(property->res_y);
    else
	res_y = asterisk;
    if (property->xlfd_mask & XAW_TPROP_SPACING)
	spacing = XrmQuarkToString(property->spacing);
    else
	spacing = asterisk;
    if (property->xlfd_mask & XAW_TPROP_AVGWIDTH)
	avgwidth = XrmQuarkToString(property->avgwidth);
    else
	avgwidth = asterisk;

    /* use default, or what that was requested */
    if (property->registry != NULLQUARK)
	registry = XrmQuarkToString(property->registry);
    else
	registry = asterisk;
    if (property->encoding != NULLQUARK)
	encoding = XrmQuarkToString(property->encoding);
    else
	encoding = asterisk;

    if (replace) {
	result = XtNew(XawTextProperty);
	memcpy(result, property, sizeof(XawTextProperty));
    }
    else
	result = property;

    /* XXX should do the best to load a suitable font here */
    if (!(result->mask & XAW_TPROP_FONT)) {
	XmuSnprintf(identifier, sizeof(identifier),
		    "-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s",
		    foundry, family, weight, slant, setwidth, addstyle, pixel_size,
		    point_size, res_x, res_y, spacing, avgwidth, registry, encoding);
	if ((result->font = XLoadQueryFont(DisplayOfScreen(list->screen),
					   identifier)) != NULL) {
	    result->mask |= XAW_TPROP_FONT;
	    SetXlfdDefaults(DisplayOfScreen(list->screen), result);
	}
	else
	    result->mask &= ~XAW_TPROP_FONT;
    }

    if (result->font)
	xlfd = XrmQuarkToString(result->xlfd);
    else
	xlfd = null;

    XmuSnprintf(identifier, sizeof(identifier), "%08lx%08lx%s%s%d%d%d%d%s",
		property->mask, property->xlfd_mask,
		foreground, background,
		(result->mask & XAW_TPROP_UNDERLINE) != 0,
		(result->mask & XAW_TPROP_OVERSTRIKE) != 0,
		(result->mask & XAW_TPROP_SUBSCRIPT) != 0,
		(result->mask & XAW_TPROP_SUPERSCRIPT) != 0,
		xlfd);

    quark = XrmStringToQuark(identifier);
    if (result->identifier == NULLQUARK)
	result->identifier = quark;
    result->code = quark;

    if ((property = _XawTextSinkGetProperty(list, result->identifier)) != NULL) {
	if (result->font)
	    XFreeFont(DisplayOfScreen(list->screen), result->font);
	if (replace)
	    XtFree((XtPointer)result);

	return (property);
    }

    list->properties = (XawTextProperty**)
	XtRealloc((XtPointer)list->properties, sizeof(XawTextProperty*) *
		  (list->num_properties + 1));
    list->properties[list->num_properties++] = result;
    qsort((void*)list->properties, list->num_properties,
	      sizeof(XawTextProperty*), qcmp_qident);

    return (result);
}
Exemplo n.º 23
0
XBR_IMAGE *XbrGfxGIF(Display *display, unsigned char *data, int size, int html,
                     XColor *backcol, char **errmsg)
{
    register unsigned char  ch, ch1;
    register unsigned char *ptr, *ptr1;
    register int   i;
    unsigned char *raster,	/* The raster data stream, unblocked */
                  *image;	/* The image data */
    int BitOffset = 0,		/* Bit Offset of next code */
    Prefix[4096],               /* Prefix table used for decoding */
    Suffix[4096],               /* Suffix table used for decoding */
    OutCode[1025],              /* Hash table used by the decompressor */
    OutCount = 0,		/* Decompressor output 'stack count' */
    RWidth, RHeight,		/* screen dimensions */
    LeftOfs, TopOfs,		/* image offset */
    BitsPerPixel,		/* Bits per pixel, read from GIF header */
    ColorMapSize,		/* number of colors */
    Background,			/* background color */
    Transparent = 0,		/* Transparent background? */
    TransparentColour,		/* The colour that is transparent. */
    CodeSize,			/* Code size, read from GIF header */
    InitCodeSize,		/* Starting code size, used during Clear */
    Code,			/* Value returned by XbrGfxReadCode */
    MaxCode,			/* limiting value for current code size */
    ClearCode,			/* GIF clear code */
    EOFCode,			/* GIF end-of-information code */
    CurCode, OldCode, InCode,	/* Decompressor variables */
    FirstFree,			/* First free code, generated per GIF spec */
    FreeCode,			/* Decompressor, next free slot in hash table */
    FinChar,			/* Decompressor variable */
    BitMask,			/* AND mask for data size */
    ReadMask,			/* Code AND mask for current code size */
    DispCells,			/* Number of display cells */
    screen;                     /* Default screen of display */
    Colormap colormap;          /* The colour map the get colours from */
    XImage *theImage;		/* The image to build up */
    Visual *theVisual;          /* Screen visual type */
    XBR_IMAGE *retval;
    GC gc;

    DispCells = DisplayCells(display, DefaultScreen(display));
    colormap = DefaultColormap(display, DefaultScreen(display));
    theVisual = DefaultVisual(display, DefaultScreen(display));
    screen = DefaultScreen(display);

    XC = 0, YC = 0; Pass = 0; alloc = 0;

    /* Allocate memory for raster data */
    if((raster = (unsigned char *) malloc(size)) == NULL) {
        if(errmsg) *errmsg = "Out of memory!";
        return(NULL);
    }

    ptr = data;

    if(strncmp((char *)ptr, "GIF87a", 6) && strncmp((char *)ptr, "GIF89a", 6)) {
        if(errmsg) *errmsg = "Not a GIF image!";
        return(NULL);
    }
    ptr += 6;

    /* Get variables from the GIF screen descriptor */
    ch = NEXTBYTE;
    RWidth = ch + 0x100 * NEXTBYTE;
    ch = NEXTBYTE;
    RHeight = ch + 0x100 * NEXTBYTE;

    ch = NEXTBYTE;
    HasColormap = ((ch & COLORMAPMASK) ? True : False);

    BitsPerPixel = (ch & 7) + 1;
    numcols = ColorMapSize = 1 << BitsPerPixel;
    BitMask = ColorMapSize - 1;

    Background = NEXTBYTE;

    /* Supposed to be NULL */
    if(NEXTBYTE) {
        if(errmsg) *errmsg = "GIF image corrupt!";
        return(NULL);
    }

    /* Read in global colormap. */
    if(HasColormap) {
	for (i = 0; i < ColorMapSize; i++) {
	    Red[i] = NEXTBYTE;
	    Green[i] = NEXTBYTE;
	    Blue[i] = NEXTBYTE;
            used[i] = 0;
	}
        numused = 0;
    }
    else {
        if(!numcols) numcols=256;
        for (i=0; i<numcols; i++)
            cols[i] = (unsigned long) i;
    }

    /* Chomp extensions. */
    while((ch = NEXTBYTE) == GIF_EXTENSION) {
        if(NEXTBYTE == GIF_GFXBLOCK) {
	    ch = NEXTBYTE;	/* Block size */
	    Transparent = ((NEXTBYTE & GIF_TRANSMASK) ? True : False);
	    ptr += 2;
	    TransparentColour = NEXTBYTE;
	    ch = NEXTBYTE;
	} else {
	    ch = NEXTBYTE;
	    ptr += ch;
	    while((ch = NEXTBYTE) != GIF_BLOCKEND)
		ptr += ch;
	}
    }
    
    /* Check for image seperator */
    if (ch != IMAGESEP) {
        if(errmsg) *errmsg = "Corrupt GIF file: *no image separator*";
        return(NULL);
    }

    /* Now read in values from the image descriptor */
    ch = NEXTBYTE;
    LeftOfs = ch + 0x100 * NEXTBYTE;
    ch = NEXTBYTE;
    TopOfs = ch + 0x100 * NEXTBYTE;
    ch = NEXTBYTE;
    Width = ch + 0x100 * NEXTBYTE;
    ch = NEXTBYTE;
    Height = ch + 0x100 * NEXTBYTE;
    Interlace = ((NEXTBYTE & INTERLACEMASK) ? True : False);

/*
    xbrimage_resize(Width, Height);
    xbrimage_dimensions(Width, Height);
*/

    /* Note that I ignore the possible existence of a local color map.
     * I'm told there aren't many files around that use them, and the spec
     * says it's defined for future use.  This could lead to an error
     * reading some files. 
     */

    /* Start reading the raster data. First we get the intial code size
     * and compute decompressor constant values, based on this code size.
     */
    CodeSize = NEXTBYTE;
    ClearCode = (1 << CodeSize);
    EOFCode = ClearCode + 1;
    FreeCode = FirstFree = ClearCode + 2;

    /* The GIF spec has it that the code size is the code size used to
     * compute the above values is the code size given in the file, but the
     * code size used in compression/decompression is the code size given in
     * the file plus one. (thus the ++).
     */
    CodeSize++;
    InitCodeSize = CodeSize;
    MaxCode = (1 << CodeSize);
    ReadMask = MaxCode - 1;

    /* Read the raster data.  Here we just transpose it from the GIF array
     * to the raster array, turning it from a series of blocks into one long
     * data stream, which makes life much easier for XbrGfxReadCode().
     */
    ptr1 = raster;
    do {
	ch = ch1 = NEXTBYTE;
	while (ch--) *ptr1++ = NEXTBYTE;
	if ((raster - ptr1) > size) {
	    if(errmsg) *errmsg = "Corrupt GIF file\n*unblock*";
            return(NULL);
        }
    } while(ch1);


    /* Allocate the X image */
    image = (unsigned char *) malloc(Width*Height);
    if (image == NULL) {
        if(errmsg) *errmsg = "Not enough memory for Ximage!";
        return(NULL);
    }
    if(!html) {
        theImage = XCreateImage(display,theVisual,8,ZPixmap,0,(char *)image,
          Width, Height,8,Width);

        if(theImage == NULL) {
            if(errmsg) *errmsg = "Unable to create Ximage!";
             return(NULL);
       }
    }

    BytesPerScanline = Width;

    /* Decompress the file, continuing until you see the GIF EOF code.
       One obvious enhancement is to add checking for corrupt files here.
    */
    Code = XbrGfxReadCode(&BitOffset, raster, CodeSize, ReadMask);
    while (Code != EOFCode) {

        /* Clear code sets everything back to its initial value, then reads the
          immediately subsequent code as uncompressed data.
        */
	if (Code == ClearCode) {
	    CodeSize = InitCodeSize;
	    MaxCode = (1 << CodeSize);
	    ReadMask = MaxCode - 1;
	    FreeCode = FirstFree;
	    CurCode = OldCode = Code = XbrGfxReadCode(&BitOffset, raster,
              CodeSize, ReadMask);
	    FinChar = CurCode & BitMask;
	    XbrGfxAddtoPixel(FinChar, image);
	}
	else {

            /* If not a clear code, then must be data:save same as CurCode and
               InCode
            */
	    CurCode = InCode = Code;

            /* If greater or equal to FreeCode, not in the hash table yet;
               repeat the last character decoded
            */
	    if (CurCode >= FreeCode) {
		CurCode = OldCode;
		OutCode[OutCount++] = FinChar;
	    }

            /* Unless this code is raw data, pursue the chain pointed to by
              CurCode through the hash table to its end; each code in the chain
              puts its associated output code on the output queue.
            */
	    while (CurCode > BitMask) {
		if (OutCount > 1024) {
		    if(errmsg) *errmsg = "Corrupt GIF file!*OutCount*";
                    if(!html) XDestroyImage(theImage);
                    theImage = NULL;
                    return(NULL);
                    }
		OutCode[OutCount++] = Suffix[CurCode];
		CurCode = Prefix[CurCode];
	    }

            /* The last code in the chain is treated as raw data. */
	    FinChar = CurCode & BitMask;
	    OutCode[OutCount++] = FinChar;

            /* Now we put the data out to the Output routine.
               It's been stacked LIFO, so deal with it that way...
            */
            for (i = OutCount - 1; i >= 0; i--)
		XbrGfxAddtoPixel(OutCode[i], image);
	    OutCount = 0;

            /* Build the hash table on-the-fly. No table is stored in the
               file.
            */
	    Prefix[FreeCode] = OldCode;
	    Suffix[FreeCode] = FinChar;
	    OldCode = InCode;

            /* Point to the next slot in the table.  If we exceed the current
               MaxCode value, increment the code size unless it's already 12.
               If it is, do nothing: the next code decompressed better be CLEAR
            */
	    FreeCode++;
	    if (FreeCode >= MaxCode) {
		if (CodeSize < 12) {
		    CodeSize++;
		    MaxCode *= 2;
		    ReadMask = (1 << CodeSize) - 1;
		}
	    }
	}
	Code = XbrGfxReadCode(&BitOffset, raster, CodeSize, ReadMask);
    }

    free(raster);
/*
    xbrimage_colours(numused, ColorMapSize);
*/

    retval = XtNew(XBR_IMAGE);
    retval->size = size;
    retval->width = Width;
    retval->height = Height;
    retval->data = (char *)data;

    if(html) {
        retval->pixmap = (Pixmap)NULL;
        retval->num_colors = numcols;
        retval->reds = (int *) XtMalloc(sizeof(int)*numcols);
        retval->greens = (int *) XtMalloc(sizeof(int)*numcols);
        retval->blues = (int *) XtMalloc(sizeof(int)*numcols);
        for(i = 0; i < numcols; i++) {
            retval->reds[i] = Red[i] << 8;
            retval->greens[i] = Green[i] << 8;
            retval->blues[i] = Blue[i] << 8;
        }
	if(Transparent) {
	    retval->reds[TransparentColour] = backcol->red;
	    retval->greens[TransparentColour] = backcol->green;
	    retval->blues[TransparentColour] = backcol->blue;
	}
        retval->image_data = image;
        retval->npixels = 0;
    } else {
        retval->pixmap = XCreatePixmap(display, DefaultRootWindow(display),
          Width, Height, DefaultDepth(display, screen));
        retval->num_colors = numcols;
        retval->reds = NULL;
        retval->greens = NULL;
        retval->blues = NULL;
        retval->image_data = NULL;
        if(!XbrGfxGetColours(display, colormap,DispCells, image,backcol,Transparent,TransparentColour)) {
            if(errmsg) *errmsg = "Error allocating colours!";
            XDestroyImage(theImage);
            theImage = NULL;
            return(NULL);
        }

        for(i = 0; i < alloc; i++) {
            retval->pixels[i] = alloced[i];
        }
        retval->npixels = alloc-1;

        gc = XCreateGC(display, retval->pixmap,  0, NULL);
        XPutImage(display, retval->pixmap, gc, theImage, 0, 0, 0, 0, Width,
          Height);
        XFreeGC(display, gc);
        XDestroyImage(theImage);
    }

    theImage = NULL;

    return(retval);
}
Exemplo n.º 24
0
/*
 * Implementation
 */
XtPointer
ScreenConfig(XtPointer conf)
{
    XF86ConfDisplayPtr disp;
    Arg args[2];
    int i, oldrotate;

    screen = (XF86ConfScreenPtr)conf;
    if (screen == NULL)
	return (NULL);

    XtSetArg(args[0], XtNstring, screen->scrn_identifier);
    XtSetValues(ident_widget, args, 1);
    if ((default_depth = screen->scrn_defaultdepth) <= 0)
	default_depth = 8;
    sel_index = unsel_index = -1;
    for (i = 0; i < computer.num_screens; i++)
	if (computer.screens[i]->screen == screen) {
	    SetScreenRotate(computer.screens[i]);
	    rotate = computer.screens[i]->rotate;
    }
    oldrotate = rotate;

    ndefmodes = 0;
    disp = screen->scrn_display_lst;
    while (disp != NULL) {
	if (disp->disp_depth == default_depth) {
	    XF86ModePtr mod = disp->disp_mode_lst;

	    while (mod != NULL) {
		if (ndefmodes % 16 == 0)
		    defmodes = (char**)
			XtRealloc((XtPointer)defmodes,
				  (ndefmodes + 16) * sizeof(char*));
		defmodes[ndefmodes++] = XtNewString(mod->mode_name);
		mod = (XF86ModePtr)(mod->list.next);
	    }
	    break;
	}
	disp = (XF86ConfDisplayPtr)(disp->list.next);
    }
    if (ndefmodes == 0) {
	defmodes = (char**)XtMalloc(sizeof(char*));
	defmodes[0] = XtNewString("640x480");
	ndefmodes = 1;
    }

    if (listL != NULL) {
	XawListUnhighlight(listL);
	XawListUnhighlight(listR);
    }

    xf86info.cur_list = SCREEN;
    XtSetSensitive(back, xf86info.lists[SCREEN].cur_function > 0);
    XtSetSensitive(next, xf86info.lists[SCREEN].cur_function <
			 xf86info.lists[SCREEN].num_functions - 1);
    (xf86info.lists[SCREEN].functions[xf86info.lists[SCREEN].cur_function])
	(&xf86info);

    if (ConfigLoop(NULL) == True) {
	XF86ModePtr prev = NULL, mod;

	/* user may have changed the default depth, read variables again */
	disp = screen->scrn_display_lst;
	while (disp != NULL) {
	    if (disp->disp_depth == default_depth)
		break;
	    disp = (XF86ConfDisplayPtr)(disp->list.next);
	}

	if (disp == NULL) {
	    disp = (XF86ConfDisplayPtr)XtCalloc(1, sizeof(XF86ConfDisplayRec));
	    screen->scrn_display_lst = (XF86ConfDisplayPtr)
		xf86addListItem((GenericListPtr)(screen->scrn_display_lst),
			    (GenericListPtr)(disp));
	    disp->disp_depth = default_depth;
	}

	if (strcasecmp(screen->scrn_identifier, ident_string))
	    xf86renameScreen(XF86Config, screen, ident_string);

	screen->scrn_defaultdepth = default_depth;

	XtSetArg(args[0], XtNlist, NULL);
	XtSetArg(args[1], XtNnumberStrings, 0);
	XtSetValues(listL, args, 2);

	XtSetArg(args[0], XtNlist, NULL);
	XtSetArg(args[1], XtNnumberStrings, 0);
	XtSetValues(listR, args, 2);

	mod = disp->disp_mode_lst;
	/* free all modes */
	while (mod != NULL) {
	    prev = mod;
	    mod = (XF86ModePtr)(mod->list.next);
	    XtFree(prev->mode_name);
	    XtFree((XtPointer)prev);
	}
	/* readd modes */
	for (i = 0; i < ndefmodes; i++) {
	    mod = XtNew(XF86ModeRec);
	    mod->mode_name = XtNewString(defmodes[i]);
	    XtFree(defmodes[i]);
	    if (i == 0)
		disp->disp_mode_lst = mod;
	    else
		prev->list.next = mod;
	    prev = mod;
	}
	if (i == 0)
	    disp->disp_mode_lst = NULL;
	else
	    mod->list.next = NULL;

	XtFree((XtPointer)defmodes);
	defmodes = NULL;
	ndefmodes = 0;

	for (i = 0; i < computer.num_screens; i++)
	    if (computer.screens[i]->screen == screen)
		computer.screens[i]->rotate = rotate;

	if (oldrotate != rotate) {
	    static char *Rotate = "Rotate";

	    if (screen->scrn_option_lst != NULL)
		xf86removeOption(&screen->scrn_option_lst, Rotate);
	    if (rotate)
		screen->scrn_option_lst =
		    xf86addNewOption(screen->scrn_option_lst,
				     XtNewString(Rotate),
				     XtNewString(rotate > 0 ? "CW" : "CCW"));
	    UpdateScreenUI();
	    AdjustScreenUI();
	}

	return ((XtPointer)screen);
    }

    XtSetArg(args[0], XtNlist, NULL);
    XtSetArg(args[1], XtNnumberStrings, 0);
    XtSetValues(listL, args, 2);

    XtSetArg(args[0], XtNlist, NULL);
    XtSetArg(args[1], XtNnumberStrings, 0);
    XtSetValues(listR, args, 2);

    for (i = 0; i < ndefmodes; i++)
	XtFree(defmodes[i]);
    XtFree((XtPointer)defmodes);
    defmodes = NULL;
    ndefmodes = 0;

    return (NULL);
}
Exemplo n.º 25
0
/*ARGSUSED*/
XtPointer
MouseConfig(XtPointer config)
{
    XF86ConfInputPtr mouse = (XF86ConfInputPtr)config;
    XF86OptionPtr option;
    char mouse_name[32];
    Arg args[1];

    static char *Device = "Device", *Protocol = "Protocol",
		*Emulate3Buttons = "Emulate3Buttons",
		*Emulate3Timeout = "Emulate3Timeout";

    current_input = mouse;

    if (mouse != NULL) {
	emulate = xf86findOption(mouse->inp_option_lst,
				 Emulate3Buttons) != NULL;
	if ((option = xf86findOption(mouse->inp_option_lst, Device)) != NULL)
	    device = option->opt_val;
	else
	    device = NULL;
	if ((option = xf86findOption(mouse->inp_option_lst, Protocol)) != NULL)
	    protocol = option->opt_val;
	else
	    protocol = NULL;

	XtSetArg(args[0], XtNstring, mouse->inp_identifier);
	XtSetValues(ident_widget, args, 1);
    }
    else {
	XF86ConfInputPtr input = XF86Config->conf_input_lst;
	int nmouses = 0;

	while (input != NULL) {
	    if (strcasecmp(input->inp_driver, "mouse") == 0)
		++nmouses;
	    input = (XF86ConfInputPtr)(input->list.next);
	}
	do {
	    XmuSnprintf(mouse_name, sizeof(mouse_name), "Mouse%d", nmouses);
	    ++nmouses;
	} while (xf86findInput(mouse_name,
		 XF86Config->conf_input_lst));

	XtSetArg(args[0], XtNstring, mouse_name);
	XtSetValues(ident_widget, args, 1);

	emulate = True;
	device = NULL;
	protocol = NULL;
    }

    xf86info.cur_list = MOUSE;
    XtSetSensitive(back, xf86info.lists[MOUSE].cur_function > 0);
    XtSetSensitive(next, xf86info.lists[MOUSE].cur_function <
			 xf86info.lists[MOUSE].num_functions - 1);
    (xf86info.lists[MOUSE].functions[xf86info.lists[MOUSE].cur_function])
	(&xf86info);

    if (ConfigLoop(MouseConfigCheck) == True) {
	XtSetArg(args[0], XtNstring, &device);
	XtGetValues(text, args, 1);
	if (mouse == NULL) {
	    mouse = XtNew(XF86ConfInputRec);
	    mouse->list.next = NULL;
	    mouse->inp_identifier = XtNewString(ident_string);
	    mouse->inp_driver = XtNewString("mouse");
	    mouse->inp_option_lst = xf86newOption(XtNewString(Device),
						  XtNewString(device));
	    xf86addNewOption(mouse->inp_option_lst,
			     XtNewString(Protocol), XtNewString(protocol));
	    if (emulate) {
		xf86addNewOption(mouse->inp_option_lst,
			         XtNewString(Emulate3Buttons), NULL);
		xf86addNewOption(mouse->inp_option_lst,
			         XtNewString(Emulate3Timeout),
				 XtNewString("50"));
	    }
	    mouse->inp_comment = NULL;
	}
	else {
	    if ((option = xf86findOption(mouse->inp_option_lst, Device)) != NULL) {
		XtFree(option->opt_val);
		option->opt_val = XtNewString(device);
		XtFree(option->opt_comment);
	    }
	    else {
		if (mouse->inp_option_lst == NULL)
		    mouse->inp_option_lst = xf86newOption(XtNewString(Device),
							  XtNewString(device));
		else
		    xf86addNewOption(mouse->inp_option_lst,
				     XtNewString(Device), XtNewString(device));
	    }

	    if ((option = xf86findOption(mouse->inp_option_lst, Protocol)) != NULL) {
		XtFree(option->opt_val);
		option->opt_val = XtNewString(protocol);
		XtFree(option->opt_comment);
	    }
	    else
		xf86addNewOption(mouse->inp_option_lst,
				 XtNewString(Protocol), XtNewString(protocol));

	    if (emulate == False) {
		xf86removeOption(&(mouse->inp_option_lst), Emulate3Buttons);
		xf86removeOption(&(mouse->inp_option_lst), Emulate3Timeout);
	    }
	    else if (emulate) {
		xf86addNewOption(mouse->inp_option_lst,
				 XtNewString(Emulate3Buttons), NULL);
		xf86addNewOption(mouse->inp_option_lst,
				 XtNewString(Emulate3Timeout), XtNewString("50"));
	    }
	}
	if (strcasecmp(mouse->inp_identifier, ident_string))
	    xf86renameInput(XF86Config, mouse, ident_string);

	return ((XtPointer)mouse);
    }

    return (NULL);
}
Exemplo n.º 26
0
/* ARGSUSED */
static void 
DisplayInitialize(
        Widget requested_widget,
        Widget new_widget,
        ArgList args,
        Cardinal *num_args )
{
    XmDisplay	xmDisplay = (XmDisplay)new_widget;
    int		dummy1, dummy2;
    XContext 	context;

    xmDisplay->display.shellCount = 0;

    xmDisplay->display.numModals = 0;
    xmDisplay->display.modals = NULL;
    xmDisplay->display.maxModals = 0;
    xmDisplay->display.userGrabbed = False;
    xmDisplay->display.activeDC = NULL;
    xmDisplay->display.dsm = (XmDropSiteManagerObject) NULL;

    xmDisplay->display.proxyWindow =
      _XmGetDragProxyWindow(XtDisplay(xmDisplay));

    _XmInitByteOrderChar();
    xmDisplay->display.xmim_info = NULL;

    xmDisplay->display.displayInfo = (XtPointer) XtNew(XmDisplayInfo);
    ((XmDisplayInfo *)(xmDisplay->display.displayInfo))->SashCursor = 0L;
    ((XmDisplayInfo *)(xmDisplay->display.displayInfo))->TearOffCursor = 0L;
    ((XmDisplayInfo *)(xmDisplay->display.displayInfo))->UniqueStamp = 0L;
    ((XmDisplayInfo *)(xmDisplay->display.displayInfo))->destinationWidget= 
	(Widget)NULL;
    ((XmDisplayInfo *)(xmDisplay->display.displayInfo))->excParentPane.pane =
	(Widget *)NULL;
    ((XmDisplayInfo *)(xmDisplay->display.displayInfo))->excParentPane.pane_list_size = 0;
    ((XmDisplayInfo *)(xmDisplay->display.displayInfo))->excParentPane.num_panes= 0;
    ((XmDisplayInfo *)(xmDisplay->display.displayInfo))->resetFocusFlag = 0;
    ((XmDisplayInfo *)(xmDisplay->display.displayInfo))->traversal_in_progress=
	FALSE;

    xmDisplay->display.displayHasShapeExtension = 
      XShapeQueryExtension(XtDisplay(xmDisplay), &dummy1, &dummy2);

    /* Handle dynamic default of receiver protocol style */
    if (xmDisplay->display.dragReceiverProtocolStyle == 
	INVALID_PROTOCOL_VALUE) {
      if (xmDisplay->display.displayHasShapeExtension)
	xmDisplay->display.dragReceiverProtocolStyle = XmDRAG_PREFER_DYNAMIC;
      else
	xmDisplay->display.dragReceiverProtocolStyle =
	  XmDRAG_PREFER_PREREGISTER;
    }

    _XmVirtKeysInitialize (new_widget);

/* Solaris 2.6 Motif diff bug #4085003 4 lines */
#ifdef SUN_MOTIF
    _XmGetKPKeysymToKeycodeList(new_widget);
    _XmGetModifierMapping(new_widget);
#endif /* SUN_MOTIF */

    _XmProcessLock();
    if (displayContext == 0)
      displayContext = XUniqueContext();
    context = displayContext;
    _XmProcessUnlock();
	
	if (! XFindContext(XtDisplay(xmDisplay), None, context,
		(char **) &xmDisplay))
	{
		/*
		 * There's one already created for this display.
		 * What should we do?  If we destroy the previous one, we may
		 * wreak havoc with shell modality and screen objects.  BUT,
		 * Xt doesn't really give us a way to abort a create.  We'll
		 * just let the new one dangle.
		 */

		XmeWarning((Widget) xmDisplay, MESSAGE1);
	}
	else
	{
		XSaveContext(XtDisplayOfObject((Widget)xmDisplay),
			 None,
			 context,
			 (char *)xmDisplay);
	}

    if (xmDisplay->display.enable_multi_key_bindings) {
	Display * display = XtDisplay(new_widget);
	int i, num_screens = ScreenCount(display);
	XrmDatabase new_db;

	for (i = 0; i < num_screens; i++)  {
	    Screen * screen = ScreenOfDisplay(display, i);
	    XrmDatabase db = XtScreenDatabase(screen);
	    new_db = XrmGetStringDatabase(_XmDisplay_baseTranslations);
	    XrmCombineDatabase(new_db, &db, False);
	}
    }
}