static void reply_XIPassiveGrabDevice(ClientPtr client, int len, char *data, void *userdata)
{
    xXIPassiveGrabDeviceReply *rep = (xXIPassiveGrabDeviceReply*)data;

    if (client->swapped)
    {
        swaps(&rep->sequenceNumber);
        swapl(&rep->length);
        swaps(&rep->num_modifiers);

        testdata.num_modifiers = rep->num_modifiers;
    }

    reply_check_defaults(rep, len, XIPassiveGrabDevice);

    /* ProcXIPassiveGrabDevice sends the data in two batches, let the second
     * handler handle the modifier data */
    if (rep->num_modifiers > 0)
        reply_handler = reply_XIPassiveGrabDevice_data;
}
Beispiel #2
0
int pciconfig_write(
          unsigned char bus,
          unsigned char dev,
          unsigned char offset,
          int len,		/* unused, alway 4 */
          unsigned long val)
{
	unsigned long _val;
	unsigned long *ptr;

	dev >>= 3;
	_val = swapl(val);
	if (bus || dev >= 16) {
		return PCIBIOS_DEVICE_NOT_FOUND;
	} else {
		ptr = (unsigned long *)(pciConfBase + ((1<<dev) | offset));
		*ptr = _val;
	}
	return PCIBIOS_SUCCESSFUL;
}
int
ProcRRXineramaQueryVersion(ClientPtr client)
{
    xPanoramiXQueryVersionReply rep;

    REQUEST_SIZE_MATCH(xPanoramiXQueryVersionReq);
    rep.type = X_Reply;
    rep.sequenceNumber = client->sequence;
    rep.length = 0;
    rep.majorVersion = SERVER_RRXINERAMA_MAJOR_VERSION;
    rep.minorVersion = SERVER_RRXINERAMA_MINOR_VERSION;
    if (client->swapped) {
        swaps(&rep.sequenceNumber);
        swapl(&rep.length);
        swaps(&rep.majorVersion);
        swaps(&rep.minorVersion);
    }
    WriteToClient(client, sizeof(xPanoramiXQueryVersionReply), &rep);
    return Success;
}
Beispiel #4
0
void
XkbSendMapNotify(DeviceIntPtr kbd,xkbMapNotify *pMN)
{
int 		i;
XkbSrvInfoPtr	xkbi;
unsigned	time = 0,initialized;
CARD16		changed;

    xkbi = kbd->key->xkbInfo;
    initialized= 0;

    changed = pMN->changed;
    pMN->minKeyCode= xkbi->desc->min_key_code;
    pMN->maxKeyCode= xkbi->desc->max_key_code;
    for (i=1; i<currentMaxClients; i++) {
        if (clients[i] && ! clients[i]->clientGone &&
	    (clients[i]->requestVector != InitialVector) &&
	    (clients[i]->xkbClientFlags&_XkbClientInitialized) &&
	    (clients[i]->mapNotifyMask&changed))
	{
	    if (!initialized) {
		pMN->type = XkbEventCode + XkbEventBase;
		pMN->xkbType = XkbMapNotify;
		pMN->deviceID = kbd->id;
		time = GetTimeInMillis();
		initialized= 1;
	    }
	    pMN->time= time;
	    pMN->sequenceNumber = clients[i]->sequence;
	    pMN->changed = changed;
	    if ( clients[i]->swapped ) {
		register int n;
		swaps(&pMN->sequenceNumber,n);
		swapl(&pMN->time,n);
		swaps(&pMN->changed,n);
	    }
	    WriteToClient(clients[i],sizeof(xEvent),(char *)pMN);
	}
    }
    return;
}
Beispiel #5
0
static int
ProcShapeQueryVersion(ClientPtr client)
{
    xShapeQueryVersionReply rep;

    REQUEST_SIZE_MATCH(xShapeQueryVersionReq);
    memset(&rep, 0, sizeof(xShapeQueryVersionReply));
    rep.type = X_Reply;
    rep.length = 0;
    rep.sequenceNumber = client->sequence;
    rep.majorVersion = SERVER_SHAPE_MAJOR_VERSION;
    rep.minorVersion = SERVER_SHAPE_MINOR_VERSION;
    if (client->swapped) {
        swaps(&rep.sequenceNumber);
        swapl(&rep.length);
        swaps(&rep.majorVersion);
        swaps(&rep.minorVersion);
    }
    WriteToClient(client, sizeof(xShapeQueryVersionReply), (char *) &rep);
    return Success;
}
Beispiel #6
0
static int
ProcAppleDRIQueryVersion(
    register ClientPtr client
)
{
    xAppleDRIQueryVersionReply rep;

    REQUEST_SIZE_MATCH(xAppleDRIQueryVersionReq);
    rep.type = X_Reply;
    rep.length = 0;
    rep.sequenceNumber = client->sequence;
    rep.majorVersion = SERVER_APPLEDRI_MAJOR_VERSION;
    rep.minorVersion = SERVER_APPLEDRI_MINOR_VERSION;
    rep.patchVersion = SERVER_APPLEDRI_PATCH_VERSION;
    if (client->swapped) {
        swaps(&rep.sequenceNumber);
        swapl(&rep.length);
    }
    WriteToClient(client, sizeof(xAppleDRIQueryVersionReply), (char *)&rep);
    return Success;
}
Beispiel #7
0
static int
ProcEVIQueryVersion(ClientPtr client)
{
    /* REQUEST(xEVIQueryVersionReq); */
    xEVIQueryVersionReply rep;
    register int n;
    REQUEST_SIZE_MATCH (xEVIQueryVersionReq);
    rep.type = X_Reply;
    rep.length = 0;
    rep.sequenceNumber = client->sequence;
    rep.majorVersion = XEVI_MAJOR_VERSION;
    rep.minorVersion = XEVI_MAJOR_VERSION;
    if (client->swapped) {
    	swaps(&rep.sequenceNumber, n);
    	swapl(&rep.length, n);
	swaps(&rep.majorVersion, n);
	swaps(&rep.minorVersion, n);
    }
    WriteToClient(client, sizeof (xEVIQueryVersionReply), (char *)&rep);
    return (client->noClientException);
}
Beispiel #8
0
int pciconfig_read(
    unsigned char bus,
    unsigned char dev,
    unsigned char offset,
    int len,		/* unused, alway 4 */
    unsigned long *val)
{
    unsigned long _val;
    unsigned long *ptr;

    dev >>= 3;
    if (bus || dev >= 16) {
        *val = 0xFFFFFFFF;
        return PCIBIOS_DEVICE_NOT_FOUND;
    } else {
        ptr = (unsigned long *)(pciConfBase + ((1<<dev) | offset));
        _val = swapl(*ptr);
    }
    *val = _val;
    return PCIBIOS_SUCCESSFUL;
}
Beispiel #9
0
void
ResetCurrentRequest(ClientPtr client)
{
    OsCommPtr oc = (OsCommPtr) client->osPrivate;
    register ConnectionInputPtr oci = oc->input;
    int fd = oc->fd;
    register xReq *request;
    int gotnow, needed;

    if (AvailableInput == oc)
        AvailableInput = (OsCommPtr) NULL;
    oci->lenLastReq = 0;
    gotnow = oci->bufcnt + oci->buffer - oci->bufptr;
    if (gotnow < sizeof(xReq)) {
        YieldControlNoInput(fd);
    }
    else {
        request = (xReq *) oci->bufptr;
        needed = get_req_len(request, client);
        if (!needed && client->big_requests) {
            oci->bufptr -= sizeof(xBigReq) - sizeof(xReq);
            *(xReq *) oci->bufptr = *request;
            ((xBigReq *) oci->bufptr)->length = client->req_len;
            if (client->swapped) {
                swapl(&((xBigReq *) oci->bufptr)->length);
            }
        }
        if (gotnow >= (needed << 2)) {
            if (FD_ISSET(fd, &AllClients)) {
                FD_SET(fd, &ClientsWithInput);
            }
            else {
                FD_SET(fd, &IgnoredClientsWithInput);
            }
            YieldControl();
        }
        else
            YieldControlNoInput(fd);
    }
}
Beispiel #10
0
static int
ProcShapeInputSelected(ClientPtr client)
{
    REQUEST(xShapeInputSelectedReq);
    WindowPtr pWin;
    ShapeEventPtr pShapeEvent, *pHead;
    int enabled, rc;
    xShapeInputSelectedReply rep;

    REQUEST_SIZE_MATCH(xShapeInputSelectedReq);
    rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
    if (rc != Success)
        return rc;
    rc = dixLookupResourceByType((pointer *) &pHead, pWin->drawable.id,
                                 ShapeEventType, client, DixReadAccess);
    if (rc != Success && rc != BadValue)
        return rc;
    enabled = xFalse;
    if (pHead) {
        for (pShapeEvent = *pHead; pShapeEvent; pShapeEvent = pShapeEvent->next) {
            if (pShapeEvent->client == client) {
                enabled = xTrue;
                break;
            }
        }
    }

    rep.type = X_Reply;
    rep.enabled = enabled;
    rep.sequenceNumber = client->sequence;
    rep.length = 0;

    if (client->swapped) {
        swaps(&rep.sequenceNumber);
        swapl(&rep.length);
    }
    WriteToClient(client, sizeof(xShapeInputSelectedReply), &rep);
    return Success;
}
Beispiel #11
0
static int
ProcAppleWMQueryVersion(
    register ClientPtr client
)
{
    xAppleWMQueryVersionReply rep;
    register int n;

    REQUEST_SIZE_MATCH(xAppleWMQueryVersionReq);
    rep.type = X_Reply;
    rep.length = 0;
    rep.sequenceNumber = client->sequence;
    rep.majorVersion = APPLE_WM_MAJOR_VERSION;
    rep.minorVersion = APPLE_WM_MINOR_VERSION;
    rep.patchVersion = APPLE_WM_PATCH_VERSION;
    if (client->swapped) {
    	swaps(&rep.sequenceNumber, n);
    	swapl(&rep.length, n);
    }
    WriteToClient(client, sizeof(xAppleWMQueryVersionReply), (char *)&rep);
    return (client->noClientException);
}
Beispiel #12
0
static int
ProcXResQueryVersion (ClientPtr client)
{
    REQUEST(xXResQueryVersionReq);
    xXResQueryVersionReply rep;

    REQUEST_SIZE_MATCH (xXResQueryVersionReq);

    rep.type = X_Reply;
    rep.length = 0;
    rep.sequenceNumber = client->sequence;
    rep.server_major = SERVER_XRES_MAJOR_VERSION;
    rep.server_minor = SERVER_XRES_MINOR_VERSION;
    if (client->swapped) { 
        swaps(&rep.sequenceNumber);
        swapl(&rep.length);
        swaps(&rep.server_major);
        swaps(&rep.server_minor);
    }
    WriteToClient(client, sizeof (xXResQueryVersionReply), (char *)&rep);
    return Success;
}
Beispiel #13
0
static int
ProcXF86DRIQueryDirectRenderingCapable(
    register ClientPtr client
)
{
    xXF86DRIQueryDirectRenderingCapableReply	rep;
    Bool isCapable;
    register int n;

    REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
    REQUEST_SIZE_MATCH(xXF86DRIQueryDirectRenderingCapableReq);
    if (stuff->screen >= screenInfo.numScreens) {
	client->errorValue = stuff->screen;
	return BadValue;
    }

    rep.type = X_Reply;
    rep.length = 0;
    rep.sequenceNumber = client->sequence;

    if (!DRIQueryDirectRenderingCapable( screenInfo.screens[stuff->screen], 
					 &isCapable)) {
	return BadValue;
    }
    rep.isCapable = isCapable;

    if (!LocalClient(client) || client->swapped)
	rep.isCapable = 0;

    if (client->swapped) {
    	swaps(&rep.sequenceNumber, n);
    	swapl(&rep.length, n);
    }

    WriteToClient(client, 
	sizeof(xXF86DRIQueryDirectRenderingCapableReply), (char *)&rep);
    return (client->noClientException);
}
Beispiel #14
0
void
XkbSendNewKeyboardNotify(DeviceIntPtr kbd, xkbNewKeyboardNotify * pNKN)
{
    int i;
    Time time = GetTimeInMillis();
    CARD16 changed = pNKN->changed;

    pNKN->type = XkbEventCode + XkbEventBase;
    pNKN->xkbType = XkbNewKeyboardNotify;

    for (i = 1; i < currentMaxClients; i++) {
        if (!clients[i] || clients[i]->clientState != ClientStateRunning)
            continue;

        if (!(clients[i]->newKeyboardNotifyMask & changed))
            continue;

        pNKN->sequenceNumber = clients[i]->sequence;
        pNKN->time = time;
        pNKN->changed = changed;
        if (clients[i]->swapped) {
            swaps(&pNKN->sequenceNumber);
            swapl(&pNKN->time);
            swaps(&pNKN->changed);
        }
        WriteToClient(clients[i], sizeof(xEvent), pNKN);

        if (changed & XkbNKN_KeycodesMask) {
            clients[i]->minKC = pNKN->minKeyCode;
            clients[i]->maxKC = pNKN->maxKeyCode;
        }
    }

    XkbSendLegacyMapNotify(kbd, XkbNewKeyboardNotify, changed, pNKN->minKeyCode,
                           pNKN->maxKeyCode - pNKN->minKeyCode + 1);

    return;
}
static void reply_XIPassiveGrabDevice_data(ClientPtr client, int len, char *data, void *userdata)
{
    int i;

    xXIGrabModifierInfo *mods = (xXIGrabModifierInfo*)data;

    for (i = 0; i < testdata.num_modifiers; i++, mods++)
    {
        if (client->swapped)
            swapl(&mods->modifiers);

        /* 1 - 7 is the range we use for the global modifiers array
         * above */
        assert(mods->modifiers > 0);
        assert(mods->modifiers <= 7);
        assert(mods->modifiers % 2 == 1); /* because we fail odd ones */
        assert(mods->status != Success);
        assert(mods->pad0 == 0);
        assert(mods->pad1 == 0);
    }

    reply_handler = reply_XIPassiveGrabDevice;
}
Beispiel #16
0
static void SRawEvent(xXIRawEvent *from, xXIRawEvent *to)
{
    char n;
    int i;
    FP3232 *values;
    unsigned char *mask;

    memcpy(to, from, sizeof(xEvent) + from->length * 4);

    swaps(&to->sequenceNumber, n);
    swapl(&to->length, n);
    swaps(&to->evtype, n);
    swaps(&to->deviceid, n);
    swapl(&to->time, n);
    swapl(&to->detail, n);


    mask = (unsigned char*)&to[1];
    values = (FP3232*)(mask + from->valuators_len * 4);

    for (i = 0; i < from->valuators_len * 4 * 8; i++)
    {
        if (BitIsOn(mask, i))
        {
            /* for each bit set there are two FP3232 values on the wire, in
             * the order abcABC for data and data_raw. Here we swap as if
             * they were in aAbBcC order because it's easier and really
             * doesn't matter.
             */
            swapl(&values->integral, n);
            swapl(&values->frac, n);
            values++;
            swapl(&values->integral, n);
            swapl(&values->frac, n);
            values++;
        }
    }

    swaps(&to->valuators_len, n);
}
Beispiel #17
0
static 
int ProcXagQueryVersion(
    register ClientPtr client)
{
    /* REQUEST (xXagQueryVersionReq); */
    xXagQueryVersionReply rep;
    register int n;

    REQUEST_SIZE_MATCH (xXagQueryVersionReq);
    rep.type = X_Reply;
    rep.length = 0;
    rep.sequence_number = client->sequence;
    rep.server_major_version = XAG_MAJOR_VERSION;
    rep.server_minor_version = XAG_MINOR_VERSION;
    if (client->swapped) {
    	swaps (&rep.sequence_number, n);
    	swapl (&rep.length, n);
    	swaps (&rep.server_major_version, n);
    	swaps (&rep.server_minor_version, n);
    }
    WriteToClient (client, sizeof (xXagQueryVersionReply), (char *)&rep);
    return client->noClientException;
}
Beispiel #18
0
/*
 * This function sends out XKB mapping notify events to clients which
 * have explicitly selected for them.  Core and Xi events are handled by
 * XkbSendLegacyMapNotify. */
