From 28378d26b4bae377ef1212f6a51cda9b5529f1b5 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 15 May 2008 11:09:15 +0930 Subject: [PATCH] Xi: assemble button/modifier state before updating the device. #15934 The state field of the event must specify the state of the devices before the event occured. With the code as it was, the state would also include the event (e.g. state from a button press event would show the button as pressed) Gathering the state before updating the device should fix this. X.Org Bug 15934 --- Xi/exevents.c | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/Xi/exevents.c b/Xi/exevents.c index b2845473a..42b77c137 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -1021,6 +1021,26 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr device, int count) ValuatorClassPtr v; deviceValuator *xV = (deviceValuator *) xE; int ret = 0; + int state; + DeviceIntPtr mouse = NULL, kbd = NULL; + + if (IsPointerDevice(device)) + { + kbd = GetPairedDevice(device); + mouse = device; + if (!kbd->key) /* can happen with floating SDs */ + kbd = NULL; + } else + { + mouse = GetPairedDevice(device); + kbd = device; + if (!mouse->valuator || !mouse->button) /* may be float. SDs */ + mouse = NULL; + } + + /* State needs to be assembled BEFORE the device is updated. */ + state = (kbd) ? kbd->key->state : 0; + state |= (mouse) ? (mouse->button->state) : 0; ret = UpdateDeviceState(device, xE, count); if (ret == DONT_PROCESS) @@ -1034,33 +1054,12 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr device, int count) CheckMotion(xE, device); if (xE->u.u.type != DeviceValuator && xE->u.u.type != GenericEvent) { - DeviceIntPtr mouse = NULL, kbd = NULL; GetSpritePosition(device, &rootX, &rootY); xE->u.keyButtonPointer.rootX = rootX; xE->u.keyButtonPointer.rootY = rootY; NoticeEventTime(xE); - /* If 'device' is a pointer device, we need to get the paired keyboard - * for the state. If there is none, the kbd bits of state are 0. - * If 'device' is a keyboard device, get the paired pointer and use the - * pointer's state for the button bits. - */ - if (IsPointerDevice(device)) - { - kbd = GetPairedDevice(device); - mouse = device; - if (!kbd->key) /* can happen with floating SDs */ - kbd = NULL; - } - else - { - mouse = GetPairedDevice(device); - kbd = device; - if (!mouse->valuator || !mouse->button) /* may be float. SDs */ - mouse = NULL; - } - xE->u.keyButtonPointer.state = (kbd) ? (kbd->key->state) : 0; - xE->u.keyButtonPointer.state |= (mouse) ? (mouse->button->state) : 0; + xE->u.keyButtonPointer.state = state; key = xE->u.u.detail; }