[2/2] xfree86: update the device state for all DGA events (#59100)

Submitted by Peter Hutterer on Jan. 8, 2013, 1:51 a.m.

Details

Message ID 1357609894-14668-2-git-send-email-peter.hutterer@who-t.net
State Accepted
Commit ad3bc571348a7007a2960bf87ae739397c5511ee
Headers show

Not browsing as part of any series.

Commit Message

Peter Hutterer Jan. 8, 2013, 1:51 a.m.
DGA only handles master devices but it does intercept slave device events as
well (since the event handlers are per event type, not per device).

The DGA code must thus call into UpdateDeviceState to reset the button/key
state on the slave device before it discards the remainder of the event.

Test case:
- Passive GrabModeSync on VCP
- Press button
- Enable DGA after ButtonPress
- AllowEvents(SyncPointer)
- Release button

The button release is handled by DGAProcessPointerEvent but the device state
is never updated, so the slave ends up with the button permanently down.
And since the master's button state is the union of the slave states, the
master has the button permanently down.

X.Org Bug 59100 <http://bugs.freedesktop.org/show_bug.cgi?id=59100>

Reported-by: Steven Elliott <selliott4@austin.rr.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
---
 hw/xfree86/common/xf86DGA.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index c10dd32..6a05ce5 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -1033,6 +1033,9 @@  DGAProcessKeyboardEvent(ScreenPtr pScreen, DGAEvent * event, DeviceIntPtr keybd)
 
     UpdateDeviceState(keybd, &ev);
 
+    if (!IsMaster(keybd))
+        return;
+
     /*
      * Deliver the DGA event
      */
@@ -1084,6 +1087,9 @@  DGAProcessPointerEvent(ScreenPtr pScreen, DGAEvent * event, DeviceIntPtr mouse)
 
     UpdateDeviceState(mouse, &ev);
 
+    if (!IsMaster(mouse))
+        return;
+
     /*
      * Deliver the DGA event
      */
@@ -1191,9 +1197,6 @@  DGAHandleEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device)
     if (!pScreenPriv)
         return;
 
-    if (!IsMaster(device))
-        return;
-
     switch (event->subtype) {
     case KeyPress:
     case KeyRelease:

Comments

On Tue, Jan 8, 2013 at 11:51 AM, Peter Hutterer
<peter.hutterer@who-t.net> wrote:
> DGA only handles master devices but it does intercept slave device events as
> well (since the event handlers are per event type, not per device).
>
> The DGA code must thus call into UpdateDeviceState to reset the button/key
> state on the slave device before it discards the remainder of the event.
>
> Test case:
> - Passive GrabModeSync on VCP
> - Press button
> - Enable DGA after ButtonPress
> - AllowEvents(SyncPointer)
> - Release button
>
> The button release is handled by DGAProcessPointerEvent but the device state
> is never updated, so the slave ends up with the button permanently down.
> And since the master's button state is the union of the slave states, the
> master has the button permanently down.
>
> X.Org Bug 59100 <http://bugs.freedesktop.org/show_bug.cgi?id=59100>
>
> Reported-by: Steven Elliott <selliott4@austin.rr.com>
> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

LGTM,

Reviewed-by: Dave Airlie <airlied@redhat.com>
> ---
>  hw/xfree86/common/xf86DGA.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
> index c10dd32..6a05ce5 100644
> --- a/hw/xfree86/common/xf86DGA.c
> +++ b/hw/xfree86/common/xf86DGA.c
> @@ -1033,6 +1033,9 @@ DGAProcessKeyboardEvent(ScreenPtr pScreen, DGAEvent * event, DeviceIntPtr keybd)
>
>      UpdateDeviceState(keybd, &ev);
>
> +    if (!IsMaster(keybd))
> +        return;
> +
>      /*
>       * Deliver the DGA event
>       */
> @@ -1084,6 +1087,9 @@ DGAProcessPointerEvent(ScreenPtr pScreen, DGAEvent * event, DeviceIntPtr mouse)
>
>      UpdateDeviceState(mouse, &ev);
>
> +    if (!IsMaster(mouse))
> +        return;
> +
>      /*
>       * Deliver the DGA event
>       */
> @@ -1191,9 +1197,6 @@ DGAHandleEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device)
>      if (!pScreenPriv)
>          return;
>
> -    if (!IsMaster(device))
> -        return;
> -
>      switch (event->subtype) {
>      case KeyPress:
>      case KeyRelease:
> --
> 1.8.1
>
> _______________________________________________
> xorg-devel@lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel