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 #include "../include/GL/freeglut.h"
33 #include "freeglut_internal.h"
36 #if TARGET_HOST_UNIX_X11
37 #include <sys/types.h>
42 #elif TARGET_HOST_WIN32
46 #define MAX(a,b) (((a)>(b)) ? (a) : (b))
50 #define MIN(a,b) (((a)<(b)) ? (a) : (b))
55 * TODO BEFORE THE STABLE RELEASE:
57 * There are some issues concerning window redrawing under X11, and maybe
58 * some events are not handled. The Win32 version lacks some more features,
59 * but seems acceptable for not demanding purposes.
61 * Need to investigate why the X11 version breaks out with an error when
62 * closing a window (using the window manager, not glutDestroyWindow)...
65 /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
68 * Calls a window's redraw method. This is used when
69 * a redraw is forced by the incoming window messages.
71 * XXX We can/should make a "unified" window handle type so that
72 * XXX the function headers don't need this silly #ifdef junk.
73 * XXX Make the type, say, {fgWindow}. On UNIX_X11, this is
74 * XXX {Window}. On WIN32, it is {HWND}. Then do the #ifdef
75 * XXX junk *once* in "freeglut_internal.h".
77 static void fghRedrawWindowByHandle
78 #if TARGET_HOST_UNIX_X11
80 #elif TARGET_HOST_WIN32
84 SFG_Window* window = fgWindowByHandle( handle );
85 freeglut_return_if_fail( window != NULL );
86 freeglut_return_if_fail( FETCH_WCB( *window, Display ) );
87 freeglut_return_if_fail( window->State.Visible == TRUE );
89 /* fgSetWindow( window ); */
90 window->State.Redisplay = FALSE;
91 /* window->Callbacks.Display( ); */
92 INVOKE_WCB( *window, Display, ( ) );
96 * Handle a window configuration change. When no reshape
97 * callback is hooked, the viewport size is updated to
98 * match the new window size.
100 static void fghReshapeWindowByHandle
101 #if TARGET_HOST_UNIX_X11
102 ( Window handle, int width, int height )
103 #elif TARGET_HOST_WIN32
104 ( HWND handle, int width, int height )
107 SFG_Window *current_window = fgStructure.Window;
109 SFG_Window* window = fgWindowByHandle( handle );
110 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 );
119 if( !( FETCH_WCB( *window, Reshape ) ) )
121 fgSetWindow( window );
122 glViewport( 0, 0, width, height );
125 INVOKE_WCB( *window, Reshape, ( width, height ) );
128 * Force a window redraw. In Windows at least this is only a partial
129 * solution: if the window is increasing in size in either dimension,
130 * the already-drawn part does not get drawn again and things look funny.
131 * But without this we get this bad behaviour whenever we resize the
134 window->State.Redisplay = TRUE;
137 fgSetWindow( current_window );
141 * A static helper function to execute display callback for a window
143 static void fghcbDisplayWindow( SFG_Window *window, SFG_Enumerator *enumerator )
145 #if TARGET_HOST_UNIX_X11
146 if( ( FETCH_WCB( *window, Display ) ) &&
147 ( window->State.Redisplay == TRUE ) &&
148 ( window->State.Visible == TRUE ) )
150 SFG_Window *current_window = fgStructure.Window ;
152 /* fgSetWindow( window ); */
153 window->State.Redisplay = FALSE;
154 /* window->Callbacks.Display( ); */
155 INVOKE_WCB( *window, Display, ( ) );
156 fgSetWindow( current_window );
159 #elif TARGET_HOST_WIN32
161 if( window->State.NeedToResize )
163 SFG_Window *current_window = fgStructure.Window;
165 fgSetWindow( window );
167 fghReshapeWindowByHandle(
168 window->Window.Handle,
169 glutGet( GLUT_WINDOW_WIDTH ),
170 glutGet( GLUT_WINDOW_HEIGHT )
173 window->State.NeedToResize = FALSE;
174 fgSetWindow ( current_window );
177 if( ( FETCH_WCB( *window, Display ) ) &&
178 ( window->State.Redisplay == TRUE ) &&
179 ( window->State.Visible == TRUE ) )
181 window->State.Redisplay = FALSE;
184 window->Window.Handle, NULL, NULL,
185 RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE | RDW_UPDATENOW
191 fgEnumSubWindows( window, fghcbDisplayWindow, enumerator );
195 * Make all windows perform a display call
197 static void fghDisplayAll( void )
199 SFG_Enumerator enumerator;
201 enumerator.found = FALSE;
202 enumerator.data = NULL;
204 fgEnumWindows( fghcbDisplayWindow, &enumerator );
208 * Window enumerator callback to check for the joystick polling code
210 static void fghcbCheckJoystickPolls( SFG_Window *window,
211 SFG_Enumerator *enumerator )
213 long int checkTime = fgElapsedTime( );
215 if( window->State.JoystickLastPoll + window->State.JoystickPollRate <=
218 fgJoystickPollWindow( window );
219 window->State.JoystickLastPoll = checkTime;
222 fgEnumSubWindows( window, fghcbCheckJoystickPolls, enumerator );
226 * Check all windows for joystick polling
228 static void fghCheckJoystickPolls( void )
230 SFG_Enumerator enumerator;
232 enumerator.found = FALSE;
233 enumerator.data = NULL;
235 fgEnumWindows( fghcbCheckJoystickPolls, &enumerator );
239 * Check the global timers
241 static void fghCheckTimers( void )
243 long checkTime = fgElapsedTime( );
244 SFG_Timer *timer, *next;
247 fgListInit(&timedOut);
249 for( timer = (SFG_Timer *)fgState.Timers.First;
251 timer = (SFG_Timer *)next )
253 next = (SFG_Timer *)timer->Node.Next;
255 if( timer->TriggerTime <= checkTime )
257 fgListRemove( &fgState.Timers, &timer->Node );
258 fgListAppend( &timedOut, &timer->Node );
263 * Now feel free to execute all the hooked and timed out timer callbacks
264 * And delete the timed out timers...
266 while ( (timer = (SFG_Timer *)timedOut.First) )
268 if( timer->Callback != NULL )
269 timer->Callback( timer->ID );
270 fgListRemove( &timedOut, &timer->Node );
279 long fgElapsedTime( void )
281 #if TARGET_HOST_UNIX_X11
285 gettimeofday( &now, NULL );
287 elapsed = (now.tv_usec - fgState.Time.Value.tv_usec) / 1000;
288 elapsed += (now.tv_sec - fgState.Time.Value.tv_sec) * 1000;
291 #elif TARGET_HOST_WIN32
292 return timeGetTime() - fgState.Time.Value;
299 void fgError( const char *fmt, ... )
305 fprintf( stderr, "freeglut ");
306 if( fgState.ProgramName )
307 fprintf (stderr, "(%s): ", fgState.ProgramName);
308 vfprintf( stderr, fmt, ap );
309 fprintf( stderr, "\n" );
316 void fgWarning( const char *fmt, ... )
322 fprintf( stderr, "freeglut ");
323 if( fgState.ProgramName )
324 fprintf( stderr, "(%s): ", fgState.ProgramName );
325 vfprintf( stderr, fmt, ap );
326 fprintf( stderr, "\n" );
332 * Indicates whether Joystick events are being used by ANY window.
334 * The current mechanism is to walk all of the windows and ask if
335 * there is a joystick callback. Certainly in some cases, maybe
336 * in all cases, the joystick is attached to the system and accessed
337 * from ONE point by GLUT/freeglut, so this is not the right way,
338 * in general, to do this. However, the Joystick code is segregated
339 * in its own little world, so we can't access the information that
340 * we need in order to do that nicely.
343 * * Store Joystick data into freeglut global state.
344 * * Provide NON-static functions or data from Joystick *.c file.
346 * Basically, the RIGHT way to do this requires knowing something
347 * about the Joystick. Right now, the Joystick code is behind
351 static void fgCheckJoystickCallback( SFG_Window* w, SFG_Enumerator* e)
353 if( FETCH_WCB( *w, Joystick ) )
358 fgEnumSubWindows( w, fgCheckJoystickCallback, e );
360 static int fgHaveJoystick( void )
362 SFG_Enumerator enumerator;
363 enumerator.found = FALSE;
364 enumerator.data = NULL;
365 fgEnumWindows( fgCheckJoystickCallback, &enumerator );
366 return !!enumerator.data;
368 static void fgHavePendingRedisplaysCallback( SFG_Window* w, SFG_Enumerator* e)
370 if( w->State.Redisplay )
375 fgEnumSubWindows( w, fgHavePendingRedisplaysCallback, e );
377 static int fgHavePendingRedisplays (void)
379 SFG_Enumerator enumerator;
380 enumerator.found = FALSE;
381 enumerator.data = NULL;
382 fgEnumWindows( fgHavePendingRedisplaysCallback, &enumerator );
383 return !!enumerator.data;
386 * Indicates whether there are any outstanding timers.
388 static int fgHaveTimers( void )
390 return !!fgState.Timers.First;
393 * Returns the number of GLUT ticks (milliseconds) till the next timer event.
395 static long fgNextTimer( void )
397 long now = fgElapsedTime();
401 for( timer = (SFG_Timer *)fgState.Timers.First;
403 timer = (SFG_Timer *)timer->Node.Next )
404 ret = MIN( ret, MAX( 0, (timer->TriggerTime) - now ) );
409 * Does the magic required to relinquish the CPU until something interesting
412 static void fgSleepForEvents( void )
414 #if TARGET_HOST_UNIX_X11
421 if( fgState.IdleCallback || fgHavePendingRedisplays( ) )
423 socket = ConnectionNumber( fgDisplay.Display );
425 FD_SET( socket, &fdset );
427 msec = fgNextTimer( );
428 if( fgHaveJoystick( ) )
429 msec = MIN( msec, 10 );
431 wait.tv_sec = msec / 1000;
432 wait.tv_usec = (msec % 1000) * 1000;
433 err = select( socket+1, &fdset, NULL, NULL, &wait );
436 printf( "freeglut select() error: %d\n", errno );
438 #elif TARGET_HOST_WIN32
442 #if TARGET_HOST_UNIX_X11
444 * Returns GLUT modifier mask for an XEvent.
446 int fgGetXModifiers( XEvent *event )
450 if( event->xkey.state & ( ShiftMask | LockMask ) )
451 ret |= GLUT_ACTIVE_SHIFT;
452 if( event->xkey.state & ControlMask )
453 ret |= GLUT_ACTIVE_CTRL;
454 if( event->xkey.state & Mod1Mask )
455 ret |= GLUT_ACTIVE_ALT;
462 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
465 * Executes a single iteration in the freeglut processing loop.
467 void FGAPIENTRY glutMainLoopEvent( void )
469 #if TARGET_HOST_UNIX_X11
474 * This code was repeated constantly, so here it goes into a definition:
476 #define GETWINDOW(a) \
477 window = fgWindowByHandle( event.a.window ); \
478 if( window == NULL ) \
481 #define GETMOUSE(a) \
482 window->State.MouseX = event.a.x; \
483 window->State.MouseY = event.a.y;
485 freeglut_assert_ready;
487 while( XPending( fgDisplay.Display ) )
489 XNextEvent( fgDisplay.Display, &event );
495 * This is sent to confirm the XDestroyWindow call.
496 * XXX WHY is this commented out? Should we re-enable it?
498 /* fgAddToWindowDestroyList ( window, FALSE ); */
503 * Destroy the window when the WM_DELETE_WINDOW message arrives
505 if( (Atom) event.xclient.data.l[ 0 ] == fgDisplay.DeleteWindow )
507 GETWINDOW( xclient );
509 fgCloseWindow ( window ) ;
510 fgAddToWindowDestroyList ( window, FALSE );
517 * If we never do anything with this, can we just not ask to
518 * get these messages?
524 * We are too dumb to process partial exposes...
525 * XXX Well, we could do it. However, it seems to only
526 * XXX be potentially useful for single-buffered (since
527 * XXX double-buffered does not respect viewport when we
528 * XXX do a buffer-swap).
530 if( event.xexpose.count == 0 )
531 fghRedrawWindowByHandle( event.xexpose.window );
535 * CreateNotify causes a configure-event so that sub-windows are
536 * handled compatibly with GLUT. Otherwise, your sub-windows
537 * (in freeglut only) will not get an initial reshape event,
538 * which can break things.
540 * XXX NOTE that it is possible that you will more than one Reshape
541 * XXX event for your top-level window, but something like this
542 * XXX appears to be required for compatbility.
544 * GLUT presumably does this because it generally tries to treat
545 * sub-windows the same as windows.
548 case ConfigureNotify:
549 fghReshapeWindowByHandle(
550 event.xconfigure.window,
551 event.xconfigure.width,
552 event.xconfigure.height
558 * Have the client's keyboard knowledge updated (xlib.ps,
559 * page 206, says that's a good thing to do)
561 XRefreshKeyboardMapping( (XMappingEvent *) &event );
564 case VisibilityNotify:
566 GETWINDOW( xvisibility );
567 if( ! FETCH_WCB( *window, WindowStatus ) )
569 fgSetWindow( window );
572 * Sending this event, the X server can notify us that the window
573 * has just acquired one of the three possible visibility states:
574 * VisibilityUnobscured, VisibilityPartiallyObscured or
575 * VisibilityFullyObscured
577 switch( event.xvisibility.state )
579 case VisibilityUnobscured:
580 INVOKE_WCB( *window, WindowStatus, ( GLUT_FULLY_RETAINED ) );
581 window->State.Visible = TRUE;
584 case VisibilityPartiallyObscured:
585 INVOKE_WCB( *window, WindowStatus,
586 ( GLUT_PARTIALLY_RETAINED ) );
587 window->State.Visible = TRUE;
590 case VisibilityFullyObscured:
591 INVOKE_WCB( *window, WindowStatus, ( GLUT_FULLY_COVERED ) );
592 window->State.Visible = FALSE;
596 fgWarning( "Uknown X visibility state: %d",
597 event.xvisibility.state );
605 GETWINDOW( xcrossing );
606 GETMOUSE( xcrossing );
608 * if( window->Callbacks.Entry )
610 * fgSetWindow( window ) ;
611 * window->Callbacks.Entry( GLUT_ENTERED );
614 INVOKE_WCB( *window, Entry, ( GLUT_ENTERED ) );
617 /* XXX Combine EnterNotify and LeaveNotify */
620 GETWINDOW( xcrossing );
621 GETMOUSE( xcrossing );
623 * if( window->Callbacks.Entry )
625 * fgSetWindow( window ) ;
626 * window->Callbacks.Entry( GLUT_LEFT );
629 INVOKE_WCB( *window, Entry, ( GLUT_LEFT ) );
635 GETWINDOW( xmotion );
638 if( window->ActiveMenu )
640 if( window == window->ActiveMenu->ParentWindow )
642 window->ActiveMenu->Window->State.MouseX =
643 event.xmotion.x_root - window->ActiveMenu->X;
644 window->ActiveMenu->Window->State.MouseY =
645 event.xmotion.y_root - window->ActiveMenu->Y;
647 window->ActiveMenu->Window->State.Redisplay = TRUE ;
648 fgSetWindow( window->ActiveMenu->ParentWindow ) ;
654 * XXX For more than 5 buttons, just check {event.xmotion.state},
655 * XXX rather than a host of bit-masks?
657 if( (event.xmotion.state & Button1Mask) ||
658 (event.xmotion.state & Button2Mask) ||
659 (event.xmotion.state & Button3Mask) ||
660 (event.xmotion.state & Button4Mask) ||
661 (event.xmotion.state & Button5Mask) )
664 * A mouse button was pressed during the movement...
665 * Is there a motion callback hooked to the window?
668 * if( window->Callbacks.Motion )
670 * fgSetWindow ( window ) ;
671 * window->Callbacks.Motion( event.xmotion.x,
675 INVOKE_WCB( *window, Motion, ( event.xmotion.x,
681 * if( window->Callbacks.Passive )
683 * fgSetWindow( window );
684 * window->Callbacks.Passive( event.xmotion.x,
688 INVOKE_WCB( *window, Passive, ( event.xmotion.x,
697 GLboolean pressed = TRUE;
700 if( event.type == ButtonRelease )
704 * A mouse button has been pressed or released. Traditionally,
705 * break if the window was found within the freeglut structures.
707 GETWINDOW( xbutton );
711 * An X button (at least in XFree86) is numbered from 1.
712 * A GLUT button is numbered from 0.
713 * Old GLUT passed through buttons other than just the first
714 * three, though it only gave symbolic names and official
715 * support to the first three.
717 button = event.xbutton.button - 1;
720 * Do not execute the application's mouse callback if a menu
721 * is hooked to this button. In that case an appropriate
722 * private call should be generated.
723 * Near as I can tell, this is the menu behaviour:
724 * - Down-click the menu button, menu not active: activate
725 * the menu with its upper left-hand corner at the mouse
727 * - Down-click any button outside the menu, menu active:
728 * deactivate the menu
729 * - Down-click any button inside the menu, menu active:
730 * select the menu entry and deactivate the menu
731 * - Up-click the menu button, menu not active: nothing happens
732 * - Up-click the menu button outside the menu, menu active:
734 * - Up-click the menu button inside the menu, menu active:
735 * select the menu entry and deactivate the menu
737 /* Window has an active menu, it absorbs any mouse click */
738 if( window->ActiveMenu )
740 if( window == window->ActiveMenu->ParentWindow )
742 window->ActiveMenu->Window->State.MouseX =
743 event.xbutton.x_root - window->ActiveMenu->X;
744 window->ActiveMenu->Window->State.MouseY =
745 event.xbutton.y_root - window->ActiveMenu->Y;
748 /* In the menu, invoke the callback and deactivate the menu*/
749 if( fgCheckActiveMenu( window->ActiveMenu->Window,
750 window->ActiveMenu ) == TRUE )
753 * Save the current window and menu and set the current
754 * window to the window whose menu this is
756 SFG_Window *save_window = fgStructure.Window;
757 SFG_Menu *save_menu = fgStructure.Menu;
758 SFG_Window *parent_window =
759 window->ActiveMenu->ParentWindow;
760 fgSetWindow( parent_window );
761 fgStructure.Menu = window->ActiveMenu;
763 /* Execute the menu callback */
764 fgExecuteMenuCallback( window->ActiveMenu );
765 fgDeactivateMenu( parent_window );
767 /* Restore the current window and menu */
768 fgSetWindow( save_window );
769 fgStructure.Menu = save_menu;
773 * Outside the menu, deactivate if it's a downclick
774 * XXX This isn't enough. A downclick outside of
775 * XXX the interior of our freeglut windows should also
776 * XXX deactivate the menu. This is more complicated.
778 fgDeactivateMenu( window->ActiveMenu->ParentWindow );
780 window->State.Redisplay = TRUE;
785 * No active menu, let's check whether we need to activate one.
787 if( ( 0 <= button ) &&
789 ( window->Menu[ button ] ) &&
792 window->State.Redisplay = TRUE;
793 fgSetWindow( window );
794 fgActivateMenu( window, button );
799 * Check if there is a mouse or mouse wheel callback hooked to the
802 if( ! FETCH_WCB( *window, Mouse ) &&
803 ! FETCH_WCB( *window, MouseWheel ) )
806 /* fgSetWindow( window ); */
809 * XXX Why don't we use {window}? Other code here does...
811 fgStructure.Window->State.Modifiers = fgGetXModifiers( &event );
814 * Finally execute the mouse or mouse wheel callback
816 * XXX Use a symbolic constant, *not* "4"!
818 if( ( button < 4 ) || ( ! FETCH_WCB( *window, MouseWheel ) ) )
821 * if( window->Callbacks.Mouse )
822 * fgStructure.Window->Callbacks.Mouse(
824 * pressed ? GLUT_DOWN : GLUT_UP,
829 INVOKE_WCB( *window, Mouse, ( button,
830 pressed ? GLUT_DOWN : GLUT_UP,
838 * Map 4 and 5 to wheel zero; EVEN to +1, ODD to -1
839 * " 6 and 7 " " one; ...
841 * XXX This *should* be behind some variables/macros,
842 * XXX since the order and numbering isn't certain
843 * XXX See XFree86 configuration docs (even back in the
844 * XXX 3.x days, and especially with 4.x).
846 int wheel_number = (button - 4) / 2;
847 int direction = (button & 1)*2 - 1;
851 * fgStructure.Window->Callbacks.MouseWheel(
859 INVOKE_WCB( *window, MouseWheel, ( wheel_number,
867 * Trash the modifiers state
869 fgStructure.Window->State.Modifiers = 0xffffffff;
876 FGCBKeyboard keyboard_cb;
877 FGCBSpecial special_cb;
882 if( event.type == KeyPress )
884 keyboard_cb = FETCH_WCB( *window, Keyboard );
885 special_cb = FETCH_WCB( *window, Special );
889 keyboard_cb = FETCH_WCB( *window, KeyboardUp );
890 special_cb = FETCH_WCB( *window, SpecialUp );
894 * Is there a keyboard/special callback hooked for this window?
896 if( keyboard_cb || special_cb )
898 XComposeStatus composeStatus;
899 char asciiCode[ 32 ];
904 * Check for the ASCII/KeySym codes associated with the event:
906 len = XLookupString( &event.xkey, asciiCode, sizeof(asciiCode),
907 &keySym, &composeStatus );
910 * GLUT API tells us to have two separate callbacks...
915 * ...one for the ASCII translateable keypresses...
919 fgSetWindow( window );
920 window->State.Modifiers = fgGetXModifiers( &event );
921 keyboard_cb( asciiCode[ 0 ],
922 event.xkey.x, event.xkey.y );
923 window->State.Modifiers = 0xffffffff;
931 * ...and one for all the others, which need to be
932 * translated to GLUT_KEY_Xs...
936 case XK_F1: special = GLUT_KEY_F1; break;
937 case XK_F2: special = GLUT_KEY_F2; break;
938 case XK_F3: special = GLUT_KEY_F3; break;
939 case XK_F4: special = GLUT_KEY_F4; break;
940 case XK_F5: special = GLUT_KEY_F5; break;
941 case XK_F6: special = GLUT_KEY_F6; break;
942 case XK_F7: special = GLUT_KEY_F7; break;
943 case XK_F8: special = GLUT_KEY_F8; break;
944 case XK_F9: special = GLUT_KEY_F9; break;
945 case XK_F10: special = GLUT_KEY_F10; break;
946 case XK_F11: special = GLUT_KEY_F11; break;
947 case XK_F12: special = GLUT_KEY_F12; break;
949 case XK_Left: special = GLUT_KEY_LEFT; break;
950 case XK_Right: special = GLUT_KEY_RIGHT; break;
951 case XK_Up: special = GLUT_KEY_UP; break;
952 case XK_Down: special = GLUT_KEY_DOWN; break;
955 case XK_Prior: special = GLUT_KEY_PAGE_UP; break;
957 case XK_Next: special = GLUT_KEY_PAGE_DOWN; break;
959 case XK_Home: special = GLUT_KEY_HOME; break;
961 case XK_End: special = GLUT_KEY_END; break;
963 case XK_Insert: special = GLUT_KEY_INSERT; break;
967 * Execute the callback (if one has been specified),
968 * given that the special code seems to be valid...
970 if( special_cb && (special != -1) )
972 fgSetWindow( window );
973 window->State.Modifiers = fgGetXModifiers( &event );
974 special_cb( special, event.xkey.x, event.xkey.y );
975 window->State.Modifiers = 0xffffffff;
983 fgWarning ("Unknown X event type: %d", event.type);
988 #elif TARGET_HOST_WIN32
992 while( PeekMessage( &stMsg, NULL, 0, 0, PM_NOREMOVE ) )
994 if( GetMessage( &stMsg, NULL, 0, 0 ) == 0 )
995 fgState.ExecState = GLUT_EXEC_STATE_STOP ;
997 TranslateMessage( &stMsg );
998 DispatchMessage( &stMsg );
1003 fghCheckJoystickPolls( );
1010 * Enters the freeglut processing loop.
1011 * Stays until the "ExecState" changes to "GLUT_EXEC_STATE_STOP".
1013 void FGAPIENTRY glutMainLoop( void )
1015 #if TARGET_HOST_WIN32
1016 SFG_Window *window = (SFG_Window *)fgStructure.Windows.First ;
1019 freeglut_assert_ready;
1021 #if TARGET_HOST_WIN32
1023 * Processing before the main loop: If there is a window which is open and
1024 * which has a visibility callback, call it. I know this is an ugly hack,
1025 * but I'm not sure what else to do about it. Ideally we should leave
1026 * something uninitialized in the create window code and initialize it in
1027 * the main loop, and have that initialization create a "WM_ACTIVATE"
1028 * message. Then we would put the visibility callback code in the
1029 * "case WM_ACTIVATE" block below. - John Fay -- 10/24/02
1033 if ( FETCH_WCB( *window, Visibility ) )
1035 SFG_Window *current_window = fgStructure.Window ;
1038 * fgSetWindow( window );
1039 * window->Callbacks.Visibility ( window->State.Visible ) ;
1041 INVOKE_WCB( *window, Visibility, ( window->State.Visible ) );
1042 fgSetWindow( current_window );
1045 window = (SFG_Window *)window->Node.Next ;
1049 fgState.ExecState = GLUT_EXEC_STATE_RUNNING ;
1050 while( fgState.ExecState == GLUT_EXEC_STATE_RUNNING )
1052 glutMainLoopEvent( );
1054 if( fgStructure.Windows.First == NULL )
1055 fgState.ExecState = GLUT_EXEC_STATE_STOP;
1058 if( fgState.IdleCallback )
1059 fgState.IdleCallback( );
1066 fgExecutionState execState = fgState.ExecState;
1069 * When this loop terminates, destroy the display, state and structure
1070 * of a freeglut session, so that another glutInit() call can happen
1074 if( execState == GLUT_ACTION_EXIT )
1080 * Leaves the freeglut processing loop.
1082 void FGAPIENTRY glutLeaveMainLoop( void )
1084 fgState.ExecState = GLUT_EXEC_STATE_STOP ;
1088 #if TARGET_HOST_WIN32
1090 * Determine a GLUT modifer mask based on MS-WINDOWS system info.
1092 int fgGetWin32Modifiers (void)
1095 ( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
1096 ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
1097 ( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
1098 ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
1099 ( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
1100 ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
1104 * The window procedure for handling Win32 events
1106 LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
1109 SFG_Window* window = fgWindowByHandle( hWnd );
1113 if ( ( window == NULL ) && ( uMsg != WM_CREATE ) )
1114 return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
1116 /* printf ( "Window %3d message <%04x> %12d %12d\n", window?window->ID:0,
1117 uMsg, wParam, lParam ); */
1122 * The window structure is passed as the creation structure paramter...
1124 window = (SFG_Window *) (((LPCREATESTRUCT) lParam)->lpCreateParams);
1125 assert( window != NULL );
1127 window->Window.Handle = hWnd;
1128 window->Window.Device = GetDC( hWnd );
1129 if( fgState.BuildingAMenu )
1131 unsigned int current_DisplayMode = fgState.DisplayMode;
1132 fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH;
1133 fgSetupPixelFormat( window, FALSE, PFD_MAIN_PLANE );
1134 fgState.DisplayMode = current_DisplayMode;
1136 if( fgStructure.MenuContext )
1137 wglMakeCurrent( window->Window.Device,
1138 fgStructure.MenuContext->Context ) ;
1141 fgStructure.MenuContext =
1142 (SFG_MenuContext *)malloc( sizeof(SFG_MenuContext) );
1143 fgStructure.MenuContext->Context =
1144 wglCreateContext( window->Window.Device );
1147 /* window->Window.Context = wglGetCurrentContext () ; */
1148 window->Window.Context = wglCreateContext( window->Window.Device );
1152 fgSetupPixelFormat( window, FALSE, PFD_MAIN_PLANE );
1154 if( fgState.UseCurrentContext != TRUE )
1155 window->Window.Context =
1156 wglCreateContext( window->Window.Device );
1159 window->Window.Context = wglGetCurrentContext( );
1160 if( ! window->Window.Context )
1161 window->Window.Context =
1162 wglCreateContext( window->Window.Device );
1166 window->State.NeedToResize = TRUE;
1167 ReleaseDC( window->Window.Handle, window->Window.Device );
1172 * We got resized... But check if the window has been already added...
1174 fghReshapeWindowByHandle( hWnd, LOWORD(lParam), HIWORD(lParam) );
1178 printf("WM_SETFOCUS: %p\n", window );
1179 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1183 if (LOWORD(wParam) != WA_INACTIVE)
1185 /* glutSetCursor( fgStructure.Window->State.Cursor ); */
1186 printf("WM_ACTIVATE: glutSetCursor( %p, %d)\n", window,
1187 window->State.Cursor );
1188 glutSetCursor( window->State.Cursor );
1191 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1197 * Windows seems to need reminding to erase the cursor for NONE.
1200 if ((LOWORD(lParam) == HTCLIENT) &&
1201 (fgStructure.Window->State.Cursor == GLUT_CURSOR_NONE))
1205 /* Set the cursor AND change it for this window class. */
1206 #define MAP_CURSOR(a,b) \
1208 SetCursor( LoadCursor( NULL, b ) ); \
1211 /* Nuke the cursor AND change it for this window class. */
1212 #define ZAP_CURSOR(a,b) \
1214 SetCursor( NULL ); \
1217 if( LOWORD( lParam ) == HTCLIENT )
1218 switch( window->State.Cursor )
1220 MAP_CURSOR( GLUT_CURSOR_RIGHT_ARROW, IDC_ARROW );
1221 MAP_CURSOR( GLUT_CURSOR_LEFT_ARROW, IDC_ARROW );
1222 MAP_CURSOR( GLUT_CURSOR_INFO, IDC_HELP );
1223 MAP_CURSOR( GLUT_CURSOR_DESTROY, IDC_CROSS );
1224 MAP_CURSOR( GLUT_CURSOR_HELP, IDC_HELP );
1225 MAP_CURSOR( GLUT_CURSOR_CYCLE, IDC_SIZEALL );
1226 MAP_CURSOR( GLUT_CURSOR_SPRAY, IDC_CROSS );
1227 MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT );
1228 MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_UPARROW );
1229 MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS );
1230 /* MAP_CURSOR( GLUT_CURSOR_NONE, IDC_NO ); */
1231 ZAP_CURSOR( GLUT_CURSOR_NONE, NULL );
1234 MAP_CURSOR( GLUT_CURSOR_UP_DOWN, IDC_ARROW );
1238 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1242 window->State.Visible = TRUE;
1243 window->State.Redisplay = TRUE;
1247 BeginPaint( hWnd, &ps );
1248 fghRedrawWindowByHandle( hWnd );
1249 EndPaint( hWnd, &ps );
1254 * Make sure we don't close a window with current context active
1256 if( fgStructure.Window == window )
1261 wglMakeCurrent( NULL, NULL );
1263 * Step through the list of windows. If the rendering context
1264 * is not being used by another window, then we delete it.
1266 for( iter = (SFG_Window *)fgStructure.Windows.First;
1268 iter = (SFG_Window *)iter->Node.Next )
1270 if( ( iter->Window.Context == window->Window.Context ) &&
1271 ( iter != window ) )
1276 wglDeleteContext( window->Window.Context );
1280 * Put on a linked list of windows to be removed after all the
1281 * callbacks have returned
1283 fgAddToWindowDestroyList( window, FALSE );
1284 DestroyWindow( hWnd );
1289 * The window already got destroyed, so don't bother with it.
1295 window->State.MouseX = LOWORD( lParam );
1296 window->State.MouseY = HIWORD( lParam );
1298 if ( window->ActiveMenu )
1300 window->State.Redisplay = TRUE;
1301 fgSetWindow ( window->ActiveMenu->ParentWindow );
1305 window->State.Modifiers = fgGetWin32Modifiers( );
1307 if( ( wParam & MK_LBUTTON ) ||
1308 ( wParam & MK_MBUTTON ) ||
1309 ( wParam & MK_RBUTTON ) )
1312 * if( window->Callbacks.Motion )
1314 * fgSetWindow( window );
1315 * window->Callbacks.Motion( window->State.MouseX,
1316 * window->State.MouseY );
1319 INVOKE_WCB( *window, Motion, ( window->State.MouseX,
1320 window->State.MouseY ) );
1325 * if( window->Callbacks.Passive )
1327 * fgSetWindow( window );
1328 * window->Callbacks.Passive( window->State.MouseX,
1329 * window->State.MouseY );
1332 INVOKE_WCB( *window, Passive, ( window->State.MouseX,
1333 window->State.MouseY ) );
1336 window->State.Modifiers = 0xffffffff;
1340 case WM_LBUTTONDOWN:
1341 case WM_MBUTTONDOWN:
1342 case WM_RBUTTONDOWN:
1347 GLboolean pressed = TRUE;
1350 window->State.MouseX = LOWORD( lParam );
1351 window->State.MouseY = HIWORD( lParam );
1355 case WM_LBUTTONDOWN:
1356 pressed = TRUE; button = GLUT_LEFT_BUTTON; break;
1357 case WM_MBUTTONDOWN:
1358 pressed = TRUE; button = GLUT_MIDDLE_BUTTON; break;
1359 case WM_RBUTTONDOWN:
1360 pressed = TRUE; button = GLUT_RIGHT_BUTTON; break;
1362 pressed = FALSE; button = GLUT_LEFT_BUTTON; break;
1364 pressed = FALSE; button = GLUT_MIDDLE_BUTTON; break;
1366 pressed = FALSE; button = GLUT_RIGHT_BUTTON; break;
1368 pressed = FALSE; button = -1; break;
1371 if( GetSystemMetrics( SM_SWAPBUTTON ) )
1372 if( button == GLUT_LEFT_BUTTON )
1373 button = GLUT_RIGHT_BUTTON;
1374 else if( button == GLUT_RIGHT_BUTTON )
1375 button = GLUT_LEFT_BUTTON;
1378 return DefWindowProc( hWnd, uMsg, lParam, wParam );
1381 * Do not execute the application's mouse callback if a
1382 * menu is hooked to this button.
1383 * In that case an appropriate private call should be generated.
1384 * Near as I can tell, this is the menu behaviour:
1385 * - Down-click the menu button, menu not active: activate
1386 * the menu with its upper left-hand corner at the mouse location.
1387 * - Down-click any button outside the menu, menu active:
1388 * deactivate the menu
1389 * - Down-click any button inside the menu, menu active:
1390 * select the menu entry and deactivate the menu
1391 * - Up-click the menu button, menu not active: nothing happens
1392 * - Up-click the menu button outside the menu, menu active:
1394 * - Up-click the menu button inside the menu, menu active:
1395 * select the menu entry and deactivate the menu
1397 /* Window has an active menu, it absorbs any mouse click */
1398 if( window->ActiveMenu )
1400 /* Inside the menu, invoke the callback and deactivate the menu*/
1401 if( fgCheckActiveMenu( window, window->ActiveMenu ) == TRUE )
1404 * Save the current window and menu and set the current
1405 * window to the window whose menu this is
1407 SFG_Window *save_window = fgStructure.Window;
1408 SFG_Menu *save_menu = fgStructure.Menu;
1409 SFG_Window *parent_window = window->ActiveMenu->ParentWindow;
1410 fgSetWindow( parent_window );
1411 fgStructure.Menu = window->ActiveMenu;
1413 /* Execute the menu callback */
1414 fgExecuteMenuCallback( window->ActiveMenu );
1415 fgDeactivateMenu( parent_window );
1417 /* Restore the current window and menu */
1418 fgSetWindow( save_window );
1419 fgStructure.Menu = save_menu;
1421 else /* Out of menu, deactivate the menu if it's a downclick */
1423 if( pressed == TRUE )
1424 fgDeactivateMenu( window->ActiveMenu->ParentWindow );
1428 * Let's make the window redraw as a result of the mouse
1429 * click and menu activity.
1431 if( ! window->IsMenu )
1432 window->State.Redisplay = TRUE;
1437 if ( ( window->Menu[ button ] ) && ( pressed == TRUE ) )
1439 window->State.Redisplay = TRUE;
1440 fgSetWindow( window );
1441 fgActivateMenu( window, button );
1446 if( ! FETCH_WCB( *window, Mouse ) )
1449 fgSetWindow( window );
1450 fgStructure.Window->State.Modifiers = fgGetWin32Modifiers( );
1455 pressed == TRUE ? GLUT_DOWN : GLUT_UP,
1456 window->State.MouseX,
1457 window->State.MouseY
1461 * window->Callbacks.Mouse(
1463 * pressed == TRUE ? GLUT_DOWN : GLUT_UP,
1464 * window->State.MouseX,
1465 * window->State.MouseY
1469 fgStructure.Window->State.Modifiers = 0xffffffff;
1474 /* Should be WM_MOUSEWHEEL but my compiler doesn't recognize it */
1476 int wheel_number = LOWORD( wParam );
1477 /* THIS IS SPECULATIVE -- John Fay, 10/2/03 */
1478 short ticks = HIWORD( lParam ) / 120;
1479 /* Should be WHEEL_DELTA instead of 120 */
1489 * The mouse cursor has moved. Remember the new mouse cursor's position
1491 /* window->State.MouseX = LOWORD( lParam ); */
1492 /* Need to adjust by window position, */
1493 /* window->State.MouseY = HIWORD( lParam ); */
1494 /* change "lParam" to other parameter */
1496 if( ! FETCH_WCB( *window, MouseWheel ) &&
1497 ! FETCH_WCB( *window, Mouse ) )
1500 fgSetWindow( window );
1501 fgStructure.Window->State.Modifiers = fgGetWin32Modifiers( );
1504 if( FETCH_WCB( *window, MouseWheel ) )
1506 INVOKE_WCB( *window, MouseWheel,
1509 window->State.MouseX,
1510 window->State.MouseY
1515 * if( window->Callbacks.MouseWheel )
1516 * window->Callbacks.MouseWheel(
1519 * window->State.MouseX,
1520 * window->State.MouseY
1523 else /* No mouse wheel, call the mouse button callback twice */
1526 * XXX The below assumes that you have no more than 3 mouse
1527 * XXX buttons. Sorry.
1529 int button = wheel_number*2 + 4;
1532 INVOKE_WCB( *window, Mouse,
1533 ( button, GLUT_DOWN,
1534 window->State.MouseX, window->State.MouseY )
1536 INVOKE_WCB( *window, Mouse,
1538 window->State.MouseX, window->State.MouseX )
1542 * window->Callbacks.Mouse( button, GLUT_DOWN,
1543 * window->State.MouseX,
1544 * window->State.MouseY
1546 * window->Callbacks.Mouse( button, GLUT_UP,
1547 * window->State.MouseX,
1548 * window->State.MouseY
1553 fgStructure.Window->State.Modifiers = 0xffffffff;
1563 if( fgState.IgnoreKeyRepeat && (lParam & KF_REPEAT) )
1567 * Remember the current modifiers state. This is done here in order
1568 * to make sure the VK_DELETE keyboard callback is executed properly.
1570 window->State.Modifiers = fgGetWin32Modifiers( );
1572 GetCursorPos( &mouse_pos );
1573 ScreenToClient( window->Window.Handle, &mouse_pos );
1575 window->State.MouseX = mouse_pos.x;
1576 window->State.MouseY = mouse_pos.y;
1579 * Convert the Win32 keystroke codes to GLUTtish way
1581 # define KEY(a,b) case a: keypress = b; break;
1585 KEY( VK_F1, GLUT_KEY_F1 );
1586 KEY( VK_F2, GLUT_KEY_F2 );
1587 KEY( VK_F3, GLUT_KEY_F3 );
1588 KEY( VK_F4, GLUT_KEY_F4 );
1589 KEY( VK_F5, GLUT_KEY_F5 );
1590 KEY( VK_F6, GLUT_KEY_F6 );
1591 KEY( VK_F7, GLUT_KEY_F7 );
1592 KEY( VK_F8, GLUT_KEY_F8 );
1593 KEY( VK_F9, GLUT_KEY_F9 );
1594 KEY( VK_F10, GLUT_KEY_F10 );
1595 KEY( VK_F11, GLUT_KEY_F11 );
1596 KEY( VK_F12, GLUT_KEY_F12 );
1597 KEY( VK_PRIOR, GLUT_KEY_PAGE_UP );
1598 KEY( VK_NEXT, GLUT_KEY_PAGE_DOWN );
1599 KEY( VK_HOME, GLUT_KEY_HOME );
1600 KEY( VK_END, GLUT_KEY_END );
1601 KEY( VK_LEFT, GLUT_KEY_LEFT );
1602 KEY( VK_UP, GLUT_KEY_UP );
1603 KEY( VK_RIGHT, GLUT_KEY_RIGHT );
1604 KEY( VK_DOWN, GLUT_KEY_DOWN );
1605 KEY( VK_INSERT, GLUT_KEY_INSERT );
1609 * The delete key should be treated as an ASCII keypress:
1612 * if( window->Callbacks.Keyboard )
1614 * fgSetWindow( window );
1615 * window->Callbacks.Keyboard( 127, window->State.MouseX,
1616 * window->State.MouseY );
1619 INVOKE_WCB( *window, Keyboard,
1620 ( 127, window->State.MouseX, window->State.MouseY )
1624 /* if( ( keypress != -1 ) && window->Callbacks.Special )
1626 * fgSetWindow( window );
1627 * window->Callbacks.Special( keypress, window->State.MouseX,
1628 * window->State.MouseY );
1631 if( keypress != -1 )
1632 INVOKE_WCB( *window, Special,
1633 ( keypress, window->State.MouseX, window->State.MouseY )
1636 window->State.Modifiers = 0xffffffff;
1647 * Remember the current modifiers state. This is done here in order
1648 * to make sure the VK_DELETE keyboard callback is executed properly.
1650 window->State.Modifiers = fgGetWin32Modifiers( );
1652 GetCursorPos( &mouse_pos );
1653 ScreenToClient( window->Window.Handle, &mouse_pos );
1655 window->State.MouseX = mouse_pos.x;
1656 window->State.MouseY = mouse_pos.y;
1659 * Convert the Win32 keystroke codes to GLUTtish way.
1660 * "KEY(a,b)" was defined under "WM_KEYDOWN"
1665 KEY( VK_F1, GLUT_KEY_F1 );
1666 KEY( VK_F2, GLUT_KEY_F2 );
1667 KEY( VK_F3, GLUT_KEY_F3 );
1668 KEY( VK_F4, GLUT_KEY_F4 );
1669 KEY( VK_F5, GLUT_KEY_F5 );
1670 KEY( VK_F6, GLUT_KEY_F6 );
1671 KEY( VK_F7, GLUT_KEY_F7 );
1672 KEY( VK_F8, GLUT_KEY_F8 );
1673 KEY( VK_F9, GLUT_KEY_F9 );
1674 KEY( VK_F10, GLUT_KEY_F10 );
1675 KEY( VK_F11, GLUT_KEY_F11 );
1676 KEY( VK_F12, GLUT_KEY_F12 );
1677 KEY( VK_PRIOR, GLUT_KEY_PAGE_UP );
1678 KEY( VK_NEXT, GLUT_KEY_PAGE_DOWN );
1679 KEY( VK_HOME, GLUT_KEY_HOME );
1680 KEY( VK_END, GLUT_KEY_END );
1681 KEY( VK_LEFT, GLUT_KEY_LEFT );
1682 KEY( VK_UP, GLUT_KEY_UP );
1683 KEY( VK_RIGHT, GLUT_KEY_RIGHT );
1684 KEY( VK_DOWN, GLUT_KEY_DOWN );
1685 KEY( VK_INSERT, GLUT_KEY_INSERT );
1689 * The delete key should be treated as an ASCII keypress:
1691 /* if( window->Callbacks.KeyboardUp )
1693 * fgSetWindow( window );
1694 * window->Callbacks.KeyboardUp( 127, window->State.MouseX,
1695 * window->State.MouseY );
1698 INVOKE_WCB( *window, KeyboardUp,
1699 ( 127, window->State.MouseX, window->State.MouseY )
1708 GetKeyboardState( state );
1710 if( ToAscii( wParam, 0, state, code, 0 ) == 1 )
1714 * if( window->Callbacks.KeyboardUp )
1716 * fgSetWindow( window );
1717 * window->Callbacks.KeyboardUp( (char)wParam,
1718 * window->State.MouseX,
1719 * window->State.MouseY );
1722 INVOKE_WCB( *window, KeyboardUp,
1724 window->State.MouseX, window->State.MouseY )
1730 * if( (keypress != -1) && window->Callbacks.SpecialUp )
1732 * fgSetWindow( window );
1733 * window->Callbacks.SpecialUp( keypress, window->State.MouseX,
1734 * window->State.MouseY );
1737 if( keypress != -1 )
1738 INVOKE_WCB( *window, SpecialUp,
1740 window->State.MouseX, window->State.MouseY )
1743 window->State.Modifiers = 0xffffffff;
1750 if( fgState.IgnoreKeyRepeat && (lParam & KF_REPEAT) )
1753 if( FETCH_WCB( *window, Keyboard ) )
1755 /* fgSetWindow( window ); */
1756 window->State.Modifiers = fgGetWin32Modifiers( );
1757 /* window->Callbacks.Keyboard( (char)wParam, window->State.MouseX,
1758 window->State.MouseY ); */
1759 INVOKE_WCB( *window, Keyboard,
1761 window->State.MouseX, window->State.MouseY )
1763 window->State.Modifiers = 0xffffffff;
1768 case WM_CAPTURECHANGED:
1769 /* User has finished resizing the window, force a redraw */
1771 * if( window->Callbacks.Display )
1773 * fgSetWindow( window );
1774 * window->Callbacks.Display( );
1777 INVOKE_WCB( *window, Display, ( ) );
1779 /*lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ) ; */
1783 * Other messages that I have seen and which are not handled already
1785 case WM_SETTEXT: /* 0x000c */
1786 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1787 /* Pass it on to "DefWindowProc" to set the window text */
1790 case WM_GETTEXT: /* 0x000d */
1791 /* Ideally we would copy the title of the window into "lParam" */
1792 /* strncpy ( (char *)lParam, "Window Title", wParam );
1793 lRet = ( wParam > 12 ) ? 12 : wParam; */
1794 /* the number of characters copied */
1795 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1798 case WM_GETTEXTLENGTH: /* 0x000e */
1799 /* Ideally we would get the length of the title of the window */
1801 /* the number of characters in "Window Title\0" (see above) */
1804 case WM_ERASEBKGND: /* 0x0014 */
1805 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1808 case WM_SYNCPAINT: /* 0x0088 */
1809 /* Another window has moved, need to update this one */
1810 window->State.Redisplay = TRUE;
1811 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1812 /* Help screen says this message must be passed to "DefWindowProc" */
1815 case WM_NCPAINT: /* 0x0085 */
1816 /* Need to update the border of this window */
1817 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1818 /* Pass it on to "DefWindowProc" to repaint a standard border */
1823 * Handle unhandled messages
1825 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1833 /*** END OF FILE ***/