Esempio n. 1
0
int
ProcXUngrabDeviceButton(ClientPtr client)
{
    DeviceIntPtr dev;
    DeviceIntPtr mdev;
    WindowPtr pWin;
    GrabPtr temporaryGrab;
    int rc;

    REQUEST(xUngrabDeviceButtonReq);
    REQUEST_SIZE_MATCH(xUngrabDeviceButtonReq);

    rc = dixLookupDevice(&dev, stuff->grabbed_device, client, DixGrabAccess);
    if (rc != Success)
        return rc;
    if (dev->button == NULL)
        return BadMatch;

    if (stuff->modifier_device != UseXKeyboard) {
        rc = dixLookupDevice(&mdev, stuff->modifier_device, client,
                             DixReadAccess);
        if (rc != Success)
            return BadDevice;
        if (mdev->key == NULL)
            return BadMatch;
    }
    else
        mdev = PickKeyboard(client);

    rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess);
    if (rc != Success)
        return rc;

    if ((stuff->modifiers != AnyModifier) &&
        (stuff->modifiers & ~AllModifiersMask))
        return BadValue;

    temporaryGrab = AllocGrab();
    if (!temporaryGrab)
        return BadAlloc;

    temporaryGrab->resource = client->clientAsMask;
    temporaryGrab->device = dev;
    temporaryGrab->window = pWin;
    temporaryGrab->type = DeviceButtonPress;
    temporaryGrab->grabtype = XI;
    temporaryGrab->modifierDevice = mdev;
    temporaryGrab->modifiersDetail.exact = stuff->modifiers;
    temporaryGrab->modifiersDetail.pMask = NULL;
    temporaryGrab->detail.exact = stuff->button;
    temporaryGrab->detail.pMask = NULL;

    DeletePassiveGrabFromList(temporaryGrab);

    FreeGrab(temporaryGrab);
    return Success;
}
Esempio n. 2
0
int
ProcXUngrabDeviceKey(ClientPtr client)
{
    DeviceIntPtr dev;
    DeviceIntPtr mdev;
    WindowPtr pWin;
    GrabRec temporaryGrab;
    int rc;

    REQUEST(xUngrabDeviceKeyReq);
    REQUEST_SIZE_MATCH(xUngrabDeviceKeyReq);

    rc = dixLookupDevice(&dev, stuff->grabbed_device, client, DixGrabAccess);
    if (rc != Success)
	return rc;
    if (dev->key == NULL)
	return BadMatch;

    if (stuff->modifier_device != UseXKeyboard) {
	rc = dixLookupDevice(&mdev, stuff->modifier_device, client,
			     DixReadAccess);
	if (rc != Success)
	    return BadDevice;
	if (mdev->key == NULL)
	    return BadMatch;
    } else
	mdev = PickKeyboard(client);

    rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess);
    if (rc != Success)
	return rc;

    if (((stuff->key > dev->key->curKeySyms.maxKeyCode) ||
	 (stuff->key < dev->key->curKeySyms.minKeyCode))
	&& (stuff->key != AnyKey))
	return BadValue;

    if ((stuff->modifiers != AnyModifier) &&
	(stuff->modifiers & ~AllModifiersMask))
	return BadValue;

    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. 3
0
/**
 * Prepend the new grab to the list of passive grabs on the window.
 * Any previously existing grab that matches the new grab will be removed.
 * Adding a new grab that would override another client's grab will result in
 * a BadAccess.
 * 
 * @return Success or X error code on failure.
 */
