xserver: Branch 'input-hotplug' - 11 commits

Daniel Stone daniels at kemper.freedesktop.org
Tue Oct 31 01:34:00 EET 2006


 Xi/chgkbd.c                    |  102 ----------------------------
 Xi/chgkbd.h                    |    5 -
 Xi/chgptr.c                    |   91 -------------------------
 Xi/chgptr.h                    |    5 -
 Xi/extinit.c                   |    6 -
 Xi/stubs.c                     |   80 ----------------------
 dix/devices.c                  |   11 ++-
 dix/getevents.c                |    3 
 hw/kdrive/ephyr/os.c           |   30 --------
 hw/kdrive/linux/keyboard.c     |   32 +--------
 hw/kdrive/linux/linux.c        |   39 +++--------
 hw/kdrive/src/kdrive.c         |   16 ++--
 hw/kdrive/src/kdrive.h         |    1 
 hw/kdrive/src/kinput.c         |   38 ++++++++--
 hw/kdrive/vxworks/vxworks.c    |   28 -------
 hw/xfree86/common/xf86Xinput.c |  145 +----------------------------------------
 include/XIstubs.h              |   12 ---
 mi/mieq.c                      |    3 
 os/WaitFor.c                   |   20 ++---
 os/utils.c                     |   19 -----
 20 files changed, 100 insertions(+), 586 deletions(-)

New commits:
diff-tree 644ee2434a4e09f5baea00a486911f8c24b9a261 (from 738d2e88171bcce8782d670a1cda9a1d941d7977)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 29 03:52:11 2006 +0300

    kdrive: avoid null dereferences
    Avoid jumping into NULL pointers for OS or card functions which do not
    exist.

diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index f29fdb9..b6ac0b0 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -281,7 +281,7 @@ KdSuspend (void)
 	    for (screen = card->screenList; screen; screen = screen->next)
 		if (screen->mynum == card->selected && screen->pScreen)
 		    KdDisableScreen (screen->pScreen);
-	    if (card->driver)
+	    if (card->driver && card->cfuncs->restore)
 		(*card->cfuncs->restore) (card);
 	}
 	KdDisableInput ();
@@ -295,7 +295,8 @@ KdDisableScreens (void)
     KdSuspend ();
     if (kdEnabled)
     {
-	(*kdOsFuncs->Disable) ();
+        if (kdOsFuncs->Disable)
+            (*kdOsFuncs->Disable) ();
 	kdEnabled = FALSE;
     }
 }
@@ -353,7 +354,8 @@ KdEnableScreens (void)
     if (!kdEnabled)
     {
 	kdEnabled = TRUE;
-	(*kdOsFuncs->Enable) ();
+        if (kdOsFuncs->Enable)
+            (*kdOsFuncs->Enable) ();
     }
     KdResume ();
 }
@@ -373,9 +375,10 @@ AbortDDX(void)
     KdDisableScreens ();
     if (kdOsFuncs)
     {
-	if (kdEnabled)
+	if (kdEnabled && kdOsFuncs->Disable)
 	    (*kdOsFuncs->Disable) ();
-	(*kdOsFuncs->Fini) ();
+        if (kdOsFuncs->Fini)
+            (*kdOsFuncs->Fini) ();
 	KdDoSwitchCmd ("stop");
     }
 
@@ -768,7 +771,8 @@ KdOsInit (KdOsFuncs *pOsFuncs)
 	if (serverGeneration == 1) 
 	{
 	    KdDoSwitchCmd ("start");
-	    (*pOsFuncs->Init) ();
+            if (pOsFuncs->Init)
+                (*pOsFuncs->Init) ();
 	}
     }
 }
diff-tree 738d2e88171bcce8782d670a1cda9a1d941d7977 (from 96e32805d12fc36f0fa0926dbfb0dd8a5cadb739)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 29 03:48:02 2006 +0300

    kdrive: move bell ringing into an OS function
    Move the bell into an OS function, and use that if it's declared; else,
    fall back to using the driver's function.
    Remove the Linux keyboard bell function; just move it into the OS layer.
    Use named initialisers when converting the old structures, and eliminate
    unused functions.

diff --git a/hw/kdrive/ephyr/os.c b/hw/kdrive/ephyr/os.c
index ead1586..1a42495 100644
--- a/hw/kdrive/ephyr/os.c
+++ b/hw/kdrive/ephyr/os.c
@@ -34,34 +34,8 @@ EphyrInit (void)
   return hostx_init();
 }
 
-static void
-EphyrEnable (void)
-{
-  EPHYR_DBG("mark");
-}
-
-static Bool
-EphyrSpecialKey (KeySym sym)
-{
-    return FALSE;
-}
-
-static void
-EphyrDisable (void)
-{
-}
-
-static void
-EphyrFini (void)
-{
-}
-
 KdOsFuncs   EphyrOsFuncs = {
-    EphyrInit,
-    EphyrEnable,
-    EphyrSpecialKey,
-    EphyrDisable,
-    EphyrFini,
-    ephyrPoll
+    .Init = EphyrInit,
+    .pollEvents = ephyrPoll,
 };
 
