summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-02-22 13:25:54 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-02-22 13:27:38 +1000
commitf7a9b3fb20c730a4511e344356f5bb253bd1c835 (patch)
tree7b1bc7c2b5f34b03edc136ac9cfc9b0aa32c1c76
parentcfc7afc3cc8111c67dcbb96c1eb5f80e4866f358 (diff)
xfixes: use struct list for pointer barriers.pointer-barriers
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--xfixes/cursor.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index 3cafc2473..1be6e1835 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);