From de1a8b68eb10c39a0d4a197107d68d7cc009edb2 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 3 Nov 2008 11:30:48 +1030 Subject: [PATCH] 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. --- Xi/exevents.c | 32 ++++++++++++++++++++++++++++++++ include/exevents.h | 2 ++ xkb/xkbEvents.c | 8 ++++++++ 3 files changed, 42 insertions(+) diff --git a/Xi/exevents.c b/Xi/exevents.c index 155cb9b521..c520c7dc7a 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -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); } } + diff --git a/include/exevents.h b/include/exevents.h index 667004aa16..8788295bf3 100644 --- a/include/exevents.h +++ b/include/exevents.h @@ -249,4 +249,6 @@ extern Atom XIGetKnownProperty( char* name ); +extern DeviceIntPtr XIGetDevice(xEvent *ev); + #endif /* EXEVENTS_H */ diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c index 335620baa0..151849c70b 100644 --- a/xkb/xkbEvents.c +++ b/xkb/xkbEvents.c @@ -37,6 +37,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "inputstr.h" #include "windowstr.h" +#include "exevents.h" #include #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)&&