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

Jeremy Huddleston jeremyhu at freedesktop.org
Wed Oct 26 00:07:31 PDT 2011


 Xi/exevents.c                     |   20 ++++-
 Xi/xiquerydevice.c                |    7 -
 dix/devices.c                     |    2 
 dix/eventconvert.c                |   67 +++++++++++++++---
 dix/getevents.c                   |   10 +-
 dix/inpututils.c                  |   34 ++++-----
 dix/ptrveloc.c                    |    4 -
 hw/kdrive/src/kinput.c            |  139 +++++++++++++++++++++-----------------
 hw/vfb/InitOutput.c               |    2 
 hw/xfree86/common/xf86Config.c    |   16 +++-
 hw/xfree86/common/xf86Init.c      |   29 -------
 hw/xfree86/common/xf86Option.c    |    3 
 hw/xfree86/common/xf86Optionstr.h |   13 ---
 hw/xfree86/common/xf86Xinput.c    |    5 -
 hw/xfree86/doc/ddxDesign.xml      |    4 -
 hw/xfree86/modes/xf86Crtc.c       |   41 +++++------
 hw/xfree86/parser/Flags.c         |    5 -
 hw/xfree86/parser/Layout.c        |    2 
 hw/xquartz/applewm.c              |    4 -
 hw/xquartz/xpr/appledri.c         |    4 -
 hw/xwin/winwindowswm.c            |    4 -
 include/eventstr.h                |    1 
 include/exevents.h                |    3 
 include/input.h                   |    3 
 include/inputstr.h                |    7 -
 include/list.h                    |   12 +++
 include/optionstr.h               |   14 +++
 test/xi2/protocol-eventconvert.c  |   27 ++++++-
 xkb/xkbActions.c                  |    7 +
 29 files changed, 295 insertions(+), 194 deletions(-)

New commits:
commit d8ac7d930f02fb89c6aed06af1d3a1cd3685b96b
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Tue Oct 25 23:53:43 2011 -0700

    XWin: windowswm: Correct event notification swapping
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xwin/winwindowswm.c b/hw/xwin/winwindowswm.c
index 403c859..577614d 100644
--- a/hw/xwin/winwindowswm.c
+++ b/hw/xwin/winwindowswm.c
@@ -629,9 +629,11 @@ winWindowsWMExtensionInit (void)
 			       NULL,
 			       StandardMinorOpcode)))
     {
+      size_t i;
       WMReqCode = (unsigned char)extEntry->base;
       WMErrorBase = extEntry->errorBase;
       WMEventBase = extEntry->eventBase;
-      EventSwapVector[WMEventBase] = (EventSwapPtr) SNotifyEvent;
+      for (i=0; i < WindowsWMNumberEvents; i++)
+        EventSwapVector[WMEventBase + i] = (EventSwapPtr) SNotifyEvent;
     }
 }
commit dfb0ea70a3893e0a88066538912b86f8b796841a
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Tue Oct 25 23:49:33 2011 -0700

    XQuartz: appledri: Correct event notification swapping
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c
index 6b4a8a3..44c132a 100644
--- a/hw/xquartz/xpr/appledri.c
+++ b/hw/xquartz/xpr/appledri.c
@@ -529,9 +529,11 @@ AppleDRIExtensionInit(void)
                                  SProcAppleDRIDispatch,
                                  AppleDRIResetProc,
                                  StandardMinorOpcode))) {
+        size_t i;
         DRIReqCode = (unsigned char)extEntry->base;
         DRIErrorBase = extEntry->errorBase;
         DRIEventBase = extEntry->eventBase;
-        EventSwapVector[DRIEventBase] = (EventSwapPtr) SNotifyEvent;
+        for (i=0; i < AppleDRINumberEvents; i++)
+            EventSwapVector[DRIEventBase + i] = (EventSwapPtr) SNotifyEvent;
     }
 }
commit 16ff8f30b67a7e6b6d14fc70de96597b35426902
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Tue Oct 25 23:48:16 2011 -0700

    XQuartz: applewm: Correct event notification swapping
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xquartz/applewm.c b/hw/xquartz/applewm.c
index 27fb125..55976c4 100644
--- a/hw/xquartz/applewm.c
+++ b/hw/xquartz/applewm.c
@@ -725,10 +725,12 @@ AppleWMExtensionInit(
                                  NULL,
                                  StandardMinorOpcode)))
     {
+        size_t i;
         WMReqCode = (unsigned char)extEntry->base;
         WMErrorBase = extEntry->errorBase;
         WMEventBase = extEntry->eventBase;
-        EventSwapVector[WMEventBase] = (EventSwapPtr) SNotifyEvent;
+        for (i=0; i < AppleWMNumberEvents; i++)
+            EventSwapVector[WMEventBase + i] = (EventSwapPtr) SNotifyEvent;
         appleWMProcs = procsPtr;
     }
 }
commit 5701ab4a441eb113abd0851b0d71b82d12112854
Merge: 7d50211 a41214b
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Oct 24 22:09:00 2011 -0700

    Merge remote-tracking branch 'whot/for-keith'

commit a41214bc9a0f326c6dc129e4a6382efb8b826862
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Oct 25 12:57:07 2011 +1000

    kdrive: check for null memory, fix OOB
    
    If key/value allocation failed, don't bother adding another InputOption. And
    make sure the memory allocated is large enough for the trailing \0
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index a1bbcaa..6a1ce49 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -1049,10 +1049,15 @@ KdGetOptions (InputOption **options, char *string)
     if (strchr(string, '='))
     {
         tam_key = (strchr(string, '=') - string);
-        key = malloc(tam_key);
+        key = malloc(tam_key + 1);
+        if (!key)
+            goto out;
+
         strncpy(key, string, tam_key);
         key[tam_key] = '\0';
         value = strdup(strchr(string, '=') + 1);
+        if (!value)
+            goto out;
     }
     else
     {
@@ -1064,6 +1069,7 @@ KdGetOptions (InputOption **options, char *string)
     if (newopt)
         *options = newopt;
 
+out:
     free(key);
     free(value);
 
commit ffe20acedb3cdc4811eb52f8fc540ba6af7339fa
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Oct 20 16:42:20 2011 +1000

    Use new FP1616/FP3232 conversion functions
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c
index 9961d1b..5f543f6 100644
--- a/Xi/xiquerydevice.c
+++ b/Xi/xiquerydevice.c
@@ -41,6 +41,7 @@
 #include "xserver-properties.h"
 #include "exevents.h"
 #include "xace.h"
+#include "inpututils.h"
 
 #include "xiquerydevice.h"
 
@@ -351,8 +352,7 @@ ListValuatorInfo(DeviceIntPtr dev, xXIValuatorInfo* info, int axisnumber,
     info->min.frac = 0;
     info->max.integral = v->axes[axisnumber].max_value;
     info->max.frac = 0;
-    info->value.integral = (int)v->axisVal[axisnumber];
-    info->value.frac = (int)(v->axisVal[axisnumber] * (1 << 16) * (1 << 16));
+    info->value = double_to_fp3232(v->axisVal[axisnumber]);
     info->resolution = v->axes[axisnumber].resolution;
     info->number = axisnumber;
     info->mode = valuator_get_mode(dev, axisnumber);
@@ -402,8 +402,7 @@ ListScrollInfo(DeviceIntPtr dev, xXIScrollInfo *info, int axisnumber)
             ErrorF("[Xi] Unknown scroll type %d. This is a bug.\n", axis->scroll.type);
             break;
     }
-    info->increment.integral = (int)axis->scroll.increment;
-    info->increment.frac = (unsigned int)(axis->scroll.increment * (1UL << 16) * (1UL << 16));
+    info->increment = double_to_fp3232(axis->scroll.increment);
     info->sourceid = v->sourceid;
 
     info->flags = 0;
diff --git a/dix/eventconvert.c b/dix/eventconvert.c
index ff42b03..c9da396 100644
--- a/dix/eventconvert.c
+++ b/dix/eventconvert.c
@@ -49,6 +49,7 @@
 #include "inpututils.h"
 #include "xiquerydevice.h"
 #include "xkbsrv.h"
+#include "inpututils.h"
 
 
 static int countValuators(DeviceEvent *ev, int *first);
@@ -686,9 +687,7 @@ eventToDeviceEvent(DeviceEvent *ev, xEvent **xi)
         if (BitIsOn(ev->valuators.mask, i))
         {
             SetBit(ptr, i);
-            axisval->integral = trunc(ev->valuators.data[i]);
-            axisval->frac = (ev->valuators.data[i] - axisval->integral) *
-                            (1 << 16) * (1 << 16);
+            *axisval = double_to_fp3232(ev->valuators.data[i]);
             axisval++;
         }
     }
