Ejemplo n.º 1
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.º 2
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.º 3
0
Bool
_vdp_DRI2Connect(Display * dpy, XID window, char **driverName, char **deviceName)
{
   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
   xDRI2ConnectReply rep;
   xDRI2ConnectReq *req;

   XextCheckExtension(dpy, info, dri2ExtensionName, False);

   LockDisplay(dpy);
   GetReq(DRI2Connect, req);
   req->reqType = info->codes->major_opcode;
   req->dri2ReqType = X_DRI2Connect;
   req->window = window;
   req->driverType = DRI2DriverVDPAU;
   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
      UnlockDisplay(dpy);
      SyncHandle();
      return False;
   }

   if (rep.driverNameLength == 0 && rep.deviceNameLength == 0) {
      UnlockDisplay(dpy);
      SyncHandle();
      return False;
   }

   *driverName = Xmalloc(rep.driverNameLength + 1);
   if (*driverName == NULL) {
      _XEatData(dpy,
                ((rep.driverNameLength + 3) & ~3) +
                ((rep.deviceNameLength + 3) & ~3));
      UnlockDisplay(dpy);
      SyncHandle();
      return False;
   }
   _XReadPad(dpy, *driverName, rep.driverNameLength);
   (*driverName)[rep.driverNameLength] = '\0';

   *deviceName = Xmalloc(rep.deviceNameLength + 1);
   if (*deviceName == NULL) {
      Xfree(*driverName);
      _XEatData(dpy, ((rep.deviceNameLength + 3) & ~3));
      UnlockDisplay(dpy);
      SyncHandle();
      return False;
   }
   _XReadPad(dpy, *deviceName, rep.deviceNameLength);
   (*deviceName)[rep.deviceNameLength] = '\0';

   UnlockDisplay(dpy);
   SyncHandle();

   return True;
}
Ejemplo n.º 4
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.º 5
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.º 6
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.º 7
0
const char *
XFixesGetCursorName (Display *dpy, Cursor cursor, Atom *atom)
{
    XFixesExtDisplayInfo	*info = XFixesFindDisplay (dpy);
    xXFixesGetCursorNameReq	*req;
    xXFixesGetCursorNameReply	rep;
    char			*name;

    XFixesCheckExtension (dpy, info, NULL);
    if (info->major_version < 2)
	return NULL;
    LockDisplay (dpy);
    GetReq (XFixesGetCursorName, req);
    req->reqType = info->codes->major_opcode;
    req->xfixesReqType = X_XFixesGetCursorName;
    req->cursor = cursor;
    if (!_XReply (dpy, (xReply *) &rep, 0, xFalse))
    {
	UnlockDisplay (dpy);
	SyncHandle ();
	return NULL;
    }
    *atom = rep.atom;
    if ((name = (char *) Xmalloc(rep.nbytes+1))) {
	_XReadPad(dpy, name, (long)rep.nbytes);
	name[rep.nbytes] = '\0';
    } else {
	_XEatData(dpy, (unsigned long) (rep.nbytes + 3) & ~3);
	name = (char *) NULL;
    }
    UnlockDisplay(dpy);
    SyncHandle();
    return(name);
}
Ejemplo n.º 8
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.º 9
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);
}
DRI2Buffer *
DRI2GetBuffersWithFormat(Display * dpy, XID drawable,
                         int *width, int *height,
                         unsigned int *attachments, int count, int *outCount)
{
   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
   xDRI2GetBuffersReply rep;
   xDRI2GetBuffersReq *req;
   DRI2Buffer *buffers;
   xDRI2Buffer repBuffer;
   CARD32 *p;
   int i;

   XextCheckExtension(dpy, info, dri2ExtensionName, False);

   LockDisplay(dpy);
   GetReqExtra(DRI2GetBuffers, count * (4 * 2), req);
   req->reqType = info->codes->major_opcode;
   req->dri2ReqType = X_DRI2GetBuffersWithFormat;
   req->drawable = drawable;
   req->count = count;
   p = (CARD32 *) & req[1];
   for (i = 0; i < (count * 2); i++)
      p[i] = attachments[i];

   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
	  fprintf(stderr, "GetBuffersWithFormat fails\n");
      UnlockDisplay(dpy);
      SyncHandle();
      return NULL;
   }

   *width = rep.width;
   *height = rep.height;
   *outCount = rep.count;

   buffers = Xmalloc(rep.count * sizeof buffers[0]);
   if (buffers == NULL) {
      _XEatData(dpy, rep.count * sizeof repBuffer);
      UnlockDisplay(dpy);
      SyncHandle();
      return NULL;
   }

   for (i = 0; i < rep.count; i++) {
      _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer);
      buffers[i].attachment = repBuffer.attachment;
      buffers[i].name = repBuffer.name;
      buffers[i].pitch = repBuffer.pitch;
      buffers[i].cpp = repBuffer.cpp;
      buffers[i].flags = repBuffer.flags;
   }

   UnlockDisplay(dpy);
   SyncHandle();

   return buffers;
}
Ejemplo n.º 11
0
void
__glXReadPixelReply(Display * dpy, struct glx_context * gc, unsigned max_dim,
                    GLint width, GLint height, GLint depth, GLenum format,
                    GLenum type, void *dest, GLboolean dimensions_in_reply)
{
   xGLXSingleReply reply;
   GLint size;

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

   if (dimensions_in_reply) {
      width = reply.pad3;
      height = reply.pad4;
      depth = reply.pad5;

      if ((height == 0) || (max_dim < 2)) {
         height = 1;
      }
      if ((depth == 0) || (max_dim < 3)) {
         depth = 1;
      }
   }

   size = reply.length * 4;
   if (size != 0) {
      void *buf = Xmalloc(size);

      if (buf == NULL) {
         _XEatData(dpy, size);
         __glXSetError(gc, GL_OUT_OF_MEMORY);
      }
      else {
         const GLint extra = 4 - (size & 3);

         _XRead(dpy, buf, size);
         if (extra < 4) {
            _XEatData(dpy, extra);
         }

         __glEmptyImage(gc, 3, width, height, depth, format, type, buf, dest);
         Xfree(buf);
      }
   }
}
Ejemplo n.º 12
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.º 13
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.º 14
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.º 15
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.º 16
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.º 17
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.º 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
Archivo: singlepix.c Proyecto: aosm/X11
void glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type,
		   GLvoid *texels)
{
    __GLX_SINGLE_DECLARE_VARIABLES();
    const __GLXattribute * state;
    xGLXGetTexImageReply reply;
    GLubyte *buf;

    if (!dpy) return;
    __GLX_SINGLE_LOAD_VARIABLES();
    state = gc->client_state_private;

    /* Send request */
    __GLX_SINGLE_BEGIN(X_GLsop_GetTexImage,__GLX_PAD(17));
    __GLX_SINGLE_PUT_LONG(0,target);
    __GLX_SINGLE_PUT_LONG(4,level);
    __GLX_SINGLE_PUT_LONG(8,format);
    __GLX_SINGLE_PUT_LONG(12,type);
    __GLX_SINGLE_PUT_CHAR(16,state->storePack.swapEndian);
    __GLX_SINGLE_READ_XREPLY();
    compsize = reply.length << 2;

    if (compsize != 0) {
	/* Allocate a holding buffer to transform the data from */
	buf = (GLubyte*) Xmalloc(compsize);
	if (!buf) {
	    /* Throw data away */
	    _XEatData(dpy, compsize);
	    __glXSetError(gc, GL_OUT_OF_MEMORY);
	} else {
	    GLint width, height, depth;

	    /*
	    ** Fetch data into holding buffer.  Apply pixel store pack modes
	    ** to put data back into client memory
	    */
	    width = reply.width;
	    height = reply.height;
	    depth = reply.depth;
	    __GLX_SINGLE_GET_CHAR_ARRAY(buf,compsize);
	    __glEmptyImage(gc, 2, width, height, depth, format, type, buf,
			   texels);
	    Xfree((char*) buf);
	}
    } else {
	/*
	** GL error occured, don't modify user's buffer.
	*/
    }
    __GLX_SINGLE_END();
}
Ejemplo n.º 20
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.º 21
0
Archivo: singlepix.c Proyecto: aosm/X11
void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
		  GLenum format, GLenum type, GLvoid *pixels)
{
    __GLX_SINGLE_DECLARE_VARIABLES();
    const __GLXattribute * state;
    xGLXReadPixelsReply reply;
    GLubyte *buf;

    if (!dpy) return;
    __GLX_SINGLE_LOAD_VARIABLES();
    state = gc->client_state_private;

    /* Send request */
    __GLX_SINGLE_BEGIN(X_GLsop_ReadPixels,__GLX_PAD(26));
    __GLX_SINGLE_PUT_LONG(0,x);
    __GLX_SINGLE_PUT_LONG(4,y);
    __GLX_SINGLE_PUT_LONG(8,width);
    __GLX_SINGLE_PUT_LONG(12,height);
    __GLX_SINGLE_PUT_LONG(16,format);
    __GLX_SINGLE_PUT_LONG(20,type);
    __GLX_SINGLE_PUT_CHAR(24,state->storePack.swapEndian);
    __GLX_SINGLE_PUT_CHAR(25,GL_FALSE);
    __GLX_SINGLE_READ_XREPLY();
    compsize = reply.length << 2;

    if (compsize != 0) {
	/* Allocate a holding buffer to transform the data from */
	buf = (GLubyte*) Xmalloc(compsize);
	if (!buf) {
	    /* Throw data away */
	    _XEatData(dpy, compsize);
	    __glXSetError(gc, GL_OUT_OF_MEMORY);
	} else {
	    /*
	    ** Fetch data into holding buffer.  Apply pixel store pack modes
	    ** to put data back into client memory
	    */
	    __GLX_SINGLE_GET_CHAR_ARRAY(buf,compsize);
	    __glEmptyImage(gc, 2, width, height, 1, format, type, buf, pixels);
	    Xfree((char*) buf);
	}
    } else {
	/*
	** GL error occurred; don't modify user's buffer.
	*/
    }
    __GLX_SINGLE_END();
}
Ejemplo n.º 22
0
Archivo: singlepix.c Proyecto: aosm/X11
void glGetHistogram(GLenum target, GLboolean reset, GLenum format,
		    GLenum type, GLvoid *values)
{
    __GLX_SINGLE_DECLARE_VARIABLES();
    const __GLXattribute * state;
    xGLXGetHistogramReply reply;
    GLubyte *buf;

    if (!dpy) return;
    __GLX_SINGLE_LOAD_VARIABLES();
    state = gc->client_state_private;

    /* Send request */
    __GLX_SINGLE_BEGIN(X_GLsop_GetHistogram,__GLX_PAD(14));
    __GLX_SINGLE_PUT_LONG(0,(long)target);
    __GLX_SINGLE_PUT_LONG(4,(long)format);
    __GLX_SINGLE_PUT_LONG(8,(long)type);
    __GLX_SINGLE_PUT_CHAR(12,state->storePack.swapEndian);
    __GLX_SINGLE_PUT_CHAR(13,reset);
    __GLX_SINGLE_READ_XREPLY();
    compsize = (long)reply.length << 2;

    if (compsize != 0) {
        /* Allocate a holding buffer to transform the data from */
        buf = (GLubyte*)Xmalloc(compsize);
        if (!buf) {
            /* Throw data away */
            _XEatData(dpy, compsize);
            __glXSetError(gc, GL_OUT_OF_MEMORY);
        } else {
            GLint width;

            /*
            ** Fetch data into holding buffer.  Apply pixel store pack modes
            ** to put data back into client memory
            */
            width = (int)reply.width;
            __GLX_SINGLE_GET_CHAR_ARRAY(((char*)buf),(long)compsize);
            __glEmptyImage(gc, 1, width, 1, 1, format, type, buf, values);
            Xfree((char*) buf);
        }
    } else {
        /*
        ** GL error occured, don't modify user's buffer.
        */
    }
    __GLX_SINGLE_END();
}
Ejemplo n.º 23
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.º 24
0
void glGetConvolutionFilter(GLenum target, GLenum format, GLenum type,
			    GLvoid *image)
{
    __GLX_SINGLE_DECLARE_VARIABLES();
    xGLXGetConvolutionFilterReply reply;
    GLubyte *buf;

    if (!dpy) return;
    __GLX_SINGLE_LOAD_VARIABLES();

    /* Send request */
    __GLX_SINGLE_BEGIN(X_GLsop_GetConvolutionFilter, __GLX_PAD(13));
    __GLX_SINGLE_PUT_LONG(0,target);
    __GLX_SINGLE_PUT_LONG(4,format);
    __GLX_SINGLE_PUT_LONG(8,type);
    __GLX_SINGLE_PUT_CHAR(12,gc->state.storePack.swapEndian);
    __GLX_SINGLE_READ_XREPLY();
    compsize = reply.length << 2;

    if (compsize != 0) {
	/* Allocate a holding buffer to transform the data from */
	buf = (GLubyte*) Xmalloc(compsize);
	if (!buf) {
	    /* Throw data away */
	    _XEatData(dpy, compsize);
	    __glXSetError(gc, GL_OUT_OF_MEMORY);
	} else {
	    GLint width, height;

	    /*
	    ** Fetch data into holding buffer.  Apply pixel store pack modes
	    ** to put data back into client memory
	    */
	    width = reply.width;
	    height = reply.height;
	    __GLX_SINGLE_GET_CHAR_ARRAY(((char*)buf),compsize);
	    __glEmptyImage(gc, 2, width, height, 1, format, type, buf, image);
	    Xfree((char*) buf);
	}
    } else {
	/*
	** GL error occured, don't modify user's buffer.
	*/
    }
    __GLX_SINGLE_END();
}
Ejemplo n.º 25
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.º 26
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;
}
Ejemplo n.º 27
0
int
XiGMiscQueryResolutions(Display * dpy, int screen, int view, int *pactive,
                        XiGMiscResolutionInfo ** presolutions)
{
    int n, size;
    XiGMiscResolutionInfo *resolutions;
    xXiGMiscQueryResolutionsReq *req;
    xXiGMiscQueryResolutionsReply rep;
    XExtDisplayInfo *info = XiGMiscFindDisplay(dpy);
    XiGMiscCheckExtension(dpy, info, 0);

    LockDisplay(dpy);
    XiGMiscGetReq(XiGMiscQueryResolutions, req, info);
    req->screen = screen;
    req->view = view;

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

    n = rep.nresolutions;

    if (n > 0) {
        size = sizeof(XiGMiscResolutionInfo) * n;
        resolutions = (XiGMiscResolutionInfo *) Xmalloc(size);
        if (!resolutions) {
            _XEatData(dpy, (unsigned long) size);
            UnlockDisplay(dpy);
            SyncHandle();
            return 0;
        }

        _XReadPad(dpy, (void *) resolutions, size);

        *presolutions = resolutions;
        *pactive = rep.active;
    }

    UnlockDisplay(dpy);
    SyncHandle();

    return n;
}
Ejemplo n.º 28
0
int
XiGMiscQueryViews(Display * dpy, int screen, XiGMiscViewInfo ** pviews)
{
    int n, size;
    XiGMiscViewInfo *views;
    xXiGMiscQueryViewsReq *req;
    xXiGMiscQueryViewsReply rep;
    XExtDisplayInfo *info = XiGMiscFindDisplay(dpy);
    XiGMiscCheckExtension(dpy, info, 0);

    LockDisplay(dpy);
    XiGMiscGetReq(XiGMiscQueryViews, req, info);
    req->screen = screen;

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

    n = rep.nviews;

    if (n > 0) {
        size = sizeof(XiGMiscViewInfo) * n;
        views = (XiGMiscViewInfo *) Xmalloc(size);
        if (!views) {
            _XEatData(dpy, (unsigned long) size);
            UnlockDisplay(dpy);
            SyncHandle();
            return 0;
        }

        _XReadPad(dpy, (void *) views, size);

        *pviews = views;
    }

    UnlockDisplay(dpy);
    SyncHandle();

    return n;
}
Ejemplo n.º 29
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) {
	    _XEatData(dpy, (unsigned long) nbytes);
	    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;
}
Ejemplo n.º 30
0
XModifierKeymap *
XGetDeviceModifierMapping(
    register Display	*dpy,
    XDevice		*dev)
{
    unsigned long nbytes;
    XModifierKeymap *res;
    xGetDeviceModifierMappingReq *req;
    xGetDeviceModifierMappingReply rep;
    XExtDisplayInfo *info = XInput_find_display(dpy);

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

    GetReq(GetDeviceModifierMapping, req);
    req->reqType = info->codes->major_opcode;
    req->ReqType = X_GetDeviceModifierMapping;
    req->deviceid = dev->device_id;

    if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
	UnlockDisplay(dpy);
	SyncHandle();
	return (XModifierKeymap *) NULL;
    }
    nbytes = (unsigned long)rep.length << 2;
    res = (XModifierKeymap *) Xmalloc(sizeof(XModifierKeymap));
    if (res) {
	res->modifiermap = (KeyCode *) Xmalloc(nbytes);
	if (res->modifiermap)
	    _XReadPad(dpy, (char *)res->modifiermap, nbytes);
	else
	    _XEatData(dpy, (unsigned long)nbytes);
	res->max_keypermod = rep.numKeyPerModifier;
    }

    UnlockDisplay(dpy);
    SyncHandle();
    return (res);
}