Beispiel #1
0
static Status
_XkbReadGeomProperties(XkbReadBufferPtr buf,
                       XkbGeometryPtr geom,
                       xkbGetGeometryReply *rep)
{
    Status rtrn;

    if (rep->nProperties < 1)
        return Success;
    if ((rtrn = XkbAllocGeomProps(geom, rep->nProperties)) == Success) {
        register int i;
        register Bool ok = True;

        for (i = 0; (i < rep->nProperties) && ok; i++) {
            char *name = NULL;
            char *value = NULL;
            ok = _XkbGetReadBufferCountedString(buf, &name) && ok;
            ok = _XkbGetReadBufferCountedString(buf, &value) && ok;
            ok = ok && (XkbAddGeomProperty(geom, name, value) != NULL);
            if (name)
                _XkbFree(name);
            if (value)
                _XkbFree(value);
        }
        if (ok)
            rtrn = Success;
        else
            rtrn = BadLength;
    }
    return rtrn;
}
Beispiel #2
0
static Status
_XkbReadGeomDoodad(	XkbReadBufferPtr 	buf,
			XkbGeometryPtr 		geom,
			XkbSectionPtr 		section)
{
XkbDoodadPtr		doodad;
xkbDoodadWireDesc *	doodadWire;

    doodadWire= (xkbDoodadWireDesc *)
		   _XkbGetReadBufferPtr(buf,SIZEOF(xkbDoodadWireDesc));
    if (!doodadWire)
	return 	BadLength;
    doodad= XkbAddGeomDoodad(geom,section,doodadWire->any.name);
    if (!doodad)
	return BadAlloc;
    doodad->any.type= doodadWire->any.type;
    doodad->any.priority= doodadWire->any.priority;
    doodad->any.top= doodadWire->any.top;
    doodad->any.left= doodadWire->any.left;
    doodad->any.angle= doodadWire->any.angle;
    switch (doodad->any.type) {
	case XkbOutlineDoodad:
	case XkbSolidDoodad:
	    doodad->shape.color_ndx= doodadWire->shape.colorNdx;
	    doodad->shape.shape_ndx= doodadWire->shape.shapeNdx;
	    break;
	case XkbTextDoodad:
	    doodad->text.width= doodadWire->text.width;
	    doodad->text.height= doodadWire->text.height;
	    doodad->text.color_ndx= doodadWire->text.colorNdx;
	    if (!_XkbGetReadBufferCountedString(buf,&doodad->text.text))
		return BadLength;
	    if (!_XkbGetReadBufferCountedString(buf,&doodad->text.font))
		return BadLength;
	    break;
	case XkbIndicatorDoodad:
	    doodad->indicator.shape_ndx= doodadWire->indicator.shapeNdx;
	    doodad->indicator.on_color_ndx= doodadWire->indicator.onColorNdx;
	    doodad->indicator.off_color_ndx= doodadWire->indicator.offColorNdx;
	    break;
	case XkbLogoDoodad:
	    doodad->logo.color_ndx= doodadWire->logo.colorNdx;
	    doodad->logo.shape_ndx= doodadWire->logo.shapeNdx;
	    if (!_XkbGetReadBufferCountedString(buf,&doodad->logo.logo_name))
		return BadLength;
	    break;
	default:
	    return BadValue;
    }
    return Success;
}
Beispiel #3
0
static Status
_XkbReadGeomColors(XkbReadBufferPtr buf,
                   XkbGeometryPtr geom,
                   xkbGetGeometryReply *rep)
{
    Status rtrn;

    if (rep->nColors < 1)
        return Success;
    if ((rtrn = XkbAllocGeomColors(geom, rep->nColors)) == Success) {
        register int i;

        for (i = 0; i < rep->nColors; i++) {
            char *spec = NULL;
            if (!_XkbGetReadBufferCountedString(buf, &spec))
                rtrn = BadLength;
            else if (XkbAddGeomColor(geom, spec, geom->num_colors) == NULL)
                rtrn = BadAlloc;
            if (spec)
                _XkbFree(spec);
            if (rtrn != Success)
                return rtrn;
        }
        return Success;
    }
    return rtrn;
}
Beispiel #4
0
Status
_XkbReadGetGeometryReply(	Display * dpy,
				xkbGetGeometryReply * rep,
				XkbDescPtr xkb,
				int * nread_rtrn)
{
XkbGeometryPtr	geom;

    geom= _XkbTypedCalloc(1,XkbGeometryRec);
    if (!geom)
	return BadAlloc;
    if (xkb->geom)
	XkbFreeGeometry(xkb->geom,XkbGeomAllMask,True);
    xkb->geom= geom;

    geom->name= rep->name;
    geom->width_mm= rep->widthMM;
    geom->height_mm= rep->heightMM;
    if (rep->length) {
	XkbReadBufferRec	buf;
	int			left;
	if (_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4)) {
	    Status status= Success;
	    if (nread_rtrn)
		*nread_rtrn= (int)rep->length*4;
	    if (!_XkbGetReadBufferCountedString(&buf,&geom->label_font))
		status= BadLength;
	    if (status==Success)
		status= _XkbReadGeomProperties(&buf,geom,rep);
	    if (status==Success)
		status= _XkbReadGeomColors(&buf,geom,rep);
	    if (status==Success)
		status= _XkbReadGeomShapes(&buf,geom,rep);
	    if (status==Success)
		status= _XkbReadGeomSections(&buf,geom,rep);
	    if (status==Success)
		status= _XkbReadGeomDoodads(&buf,geom,rep);
	    if (status==Success)
		status= _XkbReadGeomKeyAliases(&buf,geom,rep);
	    left= _XkbFreeReadBuffer(&buf);
	    if ((status!=Success) || left || buf.error) {
		if (status==Success)	
		    status= BadLength;
		XkbFreeGeometry(geom,XkbGeomAllMask,True);
		xkb->geom= NULL;
		return status;
	    }
	    geom->base_color= &geom->colors[rep->baseColorNdx];
	    geom->label_color= &geom->colors[rep->labelColorNdx];
	}
	else {
	    XkbFreeGeometry(geom,XkbGeomAllMask,True);
	    xkb->geom= NULL;
	    return BadAlloc;
	}
    }
    return Success;
}