[PATCH xserver 3/3] xf86Cursor: Take the input lock in xf86Set/MoveCursor

Michel Dänzer michel at daenzer.net
Wed Oct 5 09:41:38 UTC 2016


From: Michel Dänzer <michel.daenzer at amd.com>

Prevents the HW cursor from intermittently jumping around when the
cursor image is changed while the cursor is being moved. This is hardly
noticeable in normal operation but can be quite confusing when stepping
through these codepaths in a debugger.

Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
 hw/xfree86/ramdac/xf86HWCurs.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/hw/xfree86/ramdac/xf86HWCurs.c b/hw/xfree86/ramdac/xf86HWCurs.c
index ddfd7c4..c2ea395 100644
--- a/hw/xfree86/ramdac/xf86HWCurs.c
+++ b/hw/xfree86/ramdac/xf86HWCurs.c
@@ -212,12 +212,15 @@ Bool
 xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
 {
     ScreenPtr pSlave;
+    Bool ret = FALSE;
+
+    input_lock();
 
     x -= pCurs->bits->xhot;
     y -= pCurs->bits->yhot;
 
     if (!xf86ScreenSetCursor(pScreen, pCurs, x, y))
-        return FALSE;
+        goto out;
 
     /* ask each slave driver to set the cursor. */
     xorg_list_for_each_entry(pSlave, &pScreen->slave_list, slave_head) {
@@ -230,10 +233,14 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
              * otherwise both the hw and sw cursor will show.
              */
             xf86SetCursor(pScreen, NullCursor, x, y);
-            return FALSE;
+            goto out;
         }
     }
-    return TRUE;
+    ret = TRUE;
+
+ out:
+    input_unlock();
+    return ret;
 }
 
 void
@@ -278,6 +285,8 @@ xf86MoveCursor(ScreenPtr pScreen, int x, int y)
     CursorPtr pCurs = xf86CurrentCursor(pScreen);
     ScreenPtr pSlave;
 
+    input_lock();
+
     x -= pCurs->bits->xhot;
     y -= pCurs->bits->yhot;
 
@@ -290,6 +299,8 @@ xf86MoveCursor(ScreenPtr pScreen, int x, int y)
 
         xf86ScreenMoveCursor(pSlave, x, y);
     }
+
+    input_unlock();
 }
 
 void
-- 
2.9.3



More information about the xorg-devel mailing list