@@ -732,13 +731,8 @@ eventToRawEvent(RawDeviceEvent *ev, xEvent **xi)
         if (BitIsOn(ev->valuators.mask, i))
         {
             SetBit(ptr, i);
-            axisval->integral = trunc(ev->valuators.data[i]);
-            axisval->frac = (ev->valuators.data[i] - axisval->integral) *
-                            (1 << 16) * (1 << 16);
-            axisval_raw->integral = trunc(ev->valuators.data_raw[i]);
-            axisval_raw->frac =
-                (ev->valuators.data_raw[i] - axisval_raw->integral) *
-                  (1 << 16) * (1 << 16);
+            *axisval =  double_to_fp3232(ev->valuators.data[i]);
+            *axisval_raw = double_to_fp3232(ev->valuators.data_raw[i]);
             axisval++;
             axisval_raw++;
         }
commit 7500d841f4c709ae0edc6420332096d3b9ef9fcc
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Oct 20 16:49:28 2011 +1000

    test: fix test with new double -> fp3232 conversion functions
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Tested-by: Dave Airlie <airlied at redhat.com>
    Reviewed-by: Dave Airlie <airlied at redhat.com>

diff --git a/test/xi2/protocol-eventconvert.c b/test/xi2/protocol-eventconvert.c
index 41a3001..ba2d96a 100644
--- a/test/xi2/protocol-eventconvert.c
+++ b/test/xi2/protocol-eventconvert.c
@@ -30,6 +30,7 @@
 #include "eventstr.h"
 #include "eventconvert.h"
 #include "exevents.h"
+#include "inpututils.h"
 #include <X11/extensions/XI2proto.h>
 
 static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out,
@@ -104,8 +105,7 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out,
             value = (FP3232*)(((unsigned char*)&out[1]) + out->valuators_len * 4);
             value += nvals;
 
-            vi.integral = trunc(in->valuators.data[i]);
-            vi.frac = in->valuators.data[i] - vi.integral;
+            vi = double_to_fp3232(in->valuators.data[i]);
 
             vo.integral = value->integral;
             vo.frac = value->frac;
@@ -120,8 +120,7 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out,
 
             raw_value = value + bits_set;
 
-            vi.integral = trunc(in->valuators.data_raw[i]);
-            vi.frac = in->valuators.data_raw[i] - vi.integral;
+            vi = double_to_fp3232(in->valuators.data_raw[i]);
 
             vo.integral = raw_value->integral;
             vo.frac = raw_value->frac;
