XRRPropertyInfo *
XRRQueryProviderProperty (Display *dpy, RRProvider provider, Atom property)
{
    XExtDisplayInfo		*info = XRRFindDisplay(dpy);
    xRRQueryProviderPropertyReply rep;
    xRRQueryProviderPropertyReq	*req;
    unsigned int		rbytes, nbytes;
    XRRPropertyInfo		*prop_info;

    RRCheckExtension (dpy, info, NULL);

    LockDisplay (dpy);
    GetReq (RRQueryProviderProperty, req);
    req->reqType = info->codes->major_opcode;
    req->randrReqType = X_RRQueryProviderProperty;
    req->provider = provider;
    req->property = property;

    if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
	UnlockDisplay (dpy);
	SyncHandle ();
	return NULL;
    }

    if (rep.length < ((INT_MAX / sizeof(long)) - sizeof (XRRPropertyInfo))) {
        rbytes = sizeof (XRRPropertyInfo) + (rep.length * sizeof (long));
        nbytes = rep.length << 2;

        prop_info = Xmalloc (rbytes);
    } else
        prop_info = NULL;

    if (prop_info == NULL) {
	_XEatDataWords (dpy, rep.length);
	UnlockDisplay (dpy);
	SyncHandle ();
	return NULL;
    }

    prop_info->pending = rep.pending;
    prop_info->range = rep.range;
    prop_info->immutable = rep.immutable;
    prop_info->num_values = rep.length;
    if (rep.length != 0) {
	prop_info->values = (long *) (prop_info + 1);
	_XRead32 (dpy, prop_info->values, nbytes);
    } else {
	prop_info->values = NULL;
    }

    UnlockDisplay (dpy);
    SyncHandle ();
    return prop_info;
}
示例#2
0
XTimeCoord *XGetMotionEvents(
    register Display *dpy,
    Window w,
    Time start,
    Time stop,
    int *nEvents)  /* RETURN */
{
    xGetMotionEventsReply rep;
    register xGetMotionEventsReq *req;
    XTimeCoord *tc = NULL;
    LockDisplay(dpy);
    GetReq(GetMotionEvents, req);
    req->window = w;
/* XXX is this right for all machines? */
    req->start = start;
    req->stop  = stop;
    if (!_XReply (dpy, (xReply *)&rep, 0, xFalse)) {
	UnlockDisplay(dpy);
        SyncHandle();
	return (NULL);
	}

    if (rep.nEvents && (rep.nEvents < (INT_MAX / sizeof(XTimeCoord))))
	tc = Xmalloc(rep.nEvents * sizeof(XTimeCoord));
    if (tc == NULL) {
	/* server returned either no events or a bad event count */
	*nEvents = 0;
	_XEatDataWords (dpy, rep.length);
    }
    else
    {
	register XTimeCoord *tcptr;
	unsigned int i;
	xTimecoord xtc;

	*nEvents = (int) rep.nEvents;
	for (i = rep.nEvents, tcptr = tc; i > 0; i--, tcptr++) {
	    _XRead (dpy, (char *) &xtc, SIZEOF (xTimecoord));
	    tcptr->time = xtc.time;
	    tcptr->x    = cvtINT16toShort (xtc.x);
	    tcptr->y    = cvtINT16toShort (xtc.y);
	}
    }

    UnlockDisplay(dpy);
    SyncHandle();
    return (tc);
}
Atom *
XRRListProviderProperties (Display *dpy, RRProvider provider, int *nprop)
{
    XExtDisplayInfo		*info = XRRFindDisplay(dpy);
    xRRListProviderPropertiesReply rep;
    xRRListProviderPropertiesReq	*req;
    int				nbytes, rbytes;
    Atom			*props = NULL;

    RRCheckExtension (dpy, info, NULL);

    LockDisplay (dpy);
    GetReq (RRListProviderProperties, req);
    req->reqType = info->codes->major_opcode;
    req->randrReqType = X_RRListProviderProperties;
    req->provider = provider;

    if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
	UnlockDisplay (dpy);
	SyncHandle ();
	*nprop = 0;
	return NULL;
    }

    if (rep.nAtoms) {
	rbytes = rep.nAtoms * sizeof (Atom);
	nbytes = rep.nAtoms << 2;

	props = (Atom *) Xmalloc (rbytes);
	if (props == NULL) {
	    _XEatDataWords (dpy, rep.length);
	    UnlockDisplay (dpy);
	    SyncHandle ();
	    *nprop = 0;
	    return NULL;
	}

	_XRead32 (dpy, (long *) props, nbytes);
    }

    *nprop = rep.nAtoms;
    UnlockDisplay (dpy);
    SyncHandle ();
    return props;
}
示例#4
0
/*
 * XmbufGetWindowAttributes -
 * 	Gets the multibuffering attributes that apply to all buffers associated
 * 	with the given window.  Returns non-zero on success and zero if an
 * 	error occurs.
 */
