Blob Blame History Raw
From b8e4a6a4b78946e2155e0413ce396d587ab35a66 Mon Sep 17 00:00:00 2001
From: Adam Jackson <ajax@redhat.com>
Date: Fri, 9 Feb 2018 16:03:38 -0500
Subject: [PATCH xserver 6/6] animcur: Change which CursorPtr we save in
 external state

Formerly spriteInfo->anim.pCursor would point to the animated cursor (or
NULL if not animated). That value would also be available in
spriteInfo->sprite->current, so instead lets use anim.pCursor to point
to the current animation element.

(Also: having done this, look that one up from the XFixes requests)

Signed-off-by: Adam Jackson <ajax@redhat.com>
(cherry picked from commit e4edcaca33d3b23f612d5a91a93f52770d8fab3e)
---
 render/animcur.c | 7 ++++---
 xfixes/cursor.c  | 5 ++++-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/render/animcur.c b/render/animcur.c
index e585a8f23..50e254d01 100644
--- a/render/animcur.c
+++ b/render/animcur.c
@@ -133,7 +133,7 @@ AnimCurTimerNotify(OsTimerPtr timer, CARD32 now, void *arg)
     ScreenPtr pScreen = dev->spriteInfo->anim.pScreen;
     AnimCurScreenPtr as = GetAnimCurScreen(pScreen);

-    AnimCurPtr ac = GetAnimCur(dev->spriteInfo->anim.pCursor);
+    AnimCurPtr ac = GetAnimCur(dev->spriteInfo->sprite->current);
     int elt = (dev->spriteInfo->anim.elt + 1) % ac->nelt;
     DisplayCursorProcPtr DisplayCursor = pScreen->DisplayCursor;

@@ -148,6 +148,7 @@ AnimCurTimerNotify(OsTimerPtr timer, CARD32 now, void *arg)

     dev->spriteInfo->anim.elt = elt;
     dev->spriteInfo->anim.time = now + ac->elts[elt].delay;
+    dev->spriteInfo->anim.pCursor = ac->elts[elt].pCursor;

     return ac->elts[elt].delay;
 }
@@ -155,7 +156,7 @@ AnimCurTimerNotify(OsTimerPtr timer, CARD32 now, void *arg)
 static void
 AnimCurCancelTimer(DeviceIntPtr pDev)
 {
-    CursorPtr cur = pDev->spriteInfo->anim.pCursor;
+    CursorPtr cur = pDev->spriteInfo->sprite->current;

     if (IsAnimCur(cur))
         TimerCancel(GetAnimCur(cur)->timer);
@@ -172,7 +173,7 @@ AnimCurDisplayCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)

     Unwrap(as, pScreen, DisplayCursor);
     if (IsAnimCur(pCursor)) {
-        if (pCursor != pDev->spriteInfo->anim.pCursor) {
+        if (pCursor != pDev->spriteInfo->sprite->current) {
             AnimCurPtr ac = GetAnimCur(pCursor);

             AnimCurCancelTimer(pDev);
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index a150f450b..a1fbd562e 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -134,8 +134,11 @@ Bool EnableCursor = TRUE;
 static CursorPtr
 CursorForDevice(DeviceIntPtr pDev)
 {
-    if (pDev && pDev->spriteInfo && pDev->spriteInfo->sprite)
+    if (pDev && pDev->spriteInfo && pDev->spriteInfo->sprite) {
+        if (pDev->spriteInfo->anim.pCursor)
+            return pDev->spriteInfo->anim.pCursor;
         return pDev->spriteInfo->sprite->current;
+    }

     return NULL;
 }
--
2.14.3