xkb: extract the correct device in XkbFilterEvents.

If the event is an XI event, we need to work on the correct device, not on
the VCK.

Adds XIGetDevice(event) function to extract the device from an event.
This commit is contained in:
Peter Hutterer 2008-11-03 11:30:48 +10:30
parent d972399566
commit de1a8b68eb
3 changed files with 42 additions and 0 deletions

View File

@ -133,6 +133,37 @@ IsPointerEvent(xEvent* xE)
return FALSE;
}
/**
* @return the device matching the deviceid of the device set in the event, or
* NULL if the event is not an XInput event.
*/
DeviceIntPtr
XIGetDevice(xEvent* xE)
{
DeviceIntPtr pDev = NULL;
if (xE->u.u.type == DeviceButtonPress ||
xE->u.u.type == DeviceButtonRelease ||
xE->u.u.type == DeviceMotionNotify ||
xE->u.u.type == DeviceEnterNotify ||
xE->u.u.type == DeviceLeaveNotify ||
xE->u.u.type == ProximityIn ||
xE->u.u.type == ProximityOut ||
xE->u.u.type == DevicePropertyNotify)
{
int rc;
int id;
id = ((deviceKeyButtonPointer*)xE)->deviceid;
rc = dixLookupDevice(&pDev, id, serverClient, DixUnknownAccess);
if (rc != Success)
ErrorF("[dix] XIGetDevice failed on XACE restrictions (%d)\n", rc);
}
return pDev;
}
/**
* Copy the device->key into master->key and send a mapping notify to the
* clients if appropriate.
@ -2107,3 +2138,4 @@ SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent * ev, int count)
FindInterestedChildren(dev, p1, mask, ev, count);
}
}

View File

@ -249,4 +249,6 @@ extern Atom XIGetKnownProperty(
char* name
);
extern DeviceIntPtr XIGetDevice(xEvent *ev);
#endif /* EXEVENTS_H */

View File

@ -37,6 +37,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <X11/extensions/XIproto.h>
#include "inputstr.h"
#include "windowstr.h"
#include "exevents.h"
#include <xkbsrv.h>
#include "xkb.h"
@ -811,6 +812,13 @@ int i, button_mask;
DeviceIntPtr pXDev = inputInfo.keyboard;
XkbSrvInfoPtr xkbi;
if (xE->u.u.type & EXTENSION_EVENT_BASE)
{
pXDev = XIGetDevice(xE);
if (!pXDev)
pXDev = inputInfo.keyboard;
}
xkbi= pXDev->key->xkbInfo;
if ( pClient->xkbClientFlags & _XkbClientInitialized ) {
if ((xkbDebugFlags&0x10)&&