[PATCH mouse 3/3] Adjust to new Input ABI 12.

Peter Hutterer peter.hutterer at who-t.net
Tue Nov 16 16:10:05 PST 2010


New PreInit prototype and a couple of other minor changes.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/bsd_mouse.c  |    4 +-
 src/hurd_mouse.c |    2 +-
 src/mouse.c      |   85 +++++++++++++++++++++++++++++++++++++++--------------
 src/mouse.h      |    7 ++++
 src/sun_mouse.c  |    2 +-
 5 files changed, 73 insertions(+), 27 deletions(-)

diff --git a/src/bsd_mouse.c b/src/bsd_mouse.c
index 94d4382..8a57226 100644
--- a/src/bsd_mouse.c
+++ b/src/bsd_mouse.c
@@ -458,7 +458,7 @@ wsconsPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
     xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol);
 
     /* Collect the options, and process the common options. */
-    xf86CollectInputOptions(pInfo, NULL, NULL);
+    COLLECT_INPUT_OPTIONS(pInfo, NULL);
     xf86ProcessCommonOptions(pInfo, pInfo->options);
 
     /* Check if the device can be opened. */
@@ -653,7 +653,7 @@ usbPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
     xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol);
 
     /* Collect the options, and process the common options. */
-    xf86CollectInputOptions(pInfo, NULL, NULL);
+    COLLECT_INPUT_OPTIONS(pInfo, NULL);
     xf86ProcessCommonOptions(pInfo, pInfo->options);
 
     /* Check if the device can be opened. */
diff --git a/src/hurd_mouse.c b/src/hurd_mouse.c
index e0ed126..e5c7186 100644
--- a/src/hurd_mouse.c
+++ b/src/hurd_mouse.c
@@ -144,7 +144,7 @@ OsMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags)
     xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol);
 
     /* Collect the options, and process the common options. */
-    xf86CollectInputOptions(pInfo, NULL, NULL);
+    COLLECT_INPUT_OPTIONS(pInfo, NULL);
     xf86ProcessCommonOptions(pInfo, pInfo->options);
 
     /* Check if the device can be opened. */
diff --git a/src/mouse.c b/src/mouse.c
index c7103ff..21acf7b 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -112,7 +112,11 @@ typedef struct _DragLockRec {
 } DragLockRec, *DragLockPtr;
 
 
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
 static InputInfoPtr MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags);
+#else
+static int MousePreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags);
+#endif
 
 static int MouseProc(DeviceIntPtr device, int what);
 static void MouseCtrl(DeviceIntPtr device, PtrCtrl *ctrl);
