summaryrefslogtreecommitdiff
path: root/Xi
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 /Xi
parentb0780312d80ea4af0136227f90fdd7ada3db71c5 (diff)
xi: add DEVICE_ENABLE control
Add DEVICE_ENABLE control, which allows runtime enabling and disabling of specific devices.
Diffstat (limited to 'Xi')
-rw-r--r--Xi/chgdctl.c23
-rw-r--r--Xi/getdctl.c24
-rw-r--r--Xi/getdctl.h5
3 files changed, 52 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 */