[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] Sample code to reproduce potentially broken toolbar event handling (XaAES)



Peter Persson wrote:

>
> Content-Transfer-Encoding: quoted-printable
> Content-Type: text/plain;
> 	charset=us-ascii
>
> Hi,
>
> I've attached sourcecode which illustrates a problem with toolbar =
> events. The code is a bit messy since I wrote it in 10 minutes, but I =
> think it illustrates the problem well. I chose to implement the resource =
> in source form so that we know what we're dealing with.
>
> The code creates a toolbar resource with three buttons.
>  - leftmost button doesn't do anything.
>  - middle button uses graf_watchbox().
>  - right button uses graf_slidebox().
>
> Try the following:
> 1. Click quickly on the leftmost button. Only one event is generated, =
> which seems correct.
> 2. Click and hold the leftmost button. For some reason, two events are =
> generated, not just one.
> 3. Click and hold the middle button, and drag the mouse outside of the =
> button area. Note how a second click event is generated, breaking the =
> graf_watchbox() functionality.
> 4. Click and drag the right button. Note how a second click is =
> generated, breaking the graf_slidebox() functionality.

The relevant code in XaAES (widgets.c#4767) says:

              /*
               * Special case; If click goes onto a userinstalled toolbar
               * we need to give the mouse event to the client if the button
               * is still being pressed, because a 'touchexit' object may
               * return control to client immediately, and it may do
               * graf_mkstate() to check if button is released. If we dont
               * do this, client will always detect a button released...
               */
              if (md->cstate)
                button_event(lock, w->owner, md);
              if (widg->m.click){
                BLOG((0,"do_widgets:click(1)"));
                rtn = widg->m.click(lock, w, widg, md);
              }
            }
            if (b && (widg->m.properties & WIP_NODRAG))
            {
              if (widg->m.click){
                BLOG((0,"do_widgets:click(2)"));
                widg->m.click(lock, w, widg, md);
              }
            }
            else if (b && widg->m.drag){
              XA_TREE *wt = widg->stuff;
              BLOG((0,"do_widgets:drag(2),wt->exit_form=%lx", wt->exit_form));
->            if( !wt->exit_form )
                rtn = widg->m.drag(lock, w, widg, md);
            }


Note the -> - line: With this test only one WM_TOOLBAR is generated, I don't know if
this is the right solution though.

Which CPU do you need? I can upload a test-version to my site.

PS: Here's a patch for your code:

+#include <stdio.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <osbind.h>
@@ -5,7 +7,7 @@
 #include <mint/slb.h>
 #include <mint/mintbind.h>

-static OBJECT obj[3] =
+static OBJECT obj[4] =
 {
        {-1, -1, -1, G_BOX, OF_NONE, OS_NORMAL, 0x12345, 0, 0, 10, 20 },
       /* root object */
        {-1, -1, -1, G_BOX, OF_TOUCHEXIT, OS_NORMAL, 0x23456, 5,5,20,10
},      /* left button */
@@ -112,3 +114,4 @@
        return 0;
 }


-Helmut