RedrawWindow(
window->Window.Handle, NULL, NULL,
RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE | RDW_UPDATENOW
RedrawWindow(
window->Window.Handle, NULL, NULL,
RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE | RDW_UPDATENOW
- fprintf( stderr, "freeglut (%s): ", fgState.ProgramName || "");
+ fprintf( stderr, "freeglut ");
+ if( fgState.ProgramName )
+ fprintf (stderr, "(%s): ", fgState.ProgramName);
- fprintf( stderr, "freeglut (%s): ", fgState.ProgramName || "");
+ fprintf( stderr, "freeglut ");
+ if( fgState.ProgramName )
+ fprintf( stderr, "(%s): ", fgState.ProgramName );
- timer;
- timer = (SFG_Timer *)timer->Node.Next )
- ret = MIN( ret, MAX( 0, (timer->TriggerTime) - now ) );
+ timer;
+ timer = (SFG_Timer *)timer->Node.Next )
+ ret = MIN( ret, MAX( 0, (timer->TriggerTime) - now ) );
socket = ConnectionNumber( fgDisplay.Display );
FD_ZERO( &fdset );
FD_SET( socket, &fdset );
msec = fgNextTimer();
if( fgHaveJoystick() )
socket = ConnectionNumber( fgDisplay.Display );
FD_ZERO( &fdset );
FD_SET( socket, &fdset );
msec = fgNextTimer();
if( fgHaveJoystick() )
wait.tv_sec = msec / 1000;
wait.tv_usec = (msec % 1000) * 1000;
err = select( socket+1, &fdset, NULL, NULL, &wait );
if( -1 == err )
wait.tv_sec = msec / 1000;
wait.tv_usec = (msec % 1000) * 1000;
err = select( socket+1, &fdset, NULL, NULL, &wait );
if( -1 == err )
- window->ActiveMenu->Window->State.MouseX = event.xmotion.x_root - window->ActiveMenu->X ;
- window->ActiveMenu->Window->State.MouseY = event.xmotion.y_root - window->ActiveMenu->Y ;
+ window->ActiveMenu->Window->State.MouseX = event.xmotion.x_root - window->ActiveMenu->X ;
+ window->ActiveMenu->Window->State.MouseY = event.xmotion.y_root - window->ActiveMenu->Y ;
- * An X button (at least in XFree86) is numbered from 1.
- * A GLUT button is numbered from 0.
- * Old GLUT passed through buttons other than just the first
- * three, though it only gave symbolic names and official
- * support to the first three.
- *
- */
- button = event.xbutton.button - 1;
+ * An X button (at least in XFree86) is numbered from 1.
+ * A GLUT button is numbered from 0.
+ * Old GLUT passed through buttons other than just the first
+ * three, though it only gave symbolic names and official
+ * support to the first three.
+ *
+ */
+ button = event.xbutton.button - 1;
- window->ActiveMenu->Window->State.MouseX = event.xbutton.x_root - window->ActiveMenu->X ;
- window->ActiveMenu->Window->State.MouseY = event.xbutton.y_root - window->ActiveMenu->Y ;
- }
-
- if ( fgCheckActiveMenu ( window->ActiveMenu->Window, window->ActiveMenu ) == TRUE ) /* Inside the menu, invoke the callback and deactivate the menu*/
+ window->ActiveMenu->Window->State.MouseX = event.xbutton.x_root - window->ActiveMenu->X ;
+ window->ActiveMenu->Window->State.MouseY = event.xbutton.y_root - window->ActiveMenu->Y ;
+ }
+
+ if ( fgCheckActiveMenu ( window->ActiveMenu->Window, window->ActiveMenu ) == TRUE ) /* Inside the menu, invoke the callback and deactivate the menu*/
- /* Save the current window and menu and set the current window to the window whose menu this is */
- SFG_Window *save_window = fgStructure.Window ;
- SFG_Menu *save_menu = fgStructure.Menu ;
- SFG_Window *parent_window = window->ActiveMenu->ParentWindow ;
- fgSetWindow ( parent_window ) ;
- fgStructure.Menu = window->ActiveMenu ;
-
- /* Execute the menu callback */
- fgExecuteMenuCallback ( window->ActiveMenu ) ;
- fgDeactivateMenu ( parent_window ) ;
-
- /* Restore the current window and menu */
- fgSetWindow ( save_window ) ;
- fgStructure.Menu = save_menu ;
- }
- else /* Outside the menu, deactivate the menu if it's a downclick */
- if ( pressed == TRUE )
- fgDeactivateMenu ( window->ActiveMenu->ParentWindow ) ;
-
- /*
- * Let's make the window redraw as a result of the mouse click and menu activity.
- */
- window->State.Redisplay = TRUE ;
-
- break ;
+ /* Save the current window and menu and set the current window to the window whose menu this is */
+ SFG_Window *save_window = fgStructure.Window ;
+ SFG_Menu *save_menu = fgStructure.Menu ;
+ SFG_Window *parent_window = window->ActiveMenu->ParentWindow ;
+ fgSetWindow ( parent_window ) ;
+ fgStructure.Menu = window->ActiveMenu ;
+
+ /* Execute the menu callback */
+ fgExecuteMenuCallback ( window->ActiveMenu ) ;
+ fgDeactivateMenu ( parent_window ) ;
+
+ /* Restore the current window and menu */
+ fgSetWindow ( save_window ) ;
+ fgStructure.Menu = save_menu ;
+ }
+ else /* Outside the menu, deactivate the menu if it's a downclick */
+ if ( pressed == TRUE )
+ fgDeactivateMenu ( window->ActiveMenu->ParentWindow ) ;
+
+ /*
+ * Let's make the window redraw as a result of the mouse click and menu activity.
+ */
+ window->State.Redisplay = TRUE ;
+
+ break ;
}
/*
* No active menu, let's check whether we need to activate one.
*/
if (( 0 <= button ) && ( 2 >= button ) &&
}
/*
* No active menu, let's check whether we need to activate one.
*/
if (( 0 <= button ) && ( 2 >= button ) &&
- int wheel_number = button / 2 - 2 ; /* Map 4 and 5 to wheel zero */
- int direction = 9 - button * 2 ; /* Map 4 to +1 and 5 to -1 */
-
- fgStructure.Window->Callbacks.MouseWheel(
- wheel_number,
- direction,
- event.xbutton.x,
- event.xbutton.y
- );
+ /*
+ * Map 4 and 5 to wheel zero; EVEN to +1, ODD to -1
+ * " 6 and 7 " " one; ...
+ *
+ * XXX This *should* be behind some variables/macros,
+ * 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).
+ */
+ int wheel_number = (button - 4) / 2;
+ int direction = (button & 1)*2 - 1;
+
+ if( ButtonPress )
+ fgStructure.Window->Callbacks.MouseWheel(
+ wheel_number,
+ direction,
+ event.xbutton.x,
+ event.xbutton.y
+ );
- printf("WM_ACTIVATE: glutSetCursor( %p, %d)\n", window, window->State.Cursor );
+ printf("WM_ACTIVATE: glutSetCursor( %p, %d)\n", window, window->State.Cursor );
- /* Set the cursor AND change it for this window class. */
-# define MAP_CURSOR(a,b) case a: SetCursor( LoadCursor( NULL, b ) ); \
+ /* Set the cursor AND change it for this window class. */
+# define MAP_CURSOR(a,b) case a: SetCursor( LoadCursor( NULL, b ) ); \
- /* Nuke the cursor AND change it for this window class. */
-# define ZAP_CURSOR(a,b) case a: SetCursor( NULL ); \
+ /* Nuke the cursor AND change it for this window class. */
+# define ZAP_CURSOR(a,b) case a: SetCursor( NULL ); \
- switch( window->State.Cursor )
- {
- MAP_CURSOR( GLUT_CURSOR_RIGHT_ARROW, IDC_ARROW );
- MAP_CURSOR( GLUT_CURSOR_LEFT_ARROW, IDC_ARROW );
- MAP_CURSOR( GLUT_CURSOR_INFO, IDC_HELP );
- MAP_CURSOR( GLUT_CURSOR_DESTROY, IDC_CROSS );
- MAP_CURSOR( GLUT_CURSOR_HELP, IDC_HELP );
- MAP_CURSOR( GLUT_CURSOR_CYCLE, IDC_SIZEALL );
- MAP_CURSOR( GLUT_CURSOR_SPRAY, IDC_CROSS );
- MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT );
- MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_UPARROW );
- MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS );
- /* MAP_CURSOR( GLUT_CURSOR_NONE, IDC_NO ); */
- ZAP_CURSOR( GLUT_CURSOR_NONE, NULL );
-
- default:
- MAP_CURSOR( GLUT_CURSOR_UP_DOWN, IDC_ARROW );
- }
+ switch( window->State.Cursor )
+ {
+ MAP_CURSOR( GLUT_CURSOR_RIGHT_ARROW, IDC_ARROW );
+ MAP_CURSOR( GLUT_CURSOR_LEFT_ARROW, IDC_ARROW );
+ MAP_CURSOR( GLUT_CURSOR_INFO, IDC_HELP );
+ MAP_CURSOR( GLUT_CURSOR_DESTROY, IDC_CROSS );
+ MAP_CURSOR( GLUT_CURSOR_HELP, IDC_HELP );
+ MAP_CURSOR( GLUT_CURSOR_CYCLE, IDC_SIZEALL );
+ MAP_CURSOR( GLUT_CURSOR_SPRAY, IDC_CROSS );
+ MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT );
+ MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_UPARROW );
+ MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS );
+ /* MAP_CURSOR( GLUT_CURSOR_NONE, IDC_NO ); */
+ ZAP_CURSOR( GLUT_CURSOR_NONE, NULL );
+
+ default:
+ MAP_CURSOR( GLUT_CURSOR_UP_DOWN, IDC_ARROW );
+ }
- else
- lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
- break;
+ else
+ lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
+ break;
- int wheel_number = LOWORD ( lParam ) ; /* THIS IS SPECULATIVE -- John Fay, 10/2/03 */
- int direction = HIWORD ( lParam ) / 120 ; /* Should be WHEEL_DELTA instead of 120 */
+ int wheel_number = LOWORD ( lParam ) ;
+ /* THIS IS SPECULATIVE -- John Fay, 10/2/03 */
+ int ticks = HIWORD ( lParam ) / 120 ;
+ /* Should be WHEEL_DELTA instead of 120 */
+ int direction = 1;
+
+ if( ticks < 0 )
+ {
+ direction = -1;
+ ticks = -ticks;
+ }
-// window->State.MouseX = LOWORD( lParam ); // Need to adjust by window position,
-// window->State.MouseY = HIWORD( lParam ); // change "lParam" to other parameter
+ /* window->State.MouseX = LOWORD( lParam ); */
+ /* Need to adjust by window position, */
+ /* window->State.MouseY = HIWORD( lParam ); */
+ /* change "lParam" to other parameter */
- ( ( (GetKeyState( VK_LSHIFT ) < 0 ) || ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
- ( ( (GetKeyState( VK_LCONTROL ) < 0 ) || ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
- ( ( (GetKeyState( VK_LMENU ) < 0 ) || ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
-
- if ( window->Callbacks.MouseWheel )
- window->Callbacks.MouseWheel(
- wheel_number,
- direction,
- window->State.MouseX,
- window->State.MouseY
- ) ;
- else // No mouse wheel, call the mouse button callback twice
- {
- window->Callbacks.Mouse ( ( direction > 0 ) ? 4 : 5, GLUT_DOWN, window->State.MouseX, window->State.MouseY ) ;
- window->Callbacks.Mouse ( ( direction > 0 ) ? 4 : 5, GLUT_UP, window->State.MouseX, window->State.MouseY ) ;
- }
+ ( ( (GetKeyState( VK_LSHIFT ) < 0 ) ||
+ ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
+ ( ( (GetKeyState( VK_LCONTROL ) < 0 ) ||
+ ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
+ ( ( (GetKeyState( VK_LMENU ) < 0 ) ||
+ ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
+
+ while( ticks-- )
+ if ( window->Callbacks.MouseWheel )
+ window->Callbacks.MouseWheel(
+ wheel_number,
+ direction,
+ window->State.MouseX,
+ window->State.MouseY
+ ) ;
+ else /* No mouse wheel, call the mouse button callback twice */
+ {
+ /*
+ * XXX The below assumes that you have no more than 3 mouse
+ * XXX buttons. Sorry.
+ */
+ int button = wheel_number * 2 + 4;
+ button += (1 + direction)/2;
+ window->Callbacks.Mouse ( button, GLUT_DOWN,
+ window->State.MouseX,
+ window->State.MouseY ) ;
+ window->Callbacks.Mouse ( button, GLUT_UP,
+ window->State.MouseX,
+ window->State.MouseY ) ;
+ }