[Xquartz-changes] xserver: Branch 'master' - 14 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Fri Feb 10 22:24:16 PST 2012


 Xi/exevents.c                      |  160 +++++++++++++++++++------------------
 Xi/xiallowev.c                     |   81 +++++++-----------
 configure.ac                       |    6 -
 dix/events.c                       |   36 +++-----
 dix/inpututils.c                   |    3 
 dix/touch.c                        |   73 +++++++++++++++-
 hw/xfree86/common/xf86Xinput.c     |   10 +-
 hw/xfree86/dri2/dri2.c             |   20 ++--
 hw/xfree86/os-support/xf86_OSlib.h |    2 
 hw/xfree86/parser/InputClass.c     |   76 ++++++++---------
 hw/xfree86/parser/xf86Parser.h     |   20 ++--
 include/exevents.h                 |    7 +
 include/input.h                    |    7 +
 include/inputstr.h                 |    5 -
 include/list.h                     |  114 +++++++++++++-------------
 test/input.c                       |   12 +-
 test/list.c                        |  132 +++++++++++++++---------------
 xfixes/cursor.c                    |   16 +--
 18 files changed, 427 insertions(+), 353 deletions(-)

New commits:
commit 62edd970f6f36058fcb31de4555eb7c1329cce74
Author: Keith Packard <keithp at keithp.com>
Date:   Sat Feb 11 16:13:44 2012 +1300

    Bump to version 1.11.99.903 (1.12 RC3)
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index 7e48d44..a44a12a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,8 +26,8 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.60)
-AC_INIT([xorg-server], 1.11.99.902, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="2012-01-27"
+AC_INIT([xorg-server], 1.11.99.903, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="2012-02-11"
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_MAINTAINER_MODE
commit 42b6756463ee0476340656707f1088dc6c2fd220
Merge: 7674d00 ca64912
Author: Keith Packard <keithp at keithp.com>
Date:   Sat Feb 11 15:36:43 2012 +1300

    Merge remote-tracking branch 'alanc/master'

commit 7674d00b04da5cf73cfa5c7ed1d3a9f42b59960e
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Jan 27 12:41:09 2012 +1000

    Xi: handle new XIAllowEvents request in inputproto 2.1.99.6
    
    grab_window and touchid were removed from the struct for ABI compatibility
    reasons, we need to pull in the new, XI 2.2-specific struct.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/Xi/xiallowev.c b/Xi/xiallowev.c
index 38967b2..d0856b6 100644
--- a/Xi/xiallowev.c
+++ b/Xi/xiallowev.c
@@ -41,6 +41,7 @@
 #include <X11/extensions/XI2proto.h>
 
 #include "exglobals.h" /* BadDevice */
+#include "exevents.h"
 #include "xiallowev.h"
 
 int
@@ -51,8 +52,12 @@ SProcXIAllowEvents(ClientPtr client)
     swaps(&stuff->length);
     swaps(&stuff->deviceid);
     swapl(&stuff->time);
-    /* FIXME swap touchid */
-    /* FIXME swap window */
+    if (stuff->length > 3)
+    {
+        xXI2_2AllowEventsReq *req_xi22 = (xXI2_2AllowEventsReq*)stuff;
+        swapl(&req_xi22->touchid);
+        swapl(&req_xi22->grab_window);
+    }
 
     return ProcXIAllowEvents(client);
 }
@@ -63,9 +68,21 @@ ProcXIAllowEvents(ClientPtr client)
     TimeStamp time;
     DeviceIntPtr dev;
     int ret = Success;
+    XIClientPtr xi_client;
+    Bool have_xi22 = FALSE;
+    REQUEST(xXI2_2AllowEventsReq);
 
-    REQUEST(xXIAllowEventsReq);
-    /* FIXME: check request length, 12 for XI 2.0+, 20 for XI 2.2+ */
+    xi_client = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey);
+
+    if (version_compare(xi_client->major_version,
+                        xi_client->minor_version, 2, 2) >= 0)
+    {
+        REQUEST_AT_LEAST_SIZE(xXI2_2AllowEventsReq);
+        have_xi22 = TRUE;
+    } else
+    {
+        REQUEST_SIZE_MATCH(xXIAllowEventsReq);
+    }
 
     ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
     if (ret != Success)
@@ -97,8 +114,20 @@ ProcXIAllowEvents(ClientPtr client)
 	break;
     case XIRejectTouch:
     case XIAcceptTouch:
-        ret = TouchAcceptReject(client, dev, stuff->mode, stuff->touchid,
-                                stuff->grab_window, &client->errorValue);
+        {
+            int rc;
+            WindowPtr win;
+
+            if (!have_xi22)
+                return BadValue;
+
+            rc = dixLookupWindow(&win, stuff->grab_window, client, DixReadAccess);
+            if (rc != Success)
+                return rc;
+
+            ret = TouchAcceptReject(client, dev, stuff->mode, stuff->touchid,
+                                    stuff->grab_window, &client->errorValue);
+        }
         break;
     default:
 	client->errorValue = stuff->mode;
diff --git a/configure.ac b/configure.ac
index 6241119..7e48d44 100644
--- a/configure.ac
+++ b/configure.ac
@@ -776,7 +776,7 @@ XPROTO="xproto >= 7.0.22"
 RANDRPROTO="randrproto >= 1.2.99.3"
 RENDERPROTO="renderproto >= 0.11"
 XEXTPROTO="xextproto >= 7.1.99"
-INPUTPROTO="inputproto >= 2.1.99.5"
+INPUTPROTO="inputproto >= 2.1.99.6"
 KBPROTO="kbproto >= 1.0.3"
 FONTSPROTO="fontsproto"
 FIXESPROTO="fixesproto >= 5.0"
commit b96275c4cdb164aa71f7aa9fbf88be18886d1936
Author: Benjamin Otte <otte at redhat.com>
Date:   Tue Feb 7 18:01:25 2012 +1000

    dix: fix an out-of-memory crash
    
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/inpututils.c b/dix/inpututils.c
index d279c1d..9e0c551 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -432,6 +432,9 @@ valuator_mask_new(int num_valuators)
      * flying-car future, when we can dynamically alloc the masks and are
      * not constrained by signals, we can start using num_valuators */
     ValuatorMask *mask = calloc(1, sizeof(ValuatorMask));
+    if (mask == NULL)
+        return NULL;
+
     mask->last_bit = -1;
     return mask;
 }
commit 6241b5e4fdbdb08d30cc8787d858ac27122d2d49
Author: Chase Douglas <chase.douglas at canonical.com>
Date:   Fri Feb 3 16:19:11 2012 -0800

    Implement touch early accept
    
    This doesn't really implement early accept as it should. Ideally, the
    server should send end events to all subsequent touch clients as soon as
    an early accept comes in. However, this implementation is still protocol
    compliant. We can always improve it later.
    
    Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index b0832d0..1ecc3ba 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1088,6 +1088,27 @@ DeliverOneTouchEvent(ClientPtr client, DeviceIntPtr dev, TouchPointInfoPtr ti,
     return TRUE;
 }
 
+static void
+ActivateEarlyAccept(DeviceIntPtr dev, TouchPointInfoPtr ti)
+{
+    int rc;
+    ClientPtr client;
+    XID error;
+
+    rc = dixLookupClient(&client, ti->listeners[0].listener, serverClient,
+                         DixSendAccess);
+    if (rc != Success)
+    {
+        ErrorF("[Xi] Failed to lookup early accepting client.\n");
+        return;
+    }
+
+    if (TouchAcceptReject(client, dev, XIAcceptTouch, ti->client_id,
+                          ti->listeners[0].window->drawable.id, &error) !=
+        Success)
+        ErrorF("[Xi] Failed to accept touch grab after early acceptance.\n");
+}
+
 /**
  * Generate and deliver a TouchEnd event.
  *
@@ -1130,7 +1151,8 @@ TouchPuntToNextOwner(DeviceIntPtr dev, TouchPointInfoPtr ti,
                      TouchOwnershipEvent *ev)
 {
     /* Deliver the ownership */
-    if (ti->listeners[0].state == LISTENER_AWAITING_OWNER)
+    if (ti->listeners[0].state == LISTENER_AWAITING_OWNER ||
+        ti->listeners[0].state == LISTENER_EARLY_ACCEPT)
         DeliverTouchEvents(dev, ti, (InternalEvent*)ev, ti->listeners[0].listener);
     else if (ti->listeners[0].state == LISTENER_AWAITING_BEGIN)
         TouchEventHistoryReplay(ti, dev, ti->listeners[0].listener);
@@ -1143,6 +1165,9 @@ TouchPuntToNextOwner(DeviceIntPtr dev, TouchPointInfoPtr ti,
         EmitTouchEnd(dev, ti, 0, 0);
         TouchEndTouch(dev, ti);
     }
