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

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