void
XkbSendMapNotify(DeviceIntPtr kbd, xkbMapNotify * pMN)
{
    int i;
    CARD32 time = GetTimeInMillis();
    CARD16 changed = pMN->changed;
    XkbSrvInfoPtr xkbi = kbd->key->xkbInfo;

    pMN->minKeyCode = xkbi->desc->min_key_code;
    pMN->maxKeyCode = xkbi->desc->max_key_code;
    pMN->type = XkbEventCode + XkbEventBase;
    pMN->xkbType = XkbMapNotify;
    pMN->deviceID = kbd->id;

    /* 0 is serverClient. */
    for (i = 1; i < currentMaxClients; i++) {
        if (!clients[i] || clients[i]->clientState != ClientStateRunning)
            continue;

        if (!(clients[i]->mapNotifyMask & changed))
            continue;

        pMN->time = time;
        pMN->sequenceNumber = clients[i]->sequence;
        pMN->changed = changed;

        if (clients[i]->swapped) {
            swaps(&pMN->sequenceNumber);
            swapl(&pMN->time);
            swaps(&pMN->changed);
        }
        WriteToClient(clients[i], sizeof(xEvent), pMN);
    }

    XkbSendLegacyMapNotify(kbd, XkbMapNotify, changed, pMN->firstKeySym,
                           pMN->nKeySyms);
}
static void
request_XISetClientPointer(xXISetClientPointerReq * req, int error)
{
    int rc;

    client_request = init_client(req->length, req);

    rc = ProcXISetClientPointer(&client_request);
    assert(rc == error);

    if (rc == BadDevice)
        assert(client_request.errorValue == req->deviceid);

    client_request.swapped = TRUE;
    swapl(&req->win);
    swaps(&req->length);
    swaps(&req->deviceid);
    rc = SProcXISetClientPointer(&client_request);
    assert(rc == error);

    if (rc == BadDevice)
        assert(client_request.errorValue == req->deviceid);

}
static void
request_XIGetClientPointer(ClientPtr client, xXIGetClientPointerReq * req,
                           int error)
{
    int rc;

    test_data.win = req->win;

    rc = ProcXIGetClientPointer(&client_request);
    assert(rc == error);

    if (rc == BadWindow)
        assert(client_request.errorValue == req->win);

    client_request.swapped = TRUE;
    swapl(&req->win);
    swaps(&req->length);
    rc = SProcXIGetClientPointer(&client_request);
    assert(rc == error);

    if (rc == BadWindow)
        assert(client_request.errorValue == req->win);

}
Beispiel #21
0
static int _X_COLD
SProcRRSetCrtcTransform(ClientPtr client)
{
    int nparams;
    char *filter;
    CARD32 *params;

    REQUEST(xRRSetCrtcTransformReq);

    REQUEST_AT_LEAST_SIZE(xRRSetCrtcTransformReq);
    swaps(&stuff->length);
    swapl(&stuff->crtc);
    SwapLongs((CARD32 *) &stuff->transform,
              bytes_to_int32(sizeof(xRenderTransform)));
    swaps(&stuff->nbytesFilter);
    filter = (char *) (stuff + 1);
    params = (CARD32 *) (filter + pad_to_int32(stuff->nbytesFilter));
    nparams = ((CARD32 *) stuff + client->req_len) - params;
    if (nparams < 0)
        return BadLength;

    SwapLongs(params, nparams);
    return (*ProcRandrVector[stuff->randrReqType]) (client);
}
/* reply handling for the first bytes that constitute the reply */
static void reply_XIQueryDevice(ClientPtr client, int len, char* data, void *userdata)
{
    xXIQueryDeviceReply *rep = (xXIQueryDeviceReply*)data;
    struct test_data *querydata = (struct test_data*)userdata;

    if (client->swapped)
    {
        swapl(&rep->length);
        swaps(&rep->sequenceNumber);
        swaps(&rep->num_devices);
    }

    reply_check_defaults(rep, len, XIQueryDevice);

    if (querydata->which_device == XIAllDevices)
        assert(rep->num_devices == devices.num_devices);
    else if (querydata->which_device == XIAllMasterDevices)
        assert(rep->num_devices == devices.num_master_devices);
    else
        assert(rep->num_devices == 1);

    querydata->num_devices_in_reply = rep->num_devices;
    reply_handler = reply_XIQueryDevice_data;
}
Beispiel #23
0
static int
SProcXvShmPutImage(ClientPtr client)
{
  REQUEST(xvShmPutImageReq);
  swaps(&stuff->length);
  swapl(&stuff->port);
  swapl(&stuff->drawable);
  swapl(&stuff->gc);
  swapl(&stuff->shmseg);
  swapl(&stuff->id);
  swapl(&stuff->offset);
  swaps(&stuff->src_x);
  swaps(&stuff->src_y);
  swaps(&stuff->src_w);
  swaps(&stuff->src_h);
  swaps(&stuff->drw_x);
  swaps(&stuff->drw_y);
  swaps(&stuff->drw_w);
  swaps(&stuff->drw_h);
  swaps(&stuff->width);
  swaps(&stuff->height);
  return XvProcVector[xv_ShmPutImage](client);
}
Beispiel #24
0
static int
SProcXvShmPutImage(ClientPtr client)
{
  char n;
  REQUEST(xvShmPutImageReq);
  swaps(&stuff->length, n);
  swapl(&stuff->port, n);
  swapl(&stuff->drawable, n);
  swapl(&stuff->gc, n);
  swapl(&stuff->shmseg, n);
  swapl(&stuff->id, n);
  swapl(&stuff->offset, n);
  swaps(&stuff->src_x, n);
  swaps(&stuff->src_y, n);
  swaps(&stuff->src_w, n);
  swaps(&stuff->src_h, n);
  swaps(&stuff->drw_x, n);
  swaps(&stuff->drw_y, n);
  swaps(&stuff->drw_w, n);
  swaps(&stuff->drw_h, n);
  swaps(&stuff->width, n);
  swaps(&stuff->height, n);
  return XvProcVector[xv_ShmPutImage](client);
}
Beispiel #25
0
static void SDeviceEvent(xXIDeviceEvent *from, xXIDeviceEvent *to)
{
    int i;
    char n;
    char *ptr;
    char *vmask;

    memcpy(to, from, sizeof(xEvent) + from->length * 4);

    swaps(&to->sequenceNumber, n);
    swapl(&to->length, n);
    swaps(&to->evtype, n);
    swaps(&to->deviceid, n);
    swapl(&to->time, n);
    swapl(&to->detail, n);
    swapl(&to->root, n);
    swapl(&to->event, n);
    swapl(&to->child, n);
    swapl(&to->root_x, n);
    swapl(&to->root_y, n);
    swapl(&to->event_x, n);
    swapl(&to->event_y, n);
    swaps(&to->buttons_len, n);
    swaps(&to->valuators_len, n);
    swaps(&to->sourceid, n);
    swapl(&to->mods.base_mods, n);
    swapl(&to->mods.latched_mods, n);
    swapl(&to->mods.locked_mods, n);
    swapl(&to->mods.effective_mods, n);
    swapl(&to->flags, n);

    ptr = (char*)(&to[1]);
    ptr += from->buttons_len * 4;
    vmask = ptr; /* valuator mask */
    ptr += from->valuators_len * 4;
    for (i = 0; i < from->valuators_len * 32; i++)
    {
        if (BitIsOn(vmask, i))
        {
            swapl(((uint32_t*)ptr), n);
            ptr += 4;
            swapl(((uint32_t*)ptr), n);
            ptr += 4;
        }
    }
}
Beispiel #26
0
static void
SDeviceChangedEvent(xXIDeviceChangedEvent* from, xXIDeviceChangedEvent* to)
{
    char n;
    int i, j;
    xXIAnyInfo *any;

    *to = *from;
    memcpy(&to[1], &from[1], from->length * 4);

    any = (xXIAnyInfo*)&to[1];
    for (i = 0; i < to->num_classes; i++)
    {
        int length = any->length;

        switch(any->type)
        {
        case KeyClass:
        {
            xXIKeyInfo *ki = (xXIKeyInfo*)any;
            uint32_t *key = (uint32_t*)&ki[1];
            for (j = 0; j < ki->num_keycodes; j++, key++)
                swapl(key, n);
            swaps(&ki->num_keycodes, n);
        }
        break;
        case ButtonClass:
        {
            xXIButtonInfo *bi = (xXIButtonInfo*)any;
            Atom *labels = (Atom*)((char*)bi + sizeof(xXIButtonInfo) +
                                   pad_to_int32(bits_to_bytes(bi->num_buttons)));
            for (j = 0; j < bi->num_buttons; j++)
                swapl(&labels[j], n);
            swaps(&bi->num_buttons, n);
        }
        break;
        case ValuatorClass:
        {
            xXIValuatorInfo* ai = (xXIValuatorInfo*)any;
            swapl(&ai->label, n);
            swapl(&ai->min.integral, n);
            swapl(&ai->min.frac, n);
            swapl(&ai->max.integral, n);
            swapl(&ai->max.frac, n);
            swapl(&ai->resolution, n);
            swaps(&ai->number, n);
        }
        break;
        }

        swaps(&any->type, n);
        swaps(&any->length, n);
        swaps(&any->sourceid, n);

        any = (xXIAnyInfo*)((char*)any + length * 4);
    }

    swaps(&to->sequenceNumber, n);
    swapl(&to->length, n);
    swaps(&to->evtype, n);
    swaps(&to->deviceid, n);
    swapl(&to->time, n);
    swaps(&to->num_classes, n);
    swaps(&to->sourceid, n);

}
Beispiel #27
0
static void
SDeviceLeaveNotifyEvent (xXILeaveEvent *from, xXILeaveEvent *to)
{
    char n;

    *to = *from;
    swaps(&to->sequenceNumber,n);
    swapl(&to->length, n);
    swaps(&to->evtype, n);
    swaps(&to->deviceid, n);
    swapl(&to->time, n);
    swapl(&to->root, n);
    swapl(&to->event, n);
    swapl(&to->child, n);
    swapl(&to->root_x, n);
    swapl(&to->root_y, n);
    swapl(&to->event_x, n);
    swapl(&to->event_y, n);
    swaps(&to->sourceid, n);
    swaps(&to->buttons_len, n);
    swapl(&to->mods.base_mods, n);
    swapl(&to->mods.latched_mods, n);
    swapl(&to->mods.locked_mods, n);
}
Beispiel #28
0
int
ProcRRGetPanning (ClientPtr client)
{
    REQUEST(xRRGetPanningReq);
    xRRGetPanningReply	rep;
    RRCrtcPtr		crtc;
    ScreenPtr		pScreen;
    rrScrPrivPtr	pScrPriv;
    BoxRec		total;
    BoxRec		tracking;
    INT16		border[4];
    int			n;
    
    REQUEST_SIZE_MATCH(xRRGetPanningReq);
    VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);

    /* All crtcs must be associated with screens before client
     * requests are processed
     */
    pScreen = crtc->pScreen;
    pScrPriv = rrGetScrPriv(pScreen);

    if (!pScrPriv)
	return RRErrorBase + BadRRCrtc;

    memset(&rep, 0, sizeof(rep));
    rep.type = X_Reply;
    rep.status = RRSetConfigSuccess;
    rep.sequenceNumber = client->sequence;
    rep.length = 1;
    rep.timestamp = pScrPriv->lastSetTime.milliseconds;

    if (pScrPriv->rrGetPanning &&
	pScrPriv->rrGetPanning (pScreen, crtc, &total, &tracking, border)) {
	rep.left          = total.x1;
	rep.top           = total.y1;
	rep.width         = total.x2 - total.x1;
	rep.height        = total.y2 - total.y1;
	rep.track_left    = tracking.x1;
	rep.track_top     = tracking.y1;
	rep.track_width   = tracking.x2 - tracking.x1;
	rep.track_height  = tracking.y2 - tracking.y1;
	rep.border_left   = border[0];
	rep.border_top    = border[1];
	rep.border_right  = border[2];
	rep.border_bottom = border[3];
    }

    if (client->swapped) {
	swaps(&rep.sequenceNumber, n);
	swapl(&rep.length, n);
	swaps(&rep.timestamp, n);
	swaps(&rep.left, n);
	swaps(&rep.top, n);
	swaps(&rep.width, n);
	swaps(&rep.height, n);
	swaps(&rep.track_left, n);
	swaps(&rep.track_top, n);
	swaps(&rep.track_width, n);
	swaps(&rep.track_height, n);
	swaps(&rep.border_left, n);
	swaps(&rep.border_top, n);
	swaps(&rep.border_right, n);
	swaps(&rep.border_bottom, n);
    }
    WriteToClient(client, sizeof(xRRGetPanningReply), (char *)&rep);
    return Success;
}
Beispiel #29
0
int
ProcRRSetCrtcConfig (ClientPtr client)
{
    REQUEST(xRRSetCrtcConfigReq);
    xRRSetCrtcConfigReply   rep;
    ScreenPtr		    pScreen;
    rrScrPrivPtr	    pScrPriv;
    RRCrtcPtr		    crtc;
    RRModePtr		    mode;
    int			    numOutputs;
    RROutputPtr		    *outputs = NULL;
    RROutput		    *outputIds;
    TimeStamp		    configTime;
    TimeStamp		    time;
    Rotation		    rotation;
    int			    rc, i, j;
    
    REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq);
    numOutputs = (stuff->length - bytes_to_int32(SIZEOF (xRRSetCrtcConfigReq)));
    
    VERIFY_RR_CRTC(stuff->crtc, crtc, DixSetAttrAccess);

    if (stuff->mode == None)
    {
	mode = NULL;
	if (numOutputs > 0)
	    return BadMatch;
    }
    else
    {
	VERIFY_RR_MODE(stuff->mode, mode, DixSetAttrAccess);
	if (numOutputs == 0)
	    return BadMatch;
    }
    if (numOutputs)
    {
	outputs = malloc(numOutputs * sizeof (RROutputPtr));
	if (!outputs)
	    return BadAlloc;
    }
    else
	outputs = NULL;
    
    outputIds = (RROutput *) (stuff + 1);
    for (i = 0; i < numOutputs; i++)
    {
	rc = dixLookupResourceByType((pointer *)(outputs + i), outputIds[i],
				     RROutputType, client, DixSetAttrAccess);
	if (rc != Success)
	{
	    free(outputs);
	    return rc;
	}
	/* validate crtc for this output */
	for (j = 0; j < outputs[i]->numCrtcs; j++)
	    if (outputs[i]->crtcs[j] == crtc)
		break;
	if (j == outputs[i]->numCrtcs)
	{
	    free(outputs);
	    return BadMatch;
	}
	/* validate mode for this output */
	for (j = 0; j < outputs[i]->numModes + outputs[i]->numUserModes; j++)
	{
	    RRModePtr	m = (j < outputs[i]->numModes ? 
			     outputs[i]->modes[j] :
			     outputs[i]->userModes[j - outputs[i]->numModes]);
	    if (m == mode)
		break;
	}
	if (j == outputs[i]->numModes + outputs[i]->numUserModes)
	{
	    free(outputs);
	    return BadMatch;
	}
    }
    /* validate clones */
    for (i = 0; i < numOutputs; i++)
    {
	for (j = 0; j < numOutputs; j++)
	{
	    int k;
	    if (i == j)
		continue;
	    for (k = 0; k < outputs[i]->numClones; k++)
	    {
		if (outputs[i]->clones[k] == outputs[j])
		    break;
	    }
	    if (k == outputs[i]->numClones)
	    {
		free(outputs);
		return BadMatch;
	    }
	}
    }

    pScreen = crtc->pScreen;
    pScrPriv = rrGetScrPriv(pScreen);
    
    time = ClientTimeToServerTime(stuff->timestamp);
    configTime = ClientTimeToServerTime(stuff->configTimestamp);
    
    if (!pScrPriv)
    {
	time = currentTime;
	rep.status = RRSetConfigFailed;
	goto sendReply;
    }
    
    /*
     * Validate requested rotation
     */
    rotation = (Rotation) stuff->rotation;

    /* test the rotation bits only! */
    switch (rotation & 0xf) {
    case RR_Rotate_0:
    case RR_Rotate_90:
    case RR_Rotate_180:
    case RR_Rotate_270:
	break;
    default:
	/*
	 * Invalid rotation
	 */
	client->errorValue = stuff->rotation;
	free(outputs);
	return BadValue;
    }

    if (mode)
    {
	if ((~crtc->rotations) & rotation)
	{
	    /*
	     * requested rotation or reflection not supported by screen
	     */
	    client->errorValue = stuff->rotation;
	    free(outputs);
	    return BadMatch;
	}
    
#ifdef RANDR_12_INTERFACE
	/*
	 * Check screen size bounds if the DDX provides a 1.2 interface
	 * for setting screen size. Else, assume the CrtcSet sets
	 * the size along with the mode. If the driver supports transforms,
	 * then it must allow crtcs to display a subset of the screen, so
	 * only do this check for drivers without transform support.
	 */
	if (pScrPriv->rrScreenSetSize && !crtc->transforms)
	{
	    int source_width;
	    int	source_height;
	    PictTransform transform;
	    struct pixman_f_transform f_transform, f_inverse;

	    RRTransformCompute (stuff->x, stuff->y,
				mode->mode.width, mode->mode.height,
				rotation,
				&crtc->client_pending_transform,
				&transform, &f_transform, &f_inverse);

	    RRModeGetScanoutSize (mode, &transform, &source_width, &source_height);
	    if (stuff->x + source_width > pScreen->width)
	    {
		client->errorValue = stuff->x;
		free(outputs);
		return BadValue;
	    }
	    
	    if (stuff->y + source_height > pScreen->height)
	    {
		client->errorValue = stuff->y;
		free(outputs);
		return BadValue;
	    }
	}
#endif
    }
    
    if (!RRCrtcSet (crtc, mode, stuff->x, stuff->y,
		   rotation, numOutputs, outputs))
    {
	rep.status = RRSetConfigFailed;
	goto sendReply;
    }
    rep.status = RRSetConfigSuccess;
    pScrPriv->lastSetTime = time;
    
