Ejemplo n.º 1
0
Archivo: Xv.c Proyecto: narenas/nx-libs
XvAttribute* 
XvQueryPortAttributes(Display *dpy, XvPortID port, int *num)
{
  XExtDisplayInfo *info = xv_find_display(dpy);
  xvQueryPortAttributesReq *req;
  xvQueryPortAttributesReply rep;
  XvAttribute *ret = NULL;

  *num = 0;

  XvCheckExtension(dpy, info, NULL);

  LockDisplay(dpy);

  XvGetReq(QueryPortAttributes, req);
  req->port = port;

  /* READ THE REPLY */

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

  if(rep.num_attributes) {
      int size = (rep.num_attributes * sizeof(XvAttribute)) + rep.text_size;

      if((ret = Xmalloc(size))) {
	  char* marker = (char*)(&ret[rep.num_attributes]);
	  xvAttributeInfo Info;
	  int i;
	
	  for(i = 0; i < rep.num_attributes; i++) {
             _XRead(dpy, (char*)(&Info), sz_xvAttributeInfo);
	      ret[i].flags = (int)Info.flags;	      
	      ret[i].min_value = Info.min;	      
	      ret[i].max_value = Info.max;	      
	      ret[i].name = marker;
	      _XRead(dpy, marker, Info.size);
	      marker += Info.size;
	      (*num)++;
	  }
      } else
	_XEatData(dpy, rep.length << 2);
  }

  UnlockDisplay(dpy);
  SyncHandle();

  return ret;
}
Ejemplo n.º 2
0
Archivo: Xv.c Proyecto: narenas/nx-libs
XvImage * XvCreateImage (
   Display *dpy,
   XvPortID port,
   int id,
   char *data,
   int width, 
   int height 
) {
   XExtDisplayInfo *info = xv_find_display(dpy);
   xvQueryImageAttributesReq *req;
   xvQueryImageAttributesReply rep;
   XvImage *ret = NULL;

   XvCheckExtension(dpy, info, NULL);

   LockDisplay(dpy);

   XvGetReq(QueryImageAttributes, req);
   req->id = id;
   req->port = port;
   req->width = width;
   req->height = height;

   /* READ THE REPLY */

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

   if((ret = (XvImage*)Xmalloc(sizeof(XvImage) + (rep.num_planes << 3)))) {
	ret->id = id;
	ret->width = rep.width;
	ret->height = rep.height;
	ret->data_size = rep.data_size;
	ret->num_planes = rep.num_planes;
	ret->pitches = (int*)(&ret[1]);
	ret->offsets = ret->pitches + rep.num_planes;
	ret->data = data;
	ret->obdata = NULL;
  	_XRead(dpy, (char*)(ret->pitches), rep.num_planes << 2);
	_XRead(dpy, (char*)(ret->offsets), rep.num_planes << 2);
   } else
	_XEatData(dpy, rep.length << 2);

   UnlockDisplay(dpy);
   SyncHandle();

   return ret;
}
Ejemplo n.º 3
0
void __indirect_glGetVertexAttribivARB( GLuint index, GLenum pname,
					GLint * params )
{
    __GLXcontext * const gc = __glXGetCurrentContext();
    Display * const dpy = gc->currentDpy;
    __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
    xGLXSingleReply reply;


    get_vertex_attrib( gc, 1303, index, pname, (xReply *) & reply );

    if ( reply.size != 0 ) {
	if ( ! get_attrib_array_data( state, index, pname, params ) ) {
	    if (reply.size == 1) {
		*params = (GLint) reply.pad3;
	    } 
	    else {
		_XRead(dpy, (void *) params, 4 * reply.size);
	    }
	}
    }

    UnlockDisplay(dpy);
    SyncHandle();
}
Ejemplo n.º 4
0
CARD32
__glXReadReply(Display * dpy, size_t size, void *dest,
               GLboolean reply_is_always_array)
{
   xGLXSingleReply reply;

   (void) _XReply(dpy, (xReply *) & reply, 0, False);
   if (size != 0) {
      if ((reply.length > 0) || reply_is_always_array) {
         const GLint bytes = (reply_is_always_array)
            ? (4 * reply.length) : (reply.size * size);
         const GLint extra = 4 - (bytes & 3);

         _XRead(dpy, dest, bytes);
         if (extra < 4) {
            _XEatData(dpy, extra);
         }
      }
      else {
         (void) memcpy(dest, &(reply.pad3), size);
      }
   }

   return reply.retval;
}
Ejemplo n.º 5
0
int
XQueryColor(
    register Display *dpy,
    Colormap cmap,
    XColor *def)	/* RETURN */
{
    xrgb color;
    xQueryColorsReply rep;
    register xQueryColorsReq *req;
    unsigned long val = def->pixel;	/* needed for macro below */

    LockDisplay(dpy);
    GetReqExtra(QueryColors, 4, req); /* a pixel (CARD32) is 4 bytes */
    req->cmap = cmap;

    OneDataCard32 (dpy, NEXTPTR(req,xQueryColorsReq), val);

    if (_XReply(dpy, (xReply *) &rep, 0, xFalse) != 0) {

	    _XRead(dpy, (char *)&color, (long) SIZEOF(xrgb));

	    def->red = color.red;
	    def->blue = color.blue;
	    def->green = color.green;
	    def->flags = DoRed | DoGreen | DoBlue;
        }
    UnlockDisplay(dpy);
    SyncHandle();
    return 1;
}
Ejemplo n.º 6
0
void __indirect_glGetVertexAttribdvARB( GLuint index, GLenum pname,
					GLdouble * params )
{
    __GLXcontext * const gc = __glXGetCurrentContext();
    Display * const dpy = gc->currentDpy;
    __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
    xGLXSingleReply reply;


    get_vertex_attrib( gc, 1301, index, pname, (xReply *) & reply );

    if ( reply.size != 0 ) {
	GLintptr data;


	if ( get_attrib_array_data( state, index, pname, & data ) ) {
	    *params = (GLdouble) data;
	}
	else {
	    if (reply.size == 1) {
		(void) memcpy( params, & reply.pad3, sizeof( GLdouble ) );
	    } 
	    else {
		_XRead(dpy, (void *) params, 8 * reply.size);
	    }
	}
    }

    UnlockDisplay(dpy);
    SyncHandle();
}
Ejemplo n.º 7
0
void
__indirect_glGetCompressedTexImageARB( GLenum target, GLint level, 
				    GLvoid * img )
{
    __GLX_SINGLE_DECLARE_VARIABLES();
    xGLXGetTexImageReply reply;
    size_t image_bytes;

    __GLX_SINGLE_LOAD_VARIABLES();
    __GLX_SINGLE_BEGIN( X_GLsop_GetCompressedTexImage, 8 );
    __GLX_SINGLE_PUT_LONG( 0, target );
    __GLX_SINGLE_PUT_LONG( 4, level );
    __GLX_SINGLE_READ_XREPLY();

    image_bytes = reply.width;
    assert( image_bytes <= ((4 * reply.length) - 0) );
    assert( image_bytes >= ((4 * reply.length) - 3) );
    
    if ( image_bytes != 0 ) {
	_XRead( dpy, (char *) img, image_bytes );
	if ( image_bytes < (4 * reply.length) ) {
	    _XEatData( dpy, (4 * reply.length) - image_bytes );
	}
    }

    __GLX_SINGLE_END();
}
Ejemplo n.º 8
0
Bool XNVCTRLQueryTargetBinaryData (
    Display *dpy,
    int target_type,
    int target_id,
    unsigned int display_mask,
    unsigned int attribute,
    unsigned char **ptr,
    int *len
) {
    XExtDisplayInfo *info = find_display (dpy);
    xnvCtrlQueryBinaryDataReply rep;
    xnvCtrlQueryBinaryDataReq   *req;
    Bool exists;
    int length, numbytes, slop;

    if (!ptr) return False;

    if(!XextHasExtension(info))
        return False;

    XNVCTRLCheckExtension (dpy, info, False);
    XNVCTRLCheckTargetData(dpy, info, &target_type, &target_id);

    LockDisplay (dpy);
    GetReq (nvCtrlQueryBinaryData, req);
    req->reqType = info->codes->major_opcode;
    req->nvReqType = X_nvCtrlQueryBinaryData;
    req->target_type = target_type;
    req->target_id = target_id;
    req->display_mask = display_mask;
    req->attribute = attribute;
    if (!_XReply (dpy, (xReply *) &rep, 0, False)) {
        UnlockDisplay (dpy);
        SyncHandle ();
        return False;
    }
    length = rep.length;
    numbytes = rep.n;
    slop = numbytes & 3;
    exists = rep.flags;
    if (exists) {
        *ptr = (unsigned char *) Xmalloc(numbytes);
    }
    if (!exists || !*ptr) {
        _XEatData(dpy, length);
        UnlockDisplay (dpy);
        SyncHandle ();
        return False;
    } else {
        _XRead(dpy, (char *) *ptr, numbytes);
        if (slop) _XEatData(dpy, 4-slop);
    }
    if (len) *len = numbytes;
    UnlockDisplay (dpy);
    SyncHandle ();
    return exists;
}
Ejemplo n.º 9
0
Archivo: XvMC.c Proyecto: aosm/X11libs
Status _xvmc_create_subpicture (
    Display *dpy,
    XvMCContext *context,
    XvMCSubpicture *subpicture,
    int *priv_count,
    CARD32 **priv_data
)
{
    XExtDisplayInfo *info = xvmc_find_display(dpy);
    xvmcCreateSubpictureReply rep;
    xvmcCreateSubpictureReq  *req;

    *priv_count = 0;
    *priv_data = NULL;

    XvMCCheckExtension (dpy, info, BadImplementation);

    LockDisplay (dpy);
    XvMCGetReq (CreateSubpicture, req);

    subpicture->subpicture_id = XAllocID(dpy);
    subpicture->context_id = context->context_id;

    req->subpicture_id = subpicture->subpicture_id;
    req->context_id = subpicture->context_id;
    req->xvimage_id = subpicture->xvimage_id;
    req->width = subpicture->width;
    req->height = subpicture->height;
    if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
        UnlockDisplay (dpy);
        SyncHandle ();
        return BadImplementation;
    }

    subpicture->width = rep.width_actual;
    subpicture->height = rep.height_actual;
    subpicture->num_palette_entries = rep.num_palette_entries;
    subpicture->entry_bytes = rep.entry_bytes;
    subpicture->component_order[0] = rep.component_order[0];
    subpicture->component_order[1] = rep.component_order[1];
    subpicture->component_order[2] = rep.component_order[2];
    subpicture->component_order[3] = rep.component_order[3];

    if(rep.length) {
        *priv_data = Xmalloc(rep.length << 2);
        if(*priv_data) {
            _XRead(dpy, (char*)(*priv_data), rep.length << 2);
            *priv_count = rep.length;
        } else
            _XEatData(dpy, rep.length << 2);
    }

    UnlockDisplay (dpy);
    SyncHandle ();
    return Success;
}
Ejemplo n.º 10
0
Bool XNVCTRLQueryDDCCIBlockLutOperation (
    Display *dpy,
    int screen,
    unsigned int display_mask,
    unsigned int color, // NV_CTRL_DDCCI_RED_LUT, NV_CTRL_DDCCI_GREEN_LUT, NV_CTRL_DDCCI_BLUE_LUT
    unsigned int offset,
    unsigned int size,
    unsigned int **value
) {
    XExtDisplayInfo *info = find_display (dpy);
    xnvCtrlQueryDDCCIBlockLutOperationReply rep;
    xnvCtrlQueryDDCCIBlockLutOperationReq *req;
    Bool exists;
    int length, slop;
    char *ptr;

    if(!XextHasExtension(info))
        return False;

    XNVCTRLCheckExtension (dpy, info, False);

    LockDisplay (dpy);
    GetReq (nvCtrlQueryDDCCIBlockLutOperation, req);
    req->reqType = info->codes->major_opcode;
    req->nvReqType = X_nvCtrlQueryDDCCIBlockLutOperation;
    req->screen = screen;
    req->display_mask = display_mask;
    req->color=color;
    req->offset=offset;
    req->size=size;
    if (!_XReply (dpy, (xReply *) &rep, 0, False)) {
        UnlockDisplay (dpy);
        SyncHandle ();
        return False;
    }
    length = rep.length;
    slop = rep.num_bytes & 3;
    ptr = (char *) Xmalloc(rep.num_bytes);
    if (! ptr) {
        _XEatData(dpy, length);
        UnlockDisplay (dpy);
        SyncHandle ();
        return False;
    } else {
        _XRead(dpy, (char *) ptr, rep.num_bytes);
        if (slop) _XEatData(dpy, 4-slop);
    }
    exists = rep.flags;
    if(exists) {
        *value=(unsigned int *)ptr;
    }
    UnlockDisplay (dpy);
    SyncHandle ();
    return exists;
}
Ejemplo n.º 11
0
static struct glx_config *
createConfigsFromProperties(Display * dpy, int nvisuals, int nprops,
                            int screen, GLboolean tagged_only)
{
   INT32 buf[__GLX_TOTAL_CONFIG], *props;
   unsigned prop_size;
   struct glx_config *modes, *m;
   int i;

   if (nprops == 0)
      return NULL;

   /* FIXME: Is the __GLX_MIN_CONFIG_PROPS test correct for FBconfigs? */

   /* Check number of properties */
   if (nprops < __GLX_MIN_CONFIG_PROPS || nprops > __GLX_MAX_CONFIG_PROPS)
      return NULL;

   /* Allocate memory for our config structure */
   modes = glx_config_create_list(nvisuals);
   if (!modes)
      return NULL;

   prop_size = nprops * __GLX_SIZE_INT32;
   if (prop_size <= sizeof(buf))
      props = buf;
   else
      props = malloc(prop_size);

   /* Read each config structure and convert it into our format */
   m = modes;
   for (i = 0; i < nvisuals; i++) {
      _XRead(dpy, (char *) props, prop_size);
#ifdef GLX_USE_APPLEGL
       /* Older X servers don't send this so we default it here. */
      m->drawableType = GLX_WINDOW_BIT;
#else
      /* 
       * The XQuartz 2.3.2.1 X server doesn't set this properly, so
       * set the proper bits here.
       * AppleSGLX supports windows, pixmaps, and pbuffers with all config.
       */
      m->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
#endif
       __glXInitializeVisualConfigFromTags(m, nprops, props,
                                          tagged_only, GL_TRUE);
      m->screen = screen;
      m = m->next;
   }

   if (props != buf)
      free(props);

   return modes;
}
Ejemplo n.º 12
0
Bool XNVCTRLQueryStringAttribute (
    Display *dpy,
    int screen,
    unsigned int display_mask,
    unsigned int attribute,
    char **ptr
)
{
    XExtDisplayInfo *info = find_display (dpy);
    xnvCtrlQueryStringAttributeReply rep;
    xnvCtrlQueryStringAttributeReq   *req;
    Bool exists;
    int length, numbytes, slop;

    if (!ptr) return False;

    if(!XextHasExtension(info))
        return False;

    XNVCTRLCheckExtension (dpy, info, False);

    LockDisplay (dpy);
    GetReq (nvCtrlQueryStringAttribute, req);
    req->reqType = info->codes->major_opcode;
    req->nvReqType = X_nvCtrlQueryStringAttribute;
    req->screen = screen;
    req->display_mask = display_mask;
    req->attribute = attribute;
    if (!_XReply (dpy, (xReply *) &rep, 0, False))
    {
        UnlockDisplay (dpy);
        SyncHandle ();
        return False;
    }
    length = rep.length;
    numbytes = rep.n;
    slop = numbytes & 3;
    *ptr = (char *) Xmalloc(numbytes);
    if (! *ptr)
    {
        _XEatData(dpy, length);
        UnlockDisplay (dpy);
        SyncHandle ();
        return False;
    }
    else
    {
        _XRead(dpy, (char *) *ptr, numbytes);
        if (slop) _XEatData(dpy, 4-slop);
    }
    exists = rep.flags;
    UnlockDisplay (dpy);
    SyncHandle ();
    return exists;
}
Ejemplo n.º 13
0
XTimeCoord *XGetMotionEvents(
    register Display *dpy,
    Window w,
    Time start,
    Time stop,
    int *nEvents)  /* RETURN */
{
    xGetMotionEventsReply rep;
    register xGetMotionEventsReq *req;
    XTimeCoord *tc = NULL;
    long nbytes;
    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) {
	if (! (tc = (XTimeCoord *)
	       Xmalloc( (unsigned)
		       (nbytes = (long) rep.nEvents * sizeof(XTimeCoord))))) {
	    _XEatData (dpy, (unsigned long) nbytes);
	    UnlockDisplay(dpy);
	    SyncHandle();
	    return (NULL);
	}
    }

    *nEvents = rep.nEvents;
    nbytes = SIZEOF (xTimecoord);
    {
	register XTimeCoord *tcptr;
	register int i;
	xTimecoord xtc;

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

    UnlockDisplay(dpy);
    SyncHandle();
    return (tc);
}
Ejemplo n.º 14
0
/* XXXAlternative: Instead of getting the manufacturer string from the server,
 * get the manufacturer Id instead, and have controller_manufacturer assigned
 * to a static string that would not need to be malloc'ed and freed.
 */