@@ -842,10 +846,48 @@ MousePickProtocol(InputInfoPtr pInfo, const char* device,
     return protocol;
 }
 
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
+static int NewMousePreInit(InputDriverPtr drv, InputInfoPtr pInfo,
+                           int flags);
+
 static InputInfoPtr
 MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
 {
     InputInfoPtr pInfo;
+
+    if (!(pInfo = xf86AllocateInput(drv, 0)))
+	return NULL;
+
+    pInfo->name = dev->identifier;
+    pInfo->flags = XI86_SEND_DRAG_EVENTS;
+    pInfo->conf_idev = dev;
+    pInfo->close_proc = NULL;
+    pInfo->private_flags = 0;
+    pInfo->always_core_feedback = NULL;
+
+    if (NewMousePreInit(drv, pInfo, flags) == Success)
+    {
+        /* Check if SendDragEvents has been disabled. */
+        if (!xf86SetBoolOption(dev->commonOptions, "SendDragEvents", TRUE))
+            pInfo->flags &= ~XI86_SEND_DRAG_EVENTS;
+
+        pInfo->flags |= XI86_CONFIGURED;
+
+        return pInfo;
+    }
+
+    xf86DeleteInput(pInfo, 0);
+
+    return NULL;
+}
+
+static InputInfoPtr
+NewMousePreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
+#else
+static int
+MousePreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
+#endif
+{
     MouseDevPtr pMse;
     mousePrivPtr mPriv;
     MessageType protocolFrom = X_DEFAULT;
@@ -854,44 +896,34 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
     MouseProtocolID protocolID;
     MouseProtocolPtr pProto;
     int i;
-    
-    if (!InitProtocols())
-	return NULL;
+    int rc = Success;
 
-    if (!(pInfo = xf86AllocateInput(drv, 0)))
-	return NULL;
+    if (!InitProtocols())
+	return BadAlloc;
 
     /* Initialise the InputInfoRec. */
-    pInfo->name = dev->identifier;
     pInfo->type_name = XI_MOUSE;
-    pInfo->flags = XI86_SEND_DRAG_EVENTS;
     pInfo->device_control = MouseProc;
     pInfo->read_input = MouseReadInput;
     pInfo->control_proc = NULL;
-    pInfo->close_proc = NULL;
     pInfo->switch_mode = NULL;
     pInfo->fd = -1;
     pInfo->dev = NULL;
-    pInfo->private_flags = 0;
-    pInfo->always_core_feedback = NULL;
-    pInfo->conf_idev = dev;
 
     /* Allocate the MouseDevRec and initialise it. */
     if (!(pMse = calloc(sizeof(MouseDevRec), 1)))
+    {
+	rc = BadAlloc;
 	goto out;
+    }
 
     pInfo->private = pMse;
     pMse->Ctrl = MouseCtrl;
     pMse->PostEvent = MousePostEvent;
     pMse->CommonOptions = MouseCommonOptions;
 
-    /* Check if SendDragEvents has been disabled. */
-    if (!xf86SetBoolOption(dev->commonOptions, "SendDragEvents", TRUE)) {
-	pInfo->flags &= ~XI86_SEND_DRAG_EVENTS;
-    }
-
     /* Find the protocol type. */
-    protocol = xf86SetStrOption(dev->commonOptions, "Protocol", NULL);
+    protocol = xf86SetStrOption(pInfo->options, "Protocol", NULL);
     if (protocol) {
 	protocolFrom = X_CONFIG;
     } else if (osInfo->DefaultProtocol) {
@@ -900,10 +932,11 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
     }
     if (!protocol) {
 	xf86Msg(X_ERROR, "%s: No Protocol specified\n", pInfo->name);
+	rc = BadValue;
 	goto out;
     }
 
-    device = xf86SetStrOption(dev->commonOptions, "Device", NULL);
+    device = xf86SetStrOption(pInfo->options, "Device", NULL);
 
     /* Default Mapping: 1 2 3 8 9 10 11 ... */
     for (i = 0; i < MSE_MAXBUTTONS; i++)
@@ -916,14 +949,17 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
 
     xf86Msg(protocolFrom, "%s: Protocol: \"%s\"\n", pInfo->name, protocol);
     if (!(pProto = GetProtocol(protocolID)))
+    {
+	rc = BadValue;
 	goto out;
+    }
 
     pMse->protocolID = protocolID;
     pMse->oldProtocolID = protocolID;  /* hack */
 
     pMse->autoProbe = FALSE;
     /* Collect the options, and process the common options. */
-    xf86CollectInputOptions(pInfo, pProto->defaults, NULL);
+    COLLECT_INPUT_OPTIONS(pInfo, pProto->defaults);
     xf86ProcessCommonOptions(pInfo, pInfo->options);
 
     /* Check if the device can be opened. */
@@ -937,6 +973,7 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
 		free(pMse->mousePriv);
 	    free(pMse);
 	    pInfo->private = NULL;
+	    rc = BadValue;
 	    goto out;
 	}
     }
@@ -944,7 +981,11 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
     pInfo->fd = -1;
 
     if (!(mPriv = (pointer) calloc(sizeof(mousePrivRec), 1)))
+    {
+	rc = BadAlloc;
 	goto out;
+    }
+
     pMse->mousePriv = mPriv;
     pMse->CommonOptions(pInfo);
     pMse->checkMovements = checkForErraticMovements;
@@ -954,11 +995,9 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
     
     MouseHWOptions(pInfo);
     MouseSerialOptions(pInfo);
-    
-    pInfo->flags |= XI86_CONFIGURED;
 
 out:
-    return pInfo;
+    return rc;
 }
 
 
@@ -2519,7 +2558,7 @@ initMouseHW(InputInfoPtr pInfo)
 	    usleep(100000);
 	    /* Set the parameters up for the MM series protocol. */
 	    options = pInfo->options;
-	    xf86CollectInputOptions(pInfo, mmDefaults, NULL);
+	    COLLECT_INPUT_OPTIONS(pInfo, mmDefaults);
 	    xf86SetSerial(pInfo->fd, pInfo->options);
 	    pInfo->options = options;
 
diff --git a/src/mouse.h b/src/mouse.h
index 8c02ba1..9f5b47e 100644
--- a/src/mouse.h
+++ b/src/mouse.h
@@ -32,6 +32,13 @@
 
 #include "xf86Xinput.h"
 
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
+#define COLLECT_INPUT_OPTIONS(pInfo, options) xf86CollectInputOptions((pInfo), (options), NULL)
+#else
+#define COLLECT_INPUT_OPTIONS(pInfo, options) xf86CollectInputOptions((pInfo), (options))
+#endif
+
+
 /* Mouse interface classes */
 #define MSE_NONE	0x00
 #define MSE_SERIAL	0x01		/* serial port */
diff --git a/src/sun_mouse.c b/src/sun_mouse.c
index 95b45bc..2799947 100644
--- a/src/sun_mouse.c
+++ b/src/sun_mouse.c
@@ -216,7 +216,7 @@ vuidPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
     xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol);
 
     /* Collect the options, and process the common options. */
-    xf86CollectInputOptions(pInfo, NULL, NULL);
+    COLLECT_INPUT_OPTIONS(pInfo, NULL);
     xf86ProcessCommonOptions(pInfo, pInfo->options);
 
     pVuidMse->buffer = (unsigned char *)&pVuidMse->event;
-- 
1.7.3.2



More information about the xorg-devel mailing list