diff --git a/hw/kdrive/linux/keyboard.c b/hw/kdrive/linux/keyboard.c
index 24653ad..b7571f6 100644
--- a/hw/kdrive/linux/keyboard.c
+++ b/hw/kdrive/linux/keyboard.c
@@ -791,11 +791,6 @@ LinuxKeyboardInit (KdKeyboardInfo *ki)
 }
 
 static void
-LinuxKeyboardFini (KdKeyboardInfo *ki)
-{
-}
-
-static void
 LinuxKeyboardLeds (KdKeyboardInfo *ki, int leds)
 {
     if (!ki)
@@ -804,29 +799,10 @@ LinuxKeyboardLeds (KdKeyboardInfo *ki, i
     ioctl ((int)ki->driverPrivate, KDSETLED, leds & 7);
 }
 
-static void
-LinuxKeyboardBell (KdKeyboardInfo *ki, int volume, int pitch, int duration)
-{
-    if (!ki)
-        return;
-
-    if (volume && pitch)
-    {
-	ioctl((int)ki->driverPrivate, KDMKTONE,
-	      ((1193190 / pitch) & 0xffff) |
-	      (((unsigned long)duration *
-		volume / 50) << 16));
-
-    }
-}
-
 KdKeyboardDriver LinuxKeyboardDriver = {
     "keyboard",
-    LinuxKeyboardInit,
-    LinuxKeyboardEnable,
-    LinuxKeyboardLeds,
-    LinuxKeyboardBell,
-    LinuxKeyboardDisable,
-    LinuxKeyboardFini,
-    NULL,
+    .Init = LinuxKeyboardInit,
+    .Enable = LinuxKeyboardEnable,
+    .Leds = LinuxKeyboardLeds,
+    .Disable = LinuxKeyboardDisable,
 };
diff --git a/hw/kdrive/linux/linux.c b/hw/kdrive/linux/linux.c
index 7ba99b4..c1fe185 100644
--- a/hw/kdrive/linux/linux.c
+++ b/hw/kdrive/linux/linux.c
@@ -373,26 +373,6 @@ LinuxEnable (void)
     enabled = TRUE;
 }
 
-static Bool
-LinuxSpecialKey (KeySym sym)
-{
-    struct vt_stat  vts;
-    int		    con;
-    
-    if (XK_F1 <= sym && sym <= XK_F12)
-    {
-	con = sym - XK_F1 + 1;
-	memset (&vts, '\0', sizeof (vts));	/* valgrind */
-	ioctl (LinuxConsoleFd, VT_GETSTATE, &vts);
-	if (con != vts.v_active && (vts.v_state & (1 << con)))
-	{
-	    ioctl (LinuxConsoleFd, VT_ACTIVATE, con);
-	    return TRUE;
-	}
-    }
-    return FALSE;
-}
-
 static void
 LinuxDisable (void)
 {
@@ -481,13 +461,20 @@ KdOsAddInputDrivers ()
     KdAddKeyboardDriver(&LinuxKeyboardDriver);
 }
 