commit 4bb5d8fae4f9a70f12591315f0b267a2ea826a0c
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Oct 19 13:17:51 2011 +1000

    Xi: send DeviceChangedEvents when the scroll valuators change value
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 7afb69e..053c76f 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1103,6 +1103,8 @@ SetScrollValuator(DeviceIntPtr dev, int axnum, enum ScrollType type, double incr
 {
     AxisInfoPtr ax;
     int *current_ax;
+    InternalEvent dce;
+    DeviceIntPtr master;
 
     if (!dev || !dev->valuator || axnum >= dev->valuator->numAxes)
         return FALSE;
@@ -1139,7 +1141,16 @@ SetScrollValuator(DeviceIntPtr dev, int axnum, enum ScrollType type, double incr
     ax->scroll.type = type;
     ax->scroll.increment = increment;
     ax->scroll.flags = flags;
-    /* FIXME: generate DeviceChanged Events */
+
+    master = GetMaster(dev, MASTER_ATTACHED);
+    CreateClassesChangedEvent(&dce, master, dev, DEVCHANGE_POINTER_EVENT | DEVCHANGE_DEVICE_CHANGE);
+    XISendDeviceChangedEvent(dev, &dce.changed_event);
+
+    /* if the current slave is us, update the master. If not, we'll update
+     * whenever the next slave switch happens anyway. CMDC sends the event
+     * for us */
+    if (master && master->lastSlave == dev)
+        ChangeMasterDeviceClasses(master, &dce.changed_event);
 
     return TRUE;
 }
commit 1f4af6c12fb5d4c19f4eac3df768517c9132cc88
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Oct 19 12:28:37 2011 +1000

    dix: accept a NULL master for CreateClassesChangedEvent
    
    If a floating device changes, the master is NULL but we must still create a
    DCE for it.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/getevents.c b/dix/getevents.c
index 8057e62..4845a10 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -218,7 +218,7 @@ CreateClassesChangedEvent(InternalEvent* event,
     dce = &event->changed_event;
     memset(dce, 0, sizeof(DeviceChangedEvent));
     dce->deviceid = slave->id;
-    dce->masterid = master->id;
+    dce->masterid = master ? master->id : 0;
     dce->header = ET_Internal;
     dce->length = sizeof(DeviceChangedEvent);
     dce->type = ET_DeviceChanged;
commit d77dec6971e4a0b306c8dbd5adf627908d7972cb
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Oct 19 12:11:16 2011 +1000

    Xi: ensure the deviceid for DeviceChangedEvents is always the right one
    
    If we're sending the event for a given device, make sure the deviceid is
    that of the device.
    This allows callers to use the same DCE for slave and master without having
    to fiddle the DCE's internal fields.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 2ae5a62..7afb69e 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -699,6 +699,7 @@ ChangeMasterDeviceClasses(DeviceIntPtr device, DeviceChangedEvent *dce)
 
     /* FIXME: the classes may have changed since we generated the event. */
     DeepCopyDeviceClasses(slave, device, dce);
+    dce->deviceid = device->id;
     XISendDeviceChangedEvent(device, dce);
 }
 
commit e9dee21fa3213bfe87b2b728a38eb41d3ba0e664
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Oct 18 17:47:59 2011 +1000

    dix: pass the flags into the CreateClassesChangedEvent
    
    No effective functional changes, prep work for future patches.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/getevents.c b/dix/getevents.c
index 31c69bf..8057e62 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -209,7 +209,7 @@ void
 CreateClassesChangedEvent(InternalEvent* event,
                           DeviceIntPtr master,
                           DeviceIntPtr slave,
-                          int type)
+                          int flags)
 {
     int i;
     DeviceChangedEvent *dce;
@@ -223,8 +223,7 @@ CreateClassesChangedEvent(InternalEvent* event,
     dce->length = sizeof(DeviceChangedEvent);
     dce->type = ET_DeviceChanged;
     dce->time = ms;
-    dce->flags = type;
-    dce->flags |= DEVCHANGE_SLAVE_SWITCH;
+    dce->flags = flags;
     dce->sourceid = slave->id;
 
     if (slave->button)
@@ -674,7 +673,7 @@ UpdateFromMaster(InternalEvent* events, DeviceIntPtr dev, int type, int *num_eve
 
     if (master && master->last.slave != dev)
     {
-        CreateClassesChangedEvent(events, master, dev, type);
+        CreateClassesChangedEvent(events, master, dev, type | DEVCHANGE_SLAVE_SWITCH);
         if (IsPointerDevice(master))
         {
             updateSlaveDeviceCoords(master, dev);
diff --git a/include/input.h b/include/input.h
index a1930bb..4eee47c 100644
--- a/include/input.h
+++ b/include/input.h
@@ -427,7 +427,8 @@ extern _X_EXPORT void FreeEventList(InternalEvent *list, int num_events);
 extern void CreateClassesChangedEvent(InternalEvent *event,
                                       DeviceIntPtr master,
                                       DeviceIntPtr slave,
-                                      int type);
+                                      int flags);
+
 extern InternalEvent * UpdateFromMaster(
     InternalEvent *events,
     DeviceIntPtr pDev,
commit fcdd2587a17437b643b4592aa7f65d11c05a4cd8
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Oct 18 17:41:29 2011 +1000

    dix: drop unused argument from XISendDeviceChangedEvent
    
    Instead of device and master (and just using master), drop the master
    argument and let the callers pass in the device the event is to be sent for.
    
    No effective functional changes.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 74a78ec..2ae5a62 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -651,7 +651,7 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to, DeviceChangedEvent *dc
  * Send an XI2 DeviceChangedEvent to all interested clients.
  */
 void
-XISendDeviceChangedEvent(DeviceIntPtr device, DeviceIntPtr master, DeviceChangedEvent *dce)
+XISendDeviceChangedEvent(DeviceIntPtr device, DeviceChangedEvent *dce)
 {
     xXIDeviceChangedEvent *dcce;
     int rc;
@@ -665,7 +665,7 @@ XISendDeviceChangedEvent(DeviceIntPtr device, DeviceIntPtr master, DeviceChanged
 
     /* we don't actually swap if there's a NullClient, swapping is done
      * later when event is delivered. */
-    SendEventToAllWindows(master, XI_DeviceChangedMask, (xEvent*)dcce, 1);
+    SendEventToAllWindows(device, XI_DeviceChangedMask, (xEvent*)dcce, 1);
     free(dcce);
 }
 
@@ -699,7 +699,7 @@ ChangeMasterDeviceClasses(DeviceIntPtr device, DeviceChangedEvent *dce)
 
     /* FIXME: the classes may have changed since we generated the event. */
     DeepCopyDeviceClasses(slave, device, dce);
-    XISendDeviceChangedEvent(slave, device, dce);
+    XISendDeviceChangedEvent(device, dce);
 }
 
 /**
diff --git a/dix/devices.c b/dix/devices.c
index 64557aa..7c196e0 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -2360,7 +2360,7 @@ RecalculateMasterButtons(DeviceIntPtr slave)
             event.keys.max_keycode = master->key->xkbInfo->desc->max_key_code;
         }
 
-        XISendDeviceChangedEvent(master, master, &event);
+        XISendDeviceChangedEvent(master, &event);
     }
 }
 
diff --git a/include/exevents.h b/include/exevents.h
index 4fe6c61..720fb2e 100644
--- a/include/exevents.h
+++ b/include/exevents.h
@@ -322,8 +322,7 @@ extern int
 XIShouldNotify(ClientPtr client, DeviceIntPtr dev);
 
 extern void
-XISendDeviceChangedEvent(DeviceIntPtr device, DeviceIntPtr master,
-                         DeviceChangedEvent *dce);
+XISendDeviceChangedEvent(DeviceIntPtr device, DeviceChangedEvent *dce);
 
 extern int
 XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
commit 8473e441b0f832775153281bc3df5e2d4feb2b36
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Oct 18 17:11:27 2011 +1000

    dix: add ScrollInfo to DeviceChangedEvents
    
    3304bbff9b4ed63f1a47410a5320a136420ba2c6 added smooth scrolling support for
    pointer events and for XIQueryDevice but didn't add the matching parts to
    XIDeviceChangedEvents.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/eventconvert.c b/dix/eventconvert.c
index 189cb85..ff42b03 100644
--- a/dix/eventconvert.c
+++ b/dix/eventconvert.c
@@ -43,8 +43,10 @@
 #include "inputstr.h"
 #include "misc.h"
 #include "eventstr.h"
+#include "exevents.h"
 #include "exglobals.h"
 #include "eventconvert.h"
+#include "inpututils.h"
 #include "xiquerydevice.h"
 #include "xkbsrv.h"
 
@@ -482,6 +484,40 @@ appendValuatorInfo(DeviceChangedEvent *dce, xXIValuatorInfo *info, int axisnumbe
 }
 
 static int
+appendScrollInfo(DeviceChangedEvent *dce, xXIScrollInfo *info, int axisnumber)
+{
+    if (dce->valuators[axisnumber].scroll.type == SCROLL_TYPE_NONE)
+        return 0;
+
+    info->type = XIScrollClass;
+    info->length = sizeof(xXIScrollInfo)/4;
+    info->number = axisnumber;
+    switch(dce->valuators[axisnumber].scroll.type)
+    {
+        case SCROLL_TYPE_VERTICAL:
+            info->scroll_type = XIScrollTypeVertical;
+            break;
+        case SCROLL_TYPE_HORIZONTAL:
+            info->scroll_type = XIScrollTypeHorizontal;
+            break;
+        default:
+            ErrorF("[Xi] Unknown scroll type %d. This is a bug.\n", dce->valuators[axisnumber].scroll.type);
+            break;
+    }
+    info->increment = double_to_fp3232(dce->valuators[axisnumber].scroll.increment);
+    info->sourceid = dce->sourceid;
+
+    info->flags = 0;
+
+    if (dce->valuators[axisnumber].scroll.flags & SCROLL_FLAG_DONT_EMULATE)
+        info->flags |= XIScrollFlagNoEmulation;
+    if (dce->valuators[axisnumber].scroll.flags & SCROLL_FLAG_PREFERRED)
+        info->flags |= XIScrollFlagPreferred;
+
+    return info->length * 4;
+}
+
+static int
 eventToDeviceChanged(DeviceChangedEvent *dce, xEvent **xi)
 {
     xXIDeviceChangedEvent *dcce;
@@ -496,8 +532,16 @@ eventToDeviceChanged(DeviceChangedEvent *dce, xEvent **xi)
         len += pad_to_int32(bits_to_bytes(dce->buttons.num_buttons));
     }
     if (dce->num_valuators)
+    {
+        int i;
+
         len += sizeof(xXIValuatorInfo) * dce->num_valuators;
 
+        for (i = 0; i < dce->num_valuators; i++)
+            if (dce->valuators[i].scroll.type != SCROLL_TYPE_NONE)
+                len += sizeof(xXIScrollInfo);
+    }
+
     nkeys = (dce->keys.max_keycode > 0) ?
                 dce->keys.max_keycode - dce->keys.min_keycode + 1 : 0;
     if (nkeys > 0)
@@ -543,6 +587,15 @@ eventToDeviceChanged(DeviceChangedEvent *dce, xEvent **xi)
         dcce->num_classes += dce->num_valuators;
         for (i = 0; i < dce->num_valuators; i++)
             ptr += appendValuatorInfo(dce, (xXIValuatorInfo*)ptr, i);
+
+        for (i = 0; i < dce->num_valuators; i++)
+        {
+            if (dce->valuators[i].scroll.type != SCROLL_TYPE_NONE)
+            {
+                dcce->num_classes++;
+                ptr += appendScrollInfo(dce, (xXIScrollInfo*)ptr, i);
+            }
+        }
     }
 
     *xi = (xEvent*)dcce;
diff --git a/dix/getevents.c b/dix/getevents.c
index 7be39dc..31c69bf 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -243,6 +243,7 @@ CreateClassesChangedEvent(InternalEvent* event,
             dce->valuators[i].resolution = slave->valuator->axes[i].resolution;
             dce->valuators[i].mode = slave->valuator->axes[i].mode;
             dce->valuators[i].name = slave->valuator->axes[i].label;
+            dce->valuators[i].scroll = slave->valuator->axes[i].scroll;
         }
     }
     if (slave->key)
diff --git a/include/eventstr.h b/include/eventstr.h
index 2de077f..4d836fb 100644
--- a/include/eventstr.h
+++ b/include/eventstr.h
@@ -153,6 +153,7 @@ struct _DeviceChangedEvent
         uint32_t resolution;    /**< Resolution counts/m */
         uint8_t mode;           /**< Relative or Absolute */
         Atom name;              /**< Axis name */
+        ScrollInfo scroll;      /**< Smooth scrolling info */
     } valuators[MAX_VALUATORS];
 
     struct {
diff --git a/test/xi2/protocol-eventconvert.c b/test/xi2/protocol-eventconvert.c
index bfa23b5..41a3001 100644
--- a/test/xi2/protocol-eventconvert.c
+++ b/test/xi2/protocol-eventconvert.c
@@ -748,6 +748,26 @@ static void test_values_XIDeviceChangedEvent(DeviceChangedEvent *in,
 
                 }
                 break;
+            case XIScrollClass:
+                {
+                    xXIScrollInfo *s = (xXIScrollInfo*)any;
+                    assert(s->length ==
+                             bytes_to_int32(sizeof(xXIScrollInfo)));
+
+                    assert(s->sourceid == in->sourceid);
+                    assert(s->number < in->num_valuators);
+                    switch(s->type)
+                    {
+                        case XIScrollTypeVertical:
+                            assert(in->valuators[s->number].scroll.type == SCROLL_TYPE_VERTICAL);
+                            break;
+                        case XIScrollTypeHorizontal:
+                            assert(in->valuators[s->number].scroll.type == SCROLL_TYPE_HORIZONTAL);
+                            break;
+                    }
+                    if (s->flags & XIScrollFlagPreferred)
+                        assert(in->valuators[s->number].scroll.flags & SCROLL_FLAG_PREFERRED);
+                }
             default:
                 printf("Invalid class type.\n\n");
                 assert(1);
commit e3f6a76dd480717eae4b17ad8e2ff707de2ffe4c
Author: Andreas Wettstein <wettstein509 at solnet.ch>
Date:   Thu Aug 11 16:33:33 2011 +1000

    xkb: Support noLock and noUnlock flags for LockMods
    
    These flags are required by the XKB spec section 6.3.
    
    Signed-off-by: Andreas Wettstein <wettstein509 at solnet.ch>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index 4b5405a..000002a 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -344,15 +344,18 @@ _XkbFilterLockState(	XkbSrvInfoPtr	xkbi,
 	filter->keycode = keycode;
 	filter->active = 1;
 	filter->filterOthers = 0;
-	filter->priv = 0;
+	filter->priv = xkbi->state.locked_mods&pAction->mods.mask;
 	filter->filter = _XkbFilterLockState;
 	filter->upAction = *pAction;
-	xkbi->state.locked_mods^= pAction->mods.mask;
+	if (!(filter->upAction.mods.flags&XkbSA_LockNoLock))
+	    xkbi->state.locked_mods|= pAction->mods.mask;
 	xkbi->setMods = pAction->mods.mask;
     }
     else if (filter->keycode==keycode) {
 	filter->active = 0;
 	xkbi->clearMods = filter->upAction.mods.mask;
+	if (!(filter->upAction.mods.flags&XkbSA_LockNoUnlock))
+	    xkbi->state.locked_mods&= ~filter->priv;
     }
     return 1;
 }
commit 6f33593dc087d367d899d1cb6e6e30b282d922e2
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Oct 21 09:09:55 2011 +1000

    xfree86 doc: replace driver "keyboard" with "kbd"
    
    We've deprecated keyboard a long time ago
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/hw/xfree86/doc/ddxDesign.xml b/hw/xfree86/doc/ddxDesign.xml
index a4baad5..0d5e952 100644
--- a/hw/xfree86/doc/ddxDesign.xml
+++ b/hw/xfree86/doc/ddxDesign.xml
@@ -189,7 +189,7 @@ following changes:
 	  <varlistentry><term><emphasis>Keyboard</emphasis></term>
 	    <listitem><literallayout>
              &k.identifier; "Implicit Core Keyboard"
-             &k.driver; "keyboard"
+             &k.driver; "kbd"
 	      </literallayout></listitem></varlistentry>
 	  <varlistentry><term><emphasis>Pointer</emphasis></term>
 	    <listitem><literallayout>
@@ -206,7 +206,7 @@ following changes:
     is no &k.serverlayout; section, if the <option>-screen</option> command
     line options is used, or if the &k.serverlayout; section doesn't
     reference any &k.inputdevice; sections.  In this case, the first
-    sections with drivers "keyboard" and "mouse" are used as the core
+    sections with drivers "kbd" and "mouse" are used as the core
     keyboard and pointer respectively.
       </para>
     </sect2>
commit e4cd24e717ef1059804b3f6bb483810b708cd56a
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Aug 5 14:48:02 2011 +1000

    xfree86: use NewInputDeviceRequest for xorg.conf devices too
    
    Only use one init path for input devices - through NIDR.
    
    This requires that inp_driver and inp_identifier from the
    XF86ConfInputRec are copied over into the options for NIDR to see them.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 96e98c1..cb4be42 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -1196,6 +1196,10 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
 	if (foundPointer) {
 	    Pointer->options = xf86AddNewOption(Pointer->options,
 					        "CorePointer", "on");
+	    Pointer->options = xf86AddNewOption(Pointer->options,
+						"driver", confInput->inp_driver);
+	    Pointer->options = xf86AddNewOption(Pointer->options,
+						"identifier", confInput->inp_identifier);
 	    servlayoutp->inputs = addDevice(servlayoutp->inputs, Pointer);
 	}
     }
@@ -1286,6 +1290,10 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
 	if (foundKeyboard) {
 	    Keyboard->options = xf86AddNewOption(Keyboard->options,
 						 "CoreKeyboard", "on");
+	    Keyboard->options = xf86AddNewOption(Keyboard->options,
+						 "driver", confInput->inp_driver);
+	    Keyboard->options = xf86AddNewOption(Keyboard->options,
+						 "identifier", confInput->inp_identifier);
 	    servlayoutp->inputs = addDevice(servlayoutp->inputs, Keyboard);
 	}
     }
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 74e0bc2..a0fdf29 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -811,21 +811,6 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
 				 NULL);
 }
 
-static InputInfoPtr
-duplicateDevice(InputInfoPtr pInfo)
-{
-    InputInfoPtr dup = calloc(1, sizeof(InputInfoRec));
-    if (dup) {
-        dup->name = strdup(pInfo->name);
-        dup->driver = strdup(pInfo->driver);
-        dup->options = xf86OptionListDuplicate(pInfo->options);
-        /* type_name is a const string */
-        dup->type_name = pInfo->type_name;
-        dup->fd = -1;
-    }
-    return dup;
-}
-
 /**
  * Initialize all supported input devices present and referenced in the
  * xorg.conf.
@@ -842,20 +827,8 @@ InitInput(int argc, char **argv)
 
     /* Initialize all configured input devices */
     for (pInfo = xf86ConfigLayout.inputs; pInfo && *pInfo; pInfo++) {
-        InputInfoPtr dup;
-        /* Replace obsolete keyboard driver with kbd */
-        if (!xf86NameCmp((*pInfo)->driver, "keyboard")) {
-            strcpy((*pInfo)->driver, "kbd");
-        }
-
-        /* Data passed into xf86NewInputDevice will be freed on shutdown.
-         * Duplicate from xf86ConfigLayout.inputs, otherwise we don't have any
-         * xorg.conf input devices in the second generation
-         */
-        dup = duplicateDevice(*pInfo);
-
         /* If one fails, the others will too */
-        if (xf86NewInputDevice(dup, &dev, TRUE) == BadAlloc)
+        if (NewInputDeviceRequest((*pInfo)->options, NULL, &dev) == BadAlloc)
             break;
     }
 
commit 1ecc427a39d41e723912492b846512fd0ad9af2d
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Aug 10 14:37:41 2011 +1000

    dix: move #if statement to stop compiler warning
    
    ptrveloc.c: In function 'QueryTrackers':
    ptrveloc.c:598:34: warning: variable 'used_offset' set but not used
    [-Wunused-but-set-variable]
    
    used_offset is used, but only in the debugging code. Move the #if statement
    to ignore that warning.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index 53a0d03..7b6f560 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -649,13 +649,13 @@ QueryTrackers(DeviceVelocityPtr vel, int cur_t){
 	DebugAccelF("(dix prtacc) query: last tracker in effect\n");
 	used_offset = vel->num_tracker-1;
     }
-#ifdef PTRACCEL_DEBUGGING
     if(used_offset >= 0){
+#ifdef PTRACCEL_DEBUGGING
 	MotionTracker *tracker = TRACKER(vel, used_offset);
 	DebugAccelF("(dix prtacc) result: offset %i [dx: %i dy: %i diff: %i]\n",
 	            used_offset, tracker->dx, tracker->dy, cur_t - tracker->time);
-    }
 #endif
+    }
     return result;
 }
 
