summaryrefslogtreecommitdiff
path: root/xkb/xkbEvents.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter@cs.unisa.edu.au>2007-09-06 18:49:57 +0930
committerPeter Hutterer <peter@cs.unisa.edu.au>2007-09-06 18:49:57 +0930
commit6334d4e7be18de5f237c12a6dc20f75aa23477d0 (patch)
tree944712ad644e14918fd237530282f396a74e8e50 /xkb/xkbEvents.c
parent49dbe9a757a3d7a0b9ab318242c6cc0cbd4dd1f0 (diff)
xkb: enable XI event processing for xkb.
XI events can now take the same processing paths as core events, and should do the correct state changes etc. There's some cases where XKB will use KeyPress as type for an event to be delivered to the client. Stuck warnings in, not sure what the correct solution is yet.
Diffstat (limited to 'xkb/xkbEvents.c')
-rw-r--r--xkb/xkbEvents.c43
1 files changed, 35 insertions, 8 deletions
diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c
index 973e1ad1d..22ca2d6e9 100644
--- a/xkb/xkbEvents.c
+++ b/xkb/xkbEvents.c
@@ -34,6 +34,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <X11/Xproto.h>
#include <X11/keysym.h>
#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
#include "inputstr.h"
#include "windowstr.h"
#include <xkbsrv.h>
@@ -814,7 +815,9 @@ GrabInfoPtr grabinfo;
if ( pClient->xkbClientFlags & _XkbClientInitialized ) {
#ifdef DEBUG
if ((xkbDebugFlags&0x10)&&
- ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease))) {
+ ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease)||
+ (xE[0].u.u.type==DeviceKeyPress)||
+ (xE[0].u.u.type == DeviceKeyRelease))) {
ErrorF("XKbFilterWriteEvents:\n");
ErrorF(" Event state= 0x%04x\n",xE[0].u.keyButtonPointer.state);
ErrorF(" XkbLastRepeatEvent!=xE (0x%p!=0x%p) %s\n",
@@ -834,7 +837,9 @@ GrabInfoPtr grabinfo;
}
if ((pXDev->deviceGrab.grab != NullGrab)
&& pXDev->deviceGrab.fromPassiveGrab &&
- ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease))) {
+ ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease)||
+ (xE[0].u.u.type==DeviceKeyPress)||
+ (xE[0].u.u.type == DeviceKeyRelease))) {
register unsigned state,flags;
flags= pClient->xkbClientFlags;
@@ -879,10 +884,12 @@ GrabInfoPtr grabinfo;
type= xE[i].u.u.type;
#ifdef DEBUG
if ((xkbDebugFlags&0x4)&&
- ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease))) {
+ ((xE[i].u.u.type==KeyPress)||(xE[i].u.u.type==KeyRelease)||
+ (xE[i].u.u.type==DeviceKeyPress)||
+ (xE[i].u.u.type == DeviceKeyRelease))) {
XkbStatePtr s= &xkbi->state;
ErrorF("XKbFilterWriteEvents (non-XKB):\n");
- ErrorF("event= 0x%04x\n",xE[0].u.keyButtonPointer.state);
+ ErrorF("event= 0x%04x\n",xE[i].u.keyButtonPointer.state);
ErrorF("lookup= 0x%02x, grab= 0x%02x\n",s->lookup_mods,
s->grab_mods);
ErrorF("compat lookup= 0x%02x, grab= 0x%02x\n",
@@ -902,9 +909,22 @@ GrabInfoPtr grabinfo;
xE[i].u.keyButtonPointer.state= new;
}
else if ((type==EnterNotify)||(type==LeaveNotify)) {
- xE->u.enterLeave.state&= 0x1F00;
- xE->u.enterLeave.state|= xkbi->state.compat_grab_mods;
- }
+ xE[i].u.enterLeave.state&= 0x1F00;
+ xE[i].u.enterLeave.state|= xkbi->state.compat_grab_mods;
+ } else if ((type>=DeviceKeyPress)&&(type<=DeviceMotionNotify)) {
+ CARD16 old, new;
+ deviceKeyButtonPointer *kbp = (deviceKeyButtonPointer*)&xE[i];
+ old= kbp->state&(~0x1F00);
+ new= kbp->state&0x1F00;
+ if (old==XkbStateFieldFromRec(&xkbi->state))
+ new|= xkbi->state.compat_lookup_mods;
+ else new|= xkbi->state.compat_grab_mods;
+ kbp->state= new;
+ } else if ((type==DeviceEnterNotify)||(type==DeviceLeaveNotify)) {
+ deviceEnterNotify *del = (deviceEnterNotify*)&xE[i];
+ del->state&=0x1F00;
+ del->state|= xkbi->state.compat_grab_mods;
+ }
button_mask = 1 << xE[i].u.u.detail;
if (type == ButtonPress &&
((xE[i].u.keyButtonPointer.state >> 7) & button_mask) == button_mask &&
@@ -913,7 +933,14 @@ GrabInfoPtr grabinfo;
ErrorF("Faking release of button %d\n", xE[i].u.u.detail);
#endif
XkbDDXFakePointerButton(ButtonRelease, xE[i].u.u.detail);
- }
+ } else if (type == DeviceButtonPress &&
+ ((((deviceKeyButtonPointer*)&xE[i])->state >> 7) & button_mask) == button_mask &&
+ (xkbi->lockedPtrButtons & button_mask) == button_mask) {
+#ifdef DEBUG
+ ErrorF("Faking release of button %d\n", ((deviceKeyButtonPointer*)&xE[i])->state)
+#endif
+ XkbDDXFakePointerButton(DeviceButtonRelease, ((deviceKeyButtonPointer*)&xE[i])->state);
+ }
}
}
return True;