aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/Xi/listdev.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-09-06 18:48:27 +0000
committermarha <marha@users.sourceforge.net>2009-09-06 18:48:27 +0000
commita915739887477b28d924ecc8417ee107d125bd6c (patch)
treec02f315476b61892d1fd89182e18943dce8d6277 /xorg-server/Xi/listdev.c
parent6f25a23db1df27e992c34f6fd4c82e83c44fc2e2 (diff)
downloadvcxsrv-a915739887477b28d924ecc8417ee107d125bd6c.tar.gz
vcxsrv-a915739887477b28d924ecc8417ee107d125bd6c.tar.bz2
vcxsrv-a915739887477b28d924ecc8417ee107d125bd6c.zip
Switched to xorg-server-1.6.99.900.tar.gz
Diffstat (limited to 'xorg-server/Xi/listdev.c')
-rw-r--r--xorg-server/Xi/listdev.c121
1 files changed, 77 insertions, 44 deletions
diff --git a/xorg-server/Xi/listdev.c b/xorg-server/Xi/listdev.c
index 56ba2f6eb..98ef7aa43 100644
--- a/xorg-server/Xi/listdev.c
+++ b/xorg-server/Xi/listdev.c
@@ -50,8 +50,6 @@ SOFTWARE.
*
*/
-#define NEED_EVENTS
-#define NEED_REPLIES
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
@@ -63,9 +61,10 @@ SOFTWARE.
#include <X11/extensions/XIproto.h>
#include "XIstubs.h"
#include "extnsionst.h"
-#include "exglobals.h" /* FIXME */
#include "exevents.h"
#include "xace.h"
+#include "xkbsrv.h"
+#include "xkbstr.h"
#include "listdev.h"
@@ -93,7 +92,7 @@ SProcXListInputDevices(ClientPtr client)
*
*/
-void
+static void
SizeDeviceInfo(DeviceIntPtr d, int *namesize, int *size)
{
int chunks;
@@ -175,11 +174,11 @@ CopySwapDevice(ClientPtr client, DeviceIntPtr d, int num_classes,
dev = (xDeviceInfoPtr) * buf;
dev->id = d->id;
- dev->type = d->type;
+ dev->type = d->xinput_type;
dev->num_classes = num_classes;
- if (d->isMaster && IsKeyboardDevice(d))
+ if (IsMaster(d) && IsKeyboardDevice(d))
dev->use = IsXKeyboard;
- else if (d->isMaster && IsPointerDevice(d))
+ else if (IsMaster(d) && IsPointerDevice(d))
dev->use = IsXPointer;
else if (d->key && d->kbdfeed)
dev->use = IsXExtensionKeyboard;
@@ -209,8 +208,8 @@ CopySwapKeyClass(ClientPtr client, KeyClassPtr k, char **buf)
k2 = (xKeyInfoPtr) * buf;
k2->class = KeyClass;
k2->length = sizeof(xKeyInfo);
- k2->min_keycode = k->curKeySyms.minKeyCode;
- k2->max_keycode = k->curKeySyms.maxKeyCode;
+ k2->min_keycode = k->xkbInfo->desc->min_key_code;
+ k2->max_keycode = k->xkbInfo->desc->max_key_code;
k2->num_keys = k2->max_keycode - k2->min_keycode + 1;
if (client && client->swapped) {
swaps(&k2->num_keys, n);
@@ -273,6 +272,24 @@ CopySwapValuatorClass(ClientPtr client, ValuatorClassPtr v, char **buf)
return (i);
}
+static void
+CopySwapClasses(ClientPtr client, DeviceIntPtr dev, CARD8 *num_classes,
+ char** classbuf)
+{
+ if (dev->key != NULL) {
+ CopySwapKeyClass(client, dev->key, classbuf);
+ (*num_classes)++;
+ }
+ if (dev->button != NULL) {
+ CopySwapButtonClass(client, dev->button, classbuf);
+ (*num_classes)++;
+ }
+ if (dev->valuator != NULL) {
+ (*num_classes) +=
+ CopySwapValuatorClass(client, dev->valuator, classbuf);
+ }
+}
+
/***********************************************************************
*
* This procedure lists information to be returned for an input device.
@@ -288,24 +305,26 @@ ListDeviceInfo(ClientPtr client, DeviceIntPtr d, xDeviceInfoPtr dev,
CopySwapClasses(client, d, &dev->num_classes, classbuf);
}
-void
-CopySwapClasses(ClientPtr client, DeviceIntPtr dev, CARD8 *num_classes,
- char** classbuf)
+/***********************************************************************
+ *
+ * This procedure checks if a device should be left off the list.
+ *
+ */
+
+static Bool
+ShouldSkipDevice(ClientPtr client, DeviceIntPtr d)
{
- if (dev->key != NULL) {
- CopySwapKeyClass(client, dev->key, classbuf);
- (*num_classes)++;
- }
- if (dev->button != NULL) {
- CopySwapButtonClass(client, dev->button, classbuf);
- (*num_classes)++;
- }
- if (dev->valuator != NULL) {
- (*num_classes) +=
- CopySwapValuatorClass(client, dev->valuator, classbuf);
+ /* don't send master devices other than VCP/VCK */
+ if (!IsMaster(d) || d == inputInfo.pointer || d == inputInfo.keyboard)
+ {
+ int rc = XaceHook(XACE_DEVICE_ACCESS, client, d, DixGetAttrAccess);
+ if (rc == Success)
+ return FALSE;
}
+ return TRUE;
}
+
/***********************************************************************
*
* This procedure lists the input devices available to the server.
@@ -320,66 +339,80 @@ int
ProcXListInputDevices(ClientPtr client)
{
xListInputDevicesReply rep;
- XIClientPtr pXIClient;
int numdevs = 0;
int namesize = 1; /* need 1 extra byte for strcpy */
- int rc, size = 0;
+ int i = 0, size = 0;
int total_length;
- char *devbuf;
- char *classbuf;
- char *namebuf;
- char *savbuf;
+ char *devbuf, *classbuf, *namebuf, *savbuf;
+ Bool *skip;
xDeviceInfo *dev;
DeviceIntPtr d;
REQUEST_SIZE_MATCH(xListInputDevicesReq);
+ memset(&rep, 0, sizeof(xListInputDevicesReply));
rep.repType = X_Reply;
rep.RepType = X_ListInputDevices;
rep.length = 0;
rep.sequenceNumber = client->sequence;
- pXIClient = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey);
AddOtherInputDevices();
- for (d = inputInfo.devices; d; d = d->next) {
- rc = XaceHook(XACE_DEVICE_ACCESS, client, d, DixGetAttrAccess);
- if (rc != Success)
- return rc;
+ /* allocate space for saving skip value */
+ skip = xcalloc(sizeof(Bool), inputInfo.numDevices);
+ if (!skip)
+ return BadAlloc;
+
+ /* figure out which devices to skip */
+ numdevs = 0;
+ for (d = inputInfo.devices; d; d = d->next, i++) {
+ skip[i] = ShouldSkipDevice(client, d);
+ if (skip[i])
+ continue;
+
SizeDeviceInfo(d, &namesize, &size);
numdevs++;
}
- for (d = inputInfo.off_devices; d; d = d->next) {
- rc = XaceHook(XACE_DEVICE_ACCESS, client, d, DixGetAttrAccess);
- if (rc != Success)
- return rc;
+ for (d = inputInfo.off_devices; d; d = d->next, i++) {
+ skip[i] = ShouldSkipDevice(client, d);
+ if (skip[i])
+ continue;
+
SizeDeviceInfo(d, &namesize, &size);
numdevs++;
}
+ /* allocate space for reply */
total_length = numdevs * sizeof(xDeviceInfo) + size + namesize;
- devbuf = (char *)xalloc(total_length);
+ devbuf = (char *)xcalloc(1, total_length);
classbuf = devbuf + (numdevs * sizeof(xDeviceInfo));
namebuf = classbuf + size;
savbuf = devbuf;
+ /* fill in and send reply */
+ i = 0;
dev = (xDeviceInfoPtr) devbuf;
- for (d = inputInfo.devices; d; d = d->next)
- {
+ for (d = inputInfo.devices; d; d = d->next, i++) {
+ if (skip[i])
+ continue;
+
ListDeviceInfo(client, d, dev++, &devbuf, &classbuf, &namebuf);
}
- for (d = inputInfo.off_devices; d; d = d->next)
- {
+ for (d = inputInfo.off_devices; d; d = d->next, i++) {
+ if (skip[i])
+ continue;
+
ListDeviceInfo(client, d, dev++, &devbuf, &classbuf, &namebuf);
}
rep.ndevices = numdevs;
- rep.length = (total_length + 3) >> 2;
+ rep.length = bytes_to_int32(total_length);
WriteReplyToClient(client, sizeof(xListInputDevicesReply), &rep);
WriteToClient(client, total_length, savbuf);
xfree(savbuf);
+ xfree(skip);
return Success;
}