+static void
+LinuxBell(int volume, int pitch, int duration)
+{
+    if (volume && pitch)
+        ioctl(LinuxConsoleFd, KDMKTONE, ((1193190 / pitch) & 0xffff) |
+              (((unsigned long)duration * volume / 50) << 16));
+}
+
 KdOsFuncs   LinuxFuncs = {
-    LinuxInit,
-    LinuxEnable,
-    LinuxSpecialKey,
-    LinuxDisable,
-    LinuxFini,
-    0
+    .Init = LinuxInit,
+    .Enable = LinuxEnable,
+    .Disable = LinuxDisable,
+    .Fini = LinuxFini,
+    .Bell = LinuxBell,
 };
 
 void
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index 15d7031..f0fc909 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -369,6 +369,7 @@ typedef struct _KdOsFuncs {
     void	    (*Disable) (void);
     void	    (*Fini) (void);
     void	    (*pollEvents) (void);
+    void            (*Bell) (int, int, int);
 } KdOsFuncs;
 
 typedef enum _KdSyncPolarity {
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index fdeed82..be18586 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -523,22 +523,46 @@ LegalModifier(unsigned int key, DeviceIn
 }
 
 static void
-KdBell (int volume, DeviceIntPtr pDev, pointer ctrl, int something)
+KdBell (int volume, DeviceIntPtr pDev, pointer arg, int something)
 {
+    KeybdCtrl *ctrl = arg;
     KdKeyboardInfo *ki = NULL;
-
+    
     for (ki = kdKeyboards; ki; ki = ki->next) {
-        if (ki->dixdev && (ki->dixdev->id == pDev->id))
+        if (ki->dixdev && ki->dixdev->id == pDev->id)
             break;
     }
 
     if (!ki || !ki->dixdev || ki->dixdev->id != pDev->id || !ki->driver)
         return;
-        
-    if (kdInputEnabled) {
-        if (ki->driver->Bell)
-            (*ki->driver->Bell) (ki, volume, ki->bellPitch, ki->bellDuration);
+    
+    KdRingBell(ki, volume, ctrl->bell_pitch, ctrl->bell_duration);
+}
+
+void
+DDXRingBell(int volume, int pitch, int duration)
+{
+    KdKeyboardInfo *ki = NULL;
+
+    if (kdOsFuncs->Bell) {
+        (*kdOsFuncs->Bell)(volume, pitch, duration);
     }
+    else {
+        for (ki = kdKeyboards; ki; ki = ki->next) {
+            if (ki->dixdev->coreEvents)
+                KdRingBell(ki, volume, pitch, duration);
+        }
+    }
+}
+
+void
+KdRingBell(KdKeyboardInfo *ki, int volume, int pitch, int duration)
+{
+    if (!ki || !ki->driver || !ki->driver->Bell)
+        return;
+        
+    if (kdInputEnabled)
+        (*ki->driver->Bell) (ki, volume, pitch, duration);
 }
 
 
diff --git a/hw/kdrive/vxworks/vxworks.c b/hw/kdrive/vxworks/vxworks.c
index aa46001..688de62 100644
--- a/hw/kdrive/vxworks/vxworks.c
+++ b/hw/kdrive/vxworks/vxworks.c
@@ -12,17 +12,6 @@
 #include "kdrive.h"
 #include <X11/keysym.h>
 
-int
-VxWorksInit (void)
-{
-    return 1;
-}
-
-void
-VxWorksEnable (void)
-{
-}
-
 Bool
 VxWorksSpecialKey (KeySym sym)
 {
@@ -38,16 +27,6 @@ VxWorksSpecialKey (KeySym sym)
 }
 
 void
-VxWorksDisable (void)
-{
-}
-
-void
-VxWorksFini (void)
-{
-}
-
-void
 KdOsAddInputDrivers (void)
 {
     KdAddPointerDriver(&VxWorksMouseDriver);
@@ -55,12 +34,7 @@ KdOsAddInputDrivers (void)
 }
 
 KdOsFuncs   VxWorksFuncs = {
-    VxWorksInit,
-    VxWorksEnable,
-    VxWorksSpecialKey,
-    VxWorksDisable,
-    VxWorksFini,
-    0
+    .SpecialKey = VxWorksSpecialKey,
 };
 
 void
diff-tree 96e32805d12fc36f0fa0926dbfb0dd8a5cadb739 (from 68f595ca6c7883e030947b7f95c50e92aa733f2b)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 29 03:43:34 2006 +0300

    Xi: disallow changing core keyboard and pointer
    Just short-circuit the change core keyboard/pointer requests.

diff --git a/Xi/chgkbd.c b/Xi/chgkbd.c
index 289bd85..8134b40 100644
--- a/Xi/chgkbd.c
+++ b/Xi/chgkbd.c
@@ -64,7 +64,6 @@ SOFTWARE.
 #include "XIstubs.h"
 #include "globals.h"
 #include "extnsionst.h"
-#include "extinit.h"	/* LookupDeviceIntRec */
 
 #include "exevents.h"
 #include "exglobals.h"
@@ -99,107 +98,10 @@ SProcXChangeKeyboardDevice(register Clie
 int
 ProcXChangeKeyboardDevice(register ClientPtr client)
 {
-    int i;
-    DeviceIntPtr xkbd = inputInfo.keyboard;
-    DeviceIntPtr dev;
-    FocusClassPtr xf = xkbd->focus;
-    FocusClassPtr df;
-    KeyClassPtr k;
-    xChangeKeyboardDeviceReply rep;
-    changeDeviceNotify ev;
-
     REQUEST(xChangeKeyboardDeviceReq);
     REQUEST_SIZE_MATCH(xChangeKeyboardDeviceReq);
 
-    rep.repType = X_Reply;
-    rep.RepType = X_ChangeKeyboardDevice;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
-    dev = LookupDeviceIntRec(stuff->deviceid);
-    if (dev == NULL) {
-	rep.status = -1;
-	SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0,
-			  BadDevice);
-	return Success;
-    }
-
-    k = dev->key;
-    if (k == NULL) {
-	rep.status = -1;
-	SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0,
-			  BadMatch);
-	return Success;
-    }
-
-    if (((dev->grab) && !SameClient(dev->grab, client)) ||
-	((xkbd->grab) && !SameClient(xkbd->grab, client)))
-	rep.status = AlreadyGrabbed;
-    else if ((dev->sync.frozen &&
-	      dev->sync.other && !SameClient(dev->sync.other, client)) ||
-	     (xkbd->sync.frozen &&
-	      xkbd->sync.other && !SameClient(xkbd->sync.other, client)))
-	rep.status = GrabFrozen;
-    else {
-	if (ChangeKeyboardDevice(xkbd, dev) != Success) {
-	    SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0,
-			      BadDevice);
-	    return Success;
-	}
-	if (!dev->focus)
-	    InitFocusClassDeviceStruct(dev);
-	if (!dev->kbdfeed)
-	    InitKbdFeedbackClassDeviceStruct(dev, (BellProcPtr) NoopDDA,
-					     (KbdCtrlProcPtr) NoopDDA);
-	df = dev->focus;
-	df->win = xf->win;
-	df->revert = xf->revert;
-	df->time = xf->time;
-	df->traceGood = xf->traceGood;
-	if (df->traceSize != xf->traceSize) {
-	    Must_have_memory = TRUE;	/* XXX */
-	    df->trace = (WindowPtr *) xrealloc(df->trace,
-					       xf->traceSize *
-					       sizeof(WindowPtr));
-	    Must_have_memory = FALSE;	/* XXX */
-	}
-	df->traceSize = xf->traceSize;
-	for (i = 0; i < df->traceSize; i++)
-	    df->trace[i] = xf->trace[i];
-	RegisterOtherDevice(xkbd);
-	RegisterKeyboardDevice(dev);
-
-	ev.type = ChangeDeviceNotify;
-	ev.deviceid = stuff->deviceid;
-	ev.time = currentTime.milliseconds;
-	ev.request = NewKeyboard;
-
-	SendEventToAllWindows(dev, ChangeDeviceNotifyMask, (xEvent *) & ev, 1);
-	SendMappingNotify(MappingKeyboard, k->curKeySyms.minKeyCode,
-			  k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode +
-			  1, client);
-
-	rep.status = 0;
-    }
-
-    WriteReplyToClient(client, sizeof(xChangeKeyboardDeviceReply), &rep);
+    SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0,
+                      BadDevice);
     return Success;
 }
