/*
 * 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 = xf86_config->cursor;
    int			c;
    CARD8		*bits = cursor ?
        dixLookupPrivate(&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 (crtc->funcs->load_cursor_image)
		crtc->funcs->set_cursor_colors (crtc, bg, fg);
	    else if (bits)
		xf86_crtc_convert_cursor_to_argb (crtc, bits);
	}
    }
}
示例#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 = xf86Screens[screen->myNum];
    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)
    {
#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0)
	void *src = dixLookupPrivate(&cursor->devPrivates, CursorScreenKey(screen));
#else
	void *src = cursor->devPriv[screen->myNum];
#endif
#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);
    }
}