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( );
307 while( fgState.Timers.First )
309 SFG_Timer *timer = fgState.Timers.First;
311 if( timer->TriggerTime > checkTime )
314 fgListRemove( &fgState.Timers, &timer->Node );
315 fgListAppend( &fgState.FreeTimers, &timer->Node );
317 timer->Callback( timer->ID );
324 long fgElapsedTime( void )
326 if ( fgState.Time.Set )
328 #if TARGET_HOST_UNIX_X11
332 gettimeofday( &now, NULL );
334 elapsed = (now.tv_usec - fgState.Time.Value.tv_usec) / 1000;
335 elapsed += (now.tv_sec - fgState.Time.Value.tv_sec) * 1000;
338 #elif TARGET_HOST_WIN32
339 return timeGetTime() - fgState.Time.Value;
344 #if TARGET_HOST_UNIX_X11
345 gettimeofday( &fgState.Time.Value, NULL );
346 #elif TARGET_HOST_WIN32
347 fgState.Time.Value = timeGetTime ();
349 fgState.Time.Set = GL_TRUE ;
358 void fgError( const char *fmt, ... )
364 fprintf( stderr, "freeglut ");
365 if( fgState.ProgramName )
366 fprintf (stderr, "(%s): ", fgState.ProgramName);
367 vfprintf( stderr, fmt, ap );
368 fprintf( stderr, "\n" );
372 if ( fgState.Initialised )
378 void fgWarning( const char *fmt, ... )
384 fprintf( stderr, "freeglut ");
385 if( fgState.ProgramName )
386 fprintf( stderr, "(%s): ", fgState.ProgramName );
387 vfprintf( stderr, fmt, ap );
388 fprintf( stderr, "\n" );
394 * Indicates whether Joystick events are being used by ANY window.
396 * The current mechanism is to walk all of the windows and ask if
397 * there is a joystick callback. Certainly in some cases, maybe
398 * in all cases, the joystick is attached to the system and accessed
399 * from ONE point by GLUT/freeglut, so this is not the right way,
400 * in general, to do this. However, the Joystick code is segregated
401 * in its own little world, so we can't access the information that
402 * we need in order to do that nicely.
405 * * Store Joystick data into freeglut global state.
406 * * Provide NON-static functions or data from Joystick *.c file.
408 * Basically, the RIGHT way to do this requires knowing something
409 * about the Joystick. Right now, the Joystick code is behind
413 static void fgCheckJoystickCallback( SFG_Window* w, SFG_Enumerator* e)
415 if( FETCH_WCB( *w, Joystick ) )
420 fgEnumSubWindows( w, fgCheckJoystickCallback, e );
422 static int fgHaveJoystick( void )
424 SFG_Enumerator enumerator;
425 enumerator.found = GL_FALSE;
426 enumerator.data = NULL;
427 fgEnumWindows( fgCheckJoystickCallback, &enumerator );
428 return !!enumerator.data;
430 static void fgHavePendingRedisplaysCallback( SFG_Window* w, SFG_Enumerator* e)
432 if( w->State.Redisplay )
437 fgEnumSubWindows( w, fgHavePendingRedisplaysCallback, e );
439 static int fgHavePendingRedisplays (void)
441 SFG_Enumerator enumerator;
442 enumerator.found = GL_FALSE;
443 enumerator.data = NULL;
444 fgEnumWindows( fgHavePendingRedisplaysCallback, &enumerator );
445 return !!enumerator.data;
448 * Returns the number of GLUT ticks (milliseconds) till the next timer event.
450 static long fgNextTimer( void )
453 SFG_Timer *timer = fgState.Timers.First;
456 ret = timer->TriggerTime - fgElapsedTime();
463 * Does the magic required to relinquish the CPU until something interesting
466 static void fgSleepForEvents( void )
468 #if TARGET_HOST_UNIX_X11
475 if( fgState.IdleCallback || fgHavePendingRedisplays( ) )
477 socket = ConnectionNumber( fgDisplay.Display );
479 FD_SET( socket, &fdset );
481 msec = fgNextTimer( );
482 if( fgHaveJoystick( ) )
483 msec = MIN( msec, 10 );
485 wait.tv_sec = msec / 1000;
486 wait.tv_usec = (msec % 1000) * 1000;
487 err = select( socket+1, &fdset, NULL, NULL, &wait );
490 fgWarning ( "freeglut select() error: %d\n", errno );
492 #elif TARGET_HOST_WIN32
496 #if TARGET_HOST_UNIX_X11
498 * Returns GLUT modifier mask for an XEvent.
500 int fgGetXModifiers( XEvent *event )
504 if( event->xkey.state & ( ShiftMask | LockMask ) )
505 ret |= GLUT_ACTIVE_SHIFT;
506 if( event->xkey.state & ControlMask )
507 ret |= GLUT_ACTIVE_CTRL;
508 if( event->xkey.state & Mod1Mask )
509 ret |= GLUT_ACTIVE_ALT;
516 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
519 * Executes a single iteration in the freeglut processing loop.
521 void FGAPIENTRY glutMainLoopEvent( void )
523 #if TARGET_HOST_UNIX_X11
528 * This code was repeated constantly, so here it goes into a definition:
530 #define GETWINDOW(a) \
531 window = fgWindowByHandle( event.a.window ); \
532 if( window == NULL ) \
535 #define GETMOUSE(a) \
536 window->State.MouseX = event.a.x; \
537 window->State.MouseY = event.a.y;
539 freeglut_assert_ready;
541 while( XPending( fgDisplay.Display ) )
543 XNextEvent( fgDisplay.Display, &event );
549 * Destroy the window when the WM_DELETE_WINDOW message arrives
551 if( (Atom) event.xclient.data.l[ 0 ] == fgDisplay.DeleteWindow )
553 GETWINDOW( xclient );
555 fgDestroyWindow ( window );
557 if( fgState.ActionOnWindowClose == GLUT_ACTION_EXIT )
563 fgState.ExecState = GLUT_EXEC_STATE_STOP;
569 * CreateNotify causes a configure-event so that sub-windows are
570 * handled compatibly with GLUT. Otherwise, your sub-windows
571 * (in freeglut only) will not get an initial reshape event,
572 * which can break things.
574 * GLUT presumably does this because it generally tries to treat
575 * sub-windows the same as windows.
577 * XXX Technically, GETWINDOW( xconfigure ) and
578 * XXX {event.xconfigure} may not be legit ways to get at
579 * XXX data for CreateNotify events. In practice, the data
580 * XXX is in a union which is laid out much the same either
581 * XXX way. But if you want to split hairs, this isn't legit,
582 * XXX and we should instead duplicate some code.
585 case ConfigureNotify:
586 GETWINDOW( xconfigure );
588 int width = event.xconfigure.width;
589 int height = event.xconfigure.height;
591 if( ( width != window->State.OldWidth ) ||
592 ( height != window->State.OldHeight ) )
594 window->State.OldWidth = width;
595 window->State.OldHeight = height;
596 if( FETCH_WCB( *window, Reshape ) )
597 INVOKE_WCB( *window, Reshape, ( width, height ) );
600 fgSetWindow( window );
601 glViewport( 0, 0, width, height );
603 glutPostRedisplay( );
610 * This is sent to confirm the XDestroyWindow call.
611 * XXX WHY is this commented out? Should we re-enable it?
613 /* fgAddToWindowDestroyList ( window ); */
618 * We are too dumb to process partial exposes...
620 * XXX Well, we could do it. However, it seems to only
621 * XXX be potentially useful for single-buffered (since
622 * XXX double-buffered does not respect viewport when we
623 * XXX do a buffer-swap).
625 * XXX GETWINDOW( xexpose );
626 * XXX fgSetWindow( window );
627 * XXX glutPostRedisplay( );
629 if( event.xexpose.count == 0 )
630 fghRedrawWindowByHandle( event.xexpose.window );
636 * If we never do anything with this, can we just not ask to
637 * get these messages?
643 * Have the client's keyboard knowledge updated (xlib.ps,
644 * page 206, says that's a good thing to do)
646 XRefreshKeyboardMapping( (XMappingEvent *) &event );
649 case VisibilityNotify:
651 GETWINDOW( xvisibility );
653 * XXX INVOKE_WCB() does this check for us.
655 if( ! FETCH_WCB( *window, WindowStatus ) )
657 fgSetWindow( window );
660 * Sending this event, the X server can notify us that the window
661 * has just acquired one of the three possible visibility states:
662 * VisibilityUnobscured, VisibilityPartiallyObscured or
663 * VisibilityFullyObscured
665 switch( event.xvisibility.state )
667 case VisibilityUnobscured:
668 INVOKE_WCB( *window, WindowStatus, ( GLUT_FULLY_RETAINED ) );
669 window->State.Visible = GL_TRUE;
672 case VisibilityPartiallyObscured:
673 INVOKE_WCB( *window, WindowStatus,
674 ( GLUT_PARTIALLY_RETAINED ) );
675 window->State.Visible = GL_TRUE;
678 case VisibilityFullyObscured:
679 INVOKE_WCB( *window, WindowStatus, ( GLUT_FULLY_COVERED ) );
680 window->State.Visible = GL_FALSE;
684 fgWarning( "Uknown X visibility state: %d",
685 event.xvisibility.state );
693 GETWINDOW( xcrossing );
694 GETMOUSE( xcrossing );
695 INVOKE_WCB( *window, Entry, ( ( EnterNotify == event.type ) ?
702 GETWINDOW( xmotion );
705 if( window->ActiveMenu )
707 if( window == window->ActiveMenu->ParentWindow )
709 window->ActiveMenu->Window->State.MouseX =
710 event.xmotion.x_root - window->ActiveMenu->X;
711 window->ActiveMenu->Window->State.MouseY =
712 event.xmotion.y_root - window->ActiveMenu->Y;
714 window->ActiveMenu->Window->State.Redisplay = GL_TRUE ;
715 fgSetWindow( window->ActiveMenu->ParentWindow );
721 * XXX For more than 5 buttons, just check {event.xmotion.state},
722 * XXX rather than a host of bit-masks? Or maybe we need to
723 * XXX track ButtonPress/ButtonRelease events in our own
726 #define BUTTON_MASK \
727 ( Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask )
728 if ( event.xmotion.state & BUTTON_MASK )
729 INVOKE_WCB( *window, Motion, ( event.xmotion.x,
732 INVOKE_WCB( *window, Passive, ( event.xmotion.x,
740 GLboolean pressed = GL_TRUE;
743 if( event.type == ButtonRelease )
747 * A mouse button has been pressed or released. Traditionally,
748 * break if the window was found within the freeglut structures.
750 GETWINDOW( xbutton );
754 * An X button (at least in XFree86) is numbered from 1.
755 * A GLUT button is numbered from 0.
756 * Old GLUT passed through buttons other than just the first
757 * three, though it only gave symbolic names and official
758 * support to the first three.
760 button = event.xbutton.button - 1;
763 * XXX This comment is replicated in the WIN32 section and
764 * XXX maybe also in the menu code. Can we move the info
765 * XXX to one central place and *reference* it from here?
767 * Do not execute the application's mouse callback if a menu
768 * is hooked to this button. In that case an appropriate
769 * private call should be generated.
770 * Near as I can tell, this is the menu behaviour:
771 * - Down-click the menu button, menu not active: activate
772 * the menu with its upper left-hand corner at the mouse
774 * - Down-click any button outside the menu, menu active:
775 * deactivate the menu
776 * - Down-click any button inside the menu, menu active:
777 * select the menu entry and deactivate the menu
778 * - Up-click the menu button, menu not active: nothing happens
779 * - Up-click the menu button outside the menu, menu active:
781 * - Up-click the menu button inside the menu, menu active:
782 * select the menu entry and deactivate the menu
784 /* Window has an active menu, it absorbs any mouse click */
785 if( window->ActiveMenu )
787 if( window == window->ActiveMenu->ParentWindow )
789 window->ActiveMenu->Window->State.MouseX =
790 event.xbutton.x_root - window->ActiveMenu->X;
791 window->ActiveMenu->Window->State.MouseY =
792 event.xbutton.y_root - window->ActiveMenu->Y;
795 /* In the menu, invoke the callback and deactivate the menu*/
796 if( fgCheckActiveMenu( window->ActiveMenu->Window,
797 window->ActiveMenu ) )
800 * Save the current window and menu and set the current
801 * window to the window whose menu this is
803 SFG_Window *save_window = fgStructure.Window;
804 SFG_Menu *save_menu = fgStructure.Menu;
805 SFG_Window *parent_window =
806 window->ActiveMenu->ParentWindow;
807 fgSetWindow( parent_window );
808 fgStructure.Menu = window->ActiveMenu;
810 /* Execute the menu callback */
811 fgExecuteMenuCallback( window->ActiveMenu );
812 fgDeactivateMenu( parent_window );
814 /* Restore the current window and menu */
815 fgSetWindow( save_window );
816 fgStructure.Menu = save_menu;
820 * Outside the menu, deactivate if it's a downclick
822 * XXX This isn't enough. A downclick outside of
823 * XXX the interior of our freeglut windows should also
824 * XXX deactivate the menu. This is more complicated.
826 fgDeactivateMenu( window->ActiveMenu->ParentWindow );
829 * XXX Why does an active menu require a redisplay at
830 * XXX this point? If this can come out cleanly, then
831 * XXX it probably should do so; if not, a comment should
834 window->State.Redisplay = GL_TRUE;
839 * No active menu, let's check whether we need to activate one.
841 if( ( 0 <= button ) &&
842 ( FREEGLUT_MAX_MENUS > button ) &&
843 ( window->Menu[ button ] ) &&
847 * XXX Posting a requisite Redisplay seems bogus.
849 window->State.Redisplay = GL_TRUE;
850 fgSetWindow( window );
851 fgActivateMenu( window, button );
856 * Check if there is a mouse or mouse wheel callback hooked to the
859 if( ! FETCH_WCB( *window, Mouse ) &&
860 ! FETCH_WCB( *window, MouseWheel ) )
863 fgState.Modifiers = fgGetXModifiers( &event );
866 * Finally execute the mouse or mouse wheel callback
868 * XXX Use a symbolic constant, *not* "4"! ("3, sire!")
870 if( ( button < 3 ) || ( ! FETCH_WCB( *window, MouseWheel ) ) )
871 INVOKE_WCB( *window, Mouse, ( button,
872 pressed ? GLUT_DOWN : GLUT_UP,
879 * Map 4 and 5 to wheel zero; EVEN to +1, ODD to -1
880 * " 6 and 7 " " one; ...
882 * XXX This *should* be behind some variables/macros,
883 * XXX since the order and numbering isn't certain
884 * XXX See XFree86 configuration docs (even back in the
885 * XXX 3.x days, and especially with 4.x).
887 * XXX Note that {button} has already been decremeted
888 * XXX in mapping from X button numbering to GLUT.
890 int wheel_number = (button - 3) / 2;
896 INVOKE_WCB( *window, MouseWheel, ( wheel_number,
904 * Trash the modifiers state
906 fgState.Modifiers = 0xffffffff;
913 FGCBKeyboard keyboard_cb;
914 FGCBSpecial special_cb;
919 if( event.type == KeyPress )
921 keyboard_cb = FETCH_WCB( *window, Keyboard );
922 special_cb = FETCH_WCB( *window, Special );
926 keyboard_cb = FETCH_WCB( *window, KeyboardUp );
927 special_cb = FETCH_WCB( *window, SpecialUp );
931 * Is there a keyboard/special callback hooked for this window?
933 if( keyboard_cb || special_cb )
935 XComposeStatus composeStatus;
936 char asciiCode[ 32 ];
941 * Check for the ASCII/KeySym codes associated with the event:
943 len = XLookupString( &event.xkey, asciiCode, sizeof(asciiCode),
944 &keySym, &composeStatus
948 * GLUT API tells us to have two separate callbacks...
953 * ...one for the ASCII translateable keypresses...
957 fgSetWindow( window );
958 fgState.Modifiers = fgGetXModifiers( &event );
959 keyboard_cb( asciiCode[ 0 ],
960 event.xkey.x, event.xkey.y
962 fgState.Modifiers = 0xffffffff;
970 * ...and one for all the others, which need to be
971 * translated to GLUT_KEY_Xs...
975 case XK_F1: special = GLUT_KEY_F1; break;
976 case XK_F2: special = GLUT_KEY_F2; break;
977 case XK_F3: special = GLUT_KEY_F3; break;
978 case XK_F4: special = GLUT_KEY_F4; break;
979 case XK_F5: special = GLUT_KEY_F5; break;
980 case XK_F6: special = GLUT_KEY_F6; break;
981 case XK_F7: special = GLUT_KEY_F7; break;
982 case XK_F8: special = GLUT_KEY_F8; break;
983 case XK_F9: special = GLUT_KEY_F9; break;
984 case XK_F10: special = GLUT_KEY_F10; break;
985 case XK_F11: special = GLUT_KEY_F11; break;
986 case XK_F12: special = GLUT_KEY_F12; break;
988 case XK_Left: special = GLUT_KEY_LEFT; break;
989 case XK_Right: special = GLUT_KEY_RIGHT; break;
990 case XK_Up: special = GLUT_KEY_UP; break;
991 case XK_Down: special = GLUT_KEY_DOWN; break;
994 case XK_Prior: special = GLUT_KEY_PAGE_UP; break;
996 case XK_Next: special = GLUT_KEY_PAGE_DOWN; break;
998 case XK_Home: special = GLUT_KEY_HOME; break;
1000 case XK_End: special = GLUT_KEY_END; break;
1002 case XK_Insert: special = GLUT_KEY_INSERT; break;
1006 * Execute the callback (if one has been specified),
1007 * given that the special code seems to be valid...
1009 if( special_cb && (special != -1) )
1011 fgSetWindow( window );
1012 fgState.Modifiers = fgGetXModifiers( &event );
1013 special_cb( special, event.xkey.x, event.xkey.y );
1014 fgState.Modifiers = 0xffffffff;
1021 case ReparentNotify:
1022 break; /* XXX Should disable this event */
1025 fgWarning ("Unknown X event type: %d", event.type);
1030 #elif TARGET_HOST_WIN32
1034 while( PeekMessage( &stMsg, NULL, 0, 0, PM_NOREMOVE ) )
1036 if( GetMessage( &stMsg, NULL, 0, 0 ) == 0 )
1038 if( fgState.ActionOnWindowClose == GLUT_ACTION_EXIT )
1043 fgState.ExecState = GLUT_EXEC_STATE_STOP;
1047 TranslateMessage( &stMsg );
1048 DispatchMessage( &stMsg );
1052 if( fgState.Timers.First )
1054 fghCheckJoystickPolls( );
1061 * Enters the freeglut processing loop.
1062 * Stays until the "ExecState" changes to "GLUT_EXEC_STATE_STOP".
1064 void FGAPIENTRY glutMainLoop( void )
1066 #if TARGET_HOST_WIN32
1067 SFG_Window *window = (SFG_Window *)fgStructure.Windows.First ;
1070 freeglut_assert_ready;
1072 #if TARGET_HOST_WIN32
1074 * Processing before the main loop: If there is a window which is open and
1075 * which has a visibility callback, call it. I know this is an ugly hack,
1076 * but I'm not sure what else to do about it. Ideally we should leave
1077 * something uninitialized in the create window code and initialize it in
1078 * the main loop, and have that initialization create a "WM_ACTIVATE"
1079 * message. Then we would put the visibility callback code in the
1080 * "case WM_ACTIVATE" block below. - John Fay -- 10/24/02
1084 if ( FETCH_WCB( *window, Visibility ) )
1086 SFG_Window *current_window = fgStructure.Window ;
1088 INVOKE_WCB( *window, Visibility, ( window->State.Visible ) );
1089 fgSetWindow( current_window );
1092 window = (SFG_Window *)window->Node.Next ;
1096 fgState.ExecState = GLUT_EXEC_STATE_RUNNING ;
1097 while( fgState.ExecState == GLUT_EXEC_STATE_RUNNING )
1101 glutMainLoopEvent( );
1103 * Step through the list of windows, seeing if there are any
1104 * that are not menus
1106 for( window = ( SFG_Window * )fgStructure.Windows.First;
1108 window = ( SFG_Window * )window->Node.Next )
1109 if ( ! ( window->IsMenu ) )
1113 fgState.ExecState = GLUT_EXEC_STATE_STOP;
1116 if( fgState.IdleCallback )
1117 fgState.IdleCallback( );
1119 fgSleepForEvents( );
1124 * When this loop terminates, destroy the display, state and structure
1125 * of a freeglut session, so that another glutInit() call can happen
1128 if( fgState.ActionOnWindowClose == GLUT_ACTION_EXIT )
1133 * Leaves the freeglut processing loop.
1135 void FGAPIENTRY glutLeaveMainLoop( void )
1137 fgState.ExecState = GLUT_EXEC_STATE_STOP ;
1141 #if TARGET_HOST_WIN32
1143 * Determine a GLUT modifer mask based on MS-WINDOWS system info.
1145 int fgGetWin32Modifiers (void)
1148 ( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
1149 ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
1150 ( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
1151 ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
1152 ( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
1153 ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
1157 * The window procedure for handling Win32 events
1159 LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
1162 SFG_Window* window = fgWindowByHandle( hWnd );
1166 if ( ( window == NULL ) && ( uMsg != WM_CREATE ) )
1167 return DefWindowProc( hWnd, uMsg, wParam, lParam );
1169 /* printf ( "Window %3d message <%04x> %12d %12d\n", window?window->ID:0,
1170 uMsg, wParam, lParam ); */
1175 * The window structure is passed as the creation structure paramter...
1177 window = (SFG_Window *) (((LPCREATESTRUCT) lParam)->lpCreateParams);
1178 assert( window != NULL );
1180 window->Window.Handle = hWnd;
1181 window->Window.Device = GetDC( hWnd );
1182 if( window->IsMenu )
1184 unsigned int current_DisplayMode = fgState.DisplayMode;
1185 fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH;
1186 fgSetupPixelFormat( window, GL_FALSE, PFD_MAIN_PLANE );
1187 fgState.DisplayMode = current_DisplayMode;
1189 if( fgStructure.MenuContext )
1190 wglMakeCurrent( window->Window.Device,
1191 fgStructure.MenuContext->Context
1195 fgStructure.MenuContext =
1196 (SFG_MenuContext *)malloc( sizeof(SFG_MenuContext) );
1197 fgStructure.MenuContext->Context =
1198 wglCreateContext( window->Window.Device );
1201 /* window->Window.Context = wglGetCurrentContext (); */
1202 window->Window.Context = wglCreateContext( window->Window.Device );
1206 fgSetupPixelFormat( window, GL_FALSE, PFD_MAIN_PLANE );
1208 if( ! fgState.UseCurrentContext )
1209 window->Window.Context =
1210 wglCreateContext( window->Window.Device );
1213 window->Window.Context = wglGetCurrentContext( );
1214 if( ! window->Window.Context )
1215 window->Window.Context =
1216 wglCreateContext( window->Window.Device );
1220 window->State.NeedToResize = GL_TRUE;
1221 window->State.Width = fgState.Size.X;
1222 window->State.Height = fgState.Size.Y;
1224 ReleaseDC( window->Window.Handle, window->Window.Device );
1229 * We got resized... But check if the window has been already added...
1231 window->State.NeedToResize = GL_TRUE;
1232 window->State.Width = LOWORD(lParam);
1233 window->State.Height = HIWORD(lParam);
1237 printf("WM_SETFOCUS: %p\n", window );
1238 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1242 if (LOWORD(wParam) != WA_INACTIVE)
1244 /* glutSetCursor( fgStructure.Window->State.Cursor ); */
1245 printf("WM_ACTIVATE: glutSetCursor( %p, %d)\n", window,
1246 window->State.Cursor );
1247 glutSetCursor( window->State.Cursor );
1250 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1255 * XXX Why not re-use some common code with the glutSetCursor()
1256 * XXX function (or perhaps invoke glutSetCursor())?
1257 * XXX That is, why are we duplicating code, here, from
1258 * XXX glutSetCursor()? The WIN32 code should be able to just
1259 * XXX call glutSetCurdsor() instead of defining two macros
1260 * XXX and implementing a nested case in-line.
1263 /* Set the cursor AND change it for this window class. */
1264 #define MAP_CURSOR(a,b) \
1266 SetCursor( LoadCursor( NULL, b ) ); \
1269 /* Nuke the cursor AND change it for this window class. */
1270 #define ZAP_CURSOR(a,b) \
1272 SetCursor( NULL ); \
1275 if( LOWORD( lParam ) == HTCLIENT )
1276 switch( window->State.Cursor )
1278 MAP_CURSOR( GLUT_CURSOR_RIGHT_ARROW, IDC_ARROW );
1279 MAP_CURSOR( GLUT_CURSOR_LEFT_ARROW, IDC_ARROW );
1280 MAP_CURSOR( GLUT_CURSOR_INFO, IDC_HELP );
1281 MAP_CURSOR( GLUT_CURSOR_DESTROY, IDC_CROSS );
1282 MAP_CURSOR( GLUT_CURSOR_HELP, IDC_HELP );
1283 MAP_CURSOR( GLUT_CURSOR_CYCLE, IDC_SIZEALL );
1284 MAP_CURSOR( GLUT_CURSOR_SPRAY, IDC_CROSS );
1285 MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT );
1286 MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_UPARROW );
1287 MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS );
1288 /* MAP_CURSOR( GLUT_CURSOR_NONE, IDC_NO ); */
1289 ZAP_CURSOR( GLUT_CURSOR_NONE, NULL );
1292 MAP_CURSOR( GLUT_CURSOR_UP_DOWN, IDC_ARROW );
1295 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1299 window->State.Visible = GL_TRUE;
1300 window->State.Redisplay = GL_TRUE;
1304 /* Turn on the visibility in case it was turned off somehow */
1305 window->State.Visible = GL_TRUE;
1306 BeginPaint( hWnd, &ps );
1307 fghRedrawWindowByHandle( hWnd );
1308 EndPaint( hWnd, &ps );
1312 fgDestroyWindow ( window );
1313 if ( fgState.ActionOnWindowClose != GLUT_ACTION_CONTINUE_EXECUTION )
1319 * The window already got destroyed, so don't bother with it.
1325 window->State.MouseX = LOWORD( lParam );
1326 window->State.MouseY = HIWORD( lParam );
1328 if ( window->ActiveMenu )
1330 window->State.Redisplay = GL_TRUE;
1331 fgSetWindow ( window->ActiveMenu->ParentWindow );
1335 fgState.Modifiers = fgGetWin32Modifiers( );
1337 if( ( wParam & MK_LBUTTON ) ||
1338 ( wParam & MK_MBUTTON ) ||
1339 ( wParam & MK_RBUTTON ) )
1340 INVOKE_WCB( *window, Motion, ( window->State.MouseX,
1341 window->State.MouseY ) );
1343 INVOKE_WCB( *window, Passive, ( window->State.MouseX,
1344 window->State.MouseY ) );
1346 fgState.Modifiers = 0xffffffff;
1350 case WM_LBUTTONDOWN:
1351 case WM_MBUTTONDOWN:
1352 case WM_RBUTTONDOWN:
1357 GLboolean pressed = GL_TRUE;
1360 window->State.MouseX = LOWORD( lParam );
1361 window->State.MouseY = HIWORD( lParam );
1365 case WM_LBUTTONDOWN:
1367 button = GLUT_LEFT_BUTTON;
1369 case WM_MBUTTONDOWN:
1371 button = GLUT_MIDDLE_BUTTON;
1373 case WM_RBUTTONDOWN:
1375 button = GLUT_RIGHT_BUTTON;
1379 button = GLUT_LEFT_BUTTON;
1383 button = GLUT_MIDDLE_BUTTON;
1387 button = GLUT_RIGHT_BUTTON;
1395 if( GetSystemMetrics( SM_SWAPBUTTON ) )
1396 if( button == GLUT_LEFT_BUTTON )
1397 button = GLUT_RIGHT_BUTTON;
1398 else if( button == GLUT_RIGHT_BUTTON )
1399 button = GLUT_LEFT_BUTTON;
1402 return DefWindowProc( hWnd, uMsg, lParam, wParam );
1405 * XXX This comment is duplicated in two other spots.
1406 * XXX Can we centralize it?
1408 * Do not execute the application's mouse callback if a
1409 * menu is hooked to this button.
1410 * In that case an appropriate private call should be generated.
1411 * Near as I can tell, this is the menu behaviour:
1412 * - Down-click the menu button, menu not active: activate
1413 * the menu with its upper left-hand corner at the mouse location.
1414 * - Down-click any button outside the menu, menu active:
1415 * deactivate the menu
1416 * - Down-click any button inside the menu, menu active:
1417 * select the menu entry and deactivate the menu
1418 * - Up-click the menu button, menu not active: nothing happens
1419 * - Up-click the menu button outside the menu, menu active:
1421 * - Up-click the menu button inside the menu, menu active:
1422 * select the menu entry and deactivate the menu
1424 /* Window has an active menu, it absorbs any mouse click */
1425 if( window->ActiveMenu )
1427 /* Outside the menu, deactivate the menu if it's a downclick */
1428 if( ! fgCheckActiveMenu( window, window->ActiveMenu ) )
1431 fgDeactivateMenu( window->ActiveMenu->ParentWindow );
1433 else /* In menu, invoke the callback and deactivate the menu*/
1436 * Save the current window and menu and set the current
1437 * window to the window whose menu this is
1439 SFG_Window *save_window = fgStructure.Window;
1440 SFG_Menu *save_menu = fgStructure.Menu;
1441 SFG_Window *parent_window = window->ActiveMenu->ParentWindow;
1442 fgSetWindow( parent_window );
1443 fgStructure.Menu = window->ActiveMenu;
1445 /* Execute the menu callback */
1446 fgExecuteMenuCallback( window->ActiveMenu );
1447 fgDeactivateMenu( parent_window );
1449 /* Restore the current window and menu */
1450 fgSetWindow( save_window );
1451 fgStructure.Menu = save_menu;
1455 * Let's make the window redraw as a result of the mouse
1456 * click and menu activity.
1458 if( ! window->IsMenu )
1459 window->State.Redisplay = GL_TRUE;
1464 if( window->Menu[ button ] && pressed )
1466 window->State.Redisplay = GL_TRUE;
1467 fgSetWindow( window );
1468 fgActivateMenu( window, button );
1473 if( ! FETCH_WCB( *window, Mouse ) )
1476 fgSetWindow( window );
1477 fgState.Modifiers = fgGetWin32Modifiers( );
1482 pressed ? GLUT_DOWN : GLUT_UP,
1483 window->State.MouseX,
1484 window->State.MouseY
1488 fgState.Modifiers = 0xffffffff;
1493 /* Should be WM_MOUSEWHEEL but my compiler doesn't recognize it */
1496 * XXX THIS IS SPECULATIVE -- John Fay, 10/2/03
1497 * XXX Should use WHEEL_DELTA instead of 120
1499 int wheel_number = LOWORD( wParam );
1500 short ticks = ( short )HIWORD( wParam ) / 120;
1510 * The mouse cursor has moved. Remember the new mouse cursor's position
1512 /* window->State.MouseX = LOWORD( lParam ); */
1513 /* Need to adjust by window position, */
1514 /* window->State.MouseY = HIWORD( lParam ); */
1515 /* change "lParam" to other parameter */
1517 if( ! FETCH_WCB( *window, MouseWheel ) &&
1518 ! FETCH_WCB( *window, Mouse ) )
1521 fgSetWindow( window );
1522 fgState.Modifiers = fgGetWin32Modifiers( );
1525 if( FETCH_WCB( *window, MouseWheel ) )
1526 INVOKE_WCB( *window, MouseWheel,
1529 window->State.MouseX,
1530 window->State.MouseY
1533 else /* No mouse wheel, call the mouse button callback twice */
1536 * XXX The below assumes that you have no more than 3 mouse
1537 * XXX buttons. Sorry.
1539 int button = wheel_number*2 + 4;
1542 INVOKE_WCB( *window, Mouse,
1543 ( button, GLUT_DOWN,
1544 window->State.MouseX, window->State.MouseY )
1546 INVOKE_WCB( *window, Mouse,
1548 window->State.MouseX, window->State.MouseX )
1552 fgState.Modifiers = 0xffffffff;
1562 if( fgState.IgnoreKeyRepeat && (lParam & KF_REPEAT) )
1566 * Remember the current modifiers state. This is done here in order
1567 * to make sure the VK_DELETE keyboard callback is executed properly.
1569 fgState.Modifiers = fgGetWin32Modifiers( );
1571 GetCursorPos( &mouse_pos );
1572 ScreenToClient( window->Window.Handle, &mouse_pos );
1574 window->State.MouseX = mouse_pos.x;
1575 window->State.MouseY = mouse_pos.y;
1578 * Convert the Win32 keystroke codes to GLUTtish way
1580 # define KEY(a,b) case a: keypress = b; break;
1584 KEY( VK_F1, GLUT_KEY_F1 );
1585 KEY( VK_F2, GLUT_KEY_F2 );
1586 KEY( VK_F3, GLUT_KEY_F3 );
1587 KEY( VK_F4, GLUT_KEY_F4 );
1588 KEY( VK_F5, GLUT_KEY_F5 );
1589 KEY( VK_F6, GLUT_KEY_F6 );
1590 KEY( VK_F7, GLUT_KEY_F7 );
1591 KEY( VK_F8, GLUT_KEY_F8 );
1592 KEY( VK_F9, GLUT_KEY_F9 );
1593 KEY( VK_F10, GLUT_KEY_F10 );
1594 KEY( VK_F11, GLUT_KEY_F11 );
1595 KEY( VK_F12, GLUT_KEY_F12 );
1596 KEY( VK_PRIOR, GLUT_KEY_PAGE_UP );
1597 KEY( VK_NEXT, GLUT_KEY_PAGE_DOWN );
1598 KEY( VK_HOME, GLUT_KEY_HOME );
1599 KEY( VK_END, GLUT_KEY_END );
1600 KEY( VK_LEFT, GLUT_KEY_LEFT );
1601 KEY( VK_UP, GLUT_KEY_UP );
1602 KEY( VK_RIGHT, GLUT_KEY_RIGHT );
1603 KEY( VK_DOWN, GLUT_KEY_DOWN );
1604 KEY( VK_INSERT, GLUT_KEY_INSERT );
1608 * The delete key should be treated as an ASCII keypress:
1610 INVOKE_WCB( *window, Keyboard,
1611 ( 127, window->State.MouseX, window->State.MouseY )
1615 if( keypress != -1 )
1616 INVOKE_WCB( *window, Special,
1618 window->State.MouseX, window->State.MouseY )
1621 fgState.Modifiers = 0xffffffff;
1632 * Remember the current modifiers state. This is done here in order
1633 * to make sure the VK_DELETE keyboard callback is executed properly.
1635 fgState.Modifiers = fgGetWin32Modifiers( );
1637 GetCursorPos( &mouse_pos );
1638 ScreenToClient( window->Window.Handle, &mouse_pos );
1640 window->State.MouseX = mouse_pos.x;
1641 window->State.MouseY = mouse_pos.y;
1644 * Convert the Win32 keystroke codes to GLUTtish way.
1645 * "KEY(a,b)" was defined under "WM_KEYDOWN"
1650 KEY( VK_F1, GLUT_KEY_F1 );
1651 KEY( VK_F2, GLUT_KEY_F2 );
1652 KEY( VK_F3, GLUT_KEY_F3 );
1653 KEY( VK_F4, GLUT_KEY_F4 );
1654 KEY( VK_F5, GLUT_KEY_F5 );
1655 KEY( VK_F6, GLUT_KEY_F6 );
1656 KEY( VK_F7, GLUT_KEY_F7 );
1657 KEY( VK_F8, GLUT_KEY_F8 );
1658 KEY( VK_F9, GLUT_KEY_F9 );
1659 KEY( VK_F10, GLUT_KEY_F10 );
1660 KEY( VK_F11, GLUT_KEY_F11 );
1661 KEY( VK_F12, GLUT_KEY_F12 );
1662 KEY( VK_PRIOR, GLUT_KEY_PAGE_UP );
1663 KEY( VK_NEXT, GLUT_KEY_PAGE_DOWN );
1664 KEY( VK_HOME, GLUT_KEY_HOME );
1665 KEY( VK_END, GLUT_KEY_END );
1666 KEY( VK_LEFT, GLUT_KEY_LEFT );
1667 KEY( VK_UP, GLUT_KEY_UP );
1668 KEY( VK_RIGHT, GLUT_KEY_RIGHT );
1669 KEY( VK_DOWN, GLUT_KEY_DOWN );
1670 KEY( VK_INSERT, GLUT_KEY_INSERT );
1674 * The delete key should be treated as an ASCII keypress:
1676 INVOKE_WCB( *window, KeyboardUp,
1677 ( 127, window->State.MouseX, window->State.MouseY )
1686 GetKeyboardState( state );
1688 if( ToAscii( wParam, 0, state, code, 0 ) == 1 )
1691 INVOKE_WCB( *window, KeyboardUp,
1693 window->State.MouseX, window->State.MouseY )
1698 if( keypress != -1 )
1699 INVOKE_WCB( *window, SpecialUp,
1701 window->State.MouseX, window->State.MouseY )
1704 fgState.Modifiers = 0xffffffff;
1711 if( fgState.IgnoreKeyRepeat && (lParam & KF_REPEAT) )
1714 fgState.Modifiers = fgGetWin32Modifiers( );
1715 INVOKE_WCB( *window, Keyboard,
1717 window->State.MouseX, window->State.MouseY )
1719 fgState.Modifiers = 0xffffffff;
1723 case WM_CAPTURECHANGED:
1724 /* User has finished resizing the window, force a redraw */
1725 INVOKE_WCB( *window, Display, ( ) );
1727 /*lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ); */
1731 * Other messages that I have seen and which are not handled already
1733 case WM_SETTEXT: /* 0x000c */
1734 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1735 /* Pass it on to "DefWindowProc" to set the window text */
1738 case WM_GETTEXT: /* 0x000d */
1739 /* Ideally we would copy the title of the window into "lParam" */
1740 /* strncpy ( (char *)lParam, "Window Title", wParam );
1741 lRet = ( wParam > 12 ) ? 12 : wParam; */
1742 /* the number of characters copied */
1743 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1746 case WM_GETTEXTLENGTH: /* 0x000e */
1747 /* Ideally we would get the length of the title of the window */
1749 /* the number of characters in "Window Title\0" (see above) */
1752 case WM_ERASEBKGND: /* 0x0014 */
1753 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1756 case WM_SYNCPAINT: /* 0x0088 */
1757 /* Another window has moved, need to update this one */
1758 window->State.Redisplay = GL_TRUE;
1759 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1760 /* Help screen says this message must be passed to "DefWindowProc" */
1763 case WM_NCPAINT: /* 0x0085 */
1764 /* Need to update the border of this window */
1765 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1766 /* Pass it on to "DefWindowProc" to repaint a standard border */
1769 case WM_SYSCOMMAND : /* 0x0112 */
1772 * We have received a system command message. Try to act on it.
1773 * The commands are passed in through the "lParam" parameter:
1774 * Clicking on a corner to resize the window gives a "F004" message
1775 * but this is not defined in my header file.
1786 /* User has clicked on the "-" to minimize the window */
1787 /* Turn off the visibility */
1788 window->State.Visible = GL_FALSE ;
1795 case SC_NEXTWINDOW :
1798 case SC_PREVWINDOW :
1802 /* Followed very closely by a WM_CLOSE message */
1826 case SC_SCREENSAVE :
1834 /* We need to pass the message on to the operating system as well */
1835 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1840 * Handle unhandled messages
1842 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1850 /*** END OF FILE ***/