-
-/***********************************************************************
- *
- * This procedure writes the reply for the XChangeKeyboardDevice 
- * function, if the client and server have a different byte ordering.
- *
- */
-
-void
-SRepXChangeKeyboardDevice(ClientPtr client, int size,
-			  xChangeKeyboardDeviceReply * rep)
-{
-    register char n;
-
-    swaps(&rep->sequenceNumber, n);
-    swapl(&rep->length, n);
-    WriteToClient(client, size, (char *)rep);
-}
diff --git a/Xi/chgkbd.h b/Xi/chgkbd.h
index 7a883b7..5f99223 100644
--- a/Xi/chgkbd.h
+++ b/Xi/chgkbd.h
@@ -36,9 +36,4 @@ int SProcXChangeKeyboardDevice(ClientPtr
 int ProcXChangeKeyboardDevice(ClientPtr	/* client */
     );
 
-void SRepXChangeKeyboardDevice(ClientPtr /* client */ ,
-			       int /* size */ ,
-			       xChangeKeyboardDeviceReply *	/* rep */
-    );
-
 #endif /* CHGKBD_H */
diff --git a/Xi/chgptr.c b/Xi/chgptr.c
index b799092..22c8a5f 100644
--- a/Xi/chgptr.c
+++ b/Xi/chgptr.c
@@ -101,97 +101,10 @@ SProcXChangePointerDevice(register Clien
 int
 ProcXChangePointerDevice(register ClientPtr client)
 {
-    DeviceIntPtr xptr = inputInfo.pointer;
-    DeviceIntPtr dev;
-    ValuatorClassPtr v;
-    xChangePointerDeviceReply rep;
-    changeDeviceNotify ev;
-
     REQUEST(xChangePointerDeviceReq);
     REQUEST_SIZE_MATCH(xChangePointerDeviceReq);
 
-    rep.repType = X_Reply;
-    rep.RepType = X_ChangePointerDevice;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
-    dev = LookupDeviceIntRec(stuff->deviceid);
-    if (dev == NULL) {
-	rep.status = -1;
-	SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0,
-			  BadDevice);
-	return Success;
-    }
-
-    v = dev->valuator;
-    if (v == NULL || v->numAxes < 2 ||
-	stuff->xaxis >= v->numAxes || stuff->yaxis >= v->numAxes) {
-	rep.status = -1;
-	SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0, BadMatch);
-	return Success;
-    }
-
-    if (((dev->grab) && !SameClient(dev->grab, client)) ||
-	((xptr->grab) && !SameClient(xptr->grab, client)))
-	rep.status = AlreadyGrabbed;
-    else if ((dev->sync.frozen &&
-	      dev->sync.other && !SameClient(dev->sync.other, client)) ||
-	     (xptr->sync.frozen &&
-	      xptr->sync.other && !SameClient(xptr->sync.other, client)))
-	rep.status = GrabFrozen;
-    else {
-	if (ChangePointerDevice(xptr, dev, stuff->xaxis, stuff->yaxis) !=
-	    Success) {
-	    SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0,
-			      BadDevice);
-	    return Success;
-	}
-	if (dev->focus)
-	    DeleteFocusClassDeviceStruct(dev);
-	if (!dev->button)
-	    InitButtonClassDeviceStruct(dev, 0, NULL);
-	if (!dev->ptrfeed)
-	    InitPtrFeedbackClassDeviceStruct(dev, (PtrCtrlProcPtr) NoopDDA);
-	RegisterOtherDevice(xptr);
-	RegisterPointerDevice(dev);
-
-	ev.type = ChangeDeviceNotify;
-	ev.deviceid = stuff->deviceid;
-	ev.time = currentTime.milliseconds;
-	ev.request = NewPointer;
-
-	SendEventToAllWindows(dev, ChangeDeviceNotifyMask, (xEvent *) & ev, 1);
-	SendMappingNotify(MappingPointer, 0, 0, client);
-
-	rep.status = 0;
-    }
-
-    WriteReplyToClient(client, sizeof(xChangePointerDeviceReply), &rep);
+    SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0,
+                      BadDevice);
     return Success;
 }