commit f9067c1dd8ce9058eb48a20dfae52bc8cf3a1e55
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Aug 5 14:05:58 2011 +1000

    xfree86: Fix a comment, the old function doesn't exist anymore
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c
index 1a1f42a..9c52878 100644
--- a/hw/xfree86/common/xf86Option.c
+++ b/hw/xfree86/common/xf86Option.c
@@ -299,7 +299,7 @@ xf86CheckPercentOption(XF86OptionPtr optlist, const char *name, double deflt)
     return LookupPercentOption(optlist, name, deflt, FALSE);
 }
 /*
- * addNewOption() has the required property of replacing the option value
+ * xf86AddNewOption() has the required property of replacing the option value
  * if the option is already present.
  */
 XF86OptionPtr
commit aeab26e9e1751e1e3514798fa53e9bd604b0d254
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Aug 10 15:58:34 2011 +1000

    xfree86: use xf86AddNewOption instead of xf86addNewOption
    
    The former strdups for us. If the strdup fails we miss out on the
    CorePointer option (default on anyway) and we're likely to fall over soon
    anyway, so let's pretend this is the same behaviour.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 5c46152..96e98c1 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -1194,8 +1194,8 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
 	if (Pointer)
 	    foundPointer = configInput(Pointer, confInput, from);
 	if (foundPointer) {
-	    Pointer->options = xf86addNewOption(Pointer->options,
-					       xnfstrdup("CorePointer"), "on");
+	    Pointer->options = xf86AddNewOption(Pointer->options,
+					        "CorePointer", "on");
 	    servlayoutp->inputs = addDevice(servlayoutp->inputs, Pointer);
 	}
     }
