Moving the platform-specific window state fields into their own substructure
[freeglut] / src / Common / freeglut_main.c
index b1654a5..66281ea 100644 (file)
@@ -72,6 +72,7 @@ struct GXKeyList gxKeyList;
 \r
 extern void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height );\r
 extern void fgPlatformDisplayWindow ( SFG_Window *window );\r
+extern unsigned long fgPlatformSystemTime ( void );\r
 extern void fgPlatformSleepForEvents( long msec );\r
 extern void fgPlatformProcessSingleEvent ( void );\r
 extern void fgPlatformMainLoopPreliminaryWork ( void );\r
@@ -96,11 +97,11 @@ extern void fgPlatformMainLoopPreliminaryWork ( void );
  * match the new window size.\r
  */\r
 #if TARGET_HOST_POSIX_X11\r
-static void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height )\r
+void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height )\r
 {\r
-    XResizeWindow( fgDisplay.Display, window->Window.Handle,\r
+    XResizeWindow( fgDisplay.pDisplay.Display, window->Window.Handle,\r
                    width, height );\r
-    XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */\r
+    XFlush( fgDisplay.pDisplay.Display ); /* XXX Shouldn't need this */\r
 }\r
 #endif\r
 \r
@@ -170,10 +171,20 @@ void fghRedrawWindow ( SFG_Window *window )
  * A static helper function to execute display callback for a window\r
  */\r
 #if TARGET_HOST_POSIX_X11\r
-static void fgPlatformDisplayWindow ( SFG_Window *window )\r
+void fgPlatformDisplayWindow ( SFG_Window *window )\r
 {\r
         fghRedrawWindow ( window ) ;\r
 }\r
+\r
+\r
+unsigned long fgPlatformSystemTime ( void )\r
+{\r
+#if TARGET_HOST_SOLARIS || HAVE_GETTIMEOFDAY\r
+    struct timeval now;\r
+    gettimeofday( &now, NULL );\r
+    return now.tv_usec/1000 + now.tv_sec*1000;\r
+#endif\r
+}\r
 #endif\r
 \r
 static void fghcbDisplayWindow( SFG_Window *window,\r
@@ -262,18 +273,9 @@ static void fghCheckTimers( void )
  * when subtracting an initial start time, unless the total time exceeds\r
  * 32-bit, where the GLUT API return value is also overflowed.\r
  */  \r
-unsigned long fgSystemTime(void) {\r
-#if TARGET_HOST_SOLARIS || HAVE_GETTIMEOFDAY\r
-    struct timeval now;\r
-    gettimeofday( &now, NULL );\r
-    return now.tv_usec/1000 + now.tv_sec*1000;\r
-#elif TARGET_HOST_MS_WINDOWS\r
-#    if defined(_WIN32_WCE)\r
-    return GetTickCount();\r
-#    else\r
-    return timeGetTime();\r
-#    endif\r
-#endif\r
+unsigned long fgSystemTime(void)\r
+{\r
+       return fgPlatformSystemTime ();\r
 }\r
   \r
 /*\r
@@ -416,7 +418,7 @@ static long fghNextTimer( void )
  */\r
 \r
 #if TARGET_HOST_POSIX_X11\r
-static void fgPlatformSleepForEvents( long msec )\r
+void fgPlatformSleepForEvents( long msec )\r
 {\r
     /*\r
      * Possibly due to aggressive use of XFlush() and friends,\r
@@ -427,14 +429,14 @@ static void fgPlatformSleepForEvents( long msec )
      * need to allow that we may have an empty socket but non-\r
      * empty event queue.\r
      */\r
-    if( ! XPending( fgDisplay.Display ) )\r
+    if( ! XPending( fgDisplay.pDisplay.Display ) )\r
     {\r
         fd_set fdset;\r
         int err;\r
         int socket;\r
         struct timeval wait;\r
 \r
-        socket = ConnectionNumber( fgDisplay.Display );\r
+        socket = ConnectionNumber( fgDisplay.pDisplay.Display );\r
         FD_ZERO( &fdset );\r
         FD_SET( socket, &fdset );\r
         wait.tv_sec = msec / 1000;\r
@@ -943,9 +945,9 @@ void fgPlatformProcessSingleEvent ( void )
 \r
     FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoopEvent" );\r
 \r
-    while( XPending( fgDisplay.Display ) )\r
+    while( XPending( fgDisplay.pDisplay.Display ) )\r
     {\r
-        XNextEvent( fgDisplay.Display, &event );\r
+        XNextEvent( fgDisplay.pDisplay.Display, &event );\r
 #if _DEBUG\r
         fghPrintEvent( &event );\r
 #endif\r
@@ -958,7 +960,7 @@ void fgPlatformProcessSingleEvent ( void )
                 break;\r
             }\r
             /* Destroy the window when the WM_DELETE_WINDOW message arrives */\r
-            if( (Atom) event.xclient.data.l[ 0 ] == fgDisplay.DeleteWindow )\r
+            if( (Atom) event.xclient.data.l[ 0 ] == fgDisplay.pDisplay.DeleteWindow )\r
             {\r
                 GETWINDOW( xclient );\r
 \r
@@ -999,13 +1001,13 @@ void fgPlatformProcessSingleEvent ( void )
                     height = event.xconfigure.height;\r
                 }\r
 \r
-                if( ( width != window->State.OldWidth ) ||\r
-                    ( height != window->State.OldHeight ) )\r
+                if( ( width != window->State.pWState.OldWidth ) ||\r
+                    ( height != window->State.pWState.OldHeight ) )\r
                 {\r
                     SFG_Window *current_window = fgStructure.CurrentWindow;\r
 \r
-                    window->State.OldWidth = width;\r
-                    window->State.OldHeight = height;\r
+                    window->State.pWState.OldWidth = width;\r
+                    window->State.pWState.OldHeight = height;\r
                     if( FETCH_WCB( *window, Reshape ) )\r
                         INVOKE_WCB( *window, Reshape, ( width, height ) );\r
                     else\r
@@ -1256,7 +1258,7 @@ void fgPlatformProcessSingleEvent ( void )
                      */\r
 \r
                     char keys[32];\r
-                    XQueryKeymap( fgDisplay.Display, keys ); /* Look at X11 keystate to detect repeat mode */\r
+                    XQueryKeymap( fgDisplay.pDisplay.Display, keys ); /* Look at X11 keystate to detect repeat mode */\r
 \r
                     if ( event.xkey.keycode<256 )            /* XQueryKeymap is limited to 256 keycodes    */\r
                     {\r
@@ -1405,7 +1407,7 @@ void fgPlatformProcessSingleEvent ( void )
 }\r
 \r
 \r
-static void fgPlatformMainLoopPreliminaryWork ( void )\r
+void fgPlatformMainLoopPreliminaryWork ( void )\r
 {\r
 }\r
 #endif\r