-
-void
-DeleteFocusClassDeviceStruct(DeviceIntPtr dev)
-{
-    xfree(dev->focus->trace);
-    xfree(dev->focus);
-    dev->focus = NULL;
-}
-
-/***********************************************************************
- *
- * This procedure writes the reply for the XChangePointerDevice 
- * function, if the client and server have a different byte ordering.
- *
- */
-
-void
-SRepXChangePointerDevice(ClientPtr client, int size,
-			 xChangePointerDeviceReply * rep)
-{
-    register char n;
-
-    swaps(&rep->sequenceNumber, n);
-    swapl(&rep->length, n);
-    WriteToClient(client, size, (char *)rep);
-}
diff --git a/Xi/chgptr.h b/Xi/chgptr.h
index aeda822..fb3b5cc 100644
--- a/Xi/chgptr.h
+++ b/Xi/chgptr.h
@@ -53,9 +53,4 @@ void FindInterestedChildren(	/* FIXME: c
 			       int	/* count */
     );
 
-void SRepXChangePointerDevice(ClientPtr /* client */ ,
-			      int /* size */ ,
-			      xChangePointerDeviceReply *	/* rep */
-    );
-
 #endif /* CHGPTR_H */
diff --git a/Xi/extinit.c b/Xi/extinit.c
index c35a964..4548837 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -465,12 +465,6 @@ SReplyIDispatch(ClientPtr client, int le
     else if (rep->RepType == X_GetDeviceMotionEvents)
 	SRepXGetDeviceMotionEvents(client, len,
 				   (xGetDeviceMotionEventsReply *) rep);
-    else if (rep->RepType == X_ChangeKeyboardDevice)
-	SRepXChangeKeyboardDevice(client, len,
-				  (xChangeKeyboardDeviceReply *) rep);
-    else if (rep->RepType == X_ChangePointerDevice)
-	SRepXChangePointerDevice(client, len,
-				 (xChangePointerDeviceReply *) rep);
     else if (rep->RepType == X_GrabDevice)
 	SRepXGrabDevice(client, len, (xGrabDeviceReply *) rep);
     else if (rep->RepType == X_GetDeviceFocus)
diff --git a/Xi/stubs.c b/Xi/stubs.c
index 28ecd8b..e2ed1ce 100644
--- a/Xi/stubs.c
+++ b/Xi/stubs.c
@@ -68,86 +68,6 @@ SOFTWARE.
 
 /***********************************************************************
  *
- * Caller:	ProcXChangeKeyboardDevice
- *
- * This procedure does the implementation-dependent portion of the work
- * needed to change the keyboard device.
- *
- * The X keyboard device has a FocusRec.  If the device that has been 
- * made into the new X keyboard did not have a FocusRec, 
- * ProcXChangeKeyboardDevice will allocate one for it.
- *
- * If you do not want clients to be able to focus the old X keyboard
- * device, call DeleteFocusClassDeviceStruct to free the FocusRec.
- *
- * If you support input devices with keys that you do not want to be 
- * used as the X keyboard, you need to check for them here and return 
- * a BadDevice error.
- *
- * The default implementation is to do nothing (assume you do want
- * clients to be able to focus the old X keyboard).  The commented-out
- * sample code shows what you might do if you don't want the default.
- *
- */
-
-int
-ChangeKeyboardDevice(DeviceIntPtr old_dev, DeviceIntPtr new_dev)
-{
-    /***********************************************************************
-     DeleteFocusClassDeviceStruct(old_dev);	 * defined in xchgptr.c *
-    **********************************************************************/
-    return BadMatch;
-}
-
-/***********************************************************************
- *
- * Caller:	ProcXChangePointerDevice
- *
- * This procedure does the implementation-dependent portion of the work
- * needed to change the pointer device.
- *
- * The X pointer device does not have a FocusRec.  If the device that
- * has been made into the new X pointer had a FocusRec, 
- * ProcXChangePointerDevice will free it.
- *
- * If you want clients to be able to focus the old pointer device that
- * has now become accessible through the input extension, you need to 
- * add a FocusRec to it here.
- *
- * The XChangePointerDevice protocol request also allows the client
- * to choose which axes of the new pointer device are used to move 
- * the X cursor in the X- and Y- directions.  If the axes are different
- * than the default ones, you need to keep track of that here.
- *
- * If you support input devices with valuators that you do not want to be 
- * used as the X pointer, you need to check for them here and return a 
- * BadDevice error.
- *
- * The default implementation is to do nothing (assume you don't want
- * clients to be able to focus the old X pointer).  The commented-out
- * sample code shows what you might do if you don't want the default.
- *
- */
-
-int
-ChangePointerDevice(DeviceIntPtr old_dev,
-		    DeviceIntPtr new_dev, unsigned char x, unsigned char y)
-{
-    /***********************************************************************
-    InitFocusClassDeviceStruct(old_dev);	* allow focusing old ptr*
-
-    x_axis = x;					* keep track of new x-axis*
-    y_axis = y;					* keep track of new y-axis*
-    if (x_axis != 0 || y_axis != 1)
-	axes_changed = TRUE;			* remember axes have changed*
-    else
-	axes_changed = FALSE;
-    *************************************************************************/
-    return BadMatch;
-}
-
-/***********************************************************************
- *
  * Caller:	ProcXCloseDevice
  *
  * Take care of implementation-dependent details of closing a device.
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 915a219..be3368d 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -251,148 +251,12 @@ OpenInputDevice(DeviceIntPtr	dev,
     *status = Success;
 }
 
-
-/***********************************************************************
- *
- * Caller:	ProcXChangeKeyboardDevice
- *
- * This procedure does the implementation-dependent portion of the work
- * needed to change the keyboard device.
- *
- * The X keyboard device has a FocusRec.  If the device that has been 
- * made into the new X keyboard did not have a FocusRec, 
- * ProcXChangeKeyboardDevice will allocate one for it.
- *
- * If you do not want clients to be able to focus the old X keyboard
- * device, call DeleteFocusClassDeviceStruct to free the FocusRec.
- *
- * If you support input devices with keys that you do not want to be 
- * used as the X keyboard, you need to check for them here and return 
- * a BadDevice error.
- *
- * The default implementation is to do nothing (assume you do want
- * clients to be able to focus the old X keyboard).  The commented-out
- * sample code shows what you might do if you don't want the default.
- *
- ***********************************************************************
- */
-
-int
-ChangeKeyboardDevice (DeviceIntPtr old_dev, DeviceIntPtr new_dev)
-{
-  /**********************************************************************
-   * DeleteFocusClassDeviceStruct(old_dev);	 * defined in xchgptr.c *
-   **********************************************************************/
-  return !Success;
-}
-
-
-/***********************************************************************
- *
- * Caller:	ProcXChangePointerDevice
- *
- * This procedure does the implementation-dependent portion of the work
- * needed to change the pointer device.
- *
- * The X pointer device does not have a FocusRec.  If the device that
- * has been made into the new X pointer had a FocusRec, 
- * ProcXChangePointerDevice will free it.
- *
- * If you want clients to be able to focus the old pointer device that
- * has now become accessible through the input extension, you need to 
- * add a FocusRec to it here.
- *
- * The XChangePointerDevice protocol request also allows the client
- * to choose which axes of the new pointer device are used to move 
- * the X cursor in the X- and Y- directions.  If the axes are different
- * than the default ones, you need to keep track of that here.
- *
- * If you support input devices with valuators that you do not want to be 
- * used as the X pointer, you need to check for them here and return a 
- * BadDevice error.
- *
- * The default implementation is to do nothing (assume you don't want
- * clients to be able to focus the old X pointer).  The commented-out
- * sample code shows what you might do if you don't want the default.
- *
- ***********************************************************************
- */
-
-int
-ChangePointerDevice (
-     DeviceIntPtr	old_dev,
-     DeviceIntPtr	new_dev,
-     unsigned char	x,
-     unsigned char	y)
-{
-  /************************************************************************
-    InitFocusClassDeviceStruct(old_dev);	* allow focusing old ptr*
-    
-    x_axis = x;					* keep track of new x-axis*
-    y_axis = y;					* keep track of new y-axis*
-    if (x_axis != 0 || y_axis != 1)
-    axes_changed = TRUE;			* remember axes have changed*
-    else
-    axes_changed = FALSE;
-   *************************************************************************/
-
-    return !Success;
-}
-
-
-/***********************************************************************
- *
- * Caller:	ProcXCloseDevice
- *
- * Take care of implementation-dependent details of closing a device.
- * Some implementations may actually close the device, others may just
- * remove this clients interest in that device.
- *
- * The default implementation is to do nothing (assume all input devices
- * are initialized during X server initialization and kept open).
- *
- ***********************************************************************
- */
-
-void
-CloseInputDevice (DeviceIntPtr d, ClientPtr client)
-{
-}
-
-
-/***********************************************************************
- *
- * Caller:	ProcXListInputDevices
- *
- * This is the implementation-dependent routine to initialize an input 
- * device to the point that information about it can be listed.
- * Some implementations open all input devices when the server is first
- * initialized, and never close them.  Other implementations open only
- * the X pointer and keyboard devices during server initialization,
- * and only open other input devices when some client makes an
- * XOpenDevice request.  If some other process has the device open, the
- * server may not be able to get information about the device to list it.
- *
- * This procedure should be used by implementations that do not initialize
- * all input devices at server startup.  It should do device-dependent
- * initialization for any devices not previously initialized, and call
- * AddInputDevice for each of those devices so that a DeviceIntRec will be 
- * created for them.
- *
- * The default implementation is to do nothing (assume all input devices
- * are initialized during X server initialization and kept open).
- * The commented-out sample code shows what you might do if you don't want 
- * the default.
- *
- ***********************************************************************
- */
-
 void
-AddOtherInputDevices ()
+CloseInputDevice(DeviceIntPtr dev,
+                 ClientPtr client)
 {
 }
 
-
 /****************************************************************************
  *
  * Caller:	ProcXSetDeviceMode
@@ -475,6 +339,11 @@ ChangeDeviceControl (ClientPtr client, D
       return (*local->control_proc)(local, control);
   }
 }
+
+void
+AddOtherInputDevices()
+{
+}
 #endif
 
 int
diff --git a/include/XIstubs.h b/include/XIstubs.h
index 45f6eb1..6797e07 100644
--- a/include/XIstubs.h
+++ b/include/XIstubs.h
@@ -26,18 +26,6 @@ OR IN CONNECTION WITH THE USE OR PERFORM
 #ifndef XI_STUBS_H
 #define XI_STUBS_H 1
 
-int
-ChangeKeyboardDevice (
-	DeviceIntPtr           /* old_dev */,
-	DeviceIntPtr           /* new_dev */);
-
-int
-ChangePointerDevice (
-	DeviceIntPtr           /* old_dev */,
-	DeviceIntPtr           /* new_dev */,
-	unsigned char          /* x */,
-	unsigned char          /* y */);
-
 void
 CloseInputDevice (
 	DeviceIntPtr           /* d */,
diff-tree 68f595ca6c7883e030947b7f95c50e92aa733f2b (from 51a06b3c44509c72279b5cfcf2b52b9a35c461b0)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 29 03:41:34 2006 +0300

    GetTimeInMillis: use correct units for clock_gettime
    Make sure we're treating the nanoseconds as a long, not an int, so we
    don't overflow.

diff --git a/os/utils.c b/os/utils.c
index 7d258a4..c7a8964 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -552,7 +552,7 @@ GetTimeInMillis(void)
 #ifdef MONOTONIC_CLOCK
     struct timespec tp;
     if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
-        return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000);
+        return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L);
 #endif
 
     X_GETTIMEOFDAY(&tv);
