- window->Callbacks.Passive( event.xmotion.x, event.xmotion.y );
- }
- }
- }
- break;
-
- case ButtonRelease:
- case ButtonPress:
- {
- GLboolean pressed = TRUE ;
- int button;
-
- if ( event.type == ButtonRelease ) pressed = FALSE ;
-
- /*
- * A mouse button has been pressed or released. Traditionally,
- * break if the window was found within the freeglut structures.
- */
- GETWINDOW( xbutton ); GETMOUSE( xbutton );
-
- /*
- * An X button (at least in XFree86) is numbered from 1.
- * A GLUT button is numbered from 0.
- * Old GLUT passed through buttons other than just the first
- * three, though it only gave symbolic names and official
- * support to the first three.
- *
- */
- button = event.xbutton.button - 1;
-
- /*
- * Do not execute the application's mouse callback if a menu is hooked to this button.
- * In that case an appropriate private call should be generated.
- * Near as I can tell, this is the menu behaviour:
- * - Down-click the menu button, menu not active: activate the menu with its upper left-hand corner at the mouse location.
- * - Down-click any button outside the menu, menu active: deactivate the menu
- * - Down-click any button inside the menu, menu active: select the menu entry and deactivate the menu
- * - Up-click the menu button, menu not active: nothing happens
- * - Up-click the menu button outside the menu, menu active: nothing happens
- * - Up-click the menu button inside the menu, menu active: select the menu entry and deactivate the menu
- */
- if ( window->ActiveMenu != NULL ) /* Window has an active menu, it absorbs any mouse click */
- {
- if ( window == window->ActiveMenu->ParentWindow )
- {
- window->ActiveMenu->Window->State.MouseX = event.xbutton.x_root - window->ActiveMenu->X ;
- window->ActiveMenu->Window->State.MouseY = event.xbutton.y_root - window->ActiveMenu->Y ;
- }
-
- if ( fgCheckActiveMenu ( window->ActiveMenu->Window, window->ActiveMenu ) == TRUE ) /* Inside the menu, invoke the callback and deactivate the menu*/
- {
- /* Save the current window and menu and set the current window to the window whose menu this is */
- SFG_Window *save_window = fgStructure.Window ;
- SFG_Menu *save_menu = fgStructure.Menu ;
- SFG_Window *parent_window = window->ActiveMenu->ParentWindow ;
- fgSetWindow ( parent_window ) ;
- fgStructure.Menu = window->ActiveMenu ;
-
- /* Execute the menu callback */
- fgExecuteMenuCallback ( window->ActiveMenu ) ;
- fgDeactivateMenu ( parent_window ) ;
-
- /* Restore the current window and menu */
- fgSetWindow ( save_window ) ;
- fgStructure.Menu = save_menu ;
- }
- else /* Outside the menu, deactivate the menu if it's a downclick */
- {
- if ( pressed == TRUE ) fgDeactivateMenu ( window->ActiveMenu->ParentWindow ) ;
- }
-
- /*
- * Let's make the window redraw as a result of the mouse click and menu activity.
- */
- window->State.Redisplay = TRUE ;
-
- break ;
- }