@@ -1284,8 +1284,8 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
 	if (Keyboard)
 	    foundKeyboard = configInput(Keyboard, confInput, from);
 	if (foundKeyboard) {
-	    Keyboard->options = xf86addNewOption(Keyboard->options,
-						xnfstrdup("CoreKeyboard"), "on");
+	    Keyboard->options = xf86AddNewOption(Keyboard->options,
+						 "CoreKeyboard", "on");
 	    servlayoutp->inputs = addDevice(servlayoutp->inputs, Keyboard);
 	}
     }
commit c39c8d34282b82d73c3c69a16cf0c2816256d85b
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Aug 10 14:38:58 2011 +1000

    input: switch InputOption to use XF86OptionRec storage.
    
    Use the same struct for both InputOption and XF86OptionRec so we don't need
    to convert to and fro the two in the config backends.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/inpututils.c b/dix/inpututils.c
index 2915e67..5797f92 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -38,6 +38,7 @@
 #include "inpututils.h"
 #include "eventstr.h"
 #include "scrnintstr.h"
+#include "optionstr.h"
 
 /* Check if a button map change is okay with the device.
  * Returns -1 for BadValue, as it collides with MappingBusy. */
@@ -670,8 +671,9 @@ point_on_screen(ScreenPtr pScreen, int x, int y)
 static void
 input_option_free(InputOption *o)
 {
-    free(o->key);
-    free(o->value);
+    free(o->opt_name);
+    free(o->opt_val);
+    free(o->opt_comment);
     free(o);
 }
 
