[PATCH:xf86-input-mouse 2/4] Set XI_PROP_DEVICE_NODE property to string from "Device" option

Alan Coopersmith alan.coopersmith at oracle.com
Fri Apr 27 17:43:50 PDT 2012


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 man/mousedrv.man |    3 ++-
 src/mouse.c      |   23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/man/mousedrv.man b/man/mousedrv.man
index 23528f6..c9c2744 100644
--- a/man/mousedrv.man
+++ b/man/mousedrv.man
@@ -113,8 +113,9 @@ protocol setting is platform-specific.
 .BI "Option \*qDevice\*q \*q" string \*q
 Specifies the device through which the mouse can be accessed.  A common
 setting is "/dev/mouse", which is often a symbolic link to the real
-device.  This option is mandatory, and there is no default setting. The server
+device.  This option is mandatory, and there is no default setting. The driver
 may however attempt to probe some default devices if this option is missing.
+Property: "Device Node" (read-only).
 .TP 7
 .BI "Option \*qButtons\*q \*q" integer \*q
 Specifies the number of mouse buttons.  In cases where the number of buttons
diff --git a/src/mouse.c b/src/mouse.c
index f4c7c82..7613403 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -62,6 +62,9 @@
 
 #include "xf86Xinput.h"
 #include "xf86_OSproc.h"
+#include "exevents.h"
+#include <X11/Xatom.h>
+#include "xserver-properties.h"
 
 #include "compiler.h"
 
@@ -118,6 +121,7 @@ static InputInfoPtr MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags);
 static int MousePreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags);
 #endif
 
+static void MouseInitProperties(DeviceIntPtr device);
 static int MouseProc(DeviceIntPtr device, int what);
 static void MouseCtrl(DeviceIntPtr device, PtrCtrl *ctrl);
 static void MousePostEvent(InputInfoPtr pInfo, int buttons,
@@ -1019,6 +1023,24 @@ out:
     return rc;
 }
 
+static void MouseInitProperties(DeviceIntPtr device)
+{
+    InputInfoPtr pInfo = device->public.devicePrivate;
+
+#ifdef XI_PROP_DEVICE_NODE
+    const char *device_node =
+        xf86CheckStrOption(pInfo->options, "Device", NULL);
+
+    if (device_node)
+    {
+        Atom prop_device = MakeAtom(XI_PROP_DEVICE_NODE,
+                                    strlen(XI_PROP_DEVICE_NODE), TRUE);
+        XIChangeDeviceProperty(device, prop_device, XA_STRING, 8,
+                               PropModeReplace,
+                               strlen(device_node), device_node, FALSE);
+    }
+#endif /* XI_PROP_DEVICE_NODE */
+}
 
 static void
 MouseReadInput(InputInfoPtr pInfo)
@@ -1616,6 +1638,7 @@ MouseProc(DeviceIntPtr device, int what)
 	ErrorF("assigning %p atom=%d name=%s\n", device, pInfo->atom,
 		pInfo->name);
 #endif
+	MouseInitProperties(device);
 	break;
 
     case DEVICE_ON:
-- 
1.7.9.2



More information about the xorg-devel mailing list