+
+    if (ti->listeners[0].state == LISTENER_EARLY_ACCEPT)
+        ActivateEarlyAccept(dev, ti);
 }
 
 /**
diff --git a/dix/touch.c b/dix/touch.c
index f55bb8c..d04801c 100644
--- a/dix/touch.c
+++ b/dix/touch.c
@@ -1022,12 +1022,11 @@ TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
     if (i > 0)
     {
         if (mode == XIRejectTouch)
-        {
             TouchRejected(dev, ti, ti->listeners[i].listener, NULL);
-            return Success;
-        }
-        /* FIXME: Implement early accept */
-        return BadAccess;
+        else
+            ti->listeners[i].state = LISTENER_EARLY_ACCEPT;
+
+        return Success;
     }
 
     nev = GetTouchOwnershipEvents(events, dev, ti, mode,
diff --git a/include/input.h b/include/input.h
index fea5a31..b7825a7 100644
--- a/include/input.h
+++ b/include/input.h
@@ -583,6 +583,8 @@ extern _X_EXPORT void FreeInputAttributes(InputAttributes *attrs);
 enum TouchListenerState{
     LISTENER_AWAITING_BEGIN = 0,   /**< Waiting for a TouchBegin event */
     LISTENER_AWAITING_OWNER,       /**< Waiting for a TouchOwnership event */
+    LISTENER_EARLY_ACCEPT,         /**< Waiting for ownership, has already
+                                        accepted */
     LISTENER_IS_OWNER,             /**< Is the current owner */
     LISTENER_HAS_END,              /**< Has already received the end event */
 };
commit b0c54856df71f9cabf9dad176fdade960ef8c5d9
Author: Chase Douglas <chase.douglas at canonical.com>
Date:   Fri Feb 3 16:19:10 2012 -0800

    Implement early touch reject
    
    Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/touch.c b/dix/touch.c
index 7daf81b..f55bb8c 100644
--- a/dix/touch.c
+++ b/dix/touch.c
@@ -1019,9 +1019,16 @@ TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
     if (i == ti->num_listeners)
         return BadAccess;
 
-    /* FIXME: Implement early accept/reject */
     if (i > 0)
+    {
+        if (mode == XIRejectTouch)
+        {
+            TouchRejected(dev, ti, ti->listeners[i].listener, NULL);
+            return Success;
+        }
+        /* FIXME: Implement early accept */
         return BadAccess;
+    }
 
     nev = GetTouchOwnershipEvents(events, dev, ti, mode,
                                   ti->listeners[0].listener, 0);
commit 656ab879f20892975510723ce8fe78faf64aadb4
Author: Chase Douglas <chase.douglas at canonical.com>
Date:   Fri Feb 3 16:19:09 2012 -0800

    Check for proper window ID when processing touch allow requests
    
    Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/xiallowev.c b/Xi/xiallowev.c
index dab3393..38967b2 100644
--- a/Xi/xiallowev.c
+++ b/Xi/xiallowev.c
@@ -98,7 +98,7 @@ ProcXIAllowEvents(ClientPtr client)
     case XIRejectTouch:
     case XIAcceptTouch:
         ret = TouchAcceptReject(client, dev, stuff->mode, stuff->touchid,
-                                &client->errorValue);
+                                stuff->grab_window, &client->errorValue);
         break;
     default:
 	client->errorValue = stuff->mode;
diff --git a/dix/touch.c b/dix/touch.c
index 4a116ee..7daf81b 100644
--- a/dix/touch.c
+++ b/dix/touch.c
@@ -988,7 +988,7 @@ TouchListenerGone(XID resource)
 
 int
 TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
-                  uint32_t touchid, XID *error)
+                  uint32_t touchid, Window grab_window, XID *error)
 {
     TouchPointInfoPtr ti;
     int nev, i;
@@ -1003,8 +1003,6 @@ TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
         return BadDevice;
     }
 
-    /* FIXME window is unhandled */
-
     ti = TouchFindByClientID(dev, touchid);
     if (!ti)
     {
@@ -1012,9 +1010,17 @@ TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
         return BadValue;
     }
 
-    /* FIXME: Allow for early accept */
-    if (ti->num_listeners == 0 ||
-        CLIENT_ID(ti->listeners[0].listener) != client->index)
+    for (i = 0; i < ti->num_listeners; i++)
+    {
+        if (CLIENT_ID(ti->listeners[i].listener) == client->index &&
+            ti->listeners[i].window->drawable.id == grab_window)
+            break;
+    }
+    if (i == ti->num_listeners)
+        return BadAccess;
+
+    /* FIXME: Implement early accept/reject */
+    if (i > 0)
         return BadAccess;
 
     nev = GetTouchOwnershipEvents(events, dev, ti, mode,
diff --git a/include/input.h b/include/input.h
index 605e74d..fea5a31 100644
--- a/include/input.h
+++ b/include/input.h
@@ -626,7 +626,7 @@ extern int TouchGetPointerEventType(const InternalEvent *ev);
 extern void TouchRemovePointerGrab(DeviceIntPtr dev);
 extern void TouchListenerGone(XID resource);
 extern int TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
-                             uint32_t touchid, XID *error);
+                             uint32_t touchid, Window grab_window, XID *error);
 
 /* misc event helpers */
 extern Mask GetEventMask(DeviceIntPtr dev, xEvent* ev, InputClientsPtr clients);
commit 9a260e9af83feb5c53ffd3b2da2dc3adf06240a1
Author: Chase Douglas <chase.douglas at canonical.com>
Date:   Fri Feb 3 16:19:08 2012 -0800

    Move AllowTouch to dix/touch.c, and rename to TouchAcceptReject
    
    Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/xiallowev.c b/Xi/xiallowev.c
index a4b2f57..dab3393 100644
--- a/Xi/xiallowev.c
+++ b/Xi/xiallowev.c
@@ -57,47 +57,6 @@ SProcXIAllowEvents(ClientPtr client)
     return ProcXIAllowEvents(client);
 }
 
-static int
-AllowTouch(ClientPtr client, DeviceIntPtr dev, int mode, uint32_t touchid, XID *error)
-{
-    TouchPointInfoPtr ti;
-    int nev, i;
-    InternalEvent *events = InitEventList(GetMaximumEventsNum());
-
-    if (!events)
-        return BadAlloc;
-
-    if (!dev->touch)
-    {
-        *error = dev->id;
-        return BadDevice;
-    }
-
-    /* FIXME window is unhandled */
-
-    ti = TouchFindByClientID(dev, touchid);
-    if (!ti)
-    {
-        *error = touchid;
-        return BadValue;
-    }
-
-    /* FIXME: Allow for early accept */
-    if (ti->num_listeners == 0 || CLIENT_ID(ti->listeners[0].listener) != client->index)
-        return BadAccess;
-
-    nev = GetTouchOwnershipEvents(events, dev, ti, mode, ti->listeners[0].listener, 0);
-    if (nev == 0)
-        return BadAlloc;
-    for (i = 0; i < nev; i++)
-        mieqProcessDeviceEvent(dev, events + i, NULL);
-
-    ProcessInputEvents();
-
-    FreeEventList(events, GetMaximumEventsNum());
-    return Success;
-}
-
 int
 ProcXIAllowEvents(ClientPtr client)
 {
@@ -138,9 +97,8 @@ ProcXIAllowEvents(ClientPtr client)
 	break;
     case XIRejectTouch:
     case XIAcceptTouch:
-        ret = AllowTouch(client, dev,
-                         stuff->mode, stuff->touchid,
-                         &client->errorValue);
+        ret = TouchAcceptReject(client, dev, stuff->mode, stuff->touchid,
+                                &client->errorValue);
         break;
     default:
 	client->errorValue = stuff->mode;
diff --git a/dix/touch.c b/dix/touch.c
index b42859d..4a116ee 100644
--- a/dix/touch.c
+++ b/dix/touch.c
@@ -34,6 +34,7 @@
 
 #include "eventstr.h"
 #include "exevents.h"
+#include "exglobals.h"
 #include "inpututils.h"
 #include "eventconvert.h"
 #include "windowstr.h"
@@ -984,3 +985,47 @@ TouchListenerGone(XID resource)
 
     FreeEventList(events, GetMaximumEventsNum());
 }
+
+int
+TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
+                  uint32_t touchid, XID *error)
+{
+    TouchPointInfoPtr ti;
+    int nev, i;
+    InternalEvent *events = InitEventList(GetMaximumEventsNum());
+
+    if (!events)
+        return BadAlloc;
+
+    if (!dev->touch)
+    {
+        *error = dev->id;
+        return BadDevice;
+    }
+
+    /* FIXME window is unhandled */
+
+    ti = TouchFindByClientID(dev, touchid);
+    if (!ti)
+    {
+        *error = touchid;
+        return BadValue;
+    }
+
+    /* FIXME: Allow for early accept */
+    if (ti->num_listeners == 0 ||
+        CLIENT_ID(ti->listeners[0].listener) != client->index)
+        return BadAccess;
+
+    nev = GetTouchOwnershipEvents(events, dev, ti, mode,
+                                  ti->listeners[0].listener, 0);
+    if (nev == 0)
+        return BadAlloc;
+    for (i = 0; i < nev; i++)
+        mieqProcessDeviceEvent(dev, events + i, NULL);
+
+    ProcessInputEvents();
+
+    FreeEventList(events, GetMaximumEventsNum());
+    return Success;
+}
diff --git a/include/input.h b/include/input.h
index 53645b4..605e74d 100644
--- a/include/input.h
+++ b/include/input.h
@@ -625,6 +625,8 @@ extern int TouchConvertToPointerEvent(const InternalEvent *ev,
 extern int TouchGetPointerEventType(const InternalEvent *ev);
 extern void TouchRemovePointerGrab(DeviceIntPtr dev);
 extern void TouchListenerGone(XID resource);
+extern int TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
+                             uint32_t touchid, XID *error);
 
 /* misc event helpers */
 extern Mask GetEventMask(DeviceIntPtr dev, xEvent* ev, InputClientsPtr clients);
commit 192b2c9a2ec04522655675ddfe71de5cf974cc7b
Author: Chase Douglas <chase.douglas at canonical.com>
Date:   Fri Feb 3 16:19:07 2012 -0800

    Export TouchEventRejected as TouchRejected
    
    This function is mostly correct for early reject usage. With a small
    change to pass the client resource explicitly and making the
    TouchOwnership event optional, it is usable for all rejection scenarios.
    This change exports it for use outside Xi/exevents.c and modifies the
    name accordingly.
    
    Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 218df2a..b0832d0 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1145,18 +1145,34 @@ TouchPuntToNextOwner(DeviceIntPtr dev, TouchPointInfoPtr ti,
     }
 }
 
