diff options
author | Peter Hutterer <peter@cs.unisa.edu.au> | 2008-05-15 11:09:15 +0930 |
---|---|---|
committer | Peter Hutterer <peter@cs.unisa.edu.au> | 2008-05-16 15:42:57 +0930 |
commit | 28378d26b4bae377ef1212f6a51cda9b5529f1b5 (patch) | |
tree | 440d0bbccc35d62e3efc79cf433bc36f7f68009b /Xi | |
parent | 937e5aae33d3b5112b5d10d605e25f57b48caa3f (diff) |
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 <http://bugs.freedesktop.org/show_bug.cgi?id=15934>
Diffstat (limited to 'Xi')
-rw-r--r-- | Xi/exevents.c | 43 |
1 files 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; } |