sendReply:
    free(outputs);
    
    rep.type = X_Reply;
    /* rep.status has already been filled in */
    rep.length = 0;
    rep.sequenceNumber = client->sequence;
    rep.newTimestamp = pScrPriv->lastSetTime.milliseconds;

    if (client->swapped) 
    {
	int n;
    	swaps(&rep.sequenceNumber, n);
    	swapl(&rep.length, n);
	swapl(&rep.newTimestamp, n);
    }
    WriteToClient(client, sizeof(xRRSetCrtcConfigReply), (char *)&rep);
    
    return Success;
}
Beispiel #30
0
int
ProcRRGetCrtcInfo (ClientPtr client)
{
    REQUEST(xRRGetCrtcInfoReq);
    xRRGetCrtcInfoReply	rep;
    RRCrtcPtr			crtc;
    CARD8			*extra;
    unsigned long		extraLen;
    ScreenPtr			pScreen;
    rrScrPrivPtr		pScrPriv;
    RRModePtr			mode;
    RROutput			*outputs;
    RROutput			*possible;
    int				i, j, k, n;
    int				width, height;
    BoxRec			panned_area;
    
    REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq);
    VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);

    /* All crtcs must be associated with screens before client
     * requests are processed
     */
    pScreen = crtc->pScreen;
    pScrPriv = rrGetScrPriv(pScreen);

    mode = crtc->mode;
    
    rep.type = X_Reply;
    rep.status = RRSetConfigSuccess;
    rep.sequenceNumber = client->sequence;
    rep.length = 0;
    rep.timestamp = pScrPriv->lastSetTime.milliseconds;
    if (pScrPriv->rrGetPanning &&
	pScrPriv->rrGetPanning (pScreen, crtc, &panned_area, NULL, NULL) &&
	(panned_area.x2 > panned_area.x1) && (panned_area.y2 > panned_area.y1))
    {
 	rep.x = panned_area.x1;
	rep.y = panned_area.y1;
	rep.width = panned_area.x2 - panned_area.x1;
	rep.height = panned_area.y2 - panned_area.y1;
    }
    else
    {
	RRCrtcGetScanoutSize (crtc, &width, &height);
	rep.x = crtc->x;
	rep.y = crtc->y;
	rep.width = width;
	rep.height = height;
    }
    rep.mode = mode ? mode->mode.id : 0;
    rep.rotation = crtc->rotation;
    rep.rotations = crtc->rotations;
    rep.nOutput = crtc->numOutputs;
    k = 0;
    for (i = 0; i < pScrPriv->numOutputs; i++)
	for (j = 0; j < pScrPriv->outputs[i]->numCrtcs; j++)
	    if (pScrPriv->outputs[i]->crtcs[j] == crtc)
		k++;
    rep.nPossibleOutput = k;
    
    rep.length = rep.nOutput + rep.nPossibleOutput;

    extraLen = rep.length << 2;
    if (extraLen)
    {
	extra = malloc(extraLen);
	if (!extra)
	    return BadAlloc;
    }
    else
	extra = NULL;

    outputs = (RROutput *) extra;
    possible = (RROutput *) (outputs + rep.nOutput);
    
    for (i = 0; i < crtc->numOutputs; i++)
    {
	outputs[i] = crtc->outputs[i]->id;
	if (client->swapped)
	    swapl (&outputs[i], n);
    }
    k = 0;
    for (i = 0; i < pScrPriv->numOutputs; i++)
	for (j = 0; j < pScrPriv->outputs[i]->numCrtcs; j++)
	    if (pScrPriv->outputs[i]->crtcs[j] == crtc)
	    {
		possible[k] = pScrPriv->outputs[i]->id;
		if (client->swapped)
		    swapl (&possible[k], n);
		k++;
	    }
    
    if (client->swapped) {
	swaps(&rep.sequenceNumber, n);
	swapl(&rep.length, n);
	swapl(&rep.timestamp, n);
	swaps(&rep.x, n);
	swaps(&rep.y, n);
	swaps(&rep.width, n);
	swaps(&rep.height, n);
	swapl(&rep.mode, n);
	swaps(&rep.rotation, n);
	swaps(&rep.rotations, n);
	swaps(&rep.nOutput, n);
	swaps(&rep.nPossibleOutput, n);
    }
    WriteToClient(client, sizeof(xRRGetCrtcInfoReply), (char *)&rep);
    if (extraLen)
    {
	WriteToClient (client, extraLen, (char *) extra);
	free(extra);
    }
    
    return Success;
}