Fixed x11 and Wayland not using INVOKE_WCB

...since INVOKE_WCB handled user data. Now they handle user data.

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1823 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
dcnieho 2017-06-30 23:22:45 +00:00
parent 850d80554a
commit cc6830131a
2 changed files with 29 additions and 16 deletions

View File

@ -71,8 +71,10 @@ void fghKeyboardInterpretKeysym( SFG_Window* window,
xkb_keysym_t sym, xkb_keysym_t sym,
uint32_t state ) uint32_t state )
{ {
FGCBKeyboard keyboard_cb; FGCBKeyboardUC keyboard_cb;
FGCBSpecial special_cb; FGCBSpecialUC special_cb;
FGCBUserData keyboard_ud;
FGCBUserData special_ud;
char string[16]; char string[16];
int special = -1; int special = -1;
@ -81,13 +83,17 @@ void fghKeyboardInterpretKeysym( SFG_Window* window,
* others, which need to be translated to GLUT_KEY_Xs... */ * others, which need to be translated to GLUT_KEY_Xs... */
if( state ) if( state )
{ {
keyboard_cb = (FGCBKeyboard)( FETCH_WCB( *window, Keyboard )); keyboard_cb = (FGCBKeyboardUC)( FETCH_WCB( *window, Keyboard ));
special_cb = (FGCBSpecial) ( FETCH_WCB( *window, Special )); special_cb = (FGCBSpecialUC) ( FETCH_WCB( *window, Special ));
keyboard_ud = FETCH_USER_DATA_WCB( *window, Keyboard );
special_ud = FETCH_USER_DATA_WCB( *window, Special );
} }
else else
{ {
keyboard_cb = (FGCBKeyboard)( FETCH_WCB( *window, KeyboardUp )); keyboard_cb = (FGCBKeyboardUC)( FETCH_WCB( *window, KeyboardUp ));
special_cb = (FGCBSpecial) ( FETCH_WCB( *window, SpecialUp )); special_cb = (FGCBSpecialUC) ( FETCH_WCB( *window, SpecialUp ));
keyboard_ud = FETCH_USER_DATA_WCB( *window, KeyboardUp );
special_ud = FETCH_USER_DATA_WCB( *window, SpecialUp );
} }
switch( sym ) switch( sym )
@ -127,13 +133,13 @@ void fghKeyboardInterpretKeysym( SFG_Window* window,
if( special_cb && (special != -1) ) if( special_cb && (special != -1) )
{ {
fgSetWindow( window ); fgSetWindow( window );
special_cb( special, window->State.MouseX, window->State.MouseY ); special_cb( special, window->State.MouseX, window->State.MouseY, special_ud );
} }
else if( keyboard_cb && (special == -1) ) else if( keyboard_cb && (special == -1) )
{ {
fgSetWindow( window ); fgSetWindow( window );
xkb_keysym_to_utf8( sym, string, sizeof( string ) ); xkb_keysym_to_utf8( sym, string, sizeof( string ) );
keyboard_cb( string[0], window->State.MouseX, window->State.MouseY ); keyboard_cb( string[0], window->State.MouseX, window->State.MouseY, keyboard_ud );
} }
} }

View File

@ -890,8 +890,10 @@ void fgPlatformProcessSingleEvent ( void )
case KeyRelease: case KeyRelease:
case KeyPress: case KeyPress:
{ {
FGCBKeyboard keyboard_cb; FGCBKeyboardUC keyboard_cb;
FGCBSpecial special_cb; FGCBSpecialUC special_cb;
FGCBUserData keyboard_ud;
FGCBUserData special_ud;
GETWINDOW( xkey ); GETWINDOW( xkey );
GETMOUSE( xkey ); GETMOUSE( xkey );
@ -932,13 +934,17 @@ void fgPlatformProcessSingleEvent ( void )
if( event.type == KeyPress ) if( event.type == KeyPress )
{ {
keyboard_cb = (FGCBKeyboard)( FETCH_WCB( *window, Keyboard )); keyboard_cb = (FGCBKeyboardUC)( FETCH_WCB( *window, Keyboard ));
special_cb = (FGCBSpecial) ( FETCH_WCB( *window, Special )); special_cb = (FGCBSpecialUC) ( FETCH_WCB( *window, Special ));
keyboard_ud = FETCH_USER_DATA_WCB( *window, Keyboard );
special_ud = FETCH_USER_DATA_WCB( *window, Special );
} }
else else
{ {
keyboard_cb = (FGCBKeyboard)( FETCH_WCB( *window, KeyboardUp )); keyboard_cb = (FGCBKeyboardUC)( FETCH_WCB( *window, KeyboardUp ));
special_cb = (FGCBSpecial) ( FETCH_WCB( *window, SpecialUp )); special_cb = (FGCBSpecialUC) ( FETCH_WCB( *window, SpecialUp ));
keyboard_ud = FETCH_USER_DATA_WCB( *window, KeyboardUp );
special_ud = FETCH_USER_DATA_WCB( *window, SpecialUp );
} }
/* Is there a keyboard/special callback hooked for this window? */ /* Is there a keyboard/special callback hooked for this window? */
@ -963,7 +969,8 @@ void fgPlatformProcessSingleEvent ( void )
fgSetWindow( window ); fgSetWindow( window );
fgState.Modifiers = fgPlatformGetModifiers( event.xkey.state ); fgState.Modifiers = fgPlatformGetModifiers( event.xkey.state );
keyboard_cb( asciiCode[ 0 ], keyboard_cb( asciiCode[ 0 ],
event.xkey.x, event.xkey.y event.xkey.x, event.xkey.y,
keyboard_ud
); );
fgState.Modifiers = INVALID_MODIFIERS; fgState.Modifiers = INVALID_MODIFIERS;
} }
@ -1031,7 +1038,7 @@ void fgPlatformProcessSingleEvent ( void )
{ {
fgSetWindow( window ); fgSetWindow( window );
fgState.Modifiers = fgPlatformGetModifiers( event.xkey.state ); fgState.Modifiers = fgPlatformGetModifiers( event.xkey.state );
special_cb( special, event.xkey.x, event.xkey.y ); special_cb( special, event.xkey.x, event.xkey.y, special_ud );
fgState.Modifiers = INVALID_MODIFIERS; fgState.Modifiers = INVALID_MODIFIERS;
} }
} }