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.
28 #include <GL/freeglut.h>
29 #include "freeglut_internal.h"
33 # define VFPRINTF(s,f,a) vfprintf((s),(f),(a))
35 # define VFPRINTF(s,f,a) _doprnt((f),(a),(s))
37 # define VFPRINTF(s,f,a)
42 typedef struct GXDisplayProperties GXDisplayProperties;
43 typedef struct GXKeyList GXKeyList;
46 typedef struct GXKeyList (*GXGETDEFAULTKEYS)(int);
47 typedef int (*GXOPENINPUT)();
49 GXGETDEFAULTKEYS GXGetDefaultKeys_ = NULL;
50 GXOPENINPUT GXOpenInput_ = NULL;
52 struct GXKeyList gxKeyList;
57 * Try to get the maximum value allowed for ints, falling back to the minimum
58 * guaranteed by ISO C99 if there is no suitable header.
64 # define INT_MAX 32767
68 #define MIN(a,b) (((a)<(b)) ? (a) : (b))
73 * TODO BEFORE THE STABLE RELEASE:
75 * There are some issues concerning window redrawing under X11, and maybe
76 * some events are not handled. The Win32 version lacks some more features,
77 * but seems acceptable for not demanding purposes.
79 * Need to investigate why the X11 version breaks out with an error when
80 * closing a window (using the window manager, not glutDestroyWindow)...
83 /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
86 * Handle a window configuration change. When no reshape
87 * callback is hooked, the viewport size is updated to
88 * match the new window size.
90 static void fghReshapeWindow ( SFG_Window *window, int width, int height )
92 SFG_Window *current_window = fgStructure.CurrentWindow;
94 freeglut_return_if_fail( window != NULL );
97 #if TARGET_HOST_UNIX_X11
99 XResizeWindow( fgDisplay.Display, window->Window.Handle,
101 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
103 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
105 #if !TARGET_HOST_WINCE
111 * For windowed mode, get the current position of the
112 * window and resize taking the size of the frame
113 * decorations into account.
116 /* "GetWindowRect" returns the pixel coordinates of the outside of the window */
117 GetWindowRect( window->Window.Handle, &winRect );
123 if ( window->Parent == NULL )
125 if ( ! window->IsMenu && !window->State.IsGameMode )
127 w += GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
128 h += GetSystemMetrics( SM_CYSIZEFRAME ) * 2 +
129 GetSystemMetrics( SM_CYCAPTION );
135 GetWindowRect( window->Parent->Window.Handle, &parentRect );
136 x -= parentRect.left + GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
137 y -= parentRect.top + GetSystemMetrics( SM_CYSIZEFRAME ) * 2 +
138 GetSystemMetrics( SM_CYCAPTION );
142 * SWP_NOACTIVATE Do not activate the window
143 * SWP_NOOWNERZORDER Do not change position in z-order
144 * SWP_NOSENDCHANGING Supress WM_WINDOWPOSCHANGING message
145 * SWP_NOZORDER Retains the current Z order (ignore 2nd param)
148 SetWindowPos( window->Window.Handle,
151 SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING |
155 #endif /* TARGET_HOST_WINCE */
158 * XXX Should update {window->State.OldWidth, window->State.OldHeight}
159 * XXX to keep in lockstep with UNIX_X11 code.
161 if( FETCH_WCB( *window, Reshape ) )
162 INVOKE_WCB( *window, Reshape, ( width, height ) );
165 fgSetWindow( window );
166 glViewport( 0, 0, width, height );
172 * Force a window redraw. In Windows at least this is only a partial
173 * solution: if the window is increasing in size in either dimension,
174 * the already-drawn part does not get drawn again and things look funny.
175 * But without this we get this bad behaviour whenever we resize the
178 window->State.Redisplay = GL_TRUE;
181 fgSetWindow( current_window );
185 * Calls a window's redraw method. This is used when
186 * a redraw is forced by the incoming window messages.
188 static void fghRedrawWindow ( SFG_Window *window )
190 SFG_Window *current_window = fgStructure.CurrentWindow;
192 freeglut_return_if_fail( window );
193 freeglut_return_if_fail( FETCH_WCB ( *window, Display ) );
195 window->State.Redisplay = GL_FALSE;
197 freeglut_return_if_fail( window->State.Visible );
199 fgSetWindow( window );
201 if( window->State.NeedToResize )
209 window->State.NeedToResize = GL_FALSE;
212 INVOKE_WCB( *window, Display, ( ) );
214 fgSetWindow( current_window );
218 * A static helper function to execute display callback for a window
220 static void fghcbDisplayWindow( SFG_Window *window,
221 SFG_Enumerator *enumerator )
223 if( window->State.Redisplay &&
224 window->State.Visible )
226 window->State.Redisplay = GL_FALSE;
228 #if TARGET_HOST_UNIX_X11
229 fghRedrawWindow ( window ) ;
230 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
232 window->Window.Handle, NULL, NULL,
233 RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE | RDW_UPDATENOW
238 fgEnumSubWindows( window, fghcbDisplayWindow, enumerator );
242 * Make all windows perform a display call
244 static void fghDisplayAll( void )
246 SFG_Enumerator enumerator;
248 enumerator.found = GL_FALSE;
249 enumerator.data = NULL;
251 fgEnumWindows( fghcbDisplayWindow, &enumerator );
255 * Window enumerator callback to check for the joystick polling code
257 static void fghcbCheckJoystickPolls( SFG_Window *window,
258 SFG_Enumerator *enumerator )
260 long int checkTime = fgElapsedTime( );
262 if( window->State.JoystickLastPoll + window->State.JoystickPollRate <=
265 #if !TARGET_HOST_WINCE
266 fgJoystickPollWindow( window );
267 #endif /* !TARGET_HOST_WINCE */
268 window->State.JoystickLastPoll = checkTime;
271 fgEnumSubWindows( window, fghcbCheckJoystickPolls, enumerator );
275 * Check all windows for joystick polling
277 static void fghCheckJoystickPolls( void )
279 SFG_Enumerator enumerator;
281 enumerator.found = GL_FALSE;
282 enumerator.data = NULL;
284 fgEnumWindows( fghcbCheckJoystickPolls, &enumerator );
288 * Check the global timers
290 static void fghCheckTimers( void )
292 long checkTime = fgElapsedTime( );
294 while( fgState.Timers.First )
296 SFG_Timer *timer = fgState.Timers.First;
298 if( timer->TriggerTime > checkTime )
301 fgListRemove( &fgState.Timers, &timer->Node );
302 fgListAppend( &fgState.FreeTimers, &timer->Node );
304 timer->Callback( timer->ID );
311 long fgElapsedTime( void )
313 if ( fgState.Time.Set )
315 #if TARGET_HOST_UNIX_X11
319 gettimeofday( &now, NULL );
321 elapsed = (now.tv_usec - fgState.Time.Value.tv_usec) / 1000;
322 elapsed += (now.tv_sec - fgState.Time.Value.tv_sec) * 1000;
325 #elif TARGET_HOST_WIN32
326 return timeGetTime() - fgState.Time.Value;
327 #elif TARGET_HOST_WINCE
328 return GetTickCount() - fgState.Time.Value;
333 #if TARGET_HOST_UNIX_X11
334 gettimeofday( &fgState.Time.Value, NULL );
335 #elif TARGET_HOST_WIN32
336 fgState.Time.Value = timeGetTime ();
337 #elif TARGET_HOST_WINCE
338 fgState.Time.Value = GetTickCount();
340 fgState.Time.Set = GL_TRUE ;
349 void fgError( const char *fmt, ... )
355 fprintf( stderr, "freeglut ");
356 if( fgState.ProgramName )
357 fprintf( stderr, "(%s): ", fgState.ProgramName );
358 VFPRINTF( stderr, fmt, ap );
359 fprintf( stderr, "\n" );
363 if ( fgState.Initialised )
369 void fgWarning( const char *fmt, ... )
375 fprintf( stderr, "freeglut ");
376 if( fgState.ProgramName )
377 fprintf( stderr, "(%s): ", fgState.ProgramName );
378 VFPRINTF( stderr, fmt, ap );
379 fprintf( stderr, "\n" );
385 * Indicates whether Joystick events are being used by ANY window.
387 * The current mechanism is to walk all of the windows and ask if
388 * there is a joystick callback. We have a short-circuit early
389 * return if we find any joystick handler registered.
391 * The real way to do this is to make use of the glutTimer() API
392 * to more cleanly re-implement the joystick API. Then, this code
393 * and all other "joystick timer" code can be yanked.
396 static void fghCheckJoystickCallback( SFG_Window* w, SFG_Enumerator* e)
398 if( FETCH_WCB( *w, Joystick ) )
403 fgEnumSubWindows( w, fghCheckJoystickCallback, e );
405 static int fghHaveJoystick( void )
407 SFG_Enumerator enumerator;
409 enumerator.found = GL_FALSE;
410 enumerator.data = NULL;
411 fgEnumWindows( fghCheckJoystickCallback, &enumerator );
412 return !!enumerator.data;
414 static void fghHavePendingRedisplaysCallback( SFG_Window* w, SFG_Enumerator* e)
416 if( w->State.Redisplay )
421 fgEnumSubWindows( w, fghHavePendingRedisplaysCallback, e );
423 static int fghHavePendingRedisplays (void)
425 SFG_Enumerator enumerator;
427 enumerator.found = GL_FALSE;
428 enumerator.data = NULL;
429 fgEnumWindows( fghHavePendingRedisplaysCallback, &enumerator );
430 return !!enumerator.data;
433 * Returns the number of GLUT ticks (milliseconds) till the next timer event.
435 static long fghNextTimer( void )
438 SFG_Timer *timer = fgState.Timers.First;
441 ret = timer->TriggerTime - fgElapsedTime();
448 * Does the magic required to relinquish the CPU until something interesting
451 static void fghSleepForEvents( void )
455 if( fgState.IdleCallback || fghHavePendingRedisplays( ) )
458 msec = fghNextTimer( );
459 /* XXX Use GLUT timers for joysticks... */
460 /* XXX Dumb; forces granularity to .01sec */
461 if( fghHaveJoystick( ) && ( msec < 10 ) )
464 #if TARGET_HOST_UNIX_X11
466 * Possibly due to aggressive use of XFlush() and friends,
467 * it is possible to have our socket drained but still have
468 * unprocessed events. (Or, this may just be normal with
469 * X, anyway?) We do non-trivial processing of X events
470 * after the event-reading loop, in any case, so we
471 * need to allow that we may have an empty socket but non-
474 if( ! XPending( fgDisplay.Display ) )
481 socket = ConnectionNumber( fgDisplay.Display );
483 FD_SET( socket, &fdset );
484 wait.tv_sec = msec / 1000;
485 wait.tv_usec = (msec % 1000) * 1000;
486 err = select( socket+1, &fdset, NULL, NULL, &wait );
488 if( ( -1 == err ) && ( errno != EINTR ) )
489 fgWarning ( "freeglut select() error: %d", errno );
491 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
492 MsgWaitForMultipleObjects( 0, NULL, FALSE, msec, QS_ALLEVENTS );
496 #if TARGET_HOST_UNIX_X11
498 * Returns GLUT modifier mask for an XEvent.
500 static int fghGetXModifiers( 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
527 /* This code was repeated constantly, so here it goes into a definition: */
528 #define GETWINDOW(a) \
529 window = fgWindowByHandle( event.a.window ); \
530 if( window == NULL ) \
533 #define GETMOUSE(a) \
534 window->State.MouseX = event.a.x; \
535 window->State.MouseY = event.a.y;
537 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoopEvent" );
539 while( XPending( fgDisplay.Display ) )
541 XNextEvent( fgDisplay.Display, &event );
546 /* Destroy the window when the WM_DELETE_WINDOW message arrives */
547 if( (Atom) event.xclient.data.l[ 0 ] == fgDisplay.DeleteWindow )
549 GETWINDOW( xclient );
551 fgDestroyWindow ( window );
553 if( fgState.ActionOnWindowClose == GLUT_ACTION_EXIT )
558 else if( fgState.ActionOnWindowClose == GLUT_ACTION_GLUTMAINLOOP_RETURNS )
559 fgState.ExecState = GLUT_EXEC_STATE_STOP;
566 * CreateNotify causes a configure-event so that sub-windows are
567 * handled compatibly with GLUT. Otherwise, your sub-windows
568 * (in freeglut only) will not get an initial reshape event,
569 * which can break things.
571 * GLUT presumably does this because it generally tries to treat
572 * sub-windows the same as windows.
574 * XXX Technically, GETWINDOW( xconfigure ) and
575 * XXX {event.xconfigure} may not be legit ways to get at
576 * XXX data for CreateNotify events. In practice, the data
577 * XXX is in a union which is laid out much the same either
578 * XXX way. But if you want to split hairs, this isn't legit,
579 * XXX and we should instead duplicate some code.
582 case ConfigureNotify:
583 GETWINDOW( xconfigure );
585 int width = event.xconfigure.width;
586 int height = event.xconfigure.height;
588 if( ( width != window->State.OldWidth ) ||
589 ( height != window->State.OldHeight ) )
591 window->State.OldWidth = width;
592 window->State.OldHeight = height;
593 if( FETCH_WCB( *window, Reshape ) )
594 INVOKE_WCB( *window, Reshape, ( width, height ) );
597 fgSetWindow( window );
598 glViewport( 0, 0, width, height );
600 glutPostRedisplay( );
607 * This is sent to confirm the XDestroyWindow call.
609 * XXX WHY is this commented out? Should we re-enable it?
611 /* fgAddToWindowDestroyList ( window ); */
616 * We are too dumb to process partial exposes...
618 * XXX Well, we could do it. However, it seems to only
619 * XXX be potentially useful for single-buffered (since
620 * XXX double-buffered does not respect viewport when we
621 * XXX do a buffer-swap).
624 if( event.xexpose.count == 0 )
626 GETWINDOW( xexpose );
627 fgSetWindow( window );
628 glutPostRedisplay( );
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( "Unknown 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 * Do not execute the application's mouse callback if a menu
763 * is hooked to this button. In that case an appropriate
764 * private call should be generated.
766 if( fgCheckActiveMenu( window, button, pressed,
767 event.xbutton.x_root, event.xbutton.y_root ) )
771 * Check if there is a mouse or mouse wheel callback hooked to the
774 if( ! FETCH_WCB( *window, Mouse ) &&
775 ! FETCH_WCB( *window, MouseWheel ) )
778 fgState.Modifiers = fghGetXModifiers( &event );
781 * Finally execute the mouse or mouse wheel callback
783 * XXX Use a symbolic constant, *not* "4"! ("3, sire!")
785 if( ( button < 3 ) || ( ! FETCH_WCB( *window, MouseWheel ) ) )
786 INVOKE_WCB( *window, Mouse, ( button,
787 pressed ? GLUT_DOWN : GLUT_UP,
794 * Map 4 and 5 to wheel zero; EVEN to +1, ODD to -1
795 * " 6 and 7 " " one; ...
797 * XXX This *should* be behind some variables/macros,
798 * XXX since the order and numbering isn't certain
799 * XXX See XFree86 configuration docs (even back in the
800 * XXX 3.x days, and especially with 4.x).
802 * XXX Note that {button} has already been decremeted
803 * XXX in mapping from X button numbering to GLUT.
805 int wheel_number = (button - 3) / 2;
811 INVOKE_WCB( *window, MouseWheel, ( wheel_number,
818 /* Trash the modifiers state */
819 fgState.Modifiers = 0xffffffff;
826 FGCBKeyboard keyboard_cb;
827 FGCBSpecial special_cb;
832 /* Detect auto repeated keys, if configured globally or per-window */
834 if ( fgState.KeyRepeat==GLUT_KEY_REPEAT_OFF || window->State.IgnoreKeyRepeat==GL_TRUE )
836 if (event.type==KeyRelease)
839 * Look at X11 keystate to detect repeat mode.
840 * While X11 says the key is actually held down, we'll ignore KeyRelease/KeyPress pairs.
844 XQueryKeymap( fgDisplay.Display, keys ); /* Look at X11 keystate to detect repeat mode */
846 if ( event.xkey.keycode<256 ) /* XQueryKeymap is limited to 256 keycodes */
848 if ( keys[event.xkey.keycode>>3] & (1<<(event.xkey.keycode%8)) )
849 window->State.KeyRepeating = GL_TRUE;
851 window->State.KeyRepeating = GL_FALSE;
856 window->State.KeyRepeating = GL_FALSE;
858 /* Cease processing this event if it is auto repeated */
860 if (window->State.KeyRepeating)
863 if( event.type == KeyPress )
865 keyboard_cb = FETCH_WCB( *window, Keyboard );
866 special_cb = FETCH_WCB( *window, Special );
870 keyboard_cb = FETCH_WCB( *window, KeyboardUp );
871 special_cb = FETCH_WCB( *window, SpecialUp );
874 /* Is there a keyboard/special callback hooked for this window? */
875 if( keyboard_cb || special_cb )
877 XComposeStatus composeStatus;
878 char asciiCode[ 32 ];
882 /* Check for the ASCII/KeySym codes associated with the event: */
883 len = XLookupString( &event.xkey, asciiCode, sizeof(asciiCode),
884 &keySym, &composeStatus
887 /* GLUT API tells us to have two separate callbacks... */
890 /* ...one for the ASCII translateable keypresses... */
893 fgSetWindow( window );
894 fgState.Modifiers = fghGetXModifiers( &event );
895 keyboard_cb( asciiCode[ 0 ],
896 event.xkey.x, event.xkey.y
898 fgState.Modifiers = 0xffffffff;
906 * ...and one for all the others, which need to be
907 * translated to GLUT_KEY_Xs...
911 case XK_F1: special = GLUT_KEY_F1; break;
912 case XK_F2: special = GLUT_KEY_F2; break;
913 case XK_F3: special = GLUT_KEY_F3; break;
914 case XK_F4: special = GLUT_KEY_F4; break;
915 case XK_F5: special = GLUT_KEY_F5; break;
916 case XK_F6: special = GLUT_KEY_F6; break;
917 case XK_F7: special = GLUT_KEY_F7; break;
918 case XK_F8: special = GLUT_KEY_F8; break;
919 case XK_F9: special = GLUT_KEY_F9; break;
920 case XK_F10: special = GLUT_KEY_F10; break;
921 case XK_F11: special = GLUT_KEY_F11; break;
922 case XK_F12: special = GLUT_KEY_F12; break;
924 case XK_Left: special = GLUT_KEY_LEFT; break;
925 case XK_Right: special = GLUT_KEY_RIGHT; break;
926 case XK_Up: special = GLUT_KEY_UP; break;
927 case XK_Down: special = GLUT_KEY_DOWN; break;
930 case XK_Prior: special = GLUT_KEY_PAGE_UP; break;
932 case XK_Next: special = GLUT_KEY_PAGE_DOWN; break;
934 case XK_Home: special = GLUT_KEY_HOME; break;
936 case XK_End: special = GLUT_KEY_END; break;
938 case XK_Insert: special = GLUT_KEY_INSERT; break;
942 * Execute the callback (if one has been specified),
943 * given that the special code seems to be valid...
945 if( special_cb && (special != -1) )
947 fgSetWindow( window );
948 fgState.Modifiers = fghGetXModifiers( &event );
949 special_cb( special, event.xkey.x, event.xkey.y );
950 fgState.Modifiers = 0xffffffff;
958 break; /* XXX Should disable this event */
961 fgWarning ("Unknown X event type: %d", event.type);
966 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
970 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoopEvent" );
972 while( PeekMessage( &stMsg, NULL, 0, 0, PM_NOREMOVE ) )
974 if( GetMessage( &stMsg, NULL, 0, 0 ) == 0 )
976 if( fgState.ActionOnWindowClose == GLUT_ACTION_EXIT )
981 else if( fgState.ActionOnWindowClose == GLUT_ACTION_GLUTMAINLOOP_RETURNS )
982 fgState.ExecState = GLUT_EXEC_STATE_STOP;
987 TranslateMessage( &stMsg );
988 DispatchMessage( &stMsg );
992 if( fgState.Timers.First )
994 fghCheckJoystickPolls( );
1001 * Enters the freeglut processing loop.
1002 * Stays until the "ExecState" changes to "GLUT_EXEC_STATE_STOP".
1004 void FGAPIENTRY glutMainLoop( void )
1008 #if TARGET_HOST_WIN32 || TARGET_HOST_WINCE
1009 SFG_Window *window = (SFG_Window *)fgStructure.Windows.First ;
1012 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoop" );
1014 #if TARGET_HOST_WIN32 || TARGET_HOST_WINCE
1016 * Processing before the main loop: If there is a window which is open and
1017 * which has a visibility callback, call it. I know this is an ugly hack,
1018 * but I'm not sure what else to do about it. Ideally we should leave
1019 * something uninitialized in the create window code and initialize it in
1020 * the main loop, and have that initialization create a "WM_ACTIVATE"
1021 * message. Then we would put the visibility callback code in the
1022 * "case WM_ACTIVATE" block below. - John Fay -- 10/24/02
1026 if ( FETCH_WCB( *window, Visibility ) )
1028 SFG_Window *current_window = fgStructure.CurrentWindow ;
1030 INVOKE_WCB( *window, Visibility, ( window->State.Visible ) );
1031 fgSetWindow( current_window );
1034 window = (SFG_Window *)window->Node.Next ;
1038 fgState.ExecState = GLUT_EXEC_STATE_RUNNING ;
1039 while( fgState.ExecState == GLUT_EXEC_STATE_RUNNING )
1043 glutMainLoopEvent( );
1045 * Step through the list of windows, seeing if there are any
1046 * that are not menus
1048 for( window = ( SFG_Window * )fgStructure.Windows.First;
1050 window = ( SFG_Window * )window->Node.Next )
1051 if ( ! ( window->IsMenu ) )
1055 fgState.ExecState = GLUT_EXEC_STATE_STOP;
1058 if( fgState.IdleCallback )
1059 fgState.IdleCallback( );
1061 fghSleepForEvents( );
1066 * When this loop terminates, destroy the display, state and structure
1067 * of a freeglut session, so that another glutInit() call can happen
1069 * Save the "ActionOnWindowClose" because "fgDeinitialize" resets it.
1071 action = fgState.ActionOnWindowClose;
1073 if( action == GLUT_ACTION_EXIT )
1078 * Leaves the freeglut processing loop.
1080 void FGAPIENTRY glutLeaveMainLoop( void )
1082 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLeaveMainLoop" );
1083 fgState.ExecState = GLUT_EXEC_STATE_STOP ;
1087 #if TARGET_HOST_WIN32 || TARGET_HOST_WINCE
1089 * Determine a GLUT modifer mask based on MS-WINDOWS system info.
1091 static int fghGetWin32Modifiers (void)
1094 ( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
1095 ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
1096 ( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
1097 ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
1098 ( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
1099 ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
1103 * The window procedure for handling Win32 events
1105 LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
1112 FREEGLUT_INTERNAL_ERROR_EXIT_IF_NOT_INITIALISED ( "Event Handler" ) ;
1114 window = fgWindowByHandle( hWnd );
1116 if ( ( window == NULL ) && ( uMsg != WM_CREATE ) )
1117 return DefWindowProc( hWnd, uMsg, wParam, lParam );
1119 /* printf ( "Window %3d message <%04x> %12d %12d\n", window?window->ID:0,
1120 uMsg, wParam, lParam ); */
1124 /* The window structure is passed as the creation structure paramter... */
1125 window = (SFG_Window *) (((LPCREATESTRUCT) lParam)->lpCreateParams);
1126 FREEGLUT_INTERNAL_ERROR_EXIT ( ( window != NULL ), "Cannot create window",
1129 window->Window.Handle = hWnd;
1130 window->Window.Device = GetDC( hWnd );
1131 if( window->IsMenu )
1133 unsigned int current_DisplayMode = fgState.DisplayMode;
1134 fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH;
1135 #if !TARGET_HOST_WINCE
1136 fgSetupPixelFormat( window, GL_FALSE, PFD_MAIN_PLANE );
1138 fgState.DisplayMode = current_DisplayMode;
1140 if( fgStructure.MenuContext )
1141 wglMakeCurrent( window->Window.Device,
1142 fgStructure.MenuContext->Context
1146 fgStructure.MenuContext =
1147 (SFG_MenuContext *)malloc( sizeof(SFG_MenuContext) );
1148 fgStructure.MenuContext->Context =
1149 wglCreateContext( window->Window.Device );
1152 /* window->Window.Context = wglGetCurrentContext (); */
1153 window->Window.Context = wglCreateContext( window->Window.Device );
1157 #if !TARGET_HOST_WINCE
1158 fgSetupPixelFormat( window, GL_FALSE, PFD_MAIN_PLANE );
1161 if( ! fgState.UseCurrentContext )
1162 window->Window.Context =
1163 wglCreateContext( window->Window.Device );
1166 window->Window.Context = wglGetCurrentContext( );
1167 if( ! window->Window.Context )
1168 window->Window.Context =
1169 wglCreateContext( window->Window.Device );
1173 window->State.NeedToResize = GL_TRUE;
1174 window->State.Width = fgState.Size.X;
1175 window->State.Height = fgState.Size.Y;
1177 ReleaseDC( window->Window.Handle, window->Window.Device );
1179 #if TARGET_HOST_WINCE
1180 /* Take over button handling */
1182 HINSTANCE dxDllLib=LoadLibrary(_T("gx.dll"));
1185 GXGetDefaultKeys_=(GXGETDEFAULTKEYS)GetProcAddress(dxDllLib, _T("?GXGetDefaultKeys@@YA?AUGXKeyList@@H@Z"));
1186 GXOpenInput_=(GXOPENINPUT)GetProcAddress(dxDllLib, _T("?GXOpenInput@@YAHXZ"));
1191 if(GXGetDefaultKeys_)
1192 gxKeyList = (*GXGetDefaultKeys_)(GX_LANDSCAPEKEYS);
1195 #endif /* TARGET_HOST_WINCE */
1200 * If the window is visible, then it is the user manually resizing it.
1201 * If it is not, then it is the system sending us a dummy resize with
1202 * zero dimensions on a "glutIconifyWindow" call.
1204 if( window->State.Visible )
1206 window->State.NeedToResize = GL_TRUE;
1207 #if TARGET_HOST_WINCE
1208 window->State.Width = HIWORD(lParam);
1209 window->State.Height = LOWORD(lParam);
1211 window->State.Width = LOWORD(lParam);
1212 window->State.Height = HIWORD(lParam);
1213 #endif /* TARGET_HOST_WINCE */
1219 /* printf("WM_SETFOCUS: %p\n", window ); */
1220 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1224 if (LOWORD(wParam) != WA_INACTIVE)
1226 /* printf("WM_ACTIVATE: fgSetCursor( %p, %d)\n", window,
1227 window->State.Cursor ); */
1228 fgSetCursor( window, window->State.Cursor );
1231 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1236 /* printf ( "Cursor event %x %x %x %x\n", window, window->State.Cursor, lParam, wParam ) ; */
1237 if( LOWORD( lParam ) == HTCLIENT )
1238 fgSetCursor ( window, window->State.Cursor ) ;
1240 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1244 window->State.Visible = GL_TRUE;
1245 window->State.Redisplay = GL_TRUE;
1249 /* Turn on the visibility in case it was turned off somehow */
1250 window->State.Visible = GL_TRUE;
1251 BeginPaint( hWnd, &ps );
1252 fghRedrawWindow( window );
1253 EndPaint( hWnd, &ps );
1257 fgDestroyWindow ( window );
1258 if ( fgState.ActionOnWindowClose != GLUT_ACTION_CONTINUE_EXECUTION )
1264 * The window already got destroyed, so don't bother with it.
1270 #if TARGET_HOST_WINCE
1271 window->State.MouseX = 320-HIWORD( lParam );
1272 window->State.MouseY = LOWORD( lParam );
1274 window->State.MouseX = LOWORD( lParam );
1275 window->State.MouseY = HIWORD( lParam );
1276 #endif /* TARGET_HOST_WINCE */
1277 /* Restrict to [-32768, 32767] to match X11 behaviour */
1278 /* See comment in "freeglut_developer" mailing list 10/4/04 */
1279 if ( window->State.MouseX > 32767 ) window->State.MouseX -= 65536;
1280 if ( window->State.MouseY > 32767 ) window->State.MouseY -= 65536;
1282 if ( window->ActiveMenu )
1284 window->State.Redisplay = GL_TRUE;
1285 fgSetWindow ( window->ActiveMenu->ParentWindow );
1289 fgState.Modifiers = fghGetWin32Modifiers( );
1291 if( ( wParam & MK_LBUTTON ) ||
1292 ( wParam & MK_MBUTTON ) ||
1293 ( wParam & MK_RBUTTON ) )
1294 INVOKE_WCB( *window, Motion, ( window->State.MouseX,
1295 window->State.MouseY ) );
1297 INVOKE_WCB( *window, Passive, ( window->State.MouseX,
1298 window->State.MouseY ) );
1300 fgState.Modifiers = 0xffffffff;
1304 case WM_LBUTTONDOWN:
1305 case WM_MBUTTONDOWN:
1306 case WM_RBUTTONDOWN:
1311 GLboolean pressed = GL_TRUE;
1314 #if TARGET_HOST_WINCE
1315 window->State.MouseX = 320-HIWORD( lParam );
1316 window->State.MouseY = LOWORD( lParam );
1318 window->State.MouseX = LOWORD( lParam );
1319 window->State.MouseY = HIWORD( lParam );
1320 #endif /* TARGET_HOST_WINCE */
1322 /* Restrict to [-32768, 32767] to match X11 behaviour */
1323 /* See comment in "freeglut_developer" mailing list 10/4/04 */
1324 if ( window->State.MouseX > 32767 ) window->State.MouseX -= 65536;
1325 if ( window->State.MouseY > 32767 ) window->State.MouseY -= 65536;
1329 case WM_LBUTTONDOWN:
1331 button = GLUT_LEFT_BUTTON;
1333 case WM_MBUTTONDOWN:
1335 button = GLUT_MIDDLE_BUTTON;
1337 case WM_RBUTTONDOWN:
1339 button = GLUT_RIGHT_BUTTON;
1343 button = GLUT_LEFT_BUTTON;
1347 button = GLUT_MIDDLE_BUTTON;
1351 button = GLUT_RIGHT_BUTTON;
1359 #if !TARGET_HOST_WINCE
1360 if( GetSystemMetrics( SM_SWAPBUTTON ) )
1362 if( button == GLUT_LEFT_BUTTON )
1363 button = GLUT_RIGHT_BUTTON;
1365 if( button == GLUT_RIGHT_BUTTON )
1366 button = GLUT_LEFT_BUTTON;
1368 #endif /* !TARGET_HOST_WINCE */
1371 return DefWindowProc( hWnd, uMsg, lParam, wParam );
1374 * Do not execute the application's mouse callback if a menu
1375 * is hooked to this button. In that case an appropriate
1376 * private call should be generated.
1378 if( fgCheckActiveMenu( window, button, pressed,
1379 window->State.MouseX, window->State.MouseY ) )
1382 /* Set capture so that the window captures all the mouse messages */
1384 * XXX - Multiple button support: Under X11, the mouse is not released
1385 * XXX - from the window until all buttons have been released, even if the
1386 * XXX - user presses a button in another window. This will take more
1387 * XXX - code changes than I am up to at the moment (10/5/04). The present
1388 * XXX - is a 90 percent solution.
1390 if ( pressed == GL_TRUE )
1391 SetCapture ( window->Window.Handle ) ;
1395 if( ! FETCH_WCB( *window, Mouse ) )
1398 fgSetWindow( window );
1399 fgState.Modifiers = fghGetWin32Modifiers( );
1404 pressed ? GLUT_DOWN : GLUT_UP,
1405 window->State.MouseX,
1406 window->State.MouseY
1410 fgState.Modifiers = 0xffffffff;
1415 /* Should be WM_MOUSEWHEEL but my compiler doesn't recognize it */
1418 * XXX THIS IS SPECULATIVE -- John Fay, 10/2/03
1419 * XXX Should use WHEEL_DELTA instead of 120
1421 int wheel_number = LOWORD( wParam );
1422 short ticks = ( short )HIWORD( wParam ) / 120;
1432 * The mouse cursor has moved. Remember the new mouse cursor's position
1434 /* window->State.MouseX = LOWORD( lParam ); */
1435 /* Need to adjust by window position, */
1436 /* window->State.MouseY = HIWORD( lParam ); */
1437 /* change "lParam" to other parameter */
1439 if( ! FETCH_WCB( *window, MouseWheel ) &&
1440 ! FETCH_WCB( *window, Mouse ) )
1443 fgSetWindow( window );
1444 fgState.Modifiers = fghGetWin32Modifiers( );
1447 if( FETCH_WCB( *window, MouseWheel ) )
1448 INVOKE_WCB( *window, MouseWheel,
1451 window->State.MouseX,
1452 window->State.MouseY
1455 else /* No mouse wheel, call the mouse button callback twice */
1458 * XXX The below assumes that you have no more than 3 mouse
1459 * XXX buttons. Sorry.
1461 int button = wheel_number*2 + 4;
1464 INVOKE_WCB( *window, Mouse,
1465 ( button, GLUT_DOWN,
1466 window->State.MouseX, window->State.MouseY )
1468 INVOKE_WCB( *window, Mouse,
1470 window->State.MouseX, window->State.MouseX )
1474 fgState.Modifiers = 0xffffffff;
1484 if( ( fgState.KeyRepeat==GLUT_KEY_REPEAT_OFF || window->State.IgnoreKeyRepeat==GL_TRUE ) && (HIWORD(lParam) & KF_REPEAT) )
1488 * Remember the current modifiers state. This is done here in order
1489 * to make sure the VK_DELETE keyboard callback is executed properly.
1491 fgState.Modifiers = fghGetWin32Modifiers( );
1493 GetCursorPos( &mouse_pos );
1494 ScreenToClient( window->Window.Handle, &mouse_pos );
1496 window->State.MouseX = mouse_pos.x;
1497 window->State.MouseY = mouse_pos.y;
1499 /* Convert the Win32 keystroke codes to GLUTtish way */
1500 # define KEY(a,b) case a: keypress = b; break;
1504 KEY( VK_F1, GLUT_KEY_F1 );
1505 KEY( VK_F2, GLUT_KEY_F2 );
1506 KEY( VK_F3, GLUT_KEY_F3 );
1507 KEY( VK_F4, GLUT_KEY_F4 );
1508 KEY( VK_F5, GLUT_KEY_F5 );
1509 KEY( VK_F6, GLUT_KEY_F6 );
1510 KEY( VK_F7, GLUT_KEY_F7 );
1511 KEY( VK_F8, GLUT_KEY_F8 );
1512 KEY( VK_F9, GLUT_KEY_F9 );
1513 KEY( VK_F10, GLUT_KEY_F10 );
1514 KEY( VK_F11, GLUT_KEY_F11 );
1515 KEY( VK_F12, GLUT_KEY_F12 );
1516 KEY( VK_PRIOR, GLUT_KEY_PAGE_UP );
1517 KEY( VK_NEXT, GLUT_KEY_PAGE_DOWN );
1518 KEY( VK_HOME, GLUT_KEY_HOME );
1519 KEY( VK_END, GLUT_KEY_END );
1520 KEY( VK_LEFT, GLUT_KEY_LEFT );
1521 KEY( VK_UP, GLUT_KEY_UP );
1522 KEY( VK_RIGHT, GLUT_KEY_RIGHT );
1523 KEY( VK_DOWN, GLUT_KEY_DOWN );
1524 KEY( VK_INSERT, GLUT_KEY_INSERT );
1527 /* The delete key should be treated as an ASCII keypress: */
1528 INVOKE_WCB( *window, Keyboard,
1529 ( 127, window->State.MouseX, window->State.MouseY )
1533 #if TARGET_HOST_WINCE
1534 if(!(lParam & 0x40000000)) /* Prevent auto-repeat */
1536 if(wParam==(unsigned)gxKeyList.vkRight)
1537 keypress = GLUT_KEY_RIGHT;
1538 else if(wParam==(unsigned)gxKeyList.vkLeft)
1539 keypress = GLUT_KEY_LEFT;
1540 else if(wParam==(unsigned)gxKeyList.vkUp)
1541 keypress = GLUT_KEY_UP;
1542 else if(wParam==(unsigned)gxKeyList.vkDown)
1543 keypress = GLUT_KEY_DOWN;
1544 else if(wParam==(unsigned)gxKeyList.vkA)
1545 keypress = GLUT_KEY_F1;
1546 else if(wParam==(unsigned)gxKeyList.vkB)
1547 keypress = GLUT_KEY_F2;
1548 else if(wParam==(unsigned)gxKeyList.vkC)
1549 keypress = GLUT_KEY_F3;
1550 else if(wParam==(unsigned)gxKeyList.vkStart)
1551 keypress = GLUT_KEY_F4;
1555 if( keypress != -1 )
1556 INVOKE_WCB( *window, Special,
1558 window->State.MouseX, window->State.MouseY )
1561 fgState.Modifiers = 0xffffffff;
1572 * Remember the current modifiers state. This is done here in order
1573 * to make sure the VK_DELETE keyboard callback is executed properly.
1575 fgState.Modifiers = fghGetWin32Modifiers( );
1577 GetCursorPos( &mouse_pos );
1578 ScreenToClient( window->Window.Handle, &mouse_pos );
1580 window->State.MouseX = mouse_pos.x;
1581 window->State.MouseY = mouse_pos.y;
1584 * Convert the Win32 keystroke codes to GLUTtish way.
1585 * "KEY(a,b)" was defined under "WM_KEYDOWN"
1590 KEY( VK_F1, GLUT_KEY_F1 );
1591 KEY( VK_F2, GLUT_KEY_F2 );
1592 KEY( VK_F3, GLUT_KEY_F3 );
1593 KEY( VK_F4, GLUT_KEY_F4 );
1594 KEY( VK_F5, GLUT_KEY_F5 );
1595 KEY( VK_F6, GLUT_KEY_F6 );
1596 KEY( VK_F7, GLUT_KEY_F7 );
1597 KEY( VK_F8, GLUT_KEY_F8 );
1598 KEY( VK_F9, GLUT_KEY_F9 );
1599 KEY( VK_F10, GLUT_KEY_F10 );
1600 KEY( VK_F11, GLUT_KEY_F11 );
1601 KEY( VK_F12, GLUT_KEY_F12 );
1602 KEY( VK_PRIOR, GLUT_KEY_PAGE_UP );
1603 KEY( VK_NEXT, GLUT_KEY_PAGE_DOWN );
1604 KEY( VK_HOME, GLUT_KEY_HOME );
1605 KEY( VK_END, GLUT_KEY_END );
1606 KEY( VK_LEFT, GLUT_KEY_LEFT );
1607 KEY( VK_UP, GLUT_KEY_UP );
1608 KEY( VK_RIGHT, GLUT_KEY_RIGHT );
1609 KEY( VK_DOWN, GLUT_KEY_DOWN );
1610 KEY( VK_INSERT, GLUT_KEY_INSERT );
1613 /* The delete key should be treated as an ASCII keypress: */
1614 INVOKE_WCB( *window, KeyboardUp,
1615 ( 127, window->State.MouseX, window->State.MouseY )
1621 #if !TARGET_HOST_WINCE
1625 GetKeyboardState( state );
1627 if( ToAscii( wParam, 0, state, code, 0 ) == 1 )
1630 INVOKE_WCB( *window, KeyboardUp,
1632 window->State.MouseX, window->State.MouseY )
1634 #endif /* !TARGET_HOST_WINCE */
1638 if( keypress != -1 )
1639 INVOKE_WCB( *window, SpecialUp,
1641 window->State.MouseX, window->State.MouseY )
1644 fgState.Modifiers = 0xffffffff;
1651 if( (fgState.KeyRepeat==GLUT_KEY_REPEAT_OFF || window->State.IgnoreKeyRepeat==GL_TRUE) && (HIWORD(lParam) & KF_REPEAT) )
1654 fgState.Modifiers = fghGetWin32Modifiers( );
1655 INVOKE_WCB( *window, Keyboard,
1657 window->State.MouseX, window->State.MouseY )
1659 fgState.Modifiers = 0xffffffff;
1663 case WM_CAPTURECHANGED:
1664 /* User has finished resizing the window, force a redraw */
1665 INVOKE_WCB( *window, Display, ( ) );
1667 /*lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ); */
1670 /* Other messages that I have seen and which are not handled already */
1671 case WM_SETTEXT: /* 0x000c */
1672 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1673 /* Pass it on to "DefWindowProc" to set the window text */
1676 case WM_GETTEXT: /* 0x000d */
1677 /* Ideally we would copy the title of the window into "lParam" */
1678 /* strncpy ( (char *)lParam, "Window Title", wParam );
1679 lRet = ( wParam > 12 ) ? 12 : wParam; */
1680 /* the number of characters copied */
1681 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1684 case WM_GETTEXTLENGTH: /* 0x000e */
1685 /* Ideally we would get the length of the title of the window */
1687 /* the number of characters in "Window Title\0" (see above) */
1690 case WM_ERASEBKGND: /* 0x0014 */
1691 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1694 #if !TARGET_HOST_WINCE
1695 case WM_SYNCPAINT: /* 0x0088 */
1696 /* Another window has moved, need to update this one */
1697 window->State.Redisplay = GL_TRUE;
1698 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1699 /* Help screen says this message must be passed to "DefWindowProc" */
1702 case WM_NCPAINT: /* 0x0085 */
1703 /* Need to update the border of this window */
1704 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1705 /* Pass it on to "DefWindowProc" to repaint a standard border */
1708 case WM_SYSCOMMAND : /* 0x0112 */
1711 * We have received a system command message. Try to act on it.
1712 * The commands are passed in through the "wParam" parameter:
1713 * The least significant digit seems to be which edge of the window
1714 * is being used for a resize event:
1718 * Congratulations and thanks to Richard Rauch for figuring this out..
1720 switch ( wParam & 0xfff0 )
1729 /* User has clicked on the "-" to minimize the window */
1730 /* Turn off the visibility */
1731 window->State.Visible = GL_FALSE ;
1738 case SC_NEXTWINDOW :
1741 case SC_PREVWINDOW :
1745 /* Followed very closely by a WM_CLOSE message */
1769 case SC_SCREENSAVE :
1777 fgWarning( "Unknown wParam type 0x%x", wParam );
1782 #endif /* !TARGET_HOST_WINCE */
1784 /* We need to pass the message on to the operating system as well */
1785 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1789 /* Handle unhandled messages */
1790 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1798 /*** END OF FILE ***/