4 * The windows message processing methods.
6 * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
7 * Written by Pawel W. Olszta, <olszta@sourceforge.net>
8 * Creation date: Fri Dec 3 1999
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 #define G_LOG_DOMAIN "freeglut-main"
34 #include "../include/GL/freeglut.h"
35 #include "freeglut_internal.h"
38 #if TARGET_HOST_UNIX_X11
39 #include <sys/types.h>
44 #elif TARGET_HOST_WIN32
48 #define MAX(a,b) (((a)>(b)) ? (a) : (b))
52 #define MIN(a,b) (((a)<(b)) ? (a) : (b))
57 * TODO BEFORE THE STABLE RELEASE:
59 * There are some issues concerning window redrawing under X11, and maybe
60 * some events are not handled. The Win32 version lacks some more features,
61 * but seems acceptable for not demanding purposes.
63 * Need to investigate why the X11 version breaks out with an error when
64 * closing a window (using the window manager, not glutDestroyWindow)...
67 /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
70 * Calls a window's redraw method. This is used when
71 * a redraw is forced by the incoming window messages.
73 * XXX We can/should make a "unified" window handle type so that
74 * XXX the function headers don't need this silly #ifdef junk.
75 * XXX Make the type, say, {fgWindow}. On UNIX_X11, this is
76 * XXX {Window}. On WIN32, it is {HWND}. Then do the #ifdef
77 * XXX junk *once* in "freeglut_internal.h".
79 static void fghRedrawWindowByHandle
80 #if TARGET_HOST_UNIX_X11
82 #elif TARGET_HOST_WIN32
86 SFG_Window* window = fgWindowByHandle( handle );
87 freeglut_return_if_fail( window != NULL );
88 freeglut_return_if_fail( window->Callbacks.Display != NULL );
89 freeglut_return_if_fail( window->State.Visible == TRUE );
91 fgSetWindow( window );
92 window->State.Redisplay = FALSE;
93 window->Callbacks.Display();
97 * Handle a window configuration change. When no reshape
98 * callback is hooked, the viewport size is updated to
99 * match the new window size.
101 static void fghReshapeWindowByHandle
102 #if TARGET_HOST_UNIX_X11
103 ( Window handle, int width, int height )
104 #elif TARGET_HOST_WIN32
105 ( HWND handle, int width, int height )
108 SFG_Window *current_window = fgStructure.Window ;
110 SFG_Window* window = fgWindowByHandle( handle );
111 freeglut_return_if_fail( window != NULL );
113 fgSetWindow( window );
114 if( window->Callbacks.Reshape != NULL )
115 window->Callbacks.Reshape( width, height );
117 glViewport( 0, 0, width, height );
120 * Force a window redraw. In Windows at least this is only a partial
121 * solution: if the window is increasing in size in either dimension,
122 * the already-drawn part does not get drawn again and things look funny.
123 * But without this we get this bad behaviour whenever we resize the
126 window->State.Redisplay = TRUE ;
129 fgSetWindow( current_window ) ;
133 * A static helper function to execute display callback for a window
135 static void fghcbDisplayWindow( SFG_Window *window, SFG_Enumerator *enumerator )
137 #if TARGET_HOST_UNIX_X11
138 if( (window->Callbacks.Display != NULL) &&
139 (window->State.Redisplay == TRUE) &&
140 (window->State.Visible == TRUE) )
142 SFG_Window *current_window = fgStructure.Window ;
144 fgSetWindow( window );
145 window->State.Redisplay = FALSE;
146 window->Callbacks.Display();
147 fgSetWindow( current_window ) ;
150 #elif TARGET_HOST_WIN32
152 if( window->State.NeedToResize )
154 SFG_Window *current_window = fgStructure.Window ;
156 fgSetWindow( window );
158 fghReshapeWindowByHandle(
159 window->Window.Handle,
160 glutGet( GLUT_WINDOW_WIDTH ),
161 glutGet( GLUT_WINDOW_HEIGHT )
164 window->State.NeedToResize = FALSE;
165 fgSetWindow ( current_window ) ;
168 if( (window->Callbacks.Display != NULL) &&
169 (window->State.Redisplay == TRUE) &&
170 (window->State.Visible == TRUE) )
172 window->State.Redisplay = FALSE;
175 window->Window.Handle, NULL, NULL,
176 RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE | RDW_UPDATENOW
182 fgEnumSubWindows( window, fghcbDisplayWindow, enumerator );
186 * Make all windows perform a display call
188 static void fghDisplayAll( void )
190 SFG_Enumerator enumerator;
192 enumerator.found = FALSE;
193 enumerator.data = NULL;
195 fgEnumWindows( fghcbDisplayWindow, &enumerator );
199 * Window enumerator callback to check for the joystick polling code
201 static void fghcbCheckJoystickPolls( SFG_Window *window,
202 SFG_Enumerator *enumerator )
204 long int checkTime = fgElapsedTime();
206 if( window->State.JoystickLastPoll + window->State.JoystickPollRate <=
209 fgJoystickPollWindow( window );
210 window->State.JoystickLastPoll = checkTime;
213 fgEnumSubWindows( window, fghcbCheckJoystickPolls, enumerator );
217 * Check all windows for joystick polling
219 static void fghCheckJoystickPolls( void )
221 SFG_Enumerator enumerator;
223 enumerator.found = FALSE;
224 enumerator.data = NULL;
226 fgEnumWindows( fghcbCheckJoystickPolls, &enumerator );
230 * Check the global timers
232 static void fghCheckTimers( void )
234 long checkTime = fgElapsedTime();
235 SFG_Timer *timer, *next;
238 fgListInit(&timedOut);
240 for( timer = (SFG_Timer *)fgState.Timers.First;
242 timer = (SFG_Timer *)next )
244 next = (SFG_Timer *)timer->Node.Next;
246 if( timer->TriggerTime <= checkTime )
248 fgListRemove( &fgState.Timers, &timer->Node );
249 fgListAppend( &timedOut, &timer->Node );
254 * Now feel free to execute all the hooked and timed out timer callbacks
255 * And delete the timed out timers...
257 while ( (timer = (SFG_Timer *)timedOut.First) )
259 if( timer->Callback != NULL )
260 timer->Callback( timer->ID );
261 fgListRemove( &timedOut, &timer->Node );
270 long fgElapsedTime( void )
272 #if TARGET_HOST_UNIX_X11
276 gettimeofday( &now, NULL );
278 elapsed = (now.tv_usec - fgState.Time.Value.tv_usec) / 1000;
279 elapsed += (now.tv_sec - fgState.Time.Value.tv_sec) * 1000;
282 #elif TARGET_HOST_WIN32
283 return (timeGetTime() - fgState.Time.Value);
290 void fgError( const char *fmt, ... )
296 fprintf( stderr, "freeglut ");
297 if( fgState.ProgramName )
298 fprintf (stderr, "(%s): ", fgState.ProgramName);
299 vfprintf( stderr, fmt, ap );
300 fprintf( stderr, "\n" );
307 void fgWarning( const char *fmt, ... )
313 fprintf( stderr, "freeglut ");
314 if( fgState.ProgramName )
315 fprintf( stderr, "(%s): ", fgState.ProgramName );
316 vfprintf( stderr, fmt, ap );
317 fprintf( stderr, "\n" );
323 * Indicates whether Joystick events are being used by ANY window.
325 * The current mechanism is to walk all of the windows and ask if
326 * there is a joystick callback. Certainly in some cases, maybe
327 * in all cases, the joystick is attached to the system and accessed
328 * from ONE point by GLUT/freeglut, so this is not the right way,
329 * in general, to do this. However, the Joystick code is segregated
330 * in its own little world, so we can't access the information that
331 * we need in order to do that nicely.
334 * * Store Joystick data into freeglut global state.
335 * * Provide NON-static functions or data from Joystick *.c file.
337 * Basically, the RIGHT way to do this requires knowing something
338 * about the Joystick. Right now, the Joystick code is behind
342 static void fgCheckJoystickCallback( SFG_Window* w, SFG_Enumerator* e)
344 if( w->Callbacks.Joystick )
349 fgEnumSubWindows( w, fgCheckJoystickCallback, e );
351 static int fgHaveJoystick( void )
353 SFG_Enumerator enumerator;
354 enumerator.found = FALSE;
355 enumerator.data = NULL;
356 fgEnumWindows( fgCheckJoystickCallback, &enumerator );
357 return !!enumerator.data;
359 static void fgHavePendingRedisplaysCallback( SFG_Window* w, SFG_Enumerator* e)
361 if( w->State.Redisplay )
366 fgEnumSubWindows( w, fgHavePendingRedisplaysCallback, e );
368 static int fgHavePendingRedisplays (void)
370 SFG_Enumerator enumerator;
371 enumerator.found = FALSE;
372 enumerator.data = NULL;
373 fgEnumWindows( fgHavePendingRedisplaysCallback, &enumerator );
374 return !!enumerator.data;
377 * Indicates whether there are any outstanding timers.
379 static int fgHaveTimers( void )
381 return !!fgState.Timers.First;
384 * Returns the number of GLUT ticks (milliseconds) till the next timer event.
386 static long fgNextTimer( void )
388 long now = fgElapsedTime();
392 for( timer = (SFG_Timer *)fgState.Timers.First;
394 timer = (SFG_Timer *)timer->Node.Next )
395 ret = MIN( ret, MAX( 0, (timer->TriggerTime) - now ) );
400 * Does the magic required to relinquish the CPU until something interesting
403 static void fgSleepForEvents( void )
405 #if TARGET_HOST_UNIX_X11
412 if( fgState.IdleCallback ||
413 fgHavePendingRedisplays() )
415 socket = ConnectionNumber( fgDisplay.Display );
417 FD_SET( socket, &fdset );
419 msec = fgNextTimer();
420 if( fgHaveJoystick() )
421 msec = MIN( msec, 10 );
423 wait.tv_sec = msec / 1000;
424 wait.tv_usec = (msec % 1000) * 1000;
425 err = select( socket+1, &fdset, NULL, NULL, &wait );
428 printf( "freeglut select() error: %d\n", errno );
430 #elif TARGET_HOST_WIN32
435 * Returns GLUT modifier mask for an XEvent.
437 int fgGetXModifiers(XEvent *event)
441 if( event->xkey.state & ( ShiftMask | LockMask ) )
442 ret |= GLUT_ACTIVE_SHIFT;
443 if( event->xkey.state & ControlMask )
444 ret |= GLUT_ACTIVE_CTRL;
445 if( event->xkey.state & Mod1Mask )
446 ret |= GLUT_ACTIVE_ALT;
452 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
455 * Executes a single iteration in the freeglut processing loop.
457 void FGAPIENTRY glutMainLoopEvent( void )
459 #if TARGET_HOST_UNIX_X11
464 * This code was repeated constantly, so here it goes into a definition:
466 #define GETWINDOW(a) \
467 window = fgWindowByHandle( event.a.window ); \
468 if( window == NULL ) \
471 #define GETMOUSE(a) \
472 window->State.MouseX = event.a.x; \
473 window->State.MouseY = event.a.y;
475 freeglut_assert_ready;
477 while( XPending( fgDisplay.Display ) )
479 XNextEvent( fgDisplay.Display, &event );
485 * This is sent to confirm the XDestroyWindow call.
486 * XXX WHY is this commented out? Should we re-enable it?
488 /* fgAddToWindowDestroyList ( window, FALSE ); */
493 * Destroy the window when the WM_DELETE_WINDOW message arrives
495 if( (Atom) event.xclient.data.l[ 0 ] == fgDisplay.DeleteWindow )
497 GETWINDOW( xclient );
499 fgCloseWindow ( window ) ;
500 fgAddToWindowDestroyList ( window, FALSE );
507 * If we never do anything with this, can we just not ask to
508 * get these messages?
514 * We are too dumb to process partial exposes...
515 * XXX Well, we could do it. However, it seems to only
516 * XXX be potentially useful for single-buffered (since
517 * XXX double-buffered does not respect viewport when we
518 * XXX do a buffer-swap).
520 if( event.xexpose.count == 0 )
521 fghRedrawWindowByHandle( event.xexpose.window );
525 * CreateNotify causes a configure-event so that sub-windows are
526 * handled compatibly with GLUT. Otherwise, your sub-windows
527 * (in freeglut only) will not get an initial reshape event,
528 * which can break things.
530 * XXX NOTE that it is possible that you will more than one Reshape
531 * XXX event for your top-level window, but something like this
532 * XXX appears to be required for compatbility.
534 * GLUT presumably does this because it generally tries to treat
535 * sub-windows the same as windows.
538 case ConfigureNotify:
539 fghReshapeWindowByHandle(
540 event.xconfigure.window,
541 event.xconfigure.width,
542 event.xconfigure.height
548 * Have the client's keyboard knowledge updated (xlib.ps,
549 * page 206, says that's a good thing to do)
551 XRefreshKeyboardMapping( (XMappingEvent *) &event );
554 case VisibilityNotify:
556 GETWINDOW( xvisibility );
557 if( window->Callbacks.WindowStatus == NULL )
559 fgSetWindow( window );
562 * Sending this event, the X server can notify us that the window
563 * has just acquired one of the three possible visibility states:
564 * VisibilityUnobscured, VisibilityPartiallyObscured or
565 * VisibilityFullyObscured
567 switch( event.xvisibility.state )
569 case VisibilityUnobscured:
570 window->Callbacks.WindowStatus( GLUT_FULLY_RETAINED );
571 window->State.Visible = TRUE;
574 case VisibilityPartiallyObscured:
575 window->Callbacks.WindowStatus( GLUT_PARTIALLY_RETAINED );
576 window->State.Visible = TRUE;
579 case VisibilityFullyObscured:
580 window->Callbacks.WindowStatus( GLUT_FULLY_COVERED );
581 window->State.Visible = FALSE;
585 fgWarning( "Uknown X visibility state: %d",
586 event.xvisibility.state );
594 GETWINDOW( xcrossing );
595 GETMOUSE( xcrossing );
596 if( window->Callbacks.Entry )
598 fgSetWindow( window ) ;
599 window->Callbacks.Entry( GLUT_ENTERED );
606 GETWINDOW( xcrossing );
607 GETMOUSE( xcrossing );
608 if( window->Callbacks.Entry )
610 fgSetWindow( window ) ;
611 window->Callbacks.Entry( GLUT_LEFT );
618 GETWINDOW( xmotion );
621 if( window->ActiveMenu )
623 if( window == window->ActiveMenu->ParentWindow )
625 window->ActiveMenu->Window->State.MouseX =
626 event.xmotion.x_root - window->ActiveMenu->X;
627 window->ActiveMenu->Window->State.MouseY =
628 event.xmotion.y_root - window->ActiveMenu->Y;
630 window->ActiveMenu->Window->State.Redisplay = TRUE ;
631 fgSetWindow( window->ActiveMenu->ParentWindow ) ;
637 * XXX For more than 5 buttons, just check {event.xmotion.state},
638 * XXX rather than a host of bit-masks?
640 if( (event.xmotion.state & Button1Mask) ||
641 (event.xmotion.state & Button2Mask) ||
642 (event.xmotion.state & Button3Mask) ||
643 (event.xmotion.state & Button4Mask) ||
644 (event.xmotion.state & Button5Mask) )
647 * A mouse button was pressed during the movement...
648 * Is there a motion callback hooked to the window?
650 if( window->Callbacks.Motion )
652 fgSetWindow ( window ) ;
653 window->Callbacks.Motion( event.xmotion.x,
657 else if( window->Callbacks.Passive )
659 fgSetWindow ( window ) ;
660 window->Callbacks.Passive( event.xmotion.x, event.xmotion.y );
668 GLboolean pressed = TRUE;
671 if( event.type == ButtonRelease )
675 * A mouse button has been pressed or released. Traditionally,
676 * break if the window was found within the freeglut structures.
678 GETWINDOW( xbutton );
682 * An X button (at least in XFree86) is numbered from 1.
683 * A GLUT button is numbered from 0.
684 * Old GLUT passed through buttons other than just the first
685 * three, though it only gave symbolic names and official
686 * support to the first three.
688 button = event.xbutton.button - 1;
691 * Do not execute the application's mouse callback if a menu
692 * is hooked to this button. In that case an appropriate
693 * private call should be generated.
694 * Near as I can tell, this is the menu behaviour:
695 * - Down-click the menu button, menu not active: activate
696 * the menu with its upper left-hand corner at the mouse
698 * - Down-click any button outside the menu, menu active:
699 * deactivate the menu
700 * - Down-click any button inside the menu, menu active:
701 * select the menu entry and deactivate the menu
702 * - Up-click the menu button, menu not active: nothing happens
703 * - Up-click the menu button outside the menu, menu active:
705 * - Up-click the menu button inside the menu, menu active:
706 * select the menu entry and deactivate the menu
708 /* Window has an active menu, it absorbs any mouse click */
709 if( window->ActiveMenu )
711 if( window == window->ActiveMenu->ParentWindow )
713 window->ActiveMenu->Window->State.MouseX =
714 event.xbutton.x_root - window->ActiveMenu->X;
715 window->ActiveMenu->Window->State.MouseY =
716 event.xbutton.y_root - window->ActiveMenu->Y;
719 /* In the menu, invoke the callback and deactivate the menu*/
720 if( fgCheckActiveMenu( window->ActiveMenu->Window,
721 window->ActiveMenu ) == TRUE )
724 * Save the current window and menu and set the current
725 * window to the window whose menu this is
727 SFG_Window *save_window = fgStructure.Window;
728 SFG_Menu *save_menu = fgStructure.Menu;
729 SFG_Window *parent_window =
730 window->ActiveMenu->ParentWindow;
731 fgSetWindow( parent_window );
732 fgStructure.Menu = window->ActiveMenu;
734 /* Execute the menu callback */
735 fgExecuteMenuCallback( window->ActiveMenu );
736 fgDeactivateMenu( parent_window );
738 /* Restore the current window and menu */
739 fgSetWindow( save_window );
740 fgStructure.Menu = save_menu;
744 * Outside the menu, deactivate if it's a downclick
745 * XXX This isn't enough. A downclick outside of
746 * XXX the interior of our freeglut windows should also
747 * XXX deactivate the menu. This is more complicated.
749 fgDeactivateMenu( window->ActiveMenu->ParentWindow );
751 window->State.Redisplay = TRUE;
756 * No active menu, let's check whether we need to activate one.
758 if( ( 0 <= button ) &&
760 ( window->Menu[ button ] ) &&
763 window->State.Redisplay = TRUE;
764 fgSetWindow( window );
765 fgActivateMenu( window, button );
770 * Check if there is a mouse or mouse wheel callback hooked to the
773 if( ( window->Callbacks.Mouse == NULL ) &&
774 ( window->Callbacks.MouseWheel == NULL ) )
777 fgSetWindow( window );
780 * XXX Why don't we use {window}? Other code here does...
782 fgStructure.Window->State.Modifiers = fgGetXModifiers( &event );
785 * Finally execute the mouse or mouse wheel callback
787 * XXX Use a symbolic constant, *not* "4"!
789 if( ( button < 4 ) || ( !( window->Callbacks.MouseWheel ) ) )
791 if( window->Callbacks.Mouse )
792 fgStructure.Window->Callbacks.Mouse(
794 event.type == ButtonPress ? GLUT_DOWN : GLUT_UP,
801 if( ( button >= 4 ) && window->Callbacks.MouseWheel )
804 * Map 4 and 5 to wheel zero; EVEN to +1, ODD to -1
805 * " 6 and 7 " " one; ...
807 * XXX This *should* be behind some variables/macros,
808 * XXX since the order and numbering isn't certain
809 * XXX See XFree86 configuration docs (even back in the
810 * XXX 3.x days, and especially with 4.x).
812 int wheel_number = (button - 4) / 2;
813 int direction = (button & 1)*2 - 1;
816 fgStructure.Window->Callbacks.MouseWheel(
826 * Trash the modifiers state
828 fgStructure.Window->State.Modifiers = 0xffffffff;
835 FGCBkeyboard keyboard_cb;
836 FGCBspecial special_cb;
841 if( event.type == KeyPress )
843 keyboard_cb = window->Callbacks.Keyboard;
844 special_cb = window->Callbacks.Special;
848 keyboard_cb = window->Callbacks.KeyboardUp;
849 special_cb = window->Callbacks.SpecialUp;
853 * Is there a keyboard/special callback hooked for this window?
855 if( keyboard_cb || special_cb )
857 XComposeStatus composeStatus;
858 char asciiCode[ 32 ];
863 * Check for the ASCII/KeySym codes associated with the event:
865 len = XLookupString( &event.xkey, asciiCode, sizeof(asciiCode),
866 &keySym, &composeStatus );
869 * GLUT API tells us to have two separate callbacks...
874 * ...one for the ASCII translateable keypresses...
878 fgSetWindow( window );
879 window->State.Modifiers = fgGetXModifiers( &event );
880 keyboard_cb( asciiCode[ 0 ],
881 event.xkey.x, event.xkey.y );
882 window->State.Modifiers = 0xffffffff;
890 * ...and one for all the others, which need to be
891 * translated to GLUT_KEY_Xs...
895 case XK_F1: special = GLUT_KEY_F1; break;
896 case XK_F2: special = GLUT_KEY_F2; break;
897 case XK_F3: special = GLUT_KEY_F3; break;
898 case XK_F4: special = GLUT_KEY_F4; break;
899 case XK_F5: special = GLUT_KEY_F5; break;
900 case XK_F6: special = GLUT_KEY_F6; break;
901 case XK_F7: special = GLUT_KEY_F7; break;
902 case XK_F8: special = GLUT_KEY_F8; break;
903 case XK_F9: special = GLUT_KEY_F9; break;
904 case XK_F10: special = GLUT_KEY_F10; break;
905 case XK_F11: special = GLUT_KEY_F11; break;
906 case XK_F12: special = GLUT_KEY_F12; break;
908 case XK_Left: special = GLUT_KEY_LEFT; break;
909 case XK_Right: special = GLUT_KEY_RIGHT; break;
910 case XK_Up: special = GLUT_KEY_UP; break;
911 case XK_Down: special = GLUT_KEY_DOWN; break;
914 case XK_Prior: special = GLUT_KEY_PAGE_UP; break;
916 case XK_Next: special = GLUT_KEY_PAGE_DOWN; break;
918 case XK_Home: special = GLUT_KEY_HOME; break;
920 case XK_End: special = GLUT_KEY_END; break;
922 case XK_Insert: special = GLUT_KEY_INSERT; break;
926 * Execute the callback (if one has been specified),
927 * given that the special code seems to be valid...
929 if( special_cb && (special != -1) )
931 fgSetWindow( window );
932 window->State.Modifiers = fgGetXModifiers( &event );
933 special_cb( special, event.xkey.x, event.xkey.y );
934 window->State.Modifiers = 0xffffffff;
942 fgWarning ("Unknown X event type: %d", event.type);
947 #elif TARGET_HOST_WIN32
951 while( PeekMessage( &stMsg, NULL, 0, 0, PM_NOREMOVE ) )
953 if( GetMessage( &stMsg, NULL, 0, 0 ) == 0 )
954 fgState.ExecState = GLUT_EXEC_STATE_STOP ;
956 TranslateMessage( &stMsg );
957 DispatchMessage( &stMsg );
962 fghCheckJoystickPolls( );
969 * Enters the freeglut processing loop.
970 * Stays until the "ExecState" changes to "GLUT_EXEC_STATE_STOP".
972 void FGAPIENTRY glutMainLoop( void )
974 #if TARGET_HOST_WIN32
975 SFG_Window *window = (SFG_Window *)fgStructure.Windows.First ;
978 freeglut_assert_ready;
980 #if TARGET_HOST_WIN32
982 * Processing before the main loop: If there is a window which is open and
983 * which has a visibility callback, call it. I know this is an ugly hack,
984 * but I'm not sure what else to do about it. Ideally we should leave
985 * something uninitialized in the create window code and initialize it in
986 * the main loop, and have that initialization create a "WM_ACTIVATE"
987 * message. Then we would put the visibility callback code in the
988 * "case WM_ACTIVATE" block below. - John Fay -- 10/24/02
992 if ( window->Callbacks.Visibility )
994 SFG_Window *current_window = fgStructure.Window ;
996 fgSetWindow( window );
997 window->Callbacks.Visibility ( window->State.Visible ) ;
998 fgSetWindow( current_window );
1001 window = (SFG_Window *)window->Node.Next ;
1005 fgState.ExecState = GLUT_EXEC_STATE_RUNNING ;
1006 while( fgState.ExecState == GLUT_EXEC_STATE_RUNNING )
1008 glutMainLoopEvent( );
1010 if( fgStructure.Windows.First == NULL )
1011 fgState.ExecState = GLUT_EXEC_STATE_STOP;
1014 if( fgState.IdleCallback )
1015 fgState.IdleCallback( );
1022 fgExecutionState execState = fgState.ActionOnWindowClose;
1025 * When this loop terminates, destroy the display, state and structure
1026 * of a freeglut session, so that another glutInit() call can happen
1030 if( execState == GLUT_ACTION_EXIT )
1036 * Leaves the freeglut processing loop.
1038 void FGAPIENTRY glutLeaveMainLoop( void )
1040 fgState.ExecState = GLUT_EXEC_STATE_STOP ;
1044 * The window procedure for handling Win32 events
1046 #if TARGET_HOST_WIN32
1047 LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
1050 SFG_Window* window = fgWindowByHandle( hWnd );
1054 if ( ( window == NULL ) && ( uMsg != WM_CREATE ) )
1055 return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
1057 /* printf ( "Window %3d message <%04x> %12d %12d\n", window?window->ID:0,
1058 uMsg, wParam, lParam ); */
1063 * The window structure is passed as the creation structure paramter...
1065 window = (SFG_Window *) (((LPCREATESTRUCT) lParam)->lpCreateParams);
1066 assert( window != NULL );
1068 window->Window.Handle = hWnd;
1069 window->Window.Device = GetDC( hWnd );
1070 if( fgState.BuildingAMenu )
1072 unsigned int current_DisplayMode = fgState.DisplayMode;
1073 fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH;
1074 fgSetupPixelFormat( window, FALSE, PFD_MAIN_PLANE );
1075 fgState.DisplayMode = current_DisplayMode;
1077 if( fgStructure.MenuContext )
1078 wglMakeCurrent( window->Window.Device,
1079 fgStructure.MenuContext->Context ) ;
1082 fgStructure.MenuContext =
1083 (SFG_MenuContext *)malloc( sizeof(SFG_MenuContext) );
1084 fgStructure.MenuContext->Context =
1085 wglCreateContext( window->Window.Device );
1088 /* window->Window.Context = wglGetCurrentContext () ; */
1089 window->Window.Context = wglCreateContext( window->Window.Device );
1093 fgSetupPixelFormat( window, FALSE, PFD_MAIN_PLANE );
1095 if( fgState.UseCurrentContext != TRUE )
1096 window->Window.Context =
1097 wglCreateContext( window->Window.Device );
1100 window->Window.Context = wglGetCurrentContext( );
1101 if( ! window->Window.Context )
1102 window->Window.Context =
1103 wglCreateContext( window->Window.Device );
1107 window->State.NeedToResize = TRUE;
1108 ReleaseDC( window->Window.Handle, window->Window.Device );
1113 * We got resized... But check if the window has been already added...
1115 fghReshapeWindowByHandle( hWnd, LOWORD(lParam), HIWORD(lParam) );
1119 printf("WM_SETFOCUS: %p\n", window );
1120 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1124 if (LOWORD(wParam) != WA_INACTIVE)
1126 /* glutSetCursor( fgStructure.Window->State.Cursor ); */
1127 printf("WM_ACTIVATE: glutSetCursor( %p, %d)\n", window,
1128 window->State.Cursor );
1130 glutSetCursor( window->State.Cursor );
1133 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1139 * Windows seems to need reminding to erase the cursor for NONE.
1142 if ((LOWORD(lParam) == HTCLIENT) &&
1143 (fgStructure.Window->State.Cursor == GLUT_CURSOR_NONE))
1146 /* Set the cursor AND change it for this window class. */
1147 # define MAP_CURSOR(a,b) case a: SetCursor( LoadCursor( NULL, b ) ); \
1149 /* Nuke the cursor AND change it for this window class. */
1150 # define ZAP_CURSOR(a,b) case a: SetCursor( NULL ); \
1153 if( LOWORD( lParam ) == HTCLIENT )
1154 switch( window->State.Cursor )
1156 MAP_CURSOR( GLUT_CURSOR_RIGHT_ARROW, IDC_ARROW );
1157 MAP_CURSOR( GLUT_CURSOR_LEFT_ARROW, IDC_ARROW );
1158 MAP_CURSOR( GLUT_CURSOR_INFO, IDC_HELP );
1159 MAP_CURSOR( GLUT_CURSOR_DESTROY, IDC_CROSS );
1160 MAP_CURSOR( GLUT_CURSOR_HELP, IDC_HELP );
1161 MAP_CURSOR( GLUT_CURSOR_CYCLE, IDC_SIZEALL );
1162 MAP_CURSOR( GLUT_CURSOR_SPRAY, IDC_CROSS );
1163 MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT );
1164 MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_UPARROW );
1165 MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS );
1166 /* MAP_CURSOR( GLUT_CURSOR_NONE, IDC_NO ); */
1167 ZAP_CURSOR( GLUT_CURSOR_NONE, NULL );
1170 MAP_CURSOR( GLUT_CURSOR_UP_DOWN, IDC_ARROW );
1174 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1178 window->State.Visible = TRUE;
1179 window->State.Redisplay = TRUE;
1183 BeginPaint( hWnd, &ps );
1184 fghRedrawWindowByHandle( hWnd );
1185 EndPaint( hWnd, &ps );
1190 * Make sure we don't close a window with current context active
1192 if( fgStructure.Window == window )
1197 wglMakeCurrent( NULL, NULL );
1199 * Step through the list of windows. If the rendering context
1200 * is not being used by another window, then we delete it.
1202 for( iter = (SFG_Window *)fgStructure.Windows.First;
1204 iter = (SFG_Window *)iter->Node.Next )
1206 if( ( iter->Window.Context == window->Window.Context ) &&
1207 ( iter != window ) )
1212 wglDeleteContext( window->Window.Context );
1216 * Put on a linked list of windows to be removed after all the
1217 * callbacks have returned
1219 fgAddToWindowDestroyList( window, FALSE ) ;
1220 DestroyWindow( hWnd );
1225 * The window already got destroyed, so don't bother with it.
1231 window->State.MouseX = LOWORD( lParam );
1232 window->State.MouseY = HIWORD( lParam );
1234 if ( window->ActiveMenu )
1236 window->State.Redisplay = TRUE ;
1239 * Since the window is a menu, make the parent window current
1241 fgSetWindow ( window->ActiveMenu->ParentWindow ) ;
1246 window->State.Modifiers =
1247 ( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
1248 ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
1249 ( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
1250 ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
1251 ( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
1252 ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
1254 if( ( wParam & MK_LBUTTON ) ||
1255 ( wParam & MK_MBUTTON ) ||
1256 ( wParam & MK_RBUTTON ) )
1258 if( window->Callbacks.Motion )
1260 fgSetWindow( window );
1261 window->Callbacks.Motion( window->State.MouseX,
1262 window->State.MouseY );
1267 if( window->Callbacks.Passive )
1269 fgSetWindow( window );
1270 window->Callbacks.Passive( window->State.MouseX,
1271 window->State.MouseY );
1275 window->State.Modifiers = 0xffffffff;
1279 case WM_LBUTTONDOWN:
1280 case WM_MBUTTONDOWN:
1281 case WM_RBUTTONDOWN:
1286 GLboolean pressed = TRUE;
1289 window->State.MouseX = LOWORD( lParam );
1290 window->State.MouseY = HIWORD( lParam );
1294 case WM_LBUTTONDOWN:
1295 pressed = TRUE; button = GLUT_LEFT_BUTTON; break;
1296 case WM_MBUTTONDOWN:
1297 pressed = TRUE; button = GLUT_MIDDLE_BUTTON; break;
1298 case WM_RBUTTONDOWN:
1299 pressed = TRUE; button = GLUT_RIGHT_BUTTON; break;
1301 pressed = FALSE; button = GLUT_LEFT_BUTTON; break;
1303 pressed = FALSE; button = GLUT_MIDDLE_BUTTON; break;
1305 pressed = FALSE; button = GLUT_RIGHT_BUTTON; break;
1307 pressed = FALSE; button = -1; break;
1310 if( GetSystemMetrics( SM_SWAPBUTTON ) )
1311 if( button == GLUT_LEFT_BUTTON )
1312 button = GLUT_RIGHT_BUTTON;
1313 else if( button == GLUT_RIGHT_BUTTON )
1314 button = GLUT_LEFT_BUTTON;
1317 return DefWindowProc( hWnd, uMsg, lParam, wParam );
1320 * Do not execute the application's mouse callback if a
1321 * menu is hooked to this button.
1322 * In that case an appropriate private call should be generated.
1323 * Near as I can tell, this is the menu behaviour:
1324 * - Down-click the menu button, menu not active: activate
1325 * the menu with its upper left-hand corner at the mouse location.
1326 * - Down-click any button outside the menu, menu active:
1327 * deactivate the menu
1328 * - Down-click any button inside the menu, menu active:
1329 * select the menu entry and deactivate the menu
1330 * - Up-click the menu button, menu not active: nothing happens
1331 * - Up-click the menu button outside the menu, menu active:
1333 * - Up-click the menu button inside the menu, menu active:
1334 * select the menu entry and deactivate the menu
1336 /* Window has an active menu, it absorbs any mouse click */
1337 if( window->ActiveMenu )
1339 /* Inside the menu, invoke the callback and deactivate the menu*/
1340 if( fgCheckActiveMenu( window, window->ActiveMenu ) == TRUE )
1343 * Save the current window and menu and set the current
1344 * window to the window whose menu this is
1346 SFG_Window *save_window = fgStructure.Window;
1347 SFG_Menu *save_menu = fgStructure.Menu;
1348 SFG_Window *parent_window = window->ActiveMenu->ParentWindow;
1349 fgSetWindow( parent_window );
1350 fgStructure.Menu = window->ActiveMenu;
1352 /* Execute the menu callback */
1353 fgExecuteMenuCallback( window->ActiveMenu );
1354 fgDeactivateMenu( parent_window );
1356 /* Restore the current window and menu */
1357 fgSetWindow( save_window );
1358 fgStructure.Menu = save_menu;
1360 else /* Out of menu, deactivate the menu if it's a downclick */
1362 if( pressed == TRUE )
1363 fgDeactivateMenu( window->ActiveMenu->ParentWindow );
1367 * Let's make the window redraw as a result of the mouse
1368 * click and menu activity.
1370 if( ! window->IsMenu )
1371 window->State.Redisplay = TRUE;
1376 if ( ( window->Menu[ button ] != NULL ) && ( pressed == TRUE ) )
1378 window->State.Redisplay = TRUE;
1379 fgSetWindow( window );
1380 fgActivateMenu( window, button );
1385 if( window->Callbacks.Mouse == NULL )
1388 fgSetWindow( window );
1390 fgStructure.Window->State.Modifiers =
1391 ( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
1392 ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
1393 ( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
1394 ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
1395 ( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
1396 ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
1398 window->Callbacks.Mouse(
1400 pressed == TRUE ? GLUT_DOWN : GLUT_UP,
1401 window->State.MouseX,
1402 window->State.MouseY
1405 fgStructure.Window->State.Modifiers = 0xffffffff;
1410 /* Should be WM_MOUSEWHEEL but my compiler doesn't recognize it */
1412 int wheel_number = LOWORD( lParam );
1413 /* THIS IS SPECULATIVE -- John Fay, 10/2/03 */
1414 int ticks = HIWORD( lParam ) / 120;
1415 /* Should be WHEEL_DELTA instead of 120 */
1425 * The mouse cursor has moved. Remember the new mouse cursor's position
1427 /* window->State.MouseX = LOWORD( lParam ); */
1428 /* Need to adjust by window position, */
1429 /* window->State.MouseY = HIWORD( lParam ); */
1430 /* change "lParam" to other parameter */
1432 if( ( window->Callbacks.MouseWheel == NULL ) &&
1433 ( window->Callbacks.Mouse == NULL ) )
1436 fgSetWindow( window );
1437 fgStructure.Window->State.Modifiers =
1438 ( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
1439 ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
1440 ( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
1441 ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
1442 ( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
1443 ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
1446 if( window->Callbacks.MouseWheel )
1447 window->Callbacks.MouseWheel(
1450 window->State.MouseX,
1451 window->State.MouseY
1453 else /* No mouse wheel, call the mouse button callback twice */
1456 * XXX The below assumes that you have no more than 3 mouse
1457 * XXX buttons. Sorry.
1459 int button = wheel_number*2 + 4;
1460 button += (1 + direction)/2;
1461 window->Callbacks.Mouse( button, GLUT_DOWN,
1462 window->State.MouseX,
1463 window->State.MouseY ) ;
1464 window->Callbacks.Mouse( button, GLUT_UP,
1465 window->State.MouseX,
1466 window->State.MouseY ) ;
1469 fgStructure.Window->State.Modifiers = 0xffffffff;
1479 if( fgState.IgnoreKeyRepeat && (lParam & KF_REPEAT) )
1483 * Remember the current modifiers state. This is done here in order
1484 * to make sure the VK_DELETE keyboard callback is executed properly.
1486 window->State.Modifiers =
1487 ( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
1488 ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
1489 ( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
1490 ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
1491 ( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
1492 ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
1494 GetCursorPos( &mouse_pos );
1495 ScreenToClient( window->Window.Handle, &mouse_pos );
1497 window->State.MouseX = mouse_pos.x;
1498 window->State.MouseY = mouse_pos.y;
1501 * Convert the Win32 keystroke codes to GLUTtish way
1503 # define KEY(a,b) case a: keypress = b; break;
1507 KEY( VK_F1, GLUT_KEY_F1 );
1508 KEY( VK_F2, GLUT_KEY_F2 );
1509 KEY( VK_F3, GLUT_KEY_F3 );
1510 KEY( VK_F4, GLUT_KEY_F4 );
1511 KEY( VK_F5, GLUT_KEY_F5 );
1512 KEY( VK_F6, GLUT_KEY_F6 );
1513 KEY( VK_F7, GLUT_KEY_F7 );
1514 KEY( VK_F8, GLUT_KEY_F8 );
1515 KEY( VK_F9, GLUT_KEY_F9 );
1516 KEY( VK_F10, GLUT_KEY_F10 );
1517 KEY( VK_F11, GLUT_KEY_F11 );
1518 KEY( VK_F12, GLUT_KEY_F12 );
1519 KEY( VK_PRIOR, GLUT_KEY_PAGE_UP );
1520 KEY( VK_NEXT, GLUT_KEY_PAGE_DOWN );
1521 KEY( VK_HOME, GLUT_KEY_HOME );
1522 KEY( VK_END, GLUT_KEY_END );
1523 KEY( VK_LEFT, GLUT_KEY_LEFT );
1524 KEY( VK_UP, GLUT_KEY_UP );
1525 KEY( VK_RIGHT, GLUT_KEY_RIGHT );
1526 KEY( VK_DOWN, GLUT_KEY_DOWN );
1527 KEY( VK_INSERT, GLUT_KEY_INSERT );
1531 * The delete key should be treated as an ASCII keypress:
1533 if( window->Callbacks.Keyboard )
1535 fgSetWindow( window );
1536 window->Callbacks.Keyboard( 127, window->State.MouseX,
1537 window->State.MouseY );
1541 if( ( keypress != -1 ) && window->Callbacks.Special )
1543 fgSetWindow( window );
1544 window->Callbacks.Special( keypress, window->State.MouseX,
1545 window->State.MouseY );
1548 window->State.Modifiers = 0xffffffff;
1559 * Remember the current modifiers state. This is done here in order
1560 * to make sure the VK_DELETE keyboard callback is executed properly.
1562 window->State.Modifiers =
1563 ( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
1564 ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
1565 ( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
1566 ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
1567 ( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
1568 ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
1570 GetCursorPos( &mouse_pos );
1571 ScreenToClient( window->Window.Handle, &mouse_pos );
1573 window->State.MouseX = mouse_pos.x;
1574 window->State.MouseY = mouse_pos.y;
1577 * Convert the Win32 keystroke codes to GLUTtish way.
1578 * "KEY(a,b)" was defined under "WM_KEYDOWN"
1583 KEY( VK_F1, GLUT_KEY_F1 );
1584 KEY( VK_F2, GLUT_KEY_F2 );
1585 KEY( VK_F3, GLUT_KEY_F3 );
1586 KEY( VK_F4, GLUT_KEY_F4 );
1587 KEY( VK_F5, GLUT_KEY_F5 );
1588 KEY( VK_F6, GLUT_KEY_F6 );
1589 KEY( VK_F7, GLUT_KEY_F7 );
1590 KEY( VK_F8, GLUT_KEY_F8 );
1591 KEY( VK_F9, GLUT_KEY_F9 );
1592 KEY( VK_F10, GLUT_KEY_F10 );
1593 KEY( VK_F11, GLUT_KEY_F11 );
1594 KEY( VK_F12, GLUT_KEY_F12 );
1595 KEY( VK_PRIOR, GLUT_KEY_PAGE_UP );
1596 KEY( VK_NEXT, GLUT_KEY_PAGE_DOWN );
1597 KEY( VK_HOME, GLUT_KEY_HOME );
1598 KEY( VK_END, GLUT_KEY_END );
1599 KEY( VK_LEFT, GLUT_KEY_LEFT );
1600 KEY( VK_UP, GLUT_KEY_UP );
1601 KEY( VK_RIGHT, GLUT_KEY_RIGHT );
1602 KEY( VK_DOWN, GLUT_KEY_DOWN );
1603 KEY( VK_INSERT, GLUT_KEY_INSERT );
1607 * The delete key should be treated as an ASCII keypress:
1609 if( window->Callbacks.KeyboardUp )
1611 fgSetWindow( window );
1612 window->Callbacks.KeyboardUp( 127, window->State.MouseX,
1613 window->State.MouseY );
1623 GetKeyboardState( state );
1625 if( ToAscii( wParam, 0, state, code, 0 ) == 1 )
1628 if( window->Callbacks.KeyboardUp )
1630 fgSetWindow( window );
1631 window->Callbacks.KeyboardUp( (char)wParam,
1632 window->State.MouseX,
1633 window->State.MouseY );
1638 if( (keypress != -1) && window->Callbacks.SpecialUp )
1640 fgSetWindow( window );
1641 window->Callbacks.SpecialUp( keypress, window->State.MouseX,
1642 window->State.MouseY );
1645 window->State.Modifiers = 0xffffffff;
1652 if( fgState.IgnoreKeyRepeat && (lParam & KF_REPEAT) )
1655 if( window->Callbacks.Keyboard )
1657 fgSetWindow( window );
1658 window->State.Modifiers =
1659 ( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
1660 ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
1661 ( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
1662 ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
1663 ( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
1664 ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
1666 window->Callbacks.Keyboard( (char)wParam, window->State.MouseX,
1667 window->State.MouseY );
1668 window->State.Modifiers = 0xffffffff;
1673 case WM_CAPTURECHANGED:
1674 /* User has finished resizing the window, force a redraw */
1675 if( window->Callbacks.Display )
1677 fgSetWindow( window );
1679 window->Callbacks.Display( );
1682 /*lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ) ; */
1686 * Other messages that I have seen and which are not handled already
1688 case WM_SETTEXT: /* 0x000c */
1689 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1690 /* Pass it on to "DefWindowProc" to set the window text */
1693 case WM_GETTEXT: /* 0x000d */
1694 /* Ideally we would copy the title of the window into "lParam" */
1695 /* strncpy ( (char *)lParam, "Window Title", wParam );
1696 lRet = ( wParam > 12 ) ? 12 : wParam; */
1697 /* the number of characters copied */
1698 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1701 case WM_GETTEXTLENGTH: /* 0x000e */
1702 /* Ideally we would get the length of the title of the window */
1704 /* the number of characters in "Window Title\0" (see above) */
1707 case WM_ERASEBKGND: /* 0x0014 */
1708 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1711 case WM_SYNCPAINT: /* 0x0088 */
1712 /* Another window has moved, need to update this one */
1713 window->State.Redisplay = TRUE;
1714 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1715 /* Help screen says this message must be passed to "DefWindowProc" */
1718 case WM_NCPAINT: /* 0x0085 */
1719 /* Need to update the border of this window */
1720 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1721 /* Pass it on to "DefWindowProc" to repaint a standard border */
1726 * Handle unhandled messages
1728 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1736 /*** END OF FILE ***/