[Linuxwacom-devel] [PATCH 2/2] Fix cursor freeze after performing gesture - RFC

2011-04-05 Thread Jason Gerecke
The prior patch has gestures use button mapping like buttons et.al.,
but for some reason this results in the cursor being stuck at the
top left of the screen when:

1) A gesture is performed
2) The gesture uses a button with an associated action
3) The action presses a button but does not release it

After much testing, I've found that this patch solves the issue and
also works for non-gesture code.

To be honest, I'm not sure why the old code didn't work but this does.
I see only see one difference in execution (the old code executed for
all 256 actions, '0' or not), but that change alone doesn't appear to
fix the bug...

Signed-off-by: Jason Gerecke killert...@gmail.com
---
 src/wcmCommon.c |   61 --
 1 files changed, 23 insertions(+), 38 deletions(-)

diff --git a/src/wcmCommon.c b/src/wcmCommon.c
index 0d3e8d8..ff70d64 100644
--- a/src/wcmCommon.c
+++ b/src/wcmCommon.c
@@ -206,7 +206,7 @@ void sendAction(InputInfoPtr pInfo, int press,
int i;
 
/* Actions only trigger on press, not release */
-   for (i = 0; press  i  nkeys; i++)
+   for (i = 0; i  nkeys; i++)
{
unsigned int action = keys[i];
 
@@ -219,6 +219,17 @@ void sendAction(InputInfoPtr pInfo, int press,
{
int btn_no = (action  AC_CODE);
int is_press = (action  
AC_KEYBTNPRESS);
+
+   if (!press)
+   {
+   if (!is_press)
+   break;
+   if (countPresses(btn_no, 
keys[i], nkeys - i))
+   is_press = 0;
+   else
+   break;
+   }
+   
xf86PostButtonEventP(pInfo-dev,
is_absolute(pInfo), 
btn_no,
is_press, 
first_val, num_val,
@@ -229,6 +240,17 @@ void sendAction(InputInfoPtr pInfo, int press,
{
int key_code = (action  AC_CODE);
int is_press = (action  
AC_KEYBTNPRESS);
+
+   if (!press)
+   {
+   if (!is_press)
+   break;
+   if (countPresses(key_code, 
keys[i], nkeys - i))
+   is_press = 0;
+   else
+   break;
+   }
+
wcmEmitKeycode(pInfo-dev, key_code, 
is_press);
}
break;
@@ -239,43 +261,6 @@ void sendAction(InputInfoPtr pInfo, int press,
break;
}
}
-
-   /* Release all non-released keys for this button. */
-   for (i = 0; !press  i  nkeys; i++)
-   {
-   unsigned int action = keys[i];
-
-   switch ((action  AC_TYPE))
-   {
-   case AC_BUTTON:
-   {
-   int btn_no = (action  AC_CODE);
-
-   /* don't care about releases here */
-   if (!(action  AC_KEYBTNPRESS))
-   break;
-
-   if (countPresses(btn_no, keys[i], 
nkeys - i))
-   xf86PostButtonEvent(pInfo-dev,
-   
is_absolute(pInfo), btn_no,
-   0, first_val, 
num_val,
-   
VCOPY(valuators, num_val));
-   }
-   break;
-   case AC_KEY:
-   {
-   int key_code = (action  AC_CODE);
-
-   /* don't care about releases here */
-   if (!(action  AC_KEYBTNPRESS))
-   break;
-
-   if (countPresses(key_code, keys[i], 
nkeys - i))
-   

Re: [Linuxwacom-devel] [PATCH 2/2] Fix cursor freeze after performing gesture - RFC

2011-04-05 Thread Chris Bagwell
The stuck part sounds like the X/Y issue I mentioned in other email.
 I've saw it in the other button post code path if I set tablet pen to
relative mode.  In that path, some X acceleration logic causes some
negative values and does bad things.  See related comment in
wcmSendNonPadEvents() for relative mode in how it was fixed.

I can't quite explain why this patch would help though.

Chris

On Tue, Apr 5, 2011 at 3:00 PM, Jason Gerecke killert...@gmail.com wrote:
 The prior patch has gestures use button mapping like buttons et.al.,
 but for some reason this results in the cursor being stuck at the
 top left of the screen when:

 1) A gesture is performed
 2) The gesture uses a button with an associated action
 3) The action presses a button but does not release it

 After much testing, I've found that this patch solves the issue and
 also works for non-gesture code.

 To be honest, I'm not sure why the old code didn't work but this does.
 I see only see one difference in execution (the old code executed for
 all 256 actions, '0' or not), but that change alone doesn't appear to
 fix the bug...

 Signed-off-by: Jason Gerecke killert...@gmail.com
 ---
  src/wcmCommon.c |   61 --
  1 files changed, 23 insertions(+), 38 deletions(-)

 diff --git a/src/wcmCommon.c b/src/wcmCommon.c
 index 0d3e8d8..ff70d64 100644
 --- a/src/wcmCommon.c
 +++ b/src/wcmCommon.c
 @@ -206,7 +206,7 @@ void sendAction(InputInfoPtr pInfo, int press,
        int i;

        /* Actions only trigger on press, not release */
 -       for (i = 0; press  i  nkeys; i++)
 +       for (i = 0; i  nkeys; i++)
        {
                unsigned int action = keys[i];

 @@ -219,6 +219,17 @@ void sendAction(InputInfoPtr pInfo, int press,
                                {
                                        int btn_no = (action  AC_CODE);
                                        int is_press = (action  
 AC_KEYBTNPRESS);
 +
 +                                       if (!press)
 +                                       {
 +                                               if (!is_press)
 +                                                       break;
 +                                               if (countPresses(btn_no, 
 keys[i], nkeys - i))
 +                                                       is_press = 0;
 +                                               else
 +                                                       break;
 +                                       }
 +
                                        xf86PostButtonEventP(pInfo-dev,
                                                            
 is_absolute(pInfo), btn_no,
                                                            is_press, 
 first_val, num_val,
 @@ -229,6 +240,17 @@ void sendAction(InputInfoPtr pInfo, int press,
                                {
                                        int key_code = (action  AC_CODE);
                                        int is_press = (action  
 AC_KEYBTNPRESS);
 +
 +                                       if (!press)
 +                                       {
 +                                               if (!is_press)
 +                                                       break;
 +                                               if (countPresses(key_code, 
 keys[i], nkeys - i))
 +                                                       is_press = 0;
 +                                               else
 +                                                       break;
 +                                       }
 +
                                        wcmEmitKeycode(pInfo-dev, key_code, 
 is_press);
                                }
                                break;
 @@ -239,43 +261,6 @@ void sendAction(InputInfoPtr pInfo, int press,
                                break;
                }
        }
 -
 -       /* Release all non-released keys for this button. */
 -       for (i = 0; !press  i  nkeys; i++)
 -       {
 -               unsigned int action = keys[i];
 -
 -               switch ((action  AC_TYPE))
 -               {
 -                       case AC_BUTTON:
 -                               {
 -                                       int btn_no = (action  AC_CODE);
 -
 -                                       /* don't care about releases here */
 -                                       if (!(action  AC_KEYBTNPRESS))
 -                                               break;
 -
 -                                       if (countPresses(btn_no, keys[i], 
 nkeys - i))
 -                                               
 xf86PostButtonEvent(pInfo-dev,
 -                                                               
 is_absolute(pInfo), btn_no,
 -                                                               0, first_val, 
 num_val,
 -                                                               
 VCOPY(valuators, num_val));
 -                               }
 -