summaryrefslogtreecommitdiff
path: root/dix
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2006-10-23 06:55:21 +0300
committerDaniel Stone <daniels@endtroducing.fooishbar.org>2006-10-23 06:55:21 +0300
commitcccf7ae0ff24d0c84b5144c457f3f86bbbc36e12 (patch)
treeb52a28993016f28f69184955532ac9c64f818195 /dix
parent35fa4ac12b3da33f81e2a12bc9661ed075f323ed (diff)
GetProximityEvents: add (untested) function
Add untested first guess at what GetProximityEvents should look like.
Diffstat (limited to 'dix')
-rw-r--r--dix/getevents.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/dix/getevents.c b/dix/getevents.c
index 802c4e6a6..17a8cb47b 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -56,6 +56,7 @@ extern Bool XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies);
#include "panoramiXsrv.h"
#endif
+#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "exglobals.h"
#include "exevents.h"
@@ -533,6 +534,57 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
}
/**
+ * Post ProximityIn/ProximityOut events, accompanied by valuators.
+ *
+ * events is not NULL-terminated; the return value is the number of events.
+ * The DDX is responsible for allocating the event structure in the first
+ * place via GetMaximumEventsNum(), and for freeing it.
+ */
+_X_EXPORT int
+GetProximityEvents(xEvent *events, DeviceIntPtr pDev, int type,
+ int first_valuator, int num_valuators, int *valuators)
+{
+ int num_events = 0;
+ deviceKeyButtonPointer *kbp = (deviceKeyButtonPointer *) events;
+
+ /* Sanity checks. */
+ if (type != ProximityIn && type != ProximityOut)
+ return 0;
+
+ if (!pDev->valuator)
+ return 0;
+
+ /* Do we need to send a DeviceValuator event? */
+ if ((pDev->valuator->mode & 1) == Relative)
+ num_valuators = 0;
+
+ if (num_valuators) {
+ if ((((num_valuators - 1) / 6) + 1) > MAX_VALUATOR_EVENTS)
+ num_valuators = MAX_VALUATOR_EVENTS * 6;
+ num_events += ((num_valuators - 1) / 6) + 1;
+ }
+
+ /* You fail. */
+ if (first_valuator < 0 ||
+ (num_valuators + first_valuator) > pDev->valuator->numAxes)
+ return 0;
+
+ kbp->type = type;
+ kbp->deviceid = pDev->id;
+ kbp->detail = 0;
+ kbp->time = GetTimeInMillis();
+
+ if (num_valuators) {
+ kbp->deviceid |= MORE_EVENTS;
+ events++;
+ events = getValuatorEvents(events, pDev, first_valuator,
+ num_valuators, valuators);
+ }
+
+ return num_events;
+}
+
+/**
* Note that pDev was the last device to send a core event. This function
* copies the complete keymap from the originating device to the core
* device, and makes sure the appropriate notifications are generated.