[AD] mouse presses and releases skipped when double clicking

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


I fixed this one. It was due to the double clicking detection
mechanism exiting prematurely from the update_dialog routine.
I really hate this bit of code. It disrupts way too much the
update. I think it would be easy to replace it with a version
that doesn't create this lag, but I guess this was done like
this for a reason, so...
Anyway, I'm still using a very old and heavily modified version
of Allegro now, so I only describe the patch, sorry (the diff
I tried to make yielded very confusing results, as I have modified
my Allegro quite a lot);

There is a block of code in update_dialog which begins by:
   /* deal with mouse buttons presses and releases */
Move it to the top of the update_dialog routine, between
   if (player->res & D_CLOSE)
      return FALSE;
and
   /* need to reinstall the dclick and switch handlers? */
   if (gui_install_time != _allegro_count) {
      install_int(dclick_check, 20);

and remove the few lines that deal with double click state
managing, which are not required here. The block of code
should then be:

   if (player->res & D_CLOSE)
      return FALSE;

   /* deal with mouse buttons presses and releases */
   if (gui_mouse_b() != player->mouse_b) {
      player->res |= offer_focus(player->dialog, player->mouse_obj,
&player->focus_obj, FALSE);

      if (player->mouse_obj >= 0) {
         /* send press and release messages */
         if ((gui_mouse_b() & 1) && !(player->mouse_b & 1))
            MESSAGE(player->mouse_obj, MSG_LPRESS, gui_mouse_b());
         if (!(gui_mouse_b() & 1) && (player->mouse_b & 1))
            MESSAGE(player->mouse_obj, MSG_LRELEASE, gui_mouse_b());

         if ((gui_mouse_b() & 4) && !(player->mouse_b & 4))
            MESSAGE(player->mouse_obj, MSG_MPRESS, gui_mouse_b());
         if (!(gui_mouse_b() & 4) && (player->mouse_b & 4))
            MESSAGE(player->mouse_obj, MSG_MRELEASE, gui_mouse_b());

         if ((gui_mouse_b() & 2) && !(player->mouse_b & 2))
            MESSAGE(player->mouse_obj, MSG_RPRESS, gui_mouse_b());
         if (!(gui_mouse_b() & 2) && (player->mouse_b & 2))
            MESSAGE(player->mouse_obj, MSG_RRELEASE, gui_mouse_b());

         player->mouse_b = gui_mouse_b();

         if (player->res == D_O_K)
            player->click_wait = TRUE;
      }
      else
         dialog_message(player->dialog, MSG_IDLE, 0, &nowhere);

      goto getout;
   }

   /* need to reinstall the dclick and switch handlers? */
   if (gui_install_time != _allegro_count) {
      install_int(dclick_check, 20);


I'll try to update soon to the new Allegro, so diff will give usable
results next time I try it :)

--
Lyrian



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/