diff-tree 51a06b3c44509c72279b5cfcf2b52b9a35c461b0 (from 196c5836f463c28f633bbba847f59acd5935359d)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 29 03:40:57 2006 +0300

    WaitForSomething: only rewind when delta is more than 250ms
    Only rewind time when we're more than (original delta + 250ms) away from
    executing the timer.
    When we're walking the timer list, use a goto to iterate all of them from
    the start again, since timers may drop out of the list.
    Don't bother trying to be smart in TimerSet, we'll pick it up in
    WaitForSomething anyway.

diff --git a/os/WaitFor.c b/os/WaitFor.c
index 896fdf1..6109e34 100644
--- a/os/WaitFor.c
+++ b/os/WaitFor.c
@@ -202,11 +202,12 @@ WaitForSomething(int *pClientsReady)
         {
             now = GetTimeInMillis();
 	    timeout = timers->expires - now;
-            /* time has rewound.  reset the timers. */
-            if (timeout > timers->delta) {
+            if (timeout > 0 && timeout > timers->delta + 250) {
+                /* time has rewound.  reset the timers. */
                 CheckAllTimers(now);
                 timeout = timers->expires - now;
             }
+
             if (timeout < 0)
                 timeout = 0;
 	    waittime.tv_sec = timeout / MILLI_PER_SECOND;
@@ -434,17 +435,18 @@ ANYSET(FdMask *src)
 #endif
 
 /* If time has rewound, re-run every affected timer.
- * TimerForce will change timer->next, but it will _generally_ only
- * promote timers in the list, meaning that we should still be
- * walking every timer. */
+ * Timers might drop out of the list, so we have to restart every time. */
 static void
 CheckAllTimers(CARD32 now)
 {
     OsTimerPtr timer;
 
+start:
     for (timer = timers; timer; timer = timer->next) {
-        if (timer->expires - now > timer->delta)
+        if (timer->expires - now > timer->delta + 250) {
             TimerForce(timer);
+            goto start;
+        }
     }
 }
 
@@ -507,10 +509,8 @@ TimerSet(OsTimerPtr timer, int flags, CA
     }
     for (prev = &timers;
 	 *prev && (int) ((*prev)->expires - millis) <= 0;
-	 prev = &(*prev)->next) {
-        if ((*prev)->expires - now > (*prev)->delta)
-            CheckAllTimers(now);
-    }
+	 prev = &(*prev)->next)
+        ;
     timer->next = *prev;
     *prev = timer;
     return timer;
diff-tree 196c5836f463c28f633bbba847f59acd5935359d (from f9a1e456f8a4eaa1a9c71fd0fe5231140975c22d)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Oct 27 01:27:31 2006 +0300

    CoreKeyboardProc: annotate with FIXME
    Setting an empty keymap by default isn't wildly useful.

diff --git a/dix/devices.c b/dix/devices.c
index 01404db..a554f2f 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -261,8 +261,11 @@ CoreKeyboardProc(DeviceIntPtr pDev, int 
         }
         else
 #endif
-        InitKeyboardDeviceStruct((DevicePtr)pDev, &keySyms, modMap,
-                                 CoreKeyboardBell, CoreKeyboardCtl);
+        {
+            /* FIXME Our keymap here isn't exactly useful. */
+            InitKeyboardDeviceStruct((DevicePtr)pDev, &keySyms, modMap,
+                                     CoreKeyboardBell, CoreKeyboardCtl);
+        }
 
         xfree(keySyms.map);
         xfree(modMap);
diff-tree f9a1e456f8a4eaa1a9c71fd0fe5231140975c22d (from a5be65401769fabcb5001dc63035c69f9e4a2712)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Oct 27 01:25:39 2006 +0300

    CoreKeyboardProc: don't leak keymap and modmap
    SetKeySymsMap does a copy here, so try not to leak them.

diff --git a/dix/devices.c b/dix/devices.c
index a5110ff..01404db 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -263,6 +263,10 @@ CoreKeyboardProc(DeviceIntPtr pDev, int 
 #endif
         InitKeyboardDeviceStruct((DevicePtr)pDev, &keySyms, modMap,
                                  CoreKeyboardBell, CoreKeyboardCtl);
+
+        xfree(keySyms.map);
+        xfree(modMap);
+
         break;
 
     case DEVICE_CLOSE:
diff-tree a5be65401769fabcb5001dc63035c69f9e4a2712 (from 85212eb504f860b054eb0f0a5029fed86cb8d1c0)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Oct 27 01:25:21 2006 +0300

    mieqEnqueue: only compare DEVICE_BITS of deviceid
    Only compare DEVICE_BITS of the two deviceids, so we don't decide that
    a valuator event isn't for us, because (id | MORE_EVENTS) != id.

diff --git a/mi/mieq.c b/mi/mieq.c
index 63cd6e1..be76580 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -117,7 +117,8 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e
             !(lastkbp->type == DeviceMotionNotify ||
               lastkbp->type == DeviceButtonPress ||
               lastkbp->type == DeviceButtonRelease) ||
-            (lastkbp->deviceid != v->deviceid)) {
+            ((lastkbp->deviceid & DEVICE_BITS) !=
+             (v->deviceid & DEVICE_BITS))) {
             ErrorF("mieqEnequeue: out-of-order valuator event; dropping.\n");
             return;
         }
diff-tree 85212eb504f860b054eb0f0a5029fed86cb8d1c0 (from 8c0556e7cb1de8c387ddd886a03a8f8afff1fd0e)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Oct 27 01:23:58 2006 +0300

    getValuatorEvents: make sure we put MORE_EVENTS in the right places
    Make sure we put MORE_EVENTS in with the device id if there are, in fact,
    more valuator events coming.

diff --git a/dix/getevents.c b/dix/getevents.c
index e34058c..b19a73f 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -365,6 +365,9 @@ getValuatorEvents(xEvent *events, Device
         case 1:
             xv->valuator0 = valuators[i];
         }
+
+        if (i + 6 < final_valuator)
+            xv->deviceid |= MORE_EVENTS;
     }
 
     return events;