-static void
-TouchEventRejected(DeviceIntPtr sourcedev, TouchPointInfoPtr ti,
-                   TouchOwnershipEvent *ev)
+/**
+ * Process a touch rejection.
+ *
+ * @param sourcedev The source device of the touch sequence.
+ * @param ti The touchpoint info record.
+ * @param resource The resource of the client rejecting the touch.
+ * @param ev TouchOwnership event to send. Set to NULL if no event should be
+ *        sent.
+ */
+void
+TouchRejected(DeviceIntPtr sourcedev, TouchPointInfoPtr ti, XID resource,
+              TouchOwnershipEvent *ev)
 {
-    Bool was_owner = (ev->resource == ti->listeners[0].listener);
+    Bool was_owner = (resource == ti->listeners[0].listener);
     void *grab;
-
+    int i;
 
     /* Send a TouchEnd event to the resource being removed, but only if they
      * haven't received one yet already */
-    if (ti->listeners[0].state != LISTENER_HAS_END)
-        EmitTouchEnd(sourcedev, ti, TOUCH_REJECT, ev->resource);
+    for (i = 0; i < ti->num_listeners; i++)
+    {
+        if (ti->listeners[i].listener == resource)
+        {
+            if (ti->listeners[i].state != LISTENER_HAS_END)
+                EmitTouchEnd(sourcedev, ti, TOUCH_REJECT, resource);
+            break;
+        }
+    }
 
     /* If there are no other listeners left, and the touchpoint is pending
      * finish, then we can just kill it now. */
@@ -1168,16 +1184,16 @@ TouchEventRejected(DeviceIntPtr sourcedev, TouchPointInfoPtr ti,
 
     /* Remove the resource from the listener list, updating
      * ti->num_listeners, as well as ti->num_grabs if it was a grab. */
-    if (TouchRemoveListener(ti, ev->resource))
+    if (TouchRemoveListener(ti, resource))
     {
-        if (dixLookupResourceByType(&grab, ev->resource, RT_PASSIVEGRAB,
+        if (dixLookupResourceByType(&grab, resource, RT_PASSIVEGRAB,
                                     serverClient, DixGetAttrAccess) == Success)
             ti->num_grabs--;
     }
 
     /* If the current owner was removed and there are further listeners, deliver
      * the TouchOwnership or TouchBegin event to the new owner. */
-    if (ti->num_listeners > 0 && was_owner)
+    if (ev && ti->num_listeners > 0 && was_owner)
         TouchPuntToNextOwner(sourcedev, ti, ev);
 }
 
@@ -1194,7 +1210,7 @@ ProcessTouchOwnershipEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
 {
 
     if (ev->reason == XIRejectTouch)
-        TouchEventRejected(dev, ti, ev);
+        TouchRejected(dev, ti, ev->resource, ev);
     else if (ev->reason == XIAcceptTouch) {
         /* The touch owner has accepted the touch.  Send TouchEnd events to
          * everyone else, and truncate the list of listeners. */
diff --git a/include/exevents.h b/include/exevents.h
index 31acb30..fb2ef27 100644
--- a/include/exevents.h
+++ b/include/exevents.h
@@ -323,6 +323,13 @@ SendEventToAllWindows(
         xEvent *               /* ev */,
         int                    /* count */);
 
+extern void
+TouchRejected(
+        DeviceIntPtr           /* sourcedev */,
+        TouchPointInfoPtr      /* ti */,
+        XID                    /* resource */,
+        TouchOwnershipEvent *  /* ev */);
+
 extern _X_HIDDEN void XI2EventSwap(
         xGenericEvent  *              /* from */,
         xGenericEvent  *              /* to */);
commit 19073425e5df1317f73f74ce0b95ab24e0e0da14
Author: Chase Douglas <chase.douglas at canonical.com>
Date:   Fri Feb 3 16:19:06 2012 -0800

    Factor out TouchEnd generation and delivery
    
    The server often needs to generate and deliver TouchEnd events for
    circumstances including touch grab acceptance and rejection. This change
    refactors the code so it can be used more easily.
    
    Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 6b2db4b..218df2a 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1089,17 +1089,46 @@ DeliverOneTouchEvent(ClientPtr client, DeviceIntPtr dev, TouchPointInfoPtr ti,
 }
 
 /**
- * If the current owner has rejected the event, deliver the
- * TouchOwnership/TouchBegin to the next item in the sprite stack.
+ * Generate and deliver a TouchEnd event.
+ *
+ * @param dev The device to deliver the event for.
+ * @param ti The touch point record to deliver the event for.
+ * @param flags Internal event flags. The called does not need to provide
+ *        TOUCH_CLIENT_ID and TOUCH_POINTER_EMULATED, this function will ensure
+ *        they are set appropriately.
+ * @param resource The client resource to deliver to, or 0 for all clients.
  */
 static void
-TouchPuntToNextOwner(DeviceIntPtr dev, TouchPointInfoPtr ti,
-                     TouchOwnershipEvent *ev)
+EmitTouchEnd(DeviceIntPtr dev, TouchPointInfoPtr ti, int flags, XID resource)
 {
     InternalEvent *tel = InitEventList(GetMaximumEventsNum());
     ValuatorMask *mask = valuator_mask_new(2);
     int i, nev;
 
+    valuator_mask_set_double(mask, 0,
+                             valuator_mask_get_double(ti->valuators, 0));
+    valuator_mask_set_double(mask, 1,
+                             valuator_mask_get_double(ti->valuators, 1));
+
+    flags |= TOUCH_CLIENT_ID;
+    if (ti->emulate_pointer)
+        flags |= TOUCH_POINTER_EMULATED;
+    nev = GetTouchEvents(tel, dev, ti->client_id, XI_TouchEnd, flags, mask);
+    for (i = 0; i < nev; i++)
+        DeliverTouchEvents(dev, ti, tel + i, resource);
+
+    valuator_mask_free(&mask);
+    FreeEventList(tel, GetMaximumEventsNum());
+}
+
+/**
+ * If the current owner has rejected the event, deliver the
+ * TouchOwnership/TouchBegin to the next item in the sprite stack.
+ */
+static void
+TouchPuntToNextOwner(DeviceIntPtr dev, TouchPointInfoPtr ti,
+                     TouchOwnershipEvent *ev)
+{
     /* Deliver the ownership */
     if (ti->listeners[0].state == LISTENER_AWAITING_OWNER)
         DeliverTouchEvents(dev, ti, (InternalEvent*)ev, ti->listeners[0].listener);
@@ -1111,60 +1140,30 @@ TouchPuntToNextOwner(DeviceIntPtr dev, TouchPointInfoPtr ti,
     if (ti->num_listeners == 1 && ti->num_grabs == 0 &&
             ti->pending_finish)
     {
-        int flags;
-        valuator_mask_set_double(mask, 0,
-                                 valuator_mask_get_double(ti->valuators, 0));
-        valuator_mask_set_double(mask, 1,
-                                 valuator_mask_get_double(ti->valuators, 1));
-
-        flags = TOUCH_CLIENT_ID;
-        if (ti->emulate_pointer)
-            flags |= TOUCH_POINTER_EMULATED;
-        nev = GetTouchEvents(tel, dev, ti->client_id, XI_TouchEnd, flags, mask);
-        for (i = 0; i < nev; i++)
-            DeliverTouchEvents(dev, ti, tel + i, 0);
+        EmitTouchEnd(dev, ti, 0, 0);
         TouchEndTouch(dev, ti);
     }
-
-    valuator_mask_free(&mask);
-    FreeEventList(tel, GetMaximumEventsNum());
 }
 
 static void
 TouchEventRejected(DeviceIntPtr sourcedev, TouchPointInfoPtr ti,
                    TouchOwnershipEvent *ev)
 {
-    InternalEvent *tel = InitEventList(GetMaximumEventsNum());
-    ValuatorMask *mask = valuator_mask_new(2);
     Bool was_owner = (ev->resource == ti->listeners[0].listener);
     void *grab;
-    int nev, i;
 
 
     /* Send a TouchEnd event to the resource being removed, but only if they
      * haven't received one yet already */
     if (ti->listeners[0].state != LISTENER_HAS_END)
-    {
-        int flags;
-        valuator_mask_set_double(mask, 0,
-                                 valuator_mask_get_double(ti->valuators, 0));
-        valuator_mask_set_double(mask, 1,
-                                 valuator_mask_get_double(ti->valuators, 1));
-
-        flags = TOUCH_CLIENT_ID|TOUCH_REJECT;
-        if (ti->emulate_pointer)
-            flags |= TOUCH_POINTER_EMULATED;
-        nev = GetTouchEvents(tel, sourcedev, ti->client_id, XI_TouchEnd, flags, mask);
-        for (i = 0; i < nev; i++)
-            DeliverTouchEvents(sourcedev, ti, tel + i, ev->resource);
-    }
+        EmitTouchEnd(sourcedev, ti, TOUCH_REJECT, ev->resource);
 
     /* If there are no other listeners left, and the touchpoint is pending
      * finish, then we can just kill it now. */
     if (ti->num_listeners == 1 && ti->pending_finish)
     {
         TouchEndTouch(sourcedev, ti);
-        goto out;
+        return;
     }
 
     /* Remove the resource from the listener list, updating
@@ -1180,10 +1179,6 @@ TouchEventRejected(DeviceIntPtr sourcedev, TouchPointInfoPtr ti,
      * the TouchOwnership or TouchBegin event to the new owner. */
     if (ti->num_listeners > 0 && was_owner)
         TouchPuntToNextOwner(sourcedev, ti, ev);
-
-out:
-    FreeEventList(tel, GetMaximumEventsNum());
-    valuator_mask_free(&mask);
 }
 
 /**
@@ -1201,33 +1196,9 @@ ProcessTouchOwnershipEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
     if (ev->reason == XIRejectTouch)
         TouchEventRejected(dev, ti, ev);
     else if (ev->reason == XIAcceptTouch) {
-        int flags;
-        int nev, i;
-        ValuatorMask *mask;
-
-        InternalEvent *tel = InitEventList(GetMaximumEventsNum());
-
-        mask = valuator_mask_new(dev->valuator->numAxes);
-        valuator_mask_set_double(mask, 0,
-                                 valuator_mask_get_double(ti->valuators, 0));
-        valuator_mask_set_double(mask, 1,
-                                 valuator_mask_get_double(ti->valuators, 1));
-
-        /* FIXME: what about early acceptance? a client may accept before it
-         * owns the touch. */
-
         /* The touch owner has accepted the touch.  Send TouchEnd events to
          * everyone else, and truncate the list of listeners. */
-        flags = TOUCH_ACCEPT|TOUCH_CLIENT_ID;
-        if (ti->emulate_pointer)
-            flags |= TOUCH_POINTER_EMULATED;
-        nev = GetTouchEvents(tel, dev, ti->client_id, XI_TouchEnd,
-                             flags, mask);
-        for (i = 0; i < nev; i++)
-            DeliverTouchEvents(dev, ti, tel + i, 0);
-
-        FreeEventList(tel, GetMaximumEventsNum());
-        valuator_mask_free(&mask);
+        EmitTouchEnd(dev, ti, TOUCH_ACCEPT, 0);
 
         while (ti->num_listeners > 1)
             TouchRemoveListener(ti, ti->listeners[1].listener);
commit ab60cadc2afb9d8882144e30fde11c3ef0f999cd
Author: Chase Douglas <chase.douglas at canonical.com>
Date:   Fri Feb 3 16:19:05 2012 -0800

    Store window pointer in touch listener record
    
    Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/touch.c b/dix/touch.c
index db0bf33..b42859d 100644
--- a/dix/touch.c
+++ b/dix/touch.c
@@ -697,12 +697,14 @@ TouchResourceIsOwner(TouchPointInfoPtr ti, XID resource)
  */
 void
 TouchAddListener(TouchPointInfoPtr ti, XID resource, enum InputLevel level,
-                 enum TouchListenerType type, enum TouchListenerState state)
+                 enum TouchListenerType type, enum TouchListenerState state,
+                 WindowPtr window)
 {
     ti->listeners[ti->num_listeners].listener = resource;
     ti->listeners[ti->num_listeners].level = level;
     ti->listeners[ti->num_listeners].state = state;
     ti->listeners[ti->num_listeners].type = type;
+    ti->listeners[ti->num_listeners].window = window;
     ti->num_listeners++;
 }
 
@@ -753,7 +755,7 @@ TouchAddGrabListener(DeviceIntPtr dev, TouchPointInfoPtr ti,
     }
 
     TouchAddListener(ti, grab->resource, grab->grabtype,
-                     type, LISTENER_AWAITING_BEGIN);
+                     type, LISTENER_AWAITING_BEGIN, grab->window);
     ti->num_grabs++;
 }
 
@@ -814,7 +816,7 @@ TouchAddRegularListener(DeviceIntPtr dev, TouchPointInfoPtr ti,
                 TouchEventHistoryAllocate(ti);
 
             TouchAddListener(ti, iclients->resource, XI2,
-                             type, LISTENER_AWAITING_BEGIN);
+                             type, LISTENER_AWAITING_BEGIN, win);
             return TRUE;
         }
     }
@@ -830,7 +832,8 @@ TouchAddRegularListener(DeviceIntPtr dev, TouchPointInfoPtr ti,
 
             TouchEventHistoryAllocate(ti);
             TouchAddListener(ti, iclients->resource, XI,
-                             LISTENER_POINTER_REGULAR, LISTENER_AWAITING_BEGIN);
+                             LISTENER_POINTER_REGULAR, LISTENER_AWAITING_BEGIN,
+                             win);
             return TRUE;
         }
     }