int
AddPassiveGrabToList(ClientPtr client, GrabPtr pGrab)
{
    GrabPtr grab;
    Mask access_mode = DixGrabAccess;
    int rc;

    for (grab = wPassiveGrabs(pGrab->window); grab; grab = grab->next)
    {
	if (GrabMatchesSecond(pGrab, grab, FALSE))
	{
	    if (CLIENT_BITS(pGrab->resource) != CLIENT_BITS(grab->resource))
	    {
		FreeGrab(pGrab);
		return BadAccess;
	    }
	}
    }

    if (pGrab->keyboardMode == GrabModeSync||pGrab->pointerMode == GrabModeSync)
	access_mode |= DixFreezeAccess;
    rc = XaceHook(XACE_DEVICE_ACCESS, client, pGrab->device, access_mode);
    if (rc != Success)
	return rc;

    /* Remove all grabs that match the new one exactly */
    for (grab = wPassiveGrabs(pGrab->window); grab; grab = grab->next)
    {
	if (GrabsAreIdentical(pGrab, grab))
	{
            DeletePassiveGrabFromList(grab);
            break;
	} 
    }

    if (!pGrab->window->optional && !MakeWindowOptional (pGrab->window))
    {
	FreeGrab(pGrab);
	return BadAlloc;
    }

    pGrab->next = pGrab->window->optional->passiveGrabs;
    pGrab->window->optional->passiveGrabs = pGrab;
    if (AddResource(pGrab->resource, RT_PASSIVEGRAB, (pointer)pGrab))
	return Success;
    return BadAlloc;
}
Esempio n. 4
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. 5
0
int
ProcXIPassiveUngrabDevice(ClientPtr client)
{
    DeviceIntPtr dev, mod_dev;
    WindowPtr win;
    GrabPtr tempGrab;
    uint32_t *modifiers;
    int i, rc;

    REQUEST(xXIPassiveUngrabDeviceReq);
    REQUEST_FIXED_SIZE(xXIPassiveUngrabDeviceReq,
                       ((uint32_t) stuff->num_modifiers) << 2);

    if (stuff->deviceid == XIAllDevices)
        dev = inputInfo.all_devices;
    else if (stuff->deviceid == XIAllMasterDevices)
        dev = inputInfo.all_master_devices;
    else {
        rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess);
        if (rc != Success)
            return rc;
    }

    if (stuff->grab_type != XIGrabtypeButton &&
        stuff->grab_type != XIGrabtypeKeycode &&
        stuff->grab_type != XIGrabtypeEnter &&
        stuff->grab_type != XIGrabtypeFocusIn &&
        stuff->grab_type != XIGrabtypeTouchBegin) {
        client->errorValue = stuff->grab_type;
        return BadValue;
    }

    if ((stuff->grab_type == XIGrabtypeEnter ||
         stuff->grab_type == XIGrabtypeFocusIn ||
         stuff->grab_type == XIGrabtypeTouchBegin) && stuff->detail != 0) {
        client->errorValue = stuff->detail;
        return BadValue;
    }

    rc = dixLookupWindow(&win, stuff->grab_window, client, DixSetAttrAccess);
    if (rc != Success)
        return rc;

    mod_dev = (IsFloating(dev)) ? dev : GetMaster(dev, MASTER_KEYBOARD);

    tempGrab = AllocGrab(NULL);
    if (!tempGrab)
        return BadAlloc;

    tempGrab->resource = client->clientAsMask;
    tempGrab->device = dev;
    tempGrab->window = win;
    switch (stuff->grab_type) {
    case XIGrabtypeButton:
        tempGrab->type = XI_ButtonPress;
        break;
    case XIGrabtypeKeycode:
        tempGrab->type = XI_KeyPress;
        break;
    case XIGrabtypeEnter:
        tempGrab->type = XI_Enter;
        break;
    case XIGrabtypeFocusIn:
        tempGrab->type = XI_FocusIn;
        break;
    case XIGrabtypeTouchBegin:
        tempGrab->type = XI_TouchBegin;
        break;
    }
    tempGrab->grabtype = XI2;
    tempGrab->modifierDevice = mod_dev;
    tempGrab->modifiersDetail.pMask = NULL;
    tempGrab->detail.exact = stuff->detail;
    tempGrab->detail.pMask = NULL;

    modifiers = (uint32_t *) &stuff[1];

    for (i = 0; i < stuff->num_modifiers; i++, modifiers++) {
        tempGrab->modifiersDetail.exact = *modifiers;
        DeletePassiveGrabFromList(tempGrab);
    }

    FreeGrab(tempGrab);

    return Success;
}
int
ProcXIPassiveUngrabDevice(ClientPtr client)
{
    DeviceIntPtr dev, mod_dev;
    WindowPtr win;
    GrabRec tempGrab;
    uint32_t* modifiers;
    int i, rc;

    REQUEST(xXIPassiveUngrabDeviceReq);
    REQUEST_AT_LEAST_SIZE(xXIPassiveUngrabDeviceReq);

    rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess);
    if (rc != Success)
	return rc;

    if (stuff->grab_type != XIGrabtypeButton &&
        stuff->grab_type != XIGrabtypeKeycode &&
        stuff->grab_type != XIGrabtypeEnter &&
        stuff->grab_type != XIGrabtypeFocusIn)
    {
        client->errorValue = stuff->grab_type;
        return BadValue;
    }

    if ((stuff->grab_type == XIGrabtypeEnter ||
         stuff->grab_type == XIGrabtypeFocusIn) && stuff->detail != 0)
    {
        client->errorValue = stuff->detail;
        return BadValue;
    }

    rc = dixLookupWindow(&win, stuff->grab_window, client, DixSetAttrAccess);
    if (rc != Success)
        return rc;

    mod_dev = (IsFloating(dev)) ? dev : GetMaster(dev, MASTER_KEYBOARD);

    tempGrab.resource = client->clientAsMask;
    tempGrab.device = dev;
    tempGrab.window = win;
    switch(stuff->grab_type)
    {
        case XIGrabtypeButton:  tempGrab.type = XI_ButtonPress; break;
        case XIGrabtypeKeycode:  tempGrab.type = XI_KeyPress;    break;
        case XIGrabtypeEnter:   tempGrab.type = XI_Enter;       break;
        case XIGrabtypeFocusIn: tempGrab.type = XI_FocusIn;     break;
    }
    tempGrab.grabtype = GRABTYPE_XI2;
    tempGrab.modifierDevice = mod_dev;
    tempGrab.modifiersDetail.pMask = NULL;
    tempGrab.detail.exact = stuff->detail;
    tempGrab.detail.pMask = NULL;

    modifiers = (uint32_t*)&stuff[1];

    for (i = 0; i < stuff->num_modifiers; i++, modifiers++)
    {
        tempGrab.modifiersDetail.exact = *modifiers;
        DeletePassiveGrabFromList(&tempGrab);
    }

    return Success;
}
Esempio n. 7
0
int
ProcXUngrabDeviceButton(ClientPtr client)
{
    DeviceIntPtr dev;
    DeviceIntPtr mdev;
    WindowPtr pWin;
    GrabRec temporaryGrab;
    int rc;

    REQUEST(xUngrabDeviceButtonReq);
    REQUEST_SIZE_MATCH(xUngrabDeviceButtonReq);

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

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

    rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixUnknownAccess);
    if (rc != Success) {
	SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, rc);
	return Success;
    }

    if ((stuff->modifiers != AnyModifier) &&
	(stuff->modifiers & ~AllModifiersMask)) {
	SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, BadValue);
	return Success;
    }

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

    DeletePassiveGrabFromList(&temporaryGrab);
    return Success;
}