summaryrefslogtreecommitdiff
path: root/dix/devices.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2008-07-13 18:40:53 +0930
committerPeter Hutterer <peter.hutterer@who-t.net>2008-07-13 20:54:33 +0930
commit5bcc45e07e8726a5442567472dd29cfb5c901f2d (patch)
tree231436a1967b3fbcf0e9a929b67204f68378afb5 /dix/devices.c
parentc9eb0e870c87d291311491452adf7f91a911e24b (diff)
Xi: expose Enable/DisableDevice through XI_PROP_ENABLED property.
Diffstat (limited to 'dix/devices.c')
-rw-r--r--dix/devices.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/dix/devices.c b/dix/devices.c
index 0d96dff4f..a7325a60f 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -57,6 +57,7 @@ SOFTWARE.
#define NEED_EVENTS
#define NEED_REPLIES
#include <X11/Xproto.h>
+#include <X11/Xatom.h>
#include "windowstr.h"
#include "inputstr.h"
#include "scrnintstr.h"
@@ -94,6 +95,30 @@ DevPrivateKey CoreDevicePrivateKey = &CoreDevicePrivateKey;
/* Used to sture classes currently not in use by an MD */
DevPrivateKey UnusedClassesPrivateKey = &UnusedClassesPrivateKey;
+
+/**
+ * DIX property handler.
+ */
+static Bool
+DeviceSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop)
+{
+ if (property == XIGetKnownProperty(XI_PROP_ENABLED))
+ {
+ if (prop->format != 8 || prop->type != XA_INTEGER || prop->size != 1)
+ return FALSE;
+
+ if ((*((CARD8*)prop->data)) && !dev->enabled)
+ EnableDevice(dev);
+ else if (!(*((CARD8*)prop->data)) && dev->enabled)
+ DisableDevice(dev);
+ return TRUE;
+ }
+
+ return TRUE;
+}
+
+
+
/**
* Create a new input device and init it to sane values. The device is added
* to the server's off_devices list.
@@ -195,6 +220,11 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
*prev = dev;
dev->next = NULL;
+ XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_ENABLED),
+ XA_INTEGER, 8, PropModeReplace, 1, &dev->enabled,
+ FALSE, FALSE, FALSE);
+ XIRegisterPropertyHandler(dev, DeviceSetProperty, NULL);
+
return dev;
}
@@ -266,6 +296,7 @@ EnableDevice(DeviceIntPtr dev)
mieqResizeEvents(evsize);
OsReleaseSignals();
+
if ((*prev != dev) || !dev->inited ||
((ret = (*dev->deviceProc)(dev, DEVICE_ON)) != Success)) {
ErrorF("[dix] couldn't enable device %d\n", dev->id);
@@ -279,6 +310,10 @@ EnableDevice(DeviceIntPtr dev)
*prev = dev;
dev->next = NULL;
+ XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_ENABLED),
+ XA_INTEGER, 8, PropModeReplace, 1, &dev->enabled,
+ TRUE, FALSE, FALSE);
+
ev.type = DevicePresenceNotify;
ev.time = currentTime.milliseconds;
ev.devchange = DeviceEnabled;
@@ -343,6 +378,10 @@ DisableDevice(DeviceIntPtr dev)
dev->next = inputInfo.off_devices;
inputInfo.off_devices = dev;
+ XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_ENABLED),
+ XA_INTEGER, 8, PropModeReplace, 1, &dev->enabled,
+ TRUE, FALSE, FALSE);
+
ev.type = DevicePresenceNotify;
ev.time = currentTime.milliseconds;
ev.devchange = DeviceDisabled;