From 8c9234a163eceda2abc0a2523e0f5587ea399935 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 15 Jun 2008 10:01:28 +0930 Subject: [PATCH] Xi: avoid double button mapping. Button events were mapped once in GetPointerEvents and then again in UpdateDeviceState. While it might make sense to just fix up UpdateDeviceState, it turns out to be better to leave the raw button number in the event because DGA reports raw device events without button translation, and so when it calls UpdateDeviceState, the button down counts get scrambled and buttons get stuck down. See also: http://lists.freedesktop.org/archives/xorg/2008-June/036201.html Signed-off-by: Peter Hutterer --- Xi/exevents.c | 13 +++++++++---- dix/getevents.c | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Xi/exevents.c b/Xi/exevents.c index 725c57835..6f88b57f3 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -1066,9 +1066,11 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr device, int count) (key == device->deviceGrab.activatingKey)) deactivateDeviceGrab = TRUE; } else if (xE->u.u.type == DeviceButtonPress) { - xE->u.u.detail = key; - if (xE->u.u.detail == 0) + xE->u.u.detail = b->map[key]; + if (xE->u.u.detail == 0) { + xE->u.u.detail = key; return; + } if (!grab && CheckDeviceGrabs(device, xE, 0, count)) { /* if a passive grab was activated, the event has been sent @@ -1077,9 +1079,11 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr device, int count) } } else if (xE->u.u.type == DeviceButtonRelease) { - xE->u.u.detail = key; - if (xE->u.u.detail == 0) + xE->u.u.detail = b->map[key]; + if (xE->u.u.detail == 0) { + xE->u.u.detail = key; return; + } if (!b->state && device->deviceGrab.fromPassiveGrab) deactivateDeviceGrab = TRUE; } @@ -1094,6 +1098,7 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr device, int count) if (deactivateDeviceGrab == TRUE) (*device->deviceGrab.DeactivateGrab) (device); + xE->u.u.detail = key; } _X_EXPORT int diff --git a/dix/getevents.c b/dix/getevents.c index 5227c54ec..b00bc11ca 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -1030,7 +1030,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons, kbp->type = DeviceButtonPress; else if (type == ButtonRelease) kbp->type = DeviceButtonRelease; - kbp->detail = pDev->button->map[buttons]; + kbp->detail = buttons; } kbp->root_x = cx; /* root_x/y always in screen coords */