@@ -701,7 +703,7 @@ input_option_new(InputOption* list, const char *key, const char *value)
 
     if (list)
     {
-        nt_list_for_each_entry(opt, list, next)
+        nt_list_for_each_entry(opt, list, list.next)
         {
             if (strcmp(input_option_get_key(opt), key) == 0)
             {
@@ -715,13 +717,13 @@ input_option_new(InputOption* list, const char *key, const char *value)
     if (!opt)
         return NULL;
 
-    nt_list_init(opt, next);
+    nt_list_init(opt, list.next);
     input_option_set_key(opt, key);
     input_option_set_value(opt, value);
 
     if (list)
     {
-        nt_list_append(opt, list, InputOption, next);
+        nt_list_append(opt, list, InputOption, list.next);
         return list;
     } else
         return opt;
@@ -732,9 +734,9 @@ input_option_free_element(InputOption *list, const char *key)
 {
     InputOption *element;
 
-    nt_list_for_each_entry(element, list, next) {
+    nt_list_for_each_entry(element, list, list.next) {
         if (strcmp(input_option_get_key(element), key) == 0) {
-            nt_list_del(element, list, InputOption, next);
+            nt_list_del(element, list, InputOption, list.next);
             input_option_free(element);
             break;
         }
@@ -750,8 +752,8 @@ input_option_free_list(InputOption **opt)
 {
     InputOption *element, *tmp;
 
-    nt_list_for_each_entry_safe(element, tmp, *opt, next) {
-        nt_list_del(element, *opt, InputOption, next);
+    nt_list_for_each_entry_safe(element, tmp, *opt, list.next) {
+        nt_list_del(element, *opt, InputOption, list.next);
         input_option_free(element);
     }
     *opt = NULL;
@@ -768,7 +770,7 @@ input_option_find(InputOption *list, const char *key)
 {
     InputOption *element;
 
-    nt_list_for_each_entry(element, list, next) {
+    nt_list_for_each_entry(element, list, list.next) {
         if (strcmp(input_option_get_key(element), key) == 0)
             return element;
     }
@@ -779,29 +781,29 @@ input_option_find(InputOption *list, const char *key)
 const char*
 input_option_get_key(const InputOption *opt)
 {
-    return opt->key;
+    return opt->opt_name;
 }
 
 const char*
 input_option_get_value(const InputOption *opt)
 {
-    return opt->value;
+    return opt->opt_val;
 }
 
 void
 input_option_set_key(InputOption *opt, const char *key)
 {
-    free(opt->key);
+    free(opt->opt_name);
     if (key)
-        opt->key = strdup(key);
+        opt->opt_name = strdup(key);
 }
 
 void
 input_option_set_value(InputOption *opt, const char *value)
 {
-    free(opt->value);
+    free(opt->opt_val);
     if (value)
-        opt->value = strdup(value);
+        opt->opt_val = strdup(value);
 }
 
 
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 15c9ae2..a1bbcaa 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -49,6 +49,7 @@
 #include "eventstr.h"
 #include "xserver-properties.h"
 #include "inpututils.h"
+#include "optionstr.h"
 
 #define AtomFromName(x) MakeAtom(x, strlen(x), 1)
 
@@ -1074,7 +1075,7 @@ KdParseKbdOptions (KdKeyboardInfo *ki)
 {
     InputOption *option = NULL;
 
-    nt_list_for_each_entry(option, ki->options, next)
+    nt_list_for_each_entry(option, ki->options, list.next)
     {
         const char *key = input_option_get_key(option);
         const char *value = input_option_get_value(option);
@@ -1174,7 +1175,7 @@ KdParsePointerOptions (KdPointerInfo *pi)
 {
     InputOption *option = NULL;
 
-    nt_list_for_each_entry(option, pi->options, next)
+    nt_list_for_each_entry(option, pi->options, list.next)
     {
         const char *key = input_option_get_key(option);
         const char *value = input_option_get_value(option);
@@ -2222,7 +2223,7 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
     KdPointerInfo *pi = NULL;
     KdKeyboardInfo *ki = NULL;
 
-    nt_list_for_each_entry(option, options, next) {
+    nt_list_for_each_entry(option, options, list.next) {
         const char *key = input_option_get_key(option);
         const char *value = input_option_get_value(option);
 
@@ -2267,7 +2268,7 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
 
     /* FIXME: change this code below to use KdParseKbdOptions and
      * KdParsePointerOptions */
-    nt_list_for_each_entry(option, options, next) {
+    nt_list_for_each_entry(option, options, list.next) {
         const char *key = input_option_get_key(option);
         const char *value = input_option_get_value(option);
 
diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c
index 73b6573..1a1f42a 100644
--- a/hw/xfree86/common/xf86Option.c
+++ b/hw/xfree86/common/xf86Option.c
@@ -44,6 +44,7 @@
 #include "xf86Xinput.h"
 #include "xf86Optrec.h"
 #include "xf86Parser.h"
+#include "optionstr.h"
 
 static Bool ParseOptionValue(int scrnIndex, XF86OptionPtr options, OptionInfoPtr p,
 			     Bool markUsed);
diff --git a/hw/xfree86/common/xf86Optionstr.h b/hw/xfree86/common/xf86Optionstr.h
index 8cc82d3..fc93856 100644
--- a/hw/xfree86/common/xf86Optionstr.h
+++ b/hw/xfree86/common/xf86Optionstr.h
@@ -24,16 +24,7 @@
 
 #ifndef XF86OPTIONSTR_H
 #define XF86OPTIONSTR_H
-
-/*
- * all records that need to be linked lists should contain a GenericList as
- * their first field.
- */
-typedef struct generic_list_rec
-{
-	void *next;
-}
-GenericListRec, *GenericListPtr, *glp;
+#include "list.h"
 
 /*
  * All options are stored using this data type.
@@ -48,6 +39,6 @@ typedef struct _XF86OptionRec
 }
 XF86OptionRec;
 
-typedef struct _XF86OptionRec *XF86OptionPtr;
+typedef struct _InputOption *XF86OptionPtr;
 
 #endif
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index ea1f927..425b359 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -68,6 +68,7 @@
 #include "exglobals.h"
 #include "eventstr.h"
 #include "inpututils.h"
+#include "optionstr.h"
 
 #include <string.h>     /* InputClassMatches */
 #ifdef HAVE_FNMATCH_H
@@ -908,7 +909,7 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
     if (!pInfo)
         return BadAlloc;
 
-    nt_list_for_each_entry(option, options, next) {
+    nt_list_for_each_entry(option, options, list.next) {
         if (strcasecmp(input_option_get_key(option), "driver") == 0) {
             if (pInfo->driver) {
                 rval = BadRequest;
@@ -946,7 +947,7 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
         }
     }
 
-    nt_list_for_each_entry(option, options, next) {
+    nt_list_for_each_entry(option, options, list.next) {
         /* Copy option key/value strings from the provided list */
         pInfo->options = xf86AddNewOption(pInfo->options,
                                           input_option_get_key(option),
diff --git a/hw/xfree86/parser/Flags.c b/hw/xfree86/parser/Flags.c
index 7a0794b..f0a6170 100644
--- a/hw/xfree86/parser/Flags.c
+++ b/hw/xfree86/parser/Flags.c
@@ -63,6 +63,7 @@
 #include "Configint.h"
 #include <X11/Xfuncproto.h>
 #include "Xprintf.h"
+#include "optionstr.h"
 
 extern LexRec val;
 
@@ -203,7 +204,7 @@ addNewOption2 (XF86OptionPtr head, char *name, char *val, int used)
 		free(new->opt_val);
 	}
 	else
-		new = calloc (1, sizeof (XF86OptionRec));
+		new = calloc (1, sizeof (*new));
 	new->opt_name = name;
 	new->opt_val = val;
 	new->opt_used = used;
@@ -284,7 +285,7 @@ xf86newOption(char *name, char *value)
 {
 	XF86OptionPtr opt;
 
-	opt = calloc(1, sizeof (XF86OptionRec));
+	opt = calloc(1, sizeof (*opt));
 	if (!opt)
 		return NULL;
 
diff --git a/hw/xfree86/parser/Layout.c b/hw/xfree86/parser/Layout.c
index e1f770b..4487b0d 100644
--- a/hw/xfree86/parser/Layout.c
+++ b/hw/xfree86/parser/Layout.c
@@ -63,7 +63,7 @@
 #include "xf86tokens.h"
 #include "Configint.h"
 #include <string.h>
-
+#include "optionstr.h"
 
 /* Needed for auto server layout */
 extern int xf86CheckBoolOption(void* optlist, const char *name, int deflt);
diff --git a/include/inputstr.h b/include/inputstr.h
index 9d4108e..7a15540 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -621,11 +621,4 @@ static inline WindowPtr DeepestSpriteWin(SpritePtr sprite)
     return sprite->spriteTrace[sprite->spriteTraceGood - 1];
 }
 
-struct _InputOption {
-    char                *key;
-    char                *value;
-    struct _InputOption *next;
-};
-
-
 #endif /* INPUTSTRUCT_H */
diff --git a/include/list.h b/include/list.h
index 7825dce..4706e17 100644
--- a/include/list.h
+++ b/include/list.h
@@ -438,4 +438,16 @@ list_is_empty(struct list *head)
 		nt_list_init(__e, _member);			\
 	} while(0)
 
+/**
+ * DO NOT USE THIS.
+ * This is a remainder of the xfree86 DDX attempt of having a set of generic
+ * list functions. Unfortunately, the xf86OptionRec uses it and we can't
+ * easily get rid of it. Do not use for new code.
+ */
+typedef struct generic_list_rec
+{
+	void *next;
+}
+GenericListRec, *GenericListPtr, *glp;
+
 #endif
diff --git a/include/optionstr.h b/include/optionstr.h
new file mode 100644
index 0000000..a71d245
--- /dev/null
+++ b/include/optionstr.h
@@ -0,0 +1,14 @@
+#ifndef OPTIONSTR_H_
+#define OPTIONSTR_H_
+#include "list.h"
+
+
+struct _InputOption {
+    GenericListRec list;
+    char *opt_name;
+    char *opt_val;
+    int opt_used;
+    char *opt_comment;
+};
+
+#endif /* INPUTSTRUCT_H */
commit 16ac78a53c1edeae183db8672104587b306cfe13
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Oct 25 11:40:58 2011 +1000

    kdrive: switch to new InputOption API.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index c14dd82..15c9ae2 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -344,7 +344,7 @@ KdEnableInput (void)
 }
 
 static KdKeyboardDriver *
-KdFindKeyboardDriver (char *name)
+KdFindKeyboardDriver (const char *name)
 {
     KdKeyboardDriver *ret;
 
@@ -361,7 +361,7 @@ KdFindKeyboardDriver (char *name)
 }
 
 static KdPointerDriver *
-KdFindPointerDriver (char *name)
+KdFindPointerDriver (const char *name)
 {
     KdPointerDriver *ret;
 
@@ -1040,33 +1040,33 @@ KdRemovePointer (KdPointerInfo *pi)
 static Bool
 KdGetOptions (InputOption **options, char *string)
 {
-    InputOption     *newopt = NULL, **tmpo = NULL;
+    InputOption     *newopt = NULL;
+    char            *key = NULL,
+                    *value = NULL;
     int             tam_key = 0;
 
-    newopt = calloc(1, sizeof (InputOption));
-    if (!newopt)
-        return FALSE;
-
-    for (tmpo = options; *tmpo; tmpo = &(*tmpo)->next)
-        ; /* Hello, I'm here */
-    *tmpo = newopt;
-
     if (strchr(string, '='))
     {
         tam_key = (strchr(string, '=') - string);
-        newopt->key = (char *)malloc(tam_key);
-        strncpy(newopt->key, string, tam_key);
-        newopt->key[tam_key] = '\0';
-        newopt->value = strdup(strchr(string, '=') + 1);
+        key = malloc(tam_key);
+        strncpy(key, string, tam_key);
+        key[tam_key] = '\0';
+        value = strdup(strchr(string, '=') + 1);
     }
     else
     {
-        newopt->key = strdup(string);
-        newopt->value = NULL;
+        key = strdup(string);
+        value = NULL;
     }
-    newopt->next = NULL;
 
-    return TRUE;
+    newopt = input_option_new(*options, key, value);
+    if (newopt)
+        *options = newopt;
+
+    free(key);
+    free(value);
+
+    return (newopt != NULL);
 }
 
 static void
@@ -1074,23 +1074,26 @@ KdParseKbdOptions (KdKeyboardInfo *ki)
 {
     InputOption *option = NULL;
 
-    for (option = ki->options; option; option = option->next)
+    nt_list_for_each_entry(option, ki->options, next)
     {
-        if (strcasecmp(option->key, "XkbRules") == 0)
-            ki->xkbRules = option->value;
-        else if (strcasecmp(option->key, "XkbModel") == 0)
-            ki->xkbModel = option->value;
-        else if (strcasecmp(option->key, "XkbLayout") == 0)
-            ki->xkbLayout = option->value;
-        else if (strcasecmp(option->key, "XkbVariant") == 0)
-            ki->xkbVariant = option->value;
-        else if (strcasecmp(option->key, "XkbOptions") == 0)
-            ki->xkbOptions = option->value;
-        else if (!strcasecmp (option->key, "device"))
-            ki->path = strdup(option->value);
+        const char *key = input_option_get_key(option);
+        const char *value = input_option_get_value(option);
+
+        if (strcasecmp(key, "XkbRules") == 0)
+            ki->xkbRules = strdup(value);
+        else if (strcasecmp(key, "XkbModel") == 0)
+            ki->xkbModel = strdup(value);
+        else if (strcasecmp(key, "XkbLayout") == 0)
+            ki->xkbLayout = strdup(value);
+        else if (strcasecmp(key, "XkbVariant") == 0)
+            ki->xkbVariant = strdup(value);
+        else if (strcasecmp(key, "XkbOptions") == 0)
+            ki->xkbOptions = strdup(value);
+        else if (!strcasecmp (key, "device"))
+            ki->path = strdup(value);
         else
            ErrorF("Kbd option key (%s) of value (%s) not assigned!\n",
-                    option->key, option->value);
+                    key, value);
     }
 }
 
@@ -1171,23 +1174,26 @@ KdParsePointerOptions (KdPointerInfo *pi)
 {
     InputOption *option = NULL;
 
-    for (option = pi->options; option; option = option->next)
+    nt_list_for_each_entry(option, pi->options, next)
     {
-        if (!strcmp (option->key, "emulatemiddle"))
+        const char *key = input_option_get_key(option);
+        const char *value = input_option_get_value(option);
+
+        if (!strcmp (key, "emulatemiddle"))
             pi->emulateMiddleButton = TRUE;
-        else if (!strcmp (option->key, "noemulatemiddle"))
+        else if (!strcmp (key, "noemulatemiddle"))
             pi->emulateMiddleButton = FALSE;
-        else if (!strcmp (option->key, "transformcoord"))
+        else if (!strcmp (key, "transformcoord"))
             pi->transformCoordinates = TRUE;
-        else if (!strcmp (option->key, "rawcoord"))
+        else if (!strcmp (key, "rawcoord"))
             pi->transformCoordinates = FALSE;
-        else if (!strcasecmp (option->key, "device"))
-            pi->path = strdup(option->value);
-        else if (!strcasecmp (option->key, "protocol"))
-            pi->protocol = strdup(option->value);
+        else if (!strcasecmp (key, "device"))
+            pi->path = strdup(value);
+        else if (!strcasecmp (key, "protocol"))
+            pi->protocol = strdup(value);
         else
             ErrorF("Pointer option key (%s) of value (%s) not assigned!\n",
-                    option->key, option->value);
+                    key, value);
     }
 }
 
@@ -2216,14 +2222,17 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
     KdPointerInfo *pi = NULL;
     KdKeyboardInfo *ki = NULL;
 
-    for (option = options; option; option = option->next) {
-        if (strcmp(option->key, "type") == 0) {
-            if (strcmp(option->value, "pointer") == 0) {
+    nt_list_for_each_entry(option, options, next) {
+        const char *key = input_option_get_key(option);
+        const char *value = input_option_get_value(option);
+
+        if (strcmp(key, "type") == 0) {
+            if (strcmp(value, "pointer") == 0) {
                 pi = KdNewPointer();
                 if (!pi)
                     return BadAlloc;
             }
-            else if (strcmp(option->value, "keyboard") == 0) {
+            else if (strcmp(value, "keyboard") == 0) {
                 ki = KdNewKeyboard();
                 if (!ki)
                     return BadAlloc;
@@ -2234,16 +2243,16 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
             }
         }
 #ifdef CONFIG_HAL
-        else if (strcmp(option->key, "_source") == 0 &&
-                 strcmp(option->value, "server/hal") == 0)
+        else if (strcmp(key, "_source") == 0 &&
+                 strcmp(value, "server/hal") == 0)
         {
             ErrorF("Ignoring device from HAL.\n");
             return BadValue;
         }
 #endif
 #ifdef CONFIG_UDEV
-        else if (strcmp(option->key, "_source") == 0 &&
-                 strcmp(option->value, "server/udev") == 0)
+        else if (strcmp(key, "_source") == 0 &&
+                 strcmp(value, "server/udev") == 0)
         {
             ErrorF("Ignoring device from udev.\n");
             return BadValue;
@@ -2258,16 +2267,19 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
 
     /* FIXME: change this code below to use KdParseKbdOptions and
      * KdParsePointerOptions */
-    for (option = options; option; option = option->next) {
-        if (strcmp(option->key, "device") == 0) {
-            if (pi && option->value)
-                pi->path = strdup(option->value);
-            else if (ki && option->value)
-                ki->path = strdup(option->value);
+    nt_list_for_each_entry(option, options, next) {
+        const char *key = input_option_get_key(option);
+        const char *value = input_option_get_value(option);
+
+        if (strcmp(key, "device") == 0) {
+            if (pi && value)
+                pi->path = strdup(value);
+            else if (ki && value)
+                ki->path = strdup(value);
         }
-        else if (strcmp(option->key, "driver") == 0) {
+        else if (strcmp(key, "driver") == 0) {
             if (pi) {
-                pi->driver = KdFindPointerDriver(option->value);
+                pi->driver = KdFindPointerDriver(value);
                 if (!pi->driver) {
                     ErrorF("couldn't find driver!\n");
                     KdFreePointer(pi);
@@ -2276,7 +2288,7 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
                 pi->options = options;
             }
             else if (ki) {
-                ki->driver = KdFindKeyboardDriver(option->value);
+                ki->driver = KdFindKeyboardDriver(value);
                 if (!ki->driver) {
                     ErrorF("couldn't find driver!\n");
                     KdFreeKeyboard(ki);
commit 7d50211ab57a35910d79fc3f67ae89aff91fa995
Author: Christopher Yeleighton <giecrilj at stegny.2a.pl>
Date:   Mon Oct 24 18:47:06 2011 -0700

    Bug 38420: Xvfb crashes in miInitVisuals() when started with depth=2
    
    https://bugs.freedesktop.org/show_bug.cgi?id=38420
    
    Exit with fatal error message, not segfault.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c
index 0e701e5..1218547 100644
--- a/hw/vfb/InitOutput.c
+++ b/hw/vfb/InitOutput.c
@@ -863,6 +863,8 @@ vfbScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
 				   (1 << DirectColor)),
 				  10, TrueColor, 0x3ff00000, 0x000ffc00, 0x000003ff);
 	break;
+    default:
+	return FALSE;
     }
 
     miSetPixmapDepths ();
commit d9d3a01ffca5e2de650d098231e16205781804c5
Merge: 17416e8 fb55f8f
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Oct 24 18:12:23 2011 -0700

    Merge remote-tracking branch 'jeremyhu/master'

commit 17416e88dcfcc584fe5f87580d5d2b719b3521c3
Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Oct 20 14:43:01 2011 +0100

    xf86Crtc: handle no outputs with no modes harder.
    
    If you started an X server with no connected outputs, we pick a default
    1024x768 mode, however if you then ran an xvidmode using app against that
    server it would segfault the server due to not finding any valid modes.
    
    This was due to the no output mode set code, only adding the modes to the
    scrn->modes once, when something called randr 1.2 xf86SetScrnInfoModes would
    get called and remove all the modes and we'd end up with 0.
    
    This change fixes xf86SetScrnInfoModes to always report a scrn mode of at
    least 1024x768, and pushes the initial configuration to just call it instead
    of setting up the mode itself.
    
    Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=746926
    
    I've seen other bugs like this on other distros so it might also actually fix them.
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 384d8b4..aac33d3 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -1915,19 +1915,25 @@ xf86SetScrnInfoModes (ScrnInfoPtr scrn)
 		break;
     }
 
-    if (scrn->modes != NULL) {
-	/* For some reason, scrn->modes is circular, unlike the other mode
-	 * lists.  How great is that?
-	 */
-	for (last = scrn->modes; last && last->next; last = last->next)
-	    ;
-	last->next = scrn->modes;
-	scrn->modes->prev = last;
-	if (mode) {
-	    while (scrn->modes != mode)
-		scrn->modes = scrn->modes->next;
-	}
+    if (!scrn->modes) {
+	scrn->modes = xf86ModesAdd(scrn->modes,
+				   xf86CVTMode(scrn->display->virtualX,
+					       scrn->display->virtualY,
+					       60, 0, 0));
+    }
+
+    /* For some reason, scrn->modes is circular, unlike the other mode
+     * lists.  How great is that?
+     */
+    for (last = scrn->modes; last && last->next; last = last->next)
+	;
+    last->next = scrn->modes;
+    scrn->modes->prev = last;
+    if (mode) {
+	while (scrn->modes != mode)
+	    scrn->modes = scrn->modes->next;
     }
+
     scrn->currentMode = scrn->modes;
 #ifdef XFreeXDGA
     if (scrn->pScreen)
@@ -2529,16 +2535,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
 			      width, height);
     }
 
-    if (have_outputs) {
-	/* Mirror output modes to scrn mode list */
-	xf86SetScrnInfoModes (scrn);
-    } else {
-	/* Clear any existing modes from scrn->modes */
-	while (scrn->modes != NULL)
-	    xf86DeleteMode(&scrn->modes, scrn->modes);
-	scrn->modes = xf86ModesAdd(scrn->modes,
-				   xf86CVTMode(width, height, 60, 0, 0));
-    }
+    xf86SetScrnInfoModes (scrn);
 
     success = TRUE;
  bailout:


More information about the Xquartz-changes mailing list