From b04767c84deafc44993723add4b1c5163fc11711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Wed, 21 Oct 2015 18:33:46 +0900 Subject: [PATCH] xfree86: Re-set current cursor after RandR 1.2 CRTC configuration change Add xf86CursorResetCursor, which allows switching between HW and SW cursor depending on the current state. Call it from xf86DisableUnusedFunctions, which is called after any CRTC configuration change such as setting a mode or disabling a CRTC. This makes sure that SW cursor is used e.g. while a transform is in use on any CRTC or while there are active PRIME output slaves, and enables HW cursor again once none of those conditions are true anymore. Reviewed-by: Keith Packard --- hw/xfree86/modes/xf86Crtc.c | 6 ++++++ hw/xfree86/ramdac/xf86Cursor.c | 24 ++++++++++++++++++++++++ hw/xfree86/ramdac/xf86Cursor.h | 1 + 3 files changed, 31 insertions(+) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 38bc58cbc..2639a3085 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -3121,6 +3121,12 @@ xf86DisableUnusedFunctions(ScrnInfoPtr pScrn) xf86_crtc_notify(pScrn->pScreen); if (pScrn->ModeSet) pScrn->ModeSet(pScrn); + if (pScrn->pScreen) { + if (pScrn->pScreen->isGPU) + xf86CursorResetCursor(pScrn->pScreen->current_master); + else + xf86CursorResetCursor(pScrn->pScreen); + } } #ifdef RANDR_12_INTERFACE diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c index 2a54571cb..c061b8028 100644 --- a/hw/xfree86/ramdac/xf86Cursor.c +++ b/hw/xfree86/ramdac/xf86Cursor.c @@ -385,6 +385,30 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs, (*ScreenPriv->spriteFuncs->SetCursor) (pDev, pScreen, pCurs, x, y); } +/* Re-set the current cursor. This will switch between hardware and software + * cursor depending on whether hardware cursor is currently supported + * according to the driver. + */ +void +xf86CursorResetCursor(ScreenPtr pScreen) +{ + xf86CursorScreenPtr ScreenPriv; + + if (!inputInfo.pointer) + return; + + if (!dixPrivateKeyRegistered(xf86CursorScreenKey)) + return; + + ScreenPriv = (xf86CursorScreenPtr) dixLookupPrivate(&pScreen->devPrivates, + xf86CursorScreenKey); + if (!ScreenPriv) + return; + + xf86CursorSetCursor(inputInfo.pointer, pScreen, ScreenPriv->CurrentCursor, + ScreenPriv->x, ScreenPriv->y); +} + static void xf86CursorMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) { diff --git a/hw/xfree86/ramdac/xf86Cursor.h b/hw/xfree86/ramdac/xf86Cursor.h index 8c98bb151..6e88240d9 100644 --- a/hw/xfree86/ramdac/xf86Cursor.h +++ b/hw/xfree86/ramdac/xf86Cursor.h @@ -59,6 +59,7 @@ extern _X_EXPORT Bool xf86InitCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr); extern _X_EXPORT xf86CursorInfoPtr xf86CreateCursorInfoRec(void); extern _X_EXPORT void xf86DestroyCursorInfoRec(xf86CursorInfoPtr); +extern _X_EXPORT void xf86CursorResetCursor(ScreenPtr pScreen); extern _X_EXPORT void xf86ForceHWCursor(ScreenPtr pScreen, Bool on); #define HARDWARE_CURSOR_INVERT_MASK 0x00000001