Handle modifiers in MotionNotify events, too. This fixes bug #1227920
(glutGetModifiers not set/allowed in mouse callbacks). In addition, some related cleanup has been done. git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@661 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
4e334977a1
commit
c4c3661612
@ -1092,3 +1092,7 @@ linking troubles for the examples.
|
|||||||
fixes bug #961938 (Executable bit set on non exe files).
|
fixes bug #961938 (Executable bit set on non exe files).
|
||||||
|
|
||||||
(283) Partial fixes for bug #1218900 (freeglut-2.4.0 on FreeBSD).
|
(283) Partial fixes for bug #1218900 (freeglut-2.4.0 on FreeBSD).
|
||||||
|
|
||||||
|
(284) Handle modifiers in MotionNotify events, too. This fixes bug
|
||||||
|
#1227920 (glutGetModifiers not set/allowed in mouse callbacks). In
|
||||||
|
addition, some related cleanup has been done.
|
||||||
|
@ -61,7 +61,7 @@ SFG_State fgState = { { -1, -1, GL_FALSE }, /* Position */
|
|||||||
GL_FALSE, /* GLDebugSwitch */
|
GL_FALSE, /* GLDebugSwitch */
|
||||||
GL_FALSE, /* XSyncSwitch */
|
GL_FALSE, /* XSyncSwitch */
|
||||||
GLUT_KEY_REPEAT_ON, /* KeyRepeat */
|
GLUT_KEY_REPEAT_ON, /* KeyRepeat */
|
||||||
0xffffffff, /* Modifiers */
|
INVALID_MODIFIERS, /* Modifiers */
|
||||||
0, /* FPSInterval */
|
0, /* FPSInterval */
|
||||||
0, /* SwapCount */
|
0, /* SwapCount */
|
||||||
0, /* SwapTime */
|
0, /* SwapTime */
|
||||||
@ -274,7 +274,7 @@ void fgDeinitialize( void )
|
|||||||
fgState.ExecState = GLUT_EXEC_STATE_INIT;
|
fgState.ExecState = GLUT_EXEC_STATE_INIT;
|
||||||
|
|
||||||
fgState.KeyRepeat = GLUT_KEY_REPEAT_ON;
|
fgState.KeyRepeat = GLUT_KEY_REPEAT_ON;
|
||||||
fgState.Modifiers = 0xffffffff;
|
fgState.Modifiers = INVALID_MODIFIERS;
|
||||||
|
|
||||||
fgState.GameModeSize.X = 640;
|
fgState.GameModeSize.X = 640;
|
||||||
fgState.GameModeSize.Y = 480;
|
fgState.GameModeSize.Y = 480;
|
||||||
|
@ -126,6 +126,8 @@ LONG WINAPI ChangeDisplaySettingsExW(LPCWSTR,LPDEVMODEW,HWND,DWORD,LPVOID);
|
|||||||
# define FALSE 0
|
# define FALSE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define INVALID_MODIFIERS 0xffffffff
|
||||||
|
|
||||||
/* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */
|
/* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */
|
||||||
|
|
||||||
/* Freeglut callbacks type definitions */
|
/* Freeglut callbacks type definitions */
|
||||||
|
@ -495,17 +495,17 @@ static void fghSleepForEvents( void )
|
|||||||
|
|
||||||
#if TARGET_HOST_UNIX_X11
|
#if TARGET_HOST_UNIX_X11
|
||||||
/*
|
/*
|
||||||
* Returns GLUT modifier mask for an XEvent.
|
* Returns GLUT modifier mask for the state field of an X11 event.
|
||||||
*/
|
*/
|
||||||
static int fghGetXModifiers( XEvent *event )
|
static int fghGetXModifiers( int state )
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if( event->xkey.state & ( ShiftMask | LockMask ) )
|
if( state & ( ShiftMask | LockMask ) )
|
||||||
ret |= GLUT_ACTIVE_SHIFT;
|
ret |= GLUT_ACTIVE_SHIFT;
|
||||||
if( event->xkey.state & ControlMask )
|
if( state & ControlMask )
|
||||||
ret |= GLUT_ACTIVE_CTRL;
|
ret |= GLUT_ACTIVE_CTRL;
|
||||||
if( event->xkey.state & Mod1Mask )
|
if( state & Mod1Mask )
|
||||||
ret |= GLUT_ACTIVE_ALT;
|
ret |= GLUT_ACTIVE_ALT;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -1181,14 +1181,15 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
|||||||
* XXX track ButtonPress/ButtonRelease events in our own
|
* XXX track ButtonPress/ButtonRelease events in our own
|
||||||
* XXX bit-mask?
|
* XXX bit-mask?
|
||||||
*/
|
*/
|
||||||
#define BUTTON_MASK \
|
fgState.Modifiers = fghGetXModifiers( event.xmotion.state );
|
||||||
( Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask )
|
if ( event.xmotion.state & ( Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask ) ) {
|
||||||
if ( event.xmotion.state & BUTTON_MASK )
|
|
||||||
INVOKE_WCB( *window, Motion, ( event.xmotion.x,
|
INVOKE_WCB( *window, Motion, ( event.xmotion.x,
|
||||||
event.xmotion.y ) );
|
event.xmotion.y ) );
|
||||||
else
|
} else {
|
||||||
INVOKE_WCB( *window, Passive, ( event.xmotion.x,
|
INVOKE_WCB( *window, Passive, ( event.xmotion.x,
|
||||||
event.xmotion.y ) );
|
event.xmotion.y ) );
|
||||||
|
}
|
||||||
|
fgState.Modifiers = INVALID_MODIFIERS;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1234,7 +1235,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
|||||||
! FETCH_WCB( *window, MouseWheel ) )
|
! FETCH_WCB( *window, MouseWheel ) )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
fgState.Modifiers = fghGetXModifiers( &event );
|
fgState.Modifiers = fghGetXModifiers( 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 ) ) )
|
if( ( button < glutDeviceGet ( GLUT_NUM_MOUSE_BUTTONS ) ) || ( ! FETCH_WCB( *window, MouseWheel ) ) )
|
||||||
@ -1269,9 +1270,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
|||||||
event.xbutton.y )
|
event.xbutton.y )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
fgState.Modifiers = INVALID_MODIFIERS;
|
||||||
/* Trash the modifiers state */
|
|
||||||
fgState.Modifiers = 0xffffffff;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1346,11 +1345,11 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
|||||||
if( keyboard_cb )
|
if( keyboard_cb )
|
||||||
{
|
{
|
||||||
fgSetWindow( window );
|
fgSetWindow( window );
|
||||||
fgState.Modifiers = fghGetXModifiers( &event );
|
fgState.Modifiers = fghGetXModifiers( event.xkey.state );
|
||||||
keyboard_cb( asciiCode[ 0 ],
|
keyboard_cb( asciiCode[ 0 ],
|
||||||
event.xkey.x, event.xkey.y
|
event.xkey.x, event.xkey.y
|
||||||
);
|
);
|
||||||
fgState.Modifiers = 0xffffffff;
|
fgState.Modifiers = INVALID_MODIFIERS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1400,9 +1399,9 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
|||||||
if( special_cb && (special != -1) )
|
if( special_cb && (special != -1) )
|
||||||
{
|
{
|
||||||
fgSetWindow( window );
|
fgSetWindow( window );
|
||||||
fgState.Modifiers = fghGetXModifiers( &event );
|
fgState.Modifiers = fghGetXModifiers( event.xkey.state );
|
||||||
special_cb( special, event.xkey.x, event.xkey.y );
|
special_cb( special, event.xkey.x, event.xkey.y );
|
||||||
fgState.Modifiers = 0xffffffff;
|
fgState.Modifiers = INVALID_MODIFIERS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1771,7 +1770,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
|||||||
INVOKE_WCB( *window, Passive, ( window->State.MouseX,
|
INVOKE_WCB( *window, Passive, ( window->State.MouseX,
|
||||||
window->State.MouseY ) );
|
window->State.MouseY ) );
|
||||||
|
|
||||||
fgState.Modifiers = 0xffffffff;
|
fgState.Modifiers = INVALID_MODIFIERS;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1881,7 +1880,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
fgState.Modifiers = 0xffffffff;
|
fgState.Modifiers = INVALID_MODIFIERS;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1948,7 +1947,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fgState.Modifiers = 0xffffffff;
|
fgState.Modifiers = INVALID_MODIFIERS;
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
@ -2035,7 +2034,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
|||||||
window->State.MouseX, window->State.MouseY )
|
window->State.MouseX, window->State.MouseY )
|
||||||
);
|
);
|
||||||
|
|
||||||
fgState.Modifiers = 0xffffffff;
|
fgState.Modifiers = INVALID_MODIFIERS;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2118,7 +2117,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
|||||||
window->State.MouseX, window->State.MouseY )
|
window->State.MouseX, window->State.MouseY )
|
||||||
);
|
);
|
||||||
|
|
||||||
fgState.Modifiers = 0xffffffff;
|
fgState.Modifiers = INVALID_MODIFIERS;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2133,7 +2132,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
|||||||
( (char)wParam,
|
( (char)wParam,
|
||||||
window->State.MouseX, window->State.MouseY )
|
window->State.MouseX, window->State.MouseY )
|
||||||
);
|
);
|
||||||
fgState.Modifiers = 0xffffffff;
|
fgState.Modifiers = INVALID_MODIFIERS;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -579,7 +579,7 @@ int FGAPIENTRY glutDeviceGet( GLenum eWhat )
|
|||||||
int FGAPIENTRY glutGetModifiers( void )
|
int FGAPIENTRY glutGetModifiers( void )
|
||||||
{
|
{
|
||||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetModifiers" );
|
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetModifiers" );
|
||||||
if( fgState.Modifiers == 0xffffffff )
|
if( fgState.Modifiers == INVALID_MODIFIERS )
|
||||||
{
|
{
|
||||||
fgWarning( "glutGetModifiers() called outside an input callback" );
|
fgWarning( "glutGetModifiers() called outside an input callback" );
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user