Corrected phrasing in docs and unneeded \ in code
[freeglut] / src / fg_internal.h
index bce77ca..a95027b 100644 (file)
@@ -291,7 +291,7 @@ typedef void (* FGCBAppStatus       )( int );
 typedef void (* FGCBAppStatusUC     )( int, FGCBUserData );
 
 /* The global callbacks type definitions */
-typedef void (* FGCBIdle            )( void ); \
+typedef void (* FGCBIdle            )( void );
 typedef void (* FGCBIdleUC          )( FGCBUserData );
 typedef void (* FGCBTimer           )( int );
 typedef void (* FGCBTimerUC         )( int, FGCBUserData );
@@ -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.