void xf_Pointer_New(rdpContext* context, rdpPointer* pointer)
{
#ifdef WITH_XCURSOR
	XcursorImage ci;
	xfContext* xfc = (xfContext*) context;

	xf_lock_x11(xfc, FALSE);

	ZeroMemory(&ci, sizeof(ci));
	ci.version = XCURSOR_IMAGE_VERSION;
	ci.size = sizeof(ci);
	ci.width = pointer->width;
	ci.height = pointer->height;
	ci.xhot = pointer->xPos;
	ci.yhot = pointer->yPos;

	ci.pixels = (XcursorPixel*) calloc(1, ci.width * ci.height * 4);

	if (!ci.pixels)
		return;

	if ((pointer->andMaskData != 0) && (pointer->xorMaskData != 0))
	{
		freerdp_image_copy_from_pointer_data((BYTE*) ci.pixels, PIXEL_FORMAT_ARGB32,
				pointer->width * 4, 0, 0, pointer->width, pointer->height,
				pointer->xorMaskData, pointer->andMaskData, pointer->xorBpp, xfc->palette);
	}

	((xfPointer*) pointer)->cursor = XcursorImageLoadCursor(xfc->display, &ci);

	free(ci.pixels);

	xf_unlock_x11(xfc, FALSE);
#endif
}
Beispiel #2
0
/* Pointer Class */
static BOOL xf_Pointer_New(rdpContext* context, rdpPointer* pointer)
{
#ifdef WITH_XCURSOR
	UINT32 CursorFormat;
	rdpGdi* gdi;
	size_t size;
	XcursorImage ci;
	xfContext* xfc = (xfContext*) context;
	xfPointer* xpointer = (xfPointer*)pointer;

	if (!context || !pointer || !context->gdi)
		return FALSE;

	if (!xfc->invert)
		CursorFormat = PIXEL_FORMAT_RGBA32;
	else
		CursorFormat = PIXEL_FORMAT_BGRA32;

	gdi = context->gdi;
	xf_lock_x11(xfc, FALSE);
	ZeroMemory(&ci, sizeof(ci));
	ci.version = XCURSOR_IMAGE_VERSION;
	ci.size = sizeof(ci);
	ci.width = pointer->width;
	ci.height = pointer->height;
	ci.xhot = pointer->xPos;
	ci.yhot = pointer->yPos;
	size = ci.height * ci.width * GetBytesPerPixel(CursorFormat);

	if (!(ci.pixels = (XcursorPixel*) _aligned_malloc(size, 16)))
	{
		xf_unlock_x11(xfc, FALSE);
		return FALSE;
	}

	if (!freerdp_image_copy_from_pointer_data(
	        (BYTE*) ci.pixels, CursorFormat,
	        0, 0, 0, pointer->width, pointer->height,
	        pointer->xorMaskData, pointer->lengthXorMask,
	        pointer->andMaskData, pointer->lengthAndMask,
	        pointer->xorBpp, &context->gdi->palette))
	{
		_aligned_free(ci.pixels);
		xf_unlock_x11(xfc, FALSE);
		return FALSE;
	}

	xpointer->cursor = XcursorImageLoadCursor(xfc->display, &ci);
	_aligned_free(ci.pixels);
	xf_unlock_x11(xfc, FALSE);
#endif
	return TRUE;
}
Beispiel #3
0
static BOOL wf_Pointer_New(rdpContext* context, const rdpPointer* pointer)
{
    HCURSOR hCur;
    ICONINFO info;
    rdpGdi* gdi;
    BOOL rc = FALSE;

    if (!context || !pointer)
        return FALSE;

    gdi = context->gdi;

    if (!gdi)
        return FALSE;

    info.fIcon = FALSE;
    info.xHotspot = pointer->xPos;
    info.yHotspot = pointer->yPos;

    if (pointer->xorBpp == 1)
    {
        BYTE* pdata = (BYTE*) _aligned_malloc(pointer->lengthAndMask +
                                              pointer->lengthXorMask, 16);

        if (!pdata)
            goto fail;

        CopyMemory(pdata, pointer->andMaskData, pointer->lengthAndMask);
        CopyMemory(pdata + pointer->lengthAndMask, pointer->xorMaskData,
                   pointer->lengthXorMask);
        info.hbmMask = CreateBitmap(pointer->width, pointer->height * 2, 1, 1, pdata);
        _aligned_free(pdata);
        info.hbmColor = NULL;
    }
    else
    {
        BYTE* pdata = (BYTE*) _aligned_malloc(pointer->lengthAndMask, 16);

        if (!pdata)
            goto fail;

        flip_bitmap(pointer->andMaskData, pdata, (pointer->width + 7) / 8,
                    pointer->height);
        info.hbmMask = CreateBitmap(pointer->width, pointer->height, 1, 1, pdata);
        _aligned_free(pdata);
        pdata = (BYTE*) _aligned_malloc(pointer->width * pointer->height *
                                        GetBitsPerPixel(gdi->dstFormat), 16);

        if (!pdata)
            goto fail;

        if (!freerdp_image_copy_from_pointer_data(pdata, gdi->dstFormat, 0, 0, 0,
                pointer->width, pointer->height,
                pointer->xorMaskData, pointer->lengthXorMask,
                pointer->andMaskData, pointer->lengthAndMask, pointer->xorBpp, &gdi->palette))
        {
            _aligned_free(pdata);
            goto fail;
        }

        info.hbmColor = CreateBitmap(pointer->width, pointer->height, 1,
                                     GetBitsPerPixel(gdi->dstFormat), pdata);
        _aligned_free(pdata);
    }

    hCur = CreateIconIndirect(&info);
    ((wfPointer*) pointer)->cursor = hCur;
    rc = TRUE;
fail:

    if (info.hbmMask)
        DeleteObject(info.hbmMask);

    if (info.hbmColor)
        DeleteObject(info.hbmColor);

    return rc;
}