Thank you very much for your patch. I'm still looking at the problem; you are right, what I submitted does NOT fix it entirely.
As an easier way to find the active menu (as distinct from the current menu), I would suggest that we add another variable to the "fgState" structure. Since GLUT has only one menu active at a time (no matter how many windows there are), we wouldn't need the "window->ActiveMenu" field any more.
On a different, but related, subject, I find that in GLUT the motion and passive motion callbacks are disabled when a menu is open. This is not the case in "freeglut". I am working on a patch for that. In addition, there is a "menu status callback" which we allow the application program to define but which we never call. I'm also working on a patch for that.
John F. Fay
From: email@example.com [mailto:firstname.lastname@example.org] On Behalf Of Takeshi Nishimura
Sent: Thursday, February 17, 2005 4:58 AM
Subject: Re: [Freeglut-developer] Attaching a Menu to Multiple Windows
Fay John F Contr AAC/WMG wrote:
> I have put in a bit of time today getting menus to work with
> multiple windows (and multiple mouse buttons in one window) and think I have
> fixed that problem.
Thank you for your work at this problem.
But the patch does not fix the problem completely. You may have trouble when
you activate two menus at the same time. Please see Bugs#1051977 for details.
You should deactivate the active menu when mouse down-click on other window
("at most one menu on the screen" policy).
I wrote an additional patch. See below.
RCS file: /cvsroot/freeglut/freeglut/freeglut/src/freeglut_menu.c,v
retrieving revision 1.37
diff -u -r1.37 freeglut_menu.c
--- freeglut/src/freeglut_menu.c 16 Feb 2005 00:52:23 -0000 1.37
+++ freeglut/src/freeglut_menu.c 17 Feb 2005 10:21:23 -0000
@@ -489,6 +489,40 @@
+ * A static helper function to find active menu
+static void fghcbFindActiveMenu( SFG_Window *window,
+ SFG_Enumerator *enumerator )
+ if( enumerator->found )
+ if (!window->IsMenu && window->ActiveMenu)
+ enumerator->found = GL_TRUE;
+ enumerator->data = window->ActiveMenu;
+ fgEnumSubWindows( window, fghcbFindActiveMenu, enumerator );
+ * Find active menu
+static SFG_Menu *fghFindActiveMenu( void )
+ SFG_Enumerator enumerator;
+ enumerator.found = GL_FALSE;
+ enumerator.data = NULL;
+ fgEnumWindows( fghcbFindActiveMenu, &enumerator );
+ if( enumerator.found )
+ return (SFG_Menu *)enumerator.data;
+ return NULL;
* Activates a menu pointed by the function argument
static void fghActivateMenu( SFG_Window* window, int button )
@@ -600,6 +634,17 @@
+ if( pressed && !window->IsMenu )
+ SFG_Menu* menu = fghFindActiveMenu( );
+ if( menu )
+ /* Another window has an active menu, deactivate it */
+ fgDeactivateMenu( menu->ParentWindow );
+ return GL_TRUE;
/* No active menu, let's check whether we need to activate one. */
if( ( 0 <= button ) &&
( FREEGLUT_MAX_MENUS > button ) &&
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
Freeglut-developer mailing list