Bool XNVCTRLQueryDDCCIDisplayControllerType (
    Display *dpy,
    int screen,
    unsigned int display_mask,
    unsigned char **controller_manufacturer,
    unsigned int *controller_type
)
{
    XExtDisplayInfo *info = find_display (dpy);
    xnvCtrlQueryDDCCIDisplayControllerTypeReply rep;
    xnvCtrlQueryDDCCIDisplayControllerTypeReq *req;
    Bool exists;
    int length, numbytes, slop;
    char *ptr;

    if(!XextHasExtension(info))
        return False;

    XNVCTRLCheckExtension (dpy, info, False);

    LockDisplay (dpy);
    GetReq (nvCtrlQueryDDCCIDisplayControllerType, req);
    req->reqType = info->codes->major_opcode;
    req->nvReqType = X_nvCtrlQueryDDCCIDisplayControllerType;
    req->screen = screen;
    req->display_mask = display_mask;
    if (!_XReply (dpy, (xReply *) &rep, 0, False)) {
        UnlockDisplay (dpy);
        SyncHandle ();
        return False;
    }
    length = rep.length;
    numbytes = rep.size;
    slop = numbytes & 3;
    ptr = (char *) Xmalloc(numbytes);
    if (! ptr) {
        _XEatData(dpy, length);
        UnlockDisplay (dpy);
        SyncHandle ();
        return False;
    } else {
        _XRead(dpy, (char *) ptr, numbytes);
        if (slop) _XEatData(dpy, 4-slop);
    }
    exists = rep.flags;
    if(exists) {
        *controller_type=rep.controller_type;
        *controller_manufacturer=ptr;
    }
    UnlockDisplay (dpy);
    SyncHandle ();
    return exists;
}
Ejemplo n.º 15
0
XineramaScreenInfo *
XineramaQueryScreens(
   Display *dpy,
   int     *number
)
{
    XExtDisplayInfo		*info = find_display (dpy);
    xXineramaQueryScreensReply	rep;
    xXineramaQueryScreensReq	*req;
    XineramaScreenInfo		*scrnInfo = NULL;

    PanoramiXCheckExtension (dpy, info, NULL);

    if (NULL != (scrnInfo = XineramaGetFake(number)))
    {
	return scrnInfo;
    }

    LockDisplay (dpy);
    GetReq (XineramaQueryScreens, req);
    req->reqType = info->codes->major_opcode;
    req->panoramiXReqType = X_XineramaQueryScreens;
    if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
	UnlockDisplay (dpy);
	SyncHandle ();
	return NULL;
    }

    if(rep.number) {
	if((scrnInfo = Xmalloc(sizeof(XineramaScreenInfo) * rep.number))) {
	    xXineramaScreenInfo scratch;
	    int i;

	    for(i = 0; i < rep.number; i++) {
		_XRead(dpy, (char*)(&scratch), sz_XineramaScreenInfo);
		scrnInfo[i].screen_number = i;
		scrnInfo[i].x_org 	  = scratch.x_org;
		scrnInfo[i].y_org 	  = scratch.y_org;
		scrnInfo[i].width 	  = scratch.width;
		scrnInfo[i].height 	  = scratch.height;
	    }

	    *number = rep.number;
	} else
	    _XEatData(dpy, rep.length << 2);
    } else {
	*number = 0;
    }

    UnlockDisplay (dpy);
    SyncHandle ();
    return scrnInfo;
}
Ejemplo n.º 16
0
Bool XNVCTRLQueryDDCCITimingReport (
    Display *dpy,
    int screen,
    unsigned int display_mask,
    unsigned int *sync_freq_out_range,
    unsigned int *unstable_count,
    unsigned int *positive_h_sync,
    unsigned int *positive_v_sync,
    unsigned int *h_freq,
    unsigned int *v_freq
) {
    XExtDisplayInfo *info = find_display (dpy);
    xnvCtrlQueryDDCCITimingReportReply rep;
    xnvCtrlQueryDDCCITimingReportReq *req;
    unsigned int buf[6];
    Bool exists;

    if(!XextHasExtension(info))
        return False;

    XNVCTRLCheckExtension (dpy, info, False);

    LockDisplay (dpy);

    GetReq (nvCtrlQueryDDCCITimingReport, req);
    req->reqType = info->codes->major_opcode;
    req->nvReqType = X_nvCtrlQueryDDCCITimingReport;
    req->screen = screen;
    req->display_mask = display_mask;

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

    _XRead(dpy, (char *)(&buf), 24);

    exists = rep.flags;

    *sync_freq_out_range = buf[0];
    *unstable_count = buf[1];
    *positive_h_sync = buf[2];
    *positive_v_sync = buf[3];
    *h_freq = buf[4];
    *v_freq = buf[5];

    UnlockDisplay (dpy);
    SyncHandle ();

    return exists;
}
Ejemplo n.º 17
0
Archivo: XRes.c Proyecto: aosm/X11libs
Status XResQueryClientResources (
    Display *dpy,
    XID xid,
    int *num_types,
    XResType **types
)
{
    XExtDisplayInfo *info = find_display (dpy);
    xXResQueryClientResourcesReq *req;
    xXResQueryClientResourcesReply rep;
    XResType *typs;
    int result = 0;

    *num_types = 0;
    *types = NULL;

    XResCheckExtension (dpy, info, 0);

    LockDisplay (dpy);
    GetReq (XResQueryClientResources, req);
    req->reqType = info->codes->major_opcode;
    req->XResReqType = X_XResQueryClientResources;
    req->xid = xid;
    if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
        UnlockDisplay (dpy);
        SyncHandle ();
        return 0;
    }

    if(rep.num_types) {
        if((typs = Xmalloc(sizeof(XResType) * rep.num_types))) {
            xXResType scratch;
            int i;

            for(i = 0; i < rep.num_types; i++) {
                _XRead(dpy, (char*)&scratch, sz_xXResType);
                typs[i].resource_type = scratch.resource_type;
                typs[i].count = scratch.count;
            }
            *types = typs;
            *num_types = rep.num_types;
            result = 1;
        } else {
            _XEatData(dpy, rep.length << 2);
        }
    }
    
    UnlockDisplay (dpy);
    SyncHandle ();
    return result;
}
Ejemplo n.º 18
0
Archivo: XvMC.c Proyecto: aosm/X11libs
XvMCSurfaceInfo * XvMCListSurfaceTypes(Display *dpy, XvPortID port, int *num)
{
    XExtDisplayInfo *info = xvmc_find_display(dpy);
    xvmcListSurfaceTypesReply rep;
    xvmcListSurfaceTypesReq  *req;
    XvMCSurfaceInfo *surface_info = NULL;

    *num = 0;

    XvMCCheckExtension (dpy, info, NULL);
    
    LockDisplay (dpy);
    XvMCGetReq (ListSurfaceTypes, req);
    req->port = port;
    if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
        UnlockDisplay (dpy);
        SyncHandle ();
        return NULL;
    }

    if(rep.num > 0) {
	surface_info = 
	    (XvMCSurfaceInfo*)Xmalloc(rep.num * sizeof(XvMCSurfaceInfo));

        if(surface_info) {
	    xvmcSurfaceInfo sinfo;
	    int i;

	    *num = rep.num;

	    for(i = 0; i < rep.num; i++) {
		_XRead(dpy, (char*)&sinfo, sizeof(xvmcSurfaceInfo));
	       surface_info[i].surface_type_id = sinfo.surface_type_id;
	       surface_info[i].chroma_format = sinfo.chroma_format;
	       surface_info[i].max_width = sinfo.max_width;
	       surface_info[i].max_height = sinfo.max_height;
	       surface_info[i].subpicture_max_width = 
					sinfo.subpicture_max_width;
	       surface_info[i].subpicture_max_height = 
					sinfo.subpicture_max_height;
	       surface_info[i].mc_type = sinfo.mc_type;
	       surface_info[i].flags = sinfo.flags;
	    }
	} else
	   _XEatData(dpy, rep.length << 2);
    }

    UnlockDisplay (dpy);
    SyncHandle ();
    return surface_info;
}
Ejemplo n.º 19
0
Bool XNVCTRLQueryGvoColorConversion (
    Display *dpy,
    int screen,
    float colorMatrix[3][3],
    float colorOffset[3],
    float colorScale[3]
) {
    XExtDisplayInfo *info = find_display (dpy);
    xnvCtrlQueryGvoColorConversionReply rep;
    xnvCtrlQueryGvoColorConversionReq *req;

    if(!XextHasExtension(info))
        return False;

    XNVCTRLCheckExtension (dpy, info, False);

    LockDisplay (dpy);

    GetReq (nvCtrlQueryGvoColorConversion, req);
    req->reqType = info->codes->major_opcode;
    req->nvReqType = X_nvCtrlQueryGvoColorConversion;
    req->screen = screen;

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

    _XRead(dpy, (char *)(colorMatrix), 36);
    _XRead(dpy, (char *)(colorOffset), 12);
    _XRead(dpy, (char *)(colorScale), 12);

    UnlockDisplay (dpy);
    SyncHandle ();

    return True;
}
Ejemplo n.º 20
0
Bool XNVCTRLQueryDDCCILutSize (
    Display *dpy,
    int screen,
    unsigned int display_mask,
    unsigned int *red_entries,
    unsigned int *green_entries,
    unsigned int *blue_entries,
    unsigned int *red_bits_per_entries,
    unsigned int *green_bits_per_entries,
    unsigned int *blue_bits_per_entries
) {
    XExtDisplayInfo *info = find_display (dpy);
    xnvCtrlQueryDDCCILutSizeReply rep;
    xnvCtrlQueryDDCCILutSizeReq *req;
    unsigned int buf[6];
    Bool exists;

    if(!XextHasExtension(info))
        return False;

    XNVCTRLCheckExtension (dpy, info, False);

    LockDisplay (dpy);

    GetReq (nvCtrlQueryDDCCILutSize, req);
    req->reqType = info->codes->major_opcode;
    req->nvReqType = X_nvCtrlQueryDDCCILutSize;
    req->screen = screen;
    req->display_mask = display_mask;

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

    _XRead(dpy, (char *)(&buf), 24);

    *red_entries = buf[0];
    *green_entries = buf[1];
    *blue_entries = buf[2];
    *red_bits_per_entries = buf[3];
    *green_bits_per_entries = buf[4];
    *blue_bits_per_entries = buf[5];

    UnlockDisplay (dpy);
    SyncHandle ();
    exists = rep.flags;
    return exists;
}
Ejemplo n.º 21
0
Archivo: XRes.c Proyecto: aosm/X11libs
Status XResQueryClients (
    Display *dpy,
    int *num_clients,
    XResClient **clients
)
{
    XExtDisplayInfo *info = find_display (dpy);
    xXResQueryClientsReq *req;
    xXResQueryClientsReply rep;
    XResClient *clnts;
    int result = 0;

    *num_clients = 0;
    *clients = NULL;

    XResCheckExtension (dpy, info, 0);

    LockDisplay (dpy);
    GetReq (XResQueryClients, req);
    req->reqType = info->codes->major_opcode;
    req->XResReqType = X_XResQueryClients;
    if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
        UnlockDisplay (dpy);
        SyncHandle ();
        return 0;
    }

    if(rep.num_clients) {
        if((clnts = Xmalloc(sizeof(XResClient) * rep.num_clients))) {
            xXResClient scratch;
            int i;

            for(i = 0; i < rep.num_clients; i++) {
                _XRead(dpy, (char*)&scratch, sz_xXResClient);
                clnts[i].resource_base = scratch.resource_base;
                clnts[i].resource_mask = scratch.resource_mask;
            }
            *clients = clnts;
            *num_clients = rep.num_clients;
            result = 1;
        } else {
            _XEatData(dpy, rep.length << 2);
        }
    }

    UnlockDisplay (dpy);
    SyncHandle ();
    return result;
}
Ejemplo n.º 22
0
static XmbufBufferInfo *read_buffer_info (Display *dpy, int nbufs)
{
    xMbufBufferInfo *netbuf = TALLOC (xMbufBufferInfo, nbufs);
    XmbufBufferInfo *bufinfo = NULL;
    long netbytes = nbufs * SIZEOF(xMbufBufferInfo);

    if (netbuf) {
	_XRead (dpy, (char *) netbuf, netbytes);

	bufinfo = TALLOC (XmbufBufferInfo, nbufs);
	if (bufinfo) {
	    register XmbufBufferInfo *c;
	    register xMbufBufferInfo *net;
	    register int i;

	    for (i = 0, c = bufinfo, net = netbuf; i < nbufs;
		 i++, c++, net++) {
		c->visualid = net->visualID;
		c->max_buffers = net->maxBuffers;
		c->depth = net->depth;
	    }
	}
	Xfree ((char *) netbuf);
    } else {				/* eat the data */
	while (netbytes > 0) {
	    char dummy[256];		/* stack size vs loops tradeoff */
	    long nbytes = sizeof dummy;

	    if (nbytes > netbytes) nbytes = netbytes;
	    _XRead (dpy, dummy, nbytes);
	    netbytes -= nbytes;
	}
    }

    return bufinfo;
}
Ejemplo n.º 23
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);
}
Ejemplo n.º 24
0
Archivo: XvMC.c Proyecto: aosm/X11libs
Status _xvmc_create_surface (
    Display *dpy,
    XvMCContext *context,
    XvMCSurface *surface,
    int *priv_count,
    CARD32 **priv_data
)
{
    XExtDisplayInfo *info = xvmc_find_display(dpy);
    xvmcCreateSurfaceReply rep;
    xvmcCreateSurfaceReq  *req;

    *priv_count = 0;
    *priv_data = NULL;

    XvMCCheckExtension (dpy, info, BadImplementation);

    LockDisplay (dpy);
    XvMCGetReq (CreateSurface, req);

    surface->surface_id = XAllocID(dpy);
    surface->context_id = context->context_id;
    surface->surface_type_id = context->surface_type_id;
    surface->width = context->width;
    surface->height = context->height;

    req->surface_id = surface->surface_id;
    req->context_id = surface->context_id;
    if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
        UnlockDisplay (dpy);
        SyncHandle ();
        return BadImplementation;
    }

    if(rep.length) {
        *priv_data = Xmalloc(rep.length << 2);
        if(*priv_data) {
            _XRead(dpy, (char*)(*priv_data), rep.length << 2);
            *priv_count = rep.length;
        } else
            _XEatData(dpy, rep.length << 2);
    }

    UnlockDisplay (dpy);
    SyncHandle ();
    return Success;
}
Ejemplo n.º 25
0
XDevice *
XOpenDevice(
    register Display	*dpy,
    register XID	 id)
{
    register long rlen;	/* raw length */
    xOpenDeviceReq *req;
    xOpenDeviceReply rep;
    XDevice *dev;
    XExtDisplayInfo *info = XInput_find_display(dpy);

    LockDisplay(dpy);
    if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1)
        return ((XDevice *) NoSuchExtension);

    GetReq(OpenDevice, req);
    req->reqType = info->codes->major_opcode;
    req->ReqType = X_OpenDevice;
    req->deviceid = id;

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

    rlen = rep.length << 2;
    dev = (XDevice *) Xmalloc(sizeof(XDevice) + rep.num_classes *
                              sizeof(XInputClassInfo));
    if (dev) {
        int dlen;	/* data length */

        dev->device_id = req->deviceid;
        dev->num_classes = rep.num_classes;
        dev->classes = (XInputClassInfo *) ((char *)dev + sizeof(XDevice));
        dlen = rep.num_classes * sizeof(xInputClassInfo);
        _XRead(dpy, (char *)dev->classes, dlen);
        /* could be padding that we still need to eat (yummy!) */
        if (rlen - dlen > 0)
            _XEatData(dpy, (unsigned long)rlen - dlen);
    } else
        _XEatData(dpy, (unsigned long)rlen);

    UnlockDisplay(dpy);
    SyncHandle();
    return (dev);
}
Ejemplo n.º 26
0
Bool XNVCTRLQueryDDCCISinglePointLutOperation (
    Display *dpy,
    int screen,
    unsigned int display_mask,
    unsigned int offset,
    unsigned int *red_value,
    unsigned int *green_value,
    unsigned int *blue_value
) {
    XExtDisplayInfo *info = find_display (dpy);
    xnvCtrlQueryDDCCISinglePointLutOperationReply rep;
    xnvCtrlQueryDDCCISinglePointLutOperationReq *req;
    unsigned int buf[4];
    Bool exists;

    if(!XextHasExtension(info))
        return False;

    XNVCTRLCheckExtension (dpy, info, False);

    LockDisplay (dpy);

    GetReq (nvCtrlQueryDDCCISinglePointLutOperation, req);
    req->reqType = info->codes->major_opcode;
    req->nvReqType = X_nvCtrlQueryDDCCISinglePointLutOperation;
    req->screen = screen;
    req->display_mask = display_mask;
    req->offset = offset;

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

    _XRead(dpy, (char *)(&buf), 12);

    *red_value = buf[0];
    *green_value = buf[1];
    *blue_value = buf[2];

    UnlockDisplay (dpy);
    SyncHandle ();

    exists=rep.flags;
    return exists;
}
Ejemplo n.º 27
0
Archivo: XERqsts.c Proyecto: aosm/X11
int XEGetStatisticsRequest(XETC *tc, XETrapGetStatsRep *ret) 
{ 
    int status = True;
    Display *dpy = tc->dpy;
    CARD32 X_XTrap = tc->extOpcode;
    xXTrapReq *reqptr;
    xXTrapGetStatsReply rep; 
    status = XEFlushConfig(tc); /* Flushout any pending configuration first */
    if (status == True)
    {
        LockDisplay(dpy); 
        GetReq(XTrap,reqptr);
        reqptr->minor_opcode = XETrap_GetStatistics;
        /* to support comm. w/ V3.1 extensions */
#ifndef CRAY
        if (tc->protocol == 31)
        {   /* this is the way we used to do it which breaks Cray's */
#ifndef VECTORED_EVENTS
            int numlongs = (1060-sizeof(xReply)+sizeof(long)-1)/sizeof(long);
#else
            int numlongs = (1544-sizeof(xReply)+sizeof(long)-1)/sizeof(long);
#endif
            status = _XReply(dpy,(xReply *)&rep,numlongs,xTrue); 
            if (status == True)
            {   /* need to shift it back into the data struct */
                xXTrapGetStatsReply tmp; 
                tmp = rep; 
                memcpy(&(rep.data),&(tmp.pad0), sizeof(rep.data));
            }
        }
        else
#endif /* CRAY */
        {   /* this is the way we do it for V3.2 */
            int numbytes = SIZEOF(xXTrapGetStatsReply) - SIZEOF(xReply);
            status = _XReply(dpy, (xReply *)&rep, 0, xFalse); 
            if (status == True)
            {
                status = _XRead(dpy, (char *)&rep.data, numbytes);
            }
        }
        SyncHandle(); 
        UnlockDisplay(dpy); 
        memcpy(ret,&(rep.data),sizeof(XETrapGetStatsRep)); 
    }
    return(status);
}
Ejemplo n.º 28
0
static __GLcontextModes *
createConfigsFromProperties(Display * dpy, int nvisuals, int nprops,
                            int screen, GLboolean tagged_only)
{
   INT32 buf[__GLX_TOTAL_CONFIG], *props;
   unsigned prop_size;
   __GLcontextModes *modes, *m;
   int i;

   if (nprops == 0)
      return NULL;

   /* FIXME: Is the __GLX_MIN_CONFIG_PROPS test correct for FBconfigs? */

   /* Check number of properties */
   if (nprops < __GLX_MIN_CONFIG_PROPS || nprops > __GLX_MAX_CONFIG_PROPS)
      return NULL;

   /* Allocate memory for our config structure */
   modes = _gl_context_modes_create(nvisuals, sizeof(__GLcontextModes));
   if (!modes)
      return NULL;

   prop_size = nprops * __GLX_SIZE_INT32;
   if (prop_size <= sizeof(buf))
      props = buf;
   else
      props = Xmalloc(prop_size);

   /* Read each config structure and convert it into our format */
   m = modes;
   for (i = 0; i < nvisuals; i++) {
      _XRead(dpy, (char *) props, prop_size);
      /* Older X servers don't send this so we default it here. */
      m->drawableType = GLX_WINDOW_BIT;
      __glXInitializeVisualConfigFromTags(m, nprops, props,
                                     tagged_only, GL_TRUE);
      m->screen = screen;
      m = m->next;
   }

   if (props != buf)
      Xfree(props);

   return modes;
}
Ejemplo n.º 29
0
int
XQueryColors(
    register Display *dpy,
    Colormap cmap,
    XColor *defs, 		/* RETURN */
    int ncolors)
{
    register int i;
    xrgb *color;
    xQueryColorsReply rep;
    long nbytes;
    register xQueryColorsReq *req;

    LockDisplay(dpy);
    GetReq(QueryColors, req);

    req->cmap = cmap;
    req->length += 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) {
	if ((color = (xrgb *)
	    Xmalloc((unsigned) (nbytes = (long) ncolors * SIZEOF(xrgb))))) {

	    _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((char *)color);
	}
	else _XEatData(dpy, (unsigned long) nbytes);
    }
    UnlockDisplay(dpy);
    SyncHandle();
    return 1;
}
Ejemplo n.º 30
0
static char *
__glXQueryServerString(Display * dpy, int opcode, CARD32 screen, CARD32 name)
{
   xGLXGenericGetStringReq *req;
   xGLXSingleReply reply;
   int length;
   int numbytes;
   char *buf;
   CARD32 for_whom = screen;
   CARD32 glxCode = X_GLXQueryServerString;


   LockDisplay(dpy);


   /* All of the GLX protocol requests for getting a string from the server
    * look the same.  The exact meaning of the for_whom field is usually
    * either the screen number (for glXQueryServerString) or the context tag
    * (for GLXSingle).
    */

   GetReq(GLXGenericGetString, req);
   req->reqType = opcode;
   req->glxCode = glxCode;
   req->for_whom = for_whom;
   req->name = name;

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

   length = reply.length * 4;
   numbytes = reply.size;

   buf = (char *) Xmalloc(numbytes);
   if (buf != NULL) {
      _XRead(dpy, buf, numbytes);
      length -= numbytes;
   }

   _XEatData(dpy, length);

   UnlockDisplay(dpy);
   SyncHandle();

   return buf;
}