xserver: Branch 'input-hotplug' - 5 commits

Daniel Stone daniels at kemper.freedesktop.org
Tue Oct 24 16:09:08 EEST 2006


 dix/getevents.c                |  195 +++++++++++++++++++++++++++++------------
 hw/kdrive/src/kdrive.c         |    2 
 hw/kdrive/src/kdrive.h         |    3 
 hw/kdrive/src/kinput.c         |   33 ++++--
 hw/xfree86/common/xf86Xinput.c |  169 +++++------------------------------
 include/input.h                |    8 +
 include/kdrive-config.h.in     |    6 +
 7 files changed, 206 insertions(+), 210 deletions(-)

New commits:
diff-tree 0cd6a3d8efb5cc1ce4f85ab95bcdf4fb66c7245d (from cccf7ae0ff24d0c84b5144c457f3f86bbbc36e12)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 06:56:07 2006 +0300

    xfree86/input: add proximity support, free valuators
    Re-add support for proximity events, and remember to both va_end our
    varargs, and free our valuators.

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index ebd5f72..36f2362 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -585,9 +585,9 @@ xf86PostMotionEvent(DeviceIntPtr	device,
     valuators = xcalloc(sizeof(int), num_valuators);
 
     va_start(var, num_valuators);
-    for (i = 0; i < num_valuators; i++) {
+    for (i = 0; i < num_valuators; i++)
         valuators[i] = va_arg(var, int);
-    }
+    va_end(var);
 
     if (!xf86Events)
         xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
@@ -600,6 +600,8 @@ xf86PostMotionEvent(DeviceIntPtr	device,
 
     for (i = 0; i < nevents; i++)
         mieqEnqueue(device, xf86Events + i);
+
+    xfree(valuators);
 }
 
 _X_EXPORT void
@@ -609,88 +611,28 @@ xf86PostProximityEvent(DeviceIntPtr	devi
                        int		num_valuators,
                        ...)
 {
-    va_list			var;
-    int				loop;
-    Bool			is_core = device->coreEvents;
-
-    ErrorF("xf86PostProximityEvent: no-op event called\n");
-
-#if 0
-    DBG(5, ErrorF("xf86PostProximityEvent BEGIN 0x%x(%s) prox=%s is_core=%s is_absolute=%s\n",
-                  device, device->name, is_in ? "true" : "false",
-                  is_core ? "True" : "False",
-                  is_absolute ? "True" : "False"));
-    
-    if (is_core) {
-        return;
-    }
-  
-    if (num_valuators && (!val || (first_valuator + num_valuators > val->numAxes))) {
-        ErrorF("Bad valuators reported for device \"%s\"\n", device->name);
-        return;
-    }
+    va_list var;
+    int i, nevents, *valuators = NULL;
 
-    xev->type = is_in ? ProximityIn : ProximityOut;
-    xev->detail = 0;
-    xev->deviceid = device->id | MORE_EVENTS;
-        
-    xv->type = DeviceValuator;
-    xv->deviceid = device->id;
-    xv->device_state = 0;
+    valuators = xcalloc(sizeof(int), num_valuators);
 
-    if ((device->valuator->mode & 1) == Relative) {
-        num_valuators = 0;
-    }
-  
-    if (num_valuators != 0) {
-        int	*axisvals = val->axisVal;
-            
-        va_start(var, num_valuators);
+    va_start(var, num_valuators);
+    for (i = 0; i < num_valuators; i++)
+        valuators[i] = va_arg(var, int);
+    va_end(var);
 
-        for(loop=0; loop<num_valuators; loop++) {
-            switch (loop % 6) {
-            case 0:
-                xv->valuator0 = is_absolute ? va_arg(var, int) : axisvals[loop]; 
-                break;
-            case 1:
-                xv->valuator1 = is_absolute ? va_arg(var, int) : axisvals[loop];
-                break;
-            case 2:
-                xv->valuator2 = is_absolute ? va_arg(var, int) : axisvals[loop];
-                break;
-            case 3:
-                xv->valuator3 = is_absolute ? va_arg(var, int) : axisvals[loop];
-                break;
-            case 4:
-                xv->valuator4 = is_absolute ? va_arg(var, int) : axisvals[loop];
-                break;
-            case 5:
-                xv->valuator5 = is_absolute ? va_arg(var, int) : axisvals[loop];
-                break;
-            }
-            if ((loop % 6 == 5) || (loop == num_valuators - 1)) {
-                xf86Info.lastEventTime = xev->time = GetTimeInMillis();
-
-                xv->num_valuators = (loop % 6) + 1;
-                xv->first_valuator = first_valuator + (loop / 6) * 6;
-                mieqEnqueue(xE);
-            }
-        }
-        va_end(var);
-    }
-    else {
-        /* no valuator */
-        xf86Info.lastEventTime = xev->time = GetTimeInMillis();
+    if (!xf86Events)
+        xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+    if (!xf86Events)
+        FatalError("Couldn't allocate event store\n");
 
-        xv->num_valuators = 0;
-        xv->first_valuator = 0;
-        mieqEnqueue(xE);
-    }
-    DBG(5, ErrorF("xf86PostProximityEvent END   0x%x(%s) prox=%s is_core=%s is_absolute=%s\n",
-                  device, device->name, is_in ? "true" : "false",
-                  is_core ? "True" : "False",
-                  is_absolute ? "True" : "False"));
-#endif
+    nevents = GetProximityEvents(xf86Events, device,
+                                 is_in ? ProximityIn : ProximityOut, 
+                                 first_valuator, num_valuators, valuators);
+    for (i = 0; i < nevents; i++)
+        mieqEnqueue(device, xf86Events + i);
+
+    xfree(valuators);
 }
 
 _X_EXPORT void
@@ -709,9 +651,9 @@ xf86PostButtonEvent(DeviceIntPtr	device,
     valuators = xcalloc(sizeof(int), num_valuators);
 
     va_start(var, num_valuators);
-    for (i = 0; i < num_valuators; i++) {
+    for (i = 0; i < num_valuators; i++)
         valuators[i] = va_arg(var, int);
-    }
+    va_end(var);
 
     if (!xf86Events)
         xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
@@ -726,6 +668,8 @@ xf86PostButtonEvent(DeviceIntPtr	device,
 
     for (i = 0; i < nevents; i++)
         mieqEnqueue(device, xf86Events + i);
+
+    xfree(valuators);
 }
 
 _X_EXPORT void
@@ -761,6 +705,7 @@ xf86PostKeyEvent(DeviceIntPtr	device,
                                             is_down ? KeyPress : KeyRelease,
                                             key_code, first_valuator,
                                             num_valuators, valuators);
+        xfree(valuators);
     }
     else {
         nevents = GetKeyboardEvents(xf86Events, device,
diff-tree cccf7ae0ff24d0c84b5144c457f3f86bbbc36e12 (from 35fa4ac12b3da33f81e2a12bc9661ed075f323ed)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 06:55:21 2006 +0300

    GetProximityEvents: add (untested) function
    Add untested first guess at what GetProximityEvents should look like.

diff --git a/dix/getevents.c b/dix/getevents.c
index 802c4e6..17a8cb4 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -56,6 +56,7 @@ extern Bool XkbCopyKeymap(XkbDescPtr src
 #include "panoramiXsrv.h"
 #endif
 
+#include <X11/extensions/XI.h>
 #include <X11/extensions/XIproto.h>
 #include "exglobals.h"
 #include "exevents.h"
@@ -533,6 +534,57 @@ GetPointerEvents(xEvent *events, DeviceI
 }
 
 /**
+ * Post ProximityIn/ProximityOut events, accompanied by valuators.
+ *
+ * events is not NULL-terminated; the return value is the number of events.
+ * The DDX is responsible for allocating the event structure in the first
+ * place via GetMaximumEventsNum(), and for freeing it.
+ */
+_X_EXPORT int
+GetProximityEvents(xEvent *events, DeviceIntPtr pDev, int type,
+                   int first_valuator, int num_valuators, int *valuators)
+{
+    int num_events = 0;
+    deviceKeyButtonPointer *kbp = (deviceKeyButtonPointer *) events;
+
+    /* Sanity checks. */
+    if (type != ProximityIn && type != ProximityOut)
+        return 0;
+
+    if (!pDev->valuator)
+        return 0;
+
+    /* Do we need to send a DeviceValuator event? */
+    if ((pDev->valuator->mode & 1) == Relative)
+        num_valuators = 0;
+
+    if (num_valuators) {
+        if ((((num_valuators - 1) / 6) + 1) > MAX_VALUATOR_EVENTS)
+            num_valuators = MAX_VALUATOR_EVENTS * 6;
+        num_events += ((num_valuators - 1) / 6) + 1;
+    }
+
+    /* You fail. */
+    if (first_valuator < 0 ||
+        (num_valuators + first_valuator) > pDev->valuator->numAxes)
+        return 0;
+
+    kbp->type = type;
+    kbp->deviceid = pDev->id;
+    kbp->detail = 0;
+    kbp->time = GetTimeInMillis();
+
+    if (num_valuators) {
+        kbp->deviceid |= MORE_EVENTS;
+        events++;
+        events = getValuatorEvents(events, pDev, first_valuator,
+                                   num_valuators, valuators);
+    }
+
+    return num_events;
+}
+
+/**
  * Note that pDev was the last device to send a core event.  This function
  * copies the complete keymap from the originating device to the core
  * device, and makes sure the appropriate notifications are generated.
diff --git a/include/input.h b/include/input.h
index 4acc856..f6ef337 100644
--- a/include/input.h
+++ b/include/input.h
@@ -410,6 +410,14 @@ extern int GetKeyboardValuatorEvents(
     int num_valuator,
     int *valuators);
 
+extern int GetProximityEvents(
+    xEvent *events,
+    DeviceIntPtr pDev,
+    int type,
+    int first_valuator,
+    int num_valuators,
+    int *valuators);
+
 extern void SwitchCoreKeyboard(DeviceIntPtr pDev);
 extern void SwitchCorePointer(DeviceIntPtr pDev);
 
diff-tree 35fa4ac12b3da33f81e2a12bc9661ed075f323ed (from a7c2d9a15dc2ff253bb69c3b0738ad993521b9c7)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 06:23:45 2006 +0300

    GetPointerEvents: break into separate functions
    Break out clipAxis, clipValuators, and getValuatorEvents, into
    separate functions, to be used by the proximity event code.

diff --git a/dix/getevents.c b/dix/getevents.c
index ca199c6..802c4e6 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -303,6 +303,69 @@ acceleratePointer(DeviceIntPtr pDev, int
 }
 
 /**
+ * Clip an axis to its bounds.
+ */
+static void
+clipAxis(DeviceIntPtr pDev, int axisNum, int *val)
+{
+    AxisInfoPtr axes = pDev->valuator->axes + axisNum;
+
+    if (*val < axes->min_value)
+        *val = axes->min_value;
+    if (axes->max_value >= 0 && *val > axes->max_value)
+        *val = axes->max_value;
+}
+
+/**
+ * Compare the list of valuators against the limits for each axis, and clip
+ * them to those bounds.
+ */
+static void
+clipValuators(DeviceIntPtr pDev, int first_valuator, int num_valuators,
+              int *valuators)
+{
+    AxisInfoPtr axes = pDev->valuator->axes + first_valuator;
+    int i;
+
+    for (i = 0; i < num_valuators; i++, axes++)
+        clipAxis(pDev, i + first_valuator, &(valuators[i]));
+}
+
+/**
+ * Fills events with valuator events for pDev, as given by the other
+ * parameters.
+ */
+static xEvent *
+getValuatorEvents(xEvent *events, DeviceIntPtr pDev, int first_valuator,
+                  int num_valuators, int *valuators) {
+    deviceValuator *xv = (deviceValuator *) events;
+    int i = 0, final_valuator = first_valuator + num_valuators;
+
+    for (i = first_valuator; i < final_valuator; i += 6, xv++, events++) {
+        xv->type = DeviceValuator;
+        xv->first_valuator = i;
+        xv->num_valuators = num_valuators;
+        xv->deviceid = pDev->id;
+        switch (final_valuator - i) {
+        case 6:
+            xv->valuator5 = valuators[i + 5];
+        case 5:
+            xv->valuator4 = valuators[i + 4];
+        case 4:
+            xv->valuator3 = valuators[i + 3];
+        case 3:
+            xv->valuator2 = valuators[i + 2];
+        case 2:
+            xv->valuator1 = valuators[i + 1];
+        case 1:
+            xv->valuator0 = valuators[i];
+        }
+    }
+
+    return events;
+}
+
+/**
  * Generate a series of xEvents (returned in xE) representing pointer
  * motion, or button presses.  Xi and XKB-aware.
  *
@@ -314,22 +377,17 @@ _X_EXPORT int
 GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
                  int flags, int first_valuator, int num_valuators,
                  int *valuators) {
-    int num_events = 0, ms = 0, final_valuator = 0, i = 0;
+    int num_events = 0, ms = 0, final_valuator = 0;
     deviceKeyButtonPointer *kbp = NULL;
-    deviceValuator *xv = NULL;
-    AxisInfoPtr axes = NULL;
     Bool sendValuators = (type == MotionNotify || flags & POINTER_ABSOLUTE);
     DeviceIntPtr cp = inputInfo.pointer;
     int x = 0, y = 0;
 
+    /* Sanity checks. */
     if (type != MotionNotify && type != ButtonPress && type != ButtonRelease)
         return 0;
 
-    if (!pDev->button || (pDev->coreEvents && (!cp->button || !cp->valuator)))
-        return 0;
-
-    /* You fail. */
-    if (first_valuator < 0)
+    if ((type == ButtonPress || type == ButtonRelease) && !pDev->button)
         return 0;
 
     if (pDev->coreEvents)
@@ -339,9 +397,9 @@ GetPointerEvents(xEvent *events, DeviceI
 
     /* Do we need to send a DeviceValuator event? */
     if ((num_valuators + first_valuator) >= 2 && sendValuators) {
-        if (((num_valuators / 6) + 1) > MAX_VALUATOR_EVENTS)
-            num_valuators = MAX_VALUATOR_EVENTS;
-        num_events += (num_valuators / 6) + 1;
+        if ((((num_valuators - 1) / 6) + 1) > MAX_VALUATOR_EVENTS)
+            num_valuators = MAX_VALUATOR_EVENTS * 6;
+        num_events += ((num_valuators - 1) / 6) + 1;
     }
     else if (type == MotionNotify && num_valuators <= 0) {
         return 0;
@@ -349,6 +407,10 @@ GetPointerEvents(xEvent *events, DeviceI
 
     final_valuator = num_valuators + first_valuator;
 
+    /* You fail. */
+    if (first_valuator < 0 || final_valuator > pDev->valuator->numAxes)
+        return 0;
+
     ms = GetTimeInMillis();
 
     kbp = (deviceKeyButtonPointer *) events;
@@ -405,24 +467,22 @@ GetPointerEvents(xEvent *events, DeviceI
         }
     }
 
-
-    axes = pDev->valuator->axes;
-    if (x < axes->min_value)
-        x = axes->min_value;
-    if (axes->max_value > 0 && x > axes->max_value)
-        x = axes->max_value;
-
-    axes++;
-    if (y < axes->min_value)
-        y = axes->min_value;
-    if (axes->max_value > 0 && y > axes->max_value)
-        y = axes->max_value;
+    /* Clip both x and y to the defined limits (usually co-ord space limit). */
+    clipAxis(pDev, 0, &x);
+    clipAxis(pDev, 1, &y);
 
     /* This takes care of crossing screens for us, as well as clipping
      * to the current screen.  Right now, we only have one history buffer,
      * so we don't set this for both the device and core.*/
     miPointerSetPosition(pDev, &x, &y, ms);
 
+    /* Drop x and y back into the valuators list, if they were originally
+     * present. */
+    if (first_valuator == 0 && num_valuators >= 1)
+        valuators[0] = x;
+    if (first_valuator <= 1 && num_valuators >= (2 - first_valuator))
+        valuators[1 - first_valuator] = y;
+
     if (pDev->coreEvents) {
         cp->valuator->lastx = x;
         cp->valuator->lasty = y;
@@ -446,39 +506,13 @@ GetPointerEvents(xEvent *events, DeviceI
 
     if (final_valuator > 2 && sendValuators) {
         kbp->deviceid |= MORE_EVENTS;
-        for (i = first_valuator; i < final_valuator; i += 6) {
-            xv = (deviceValuator *) ++events;
-            xv->type = DeviceValuator;
-            xv->first_valuator = i;
-            xv->num_valuators = num_valuators;
-            xv->deviceid = kbp->deviceid;
-            switch (final_valuator - i) {
-            case 6:
-                xv->valuator5 = valuators[i + 5];
-            case 5:
-                xv->valuator4 = valuators[i + 4];
-            case 4:
-                xv->valuator3 = valuators[i + 3];
-            case 3:
-                xv->valuator2 = valuators[i + 2];
-            case 2:
-                /* x and y may have been accelerated. */
-                if (i == 0)
-                    xv->valuator1 = kbp->root_y;
-                else
-                    xv->valuator1 = valuators[i + 1];
-            case 1:
-                /* x and y may have been accelerated. */
-                if (i == 0)
-                    xv->valuator0 = kbp->root_x;
-                else
-                    xv->valuator0 = valuators[i];
-            }
-        }
+        events++;
+        clipValuators(pDev, first_valuator, num_valuators, valuators);
+        events = getValuatorEvents(events, pDev, first_valuator,
+                                   num_valuators, valuators);
     }
 
     if (pDev->coreEvents) {
-        events++;
         events->u.u.type = type;
         events->u.keyButtonPointer.time = ms;
         events->u.keyButtonPointer.rootX = x;
@@ -562,7 +596,7 @@ SwitchCorePointer(DeviceIntPtr pDev)
 void
 PostSyntheticMotion(int x, int y, int screenNum, unsigned long time)
 {
-    xEvent xE = { 0, };
+    xEvent xE;
 
 #ifdef PANORAMIX
     /* Translate back to the sprite screen since processInputProc
@@ -574,6 +608,7 @@ PostSyntheticMotion(int x, int y, int sc
     }
 #endif
 
+    memset(&xE, 0, sizeof(xEvent));
     xE.u.u.type = MotionNotify;
     xE.u.keyButtonPointer.rootX = x;
     xE.u.keyButtonPointer.rootY = y;
diff-tree a7c2d9a15dc2ff253bb69c3b0738ad993521b9c7 (from c8f76fb3a473a022d497bd0acd6c84f58fc6efbe)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 06:08:27 2006 +0300

    kdrive: numerous warning fixes

diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index 1cc2932..f29fdb9 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -619,8 +619,6 @@ KdProcessArgument (int argc, char **argv
 {
     KdCardInfo	    *card;
     KdScreenInfo    *screen;
-    KdPointerInfo   *pi;
-    KdKeyboardInfo  *ki;
 
     if (!strcmp (argv[i], "-card"))
     {
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index 7f752e9..15d7031 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -816,6 +816,9 @@ void
 KdUnregisterFds (void *closure, Bool do_close);
 
 void
+KdUnregisterFd (void *closure, int fd, Bool do_close);
+
+void
 KdEnqueueKeyboardEvent(KdKeyboardInfo *ki, unsigned char scan_code,
                     unsigned char is_up);
 
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index c900266..78943e4 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -48,6 +48,7 @@
 #ifdef XINPUT
 #include <X11/extensions/XI.h>
 #include <X11/extensions/XIproto.h>
+#include "XIstubs.h" /* even though we don't use stubs.  cute, no? */
 #include "exevents.h"
 #include "extinit.h"
 #include "exglobals.h"
@@ -131,7 +132,7 @@ KdUnblockSigio (void)
     sigprocmask (SIG_UNBLOCK, &set, 0);
 }
 
-#ifdef DEBUG
+#ifdef DEBUG_SIGIO
 
 void
 KdAssertSigioBlocked (char *where)
@@ -244,7 +245,7 @@ KdUnregisterFd (void *closure, int fd, B
 
     for (i = 0; i < kdNumInputFds; i++) {
 	if (kdInputFds[i].closure == closure &&
-            kdInputFds[i].fd == fd) {
+            (fd == -1 || kdInputFds[i].fd == fd)) {
 	    if (kdInputEnabled)
 		KdRemoveFd (kdInputFds[i].fd);
 	    if (do_close)
@@ -258,6 +259,12 @@ KdUnregisterFd (void *closure, int fd, B
 }
 
 void
+KdUnregisterFds (void *closure, Bool do_close)
+{
+    KdUnregisterFd(closure, -1, do_close);
+}
+
+void
 KdDisableInput (void)
 {
     KdKeyboardInfo *ki;
@@ -348,7 +355,7 @@ KdEnableInput (void)
     KdUnblockSigio ();
 }
 
-KdKeyboardDriver *
+static KdKeyboardDriver *
 KdFindKeyboardDriver (char *name)
 {
     KdKeyboardDriver *ret;
@@ -365,7 +372,7 @@ KdFindKeyboardDriver (char *name)
     return NULL;
 }
 
-KdPointerDriver *
+static KdPointerDriver *
 KdFindPointerDriver (char *name)
 {
     KdPointerDriver *ret;
@@ -444,7 +451,7 @@ KdPointerProc(DeviceIntPtr pDevice, int 
 
 #ifdef XINPUT
         if (pi->inputClass == KD_TOUCHSCREEN) {
-            InitAbsoluteClassDeviceStruct(pDev);
+            InitAbsoluteClassDeviceStruct(pDevice);
             xiclass = AtomFromName(XI_TOUCHSCREEN);
         }
         else {
@@ -2261,7 +2268,8 @@ ChangeKeyboardDevice(DeviceIntPtr pOldDe
 }
 
 int
-ChangePointerDevice(DeviceIntPtr pOldDev, DeviceIntPtr pDev, int x, int y)
+ChangePointerDevice(DeviceIntPtr pOldDev, DeviceIntPtr pDev, unsigned char x,
+                    unsigned char y)
 {
     return BadDevice;
 }
@@ -2277,20 +2285,17 @@ OpenInputDevice(DeviceIntPtr pDev, Clien
         *status = Success;
 }
 
-int
+void
 CloseInputDevice(DeviceIntPtr pDev, ClientPtr client)
 {
-    if (!pDev)
-        return BadDevice;
-
-    return Success;
+    return;
 }
 
 /* We initialise all input devices at startup. */
-int
+void
 AddOtherInputDevices(void)
 {
-    return Success;
+    return;
 }
 
 /* At the moment, absolute/relative is up to the client. */
@@ -2396,4 +2401,6 @@ NewInputDeviceRequest(InputOption *optio
             return BadImplementation;
         }
     }
+
+    return Success;
 }
diff --git a/include/kdrive-config.h.in b/include/kdrive-config.h.in
index 2f454d7..3bc7792 100644
--- a/include/kdrive-config.h.in
+++ b/include/kdrive-config.h.in
@@ -25,4 +25,10 @@
 /* Verbose debugging output hilarity */
 #undef DEBUG
 
+/* Have the backtrace() function. */
+#undef HAVE_BACKTRACE
+
+/* Have execinfo.h for backtrace(). */
+#undef HAVE_EXECINFO_H
+
 #endif /* _KDRIVE_CONFIG_H_ */
diff-tree c8f76fb3a473a022d497bd0acd6c84f58fc6efbe (from c5b5b046e86b159a9d32451308f38246cc4587f7)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 05:12:15 2006 +0300

    xfree86/input: disallow pointer device changes, fix drag event calculation
    Don't allow users to change the core pointer.
    Fix xf86SendDragEvents to check the device button state, not the core
    pointer's.
    Remove unused xf86CheckButton.

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index e1fa9c1..ebd5f72 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -107,7 +107,7 @@ xf86SendDragEvents(DeviceIntPtr	device)
 {
     LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate;
     
-    if (inputInfo.pointer->button->buttonsDown > 0)
+    if (device->button->buttonsDown > 0)
         return (local->flags & XI86_SEND_DRAG_EVENTS);
     else
         return (TRUE);
@@ -115,40 +115,6 @@ xf86SendDragEvents(DeviceIntPtr	device)
 
 /***********************************************************************
  *
- * xf86CheckButton --
- *	
- *	Test if the core pointer button state is coherent with
- * the button event to send.
- *
- ***********************************************************************
- */
-Bool
-xf86CheckButton(int	button,
-                int	down)
-{
-    int	check;
-    int bit = (1 << (button - 1));
-
-    /* XXX FIXME VERDAMMT */
-#if 0
-    check = xf86CoreButtonState & bit;
-    
-    DBG(5, ErrorF("xf86CheckButton "
-                  "button=%d down=%d state=%d check=%d returns ",
-                   button, down, xf86CoreButtonState, check));
-    if ((check && down) || (!check && !down)) {
-        DBG(5, ErrorF("FALSE\n"));
-        return FALSE;
-    }
-    xf86CoreButtonState ^= bit;
-
-    DBG(5, ErrorF("TRUE\n"));
-#endif
-    return TRUE;
-}
-
-/***********************************************************************
- *
  * xf86ProcessCommonOptions --
  * 
  *	Process global options.
@@ -377,30 +343,6 @@ ChangePointerDevice (
     axes_changed = FALSE;
    *************************************************************************/
 
-  /*
-   * We don't allow axis swap or other exotic features.
-   */
-  if (x == 0 && y == 1) {
-      LocalDevicePtr	old_local = (LocalDevicePtr)old_dev->public.devicePrivate;
-      LocalDevicePtr	new_local = (LocalDevicePtr)new_dev->public.devicePrivate;
-      
-      InitFocusClassDeviceStruct(old_dev);
-    
-      /* Restore Extended motion history information */
-      old_dev->valuator->GetMotionProc   = old_local->motion_history_proc;
-      old_dev->valuator->numMotionEvents = old_local->history_size;
-
-      /* Save Extended motion history information */
-      new_local->motion_history_proc = new_dev->valuator->GetMotionProc;
-      new_local->history_size	     = new_dev->valuator->numMotionEvents;
-      
-      /* Set Core motion history information */
-      new_dev->valuator->GetMotionProc   = miPointerGetMotionEvents;
-      new_dev->valuator->numMotionEvents = miPointerGetMotionBufferSize();
-      
-    return Success;
-  }
-  else
     return !Success;
 }
 



More information about the xorg-commit mailing list