Ejemplo n.º 1
0
/*
 * Set the colors for a two-color cursor (ignore for ARGB cursors)
 */
static void
xf86_set_cursor_colors(ScrnInfoPtr scrn, int bg, int fg)
{
    ScreenPtr screen = scrn->pScreen;
    xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
    CursorPtr cursor = xf86CurrentCursor(screen);
    int c;
    CARD8 *bits = cursor ?
        dixLookupScreenPrivate(&cursor->devPrivates, CursorScreenKey, screen)
        : NULL;

    /* Save ARGB versions of these colors */
    xf86_config->cursor_fg = (CARD32) fg | 0xff000000;
    xf86_config->cursor_bg = (CARD32) bg | 0xff000000;

    for (c = 0; c < xf86_config->num_crtc; c++) {
        xf86CrtcPtr crtc = xf86_config->crtc[c];

        if (crtc->enabled && !crtc->cursor_argb) {
            if (xf86_driver_has_load_cursor_image(crtc))
                crtc->funcs->set_cursor_colors(crtc, bg, fg);
            else if (bits)
                xf86_crtc_convert_cursor_to_argb(crtc, bits);
        }
    }
}
Ejemplo n.º 2
0
void
xf86_reload_cursors(ScreenPtr screen)
{
    ScrnInfoPtr scrn;
    xf86CrtcConfigPtr xf86_config;
    xf86CursorInfoPtr cursor_info;
    CursorPtr cursor;
    int x, y;
    xf86CursorScreenPtr cursor_screen_priv;

    /* initial mode setting will not have set a screen yet.
       May be called before the devices are initialised.
     */
    if (!screen || !inputInfo.pointer)
        return;
    cursor_screen_priv = dixLookupPrivate(&screen->devPrivates,
                                          xf86CursorScreenKey);
    /* return if HW cursor is inactive, to avoid displaying two cursors */
    if (!cursor_screen_priv || !cursor_screen_priv->isUp)
        return;

    scrn = xf86ScreenToScrn(screen);
    xf86_config = XF86_CRTC_CONFIG_PTR(scrn);

    /* make sure the cursor code has been initialized */
    cursor_info = xf86_config->cursor_info;
    if (!cursor_info)
        return;

    cursor = xf86_config->cursor;
    GetSpritePosition(inputInfo.pointer, &x, &y);
    if (!(cursor_info->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN))
        (*cursor_info->HideCursor) (scrn);

    if (cursor) {
        void *src =
            dixLookupScreenPrivate(&cursor->devPrivates, CursorScreenKey,
                                   screen);
#ifdef ARGB_CURSOR
        if (cursor->bits->argb && cursor_info->LoadCursorARGB)
            (*cursor_info->LoadCursorARGB) (scrn, cursor);
        else if (src)
#endif
            (*cursor_info->LoadCursorImage) (scrn, src);

        x += scrn->frameX0 + cursor_screen_priv->HotX;
        y += scrn->frameY0 + cursor_screen_priv->HotY;
        (*cursor_info->SetCursorPosition) (scrn, x, y);
    }
}
Ejemplo n.º 3
0
Bool
miDCPutUpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
                 int x, int y, unsigned long source, unsigned long mask)
{
    miDCCursorPtr   pPriv;
    miDCBufferPtr   pBuffer;
    WindowPtr	    pWin;

    pPriv = (miDCCursorPtr)dixLookupScreenPrivate(&pCursor->bits->devPrivates,
						  miDCCursorBitsKey, pScreen);
    if (!pPriv)
    {
	pPriv = miDCRealize(pScreen, pCursor);
	if (!pPriv)
	    return FALSE;
    }

    pWin = pScreen->root;
    pBuffer = miGetDCDevice(pDev, pScreen);

#ifdef ARGB_CURSOR
    if (pPriv->pPicture)
    {
	if (!EnsurePicture(pBuffer->pRootPicture, &pWin->drawable, pWin))
	    return FALSE;
	CompositePicture (PictOpOver,
			  pPriv->pPicture,
			  NULL,
			  pBuffer->pRootPicture,
			  0, 0, 0, 0, 
			  x, y, 
			  pCursor->bits->width,
			  pCursor->bits->height);
    }
    else
#endif
    {
	miDCPutBits ((DrawablePtr)pWin, pPriv,
		     pBuffer->pSourceGC, pBuffer->pMaskGC,
		     x, y, pCursor->bits->width, pCursor->bits->height,
		     source, mask);
    }
    return TRUE;
}
Ejemplo n.º 4
0
Bool
miDCUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
{
    miDCCursorPtr   pPriv;

    pPriv = (miDCCursorPtr)dixLookupScreenPrivate(&pCursor->bits->devPrivates,
						  miDCCursorBitsKey, pScreen);
    if (pPriv && (pCursor->bits->refcnt <= 1))
    {
	if (pPriv->sourceBits)
	    (*pScreen->DestroyPixmap) (pPriv->sourceBits);
	if (pPriv->maskBits)
	    (*pScreen->DestroyPixmap) (pPriv->maskBits);
#ifdef ARGB_CURSOR
	if (pPriv->pPicture)
	    FreePicture (pPriv->pPicture, 0);
#endif
	free((pointer) pPriv);
	dixSetScreenPrivate(&pCursor->bits->devPrivates, miDCCursorBitsKey, pScreen, NULL);
    }
    return TRUE;
}