Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
 xfixes/cursor.c |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index 3cafc24..1be6e18 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -116,7 +116,7 @@ typedef struct PointerBarrierClient 
*PointerBarrierClientPtr;
 struct PointerBarrierClient {
     ScreenPtr screen;
     struct PointerBarrier barrier;
-    PointerBarrierClientPtr next;
+    struct list entry;
 };
 
 /*
@@ -128,7 +128,7 @@ typedef struct _CursorScreen {
     CloseScreenProcPtr         CloseScreen;
     ConstrainCursorHarderProcPtr ConstrainCursorHarder;
     CursorHideCountPtr          pCursorHideCounts;
-    PointerBarrierClientPtr    barriers;
+    struct list                 barriers;
 } CursorScreenRec, *CursorScreenPtr;
 
 #define GetCursorScreen(s) 
((CursorScreenPtr)dixLookupPrivate(&(s)->devPrivates, CursorScreenPrivateKey))
@@ -1175,7 +1175,7 @@ barrier_find_nearest(CursorScreenPtr cs, int dir,
     struct PointerBarrier *nearest = NULL;
     double min_distance = INT_MAX; /* can't get higher than that in X anyway */
 
-    for (c = cs->barriers; c; c = c->next) {
+    list_for_each_entry(c, &cs->barriers, entry) {
        struct PointerBarrier *b = &c->barrier;
        double distance;
 
@@ -1229,7 +1229,7 @@ CursorConstrainCursorHarder(DeviceIntPtr dev, ScreenPtr 
screen, int mode, int *x
 {
     CursorScreenPtr cs = GetCursorScreen(screen);
 
-    if (cs->barriers && !IsFloating(dev) && mode == Relative) {
+    if (!list_is_empty(&cs->barriers) && !IsFloating(dev) && mode == Relative) 
{
        int ox, oy;
        int dir;
        struct PointerBarrier *nearest = NULL;
@@ -1286,8 +1286,7 @@ CreatePointerBarrierClient(ScreenPtr screen, ClientPtr 
client,
        ret->barrier.y1 = stuff->y1;
        ret->barrier.y2 = stuff->y2;
        ret->barrier.directions = stuff->directions & 0x0f;
-       ret->next = cs->barriers;
-       cs->barriers = ret;
+       list_add(&ret->entry, &cs->barriers);
     }
 
     return ret;
@@ -1363,11 +1362,9 @@ CursorFreeBarrier(void *data, XID id)
     cs = GetCursorScreen(screen);
 
     /* find and unlink from the screen private */
-    if (cs->barriers == barrier)
-       cs->barriers = cs->barriers->next;
-    else for (b = cs->barriers; b; b = b->next) {
-       if (b->next == barrier) {
-           b->next = b->next->next;
+    list_for_each_entry(b, &cs->barriers, entry) {
+       if (b == barrier) {
+           list_del(&b->entry);
            break;
        }
     }
@@ -1428,6 +1425,7 @@ XFixesCursorInit (void)
        cs = (CursorScreenPtr) calloc(1, sizeof (CursorScreenRec));
        if (!cs)
            return FALSE;
+       list_init(&cs->barriers);
        Wrap (cs, pScreen, CloseScreen, CursorCloseScreen);
        Wrap (cs, pScreen, DisplayCursor, CursorDisplayCursor);
        Wrap (cs, pScreen, ConstrainCursorHarder, CursorConstrainCursorHarder);
-- 
1.7.4

_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to