diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 15ffc29..75266ca 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -260,17 +260,31 @@ drmmode_set_cursor_position (xf86CrtcPtr crtc, int x, int y) static void drmmode_load_cursor_argb (xf86CrtcPtr crtc, CARD32 *image) { + drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; + drmmode_ptr drmmode = drmmode_crtc->drmmode; ScrnInfoPtr pScrn = crtc->scrn; I830Ptr pI830 = I830PTR(pScrn); int ret; + dri_bo *bo; + + /* If we can, double buffer cursor updates so we can avoid flicker */ + bo = dri_bo_alloc(pI830->bufmgr, "cursor", 64*64*4, 0); + if (!bo) + bo = pI830->cursor_mem->bo; - /* cursor should be mapped already */ - ret = dri_bo_subdata(pI830->cursor_mem->bo, 0, 64*64*4, image); + ret = dri_bo_subdata(bo, 0, 64*64*4, image); if (ret) xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR, "failed to set cursor: %s", strerror(-ret)); - return; + /* If we allocated the new object, go ahead and set the cursor */ + if (bo != pI830->cursor_mem->bo) { + drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, + bo->handle, 64, 64); + + dri_bo_unreference(pI830->cursor_mem->bo); + pI830->cursor_mem->bo = bo; + } }