diff-tree 8c0556e7cb1de8c387ddd886a03a8f8afff1fd0e (from parents)
Merge: cdc8a4b7b2f099b8860a54c5c9f488e6f7c4913a 004d00e6689f452fc9fdf91f5ffc6d6aed697d54
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Oct 26 15:21:22 2006 +0300

    Merge branch 'master' into input-hotplug

diff-tree 004d00e6689f452fc9fdf91f5ffc6d6aed697d54 (from d285833290316cb5dd1e7f1e52c96be3e9cf21cd)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Oct 26 01:10:08 2006 +0300

    GetTimeInMillis: simplify monotonic test
    We don't actually need to get the CPU clock ID, which means we don't need
    the monotonic_usable test.  Since there's now only one branch, the
    compiler will treat that as likely, so we don't need xproto 7.0.9 anymore.
    
    The fallthrough to gettimeofday() is preserved.

diff --git a/configure.ac b/configure.ac
index 0f2ddd5..c0cc003 100644
--- a/configure.ac
+++ b/configure.ac
@@ -515,7 +515,7 @@ XEXT_LIB='$(top_builddir)/Xext/libXext.l
 XEXTXORG_LIB='$(top_builddir)/Xext/libXextbuiltin.la'
 
 dnl Core modules for most extensions, et al.
