summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2006-10-20 00:28:40 +0300
committerDaniel Stone <daniels@endtroducing.fooishbar.org>2006-10-20 00:43:11 +0300
commita8d3dad9d9f2b9053843e655abe463a68ba8dcb7 (patch)
treeecdd1935f9aa2b76a65504c2fb95af6e19ce5016
parentb0780312d80ea4af0136227f90fdd7ada3db71c5 (diff)
xi: add DEVICE_ENABLE control
Add DEVICE_ENABLE control, which allows runtime enabling and disabling of specific devices.
-rw-r--r--Xi/chgdctl.c23
-rw-r--r--Xi/getdctl.c24
-rw-r--r--Xi/getdctl.h5
-rw-r--r--dix/devices.c4
-rw-r--r--include/inputstr.h1
5 files changed, 57 insertions, 0 deletions
diff --git a/Xi/chgdctl.c b/Xi/chgdctl.c
index ebe086548..4b9c2b6ed 100644
--- a/Xi/chgdctl.c
+++ b/Xi/chgdctl.c
@@ -106,6 +106,7 @@ ProcXChangeDeviceControl(ClientPtr client)
CARD32 *resolution;
xDeviceTSCtl *ts;
xDeviceCoreCtl *c;
+ xDeviceEnableCtl *e;
REQUEST(xChangeDeviceControlReq);
REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
@@ -218,6 +219,28 @@ ProcXChangeDeviceControl(ClientPtr client)
}
break;
+ case DEVICE_ENABLE:
+ e = (xDeviceEnableCtl *)&stuff[1];
+
+ status = ChangeDeviceControl(client, dev, (xDeviceCtl *) e);
+
+ if (status == Success) {
+ if (e->enable)
+ EnableDevice(dev);
+ else
+ DisableDevice(dev);
+ } else if (status == DeviceBusy) {
+ rep.status = DeviceBusy;
+ WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
+ &rep);
+ return Success;
+ } else {
+ SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
+ BadMatch);
+ return Success;
+ }
+
+ break;
default:
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, BadValue);
return Success;
diff --git a/Xi/getdctl.c b/Xi/getdctl.c
index 66342b340..2ae6ef302 100644
--- a/Xi/getdctl.c
+++ b/Xi/getdctl.c
@@ -136,6 +136,9 @@ ProcXGetDeviceControl(ClientPtr client)
case DEVICE_CORE:
total_length = sizeof(xDeviceCoreCtl);
break;
+ case DEVICE_ENABLE:
+ total_length = sizeof(xDeviceEnableCtl);
+ break;
default:
SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadValue);
return Success;
@@ -157,6 +160,10 @@ ProcXGetDeviceControl(ClientPtr client)
break;
case DEVICE_CORE:
CopySwapDeviceCore(client, dev, buf);
+ break;
+ case DEVICE_ENABLE:
+ CopySwapDeviceEnable(client, dev, buf);
+ break;
default:
break;
}
@@ -239,6 +246,7 @@ void CopySwapDeviceCore (ClientPtr client, DeviceIntPtr dev, char *buf)
c->control = DEVICE_CORE;
c->length = sizeof(c);
c->status = dev->coreEvents;
+ c->iscore = (dev == inputInfo.keyboard || dev == inputInfo.pointer);
if (client->swapped) {
swaps(&c->control, n);
@@ -247,6 +255,22 @@ void CopySwapDeviceCore (ClientPtr client, DeviceIntPtr dev, char *buf)
}
}
+void CopySwapDeviceEnable (ClientPtr client, DeviceIntPtr dev, char *buf)
+{
+ register char n;
+ xDeviceEnableState *e = (xDeviceEnableState *) buf;
+
+ e->control = DEVICE_ENABLE;
+ e->length = sizeof(e);
+ e->enable = dev->enabled;
+
+ if (client->swapped) {
+ swaps(&e->control, n);
+ swaps(&e->length, n);
+ swaps(&e->enable, n);
+ }
+}
+
/***********************************************************************
*
diff --git a/Xi/getdctl.h b/Xi/getdctl.h
index 1417d1b38..1331a327c 100644
--- a/Xi/getdctl.h
+++ b/Xi/getdctl.h
@@ -52,6 +52,11 @@ void CopySwapDeviceCore(ClientPtr /* client */ ,
char * /* buf */
);
+void CopySwapDeviceEnable(ClientPtr /* client */ ,
+ DeviceIntPtr /* dev */ ,
+ char * /* buf */
+ );
+
void SRepXGetDeviceControl(ClientPtr /* client */ ,
int /* size */ ,
xGetDeviceControlReply * /* rep */
diff --git a/dix/devices.c b/dix/devices.c
index 0121eea97..7b4be0e36 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -130,6 +130,8 @@ AddInputDevice(DeviceProc deviceProc, Bool autoStart)
dev->devPrivates = NULL;
dev->unwrapProc = NULL;
dev->coreEvents = TRUE;
+ dev->inited = FALSE;
+ dev->enabled = FALSE;
for (prev = &inputInfo.off_devices; *prev; prev = &(*prev)->next)
;
@@ -154,6 +156,7 @@ EnableDevice(register DeviceIntPtr dev)
ErrorF("couldn't enable device %d\n", dev->id);
return FALSE;
}
+ dev->enabled = TRUE;
*prev = dev->next;
for (prev = &inputInfo.devices; *prev; prev = &(*prev)->next)
@@ -176,6 +179,7 @@ DisableDevice(register DeviceIntPtr dev)
if (*prev != dev)
return FALSE;
(void)(*dev->deviceProc)(dev, DEVICE_OFF);
+ dev->enabled = FALSE;
*prev = dev->next;
dev->next = inputInfo.off_devices;
inputInfo.off_devices = dev;
diff --git a/include/inputstr.h b/include/inputstr.h
index e12b64195..64763213a 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -265,6 +265,7 @@ typedef struct _DeviceIntRec {
used to initialize, turn on, or
turn off the device */
Bool inited; /* TRUE if INIT returns Success */
+ Bool enabled; /* TRUE if ON returns Success */
Bool coreEvents; /* TRUE if device also sends core */
GrabPtr grab; /* the grabber - used by DIX */
struct {