Blame SOURCES/0001-xfixes-Remove-the-CursorCurrent-array.patch

4724a4
From a5e2c313721615d40ebf328f3619286a88dae238 Mon Sep 17 00:00:00 2001
4724a4
From: Adam Jackson <ajax@redhat.com>
4724a4
Date: Wed, 17 May 2017 14:17:01 -0400
4724a4
Subject: [PATCH xserver] xfixes: Remove the CursorCurrent array
4724a4
4724a4
We're not wrapping all the ways a cursor can be destroyed, so this array
4724a4
ends up with stale data. Rather than try harder to wrap more code paths,
4724a4
just look up the cursor when we need it.
4724a4
4724a4
Signed-off-by: Adam Jackson <ajax@redhat.com>
4724a4
---
4724a4
 xfixes/cursor.c | 28 +++++++++++++++++++++-------
4724a4
 1 file changed, 21 insertions(+), 7 deletions(-)
4724a4
4724a4
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
4724a4
index c1ab3beda..b7c47bc00 100644
4724a4
--- a/xfixes/cursor.c
4724a4
+++ b/xfixes/cursor.c
4724a4
@@ -61,7 +61,6 @@
4724a4
 static RESTYPE CursorClientType;
4724a4
 static RESTYPE CursorHideCountType;
4724a4
 static RESTYPE CursorWindowType;
4724a4
-static CursorPtr CursorCurrent[MAXDEVICES];
4724a4
 
4724a4
 static DevPrivateKeyRec CursorScreenPrivateKeyRec;
4724a4
 
4724a4
@@ -132,10 +131,26 @@ typedef struct _CursorScreen {
4724a4
 Bool CursorVisible = FALSE;
4724a4
 Bool EnableCursor = TRUE;
4724a4
 
4724a4
+static CursorPtr
4724a4
+CursorForDevice(DeviceIntPtr pDev)
4724a4
+{
4724a4
+    if (pDev && pDev->spriteInfo && pDev->spriteInfo->sprite)
4724a4
+        return pDev->spriteInfo->sprite->current;
4724a4
+
4724a4
+    return NULL;
4724a4
+}
4724a4
+
4724a4
+static CursorPtr
4724a4
+CursorForClient(ClientPtr client)
4724a4
+{
4724a4
+    return CursorForDevice(PickPointer(client));
4724a4
+}
4724a4
+
4724a4
 static Bool
4724a4
 CursorDisplayCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
4724a4
 {
4724a4
     CursorScreenPtr cs = GetCursorScreen(pScreen);
4724a4
+    CursorPtr pOldCursor = CursorForDevice(pDev);
4724a4
     Bool ret;
4724a4
     DisplayCursorProcPtr backupProc;
4724a4
 
4724a4
@@ -150,11 +165,10 @@ CursorDisplayCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
4724a4
         ret = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor);
4724a4
     }
4724a4
 
4724a4
-    if (pCursor != CursorCurrent[pDev->id]) {
4724a4
+    if (pCursor != pOldCursor) {
4724a4
         CursorEventPtr e;
4724a4
 
4724a4
         UpdateCurrentTimeIf();
4724a4
-        CursorCurrent[pDev->id] = pCursor;
4724a4
         for (e = cursorEvents; e; e = e->next) {
4724a4
             if ((e->eventMask & XFixesDisplayCursorNotifyMask)) {
4724a4
                 xXFixesCursorNotifyEvent ev = {
4724a4
@@ -350,7 +364,7 @@ ProcXFixesGetCursorImage(ClientPtr client)
4724a4
     int npixels, width, height, rc, x, y;
4724a4
 
4724a4
     REQUEST_SIZE_MATCH(xXFixesGetCursorImageReq);
4724a4
-    pCursor = CursorCurrent[PickPointer(client)->id];
4724a4
+    pCursor = CursorForClient(client);
4724a4
     if (!pCursor)
4724a4
         return BadCursor;
4724a4
     rc = XaceHook(XACE_RESOURCE_ACCESS, client, pCursor->id, RT_CURSOR,
4724a4
@@ -499,7 +513,7 @@ ProcXFixesGetCursorImageAndName(ClientPtr client)
4724a4
     int rc, x, y;
4724a4
 
4724a4
     REQUEST_SIZE_MATCH(xXFixesGetCursorImageAndNameReq);
4724a4
-    pCursor = CursorCurrent[PickPointer(client)->id];
4724a4
+    pCursor = CursorForClient(client);
4724a4
     if (!pCursor)
4724a4
         return BadCursor;
4724a4
     rc = XaceHook(XACE_RESOURCE_ACCESS, client, pCursor->id, RT_CURSOR,
4724a4
@@ -873,7 +887,7 @@ ProcXFixesHideCursor(ClientPtr client)
4724a4
         for (dev = inputInfo.devices; dev; dev = dev->next) {
4724a4
             if (IsMaster(dev) && IsPointerDevice(dev))
4724a4
                 CursorDisplayCursor(dev, pWin->drawable.pScreen,
4724a4
-                                    CursorCurrent[dev->id]);
4724a4
+                                    CursorForDevice(dev));
4724a4
         }
4724a4
     }
4724a4
 
4724a4
@@ -968,7 +982,7 @@ CursorFreeHideCount(void *data, XID id)
4724a4
     deleteCursorHideCount(pChc, pChc->pScreen);
4724a4
     for (dev = inputInfo.devices; dev; dev = dev->next) {
4724a4
         if (IsMaster(dev) && IsPointerDevice(dev))
4724a4
-            CursorDisplayCursor(dev, pScreen, CursorCurrent[dev->id]);
4724a4
+            CursorDisplayCursor(dev, pScreen, CursorForDevice(dev));
4724a4
     }
4724a4
 
4724a4
     return 1;
4724a4
-- 
4724a4
2.13.0
4724a4