Esempio n. 1
0
static inline int
dixLookupWindow(WindowPtr *pWin, XID id, ClientPtr client, Mask access)
{
    *pWin = LookupWindow(id, client);
    if (!*pWin)
	return BadWindow;
    return Success;
}
Esempio n. 2
0
static 
int AttrValidate(
    ClientPtr client,
    int attrib_mask,
    AppGroupPtr pAppGrp)
{
    WindowPtr pWin;
    int idepth, ivids, found;
    ScreenPtr pScreen;
    DepthPtr pDepth;
    ColormapPtr pColormap;

    pWin = LookupWindow (pAppGrp->default_root, client);
    /* XXX check that pWin is not NULL */
    pScreen = pWin->drawable.pScreen;
    if (WindowTable[pScreen->myNum]->drawable.id != pAppGrp->default_root)
	return BadWindow;
    pDepth = pScreen->allowedDepths;
    if (pAppGrp->root_visual) {
	found = FALSE;
	for (idepth = 0; idepth < pScreen->numDepths; idepth++, pDepth++) {
	    for (ivids = 0; ivids < pDepth->numVids; ivids++) {
		if (pAppGrp->root_visual == pDepth->vids[ivids]) {
		    found = TRUE;
		    break;
		}
	    }
	}
	if (!found)
	    return BadMatch;
    }
    if (pAppGrp->default_colormap) {

	pColormap = (ColormapPtr)LookupIDByType (pAppGrp->default_colormap, RT_COLORMAP);
	/* XXX check that pColormap is not NULL */
	if (pColormap->pScreen != pScreen)
	    return BadColor;
	if (pColormap->pVisual->vid != (pAppGrp->root_visual ? pAppGrp->root_visual : pScreen->rootVisual))
	    return BadMatch;
    }
    return client->noClientException;
}
Esempio n. 3
0
int
ProcXUngrabDeviceKey(ClientPtr client)
{
    DeviceIntPtr dev;
    DeviceIntPtr mdev;
    WindowPtr pWin;
    GrabRec temporaryGrab;

    REQUEST(xUngrabDeviceKeyReq);
    REQUEST_SIZE_MATCH(xUngrabDeviceKeyReq);

    dev = LookupDeviceIntRec(stuff->grabbed_device);
    if (dev == NULL) {
        SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadDevice);
        return Success;
    }
    if (dev->key == NULL) {
        SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadMatch);
        return Success;
    }

    if (stuff->modifier_device != UseXKeyboard) {
        mdev = LookupDeviceIntRec(stuff->modifier_device);
        if (mdev == NULL) {
            SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0,
                              BadDevice);
            return Success;
        }
        if (mdev->key == NULL) {
            SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadMatch);
            return Success;
        }
    } else
        mdev = (DeviceIntPtr) LookupKeyboardDevice();

    pWin = LookupWindow(stuff->grabWindow, client);
    if (!pWin) {
        SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadWindow);
        return Success;
    }
    if (((stuff->key > dev->key->curKeySyms.maxKeyCode) ||
            (stuff->key < dev->key->curKeySyms.minKeyCode))
            && (stuff->key != AnyKey)) {
        SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadValue);
        return Success;
    }
    if ((stuff->modifiers != AnyModifier) &&
            (stuff->modifiers & ~AllModifiersMask)) {
        SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadValue);
        return Success;
    }

    temporaryGrab.resource = client->clientAsMask;
    temporaryGrab.device = dev;
    temporaryGrab.window = pWin;
    temporaryGrab.type = DeviceKeyPress;
    temporaryGrab.modifierDevice = mdev;
    temporaryGrab.modifiersDetail.exact = stuff->modifiers;
    temporaryGrab.modifiersDetail.pMask = NULL;
    temporaryGrab.detail.exact = stuff->key;
    temporaryGrab.detail.pMask = NULL;

    DeletePassiveGrabFromList(&temporaryGrab);
    return Success;
}
Esempio n. 4
0
int
ProcXGetSelectedExtensionEvents(register ClientPtr client)
{
    int i;
    int total_length = 0;
    xGetSelectedExtensionEventsReply rep;
    WindowPtr pWin;
    XEventClass *buf = NULL;
    XEventClass *tclient;
    XEventClass *aclient;
    OtherInputMasks *pOthers;
    InputClientsPtr others;

    REQUEST(xGetSelectedExtensionEventsReq);
    REQUEST_SIZE_MATCH(xGetSelectedExtensionEventsReq);

    rep.repType = X_Reply;
    rep.RepType = X_GetSelectedExtensionEvents;
    rep.length = 0;
    rep.sequenceNumber = client->sequence;
    rep.this_client_count = 0;
    rep.all_clients_count = 0;

    if (!(pWin = LookupWindow(stuff->window, client))) {
        SendErrorToClient(client, IReqCode, X_GetSelectedExtensionEvents, 0,
                          BadWindow);
        return Success;
    }

    if ((pOthers = wOtherInputMasks(pWin)) != 0) {
        for (others = pOthers->inputClients; others; others = others->next)
            for (i = 0; i < EMASKSIZE; i++)
                tclient = ClassFromMask(NULL, others->mask[i], i,
                                        &rep.all_clients_count, COUNT);

        for (others = pOthers->inputClients; others; others = others->next)
            if (SameClient(others, client)) {
                for (i = 0; i < EMASKSIZE; i++)
                    tclient = ClassFromMask(NULL, others->mask[i], i,
                                            &rep.this_client_count, COUNT);
                break;
            }

        total_length = (rep.all_clients_count + rep.this_client_count) *
                       sizeof(XEventClass);
        rep.length = (total_length + 3) >> 2;
        buf = (XEventClass *) xalloc(total_length);

        tclient = buf;
        aclient = buf + rep.this_client_count;
        if (others)
            for (i = 0; i < EMASKSIZE; i++)
                tclient =
                    ClassFromMask(tclient, others->mask[i], i, NULL, CREATE);

        for (others = pOthers->inputClients; others; others = others->next)
            for (i = 0; i < EMASKSIZE; i++)
                aclient =
                    ClassFromMask(aclient, others->mask[i], i, NULL, CREATE);
    }

    WriteReplyToClient(client, sizeof(xGetSelectedExtensionEventsReply), &rep);

    if (total_length) {
        client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
        WriteSwappedDataToClient(client, total_length, buf);
        xfree(buf);
    }
    return Success;
}