예제 #1
0
파일: grabs.c 프로젝트: Agnesa/xserver
Bool
CopyGrab(GrabPtr dst, const GrabPtr src)
{
    Mask *mdetails_mask = NULL;
    Mask *details_mask = NULL;
    XI2Mask *xi2mask;

    if (src->cursor)
        src->cursor->refcnt++;

    if (src->modifiersDetail.pMask) {
        int len = MasksPerDetailMask * sizeof(Mask);

        mdetails_mask = malloc(len);
        if (!mdetails_mask)
            return FALSE;
        memcpy(mdetails_mask, src->modifiersDetail.pMask, len);
    }

    if (src->detail.pMask) {
        int len = MasksPerDetailMask * sizeof(Mask);

        details_mask = malloc(len);
        if (!details_mask) {
            free(mdetails_mask);
            return FALSE;
        }
        memcpy(details_mask, src->detail.pMask, len);
    }

    if (!dst->xi2mask) {
        xi2mask = xi2mask_new();
        if (!xi2mask) {
            free(mdetails_mask);
            free(details_mask);
            return FALSE;
        }
    }
    else {
        xi2mask = dst->xi2mask;
        xi2mask_zero(xi2mask, -1);
    }

    *dst = *src;
    dst->modifiersDetail.pMask = mdetails_mask;
    dst->detail.pMask = details_mask;
    dst->xi2mask = xi2mask;

    xi2mask_merge(dst->xi2mask, src->xi2mask);

    return TRUE;
}
예제 #2
0
파일: grabs.c 프로젝트: timon37/xwayland
GrabPtr
CreateGrab(
    int client,
    DeviceIntPtr device,
    DeviceIntPtr modDevice,
    WindowPtr window,
    enum InputLevel grabtype,
    GrabMask *mask,
    GrabParameters *param,
    int type,
    KeyCode keybut,	/* key or button */
    WindowPtr confineTo,
    CursorPtr cursor)
{
    GrabPtr grab;

    grab = AllocGrab();
    if (!grab)
	return (GrabPtr)NULL;
    grab->resource = FakeClientID(client);
    grab->device = device;
    grab->window = window;
    grab->eventMask = mask->core; /* same for XI */
    grab->deviceMask = 0;
    grab->ownerEvents = param->ownerEvents;
    grab->keyboardMode = param->this_device_mode;
    grab->pointerMode = param->other_devices_mode;
    grab->modifiersDetail.exact = param->modifiers;
    grab->modifiersDetail.pMask = NULL;
    grab->modifierDevice = modDevice;
    grab->type = type;
    grab->grabtype = grabtype;
    grab->detail.exact = keybut;
    grab->detail.pMask = NULL;
    grab->confineTo = confineTo;
    grab->cursor = cursor;
    grab->next = NULL;

    if (grabtype == XI2)
        xi2mask_merge(grab->xi2mask, mask->xi2mask);
    if (cursor)
	cursor->refcnt++;
    return grab;

}