-REQUIRED_MODULES="randrproto renderproto [fixesproto >= 4.0] damageproto xcmiscproto xextproto [xproto >= 7.0.9] xtrans xf86miscproto xf86vidmodeproto xf86bigfontproto [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto inputproto xf86dgaproto [kbproto >= 1.0.3]"
+REQUIRED_MODULES="randrproto renderproto [fixesproto >= 4.0] damageproto xcmiscproto xextproto xproto xtrans xf86miscproto xf86vidmodeproto xf86bigfontproto [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto inputproto xf86dgaproto [kbproto >= 1.0.3]"
 REQUIRED_LIBS="xfont xau fontenc"
 
 AM_CONDITIONAL(XV, [test "x$XV" = xyes])
diff --git a/os/utils.c b/os/utils.c
index 379291c..7d258a4 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -268,8 +268,6 @@ int auditTrailLevel = 1;
 
 _X_EXPORT Bool Must_have_memory = FALSE;
 
-static int monotonic_usable = -1;
-
 #ifdef AIXV3
 int SyncOn  = 0;
 extern int SelectWaitTime;
@@ -550,22 +548,11 @@ _X_EXPORT CARD32
 GetTimeInMillis(void)
 {
     struct timeval tv;
+
 #ifdef MONOTONIC_CLOCK
     struct timespec tp;
-    int spare = 0;
-
-    if (_X_UNLIKELY(monotonic_usable == -1)) {
-        if (clock_gettime(0, &tp) == 0 &&
-            clock_getcpuclockid(0, &spare) == 0)
-            monotonic_usable = 1;
-        else
-            monotonic_usable = 0;
-    }
-
-    if (_X_LIKELY(monotonic_usable == 1)) {
-        if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
-            return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000);
-    }
+    if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
+        return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000);
 #endif
 
     X_GETTIMEOFDAY(&tv);



More information about the xorg-commit mailing list