- /*
- * No active menu, let's check whether we need to activate one.
- */
- if (( 0 <= button ) && ( 2 >= button ) &&
- ( window->Menu[ button ] != NULL ) && ( pressed == TRUE ) )
- {
- /*
- * Let's make the window redraw as a result of the mouse click.
- */
- window->State.Redisplay = TRUE ;
-
- /*
- * Set the current window
- */
- fgSetWindow( window );
-
- /*
- * Activate the appropriate menu structure...
- */
- fgActivateMenu( window, button );
-
- break;
- }
-
- /*
- * Check if there is a mouse or mouse wheel callback hooked to the
- * window
- */
- if ( ( window->Callbacks.Mouse == NULL ) &&
- ( window->Callbacks.MouseWheel == NULL ) )
- break;
-
- fgSetWindow ( window );
-
- 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;
- fgStructure.Window->State.Modifiers = modifiers;
-
- /*
- * Finally execute the mouse or mouse wheel callback
- *
- * XXX Use a symbolic constant, *not* "4"!
- */
- if ( button < 4 )
- {
- fgStructure.Window->Callbacks.Mouse(
- button,
- event.type == ButtonPress ? GLUT_DOWN : GLUT_UP,
- event.xbutton.x,
- event.xbutton.y
- );
- }
- else
- {
- if ( window->Callbacks.MouseWheel )
- {
- /*
- * Map 4 and 5 to wheel zero; EVEN to +1, ODD to -1
- * " 6 and 7 " " one; ...
- *
- * XXX This *should* be behind some variables/macros,
- * XXX since the order and numbering isn't certain
- * XXX See XFree86 configuration docs (even back in the
- * XXX 3.x days, and especially with 4.x).
- */
- int wheel_number = (button - 4) / 2;
- int direction = (button & 1)*2 - 1;
-
- if( ButtonPress )
- fgStructure.Window->Callbacks.MouseWheel(
- wheel_number,
- direction,
- event.xbutton.x,
- event.xbutton.y
- );
- }
- else
- {
- fgStructure.Window->Callbacks.Mouse(
- button,
- event.type == ButtonPress ? GLUT_DOWN : GLUT_UP,
- event.xbutton.x,
- event.xbutton.y
- );
- }
- }
-
- /*
- * Trash the modifiers state
- */
- fgStructure.Window->State.Modifiers = 0xffffffff;
- }
- break;
-
- case KeyRelease:
- case KeyPress:
- {
- FGCBkeyboard keyboard_cb;
- FGCBspecial special_cb;
-
- /*
- * A key has been pressed, find the window that had the focus:
- */
- GETWINDOW( xkey );
- GETMOUSE( xkey );
-
- if( event.type == KeyPress )
- {
- keyboard_cb = window->Callbacks.Keyboard;
- special_cb = window->Callbacks.Special;
- }
- else