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 #include #include "exglobals.h" #include "exevents.h" @@ -532,6 +533,57 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons, return num_events; } +/** + * 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 diff --git a/include/input.h b/include/input.h index 4acc85694..f6ef33784 100644 --- a/include/input.h +++ b/include/input.h @@ -410,6 +410,14 @@ extern int GetKeyboardValuatorEvents( int num_valuator, int *valuators); +extern int GetProximityEvents( + xEvent *events, + DeviceIntPtr pDev, + int type, + int first_valuator, + int num_valuators, + int *valuators); + extern void SwitchCoreKeyboard(DeviceIntPtr pDev); extern void SwitchCorePointer(DeviceIntPtr pDev);