Added support for more arbitrary number of mouse buttons (though only the
first three can work with menus), in X. This closes a compatibility gap with old GLUT, and leaves us the option of supporting scroll-wheels properly. git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@210 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
e7a43013d4
commit
7a6c02639a
@ -824,26 +824,15 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
|||||||
*/
|
*/
|
||||||
GETWINDOW( xbutton ); GETMOUSE( xbutton );
|
GETWINDOW( xbutton ); GETMOUSE( xbutton );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GLUT API assumes that you can't have more than three mouse buttons, so:
|
* An X button (at least in XFree86) is numbered from 1.
|
||||||
*/
|
* A GLUT button is numbered from 0.
|
||||||
switch( event.xbutton.button )
|
* Old GLUT passed through buttons other than just the first
|
||||||
{
|
* three, though it only gave symbolic names and official
|
||||||
/*
|
* support to the first three.
|
||||||
* WARNING: this might be wrong, if we only have two mouse buttons,
|
*
|
||||||
* Button2 might mean the right button, isn't that right?
|
*/
|
||||||
*/
|
button = event.xbutton.button - 1;
|
||||||
case Button1: button = GLUT_LEFT_BUTTON; break;
|
|
||||||
case Button2: button = GLUT_MIDDLE_BUTTON; break;
|
|
||||||
case Button3: button = GLUT_RIGHT_BUTTON; break;
|
|
||||||
default: button = -1; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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.
|
* Do not execute the application's mouse callback if a menu is hooked to this button.
|
||||||
@ -891,7 +880,8 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
|||||||
/*
|
/*
|
||||||
* No active menu, let's check whether we need to activate one.
|
* No active menu, let's check whether we need to activate one.
|
||||||
*/
|
*/
|
||||||
if ( ( window->Menu[ button ] != NULL ) && ( pressed == TRUE ) )
|
if (( 0 <= button ) && ( 2 >= button ) &&
|
||||||
|
( window->Menu[ button ] != NULL ) && ( pressed == TRUE ) )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Let's make the window redraw as a result of the mouse click.
|
* Let's make the window redraw as a result of the mouse click.
|
||||||
|
Reference in New Issue
Block a user