[resend] input: Only release SD buttons for explicit floating/reattachment (#36146)

Submitted by Peter Hutterer on May 4, 2011, 7:12 a.m.

Details

Message ID 20110504001236.GA16838@barra.bne.redhat.com
State Deferred, archived
Headers show

Not browsing as part of any series.

Commit Message

Peter Hutterer May 4, 2011, 7:12 a.m.
Grabbing an SD device temporary floats the device but we must not release
the buttons. Introduced in

    commit 9d23459415b84606ee4f38bb2d19054c432c8552
    Author: Peter Hutterer <peter.hutterer@who-t.net>
    Date:   Fri Feb 25 11:08:19 2011 +1000

    dix: release all buttons and keys before reattaching a device (#34182)

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
---
 Xi/xichangehierarchy.c |    2 ++
 dix/devices.c          |    4 +---
 include/input.h        |    2 ++
 3 files changed, 5 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/Xi/xichangehierarchy.c b/Xi/xichangehierarchy.c
index 0736a5a..96ead6f 100644
--- a/Xi/xichangehierarchy.c
+++ b/Xi/xichangehierarchy.c
@@ -355,6 +355,7 @@  detach_slave(ClientPtr client, xXIDetachSlaveInfo *c, int flags[MAXDEVICES])
         goto unwind;
     }
 
+    ReleaseButtonsAndKeys(dev);
     AttachDevice(client, dev, NULL);
     flags[dev->id] |= XISlaveDetached;
 
@@ -406,6 +407,7 @@  attach_slave(ClientPtr client, xXIAttachSlaveInfo *c,
         goto unwind;
     }
 
+    ReleaseButtonsAndKeys(dev);
     AttachDevice(client, dev, newmaster);
     flags[dev->id] |= XISlaveAttached;
 
diff --git a/dix/devices.c b/dix/devices.c
index 9d4fda2..9a4498b 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -2365,7 +2365,7 @@  RecalculateMasterButtons(DeviceIntPtr slave)
  * Generate release events for all keys/button currently down on this
  * device.
  */
-static void
+void
 ReleaseButtonsAndKeys(DeviceIntPtr dev)
 {
     InternalEvent*      eventlist = InitEventList(GetMaximumEventsNum());
@@ -2434,8 +2434,6 @@  AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master)
         free(dev->spriteInfo->sprite);
     }
 
-    ReleaseButtonsAndKeys(dev);
-
     oldmaster = GetMaster(dev, MASTER_ATTACHED);
     dev->master = master;
 
diff --git a/include/input.h b/include/input.h
index 81c9dfb..1c0065f 100644
--- a/include/input.h
+++ b/include/input.h
@@ -501,6 +501,8 @@  extern _X_EXPORT int GetMotionHistory(
     ScreenPtr pScreen,
     BOOL core);
 
+extern void ReleaseButtonsAndKeys(DeviceIntPtr dev);
+
 extern int AttachDevice(ClientPtr client,
                         DeviceIntPtr slave,
                         DeviceIntPtr master);

Comments

Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>

On May 3, 2011, at 17:12, Peter Hutterer wrote:

> Grabbing an SD device temporary floats the device but we must not release
> the buttons. Introduced in
> 
>    commit 9d23459415b84606ee4f38bb2d19054c432c8552
>    Author: Peter Hutterer <peter.hutterer@who-t.net>
>    Date:   Fri Feb 25 11:08:19 2011 +1000
> 
>    dix: release all buttons and keys before reattaching a device (#34182)
> 
> X.Org Bug 36146 <http://bugs.freedesktop.org/show_bug.cgi?id=36146>
> 
> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
> ---
> Xi/xichangehierarchy.c |    2 ++
> dix/devices.c          |    4 +---
> include/input.h        |    2 ++
> 3 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/Xi/xichangehierarchy.c b/Xi/xichangehierarchy.c
> index 0736a5a..96ead6f 100644
> --- a/Xi/xichangehierarchy.c
> +++ b/Xi/xichangehierarchy.c
> @@ -355,6 +355,7 @@ detach_slave(ClientPtr client, xXIDetachSlaveInfo *c, int flags[MAXDEVICES])
>         goto unwind;
>     }
> 
> +    ReleaseButtonsAndKeys(dev);
>     AttachDevice(client, dev, NULL);
>     flags[dev->id] |= XISlaveDetached;
> 
> @@ -406,6 +407,7 @@ attach_slave(ClientPtr client, xXIAttachSlaveInfo *c,
>         goto unwind;
>     }
> 
> +    ReleaseButtonsAndKeys(dev);
>     AttachDevice(client, dev, newmaster);
>     flags[dev->id] |= XISlaveAttached;
> 
> diff --git a/dix/devices.c b/dix/devices.c
> index 9d4fda2..9a4498b 100644
> --- a/dix/devices.c
> +++ b/dix/devices.c
> @@ -2365,7 +2365,7 @@ RecalculateMasterButtons(DeviceIntPtr slave)
>  * Generate release events for all keys/button currently down on this
>  * device.
>  */
> -static void
> +void
> ReleaseButtonsAndKeys(DeviceIntPtr dev)
> {
>     InternalEvent*      eventlist = InitEventList(GetMaximumEventsNum());
> @@ -2434,8 +2434,6 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master)
>         free(dev->spriteInfo->sprite);
>     }
> 
> -    ReleaseButtonsAndKeys(dev);
> -
>     oldmaster = GetMaster(dev, MASTER_ATTACHED);
>     dev->master = master;
> 
> diff --git a/include/input.h b/include/input.h
> index 81c9dfb..1c0065f 100644
> --- a/include/input.h
> +++ b/include/input.h
> @@ -501,6 +501,8 @@ extern _X_EXPORT int GetMotionHistory(
>     ScreenPtr pScreen,
>     BOOL core);
> 
> +extern void ReleaseButtonsAndKeys(DeviceIntPtr dev);
> +
> extern int AttachDevice(ClientPtr client,
>                         DeviceIntPtr slave,
>                         DeviceIntPtr master);
> -- 
> 1.7.4.4
> _______________________________________________
> 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
>
On Wed, May 04, 2011 at 10:12:36AM +1000, Peter Hutterer wrote:
> Grabbing an SD device temporary floats the device but we must not release
> the buttons. Introduced in
> 
>     commit 9d23459415b84606ee4f38bb2d19054c432c8552
>     Author: Peter Hutterer <peter.hutterer@who-t.net>
>     Date:   Fri Feb 25 11:08:19 2011 +1000
> 
>     dix: release all buttons and keys before reattaching a device (#34182)
> 
> X.Org Bug 36146 <http://bugs.freedesktop.org/show_bug.cgi?id=36146>
> 
> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

Sorry I've taken so long to get around to this one.  I haven't tested it
(mainly because all my external devices are in the office), but it seems
like it should work.

Reviewed-by: Daniel Stone <daniel@fooishbar.org>

Cheers,
Daniel