Re: [AD] MSG_IDLE in grabber and menus

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


On Tue, 2004-01-13 at 16:47, Elias Pschernig wrote:

> Ok, patch attached. The 2nd patch just adds the 2 missing d_yield_proc
> entries to grabber. Thr 3rd adds clarifications to the docs, and while I
> was add it, also fixed the next line after d_yield_proc which looked
> wrong in HTML, and updated some related xrefs..

Um, overlooked active_menu_player_zombie.. try this patch instead.

-- 
Elias Pschernig <elias@xxxxxxxxxx>
Index: src/gui.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/gui.c,v
retrieving revision 1.67
diff -u -p -r1.67 gui.c
--- src/gui.c	30 Nov 2003 17:59:17 -0000	1.67
+++ src/gui.c	13 Jan 2004 16:06:41 -0000
@@ -512,8 +512,8 @@ typedef struct OBJ_LIST
    when calculating the distance for the focus algorithm. */
 #define DISTANCE_RATIO  8
 
-/* Maximum size (in bytes) of a dialog array. */
-#define MAX_SIZE  0x10000  /* 64 kb */
+/* Maximum size of a dialog array for focus wrap around. */
+#define MAX_SIZE  0x10000
 
 enum axis { X_AXIS, Y_AXIS };
 
@@ -771,7 +771,12 @@ int do_dialog(DIALOG *dialog, int focus_
    player = init_dialog(dialog, focus_obj);
 
    while (update_dialog(player))
-      ;
+      /* If a non-yielding menu is active, we yield here, since the
+       * dialog is shut down and no user code can be running.
+       */
+      if (active_menu_player)
+         if (!active_menu_player->yield || active_menu_player_zombie)
+            yield_timeslice ();
 
    if (_gfx_mode_set_count == screen_count)
       show_mouse(mouse_screen);
@@ -1739,6 +1744,18 @@ static MENU_PLAYER *init_single_menu(MEN
    player->auto_open = TRUE;
    player->ret = -1;
 
+   /* determine yielding behavior */
+   player->yield = parent ? parent->yield : FALSE;
+
+   if (dialog) {
+      DIALOG *d;
+      /* scan for d_yield_proc in the underlying dialog */
+      for (d = dialog; d->proc; d++) {
+         if (d->proc == d_yield_proc)
+            player->yield = TRUE;
+      }
+   }
+
    player->dialog = dialog;
 
    player->parent = parent;
@@ -1968,6 +1985,10 @@ int update_menu(MENU_PLAYER *player)
    }
 
  End:
+
+   if (player->yield)
+      yield_timeslice ();
+
    if (player->ret >= 0) {  /* item selected? */
       if (player->menu[player->ret].flags & D_DISABLED) {
 	 return TRUE;  /* continue */


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