Status XmbufGetWindowAttributes (
    Display *dpy,
    Window w,
    XmbufWindowAttributes *attr)
{
    XExtDisplayInfo *info = find_display (dpy);
    register xMbufGetMBufferAttributesReq *req;
    xMbufGetMBufferAttributesReply rep;

    MbufCheckExtension (dpy, info, 0);

    LockDisplay (dpy);
    MbufGetReq (MbufGetMBufferAttributes, req, info);
    req->window = w;
    if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
	UnlockDisplay (dpy);
	SyncHandle ();
	return 0;
    }
    attr->buffers = (Multibuffer *) NULL;
    if ((attr->nbuffers = rep.length)) {
	int nbytes = rep.length * sizeof(Multibuffer);
	attr->buffers = (Multibuffer *) Xmalloc((unsigned) nbytes);
	nbytes = rep.length << 2;
	if (! attr->buffers) {
	    _XEatDataWords(dpy, rep.length);
	    UnlockDisplay(dpy);
	    SyncHandle();
	    return (0);
	}
	_XRead32 (dpy, (long *) attr->buffers, nbytes);
    }
    attr->displayed_index = rep.displayedBuffer;
    attr->update_action = rep.updateAction;
    attr->update_hint = rep.updateHint;
    attr->window_mode = rep.windowMode;

    UnlockDisplay (dpy);
    SyncHandle();
    return 1;
}
示例#5
0
static void
_XQueryColors(
    register Display *dpy,
    Colormap cmap,
    XColor *defs, 		/* RETURN */
    int ncolors)
{
    register int i;
    xQueryColorsReply rep;
    register xQueryColorsReq *req;

    GetReq(QueryColors, req);

    req->cmap = cmap;
    SetReqLen(req, ncolors, ncolors); /* each pixel is a CARD32 */

    for (i = 0; i < ncolors; i++)
      Data32 (dpy, (long *)&defs[i].pixel, 4L);
       /* XXX this isn't very efficient */

    if (_XReply(dpy, (xReply *) &rep, 0, xFalse) != 0) {
	unsigned long nbytes = (long) ncolors * SIZEOF(xrgb);
	xrgb *color = Xmalloc(nbytes);
	if (color != NULL) {

	    _XRead(dpy, (char *) color, nbytes);

	    for (i = 0; i < ncolors; i++) {
		register XColor *def = &defs[i];
		register xrgb *rgb = &color[i];
		def->red = rgb->red;
		def->green = rgb->green;
		def->blue = rgb->blue;
		def->flags = DoRed | DoGreen | DoBlue;
	    }
	    Xfree(color);
	}
	else
	    _XEatDataWords(dpy, rep.length);
    }
}
示例#6
0
Atom *XListProperties(
    register Display *dpy,
    Window window,
    int *n_props)  /* RETURN */
{
    unsigned long nbytes;
    xListPropertiesReply rep;
    Atom *properties;
    register xResourceReq *req;

    LockDisplay(dpy);
    GetResReq(ListProperties, window, req);
    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
	*n_props = 0;
	UnlockDisplay(dpy);
        SyncHandle();
	return ((Atom *) NULL);
    }

    if (rep.nProperties) {
	nbytes = rep.nProperties * sizeof(Atom);
	properties = Xmalloc (nbytes);
	if (! properties) {
	    _XEatDataWords(dpy, rep.length);
	    UnlockDisplay(dpy);
	    SyncHandle();
	    return (Atom *) NULL;
	}
	nbytes = rep.nProperties << 2;
	_XRead32 (dpy, (long *) properties, nbytes);
    }
    else properties = (Atom *) NULL;

    *n_props = rep.nProperties;
    UnlockDisplay(dpy);
    SyncHandle();
    return (properties);
}
示例#7
0
Status XeviGetVisualInfo(
    register Display *dpy,
    VisualID *visual,
    int n_visual,
    ExtendedVisualInfo **evi_return,
    int *n_info_return)
{
    XExtDisplayInfo *info = find_display (dpy);
    register xEVIGetVisualInfoReq *req;
    xEVIGetVisualInfoReply rep;
    int sz_info, sz_xInfo, sz_conflict, sz_xConflict;
    VisualID32 *temp_conflict, *temp_visual, *xConflictPtr;
    VisualID *conflict;
    xExtendedVisualInfo *temp_xInfo;
    XVisualInfo *vinfo;
    register ExtendedVisualInfo *infoPtr;
    register xExtendedVisualInfo *xInfoPtr;
    register int n_data, visualIndex, vinfoIndex;
    Bool isValid;
    XeviCheckExtension (dpy, info, 0);
    if (!n_info_return || !evi_return) {
	return BadValue;
    }
    *n_info_return = 0;
    *evi_return = NULL;
    vinfo = XGetVisualInfo(dpy, 0, NULL, &sz_info);
    if (!vinfo) {
	return BadValue;
    }
    if (!n_visual || !visual) {		/* copy the all visual */
    	temp_visual = (VisualID32 *)Xmalloc(sz_VisualID32 * sz_info);
    	n_visual = 0;
        for (vinfoIndex = 0; vinfoIndex < sz_info; vinfoIndex++)
	    if (notInList(temp_visual, n_visual, vinfo[vinfoIndex].visualid))
	        temp_visual[n_visual++] = vinfo[vinfoIndex].visualid;
    }
    else {	/* check if the visual is valid */
        for (visualIndex = 0; visualIndex < n_visual; visualIndex++) {
	    isValid = False;
            for (vinfoIndex = 0; vinfoIndex < sz_info; vinfoIndex++) {
	        if (visual[visualIndex] == vinfo[vinfoIndex].visualid) {
		    isValid = True;
		    break;
	        }
	    }
	    if (!isValid) {
		XFree(vinfo);
	        return BadValue;
	    }
	}
	temp_visual = (VisualID32 *)Xmalloc(sz_VisualID32 * n_visual);
        for (visualIndex = 0; visualIndex < n_visual; visualIndex++)
	    temp_visual[visualIndex] = visual[visualIndex];
    }
    XFree(vinfo);
    LockDisplay(dpy);
    GetReq(EVIGetVisualInfo, req);
    req->reqType = info->codes->major_opcode;
    req->xeviReqType = X_EVIGetVisualInfo;
    req->n_visual = n_visual;
    SetReqLen(req, n_visual, 1);
    Data(dpy, (char *)temp_visual, n_visual * sz_VisualID32);
    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
	UnlockDisplay(dpy);
	SyncHandle();
	Xfree(temp_visual);
	return BadAccess;
    }
    Xfree(temp_visual);
    if ((rep.n_info < 65536) && (rep.n_conflicts < 65536)) {
	sz_info = rep.n_info * sizeof(ExtendedVisualInfo);
	sz_xInfo = rep.n_info * sz_xExtendedVisualInfo;
	sz_conflict = rep.n_conflicts * sizeof(VisualID);
	sz_xConflict = rep.n_conflicts * sz_VisualID32;
	*evi_return = Xmalloc(sz_info + sz_conflict);
	temp_xInfo = Xmalloc(sz_xInfo);
	temp_conflict = Xmalloc(sz_xConflict);
    } else {
	sz_xInfo = sz_xConflict = 0;
	*evi_return = NULL;
	temp_xInfo = NULL;
	temp_conflict = NULL;
    }
    if (!*evi_return || !temp_xInfo || !temp_conflict) {
	_XEatDataWords(dpy, rep.length);
	UnlockDisplay(dpy);
	SyncHandle();
	if (*evi_return) {
	   Xfree(*evi_return);
	   *evi_return = NULL;
	}
	if (temp_xInfo)
	   Xfree(temp_xInfo);
	if (temp_conflict)
	   Xfree(temp_conflict);
	return BadAlloc;
    }
    _XRead(dpy, (char *)temp_xInfo, sz_xInfo);
    _XRead(dpy, (char *)temp_conflict, sz_xConflict);
    UnlockDisplay(dpy);
    SyncHandle();
    infoPtr = *evi_return;
    xInfoPtr = temp_xInfo;
    xConflictPtr = temp_conflict;
    n_data = rep.n_info;
    conflict = (VisualID *)(infoPtr + n_data);
    while (n_data-- > 0) {
	infoPtr->core_visual_id		= xInfoPtr->core_visual_id;
	infoPtr->screen			= xInfoPtr->screen;
	infoPtr->level			= xInfoPtr->level;
	infoPtr->transparency_type	= xInfoPtr->transparency_type;
	infoPtr->transparency_value	= xInfoPtr->transparency_value;
	infoPtr->min_hw_colormaps	= xInfoPtr->min_hw_colormaps;
	infoPtr->max_hw_colormaps	= xInfoPtr->max_hw_colormaps;
	infoPtr->num_colormap_conflicts = xInfoPtr->num_colormap_conflicts;
	infoPtr->colormap_conflicts	= conflict;
	conflict += infoPtr->num_colormap_conflicts;
	infoPtr++;
	xInfoPtr++;
    }
    n_data = rep.n_conflicts;
    conflict = (VisualID *)(infoPtr);
    while (n_data-- > 0)
       *conflict++ = *xConflictPtr++;
    Xfree(temp_xInfo);
    Xfree(temp_conflict);
    *n_info_return = rep.n_info;
    return Success;
}
示例#8
0
static void
CalcServerVersionAndExtensions(void)
{
    int s;
    char **be_extensions;
    char *ext;
    char *denied_extensions;

    /*
     * set the server glx version to be the minimum version
     * supported by all back-end servers
     */
    __glXVersionMajor = 0;
    __glXVersionMinor = 0;
    for (s = 0; s < __glXNumActiveScreens; s++) {
        DMXScreenInfo *dmxScreen = &dmxScreens[s];
        Display *dpy = dmxScreen->beDisplay;
        xGLXQueryVersionReq *req;
        xGLXQueryVersionReply reply;

        /* Send the glXQueryVersion request */
        LockDisplay(dpy);
        GetReq(GLXQueryVersion, req);
        req->reqType = dmxScreen->glxMajorOpcode;
        req->glxCode = X_GLXQueryVersion;
        req->majorVersion = GLX_SERVER_MAJOR_VERSION;
        req->minorVersion = GLX_SERVER_MINOR_VERSION;
        _XReply(dpy, (xReply *) &reply, 0, False);
        UnlockDisplay(dpy);
        SyncHandle();

        if (s == 0) {
            __glXVersionMajor = reply.majorVersion;
            __glXVersionMinor = reply.minorVersion;
        }
        else {
            if (reply.majorVersion < __glXVersionMajor) {
                __glXVersionMajor = reply.majorVersion;
                __glXVersionMinor = reply.minorVersion;
            }
            else if ((reply.majorVersion == __glXVersionMajor) &&
                     (reply.minorVersion < __glXVersionMinor)) {
                __glXVersionMinor = reply.minorVersion;
            }
        }

    }

    if (GLX_SERVER_MAJOR_VERSION < __glXVersionMajor) {
        __glXVersionMajor = GLX_SERVER_MAJOR_VERSION;
        __glXVersionMinor = GLX_SERVER_MINOR_VERSION;
    }
    else if ((GLX_SERVER_MAJOR_VERSION == __glXVersionMajor) &&
             (GLX_SERVER_MINOR_VERSION < __glXVersionMinor)) {
        __glXVersionMinor = GLX_SERVER_MINOR_VERSION;
    }

    snprintf(GLXServerVersion, sizeof(GLXServerVersion),
             "%d.%d DMX %d back-end server(s)",
             __glXVersionMajor, __glXVersionMinor, __glXNumActiveScreens);
    /*
     * set the ExtensionsString to the minimum extensions string
     */
    ExtensionsString[0] = '\0';

    /*
     * read extensions strings of all back-end servers
     */
    be_extensions = (char **) malloc(__glXNumActiveScreens * sizeof(char *));
    if (!be_extensions)
        return;

    for (s = 0; s < __glXNumActiveScreens; s++) {
        DMXScreenInfo *dmxScreen = &dmxScreens[s];
        Display *dpy = dmxScreen->beDisplay;
        xGLXQueryServerStringReq *req;
        xGLXQueryServerStringReply reply;
        int length, numbytes;

        /* Send the glXQueryServerString request */
        LockDisplay(dpy);
        GetReq(GLXQueryServerString, req);
        req->reqType = dmxScreen->glxMajorOpcode;
        req->glxCode = X_GLXQueryServerString;
        req->screen = DefaultScreen(dpy);
        req->name = GLX_EXTENSIONS;
        _XReply(dpy, (xReply *) &reply, 0, False);

        length = (int) reply.length;
        numbytes = (int) reply.n;
        be_extensions[s] = (char *) malloc(numbytes);
        if (!be_extensions[s]) {
            /* Throw data on the floor */
            _XEatDataWords(dpy, length);
        }
        else {
            _XReadPad(dpy, (char *) be_extensions[s], numbytes);
        }
        UnlockDisplay(dpy);
        SyncHandle();
    }

    /*
     * extensions string will include only extensions that our
     * server supports as well as all back-end servers supports.
     * extensions that are in the DMX_DENY_EXTENSIONS string will
     * not be supported.
     */
    denied_extensions = getenv("DMX_DENY_GLX_EXTENSIONS");
    ext = strtok(GLXServerExtensions, " ");
    while (ext) {
        int supported = 1;

        if (denied_extensions && strstr(denied_extensions, ext)) {
            supported = 0;
        }
        else {
            for (s = 0; s < __glXNumActiveScreens && supported; s++) {
                if (!strstr(be_extensions[s], ext)) {
                    supported = 0;
                }
            }
        }

        if (supported) {
            strcat(ExtensionsString, ext);
            strcat(ExtensionsString, " ");
        }

        ext = strtok(NULL, " ");
    }

    /*
     * release temporary storage
     */
    for (s = 0; s < __glXNumActiveScreens; s++) {
        free(be_extensions[s]);
    }
    free(be_extensions);

    if (dmxGLXSwapGroupSupport) {
        if (!denied_extensions ||
            !strstr(denied_extensions, "GLX_SGIX_swap_group")) {
            strcat(ExtensionsString, "GLX_SGIX_swap_group");
            if (!denied_extensions ||
                !strstr(denied_extensions, "GLX_SGIX_swap_barrier")) {
                strcat(ExtensionsString, " GLX_SGIX_swap_barrier");
            }
        }
    }

}
示例#9
0
Bool
ephyrHostGLXGetStringFromServer(int a_screen_number,
                                int a_string_name,
                                enum EphyrHostGLXGetStringOps a_op,
                                char **a_string)
{
    Bool is_ok = FALSE;
    Display *dpy = hostx_get_display();
    int default_screen = DefaultScreen(dpy);
    xGLXGenericGetStringReq *req = NULL;
    xGLXSingleReply reply;
    unsigned long length = 0, numbytes = 0;
    int major_opcode = 0, get_string_op = 0;

    EPHYR_RETURN_VAL_IF_FAIL(dpy && a_string, FALSE);

    EPHYR_LOG("enter\n");
    switch (a_op) {
    case EPHYR_HOST_GLX_QueryServerString:
        get_string_op = X_GLXQueryServerString;
        break;
    case EPHYR_HOST_GLX_GetString:
        get_string_op = X_GLsop_GetString;
        EPHYR_LOG("Going to glXGetString. strname:%#x, ctxttag:%d\n",
                  a_string_name, a_screen_number);
        break;
    default:
        EPHYR_LOG_ERROR("unknown EphyrHostGLXGetStringOp:%d\n", a_op);
        goto out;
    }

    if (!ephyrHostGLXGetMajorOpcode(&major_opcode)) {
        EPHYR_LOG_ERROR("failed to get major opcode\n");
        goto out;
    }
    EPHYR_LOG("major opcode: %d\n", major_opcode);

    LockDisplay(dpy);

    /* All of the GLX protocol requests for getting a string from the server
     * look the same.  The exact meaning of the a_for_whom field is usually
     * either the screen number (for glXQueryServerString) or the context tag
     * (for GLXSingle).
     */
    GetReq(GLXGenericGetString, req);
    req->reqType = major_opcode;
    req->glxCode = get_string_op;
    req->for_whom = default_screen;
    req->name = a_string_name;

    _XReply(dpy, (xReply *) &reply, 0, False);

#if UINT32_MAX >= (ULONG_MAX / 4)
    if (reply.length >= (ULONG_MAX / 4)) {
        _XEatDataWords(dpy, reply.length);
        goto eat_out;
    }
#endif
    if (reply.length > 0) {
        length = (unsigned long) reply.length * 4;
        numbytes = reply.size;
        if (numbytes > length) {
            EPHYR_LOG_ERROR("string length %d longer than reply length %d\n",
                            numbytes, length);
            goto eat_out;
        }
    }
    EPHYR_LOG("going to get a string of size:%d\n", numbytes);

    if (numbytes < INT_MAX)
        *a_string = Xcalloc(numbytes + 1, 1);
    else
        *a_string = NULL;
    if (*a_string == NULL) {
        EPHYR_LOG_ERROR("allocation failed\n");
        goto eat_out;
    }

    if (_XRead(dpy, *a_string, numbytes)) {
        EPHYR_LOG_ERROR("read failed\n");
        length = 0; /* if read failed, no idea how much to eat */
    }
    else {
        length -= numbytes;
        EPHYR_LOG("strname:%#x, strvalue:'%s', strlen:%d\n",
                  a_string_name, *a_string, numbytes);
        is_ok = TRUE;
    }

 eat_out:
    _XEatData(dpy, length);
    UnlockDisplay(dpy);
    SyncHandle();

 out:
    EPHYR_LOG("leave\n");
    return is_ok;
}
示例#10
0
int
__glXVForwardAllWithReply(__GLXclientState * cl, GLbyte * pc)
{
    ClientPtr client = cl->client;
    xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
    xGLXVendorPrivateReq *be_req;
    xGLXVendorPrivReply reply;
    xGLXVendorPrivReply be_reply;
    __GLXcontext *glxc;
    int buf_size;
    char *be_buf = NULL;
    int be_buf_size = 0;
    int from_screen = 0;
    int to_screen = 0;
    int s;

    DMXScreenInfo *dmxScreen;
    Display *dpy;

    glxc = __glXLookupContextByTag(cl, req->contextTag);
    if (!glxc) {
        return 0;
    }
    from_screen = to_screen = glxc->pScreen->myNum;

#ifdef PANORAMIX
    if (!noPanoramiXExtension) {
        from_screen = 0;
        to_screen = screenInfo.numScreens - 1;
    }
#endif

    pc += sz_xGLXVendorPrivateReq;
    buf_size = (req->length << 2) - sz_xGLXVendorPrivateReq;

    /* 
     * send the request to the first back-end server(s)
     */
    for (s = to_screen; s >= from_screen; s--) {
        dmxScreen = &dmxScreens[s];
        dpy = GetBackEndDisplay(cl, s);

        LockDisplay(dpy);
        GetReqVendorPrivate(GLXVendorPrivate, be_req);
        be_req->reqType = dmxScreen->glxMajorOpcode;
        be_req->glxCode = req->glxCode;
        be_req->length = req->length;
        be_req->vendorCode = req->vendorCode;
        be_req->contextTag = GetCurrentBackEndTag(cl, req->contextTag, s);
        if (buf_size > 0)
            _XSend(dpy, (const char *) pc, buf_size);

        /*
         * get the reply from the back-end server
         */
        _XReply(dpy, (xReply *) &be_reply, 0, False);
        if (s == from_screen) {
            /* Save data from last reply to send on to client */
            be_buf_size = be_reply.length << 2;
            if (be_buf_size > 0) {
                be_buf = malloc(be_buf_size);
                if (be_buf) {
                    _XRead(dpy, be_buf, be_buf_size);
                }
                else {
                    /* Throw data on the floor */
                    _XEatDataWords(dpy, be_reply.length);
                    return BadAlloc;
                }
            }
        }
        else {
            /* Just discard data from all replies before the last one */
            if (be_reply.length > 0)
                _XEatDataWords(dpy, be_reply.length);
        }

        UnlockDisplay(dpy);
        SyncHandle();
    }

    /*
     * send the reply to the client
     */
    memcpy(&reply, &be_reply, sz_xGLXVendorPrivReply);
    reply.type = X_Reply;
    reply.sequenceNumber = client->sequence;

    if (client->swapped) {
        SendSwappedReply(client, &reply, be_buf, be_buf_size);
    }
    else {
        WriteToClient(client, sizeof(xGLXVendorPrivReply), &reply);
        if (be_buf_size > 0)
            WriteToClient(client, be_buf_size, be_buf);
    }

    if (be_buf_size > 0)
        free(be_buf);

    return Success;
}
示例#11
0
int
__glXVForwardPipe0WithReply(__GLXclientState * cl, GLbyte * pc)
{
    ClientPtr client = cl->client;
    xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
    xGLXVendorPrivateReq *be_req;
    xGLXVendorPrivReply reply;
    xGLXVendorPrivReply be_reply;
    __GLXcontext *glxc;
    int buf_size;
    char *be_buf = NULL;
    int be_buf_size;
    DMXScreenInfo *dmxScreen;
    Display *dpy;

    glxc = __glXLookupContextByTag(cl, req->contextTag);
    if (!glxc) {
        return __glXBadContext;
    }

    pc += sz_xGLXVendorPrivateReq;
    buf_size = (req->length << 2) - sz_xGLXVendorPrivateReq;

    dmxScreen = &dmxScreens[glxc->pScreen->myNum];
    dpy = GetBackEndDisplay(cl, glxc->pScreen->myNum);

    /* 
     * send the request to the first back-end server
     */
    LockDisplay(dpy);
    GetReqVendorPrivate(GLXVendorPrivate, be_req);
    be_req->reqType = dmxScreen->glxMajorOpcode;
    be_req->glxCode = req->glxCode;
    be_req->length = req->length;
    be_req->vendorCode = req->vendorCode;
    be_req->contextTag =
        GetCurrentBackEndTag(cl, req->contextTag, glxc->pScreen->myNum);
    if (buf_size > 0)
        _XSend(dpy, (const char *) pc, buf_size);

    /*
     * get the reply from the back-end server
     */
    _XReply(dpy, (xReply *) &be_reply, 0, False);
    be_buf_size = be_reply.length << 2;
    if (be_buf_size > 0) {
        be_buf = (char *) malloc(be_buf_size);
        if (be_buf) {
            _XRead(dpy, be_buf, be_buf_size);
        }
        else {
            /* Throw data on the floor */
            _XEatDataWords(dpy, be_reply.length);
            return BadAlloc;
        }
    }

    UnlockDisplay(dpy);
    SyncHandle();

    /*
     * send the reply to the client
     */
    memcpy(&reply, &be_reply, sz_xGLXVendorPrivReply);
    reply.type = X_Reply;
    reply.sequenceNumber = client->sequence;

    if (client->swapped) {
        SendSwappedReply(client, &reply, be_buf, be_buf_size);
    }
    else {
        WriteToClient(client, sizeof(xGLXVendorPrivReply), &reply);
        if (be_buf_size > 0)
            WriteToClient(client, be_buf_size, be_buf);
    }

    if (be_buf_size > 0)
        free(be_buf);

    return Success;
}