@@ -845,7 +848,8 @@ TouchAddRegularListener(DeviceIntPtr dev, TouchPointInfoPtr ti,
         {
             TouchEventHistoryAllocate(ti);
             TouchAddListener(ti, win->drawable.id, CORE,
-                             LISTENER_POINTER_REGULAR, LISTENER_AWAITING_BEGIN);
+                             LISTENER_POINTER_REGULAR, LISTENER_AWAITING_BEGIN,
+                             win);
             return TRUE;
         }
 
@@ -857,7 +861,7 @@ TouchAddRegularListener(DeviceIntPtr dev, TouchPointInfoPtr ti,
 
             TouchEventHistoryAllocate(ti);
             TouchAddListener(ti, iclients->resource, CORE,
-                             type, LISTENER_AWAITING_BEGIN);
+                             type, LISTENER_AWAITING_BEGIN, win);
             return TRUE;
         }
     }
diff --git a/include/input.h b/include/input.h
index fb45617..53645b4 100644
--- a/include/input.h
+++ b/include/input.h
@@ -613,7 +613,8 @@ extern void TouchEventHistoryPush(TouchPointInfoPtr ti, const DeviceEvent *ev);
 extern void TouchEventHistoryReplay(TouchPointInfoPtr ti, DeviceIntPtr dev, XID resource);
 extern Bool TouchResourceIsOwner(TouchPointInfoPtr ti, XID resource);
 extern void TouchAddListener(TouchPointInfoPtr ti, XID resource, enum InputLevel level,
-                                     enum TouchListenerType type, enum TouchListenerState state);
+                             enum TouchListenerType type, enum TouchListenerState state,
+                             WindowPtr window);
 extern Bool TouchRemoveListener(TouchPointInfoPtr ti, XID resource);
 extern void TouchSetupListeners(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev);
 extern Bool TouchEnsureSprite(DeviceIntPtr sourcedev, TouchPointInfoPtr ti,
diff --git a/include/inputstr.h b/include/inputstr.h
index c3297db..4e28bc7 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -314,6 +314,7 @@ typedef struct _TouchPointInfo {
         enum TouchListenerType type;
         enum TouchListenerState state;
         enum InputLevel level;      /* matters only for emulating touches */
+        WindowPtr window;
     } *listeners;
     int         num_listeners;
     int         num_grabs;          /* number of open grabs on this touch
commit f92ba92adfce0e1975feb54ab0e1165b7c2a7bea
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Sat Feb 4 19:27:21 2012 +1000

    Revert "dix: deduplicate callers of DeliverDeviceEvents in DeliverGrabbedEvents"
    
    This call was supposed to have no functional changes but in some cases
    DeliverDeviceEvents() was called with a uninitialised win variable.
    Revert, safer than trying to sort this out otherwise.
    
    This reverts commit 6eff14a789341d366b3013c5aa020e959c954651.
    
    Reported-by: Mathieu Taillefumier <mathieu.taillefumier at free.fr>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/dix/events.c b/dix/events.c
index 04d7fb5..3c7d5d0 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4266,7 +4266,6 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
     if (grab->ownerEvents)
     {
 	WindowPtr focus;
-	WindowPtr win;
 
         /* Hack: Some pointer device have a focus class. So we need to check
          * for the type of event, to see if we really want to deliver it to
@@ -4283,16 +4282,15 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
 	else
 	    focus = PointerRootWin;
 	if (focus == PointerRootWin)
-	{
-	    win = pSprite->win;
-	    focus = NullWindow;
-	} else if (focus && (focus == pSprite->win ||
-		    IsParent(focus, pSprite->win)))
-	    win = pSprite->win;
+	    deliveries = DeliverDeviceEvents(pSprite->win, event, grab,
+                                             NullWindow, thisDev);
+	else if (focus && (focus == pSprite->win ||
+                    IsParent(focus, pSprite->win)))
+	    deliveries = DeliverDeviceEvents(pSprite->win, event, grab, focus,
+					     thisDev);
 	else if (focus)
-	    win = focus;
-
-	deliveries = DeliverDeviceEvents(win, event, grab, focus, thisDev);
+	    deliveries = DeliverDeviceEvents(focus, event, grab, focus,
+					     thisDev);
     }
     if (!deliveries)
     {
commit ca64912c02bdff486fee420a49b11f54f8f5ba08
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Thu Jan 26 16:41:25 2012 -0800

    Namespace list api to reduce conflicts with similar system headers
    
    Rename functions/macros from list_* to xorg_list_*
    Rename struct from struct list to struct xorg_list.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    In-sed-I-trust: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/events.c b/dix/events.c
index 04d7fb5..e9f3685 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1122,8 +1122,8 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
     int		eventlen;
     DeviceEvent *event = &ev->device_event;
 
-    if (!list_is_empty(&syncEvents.pending))
-        tail = list_last_entry(&syncEvents.pending, QdEventRec, next);
+    if (!xorg_list_is_empty(&syncEvents.pending))
+        tail = xorg_list_last_entry(&syncEvents.pending, QdEventRec, next);
 
     NoticeTime((InternalEvent*)event);
 
@@ -1183,13 +1183,13 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
     qe = malloc(sizeof(QdEventRec) + eventlen);
     if (!qe)
 	return;
-    list_init(&qe->next);
+    xorg_list_init(&qe->next);
     qe->device = device;
     qe->pScreen = pSprite->hotPhys.pScreen;
     qe->months = currentTime.months;
     qe->event = (InternalEvent *)(qe + 1);
     memcpy(qe->event, event, eventlen);
-    list_append(&qe->next, &syncEvents.pending);
+    xorg_list_append(&qe->next, &syncEvents.pending);
 }
 
 /**
@@ -1210,10 +1210,10 @@ PlayReleasedEvents(void)
     DeviceIntPtr pDev;
 
 restart:
-    list_for_each_entry_safe(qe, tmp, &syncEvents.pending, next) {
+    xorg_list_for_each_entry_safe(qe, tmp, &syncEvents.pending, next) {
 	if (!qe->device->deviceGrab.sync.frozen)
 	{
-	    list_del(&qe->next);
+	    xorg_list_del(&qe->next);
 	    pDev = qe->device;
 	    if (qe->event->any.type == ET_Motion)
 		CheckVirtualMotion(pDev, qe, NullWindow);
@@ -1297,7 +1297,7 @@ ComputeFreezes(void)
 	FreezeThaw(dev, dev->deviceGrab.sync.other ||
                 (dev->deviceGrab.sync.state >= FROZEN));
     if (syncEvents.playingEvents ||
-        (!replayDev && list_is_empty(&syncEvents.pending)))
+        (!replayDev && xorg_list_is_empty(&syncEvents.pending)))
 	return;
     syncEvents.playingEvents = TRUE;
     if (replayDev)
@@ -5392,9 +5392,9 @@ InitEvents(void)
     syncEvents.replayDev = (DeviceIntPtr)NULL;
     syncEvents.replayWin = NullWindow;
     if (syncEvents.pending.next)
-        list_for_each_entry_safe(qe, tmp, &syncEvents.pending, next)
+        xorg_list_for_each_entry_safe(qe, tmp, &syncEvents.pending, next)
             free(qe);
-    list_init(&syncEvents.pending);
+    xorg_list_init(&syncEvents.pending);
     syncEvents.playingEvents = FALSE;
     syncEvents.time.months = 0;
     syncEvents.time.milliseconds = 0;	/* hardly matters */
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index fd40f28..f6be999 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -516,13 +516,13 @@ match_string_implicit(const char *attr, const char *pattern)
  * If a pattern in each list entry is matched, return TRUE.
  */
 static Bool
-MatchAttrToken(const char *attr, struct list *patterns,
+MatchAttrToken(const char *attr, struct xorg_list *patterns,
                int (*compare)(const char *attr, const char *pattern))
 {
     const xf86MatchGroup *group;
 
     /* If there are no patterns, accept the match */
-    if (list_is_empty(patterns))
+    if (xorg_list_is_empty(patterns))
         return TRUE;
 
     /* If there are patterns but no attribute, reject the match */
@@ -533,7 +533,7 @@ MatchAttrToken(const char *attr, struct list *patterns,
      * Otherwise, iterate the list of patterns ensuring each entry has a
      * match. Each list entry is a separate Match line of the same type.
      */
-    list_for_each_entry(group, patterns, entry) {
+    xorg_list_for_each_entry(group, patterns, entry) {
         char * const *cur;
         Bool match = FALSE;
 
@@ -590,7 +590,7 @@ InputClassMatches(const XF86ConfInputClassPtr iclass, const InputInfoPtr idev,
      * MatchTag string
      * See if any of the device's tags match any of the MatchTag tokens.
      */
-    if (!list_is_empty(&iclass->match_tag)) {
+    if (!xorg_list_is_empty(&iclass->match_tag)) {
         char * const *tag;
         Bool match;
 
@@ -607,7 +607,7 @@ InputClassMatches(const XF86ConfInputClassPtr iclass, const InputInfoPtr idev,
     }
 
     /* MatchLayout string */
-    if (!list_is_empty(&iclass->match_layout)) {
+    if (!xorg_list_is_empty(&iclass->match_layout)) {
         if (!MatchAttrToken(xf86ConfigLayout.id,
                             &iclass->match_layout, match_string_implicit))
             return FALSE;
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index d6441a2..5cc9068 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -67,7 +67,7 @@ typedef struct _DRI2Screen *DRI2ScreenPtr;
 typedef struct _DRI2Drawable {
     DRI2ScreenPtr        dri2_screen;
     DrawablePtr		 drawable;
-    struct list		 reference_list;
+    struct xorg_list	 reference_list;
     int			 width;
     int			 height;
     DRI2BufferPtr	*buffers;
@@ -179,7 +179,7 @@ DRI2AllocateDrawable(DrawablePtr pDraw)
     pPriv->swap_limit = 1; /* default to double buffering */
     pPriv->last_swap_msc = 0;
     pPriv->last_swap_ust = 0;
-    list_init(&pPriv->reference_list);
+    xorg_list_init(&pPriv->reference_list);
     pPriv->serialNumber = DRI2DrawableSerial(pDraw);
     pPriv->needInvalidate = FALSE;
 
@@ -229,7 +229,7 @@ typedef struct DRI2DrawableRefRec {
     XID		  dri2_id;
     DRI2InvalidateProcPtr	invalidate;
     void	 *priv;
-    struct list	  link;
+    struct xorg_list		link;
 } DRI2DrawableRefRec, *DRI2DrawableRefPtr;
 
 static DRI2DrawableRefPtr
@@ -237,7 +237,7 @@ DRI2LookupDrawableRef(DRI2DrawablePtr pPriv, XID id)
 {
     DRI2DrawableRefPtr ref;
 
-    list_for_each_entry(ref, &pPriv->reference_list, link) {
+    xorg_list_for_each_entry(ref, &pPriv->reference_list, link) {
 	if (ref->id == id)
 	    return ref;
     }
@@ -270,7 +270,7 @@ DRI2AddDrawableRef(DRI2DrawablePtr pPriv, XID id, XID dri2_id,
     ref->dri2_id = dri2_id; 
     ref->invalidate = invalidate;
     ref->priv = priv;
-    list_add(&ref->link, &pPriv->reference_list);
+    xorg_list_add(&ref->link, &pPriv->reference_list);
 
     return Success;
 }
@@ -307,9 +307,9 @@ static int DRI2DrawableGone(pointer p, XID id)
     DrawablePtr pDraw;
     int i;
 
-    list_for_each_entry_safe(ref, next, &pPriv->reference_list, link) {
+    xorg_list_for_each_entry_safe(ref, next, &pPriv->reference_list, link) {
 	if (ref->dri2_id == id) {
-	    list_del(&ref->link);
+	    xorg_list_del(&ref->link);
 	    /* If this was the last ref under this X drawable XID,
 	     * unregister the X drawable resource. */
 	    if (!DRI2LookupDrawableRef(pPriv, ref->id))
@@ -319,13 +319,13 @@ static int DRI2DrawableGone(pointer p, XID id)
 	}
 
 	if (ref->id == id) {
-	    list_del(&ref->link);
+	    xorg_list_del(&ref->link);
 	    FreeResourceByType(ref->dri2_id, dri2DrawableRes, TRUE);
 	    free(ref);
 	}
     }
 
-    if (!list_is_empty(&pPriv->reference_list))
+    if (!xorg_list_is_empty(&pPriv->reference_list))
 	return Success;
 
     pDraw = pPriv->drawable;
@@ -586,7 +586,7 @@ DRI2InvalidateDrawable(DrawablePtr pDraw)
 
     pPriv->needInvalidate = FALSE;
 
-    list_for_each_entry(ref, &pPriv->reference_list, link)
+    xorg_list_for_each_entry(ref, &pPriv->reference_list, link)
 	ref->invalidate(pDraw, ref->priv, ref->id);
 }
 
diff --git a/hw/xfree86/parser/InputClass.c b/hw/xfree86/parser/InputClass.c
index 919ae18..c25117c 100644
--- a/hw/xfree86/parser/InputClass.c
+++ b/hw/xfree86/parser/InputClass.c
@@ -67,14 +67,14 @@ xf86ConfigSymTabRec InputClassTab[] =
 #define TOKEN_SEP "|"
 
 static void
-add_group_entry(struct list *head, char **values)
+add_group_entry(struct xorg_list *head, char **values)
 {
     xf86MatchGroup *group;
 
     group = malloc(sizeof(*group));
     if (group) {
         group->values = values;
-        list_add(&group->entry, head);
+        xorg_list_add(&group->entry, head);
     }
 }
 
@@ -87,15 +87,15 @@ xf86parseInputClassSection(void)
     parsePrologue(XF86ConfInputClassPtr, XF86ConfInputClassRec)
 
     /* Initialize MatchGroup lists */
-    list_init(&ptr->match_product);
-    list_init(&ptr->match_vendor);
-    list_init(&ptr->match_device);
-    list_init(&ptr->match_os);
-    list_init(&ptr->match_pnpid);
-    list_init(&ptr->match_usbid);
-    list_init(&ptr->match_driver);
-    list_init(&ptr->match_tag);
-    list_init(&ptr->match_layout);
+    xorg_list_init(&ptr->match_product);
+    xorg_list_init(&ptr->match_vendor);
+    xorg_list_init(&ptr->match_device);
+    xorg_list_init(&ptr->match_os);
+    xorg_list_init(&ptr->match_pnpid);
+    xorg_list_init(&ptr->match_usbid);
+    xorg_list_init(&ptr->match_driver);
+    xorg_list_init(&ptr->match_tag);
+    xorg_list_init(&ptr->match_layout);
 
     while ((token = xf86getToken(InputClassTab)) != ENDSECTION) {
         switch (token) {
@@ -274,63 +274,63 @@ xf86printInputClassSection (FILE * cf, XF86ConfInputClassPtr ptr)
         if (ptr->driver)
             fprintf(cf, "\tDriver          \"%s\"\n", ptr->driver);
 
-        list_for_each_entry(group, &ptr->match_product, entry) {
+        xorg_list_for_each_entry(group, &ptr->match_product, entry) {
             fprintf(cf, "\tMatchProduct    \"");
             for (cur = group->values; *cur; cur++)
                 fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
                         *cur);
             fprintf(cf, "\"\n");
         }
-        list_for_each_entry(group, &ptr->match_vendor, entry) {
+        xorg_list_for_each_entry(group, &ptr->match_vendor, entry) {
             fprintf(cf, "\tMatchVendor     \"");
             for (cur = group->values; *cur; cur++)
                 fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
                         *cur);
             fprintf(cf, "\"\n");
         }
-        list_for_each_entry(group, &ptr->match_device, entry) {
+        xorg_list_for_each_entry(group, &ptr->match_device, entry) {
             fprintf(cf, "\tMatchDevicePath \"");
             for (cur = group->values; *cur; cur++)
                 fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
                         *cur);
             fprintf(cf, "\"\n");
         }
-        list_for_each_entry(group, &ptr->match_os, entry) {
+        xorg_list_for_each_entry(group, &ptr->match_os, entry) {
             fprintf(cf, "\tMatchOS         \"");
             for (cur = group->values; *cur; cur++)
                 fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
                         *cur);
             fprintf(cf, "\"\n");
         }
-        list_for_each_entry(group, &ptr->match_pnpid, entry) {
+        xorg_list_for_each_entry(group, &ptr->match_pnpid, entry) {
             fprintf(cf, "\tMatchPnPID      \"");
             for (cur = group->values; *cur; cur++)
                 fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
                         *cur);
             fprintf(cf, "\"\n");
         }
-        list_for_each_entry(group, &ptr->match_usbid, entry) {
+        xorg_list_for_each_entry(group, &ptr->match_usbid, entry) {
             fprintf(cf, "\tMatchUSBID      \"");
             for (cur = group->values; *cur; cur++)
                 fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
                         *cur);
             fprintf(cf, "\"\n");
         }
-        list_for_each_entry(group, &ptr->match_driver, entry) {
+        xorg_list_for_each_entry(group, &ptr->match_driver, entry) {
             fprintf(cf, "\tMatchDriver     \"");
             for (cur = group->values; *cur; cur++)
                 fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
                         *cur);
             fprintf(cf, "\"\n");
         }
-        list_for_each_entry(group, &ptr->match_tag, entry) {
+        xorg_list_for_each_entry(group, &ptr->match_tag, entry) {
             fprintf(cf, "\tMatchTag        \"");
             for (cur = group->values; *cur; cur++)
                 fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
                         *cur);
             fprintf(cf, "\"\n");
         }
-        list_for_each_entry(group, &ptr->match_layout, entry) {
+        xorg_list_for_each_entry(group, &ptr->match_layout, entry) {
             fprintf(cf, "\tMatchLayout     \"");
             for (cur = group->values; *cur; cur++)
                 fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
@@ -374,56 +374,56 @@ xf86freeInputClassList (XF86ConfInputClassPtr ptr)
         TestFree(ptr->identifier);
         TestFree(ptr->driver);
 
-        list_for_each_entry_safe(group, next, &ptr->match_product, entry) {
-            list_del(&group->entry);
+        xorg_list_for_each_entry_safe(group, next, &ptr->match_product, entry) {
+            xorg_list_del(&group->entry);
             for (list = group->values; *list; list++)
                 free(*list);
             free(group);
         }
-        list_for_each_entry_safe(group, next, &ptr->match_vendor, entry) {
-            list_del(&group->entry);
+        xorg_list_for_each_entry_safe(group, next, &ptr->match_vendor, entry) {
+            xorg_list_del(&group->entry);
             for (list = group->values; *list; list++)
                 free(*list);
             free(group);
         }
-        list_for_each_entry_safe(group, next, &ptr->match_device, entry) {
-            list_del(&group->entry);
+        xorg_list_for_each_entry_safe(group, next, &ptr->match_device, entry) {
+            xorg_list_del(&group->entry);
             for (list = group->values; *list; list++)
                 free(*list);
             free(group);
         }
-        list_for_each_entry_safe(group, next, &ptr->match_os, entry) {
-            list_del(&group->entry);
+        xorg_list_for_each_entry_safe(group, next, &ptr->match_os, entry) {
+            xorg_list_del(&group->entry);
             for (list = group->values; *list; list++)
                 free(*list);
             free(group);
         }
-        list_for_each_entry_safe(group, next, &ptr->match_pnpid, entry) {
-            list_del(&group->entry);
+        xorg_list_for_each_entry_safe(group, next, &ptr->match_pnpid, entry) {
+            xorg_list_del(&group->entry);
             for (list = group->values; *list; list++)
                 free(*list);
             free(group);
         }
-        list_for_each_entry_safe(group, next, &ptr->match_usbid, entry) {
-            list_del(&group->entry);
+        xorg_list_for_each_entry_safe(group, next, &ptr->match_usbid, entry) {
+            xorg_list_del(&group->entry);
             for (list = group->values; *list; list++)
                 free(*list);
             free(group);
         }
-        list_for_each_entry_safe(group, next, &ptr->match_driver, entry) {
-            list_del(&group->entry);
+        xorg_list_for_each_entry_safe(group, next, &ptr->match_driver, entry) {
+            xorg_list_del(&group->entry);
             for (list = group->values; *list; list++)
                 free(*list);
             free(group);
         }
-        list_for_each_entry_safe(group, next, &ptr->match_tag, entry) {
-            list_del(&group->entry);
+        xorg_list_for_each_entry_safe(group, next, &ptr->match_tag, entry) {
+            xorg_list_del(&group->entry);
             for (list = group->values; *list; list++)
                 free(*list);
             free(group);
         }
-        list_for_each_entry_safe(group, next, &ptr->match_layout, entry) {
-            list_del(&group->entry);
+        xorg_list_for_each_entry_safe(group, next, &ptr->match_layout, entry) {
+            xorg_list_del(&group->entry);
             for (list = group->values; *list; list++)
                 free(*list);
             free(group);
diff --git a/hw/xfree86/parser/xf86Parser.h b/hw/xfree86/parser/xf86Parser.h
index 7d4662b..beac354 100644
--- a/hw/xfree86/parser/xf86Parser.h
+++ b/hw/xfree86/parser/xf86Parser.h
@@ -340,7 +340,7 @@ xf86TriState;
 
 typedef struct
 {
-	struct list entry;
+	struct xorg_list entry;
 	char **values;
 }
 xf86MatchGroup;
@@ -350,15 +350,15 @@ typedef struct
 	GenericListRec list;
 	char *identifier;
 	char *driver;
-	struct list match_product;
-	struct list match_vendor;
-	struct list match_device;
-	struct list match_os;
-	struct list match_pnpid;
-	struct list match_usbid;
-	struct list match_driver;
-	struct list match_tag;
-	struct list match_layout;
+	struct xorg_list match_product;
+	struct xorg_list match_vendor;
+	struct xorg_list match_device;
+	struct xorg_list match_os;
+	struct xorg_list match_pnpid;
+	struct xorg_list match_usbid;
+	struct xorg_list match_driver;
+	struct xorg_list match_tag;
+	struct xorg_list match_layout;
 	xf86TriState is_keyboard;
 	xf86TriState is_pointer;
 	xf86TriState is_joystick;
diff --git a/include/inputstr.h b/include/inputstr.h
index c3297db..8a08f67 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -622,7 +622,7 @@ extern _X_EXPORT InputInfo inputInfo;
 /* for keeping the events for devices grabbed synchronously */
 typedef struct _QdEvent *QdEventPtr;
 typedef struct _QdEvent {
-    struct list		next;
+    struct xorg_list	next;
     DeviceIntPtr	device;
     ScreenPtr		pScreen;	/* what screen the pointer was on */
     unsigned long	months;		/* milliseconds is in the event */
@@ -638,7 +638,7 @@ typedef struct _QdEvent {
  * replayed and processed as if they would come from the device directly.
  */
 typedef struct _EventSyncInfo {
-    struct list         pending;
+    struct xorg_list    pending;
 
     /** The device to replay events for. Only set in AllowEvents(), in which
      * case it is set to the device specified in the request. */
diff --git a/include/list.h b/include/list.h
index 6ec2bac..14c671f 100644
--- a/include/list.h
+++ b/include/list.h
@@ -23,8 +23,8 @@
  *
  */
 
-#ifndef _LIST_H_
-#define _LIST_H_
+#ifndef _XORG_LIST_H_
+#define _XORG_LIST_H_
 
 /**
  * @file Classic doubly-link circular list implementation.
@@ -41,17 +41,17 @@
  *     }
  *
  * We need one list head in bar and a list element in all list_of_foos (both are of
- * data type 'struct list').
+ * data type 'struct xorg_list').
  *
  *     struct bar {
  *          ...
- *          struct list list_of_foos;
+ *          struct xorg_list list_of_foos;
  *          ...
  *     }
  *
  *     struct foo {
  *          ...
- *          struct list entry;
+ *          struct xorg_list entry;
  *          ...
  *     }
  *
@@ -59,74 +59,74 @@
  *
  *     struct bar bar;
  *     ...
- *     list_init(&bar.list_of_foos);
+ *     xorg_list_init(&bar.list_of_foos);
  *
  * Then we create the first element and add it to this list:
  *
  *     struct foo *foo = malloc(...);
  *     ....
- *     list_add(&foo->entry, &bar.list_of_foos);
+ *     xorg_list_add(&foo->entry, &bar.list_of_foos);
  *
  * Repeat the above for each element you want to add to the list. Deleting
  * works with the element itself.
- *      list_del(&foo->entry);
+ *      xorg_list_del(&foo->entry);
  *      free(foo);
  *
- * Note: calling list_del(&bar.list_of_foos) will set bar.list_of_foos to an empty
+ * Note: calling xorg_list_del(&bar.list_of_foos) will set bar.list_of_foos to an empty
  * list again.
  *
  * Looping through the list requires a 'struct foo' as iterator and the
  * name of the field the subnodes use.
  *
  * struct foo *iterator;
- * list_for_each_entry(iterator, &bar.list_of_foos, entry) {
+ * xorg_list_for_each_entry(iterator, &bar.list_of_foos, entry) {
  *      if (iterator->something == ...)
  *             ...
  * }
  *
- * Note: You must not call list_del() on the iterator if you continue the
+ * Note: You must not call xorg_list_del() on the iterator if you continue the
  * loop. You need to run the safe for-each loop instead:
  *
  * struct foo *iterator, *next;
- * list_for_each_entry_safe(iterator, next, &bar.list_of_foos, entry) {
+ * xorg_list_for_each_entry_safe(iterator, next, &bar.list_of_foos, entry) {
  *      if (...)
- *              list_del(&iterator->entry);
+ *              xorg_list_del(&iterator->entry);
  * }
  *
  */
 
 /**
  * The linkage struct for list nodes. This struct must be part of your
- * to-be-linked struct. struct list is required for both the head of the
+ * to-be-linked struct. struct xorg_list is required for both the head of the
  * list and for each list node.
  *
- * Position and name of the struct list field is irrelevant.
+ * Position and name of the struct xorg_list field is irrelevant.
  * There are no requirements that elements of a list are of the same type.
- * There are no requirements for a list head, any struct list can be a list
+ * There are no requirements for a list head, any struct xorg_list can be a list
  * head.
  */
-struct list {
-    struct list *next, *prev;
+struct xorg_list {
+    struct xorg_list *next, *prev;
 };
 
 /**
  * Initialize the list as an empty list.
  *
  * Example:
- * list_init(&bar->list_of_foos);
+ * xorg_list_init(&bar->list_of_foos);
  *
  * @param The list to initialized.
  */
 static void
-list_init(struct list *list)
+xorg_list_init(struct xorg_list *list)
 {
     list->next = list->prev = list;
 }
 
 static inline void
-__list_add(struct list *entry,
-	    struct list *prev,
-	    struct list *next)
+__xorg_list_add(struct xorg_list *entry,
+	    struct xorg_list *prev,
+	    struct xorg_list *next)
 {
     next->prev = entry;
     entry->next = next;
@@ -144,15 +144,15 @@ __list_add(struct list *entry,
  *
  * Example:
  * struct foo *newfoo = malloc(...);
- * list_add(&newfoo->entry, &bar->list_of_foos);
+ * xorg_list_add(&newfoo->entry, &bar->list_of_foos);
  *
  * @param entry The new element to prepend to the list.
  * @param head The existing list.
  */
 static inline void
-list_add(struct list *entry, struct list *head)
+xorg_list_add(struct xorg_list *entry, struct xorg_list *head)
 {
-    __list_add(entry, head, head->next);
+    __xorg_list_add(entry, head, head->next);
 }
 
 /**
@@ -165,20 +165,20 @@ list_add(struct list *entry, struct list *head)
  *
  * Example:
  * struct foo *newfoo = malloc(...);
- * list_append(&newfoo->entry, &bar->list_of_foos);
+ * xorg_list_append(&newfoo->entry, &bar->list_of_foos);
  *
  * @param entry The new element to prepend to the list.
  * @param head The existing list.
  */
 static inline void
-list_append(struct list *entry, struct list *head)
+xorg_list_append(struct xorg_list *entry, struct xorg_list *head)
 {
-    __list_add(entry, head->prev, head);
+    __xorg_list_add(entry, head->prev, head);
 }
 
 
 static inline void
-__list_del(struct list *prev, struct list *next)
+__xorg_list_del(struct xorg_list *prev, struct xorg_list *next)
 {
     next->prev = prev;
     prev->next = next;
@@ -189,32 +189,32 @@ __list_del(struct list *prev, struct list *next)
  * the pointers to/from this element so it is removed from the list. It does
  * NOT free the element itself or manipulate it otherwise.
  *
- * Using list_del on a pure list head (like in the example at the top of
+ * Using xorg_list_del on a pure list head (like in the example at the top of
  * this file) will NOT remove the first element from
  * the list but rather reset the list as empty list.
  *
  * Example:
- * list_del(&foo->entry);
+ * xorg_list_del(&foo->entry);
  *
  * @param entry The element to remove.
  */
 static inline void
-list_del(struct list *entry)
+xorg_list_del(struct xorg_list *entry)
 {
-    __list_del(entry->prev, entry->next);
-    list_init(entry);
+    __xorg_list_del(entry->prev, entry->next);
+    xorg_list_init(entry);
 }
 
 /**
  * Check if the list is empty.
  *
  * Example:
- * list_is_empty(&bar->list_of_foos);
+ * xorg_list_is_empty(&bar->list_of_foos);
  *
  * @return True if the list contains one or more elements or False otherwise.
  */
 static inline Bool
-list_is_empty(struct list *head)
+xorg_list_is_empty(struct xorg_list *head)
 {
     return head->next == head;
 }
@@ -227,9 +227,9 @@ list_is_empty(struct list *head)
  * f = container_of(&foo->entry, struct foo, entry);
  * assert(f == foo);
  *
- * @param ptr Pointer to the struct list.
+ * @param ptr Pointer to the struct xorg_list.
  * @param type Data type of the list element.
- * @param member Member name of the struct list field in the list element.
+ * @param member Member name of the struct xorg_list field in the list element.
  * @return A pointer to the data struct containing the list head.
  */
 #ifndef container_of
@@ -240,7 +240,7 @@ list_is_empty(struct list *head)
 /**
  * Alias of container_of
  */
-#define list_entry(ptr, type, member) \
+#define xorg_list_entry(ptr, type, member) \
     container_of(ptr, type, member)
 
 /**
@@ -248,30 +248,30 @@ list_is_empty(struct list *head)
  *
  * Example:
  * struct foo *first;
- * first = list_first_entry(&bar->list_of_foos, struct foo, list_of_foos);
+ * first = xorg_list_first_entry(&bar->list_of_foos, struct foo, list_of_foos);
  *
  * @param ptr The list head
  * @param type Data type of the list element to retrieve
- * @param member Member name of the struct list field in the list element.
+ * @param member Member name of the struct xorg_list field in the list element.
  * @return A pointer to the first list element.
  */
-#define list_first_entry(ptr, type, member) \
-    list_entry((ptr)->next, type, member)
+#define xorg_list_first_entry(ptr, type, member) \
+    xorg_list_entry((ptr)->next, type, member)
 
 /**
  * Retrieve the last list entry for the given listpointer.
  *
  * Example:
  * struct foo *first;
- * first = list_last_entry(&bar->list_of_foos, struct foo, list_of_foos);
+ * first = xorg_list_last_entry(&bar->list_of_foos, struct foo, list_of_foos);
  *
  * @param ptr The list head
  * @param type Data type of the list element to retrieve
- * @param member Member name of the struct list field in the list element.
+ * @param member Member name of the struct xorg_list field in the list element.
  * @return A pointer to the last list element.
  */
-#define list_last_entry(ptr, type, member) \
-    list_entry((ptr)->prev, type, member)
+#define xorg_list_last_entry(ptr, type, member) \
+    xorg_list_entry((ptr)->prev, type, member)
 
 #define __container_of(ptr, sample, member)				\
     (void *)((char *)(ptr)						\
@@ -281,19 +281,19 @@ list_is_empty(struct list *head)
  *
  * Example:
  * struct foo *iterator;
- * list_for_each_entry(iterator, &bar->list_of_foos, entry) {
+ * xorg_list_for_each_entry(iterator, &bar->list_of_foos, entry) {
  *      [modify iterator]
  * }
  *
- * This macro is not safe for node deletion. Use list_for_each_entry_safe
+ * This macro is not safe for node deletion. Use xorg_list_for_each_entry_safe
  * instead.
  *
  * @param pos Iterator variable of the type of the list elements.
  * @param head List head
- * @param member Member name of the struct list in the list elements.
+ * @param member Member name of the struct xorg_list in the list elements.
  *
  */
-#define list_for_each_entry(pos, head, member)				\
+#define xorg_list_for_each_entry(pos, head, member)				\
     for (pos = __container_of((head)->next, pos, member);		\
 	 &pos->member != (head);					\
 	 pos = __container_of(pos->member.next, pos, member))
@@ -303,9 +303,9 @@ list_is_empty(struct list *head)
  * macro allows for the deletion of a list element while looping through the
  * list.
  *
- * See list_for_each_entry for more details.
+ * See xorg_list_for_each_entry for more details.
  */
-#define list_for_each_entry_safe(pos, tmp, head, member)		\
+#define xorg_list_for_each_entry_safe(pos, tmp, head, member)		\
     for (pos = __container_of((head)->next, pos, member),		\
 	 tmp = __container_of(pos->member.next, pos, member);		\
 	 &pos->member != (head);					\
@@ -315,9 +315,9 @@ list_is_empty(struct list *head)
 
 /* NULL-Terminated List Interface
  *
- * The interface below does _not_ use the struct list as described above.
+ * The interface below does _not_ use the struct xorg_list as described above.
  * It is mainly for legacy structures that cannot easily be switched to
- * struct list.
+ * struct xorg_list.
  *
  * This interface is for structs like
  *      struct foo {
@@ -349,7 +349,7 @@ list_is_empty(struct list *head)
  * struct foo *element = list;
  * while ((element = nt_list_next(element, next)) { }
  *
- * This macro is not safe for node deletion. Use list_for_each_entry_safe
+ * This macro is not safe for node deletion. Use xorg_list_for_each_entry_safe
  * instead.
  *
  * @param list The list or current element.
diff --git a/test/input.c b/test/input.c
index 576cd85..e029141 100644
--- a/test/input.c
+++ b/test/input.c
@@ -1714,7 +1714,7 @@ dix_enqueue_events(void) {
     spriteInfo.sprite = &sprite;
 
     InitEvents();
-    assert(list_is_empty(&syncEvents.pending));
+    assert(xorg_list_is_empty(&syncEvents.pending));
 
     /* this way PlayReleasedEvents really runs through all events in the
      * queue */
@@ -1728,22 +1728,22 @@ dix_enqueue_events(void) {
         ev[i].any.length = sizeof(*ev);
         ev[i].any.type = i;
         EnqueueEvent(&ev[i], &dev);
-        assert(!list_is_empty(&syncEvents.pending));
-        qe = list_last_entry(&syncEvents.pending, QdEventRec, next);
+        assert(!xorg_list_is_empty(&syncEvents.pending));
+        qe = xorg_list_last_entry(&syncEvents.pending, QdEventRec, next);
         assert(memcmp(qe->event, &ev[i], ev[i].any.length) == 0);
-        qe = list_first_entry(&syncEvents.pending, QdEventRec, next);
+        qe = xorg_list_first_entry(&syncEvents.pending, QdEventRec, next);
         assert(memcmp(qe->event, &ev[0], ev[i].any.length) == 0);
     }
 
     /* calls process_input_proc */
     dev.deviceGrab.sync.frozen = 1;
     PlayReleasedEvents();
-    assert(!list_is_empty(&syncEvents.pending));
+    assert(!xorg_list_is_empty(&syncEvents.pending));
 
 
     dev.deviceGrab.sync.frozen = 0;
     PlayReleasedEvents();
-    assert(list_is_empty(&syncEvents.pending));
+    assert(xorg_list_is_empty(&syncEvents.pending));
 
     inputInfo.devices = NULL;
 }
diff --git a/test/list.c b/test/list.c
index ffb85ef..14bc74a 100644
--- a/test/list.c
+++ b/test/list.c
@@ -33,18 +33,18 @@
 
 struct parent {
     int a;
-    struct list children;
+    struct xorg_list children;
     int b;
 };
 
 struct child {
     int foo;
     int bar;
-    struct list node;
+    struct xorg_list node;
 };
 
 static void
-test_list_init(void)
+test_xorg_list_init(void)
 {
     struct parent parent, tmp;
 
@@ -54,146 +54,146 @@ test_list_init(void)
 
     tmp = parent;
 
-    list_init(&parent.children);
+    xorg_list_init(&parent.children);
 
     /* test we haven't touched anything else. */
     assert(parent.a == tmp.a);
     assert(parent.b == tmp.b);
 
-    assert(list_is_empty(&parent.children));
+    assert(xorg_list_is_empty(&parent.children));
 }
 
 static void
-test_list_add(void)
+test_xorg_list_add(void)
 {
     struct parent parent = {0};
     struct child child[3];
     struct child *c;
 
-    list_init(&parent.children);
+    xorg_list_init(&parent.children);
 
-    list_add(&child[0].node, &parent.children);
-    assert(!list_is_empty(&parent.children));
+    xorg_list_add(&child[0].node, &parent.children);
+    assert(!xorg_list_is_empty(&parent.children));
 
-    c = list_first_entry(&parent.children, struct child, node);
+    c = xorg_list_first_entry(&parent.children, struct child, node);
     assert(memcmp(c, &child[0], sizeof(struct child)) == 0);
 
-    /* note: list_add prepends */
-    list_add(&child[1].node, &parent.children);
-    c = list_first_entry(&parent.children, struct child, node);
+    /* note: xorg_list_add prepends */
+    xorg_list_add(&child[1].node, &parent.children);
+    c = xorg_list_first_entry(&parent.children, struct child, node);
     assert(memcmp(c, &child[1], sizeof(struct child)) == 0);
 
-    list_add(&child[2].node, &parent.children);
-    c = list_first_entry(&parent.children, struct child, node);
+    xorg_list_add(&child[2].node, &parent.children);
+    c = xorg_list_first_entry(&parent.children, struct child, node);
     assert(memcmp(c, &child[2], sizeof(struct child)) == 0);
 };
 
 static void
-test_list_append(void)
+test_xorg_list_append(void)
 {
     struct parent parent = {0};
     struct child child[3];
     struct child *c;
     int i;
 
-    list_init(&parent.children);
+    xorg_list_init(&parent.children);
 
-    list_append(&child[0].node, &parent.children);
-    assert(!list_is_empty(&parent.children));
+    xorg_list_append(&child[0].node, &parent.children);
+    assert(!xorg_list_is_empty(&parent.children));
 
-    c = list_first_entry(&parent.children, struct child, node);
+    c = xorg_list_first_entry(&parent.children, struct child, node);
     assert(memcmp(c, &child[0], sizeof(struct child)) == 0);
-    c = list_last_entry(&parent.children, struct child, node);
+    c = xorg_list_last_entry(&parent.children, struct child, node);
     assert(memcmp(c, &child[0], sizeof(struct child)) == 0);
 
-    list_append(&child[1].node, &parent.children);
-    c = list_first_entry(&parent.children, struct child, node);
+    xorg_list_append(&child[1].node, &parent.children);
+    c = xorg_list_first_entry(&parent.children, struct child, node);
     assert(memcmp(c, &child[0], sizeof(struct child)) == 0);
-    c = list_last_entry(&parent.children, struct child, node);
+    c = xorg_list_last_entry(&parent.children, struct child, node);
     assert(memcmp(c, &child[1], sizeof(struct child)) == 0);
 
-    list_append(&child[2].node, &parent.children);
-    c = list_first_entry(&parent.children, struct child, node);
+    xorg_list_append(&child[2].node, &parent.children);
+    c = xorg_list_first_entry(&parent.children, struct child, node);
     assert(memcmp(c, &child[0], sizeof(struct child)) == 0);
-    c = list_last_entry(&parent.children, struct child, node);
+    c = xorg_list_last_entry(&parent.children, struct child, node);
     assert(memcmp(c, &child[2], sizeof(struct child)) == 0);
 
     i = 0;
-    list_for_each_entry(c, &parent.children, node) {
+    xorg_list_for_each_entry(c, &parent.children, node) {
         assert(memcmp(c, &child[i++], sizeof(struct child)) == 0);
     }
 };
 
 static void
-test_list_del(void)
+test_xorg_list_del(void)
 {
     struct parent parent = {0};
     struct child child[3];
     struct child *c;
 
-    list_init(&parent.children);
+    xorg_list_init(&parent.children);
 
-    list_add(&child[0].node, &parent.children);
-    assert(!list_is_empty(&parent.children));
+    xorg_list_add(&child[0].node, &parent.children);
+    assert(!xorg_list_is_empty(&parent.children));
 
-    list_del(&parent.children);
-    assert(list_is_empty(&parent.children));
+    xorg_list_del(&parent.children);
+    assert(xorg_list_is_empty(&parent.children));
 
-    list_add(&child[0].node, &parent.children);
-    list_del(&child[0].node);
-    assert(list_is_empty(&parent.children));
+    xorg_list_add(&child[0].node, &parent.children);
+    xorg_list_del(&child[0].node);
+    assert(xorg_list_is_empty(&parent.children));
 
-    list_add(&child[0].node, &parent.children);
-    list_add(&child[1].node, &parent.children);
+    xorg_list_add(&child[0].node, &parent.children);
+    xorg_list_add(&child[1].node, &parent.children);
 
-    c = list_first_entry(&parent.children, struct child, node);
+    c = xorg_list_first_entry(&parent.children, struct child, node);
     assert(memcmp(c, &child[1], sizeof(struct child)) == 0);
 
     /* delete first node */
-    list_del(&child[1].node);
-    assert(!list_is_empty(&parent.children));
-    assert(list_is_empty(&child[1].node));
-    c = list_first_entry(&parent.children, struct child, node);
+    xorg_list_del(&child[1].node);
+    assert(!xorg_list_is_empty(&parent.children));
+    assert(xorg_list_is_empty(&child[1].node));
+    c = xorg_list_first_entry(&parent.children, struct child, node);
     assert(memcmp(c, &child[0], sizeof(struct child)) == 0);
 
     /* delete last node */
-    list_add(&child[1].node, &parent.children);
-    list_del(&child[0].node);
-    c = list_first_entry(&parent.children, struct child, node);
+    xorg_list_add(&child[1].node, &parent.children);
+    xorg_list_del(&child[0].node);
+    c = xorg_list_first_entry(&parent.children, struct child, node);
     assert(memcmp(c, &child[1], sizeof(struct child)) == 0);
 
     /* delete list head */
-    list_add(&child[0].node, &parent.children);
-    list_del(&parent.children);
-    assert(list_is_empty(&parent.children));
-    assert(!list_is_empty(&child[1].node));
-    assert(!list_is_empty(&child[2].node));
+    xorg_list_add(&child[0].node, &parent.children);
+    xorg_list_del(&parent.children);
+    assert(xorg_list_is_empty(&parent.children));
+    assert(!xorg_list_is_empty(&child[1].node));
+    assert(!xorg_list_is_empty(&child[2].node));
 }
 
 static void
-test_list_for_each(void)
+test_xorg_list_for_each(void)
 {
     struct parent parent = {0};
     struct child child[3];
     struct child *c;
     int i = 0;
 
-    list_init(&parent.children);
+    xorg_list_init(&parent.children);
 
-    list_add(&child[2].node, &parent.children);
-    list_add(&child[1].node, &parent.children);
-    list_add(&child[0].node, &parent.children);
+    xorg_list_add(&child[2].node, &parent.children);
+    xorg_list_add(&child[1].node, &parent.children);
+    xorg_list_add(&child[0].node, &parent.children);
 
-    list_for_each_entry(c, &parent.children, node) {
+    xorg_list_for_each_entry(c, &parent.children, node) {
         assert(memcmp(c, &child[i], sizeof(struct child)) == 0);
         i++;
     }
 
     /* foreach on empty list */
-    list_del(&parent.children);
-    assert(list_is_empty(&parent.children));
+    xorg_list_del(&parent.children);
+    assert(xorg_list_is_empty(&parent.children));
 
-    list_for_each_entry(c, &parent.children, node) {
+    xorg_list_for_each_entry(c, &parent.children, node) {
         assert(0); /* we must not get here */
     }
 }
@@ -359,11 +359,11 @@ test_nt_list_delete(void)
 
 int main(int argc, char** argv)
 {
-    test_list_init();
-    test_list_add();
-    test_list_append();
-    test_list_del();
-    test_list_for_each();
+    test_xorg_list_init();
+    test_xorg_list_add();
+    test_xorg_list_append();
+    test_xorg_list_del();
+    test_xorg_list_for_each();
 
     test_nt_list_init();
     test_nt_list_append();
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index 53f9f20..7c46269 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -116,7 +116,7 @@ typedef struct PointerBarrierClient *PointerBarrierClientPtr;
 struct PointerBarrierClient {
     ScreenPtr screen;
     struct PointerBarrier barrier;
-    struct list entry;
+    struct xorg_list entry;
 };
 
 /*
@@ -128,7 +128,7 @@ typedef struct _CursorScreen {
     CloseScreenProcPtr		CloseScreen;
     ConstrainCursorHarderProcPtr ConstrainCursorHarder;
     CursorHideCountPtr          pCursorHideCounts;
-    struct list                 barriers;
+    struct xorg_list            barriers;
 } CursorScreenRec, *CursorScreenPtr;
 
 #define GetCursorScreen(s) ((CursorScreenPtr)dixLookupPrivate(&(s)->devPrivates, CursorScreenPrivateKey))
@@ -1172,7 +1172,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 */
 
-    list_for_each_entry(c, &cs->barriers, entry) {
+    xorg_list_for_each_entry(c, &cs->barriers, entry) {
 	struct PointerBarrier *b = &c->barrier;
 	double distance;
 
@@ -1224,7 +1224,7 @@ CursorConstrainCursorHarder(DeviceIntPtr dev, ScreenPtr screen, int mode, int *x
 {
     CursorScreenPtr cs = GetCursorScreen(screen);
 
-    if (!list_is_empty(&cs->barriers) && !IsFloating(dev) && mode == Relative) {
+    if (!xorg_list_is_empty(&cs->barriers) && !IsFloating(dev) && mode == Relative) {
 	int ox, oy;
 	int dir;
 	struct PointerBarrier *nearest = NULL;
@@ -1285,7 +1285,7 @@ CreatePointerBarrierClient(ScreenPtr screen, ClientPtr client,
 	    ret->barrier.directions &= ~(BarrierPositiveX | BarrierNegativeX);
 	if (barrier_is_vertical(&ret->barrier))
 	    ret->barrier.directions &= ~(BarrierPositiveY | BarrierNegativeY);
-	list_add(&ret->entry, &cs->barriers);
+	xorg_list_add(&ret->entry, &cs->barriers);
     }
 
     return ret;
@@ -1364,9 +1364,9 @@ CursorFreeBarrier(void *data, XID id)
     cs = GetCursorScreen(screen);
 
     /* find and unlink from the screen private */
-    list_for_each_entry(b, &cs->barriers, entry) {
+    xorg_list_for_each_entry(b, &cs->barriers, entry) {
 	if (b == barrier) {
-	    list_del(&b->entry);
+	    xorg_list_del(&b->entry);
 	    break;
 	}
     }
@@ -1426,7 +1426,7 @@ XFixesCursorInit (void)
 	cs = (CursorScreenPtr) calloc(1, sizeof (CursorScreenRec));
 	if (!cs)
 	    return FALSE;
-	list_init(&cs->barriers);
+	xorg_list_init(&cs->barriers);
 	Wrap (cs, pScreen, CloseScreen, CursorCloseScreen);
 	Wrap (cs, pScreen, DisplayCursor, CursorDisplayCursor);
 	Wrap (cs, pScreen, ConstrainCursorHarder, CursorConstrainCursorHarder);
commit 1541e242d1607d0db57b0cc12faca9b1c2850c67
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Fri Dec 23 15:17:28 2011 -0800

    Stop including <sys/proc.h> from xf86_OSlib.h on Solaris
    
    We don't need anything from that header (which defines /proc & kernel
    structures for process information), and it causes some namespace conflicts.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/os-support/xf86_OSlib.h b/hw/xfree86/os-support/xf86_OSlib.h
index 0a5861f..45500db 100644
--- a/hw/xfree86/os-support/xf86_OSlib.h
+++ b/hw/xfree86/os-support/xf86_OSlib.h
@@ -98,8 +98,8 @@
 #  if !(defined (sun) && defined (SVR4))
 #    include <sys/immu.h>
 #    include <sys/region.h>
+#    include <sys/proc.h>
 #  endif
-#  include <sys/proc.h>
 #  include <sys/tss.h>
 #  include <sys/sysi86.h>
 #  if defined(SVR4) && !defined(sun)


More information about the Xquartz-changes mailing list