summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/X11/extensions/XInput2.h23
-rw-r--r--src/Makefile.am2
-rw-r--r--src/XISelEv.c (renamed from src/XiSelEv.c)48
3 files changed, 45 insertions, 28 deletions
diff --git a/include/X11/extensions/XInput2.h b/include/X11/extensions/XInput2.h
index a31b1b7..2c2b437 100644
--- a/include/X11/extensions/XInput2.h
+++ b/include/X11/extensions/XInput2.h
@@ -68,6 +68,13 @@ typedef union {
XIDetachSlaveInfo detach;
} XIAnyHierarchyChangeInfo;
+typedef struct
+{
+ int deviceid;
+ int mask_len;
+ unsigned char* mask;
+} XIDeviceEventMask;
+
_XFUNCPROTOBEGIN
extern Bool XIQueryDevicePointer(
@@ -127,21 +134,11 @@ extern Bool XIGetClientPointer(
int* /* deviceid */
);
-typedef CARD16 XIEventType;
-
-typedef struct
-{
- int deviceid;
- int num_types;
- XIEventType *types;
-} XIDeviceEventMask;
-
-extern int
-XISelectEvent(
+extern int XISelectEvent(
Display* /* dpy */,
Window /* win */,
- XIDeviceEventMask** /* masks*/,
- int /* nmasks */
+ XIDeviceEventMask* /* masks*/,
+ int /* nmasks */
);
_XFUNCPROTOEND
diff --git a/src/Makefile.am b/src/Makefile.am
index 7279922..93907fc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -51,7 +51,7 @@ libXi_la_SOURCES = \
XUngrDvK.c \
XWarpDvPtr.c \
XExtInt.c \
- XiSelEv.c \
+ XISelEv.c \
XIint.h
libXi_la_LIBADD = $(XI_LIBS)
diff --git a/src/XiSelEv.c b/src/XISelEv.c
index 0cd3ca9..182d1e6 100644
--- a/src/XiSelEv.c
+++ b/src/XISelEv.c
@@ -1,6 +1,6 @@
/************************************************************
-Copyright 2007 Peter Hutterer <peter@cs.unisa.edu.au>
+Copyright 2009 Red Hat, Inc.
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
@@ -26,42 +26,62 @@ in this Software without prior written authorization from the author.
/***********************************************************************
*
- * XiSelectEvent - Select an event using the GE extension.
+ * XISelectEvent - Select for XI2 events.
*
*/
+#include <stdint.h>
#include <X11/Xlibint.h>
#include <X11/extensions/XI.h>
-#include <X11/extensions/XIproto.h>
-#include <X11/extensions/XInput.h>
+#include <X11/extensions/XI2proto.h>
+#include <X11/extensions/XInput2.h>
#include <X11/extensions/extutil.h>
#include <X11/extensions/ge.h>
#include <X11/extensions/geproto.h>
#include "XIint.h"
int
-XiSelectEvent(Display* dpy, Window win, XDevice* dev, Mask mask)
+XISelectEvent(Display* dpy, Window win, XIDeviceEventMask* masks, int num_masks)
{
- xXiSelectEventReq* req;
+ XIDeviceEventMask *current;
+ xXISelectEventsReq *req;
+ xXIDeviceEventMask mask;
+ int i;
+ int len = 0;
XExtDisplayInfo *info = XInput_find_display(dpy);
-
LockDisplay(dpy);
if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1)
return (NoSuchExtension);
+ GetReq(XISelectEvents, req);
- GetReq(XiSelectEvent, req);
req->reqType = info->codes->major_opcode;
- req->ReqType = X_XiSelectEvent;
- if (dev)
- req->deviceid = dev->device_id;
- else
- req->deviceid = (1 << 7); /* all devices */
+ req->ReqType = X_XISelectEvents;
req->window = win;
- req->mask = mask;
+ req->num_masks = num_masks;
+
+ /* get the right length */
+ for (i = 0; i < num_masks; i++)
+ {
+ len++;
+ current = &masks[i];
+ len += (current->mask_len + 3)/4;
+ }
+
+ SetReqLen(req, len, len);
+
+ for (i = 0; i < num_masks; i++)
+ {
+ current = &masks[i];
+ mask.deviceid = current->deviceid;
+ mask.mask_len = (current->mask_len + 3)/4;
+ Data32(dpy, &mask, sizeof(xXIDeviceEventMask));
+ Data(dpy, (char*)current->mask, current->mask_len);
+ }
UnlockDisplay(dpy);
SyncHandle();
return Success;
+
}