X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_main.c;h=823087b0129be3537273cbf2075a770c2d1bc2ce;hb=a7c34bdfaa680a83bf796eac2f2da20b92f4c139;hp=fd0abbcfd8fa75441c36765a3f702d74901cec06;hpb=e64668928cb1ae343c726195fb01d0eaf951ae84;p=freeglut diff --git a/src/freeglut_main.c b/src/freeglut_main.c index fd0abbc..823087b 100644 --- a/src/freeglut_main.c +++ b/src/freeglut_main.c @@ -508,14 +508,6 @@ void FGAPIENTRY glutMainLoopEvent( void ) switch( event.type ) { - case DestroyNotify: - /* - * This is sent to confirm the XDestroyWindow call. - * XXX WHY is this commented out? Should we re-enable it? - */ - /* fgAddToWindowDestroyList ( window, FALSE ); */ - break; - case ClientMessage: /* * Destroy the window when the WM_DELETE_WINDOW message arrives @@ -529,26 +521,6 @@ void FGAPIENTRY glutMainLoopEvent( void ) } break; - case MapNotify: - case UnmapNotify: - /* - * If we never do anything with this, can we just not ask to - * get these messages? - */ - break; - - case Expose: - /* - * We are too dumb to process partial exposes... - * XXX Well, we could do it. However, it seems to only - * XXX be potentially useful for single-buffered (since - * XXX double-buffered does not respect viewport when we - * XXX do a buffer-swap). - */ - if( event.xexpose.count == 0 ) - fghRedrawWindowByHandle( event.xexpose.window ); - break; - /* * CreateNotify causes a configure-event so that sub-windows are * handled compatibly with GLUT. Otherwise, your sub-windows @@ -571,6 +543,34 @@ void FGAPIENTRY glutMainLoopEvent( void ) ); break; + case DestroyNotify: + /* + * This is sent to confirm the XDestroyWindow call. + * XXX WHY is this commented out? Should we re-enable it? + */ + /* fgAddToWindowDestroyList ( window, FALSE ); */ + break; + + case Expose: + /* + * We are too dumb to process partial exposes... + * XXX Well, we could do it. However, it seems to only + * XXX be potentially useful for single-buffered (since + * XXX double-buffered does not respect viewport when we + * XXX do a buffer-swap). + */ + if( event.xexpose.count == 0 ) + fghRedrawWindowByHandle( event.xexpose.window ); + break; + + case MapNotify: + case UnmapNotify: + /* + * If we never do anything with this, can we just not ask to + * get these messages? + */ + break; + case MappingNotify: /* * Have the client's keyboard knowledge updated (xlib.ps, @@ -619,20 +619,13 @@ void FGAPIENTRY glutMainLoopEvent( void ) break; case EnterNotify: - { - GETWINDOW( xcrossing ); - GETMOUSE( xcrossing ); - INVOKE_WCB( *window, Entry, ( GLUT_ENTERED ) ); - } - break; - /* XXX Combine EnterNotify and LeaveNotify */ case LeaveNotify: - { GETWINDOW( xcrossing ); GETMOUSE( xcrossing ); - INVOKE_WCB( *window, Entry, ( GLUT_LEFT ) ); - } - break; + INVOKE_WCB( *window, Entry, ( ( EnterNotify == event.type ) ? + GLUT_ENTERED : + GLUT_LEFT ) ); + break; case MotionNotify: { @@ -663,15 +656,11 @@ void FGAPIENTRY glutMainLoopEvent( void ) (event.xmotion.state & Button3Mask) || (event.xmotion.state & Button4Mask) || (event.xmotion.state & Button5Mask) ) - { INVOKE_WCB( *window, Motion, ( event.xmotion.x, event.xmotion.y ) ); - } else - { INVOKE_WCB( *window, Passive, ( event.xmotion.x, event.xmotion.y ) ); - } } break; @@ -802,13 +791,11 @@ void FGAPIENTRY glutMainLoopEvent( void ) * XXX Use a symbolic constant, *not* "4"! */ if( ( button < 3 ) || ( ! FETCH_WCB( *window, MouseWheel ) ) ) - { INVOKE_WCB( *window, Mouse, ( button, pressed ? GLUT_DOWN : GLUT_UP, event.xbutton.x, event.xbutton.y ) ); - } else { /* @@ -819,14 +806,14 @@ void FGAPIENTRY glutMainLoopEvent( void ) * XXX since the order and numbering isn't certain * XXX See XFree86 configuration docs (even back in the * XXX 3.x days, and especially with 4.x). - * - * XXX Note that {button} has already been decremeted - * XXX in mapping from X button numbering to GLUT. + * + * XXX Note that {button} has already been decremeted + * XXX in mapping from X button numbering to GLUT. */ int wheel_number = (button - 3) / 2; - int direction = -1; - if( button % 2 ) - direction = 1; + int direction = -1; + if( button % 2 ) + direction = 1; if( pressed ) INVOKE_WCB( *window, MouseWheel, ( wheel_number, @@ -952,6 +939,9 @@ void FGAPIENTRY glutMainLoopEvent( void ) } break; + case ReparentNotify: + break; /* XXX Should disable this event */ + default: fgWarning ("Unknown X event type: %d", event.type); break; @@ -1213,6 +1203,8 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, break; case WM_PAINT: + /* Turn on the visibility in case it was turned off somehow */ + window->State.Visible = GL_TRUE; BeginPaint( hWnd, &ps ); fghRedrawWindowByHandle( hWnd ); EndPaint( hWnd, &ps ); @@ -1276,15 +1268,11 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, if( ( wParam & MK_LBUTTON ) || ( wParam & MK_MBUTTON ) || ( wParam & MK_RBUTTON ) ) - { INVOKE_WCB( *window, Motion, ( window->State.MouseX, window->State.MouseY ) ); - } else - { INVOKE_WCB( *window, Passive, ( window->State.MouseX, window->State.MouseY ) ); - } window->State.Modifiers = 0xffffffff; } @@ -1420,7 +1408,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, { int wheel_number = LOWORD( wParam ); /* THIS IS SPECULATIVE -- John Fay, 10/2/03 */ - short ticks = HIWORD( wParam ) / 120; + short ticks = ( short )HIWORD( wParam ) / 120; /* Should be WHEEL_DELTA instead of 120 */ int direction = 1; @@ -1447,7 +1435,6 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, while( ticks-- ) if( FETCH_WCB( *window, MouseWheel ) ) - { INVOKE_WCB( *window, MouseWheel, ( wheel_number, direction, @@ -1455,7 +1442,6 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, window->State.MouseY ) ); - } else /* No mouse wheel, call the mouse button callback twice */ { /* @@ -1701,6 +1687,75 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, /* Pass it on to "DefWindowProc" to repaint a standard border */ break; + case WM_SYSCOMMAND : /* 0x0112 */ + { + /* + * We have received a system command message. Try to act on it. + * The commands are passed in through the "lParam" parameter: + * Clicking on a corner to resize the window gives a "F004" message + * but this is not defined in my header file. + */ + switch ( lParam ) + { + case SC_SIZE : + break ; + + case SC_MOVE : + break ; + + case SC_MINIMIZE : + /* User has clicked on the "-" to minimize the window */ + /* Turn off the visibility */ + window->State.Visible = GL_FALSE ; + + break ; + + case SC_MAXIMIZE : + break ; + + case SC_NEXTWINDOW : + break ; + + case SC_PREVWINDOW : + break ; + + case SC_CLOSE : + /* Followed very closely by a WM_CLOSE message */ + break ; + + case SC_VSCROLL : + break ; + + case SC_HSCROLL : + break ; + + case SC_MOUSEMENU : + break ; + + case SC_KEYMENU : + break ; + + case SC_ARRANGE : + break ; + + case SC_RESTORE : + break ; + + case SC_TASKLIST : + break ; + + case SC_SCREENSAVE : + break ; + + case SC_HOTKEY : + break ; + } + } + + /* We need to pass the message on to the operating system as well */ + lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ); + break; + default: /* * Handle unhandled messages