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 * Handle a window configuration change. When no reshape
69 * callback is hooked, the viewport size is updated to
70 * match the new window size.
72 static void fghReshapeWindowByHandle ( SFG_WindowHandleType handle,
73 int width, int height )
75 SFG_Window *current_window = fgStructure.Window;
77 SFG_Window* window = fgWindowByHandle( handle );
78 freeglut_return_if_fail( window != NULL );
81 #if TARGET_HOST_UNIX_X11
83 XResizeWindow( fgDisplay.Display, window->Window.Handle,
85 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
87 #elif TARGET_HOST_WIN32
93 * For windowed mode, get the current position of the
94 * window and resize taking the size of the frame
95 * decorations into account.
98 GetWindowRect( window->Window.Handle, &rect );
99 rect.right = rect.left + width;
100 rect.bottom = rect.top + height;
102 if ( window->Parent == NULL )
104 if ( ! window->IsMenu && !window->State.IsGameMode )
106 rect.right += GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
107 rect.bottom += GetSystemMetrics( SM_CYSIZEFRAME ) * 2 +
108 GetSystemMetrics( SM_CYCAPTION );
113 GetWindowRect( window->Parent->Window.Handle, &rect );
114 AdjustWindowRect ( &rect, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS |
115 WS_CLIPCHILDREN, FALSE );
119 * SWP_NOACTIVATE Do not activate the window
120 * SWP_NOOWNERZORDER Do not change position in z-order
121 * SWP_NOSENDCHANGING Supress WM_WINDOWPOSCHANGING message
122 * SWP_NOZORDER Retains the current Z order (ignore 2nd param)
125 SetWindowPos( window->Window.Handle,
129 rect.right - rect.left,
130 rect.bottom - rect.top,
131 SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING |
137 * XXX Should update {window->State.OldWidth, window->State.OldHeight}
138 * XXX to keep in lockstep with UNIX_X11 code.
140 if( FETCH_WCB( *window, Reshape ) )
141 INVOKE_WCB( *window, Reshape, ( width, height ) );
144 fgSetWindow( window );
145 glViewport( 0, 0, width, height );
151 * Force a window redraw. In Windows at least this is only a partial
152 * solution: if the window is increasing in size in either dimension,
153 * the already-drawn part does not get drawn again and things look funny.
154 * But without this we get this bad behaviour whenever we resize the
157 window->State.Redisplay = GL_TRUE;
160 fgSetWindow( current_window );
164 * Calls a window's redraw method. This is used when
165 * a redraw is forced by the incoming window messages.
167 static void fghRedrawWindowByHandle ( SFG_WindowHandleType handle )
169 SFG_Window* window = fgWindowByHandle( handle );
170 freeglut_return_if_fail( window );
171 freeglut_return_if_fail( FETCH_WCB ( *window, Display ) );
173 window->State.Redisplay = GL_FALSE;
175 freeglut_return_if_fail( window->State.Visible );
177 if( window->State.NeedToResize )
179 SFG_Window *current_window = fgStructure.Window;
181 fgSetWindow( window );
183 fghReshapeWindowByHandle(
184 window->Window.Handle,
189 window->State.NeedToResize = GL_FALSE;
190 fgSetWindow ( current_window );
193 INVOKE_WCB( *window, Display, ( ) );
197 * A static helper function to execute display callback for a window
199 static void fghcbDisplayWindow( SFG_Window *window,
200 SFG_Enumerator *enumerator )
202 if( window->State.Redisplay &&
203 window->State.Visible )
206 * XXX Resizing should *not* depend upon whether there
207 * XXX is a pending redisplay flag, as far as I can tell.
209 * XXX Note, too, that the {NeedToResize} flag is a little
210 * XXX fuzzy in its meaning, since for WIN32, this also
211 * XXX means "we need to tell the application that the window has
212 * XXX changed size", while in X11, it only means "we need
213 * XXX to ask the window system to resize the window.
214 * XXX Splitting the flag's meaning might be desirable, but
215 * XXX that could complicate the code more. (On X11, the
216 * XXX user callback is called as soon as the event is
217 * XXX discovered, but resizing the window is postponed
218 * XXX until after other events.)
220 if( window->State.NeedToResize )
222 SFG_Window *current_window = fgStructure.Window;
224 fgSetWindow( window );
226 fghReshapeWindowByHandle(
227 window->Window.Handle,
232 window->State.NeedToResize = GL_FALSE;
233 fgSetWindow ( current_window );
236 window->State.Redisplay = GL_FALSE;
238 #if TARGET_HOST_UNIX_X11
240 SFG_Window *current_window = fgStructure.Window;
242 INVOKE_WCB( *window, Display, ( ) );
243 fgSetWindow( current_window );
245 #elif TARGET_HOST_WIN32
247 window->Window.Handle, NULL, NULL,
248 RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE | RDW_UPDATENOW
253 fgEnumSubWindows( window, fghcbDisplayWindow, enumerator );
257 * Make all windows perform a display call
259 static void fghDisplayAll( void )
261 SFG_Enumerator enumerator;
263 enumerator.found = GL_FALSE;
264 enumerator.data = NULL;
266 fgEnumWindows( fghcbDisplayWindow, &enumerator );
270 * Window enumerator callback to check for the joystick polling code
272 static void fghcbCheckJoystickPolls( SFG_Window *window,
273 SFG_Enumerator *enumerator )
275 long int checkTime = fgElapsedTime( );
277 if( window->State.JoystickLastPoll + window->State.JoystickPollRate <=
280 fgJoystickPollWindow( window );
281 window->State.JoystickLastPoll = checkTime;
284 fgEnumSubWindows( window, fghcbCheckJoystickPolls, enumerator );
288 * Check all windows for joystick polling
290 static void fghCheckJoystickPolls( void )
292 SFG_Enumerator enumerator;
294 enumerator.found = GL_FALSE;
295 enumerator.data = NULL;
297 fgEnumWindows( fghcbCheckJoystickPolls, &enumerator );
301 * Check the global timers
303 static void fghCheckTimers( void )
305 long checkTime = fgElapsedTime( );
308 while( timer = fgState.Timers.First )
310 if( timer->TriggerTime > checkTime )
313 fgListRemove( &fgState.Timers, &timer->Node );
314 fgListAppend( &fgState.FreeTimers, &timer->Node );
316 timer->Callback( timer->ID );
323 long fgElapsedTime( void )
325 if ( fgState.Time.Set )
327 #if TARGET_HOST_UNIX_X11
331 gettimeofday( &now, NULL );
333 elapsed = (now.tv_usec - fgState.Time.Value.tv_usec) / 1000;
334 elapsed += (now.tv_sec - fgState.Time.Value.tv_sec) * 1000;
337 #elif TARGET_HOST_WIN32
338 return timeGetTime() - fgState.Time.Value;
343 #if TARGET_HOST_UNIX_X11
344 gettimeofday( &fgState.Time.Value, NULL );
345 #elif TARGET_HOST_WIN32
346 fgState.Time.Value = timeGetTime ();
348 fgState.Time.Set = GL_TRUE ;
357 void fgError( const char *fmt, ... )
363 fprintf( stderr, "freeglut ");
364 if( fgState.ProgramName )
365 fprintf (stderr, "(%s): ", fgState.ProgramName);
366 vfprintf( stderr, fmt, ap );
367 fprintf( stderr, "\n" );
371 if ( fgState.Initialised )
377 void fgWarning( const char *fmt, ... )
383 fprintf( stderr, "freeglut ");
384 if( fgState.ProgramName )
385 fprintf( stderr, "(%s): ", fgState.ProgramName );
386 vfprintf( stderr, fmt, ap );
387 fprintf( stderr, "\n" );
393 * Indicates whether Joystick events are being used by ANY window.
395 * The current mechanism is to walk all of the windows and ask if
396 * there is a joystick callback. Certainly in some cases, maybe
397 * in all cases, the joystick is attached to the system and accessed
398 * from ONE point by GLUT/freeglut, so this is not the right way,
399 * in general, to do this. However, the Joystick code is segregated
400 * in its own little world, so we can't access the information that
401 * we need in order to do that nicely.
404 * * Store Joystick data into freeglut global state.
405 * * Provide NON-static functions or data from Joystick *.c file.
407 * Basically, the RIGHT way to do this requires knowing something
408 * about the Joystick. Right now, the Joystick code is behind
412 static void fgCheckJoystickCallback( SFG_Window* w, SFG_Enumerator* e)
414 if( FETCH_WCB( *w, Joystick ) )
419 fgEnumSubWindows( w, fgCheckJoystickCallback, e );
421 static int fgHaveJoystick( void )
423 SFG_Enumerator enumerator;
424 enumerator.found = GL_FALSE;
425 enumerator.data = NULL;
426 fgEnumWindows( fgCheckJoystickCallback, &enumerator );
427 return !!enumerator.data;
429 static void fgHavePendingRedisplaysCallback( SFG_Window* w, SFG_Enumerator* e)
431 if( w->State.Redisplay )
436 fgEnumSubWindows( w, fgHavePendingRedisplaysCallback, e );
438 static int fgHavePendingRedisplays (void)
440 SFG_Enumerator enumerator;
441 enumerator.found = GL_FALSE;
442 enumerator.data = NULL;
443 fgEnumWindows( fgHavePendingRedisplaysCallback, &enumerator );
444 return !!enumerator.data;
447 * Returns the number of GLUT ticks (milliseconds) till the next timer event.
449 static long fgNextTimer( void )
452 SFG_Timer *timer = fgState.Timers.First;
455 ret = timer->TriggerTime - fgElapsedTime();
462 * Does the magic required to relinquish the CPU until something interesting
465 static void fgSleepForEvents( void )
467 #if TARGET_HOST_UNIX_X11
474 if( fgState.IdleCallback || fgHavePendingRedisplays( ) )
476 socket = ConnectionNumber( fgDisplay.Display );
478 FD_SET( socket, &fdset );
480 msec = fgNextTimer( );
481 if( fgHaveJoystick( ) )
482 msec = MIN( msec, 10 );
484 wait.tv_sec = msec / 1000;
485 wait.tv_usec = (msec % 1000) * 1000;
486 err = select( socket+1, &fdset, NULL, NULL, &wait );
489 fgWarning ( "freeglut select() error: %d\n", errno );
491 #elif TARGET_HOST_WIN32
495 #if TARGET_HOST_UNIX_X11
497 * Returns GLUT modifier mask for an XEvent.
499 int fgGetXModifiers( XEvent *event )
503 if( event->xkey.state & ( ShiftMask | LockMask ) )
504 ret |= GLUT_ACTIVE_SHIFT;
505 if( event->xkey.state & ControlMask )
506 ret |= GLUT_ACTIVE_CTRL;
507 if( event->xkey.state & Mod1Mask )
508 ret |= GLUT_ACTIVE_ALT;
515 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
518 * Executes a single iteration in the freeglut processing loop.
520 void FGAPIENTRY glutMainLoopEvent( void )
522 #if TARGET_HOST_UNIX_X11
527 * This code was repeated constantly, so here it goes into a definition:
529 #define GETWINDOW(a) \
530 window = fgWindowByHandle( event.a.window ); \
531 if( window == NULL ) \
534 #define GETMOUSE(a) \
535 window->State.MouseX = event.a.x; \
536 window->State.MouseY = event.a.y;
538 freeglut_assert_ready;
540 while( XPending( fgDisplay.Display ) )
542 XNextEvent( fgDisplay.Display, &event );
548 * Destroy the window when the WM_DELETE_WINDOW message arrives
550 if( (Atom) event.xclient.data.l[ 0 ] == fgDisplay.DeleteWindow )
552 GETWINDOW( xclient );
554 fgDestroyWindow ( window );
556 if( fgState.ActionOnWindowClose == GLUT_ACTION_EXIT )
562 fgState.ExecState = GLUT_EXEC_STATE_STOP;
568 * CreateNotify causes a configure-event so that sub-windows are
569 * handled compatibly with GLUT. Otherwise, your sub-windows
570 * (in freeglut only) will not get an initial reshape event,
571 * which can break things.
573 * GLUT presumably does this because it generally tries to treat
574 * sub-windows the same as windows.
576 * XXX Technically, GETWINDOW( xconfigure ) and
577 * XXX {event.xconfigure} may not be legit ways to get at
578 * XXX data for CreateNotify events. In practice, the data
579 * XXX is in a union which is laid out much the same either
580 * XXX way. But if you want to split hairs, this isn't legit,
581 * XXX and we should instead duplicate some code.
584 case ConfigureNotify:
585 GETWINDOW( xconfigure );
587 int width = event.xconfigure.width;
588 int height = event.xconfigure.height;
590 if( ( width != window->State.OldWidth ) ||
591 ( height != window->State.OldHeight ) )
593 window->State.OldWidth = width;
594 window->State.OldHeight = height;
595 if( FETCH_WCB( *window, Reshape ) )
596 INVOKE_WCB( *window, Reshape, ( width, height ) );
599 fgSetWindow( window );
600 glViewport( 0, 0, width, height );
602 glutPostRedisplay( );
609 * This is sent to confirm the XDestroyWindow call.
610 * XXX WHY is this commented out? Should we re-enable it?
612 /* fgAddToWindowDestroyList ( window ); */
617 * We are too dumb to process partial exposes...
619 * XXX Well, we could do it. However, it seems to only
620 * XXX be potentially useful for single-buffered (since
621 * XXX double-buffered does not respect viewport when we
622 * XXX do a buffer-swap).
624 * XXX GETWINDOW( xexpose );
625 * XXX fgSetWindow( window );
626 * XXX glutPostRedisplay( );
628 if( event.xexpose.count == 0 )
629 fghRedrawWindowByHandle( event.xexpose.window );
635 * If we never do anything with this, can we just not ask to
636 * get these messages?
642 * Have the client's keyboard knowledge updated (xlib.ps,
643 * page 206, says that's a good thing to do)
645 XRefreshKeyboardMapping( (XMappingEvent *) &event );
648 case VisibilityNotify:
650 GETWINDOW( xvisibility );
652 * XXX INVOKE_WCB() does this check for us.
654 if( ! FETCH_WCB( *window, WindowStatus ) )
656 fgSetWindow( window );
659 * Sending this event, the X server can notify us that the window
660 * has just acquired one of the three possible visibility states:
661 * VisibilityUnobscured, VisibilityPartiallyObscured or
662 * VisibilityFullyObscured
664 switch( event.xvisibility.state )
666 case VisibilityUnobscured:
667 INVOKE_WCB( *window, WindowStatus, ( GLUT_FULLY_RETAINED ) );
668 window->State.Visible = GL_TRUE;
671 case VisibilityPartiallyObscured:
672 INVOKE_WCB( *window, WindowStatus,
673 ( GLUT_PARTIALLY_RETAINED ) );
674 window->State.Visible = GL_TRUE;
677 case VisibilityFullyObscured:
678 INVOKE_WCB( *window, WindowStatus, ( GLUT_FULLY_COVERED ) );
679 window->State.Visible = GL_FALSE;
683 fgWarning( "Uknown X visibility state: %d",
684 event.xvisibility.state );
692 GETWINDOW( xcrossing );
693 GETMOUSE( xcrossing );
694 INVOKE_WCB( *window, Entry, ( ( EnterNotify == event.type ) ?
701 GETWINDOW( xmotion );
704 if( window->ActiveMenu )
706 if( window == window->ActiveMenu->ParentWindow )
708 window->ActiveMenu->Window->State.MouseX =
709 event.xmotion.x_root - window->ActiveMenu->X;
710 window->ActiveMenu->Window->State.MouseY =
711 event.xmotion.y_root - window->ActiveMenu->Y;
713 window->ActiveMenu->Window->State.Redisplay = GL_TRUE ;
714 fgSetWindow( window->ActiveMenu->ParentWindow );
720 * XXX For more than 5 buttons, just check {event.xmotion.state},
721 * XXX rather than a host of bit-masks? Or maybe we need to
722 * XXX track ButtonPress/ButtonRelease events in our own
725 #define BUTTON_MASK \
726 ( Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask )
727 if ( event.xmotion.state & BUTTON_MASK )
728 INVOKE_WCB( *window, Motion, ( event.xmotion.x,
731 INVOKE_WCB( *window, Passive, ( event.xmotion.x,
739 GLboolean pressed = GL_TRUE;
742 if( event.type == ButtonRelease )
746 * A mouse button has been pressed or released. Traditionally,
747 * break if the window was found within the freeglut structures.
749 GETWINDOW( xbutton );
753 * An X button (at least in XFree86) is numbered from 1.
754 * A GLUT button is numbered from 0.
755 * Old GLUT passed through buttons other than just the first
756 * three, though it only gave symbolic names and official
757 * support to the first three.
759 button = event.xbutton.button - 1;
762 * XXX This comment is replicated in the WIN32 section and
763 * XXX maybe also in the menu code. Can we move the info
764 * XXX to one central place and *reference* it from here?
766 * Do not execute the application's mouse callback if a menu
767 * is hooked to this button. In that case an appropriate
768 * private call should be generated.
769 * Near as I can tell, this is the menu behaviour:
770 * - Down-click the menu button, menu not active: activate
771 * the menu with its upper left-hand corner at the mouse
773 * - Down-click any button outside the menu, menu active:
774 * deactivate the menu
775 * - Down-click any button inside the menu, menu active:
776 * select the menu entry and deactivate the menu
777 * - Up-click the menu button, menu not active: nothing happens
778 * - Up-click the menu button outside the menu, menu active:
780 * - Up-click the menu button inside the menu, menu active:
781 * select the menu entry and deactivate the menu
783 /* Window has an active menu, it absorbs any mouse click */
784 if( window->ActiveMenu )
786 if( window == window->ActiveMenu->ParentWindow )
788 window->ActiveMenu->Window->State.MouseX =
789 event.xbutton.x_root - window->ActiveMenu->X;
790 window->ActiveMenu->Window->State.MouseY =
791 event.xbutton.y_root - window->ActiveMenu->Y;
794 /* In the menu, invoke the callback and deactivate the menu*/
795 if( fgCheckActiveMenu( window->ActiveMenu->Window,
796 window->ActiveMenu ) )
799 * Save the current window and menu and set the current
800 * window to the window whose menu this is
802 SFG_Window *save_window = fgStructure.Window;
803 SFG_Menu *save_menu = fgStructure.Menu;
804 SFG_Window *parent_window =
805 window->ActiveMenu->ParentWindow;
806 fgSetWindow( parent_window );
807 fgStructure.Menu = window->ActiveMenu;
809 /* Execute the menu callback */
810 fgExecuteMenuCallback( window->ActiveMenu );
811 fgDeactivateMenu( parent_window );
813 /* Restore the current window and menu */
814 fgSetWindow( save_window );
815 fgStructure.Menu = save_menu;
819 * Outside the menu, deactivate if it's a downclick
821 * XXX This isn't enough. A downclick outside of
822 * XXX the interior of our freeglut windows should also
823 * XXX deactivate the menu. This is more complicated.
825 fgDeactivateMenu( window->ActiveMenu->ParentWindow );
828 * XXX Why does an active menu require a redisplay at
829 * XXX this point? If this can come out cleanly, then
830 * XXX it probably should do so; if not, a comment should
833 window->State.Redisplay = GL_TRUE;
838 * No active menu, let's check whether we need to activate one.
840 if( ( 0 <= button ) &&
841 ( FREEGLUT_MAX_MENUS > button ) &&
842 ( window->Menu[ button ] ) &&
846 * XXX Posting a requisite Redisplay seems bogus.
848 window->State.Redisplay = GL_TRUE;
849 fgSetWindow( window );
850 fgActivateMenu( window, button );
855 * Check if there is a mouse or mouse wheel callback hooked to the
858 if( ! FETCH_WCB( *window, Mouse ) &&
859 ! FETCH_WCB( *window, MouseWheel ) )
862 fgState.Modifiers = fgGetXModifiers( &event );
865 * Finally execute the mouse or mouse wheel callback
867 * XXX Use a symbolic constant, *not* "4"! ("3, sire!")
869 if( ( button < 3 ) || ( ! FETCH_WCB( *window, MouseWheel ) ) )
870 INVOKE_WCB( *window, Mouse, ( button,
871 pressed ? GLUT_DOWN : GLUT_UP,
878 * Map 4 and 5 to wheel zero; EVEN to +1, ODD to -1
879 * " 6 and 7 " " one; ...
881 * XXX This *should* be behind some variables/macros,
882 * XXX since the order and numbering isn't certain
883 * XXX See XFree86 configuration docs (even back in the
884 * XXX 3.x days, and especially with 4.x).
886 * XXX Note that {button} has already been decremeted
887 * XXX in mapping from X button numbering to GLUT.
889 int wheel_number = (button - 3) / 2;
895 INVOKE_WCB( *window, MouseWheel, ( wheel_number,
903 * Trash the modifiers state
905 fgState.Modifiers = 0xffffffff;
912 FGCBKeyboard keyboard_cb;
913 FGCBSpecial special_cb;
918 if( event.type == KeyPress )
920 keyboard_cb = FETCH_WCB( *window, Keyboard );
921 special_cb = FETCH_WCB( *window, Special );
925 keyboard_cb = FETCH_WCB( *window, KeyboardUp );
926 special_cb = FETCH_WCB( *window, SpecialUp );
930 * Is there a keyboard/special callback hooked for this window?
932 if( keyboard_cb || special_cb )
934 XComposeStatus composeStatus;
935 char asciiCode[ 32 ];
940 * Check for the ASCII/KeySym codes associated with the event:
942 len = XLookupString( &event.xkey, asciiCode, sizeof(asciiCode),
943 &keySym, &composeStatus
947 * GLUT API tells us to have two separate callbacks...
952 * ...one for the ASCII translateable keypresses...
956 fgSetWindow( window );
957 fgState.Modifiers = fgGetXModifiers( &event );
958 keyboard_cb( asciiCode[ 0 ],
959 event.xkey.x, event.xkey.y
961 fgState.Modifiers = 0xffffffff;
969 * ...and one for all the others, which need to be
970 * translated to GLUT_KEY_Xs...
974 case XK_F1: special = GLUT_KEY_F1; break;
975 case XK_F2: special = GLUT_KEY_F2; break;
976 case XK_F3: special = GLUT_KEY_F3; break;
977 case XK_F4: special = GLUT_KEY_F4; break;
978 case XK_F5: special = GLUT_KEY_F5; break;
979 case XK_F6: special = GLUT_KEY_F6; break;
980 case XK_F7: special = GLUT_KEY_F7; break;
981 case XK_F8: special = GLUT_KEY_F8; break;
982 case XK_F9: special = GLUT_KEY_F9; break;
983 case XK_F10: special = GLUT_KEY_F10; break;
984 case XK_F11: special = GLUT_KEY_F11; break;
985 case XK_F12: special = GLUT_KEY_F12; break;
987 case XK_Left: special = GLUT_KEY_LEFT; break;
988 case XK_Right: special = GLUT_KEY_RIGHT; break;
989 case XK_Up: special = GLUT_KEY_UP; break;
990 case XK_Down: special = GLUT_KEY_DOWN; break;
993 case XK_Prior: special = GLUT_KEY_PAGE_UP; break;
995 case XK_Next: special = GLUT_KEY_PAGE_DOWN; break;
997 case XK_Home: special = GLUT_KEY_HOME; break;
999 case XK_End: special = GLUT_KEY_END; break;
1001 case XK_Insert: special = GLUT_KEY_INSERT; break;
1005 * Execute the callback (if one has been specified),
1006 * given that the special code seems to be valid...
1008 if( special_cb && (special != -1) )
1010 fgSetWindow( window );
1011 fgState.Modifiers = fgGetXModifiers( &event );
1012 special_cb( special, event.xkey.x, event.xkey.y );
1013 fgState.Modifiers = 0xffffffff;
1020 case ReparentNotify:
1021 break; /* XXX Should disable this event */
1024 fgWarning ("Unknown X event type: %d", event.type);
1029 #elif TARGET_HOST_WIN32
1033 while( PeekMessage( &stMsg, NULL, 0, 0, PM_NOREMOVE ) )
1035 if( GetMessage( &stMsg, NULL, 0, 0 ) == 0 )
1037 if( fgState.ActionOnWindowClose == GLUT_ACTION_EXIT )
1042 fgState.ExecState = GLUT_EXEC_STATE_STOP;
1046 TranslateMessage( &stMsg );
1047 DispatchMessage( &stMsg );
1051 if( fgState.Timers.First )
1053 fghCheckJoystickPolls( );
1060 * Enters the freeglut processing loop.
1061 * Stays until the "ExecState" changes to "GLUT_EXEC_STATE_STOP".
1063 void FGAPIENTRY glutMainLoop( void )
1065 #if TARGET_HOST_WIN32
1066 SFG_Window *window = (SFG_Window *)fgStructure.Windows.First ;
1069 freeglut_assert_ready;
1071 #if TARGET_HOST_WIN32
1073 * Processing before the main loop: If there is a window which is open and
1074 * which has a visibility callback, call it. I know this is an ugly hack,
1075 * but I'm not sure what else to do about it. Ideally we should leave
1076 * something uninitialized in the create window code and initialize it in
1077 * the main loop, and have that initialization create a "WM_ACTIVATE"
1078 * message. Then we would put the visibility callback code in the
1079 * "case WM_ACTIVATE" block below. - John Fay -- 10/24/02
1083 if ( FETCH_WCB( *window, Visibility ) )
1085 SFG_Window *current_window = fgStructure.Window ;
1087 INVOKE_WCB( *window, Visibility, ( window->State.Visible ) );
1088 fgSetWindow( current_window );
1091 window = (SFG_Window *)window->Node.Next ;
1095 fgState.ExecState = GLUT_EXEC_STATE_RUNNING ;
1096 while( fgState.ExecState == GLUT_EXEC_STATE_RUNNING )
1100 glutMainLoopEvent( );
1102 * Step through the list of windows, seeing if there are any
1103 * that are not menus
1105 for( window = ( SFG_Window * )fgStructure.Windows.First;
1107 window = ( SFG_Window * )window->Node.Next )
1108 if ( ! ( window->IsMenu ) )
1112 fgState.ExecState = GLUT_EXEC_STATE_STOP;
1115 if( fgState.IdleCallback )
1116 fgState.IdleCallback( );
1118 fgSleepForEvents( );
1123 * When this loop terminates, destroy the display, state and structure
1124 * of a freeglut session, so that another glutInit() call can happen
1127 if( fgState.ActionOnWindowClose == GLUT_ACTION_EXIT )
1132 * Leaves the freeglut processing loop.
1134 void FGAPIENTRY glutLeaveMainLoop( void )
1136 fgState.ExecState = GLUT_EXEC_STATE_STOP ;
1140 #if TARGET_HOST_WIN32
1142 * Determine a GLUT modifer mask based on MS-WINDOWS system info.
1144 int fgGetWin32Modifiers (void)
1147 ( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
1148 ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
1149 ( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
1150 ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
1151 ( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
1152 ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
1156 * The window procedure for handling Win32 events
1158 LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
1161 SFG_Window* window = fgWindowByHandle( hWnd );
1165 if ( ( window == NULL ) && ( uMsg != WM_CREATE ) )
1166 return DefWindowProc( hWnd, uMsg, wParam, lParam );
1168 /* printf ( "Window %3d message <%04x> %12d %12d\n", window?window->ID:0,
1169 uMsg, wParam, lParam ); */
1174 * The window structure is passed as the creation structure paramter...
1176 window = (SFG_Window *) (((LPCREATESTRUCT) lParam)->lpCreateParams);
1177 assert( window != NULL );
1179 window->Window.Handle = hWnd;
1180 window->Window.Device = GetDC( hWnd );
1181 if( window->IsMenu )
1183 unsigned int current_DisplayMode = fgState.DisplayMode;
1184 fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH;
1185 fgSetupPixelFormat( window, GL_FALSE, PFD_MAIN_PLANE );
1186 fgState.DisplayMode = current_DisplayMode;
1188 if( fgStructure.MenuContext )
1189 wglMakeCurrent( window->Window.Device,
1190 fgStructure.MenuContext->Context
1194 fgStructure.MenuContext =
1195 (SFG_MenuContext *)malloc( sizeof(SFG_MenuContext) );
1196 fgStructure.MenuContext->Context =
1197 wglCreateContext( window->Window.Device );
1200 /* window->Window.Context = wglGetCurrentContext (); */
1201 window->Window.Context = wglCreateContext( window->Window.Device );
1205 fgSetupPixelFormat( window, GL_FALSE, PFD_MAIN_PLANE );
1207 if( ! fgState.UseCurrentContext )
1208 window->Window.Context =
1209 wglCreateContext( window->Window.Device );
1212 window->Window.Context = wglGetCurrentContext( );
1213 if( ! window->Window.Context )
1214 window->Window.Context =
1215 wglCreateContext( window->Window.Device );
1219 window->State.NeedToResize = GL_TRUE;
1220 window->State.Width = fgState.Size.X;
1221 window->State.Height = fgState.Size.Y;
1223 ReleaseDC( window->Window.Handle, window->Window.Device );
1228 * We got resized... But check if the window has been already added...
1230 window->State.NeedToResize = GL_TRUE;
1231 window->State.Width = LOWORD(lParam);
1232 window->State.Height = HIWORD(lParam);
1236 printf("WM_SETFOCUS: %p\n", window );
1237 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1241 if (LOWORD(wParam) != WA_INACTIVE)
1243 /* glutSetCursor( fgStructure.Window->State.Cursor ); */
1244 printf("WM_ACTIVATE: glutSetCursor( %p, %d)\n", window,
1245 window->State.Cursor );
1246 glutSetCursor( window->State.Cursor );
1249 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1254 * XXX Why not re-use some common code with the glutSetCursor()
1255 * XXX function (or perhaps invoke glutSetCursor())?
1256 * XXX That is, why are we duplicating code, here, from
1257 * XXX glutSetCursor()? The WIN32 code should be able to just
1258 * XXX call glutSetCurdsor() instead of defining two macros
1259 * XXX and implementing a nested case in-line.
1262 /* Set the cursor AND change it for this window class. */
1263 #define MAP_CURSOR(a,b) \
1265 SetCursor( LoadCursor( NULL, b ) ); \
1268 /* Nuke the cursor AND change it for this window class. */
1269 #define ZAP_CURSOR(a,b) \
1271 SetCursor( NULL ); \
1274 if( LOWORD( lParam ) == HTCLIENT )
1275 switch( window->State.Cursor )
1277 MAP_CURSOR( GLUT_CURSOR_RIGHT_ARROW, IDC_ARROW );
1278 MAP_CURSOR( GLUT_CURSOR_LEFT_ARROW, IDC_ARROW );
1279 MAP_CURSOR( GLUT_CURSOR_INFO, IDC_HELP );
1280 MAP_CURSOR( GLUT_CURSOR_DESTROY, IDC_CROSS );
1281 MAP_CURSOR( GLUT_CURSOR_HELP, IDC_HELP );
1282 MAP_CURSOR( GLUT_CURSOR_CYCLE, IDC_SIZEALL );
1283 MAP_CURSOR( GLUT_CURSOR_SPRAY, IDC_CROSS );
1284 MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT );
1285 MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_UPARROW );
1286 MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS );
1287 /* MAP_CURSOR( GLUT_CURSOR_NONE, IDC_NO ); */
1288 ZAP_CURSOR( GLUT_CURSOR_NONE, NULL );
1291 MAP_CURSOR( GLUT_CURSOR_UP_DOWN, IDC_ARROW );
1294 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1298 window->State.Visible = GL_TRUE;
1299 window->State.Redisplay = GL_TRUE;
1303 /* Turn on the visibility in case it was turned off somehow */
1304 window->State.Visible = GL_TRUE;
1305 BeginPaint( hWnd, &ps );
1306 fghRedrawWindowByHandle( hWnd );
1307 EndPaint( hWnd, &ps );
1311 fgDestroyWindow ( window );
1312 if ( fgState.ActionOnWindowClose != GLUT_ACTION_CONTINUE_EXECUTION )
1318 * The window already got destroyed, so don't bother with it.
1324 window->State.MouseX = LOWORD( lParam );
1325 window->State.MouseY = HIWORD( lParam );
1327 if ( window->ActiveMenu )
1329 window->State.Redisplay = GL_TRUE;
1330 fgSetWindow ( window->ActiveMenu->ParentWindow );
1334 fgState.Modifiers = fgGetWin32Modifiers( );
1336 if( ( wParam & MK_LBUTTON ) ||
1337 ( wParam & MK_MBUTTON ) ||
1338 ( wParam & MK_RBUTTON ) )
1339 INVOKE_WCB( *window, Motion, ( window->State.MouseX,
1340 window->State.MouseY ) );
1342 INVOKE_WCB( *window, Passive, ( window->State.MouseX,
1343 window->State.MouseY ) );
1345 fgState.Modifiers = 0xffffffff;
1349 case WM_LBUTTONDOWN:
1350 case WM_MBUTTONDOWN:
1351 case WM_RBUTTONDOWN:
1356 GLboolean pressed = GL_TRUE;
1359 window->State.MouseX = LOWORD( lParam );
1360 window->State.MouseY = HIWORD( lParam );
1364 case WM_LBUTTONDOWN:
1366 button = GLUT_LEFT_BUTTON;
1368 case WM_MBUTTONDOWN:
1370 button = GLUT_MIDDLE_BUTTON;
1372 case WM_RBUTTONDOWN:
1374 button = GLUT_RIGHT_BUTTON;
1378 button = GLUT_LEFT_BUTTON;
1382 button = GLUT_MIDDLE_BUTTON;
1386 button = GLUT_RIGHT_BUTTON;
1394 if( GetSystemMetrics( SM_SWAPBUTTON ) )
1395 if( button == GLUT_LEFT_BUTTON )
1396 button = GLUT_RIGHT_BUTTON;
1397 else if( button == GLUT_RIGHT_BUTTON )
1398 button = GLUT_LEFT_BUTTON;
1401 return DefWindowProc( hWnd, uMsg, lParam, wParam );
1404 * XXX This comment is duplicated in two other spots.
1405 * XXX Can we centralize it?
1407 * Do not execute the application's mouse callback if a
1408 * menu is hooked to this button.
1409 * In that case an appropriate private call should be generated.
1410 * Near as I can tell, this is the menu behaviour:
1411 * - Down-click the menu button, menu not active: activate
1412 * the menu with its upper left-hand corner at the mouse location.
1413 * - Down-click any button outside the menu, menu active:
1414 * deactivate the menu
1415 * - Down-click any button inside the menu, menu active:
1416 * select the menu entry and deactivate the menu
1417 * - Up-click the menu button, menu not active: nothing happens
1418 * - Up-click the menu button outside the menu, menu active:
1420 * - Up-click the menu button inside the menu, menu active:
1421 * select the menu entry and deactivate the menu
1423 /* Window has an active menu, it absorbs any mouse click */
1424 if( window->ActiveMenu )
1426 /* Outside the menu, deactivate the menu if it's a downclick */
1427 if( ! fgCheckActiveMenu( window, window->ActiveMenu ) )
1430 fgDeactivateMenu( window->ActiveMenu->ParentWindow );
1432 else /* In menu, invoke the callback and deactivate the menu*/
1435 * Save the current window and menu and set the current
1436 * window to the window whose menu this is
1438 SFG_Window *save_window = fgStructure.Window;
1439 SFG_Menu *save_menu = fgStructure.Menu;
1440 SFG_Window *parent_window = window->ActiveMenu->ParentWindow;
1441 fgSetWindow( parent_window );
1442 fgStructure.Menu = window->ActiveMenu;
1444 /* Execute the menu callback */
1445 fgExecuteMenuCallback( window->ActiveMenu );
1446 fgDeactivateMenu( parent_window );
1448 /* Restore the current window and menu */
1449 fgSetWindow( save_window );
1450 fgStructure.Menu = save_menu;
1454 * Let's make the window redraw as a result of the mouse
1455 * click and menu activity.
1457 if( ! window->IsMenu )
1458 window->State.Redisplay = GL_TRUE;
1463 if( window->Menu[ button ] && pressed )
1465 window->State.Redisplay = GL_TRUE;
1466 fgSetWindow( window );
1467 fgActivateMenu( window, button );
1472 if( ! FETCH_WCB( *window, Mouse ) )
1475 fgSetWindow( window );
1476 fgState.Modifiers = fgGetWin32Modifiers( );
1481 pressed ? GLUT_DOWN : GLUT_UP,
1482 window->State.MouseX,
1483 window->State.MouseY
1487 fgState.Modifiers = 0xffffffff;
1492 /* Should be WM_MOUSEWHEEL but my compiler doesn't recognize it */
1495 * XXX THIS IS SPECULATIVE -- John Fay, 10/2/03
1496 * XXX Should use WHEEL_DELTA instead of 120
1498 int wheel_number = LOWORD( wParam );
1499 short ticks = ( short )HIWORD( wParam ) / 120;
1509 * The mouse cursor has moved. Remember the new mouse cursor's position
1511 /* window->State.MouseX = LOWORD( lParam ); */
1512 /* Need to adjust by window position, */
1513 /* window->State.MouseY = HIWORD( lParam ); */
1514 /* change "lParam" to other parameter */
1516 if( ! FETCH_WCB( *window, MouseWheel ) &&
1517 ! FETCH_WCB( *window, Mouse ) )
1520 fgSetWindow( window );
1521 fgState.Modifiers = fgGetWin32Modifiers( );
1524 if( FETCH_WCB( *window, MouseWheel ) )
1525 INVOKE_WCB( *window, MouseWheel,
1528 window->State.MouseX,
1529 window->State.MouseY
1532 else /* No mouse wheel, call the mouse button callback twice */
1535 * XXX The below assumes that you have no more than 3 mouse
1536 * XXX buttons. Sorry.
1538 int button = wheel_number*2 + 4;
1541 INVOKE_WCB( *window, Mouse,
1542 ( button, GLUT_DOWN,
1543 window->State.MouseX, window->State.MouseY )
1545 INVOKE_WCB( *window, Mouse,
1547 window->State.MouseX, window->State.MouseX )
1551 fgState.Modifiers = 0xffffffff;
1561 if( fgState.IgnoreKeyRepeat && (lParam & KF_REPEAT) )
1565 * Remember the current modifiers state. This is done here in order
1566 * to make sure the VK_DELETE keyboard callback is executed properly.
1568 fgState.Modifiers = fgGetWin32Modifiers( );
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
1579 # define KEY(a,b) case a: keypress = b; break;
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 INVOKE_WCB( *window, Keyboard,
1610 ( 127, window->State.MouseX, window->State.MouseY )
1614 if( keypress != -1 )
1615 INVOKE_WCB( *window, Special,
1617 window->State.MouseX, window->State.MouseY )
1620 fgState.Modifiers = 0xffffffff;
1631 * Remember the current modifiers state. This is done here in order
1632 * to make sure the VK_DELETE keyboard callback is executed properly.
1634 fgState.Modifiers = fgGetWin32Modifiers( );
1636 GetCursorPos( &mouse_pos );
1637 ScreenToClient( window->Window.Handle, &mouse_pos );
1639 window->State.MouseX = mouse_pos.x;
1640 window->State.MouseY = mouse_pos.y;
1643 * Convert the Win32 keystroke codes to GLUTtish way.
1644 * "KEY(a,b)" was defined under "WM_KEYDOWN"
1649 KEY( VK_F1, GLUT_KEY_F1 );
1650 KEY( VK_F2, GLUT_KEY_F2 );
1651 KEY( VK_F3, GLUT_KEY_F3 );
1652 KEY( VK_F4, GLUT_KEY_F4 );
1653 KEY( VK_F5, GLUT_KEY_F5 );
1654 KEY( VK_F6, GLUT_KEY_F6 );
1655 KEY( VK_F7, GLUT_KEY_F7 );
1656 KEY( VK_F8, GLUT_KEY_F8 );
1657 KEY( VK_F9, GLUT_KEY_F9 );
1658 KEY( VK_F10, GLUT_KEY_F10 );
1659 KEY( VK_F11, GLUT_KEY_F11 );
1660 KEY( VK_F12, GLUT_KEY_F12 );
1661 KEY( VK_PRIOR, GLUT_KEY_PAGE_UP );
1662 KEY( VK_NEXT, GLUT_KEY_PAGE_DOWN );
1663 KEY( VK_HOME, GLUT_KEY_HOME );
1664 KEY( VK_END, GLUT_KEY_END );
1665 KEY( VK_LEFT, GLUT_KEY_LEFT );
1666 KEY( VK_UP, GLUT_KEY_UP );
1667 KEY( VK_RIGHT, GLUT_KEY_RIGHT );
1668 KEY( VK_DOWN, GLUT_KEY_DOWN );
1669 KEY( VK_INSERT, GLUT_KEY_INSERT );
1673 * The delete key should be treated as an ASCII keypress:
1675 INVOKE_WCB( *window, KeyboardUp,
1676 ( 127, window->State.MouseX, window->State.MouseY )
1685 GetKeyboardState( state );
1687 if( ToAscii( wParam, 0, state, code, 0 ) == 1 )
1690 INVOKE_WCB( *window, KeyboardUp,
1692 window->State.MouseX, window->State.MouseY )
1697 if( keypress != -1 )
1698 INVOKE_WCB( *window, SpecialUp,
1700 window->State.MouseX, window->State.MouseY )
1703 fgState.Modifiers = 0xffffffff;
1710 if( fgState.IgnoreKeyRepeat && (lParam & KF_REPEAT) )
1713 fgState.Modifiers = fgGetWin32Modifiers( );
1714 INVOKE_WCB( *window, Keyboard,
1716 window->State.MouseX, window->State.MouseY )
1718 fgState.Modifiers = 0xffffffff;
1722 case WM_CAPTURECHANGED:
1723 /* User has finished resizing the window, force a redraw */
1724 INVOKE_WCB( *window, Display, ( ) );
1726 /*lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ); */
1730 * Other messages that I have seen and which are not handled already
1732 case WM_SETTEXT: /* 0x000c */
1733 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1734 /* Pass it on to "DefWindowProc" to set the window text */
1737 case WM_GETTEXT: /* 0x000d */
1738 /* Ideally we would copy the title of the window into "lParam" */
1739 /* strncpy ( (char *)lParam, "Window Title", wParam );
1740 lRet = ( wParam > 12 ) ? 12 : wParam; */
1741 /* the number of characters copied */
1742 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1745 case WM_GETTEXTLENGTH: /* 0x000e */
1746 /* Ideally we would get the length of the title of the window */
1748 /* the number of characters in "Window Title\0" (see above) */
1751 case WM_ERASEBKGND: /* 0x0014 */
1752 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1755 case WM_SYNCPAINT: /* 0x0088 */
1756 /* Another window has moved, need to update this one */
1757 window->State.Redisplay = GL_TRUE;
1758 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1759 /* Help screen says this message must be passed to "DefWindowProc" */
1762 case WM_NCPAINT: /* 0x0085 */
1763 /* Need to update the border of this window */
1764 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1765 /* Pass it on to "DefWindowProc" to repaint a standard border */
1768 case WM_SYSCOMMAND : /* 0x0112 */
1771 * We have received a system command message. Try to act on it.
1772 * The commands are passed in through the "lParam" parameter:
1773 * Clicking on a corner to resize the window gives a "F004" message
1774 * but this is not defined in my header file.
1785 /* User has clicked on the "-" to minimize the window */
1786 /* Turn off the visibility */
1787 window->State.Visible = GL_FALSE ;
1794 case SC_NEXTWINDOW :
1797 case SC_PREVWINDOW :
1801 /* Followed very closely by a WM_CLOSE message */
1825 case SC_SCREENSAVE :
1833 /* We need to pass the message on to the operating system as well */
1834 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1839 * Handle unhandled messages
1841 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1849 /*** END OF FILE ***/