Added keyup events code.
[freeglut] / freeglut-1.3 / freeglut_window.c
index 5cd3876..943b027 100644 (file)
 #if TARGET_HOST_UNIX_X11
 XVisualInfo* fgChooseVisual( void )
 {
-    gint bufferSize[] = { 16, 12, 8, 4, 2, 1 };
-    gboolean wantIndexedMode = FALSE;
-    gint attributes[ 32 ];
-    gint where = 0;
+    int bufferSize[] = { 16, 12, 8, 4, 2, 1 };
+    GLboolean wantIndexedMode = FALSE;
+    int attributes[ 32 ];
+    int where = 0;
 
     /*
      * First we have to process the display mode settings...
@@ -214,10 +214,10 @@ XVisualInfo* fgChooseVisual( void )
  * Setup the pixel format for a Win32 window
  */
 #if TARGET_HOST_WIN32
-gboolean fgSetupPixelFormat( SFG_Window* window, gboolean checkOnly )
+GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly )
 {
        PIXELFORMATDESCRIPTOR* ppfd, pfd;
-       gint flags, pixelformat;
+       int flags, pixelformat;
 
        /*
         * Check if the window seems valid
@@ -300,14 +300,14 @@ gboolean fgSetupPixelFormat( SFG_Window* window, gboolean checkOnly )
  * Opens a window. Requires a SFG_Window object created and attached
  * to the freeglut structure. OpenGL context is created here.
  */
-void fgOpenWindow( SFG_Window* window, const gchar* title, gint x, gint y, gint w, gint h, gboolean gameMode )
+void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, int h, GLboolean gameMode )
 {
 #if TARGET_HOST_UNIX_X11
     XSetWindowAttributes winAttr;
     XTextProperty textProperty;
     XSizeHints sizeHints;
     XWMHints wmHints;
-    guint32 mask;
+    unsigned long mask;
 
     freeglut_assert_ready;
 
@@ -315,7 +315,7 @@ void fgOpenWindow( SFG_Window* window, const gchar* title, gint x, gint y, gint
      * Here we are upon the stage. Have the visual selected.
      */
     window->Window.VisualInfo = fgChooseVisual();
-    g_assert( window->Window.VisualInfo != NULL );
+    assert( window->Window.VisualInfo != NULL );
 
     /*
      * Have the windows attributes set
@@ -324,7 +324,7 @@ void fgOpenWindow( SFG_Window* window, const gchar* title, gint x, gint y, gint
      *       This might speed up message processing. Is that true?
      */
     winAttr.event_mask        = StructureNotifyMask | SubstructureNotifyMask | ExposureMask |
-                                ButtonPressMask | ButtonReleaseMask | KeyPressMask |
+                                ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyRelease |
                                 VisibilityChangeMask | EnterWindowMask | LeaveWindowMask |
                                 PointerMotionMask | ButtonMotionMask;
     winAttr.background_pixmap = None;
@@ -368,7 +368,7 @@ void fgOpenWindow( SFG_Window* window, const gchar* title, gint x, gint y, gint
      * Make sure the context is direct when the user wants it forced
      */
     if( fgState.ForceDirectContext && !glXIsDirect( fgDisplay.Display, window->Window.Context ) )
-        g_error( "unable to force direct context rendering for window '%s'", title );
+        fgError( "unable to force direct context rendering for window '%s'", title );
 
     /*
      * Set the new context as the current one. That's all about the window creation.
@@ -389,8 +389,8 @@ void fgOpenWindow( SFG_Window* window, const gchar* title, gint x, gint y, gint
      */
     sizeHints.flags = 0;
 
-    sizeHints.flags |= (fgState.Position.Use == TRUE) ? USPosition : PPosition;
-    sizeHints.flags |= (fgState.Size.Use     == TRUE) ? USSize     : PSize;
+    if (fgState.Position.Use == TRUE) sizeHints.flags |= USPosition;
+    if (fgState.Size.Use     == TRUE) sizeHints.flags |= USSize;
 
     /*
      * Fill in the size hints values now (the x, y, width and height
@@ -436,16 +436,16 @@ void fgOpenWindow( SFG_Window* window, const gchar* title, gint x, gint y, gint
     XMapWindow( fgDisplay.Display, window->Window.Handle );
 
     /*
-     * This somehow fixes the glutGet() GLUT_WINDOW_X and GLUT_WINDOW_Y problem...
-     */
-    XMoveWindow( fgDisplay.Display, window->Window.Handle, x, y );
-
-    /*
      * In game mode, move the viewport a bit to hide the decorations.
      * This code depends on the XFree86 video mode extensions.
      */
     if( gameMode == TRUE )
     {
+        /*
+         * This somehow fixes the glutGet() GLUT_WINDOW_X and GLUT_WINDOW_Y problem...
+         */
+        XMoveWindow( fgDisplay.Display, window->Window.Handle, x, y );
+
 #       ifdef X_XF86VidModeSetViewPort
 
         /*
@@ -469,7 +469,7 @@ void fgOpenWindow( SFG_Window* window, const gchar* title, gint x, gint y, gint
 #elif TARGET_HOST_WIN32
 
        WNDCLASS wc;
-       gint flags;
+       int flags;
        ATOM atom;
        HWND hWnd;
 
@@ -479,7 +479,7 @@ void fgOpenWindow( SFG_Window* window, const gchar* title, gint x, gint y, gint
         * Grab the window class we have registered on glutInit():
         */
        atom = GetClassInfo( fgDisplay.Instance, "FREEGLUT", &wc );
-       g_assert( atom != 0 );
+       assert( atom != 0 );
 
     if( gameMode == FALSE )
     {
@@ -512,7 +512,7 @@ void fgOpenWindow( SFG_Window* window, const gchar* title, gint x, gint y, gint
         /*
          * In game mode, the story is a little bit different...
          */
-        g_assert( window->Parent == NULL );
+        assert( window->Parent == NULL );
 
         /*
          * Set the window creation flags appropriately to make the window entirely visible:
@@ -537,7 +537,7 @@ void fgOpenWindow( SFG_Window* window, const gchar* title, gint x, gint y, gint
        /*
      * Make sure window was created
      */
-       g_assert( window->Window.Handle != NULL );
+       assert( window->Window.Handle != NULL );
 
     /*
      * Show and update the main window. Hide the mouse cursor.
@@ -624,7 +624,7 @@ int FGAPIENTRY glutCreateSubWindow( int parentID, int x, int y, int w, int h )
     /*
      * Fail if the parent has not been found
      */
-    g_return_val_if_fail( parent != NULL, 0 );
+    freeglut_return_val_if_fail( parent != NULL, 0 );
 
     /*
      * Create the new window
@@ -687,7 +687,7 @@ void FGAPIENTRY glutSetWindow( int ID )
         /*
          * ...issue a warning message and keep rolling on
          */
-        g_warning( "glutSetWindow(): window ID %i not found!", ID );
+        fgWarning( "glutSetWindow(): window ID %i not found!", ID );
         return;
     }