X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffg_internal.h;h=a61b121882ae9df0b162bbda3702515549f928d6;hb=3f8ec7f3669e36c22c669dfa9d2f3a186335b34a;hp=bce77ca09e6fb8b823dc41a9d2e564bd552e5924;hpb=753583368738a67f00d8f27adb1c8b6cff4bdfd3;p=freeglut diff --git a/src/fg_internal.h b/src/fg_internal.h index bce77ca..a61b121 100644 --- a/src/fg_internal.h +++ b/src/fg_internal.h @@ -577,6 +577,12 @@ typedef void (*SFG_Proc)(); * The {if( FETCH_WCB( ... ) != func )} test is to do type-checking * and for no other reason. Since it's hidden in the macro, the * ugliness is felt to be rather benign. + * + * If the function-pointer is the same, the data will be the only + * value updated. If the function-pointer changes, the data will + * be changed as well, preventing stail data from being passed in. + * Just updating the data does nothing unless a function-pointer + * exists, as the data is otherwise already allocated. */ #define SET_WCB(window,cbname,func,udata) \ do \ @@ -586,6 +592,10 @@ do \ (((window).CallBacks[WCB_ ## cbname]) = (SFG_Proc)(func)); \ (((window).CallbackDatas[WCB_ ## cbname]) = (udata)); \ } \ + else if( FETCH_USER_DATA_WCB( window, cbname ) != udata ) \ + { \ + (((window).CallbackDatas[WCB_ ## cbname]) = (udata)); \ + } \ } while( 0 ) /* @@ -611,14 +621,6 @@ do \ * {cbname} is the window-specific callback to be invoked, * * This expects a variable named "window" of type tagSFG_Window to exist. - */ -/* - * FETCH_USER_DATA_WCB() is used as: - * - * FETCH_USER_DATA_WCB( window, cbname ); - * - * ...where {window} is the freeglut window to fetch the callback data from, - * {cbname} is the window-specific callback data to fetch. * * The result is the callback data pointer. */ @@ -663,7 +665,6 @@ do \ * current window. * */ -#if TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE) /* FIXME: also WinCE? */ #define INVOKE_WCB(window,cbname,arg_list) \ do \ { \ @@ -675,18 +676,6 @@ do \ func EXPAND_WCB( cbname )(( arg_list, userData )); \ } \ } while( 0 ) -#else -#define INVOKE_WCB(window,cbname,arg_list) \ -do \ -{ \ - if( FETCH_WCB( window, cbname ) ) \ - { \ - fgSetWindow( &window ); \ - FGCBUserData userData = FETCH_USER_DATA_WCB( window, cbname ); \ - ((FGCB ## cbname ## UC)FETCH_WCB( window, cbname )) EXPAND_WCB( cbname )(( arg_list, userData )); \ - } \ -} while( 0 ) -#endif /* * The window callbacks the user can supply us with. Should be kept portable.