Merge remote-tracking branch 'svn/trunk' into git_master

This commit is contained in:
Diederick C. Niehorster 2018-10-10 08:18:27 +02:00
commit 9ea7d99574

View File

@ -807,11 +807,8 @@ void fgPlatformProcessSingleEvent ( void )
case ButtonRelease: case ButtonRelease:
case ButtonPress: case ButtonPress:
{ {
GLboolean pressed = GL_TRUE; GLboolean pressed;
int button; int button, x, y;
if( event.type == ButtonRelease )
pressed = GL_FALSE ;
/* /*
* A mouse button has been pressed or released. Traditionally, * A mouse button has been pressed or released. Traditionally,
@ -829,59 +826,46 @@ void fgPlatformProcessSingleEvent ( void )
*/ */
button = event.xbutton.button - 1; button = event.xbutton.button - 1;
pressed = event.type == ButtonPress ? GL_TRUE : GL_FALSE;
x = event.xbutton.x;
y = event.xbutton.y;
/* /*
* Do not execute the application's mouse callback if a menu * Do not execute the application's mouse callback if a menu
* is hooked to this button. In that case an appropriate * is hooked to this button. In that case an appropriate
* private call should be generated. * private call should be generated.
*/ */
if( fgCheckActiveMenu( window, button, pressed, if(fgCheckActiveMenu( window, button, pressed, x, y))
event.xbutton.x, event.xbutton.y ) )
break; break;
/* /*
* Check if there is a mouse or mouse wheel callback hooked to the * Check if there is a mouse or mouse wheel callback hooked to the
* window * window
*/ */
if( ! FETCH_WCB( *window, Mouse ) && if(!FETCH_WCB(*window, Mouse) && !FETCH_WCB(*window, MouseWheel))
! FETCH_WCB( *window, MouseWheel ) )
break; break;
fgState.Modifiers = fgPlatformGetModifiers( event.xbutton.state ); fgState.Modifiers = fgPlatformGetModifiers(event.xbutton.state);
/* Finally execute the mouse or mouse wheel callback */ /* Finally execute the mouse or mouse wheel callback.
if( ( button < glutDeviceGet ( GLUT_NUM_MOUSE_BUTTONS ) ) || ( ! FETCH_WCB( *window, MouseWheel ) ) ) * The mouse wheel is reported as buttons 4 (down) and 5 (up) by
INVOKE_WCB( *window, Mouse, ( button, * the X server. "button" has been converted to 0-based above, so
pressed ? GLUT_DOWN : GLUT_UP, * that's 3 and 4 for us.
event.xbutton.x, * If a wheel callback hasn't been registered, we simply treat them
event.xbutton.y ) * as button presses and pass them to the mouse handler. This is
); * important for compatibility with the original GLUT.
else */
{ if(button < 3 || button > 4 || !FETCH_WCB(*window, MouseWheel)) {
/* INVOKE_WCB(*window, Mouse, (button, pressed ? GLUT_DOWN : GLUT_UP, x, y));
* Map 4 and 5 to wheel zero; EVEN to +1, ODD to -1 } else {
* " 6 and 7 " " one; ... if(pressed) {
* int dir = button & 1 ? 1 : -1;
* XXX This *should* be behind some variables/macros, /* there's no way to know if X buttons after 5 are more
* XXX since the order and numbering isn't certain * wheels/wheel axes, or regular buttons. So we'll only
* XXX See XFree86 configuration docs (even back in the * ever invoke the wheel CB for wheel 0.
* XXX 3.x days, and especially with 4.x). */
* INVOKE_WCB(*window, MouseWheel, (0, dir, x, y));
* XXX Note that {button} has already been decremented }
* XXX in mapping from X button numbering to GLUT.
*
* XXX Should add support for partial wheel turns as Windows does -- 5/27/11
*/
int wheel_number = (button - glutDeviceGet ( GLUT_NUM_MOUSE_BUTTONS )) / 2;
int direction = -1;
if( button % 2 )
direction = 1;
if( pressed )
INVOKE_WCB( *window, MouseWheel, ( wheel_number,
direction,
event.xbutton.x,
event.xbutton.y )
);
} }
fgState.Modifiers = INVALID_MODIFIERS; fgState.Modifiers = INVALID_MODIFIERS;
} }