- /*
- * Skip the unwanted mouse buttons...
- */
- if( button == -1 )
- break;
-
- /*
- * 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 ( fgCheckActiveMenu ( 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 ;
- fgSetWindow ( window ) ;
- fgStructure.Menu = window->ActiveMenu ;
-
- /* Execute the menu callback */
- fgExecuteMenuCallback ( window->ActiveMenu ) ;
- fgDeactivateMenu ( 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 ) ;
- }
-
- /*
- * Let's make the window redraw as a result of the mouse click and menu activity.
- */
- window->State.Redisplay = TRUE ;
-
- break ;
- }
-
- /*
- * No active menu, let's check whether we need to activate one.
- */
- if ( ( window->Menu[ button ] != NULL ) && ( pressed == TRUE ) )
- {
- /*
- * Let's make the window redraw as a result of the mouse click.
- */
- window->State.Redisplay = TRUE ;
-
- /*
- * Activate the appropriate menu structure...
- */
- fgActivateMenu( window, button );
-
- break;
- }
-
- /*
- * Check if there is a mouse callback hooked to the window
- */
- if( window->Callbacks.Mouse == NULL )
- break;
-
- /*
- * Set the current window
- */
- fgSetWindow( window );
-
- /*
- * Remember the current modifiers state
- */
- modifiers = 0;
- if (event.xbutton.state & (ShiftMask|LockMask))
- modifiers |= GLUT_ACTIVE_SHIFT;
- if (event.xbutton.state & ControlMask)
- modifiers |= GLUT_ACTIVE_CTRL;
- if (event.xbutton.state & Mod1Mask)
- modifiers |= GLUT_ACTIVE_ALT;
- window->State.Modifiers = modifiers;
-
- /*
- * Finally execute the mouse callback
- */
- window->Callbacks.Mouse(
- button,
- event.type == ButtonPress ? GLUT_DOWN : GLUT_UP,
- event.xbutton.x,
- event.xbutton.y
- );
-
- /*
- * Trash the modifiers state
- */
- window->State.Modifiers = 0xffffffff;
- }
- break;
-
- case KeyRelease:
- case KeyPress:
- {
- FGCBkeyboard keyboard_cb;
- FGCBspecial special_cb;