4 * The windows message processing methods.
\r
6 * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
\r
7 * Written by Pawel W. Olszta, <olszta@sourceforge.net>
\r
8 * Creation date: Fri Dec 3 1999
\r
10 * Permission is hereby granted, free of charge, to any person obtaining a
\r
11 * copy of this software and associated documentation files (the "Software"),
\r
12 * to deal in the Software without restriction, including without limitation
\r
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
\r
14 * and/or sell copies of the Software, and to permit persons to whom the
\r
15 * Software is furnished to do so, subject to the following conditions:
\r
17 * The above copyright notice and this permission notice shall be included
\r
18 * in all copies or substantial portions of the Software.
\r
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
\r
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
\r
23 * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
24 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
28 #include <GL/freeglut.h>
\r
29 #include "freeglut_internal.h"
\r
34 #ifdef HAVE_VFPRINTF
\r
35 # define VFPRINTF(s,f,a) vfprintf((s),(f),(a))
\r
36 #elif defined(HAVE__DOPRNT)
\r
37 # define VFPRINTF(s,f,a) _doprnt((f),(a),(s))
\r
39 # define VFPRINTF(s,f,a)
\r
44 typedef struct GXDisplayProperties GXDisplayProperties;
\r
45 typedef struct GXKeyList GXKeyList;
\r
48 typedef struct GXKeyList (*GXGETDEFAULTKEYS)(int);
\r
49 typedef int (*GXOPENINPUT)();
\r
51 GXGETDEFAULTKEYS GXGetDefaultKeys_ = NULL;
\r
52 GXOPENINPUT GXOpenInput_ = NULL;
\r
54 struct GXKeyList gxKeyList;
\r
56 #endif /* _WIN32_WCE */
\r
59 * Try to get the maximum value allowed for ints, falling back to the minimum
\r
60 * guaranteed by ISO C99 if there is no suitable header.
\r
62 #ifdef HAVE_LIMITS_H
\r
63 # include <limits.h>
\r
66 # define INT_MAX 32767
\r
70 # define MIN(a,b) (((a)<(b)) ? (a) : (b))
\r
73 extern void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height );
\r
74 extern void fgPlatformDisplayWindow ( SFG_Window *window );
\r
75 extern void fgPlatformSleepForEvents( long msec );
\r
76 extern void fgPlatformProcessSingleEvent ( void );
\r
77 extern void fgPlatformMainLoopPreliminaryWork ( void );
\r
81 * TODO BEFORE THE STABLE RELEASE:
\r
83 * There are some issues concerning window redrawing under X11, and maybe
\r
84 * some events are not handled. The Win32 version lacks some more features,
\r
85 * but seems acceptable for not demanding purposes.
\r
87 * Need to investigate why the X11 version breaks out with an error when
\r
88 * closing a window (using the window manager, not glutDestroyWindow)...
\r
91 /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
\r
94 * Handle a window configuration change. When no reshape
\r
95 * callback is hooked, the viewport size is updated to
\r
96 * match the new window size.
\r
98 #if TARGET_HOST_POSIX_X11
\r
99 static void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height )
\r
101 XResizeWindow( fgDisplay.Display, window->Window.Handle,
\r
103 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
\r
107 static void fghReshapeWindow ( SFG_Window *window, int width, int height )
\r
109 SFG_Window *current_window = fgStructure.CurrentWindow;
\r
111 freeglut_return_if_fail( window != NULL );
\r
113 fgPlatformReshapeWindow ( window, width, height );
\r
115 if( FETCH_WCB( *window, Reshape ) )
\r
116 INVOKE_WCB( *window, Reshape, ( width, height ) );
\r
119 fgSetWindow( window );
\r
120 glViewport( 0, 0, width, height );
\r
124 * Force a window redraw. In Windows at least this is only a partial
\r
125 * solution: if the window is increasing in size in either dimension,
\r
126 * the already-drawn part does not get drawn again and things look funny.
\r
127 * But without this we get this bad behaviour whenever we resize the
\r
130 window->State.Redisplay = GL_TRUE;
\r
132 if( window->IsMenu )
\r
133 fgSetWindow( current_window );
\r
137 * Calls a window's redraw method. This is used when
\r
138 * a redraw is forced by the incoming window messages.
\r
140 void fghRedrawWindow ( SFG_Window *window )
\r
142 SFG_Window *current_window = fgStructure.CurrentWindow;
\r
144 freeglut_return_if_fail( window );
\r
145 freeglut_return_if_fail( FETCH_WCB ( *window, Display ) );
\r
147 window->State.Redisplay = GL_FALSE;
\r
149 freeglut_return_if_fail( window->State.Visible );
\r
151 fgSetWindow( window );
\r
153 if( window->State.NeedToResize )
\r
157 window->State.Width,
\r
158 window->State.Height
\r
161 window->State.NeedToResize = GL_FALSE;
\r
164 INVOKE_WCB( *window, Display, ( ) );
\r
166 fgSetWindow( current_window );
\r
170 * A static helper function to execute display callback for a window
\r
172 #if TARGET_HOST_POSIX_X11
\r
173 static void fgPlatformDisplayWindow ( SFG_Window *window )
\r
175 fghRedrawWindow ( window ) ;
\r
179 static void fghcbDisplayWindow( SFG_Window *window,
\r
180 SFG_Enumerator *enumerator )
\r
182 if( window->State.Redisplay &&
\r
183 window->State.Visible )
\r
185 window->State.Redisplay = GL_FALSE;
\r
186 fgPlatformDisplayWindow ( window );
\r
189 fgEnumSubWindows( window, fghcbDisplayWindow, enumerator );
\r
193 * Make all windows perform a display call
\r
195 static void fghDisplayAll( void )
\r
197 SFG_Enumerator enumerator;
\r
199 enumerator.found = GL_FALSE;
\r
200 enumerator.data = NULL;
\r
202 fgEnumWindows( fghcbDisplayWindow, &enumerator );
\r
206 * Window enumerator callback to check for the joystick polling code
\r
208 static void fghcbCheckJoystickPolls( SFG_Window *window,
\r
209 SFG_Enumerator *enumerator )
\r
211 long int checkTime = fgElapsedTime( );
\r
213 if( window->State.JoystickLastPoll + window->State.JoystickPollRate <=
\r
216 #if !defined(_WIN32_WCE)
\r
217 fgJoystickPollWindow( window );
\r
218 #endif /* !defined(_WIN32_WCE) */
\r
219 window->State.JoystickLastPoll = checkTime;
\r
222 fgEnumSubWindows( window, fghcbCheckJoystickPolls, enumerator );
\r
226 * Check all windows for joystick polling
\r
228 static void fghCheckJoystickPolls( void )
\r
230 SFG_Enumerator enumerator;
\r
232 enumerator.found = GL_FALSE;
\r
233 enumerator.data = NULL;
\r
235 fgEnumWindows( fghcbCheckJoystickPolls, &enumerator );
\r
239 * Check the global timers
\r
241 static void fghCheckTimers( void )
\r
243 long checkTime = fgElapsedTime( );
\r
245 while( fgState.Timers.First )
\r
247 SFG_Timer *timer = fgState.Timers.First;
\r
249 if( timer->TriggerTime > checkTime )
\r
252 fgListRemove( &fgState.Timers, &timer->Node );
\r
253 fgListAppend( &fgState.FreeTimers, &timer->Node );
\r
255 timer->Callback( timer->ID );
\r
260 /* Platform-dependent time in milliseconds, as an unsigned 32-bit integer.
\r
261 * This value wraps every 49.7 days, but integer overflows cancel
\r
262 * when subtracting an initial start time, unless the total time exceeds
\r
263 * 32-bit, where the GLUT API return value is also overflowed.
\r
265 unsigned long fgSystemTime(void) {
\r
266 #if TARGET_HOST_SOLARIS || HAVE_GETTIMEOFDAY
\r
267 struct timeval now;
\r
268 gettimeofday( &now, NULL );
\r
269 return now.tv_usec/1000 + now.tv_sec*1000;
\r
270 #elif TARGET_HOST_MS_WINDOWS
\r
271 # if defined(_WIN32_WCE)
\r
272 return GetTickCount();
\r
274 return timeGetTime();
\r
282 long fgElapsedTime( void )
\r
284 return (long) (fgSystemTime() - fgState.Time);
\r
290 void fgError( const char *fmt, ... )
\r
294 if (fgState.ErrorFunc) {
\r
296 va_start( ap, fmt );
\r
298 /* call user set error handler here */
\r
299 fgState.ErrorFunc(fmt, ap);
\r
305 va_start( ap, fmt );
\r
307 fprintf( stderr, "freeglut ");
\r
308 if( fgState.ProgramName )
\r
309 fprintf( stderr, "(%s): ", fgState.ProgramName );
\r
310 VFPRINTF( stderr, fmt, ap );
\r
311 fprintf( stderr, "\n" );
\r
315 if ( fgState.Initialised )
\r
322 void fgWarning( const char *fmt, ... )
\r
326 if (fgState.WarningFunc) {
\r
328 va_start( ap, fmt );
\r
330 /* call user set warning handler here */
\r
331 fgState.WarningFunc(fmt, ap);
\r
337 va_start( ap, fmt );
\r
339 fprintf( stderr, "freeglut ");
\r
340 if( fgState.ProgramName )
\r
341 fprintf( stderr, "(%s): ", fgState.ProgramName );
\r
342 VFPRINTF( stderr, fmt, ap );
\r
343 fprintf( stderr, "\n" );
\r
351 * Indicates whether Joystick events are being used by ANY window.
\r
353 * The current mechanism is to walk all of the windows and ask if
\r
354 * there is a joystick callback. We have a short-circuit early
\r
355 * return if we find any joystick handler registered.
\r
357 * The real way to do this is to make use of the glutTimer() API
\r
358 * to more cleanly re-implement the joystick API. Then, this code
\r
359 * and all other "joystick timer" code can be yanked.
\r
362 static void fghCheckJoystickCallback( SFG_Window* w, SFG_Enumerator* e)
\r
364 if( FETCH_WCB( *w, Joystick ) )
\r
366 e->found = GL_TRUE;
\r
369 fgEnumSubWindows( w, fghCheckJoystickCallback, e );
\r
371 static int fghHaveJoystick( void )
\r
373 SFG_Enumerator enumerator;
\r
375 enumerator.found = GL_FALSE;
\r
376 enumerator.data = NULL;
\r
377 fgEnumWindows( fghCheckJoystickCallback, &enumerator );
\r
378 return !!enumerator.data;
\r
380 static void fghHavePendingRedisplaysCallback( SFG_Window* w, SFG_Enumerator* e)
\r
382 if( w->State.Redisplay && w->State.Visible )
\r
384 e->found = GL_TRUE;
\r
387 fgEnumSubWindows( w, fghHavePendingRedisplaysCallback, e );
\r
389 static int fghHavePendingRedisplays (void)
\r
391 SFG_Enumerator enumerator;
\r
393 enumerator.found = GL_FALSE;
\r
394 enumerator.data = NULL;
\r
395 fgEnumWindows( fghHavePendingRedisplaysCallback, &enumerator );
\r
396 return !!enumerator.data;
\r
399 * Returns the number of GLUT ticks (milliseconds) till the next timer event.
\r
401 static long fghNextTimer( void )
\r
403 long ret = INT_MAX;
\r
404 SFG_Timer *timer = fgState.Timers.First;
\r
407 ret = timer->TriggerTime - fgElapsedTime();
\r
414 * Does the magic required to relinquish the CPU until something interesting
\r
418 #if TARGET_HOST_POSIX_X11
\r
419 static void fgPlatformSleepForEvents( long msec )
\r
422 * Possibly due to aggressive use of XFlush() and friends,
\r
423 * it is possible to have our socket drained but still have
\r
424 * unprocessed events. (Or, this may just be normal with
\r
425 * X, anyway?) We do non-trivial processing of X events
\r
426 * after the event-reading loop, in any case, so we
\r
427 * need to allow that we may have an empty socket but non-
\r
428 * empty event queue.
\r
430 if( ! XPending( fgDisplay.Display ) )
\r
435 struct timeval wait;
\r
437 socket = ConnectionNumber( fgDisplay.Display );
\r
439 FD_SET( socket, &fdset );
\r
440 wait.tv_sec = msec / 1000;
\r
441 wait.tv_usec = (msec % 1000) * 1000;
\r
442 err = select( socket+1, &fdset, NULL, NULL, &wait );
\r
444 #ifdef HAVE_ERRNO_H
\r
445 if( ( -1 == err ) && ( errno != EINTR ) )
\r
446 fgWarning ( "freeglut select() error: %d", errno );
\r
452 static void fghSleepForEvents( void )
\r
456 if( fgState.IdleCallback || fghHavePendingRedisplays( ) )
\r
459 msec = fghNextTimer( );
\r
460 /* XXX Use GLUT timers for joysticks... */
\r
461 /* XXX Dumb; forces granularity to .01sec */
\r
462 if( fghHaveJoystick( ) && ( msec > 10 ) )
\r
465 fgPlatformSleepForEvents ( msec );
\r
468 #if TARGET_HOST_POSIX_X11
\r
470 * Returns GLUT modifier mask for the state field of an X11 event.
\r
472 int fgPlatformGetModifiers( int state )
\r
476 if( state & ( ShiftMask | LockMask ) )
\r
477 ret |= GLUT_ACTIVE_SHIFT;
\r
478 if( state & ControlMask )
\r
479 ret |= GLUT_ACTIVE_CTRL;
\r
480 if( state & Mod1Mask )
\r
481 ret |= GLUT_ACTIVE_ALT;
\r
488 static const char* fghTypeToString( int type )
\r
491 case KeyPress: return "KeyPress";
\r
492 case KeyRelease: return "KeyRelease";
\r
493 case ButtonPress: return "ButtonPress";
\r
494 case ButtonRelease: return "ButtonRelease";
\r
495 case MotionNotify: return "MotionNotify";
\r
496 case EnterNotify: return "EnterNotify";
\r
497 case LeaveNotify: return "LeaveNotify";
\r
498 case FocusIn: return "FocusIn";
\r
499 case FocusOut: return "FocusOut";
\r
500 case KeymapNotify: return "KeymapNotify";
\r
501 case Expose: return "Expose";
\r
502 case GraphicsExpose: return "GraphicsExpose";
\r
503 case NoExpose: return "NoExpose";
\r
504 case VisibilityNotify: return "VisibilityNotify";
\r
505 case CreateNotify: return "CreateNotify";
\r
506 case DestroyNotify: return "DestroyNotify";
\r
507 case UnmapNotify: return "UnmapNotify";
\r
508 case MapNotify: return "MapNotify";
\r
509 case MapRequest: return "MapRequest";
\r
510 case ReparentNotify: return "ReparentNotify";
\r
511 case ConfigureNotify: return "ConfigureNotify";
\r
512 case ConfigureRequest: return "ConfigureRequest";
\r
513 case GravityNotify: return "GravityNotify";
\r
514 case ResizeRequest: return "ResizeRequest";
\r
515 case CirculateNotify: return "CirculateNotify";
\r
516 case CirculateRequest: return "CirculateRequest";
\r
517 case PropertyNotify: return "PropertyNotify";
\r
518 case SelectionClear: return "SelectionClear";
\r
519 case SelectionRequest: return "SelectionRequest";
\r
520 case SelectionNotify: return "SelectionNotify";
\r
521 case ColormapNotify: return "ColormapNotify";
\r
522 case ClientMessage: return "ClientMessage";
\r
523 case MappingNotify: return "MappingNotify";
\r
524 default: return "UNKNOWN";
\r
528 static const char* fghBoolToString( Bool b )
\r
530 return b == False ? "False" : "True";
\r
533 static const char* fghNotifyHintToString( char is_hint )
\r
535 switch( is_hint ) {
\r
536 case NotifyNormal: return "NotifyNormal";
\r
537 case NotifyHint: return "NotifyHint";
\r
538 default: return "UNKNOWN";
\r
542 static const char* fghNotifyModeToString( int mode )
\r
545 case NotifyNormal: return "NotifyNormal";
\r
546 case NotifyGrab: return "NotifyGrab";
\r
547 case NotifyUngrab: return "NotifyUngrab";
\r
548 case NotifyWhileGrabbed: return "NotifyWhileGrabbed";
\r
549 default: return "UNKNOWN";
\r
553 static const char* fghNotifyDetailToString( int detail )
\r
556 case NotifyAncestor: return "NotifyAncestor";
\r
557 case NotifyVirtual: return "NotifyVirtual";
\r
558 case NotifyInferior: return "NotifyInferior";
\r
559 case NotifyNonlinear: return "NotifyNonlinear";
\r
560 case NotifyNonlinearVirtual: return "NotifyNonlinearVirtual";
\r
561 case NotifyPointer: return "NotifyPointer";
\r
562 case NotifyPointerRoot: return "NotifyPointerRoot";
\r
563 case NotifyDetailNone: return "NotifyDetailNone";
\r
564 default: return "UNKNOWN";
\r
568 static const char* fghVisibilityToString( int state ) {
\r
570 case VisibilityUnobscured: return "VisibilityUnobscured";
\r
571 case VisibilityPartiallyObscured: return "VisibilityPartiallyObscured";
\r
572 case VisibilityFullyObscured: return "VisibilityFullyObscured";
\r
573 default: return "UNKNOWN";
\r
577 static const char* fghConfigureDetailToString( int detail )
\r
580 case Above: return "Above";
\r
581 case Below: return "Below";
\r
582 case TopIf: return "TopIf";
\r
583 case BottomIf: return "BottomIf";
\r
584 case Opposite: return "Opposite";
\r
585 default: return "UNKNOWN";
\r
589 static const char* fghPlaceToString( int place )
\r
592 case PlaceOnTop: return "PlaceOnTop";
\r
593 case PlaceOnBottom: return "PlaceOnBottom";
\r
594 default: return "UNKNOWN";
\r
598 static const char* fghMappingRequestToString( int request )
\r
600 switch( request ) {
\r
601 case MappingModifier: return "MappingModifier";
\r
602 case MappingKeyboard: return "MappingKeyboard";
\r
603 case MappingPointer: return "MappingPointer";
\r
604 default: return "UNKNOWN";
\r
608 static const char* fghPropertyStateToString( int state )
\r
611 case PropertyNewValue: return "PropertyNewValue";
\r
612 case PropertyDelete: return "PropertyDelete";
\r
613 default: return "UNKNOWN";
\r
617 static const char* fghColormapStateToString( int state )
\r
620 case ColormapUninstalled: return "ColormapUninstalled";
\r
621 case ColormapInstalled: return "ColormapInstalled";
\r
622 default: return "UNKNOWN";
\r
626 static void fghPrintEvent( XEvent *event )
\r
628 switch( event->type ) {
\r
632 XKeyEvent *e = &event->xkey;
\r
633 fgWarning( "%s: window=0x%x, root=0x%x, subwindow=0x%x, time=%lu, "
\r
634 "(x,y)=(%d,%d), (x_root,y_root)=(%d,%d), state=0x%x, "
\r
635 "keycode=%u, same_screen=%s", fghTypeToString( e->type ),
\r
636 e->window, e->root, e->subwindow, (unsigned long)e->time,
\r
637 e->x, e->y, e->x_root, e->y_root, e->state, e->keycode,
\r
638 fghBoolToString( e->same_screen ) );
\r
643 case ButtonRelease: {
\r
644 XButtonEvent *e = &event->xbutton;
\r
645 fgWarning( "%s: window=0x%x, root=0x%x, subwindow=0x%x, time=%lu, "
\r
646 "(x,y)=(%d,%d), (x_root,y_root)=(%d,%d), state=0x%x, "
\r
647 "button=%u, same_screen=%d", fghTypeToString( e->type ),
\r
648 e->window, e->root, e->subwindow, (unsigned long)e->time,
\r
649 e->x, e->y, e->x_root, e->y_root, e->state, e->button,
\r
650 fghBoolToString( e->same_screen ) );
\r
654 case MotionNotify: {
\r
655 XMotionEvent *e = &event->xmotion;
\r
656 fgWarning( "%s: window=0x%x, root=0x%x, subwindow=0x%x, time=%lu, "
\r
657 "(x,y)=(%d,%d), (x_root,y_root)=(%d,%d), state=0x%x, "
\r
658 "is_hint=%s, same_screen=%d", fghTypeToString( e->type ),
\r
659 e->window, e->root, e->subwindow, (unsigned long)e->time,
\r
660 e->x, e->y, e->x_root, e->y_root, e->state,
\r
661 fghNotifyHintToString( e->is_hint ),
\r
662 fghBoolToString( e->same_screen ) );
\r
667 case LeaveNotify: {
\r
668 XCrossingEvent *e = &event->xcrossing;
\r
669 fgWarning( "%s: window=0x%x, root=0x%x, subwindow=0x%x, time=%lu, "
\r
670 "(x,y)=(%d,%d), mode=%s, detail=%s, same_screen=%d, "
\r
671 "focus=%d, state=0x%x", fghTypeToString( e->type ),
\r
672 e->window, e->root, e->subwindow, (unsigned long)e->time,
\r
673 e->x, e->y, fghNotifyModeToString( e->mode ),
\r
674 fghNotifyDetailToString( e->detail ), (int)e->same_screen,
\r
675 (int)e->focus, e->state );
\r
681 XFocusChangeEvent *e = &event->xfocus;
\r
682 fgWarning( "%s: window=0x%x, mode=%s, detail=%s",
\r
683 fghTypeToString( e->type ), e->window,
\r
684 fghNotifyModeToString( e->mode ),
\r
685 fghNotifyDetailToString( e->detail ) );
\r
689 case KeymapNotify: {
\r
690 XKeymapEvent *e = &event->xkeymap;
\r
691 char buf[32 * 2 + 1];
\r
693 for ( i = 0; i < 32; i++ ) {
\r
694 snprintf( &buf[ i * 2 ], sizeof( buf ) - i * 2,
\r
695 "%02x", e->key_vector[ i ] );
\r
698 fgWarning( "%s: window=0x%x, %s", fghTypeToString( e->type ), e->window,
\r
704 XExposeEvent *e = &event->xexpose;
\r
705 fgWarning( "%s: window=0x%x, (x,y)=(%d,%d), (width,height)=(%d,%d), "
\r
706 "count=%d", fghTypeToString( e->type ), e->window, e->x,
\r
707 e->y, e->width, e->height, e->count );
\r
711 case GraphicsExpose: {
\r
712 XGraphicsExposeEvent *e = &event->xgraphicsexpose;
\r
713 fgWarning( "%s: drawable=0x%x, (x,y)=(%d,%d), (width,height)=(%d,%d), "
\r
714 "count=%d, (major_code,minor_code)=(%d,%d)",
\r
715 fghTypeToString( e->type ), e->drawable, e->x, e->y,
\r
716 e->width, e->height, e->count, e->major_code,
\r
722 XNoExposeEvent *e = &event->xnoexpose;
\r
723 fgWarning( "%s: drawable=0x%x, (major_code,minor_code)=(%d,%d)",
\r
724 fghTypeToString( e->type ), e->drawable, e->major_code,
\r
729 case VisibilityNotify: {
\r
730 XVisibilityEvent *e = &event->xvisibility;
\r
731 fgWarning( "%s: window=0x%x, state=%s", fghTypeToString( e->type ),
\r
732 e->window, fghVisibilityToString( e->state) );
\r
736 case CreateNotify: {
\r
737 XCreateWindowEvent *e = &event->xcreatewindow;
\r
738 fgWarning( "%s: (x,y)=(%d,%d), (width,height)=(%d,%d), border_width=%d, "
\r
739 "window=0x%x, override_redirect=%s",
\r
740 fghTypeToString( e->type ), e->x, e->y, e->width, e->height,
\r
741 e->border_width, e->window,
\r
742 fghBoolToString( e->override_redirect ) );
\r
746 case DestroyNotify: {
\r
747 XDestroyWindowEvent *e = &event->xdestroywindow;
\r
748 fgWarning( "%s: event=0x%x, window=0x%x",
\r
749 fghTypeToString( e->type ), e->event, e->window );
\r
753 case UnmapNotify: {
\r
754 XUnmapEvent *e = &event->xunmap;
\r
755 fgWarning( "%s: event=0x%x, window=0x%x, from_configure=%s",
\r
756 fghTypeToString( e->type ), e->event, e->window,
\r
757 fghBoolToString( e->from_configure ) );
\r
762 XMapEvent *e = &event->xmap;
\r
763 fgWarning( "%s: event=0x%x, window=0x%x, override_redirect=%s",
\r
764 fghTypeToString( e->type ), e->event, e->window,
\r
765 fghBoolToString( e->override_redirect ) );
\r
770 XMapRequestEvent *e = &event->xmaprequest;
\r
771 fgWarning( "%s: parent=0x%x, window=0x%x",
\r
772 fghTypeToString( event->type ), e->parent, e->window );
\r
776 case ReparentNotify: {
\r
777 XReparentEvent *e = &event->xreparent;
\r
778 fgWarning( "%s: event=0x%x, window=0x%x, parent=0x%x, (x,y)=(%d,%d), "
\r
779 "override_redirect=%s", fghTypeToString( e->type ),
\r
780 e->event, e->window, e->parent, e->x, e->y,
\r
781 fghBoolToString( e->override_redirect ) );
\r
785 case ConfigureNotify: {
\r
786 XConfigureEvent *e = &event->xconfigure;
\r
787 fgWarning( "%s: event=0x%x, window=0x%x, (x,y)=(%d,%d), "
\r
788 "(width,height)=(%d,%d), border_width=%d, above=0x%x, "
\r
789 "override_redirect=%s", fghTypeToString( e->type ), e->event,
\r
790 e->window, e->x, e->y, e->width, e->height, e->border_width,
\r
791 e->above, fghBoolToString( e->override_redirect ) );
\r
795 case ConfigureRequest: {
\r
796 XConfigureRequestEvent *e = &event->xconfigurerequest;
\r
797 fgWarning( "%s: parent=0x%x, window=0x%x, (x,y)=(%d,%d), "
\r
798 "(width,height)=(%d,%d), border_width=%d, above=0x%x, "
\r
799 "detail=%s, value_mask=%lx", fghTypeToString( e->type ),
\r
800 e->parent, e->window, e->x, e->y, e->width, e->height,
\r
801 e->border_width, e->above,
\r
802 fghConfigureDetailToString( e->detail ), e->value_mask );
\r
806 case GravityNotify: {
\r
807 XGravityEvent *e = &event->xgravity;
\r
808 fgWarning( "%s: event=0x%x, window=0x%x, (x,y)=(%d,%d)",
\r
809 fghTypeToString( e->type ), e->event, e->window, e->x, e->y );
\r
813 case ResizeRequest: {
\r
814 XResizeRequestEvent *e = &event->xresizerequest;
\r
815 fgWarning( "%s: window=0x%x, (width,height)=(%d,%d)",
\r
816 fghTypeToString( e->type ), e->window, e->width, e->height );
\r
820 case CirculateNotify: {
\r
821 XCirculateEvent *e = &event->xcirculate;
\r
822 fgWarning( "%s: event=0x%x, window=0x%x, place=%s",
\r
823 fghTypeToString( e->type ), e->event, e->window,
\r
824 fghPlaceToString( e->place ) );
\r
828 case CirculateRequest: {
\r
829 XCirculateRequestEvent *e = &event->xcirculaterequest;
\r
830 fgWarning( "%s: parent=0x%x, window=0x%x, place=%s",
\r
831 fghTypeToString( e->type ), e->parent, e->window,
\r
832 fghPlaceToString( e->place ) );
\r
836 case PropertyNotify: {
\r
837 XPropertyEvent *e = &event->xproperty;
\r
838 fgWarning( "%s: window=0x%x, atom=%lu, time=%lu, state=%s",
\r
839 fghTypeToString( e->type ), e->window,
\r
840 (unsigned long)e->atom, (unsigned long)e->time,
\r
841 fghPropertyStateToString( e->state ) );
\r
845 case SelectionClear: {
\r
846 XSelectionClearEvent *e = &event->xselectionclear;
\r
847 fgWarning( "%s: window=0x%x, selection=%lu, time=%lu",
\r
848 fghTypeToString( e->type ), e->window,
\r
849 (unsigned long)e->selection, (unsigned long)e->time );
\r
853 case SelectionRequest: {
\r
854 XSelectionRequestEvent *e = &event->xselectionrequest;
\r
855 fgWarning( "%s: owner=0x%x, requestor=0x%x, selection=0x%x, "
\r
856 "target=0x%x, property=%lu, time=%lu",
\r
857 fghTypeToString( e->type ), e->owner, e->requestor,
\r
858 (unsigned long)e->selection, (unsigned long)e->target,
\r
859 (unsigned long)e->property, (unsigned long)e->time );
\r
863 case SelectionNotify: {
\r
864 XSelectionEvent *e = &event->xselection;
\r
865 fgWarning( "%s: requestor=0x%x, selection=0x%x, target=0x%x, "
\r
866 "property=%lu, time=%lu", fghTypeToString( e->type ),
\r
867 e->requestor, (unsigned long)e->selection,
\r
868 (unsigned long)e->target, (unsigned long)e->property,
\r
869 (unsigned long)e->time );
\r
873 case ColormapNotify: {
\r
874 XColormapEvent *e = &event->xcolormap;
\r
875 fgWarning( "%s: window=0x%x, colormap=%lu, new=%s, state=%s",
\r
876 fghTypeToString( e->type ), e->window,
\r
877 (unsigned long)e->colormap, fghBoolToString( e->new ),
\r
878 fghColormapStateToString( e->state ) );
\r
882 case ClientMessage: {
\r
883 XClientMessageEvent *e = &event->xclient;
\r
886 char* end = buf + sizeof( buf );
\r
888 switch( e->format ) {
\r
890 for ( i = 0; i < 20; i++, p += 3 ) {
\r
891 snprintf( p, end - p, " %02x", e->data.b[ i ] );
\r
895 for ( i = 0; i < 10; i++, p += 5 ) {
\r
896 snprintf( p, end - p, " %04x", e->data.s[ i ] );
\r
900 for ( i = 0; i < 5; i++, p += 9 ) {
\r
901 snprintf( p, end - p, " %08lx", e->data.l[ i ] );
\r
906 fgWarning( "%s: window=0x%x, message_type=%lu, format=%d, data=(%s )",
\r
907 fghTypeToString( e->type ), e->window,
\r
908 (unsigned long)e->message_type, e->format, buf );
\r
912 case MappingNotify: {
\r
913 XMappingEvent *e = &event->xmapping;
\r
914 fgWarning( "%s: window=0x%x, request=%s, first_keycode=%d, count=%d",
\r
915 fghTypeToString( e->type ), e->window,
\r
916 fghMappingRequestToString( e->request ), e->first_keycode,
\r
922 fgWarning( "%s", fghTypeToString( event->type ) );
\r
929 void fgPlatformProcessSingleEvent ( void )
\r
931 SFG_Window* window;
\r
934 /* This code was repeated constantly, so here it goes into a definition: */
\r
935 #define GETWINDOW(a) \
\r
936 window = fgWindowByHandle( event.a.window ); \
\r
937 if( window == NULL ) \
\r
940 #define GETMOUSE(a) \
\r
941 window->State.MouseX = event.a.x; \
\r
942 window->State.MouseY = event.a.y;
\r
944 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoopEvent" );
\r
946 while( XPending( fgDisplay.Display ) )
\r
948 XNextEvent( fgDisplay.Display, &event );
\r
950 fghPrintEvent( &event );
\r
953 switch( event.type )
\r
955 case ClientMessage:
\r
956 if(fgIsSpaceballXEvent(&event)) {
\r
957 fgSpaceballHandleXEvent(&event);
\r
960 /* Destroy the window when the WM_DELETE_WINDOW message arrives */
\r
961 if( (Atom) event.xclient.data.l[ 0 ] == fgDisplay.DeleteWindow )
\r
963 GETWINDOW( xclient );
\r
965 fgDestroyWindow ( window );
\r
967 if( fgState.ActionOnWindowClose == GLUT_ACTION_EXIT )
\r
972 else if( fgState.ActionOnWindowClose == GLUT_ACTION_GLUTMAINLOOP_RETURNS )
\r
973 fgState.ExecState = GLUT_EXEC_STATE_STOP;
\r
980 * CreateNotify causes a configure-event so that sub-windows are
\r
981 * handled compatibly with GLUT. Otherwise, your sub-windows
\r
982 * (in freeglut only) will not get an initial reshape event,
\r
983 * which can break things.
\r
985 * GLUT presumably does this because it generally tries to treat
\r
986 * sub-windows the same as windows.
\r
989 case ConfigureNotify:
\r
992 if( event.type == CreateNotify ) {
\r
993 GETWINDOW( xcreatewindow );
\r
994 width = event.xcreatewindow.width;
\r
995 height = event.xcreatewindow.height;
\r
997 GETWINDOW( xconfigure );
\r
998 width = event.xconfigure.width;
\r
999 height = event.xconfigure.height;
\r
1002 if( ( width != window->State.OldWidth ) ||
\r
1003 ( height != window->State.OldHeight ) )
\r
1005 SFG_Window *current_window = fgStructure.CurrentWindow;
\r
1007 window->State.OldWidth = width;
\r
1008 window->State.OldHeight = height;
\r
1009 if( FETCH_WCB( *window, Reshape ) )
\r
1010 INVOKE_WCB( *window, Reshape, ( width, height ) );
\r
1013 fgSetWindow( window );
\r
1014 glViewport( 0, 0, width, height );
\r
1016 glutPostRedisplay( );
\r
1017 if( window->IsMenu )
\r
1018 fgSetWindow( current_window );
\r
1023 case DestroyNotify:
\r
1025 * This is sent to confirm the XDestroyWindow call.
\r
1027 * XXX WHY is this commented out? Should we re-enable it?
\r
1029 /* fgAddToWindowDestroyList ( window ); */
\r
1034 * We are too dumb to process partial exposes...
\r
1036 * XXX Well, we could do it. However, it seems to only
\r
1037 * XXX be potentially useful for single-buffered (since
\r
1038 * XXX double-buffered does not respect viewport when we
\r
1039 * XXX do a buffer-swap).
\r
1042 if( event.xexpose.count == 0 )
\r
1044 GETWINDOW( xexpose );
\r
1045 window->State.Redisplay = GL_TRUE;
\r
1053 /* We get this when iconifying a window. */
\r
1054 GETWINDOW( xunmap );
\r
1055 INVOKE_WCB( *window, WindowStatus, ( GLUT_HIDDEN ) );
\r
1056 window->State.Visible = GL_FALSE;
\r
1059 case MappingNotify:
\r
1061 * Have the client's keyboard knowledge updated (xlib.ps,
\r
1062 * page 206, says that's a good thing to do)
\r
1064 XRefreshKeyboardMapping( (XMappingEvent *) &event );
\r
1067 case VisibilityNotify:
\r
1070 * Sending this event, the X server can notify us that the window
\r
1071 * has just acquired one of the three possible visibility states:
\r
1072 * VisibilityUnobscured, VisibilityPartiallyObscured or
\r
1073 * VisibilityFullyObscured. Note that we DO NOT receive a
\r
1074 * VisibilityNotify event when iconifying a window, we only get an
\r
1075 * UnmapNotify then.
\r
1077 GETWINDOW( xvisibility );
\r
1078 switch( event.xvisibility.state )
\r
1080 case VisibilityUnobscured:
\r
1081 INVOKE_WCB( *window, WindowStatus, ( GLUT_FULLY_RETAINED ) );
\r
1082 window->State.Visible = GL_TRUE;
\r
1085 case VisibilityPartiallyObscured:
\r
1086 INVOKE_WCB( *window, WindowStatus,
\r
1087 ( GLUT_PARTIALLY_RETAINED ) );
\r
1088 window->State.Visible = GL_TRUE;
\r
1091 case VisibilityFullyObscured:
\r
1092 INVOKE_WCB( *window, WindowStatus, ( GLUT_FULLY_COVERED ) );
\r
1093 window->State.Visible = GL_FALSE;
\r
1097 fgWarning( "Unknown X visibility state: %d",
\r
1098 event.xvisibility.state );
\r
1106 GETWINDOW( xcrossing );
\r
1107 GETMOUSE( xcrossing );
\r
1108 if( ( event.type == LeaveNotify ) && window->IsMenu &&
\r
1109 window->ActiveMenu && window->ActiveMenu->IsActive )
\r
1110 fgUpdateMenuHighlight( window->ActiveMenu );
\r
1112 INVOKE_WCB( *window, Entry, ( ( EnterNotify == event.type ) ?
\r
1117 case MotionNotify:
\r
1119 GETWINDOW( xmotion );
\r
1120 GETMOUSE( xmotion );
\r
1122 if( window->ActiveMenu )
\r
1124 if( window == window->ActiveMenu->ParentWindow )
\r
1126 window->ActiveMenu->Window->State.MouseX =
\r
1127 event.xmotion.x_root - window->ActiveMenu->X;
\r
1128 window->ActiveMenu->Window->State.MouseY =
\r
1129 event.xmotion.y_root - window->ActiveMenu->Y;
\r
1132 fgUpdateMenuHighlight( window->ActiveMenu );
\r
1138 * XXX For more than 5 buttons, just check {event.xmotion.state},
\r
1139 * XXX rather than a host of bit-masks? Or maybe we need to
\r
1140 * XXX track ButtonPress/ButtonRelease events in our own
\r
1143 fgState.Modifiers = fgPlatformGetModifiers( event.xmotion.state );
\r
1144 if ( event.xmotion.state & ( Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask ) ) {
\r
1145 INVOKE_WCB( *window, Motion, ( event.xmotion.x,
\r
1146 event.xmotion.y ) );
\r
1148 INVOKE_WCB( *window, Passive, ( event.xmotion.x,
\r
1149 event.xmotion.y ) );
\r
1151 fgState.Modifiers = INVALID_MODIFIERS;
\r
1155 case ButtonRelease:
\r
1158 GLboolean pressed = GL_TRUE;
\r
1161 if( event.type == ButtonRelease )
\r
1162 pressed = GL_FALSE ;
\r
1165 * A mouse button has been pressed or released. Traditionally,
\r
1166 * break if the window was found within the freeglut structures.
\r
1168 GETWINDOW( xbutton );
\r
1169 GETMOUSE( xbutton );
\r
1172 * An X button (at least in XFree86) is numbered from 1.
\r
1173 * A GLUT button is numbered from 0.
\r
1174 * Old GLUT passed through buttons other than just the first
\r
1175 * three, though it only gave symbolic names and official
\r
1176 * support to the first three.
\r
1178 button = event.xbutton.button - 1;
\r
1181 * Do not execute the application's mouse callback if a menu
\r
1182 * is hooked to this button. In that case an appropriate
\r
1183 * private call should be generated.
\r
1185 if( fgCheckActiveMenu( window, button, pressed,
\r
1186 event.xbutton.x_root, event.xbutton.y_root ) )
\r
1190 * Check if there is a mouse or mouse wheel callback hooked to the
\r
1193 if( ! FETCH_WCB( *window, Mouse ) &&
\r
1194 ! FETCH_WCB( *window, MouseWheel ) )
\r
1197 fgState.Modifiers = fgPlatformGetModifiers( event.xbutton.state );
\r
1199 /* Finally execute the mouse or mouse wheel callback */
\r
1200 if( ( button < glutDeviceGet ( GLUT_NUM_MOUSE_BUTTONS ) ) || ( ! FETCH_WCB( *window, MouseWheel ) ) )
\r
1201 INVOKE_WCB( *window, Mouse, ( button,
\r
1202 pressed ? GLUT_DOWN : GLUT_UP,
\r
1209 * Map 4 and 5 to wheel zero; EVEN to +1, ODD to -1
\r
1210 * " 6 and 7 " " one; ...
\r
1212 * XXX This *should* be behind some variables/macros,
\r
1213 * XXX since the order and numbering isn't certain
\r
1214 * XXX See XFree86 configuration docs (even back in the
\r
1215 * XXX 3.x days, and especially with 4.x).
\r
1217 * XXX Note that {button} has already been decremented
\r
1218 * XXX in mapping from X button numbering to GLUT.
\r
1220 * XXX Should add support for partial wheel turns as Windows does -- 5/27/11
\r
1222 int wheel_number = (button - glutDeviceGet ( GLUT_NUM_MOUSE_BUTTONS )) / 2;
\r
1223 int direction = -1;
\r
1228 INVOKE_WCB( *window, MouseWheel, ( wheel_number,
\r
1234 fgState.Modifiers = INVALID_MODIFIERS;
\r
1241 FGCBKeyboard keyboard_cb;
\r
1242 FGCBSpecial special_cb;
\r
1244 GETWINDOW( xkey );
\r
1247 /* Detect auto repeated keys, if configured globally or per-window */
\r
1249 if ( fgState.KeyRepeat==GLUT_KEY_REPEAT_OFF || window->State.IgnoreKeyRepeat==GL_TRUE )
\r
1251 if (event.type==KeyRelease)
\r
1254 * Look at X11 keystate to detect repeat mode.
\r
1255 * While X11 says the key is actually held down, we'll ignore KeyRelease/KeyPress pairs.
\r
1259 XQueryKeymap( fgDisplay.Display, keys ); /* Look at X11 keystate to detect repeat mode */
\r
1261 if ( event.xkey.keycode<256 ) /* XQueryKeymap is limited to 256 keycodes */
\r
1263 if ( keys[event.xkey.keycode>>3] & (1<<(event.xkey.keycode%8)) )
\r
1264 window->State.KeyRepeating = GL_TRUE;
\r
1266 window->State.KeyRepeating = GL_FALSE;
\r
1271 window->State.KeyRepeating = GL_FALSE;
\r
1273 /* Cease processing this event if it is auto repeated */
\r
1275 if (window->State.KeyRepeating)
\r
1277 if (event.type == KeyPress) window->State.KeyRepeating = GL_FALSE;
\r
1281 if( event.type == KeyPress )
\r
1283 keyboard_cb = (FGCBKeyboard)( FETCH_WCB( *window, Keyboard ));
\r
1284 special_cb = (FGCBSpecial) ( FETCH_WCB( *window, Special ));
\r
1288 keyboard_cb = (FGCBKeyboard)( FETCH_WCB( *window, KeyboardUp ));
\r
1289 special_cb = (FGCBSpecial) ( FETCH_WCB( *window, SpecialUp ));
\r
1292 /* Is there a keyboard/special callback hooked for this window? */
\r
1293 if( keyboard_cb || special_cb )
\r
1295 XComposeStatus composeStatus;
\r
1296 char asciiCode[ 32 ];
\r
1300 /* Check for the ASCII/KeySym codes associated with the event: */
\r
1301 len = XLookupString( &event.xkey, asciiCode, sizeof(asciiCode),
\r
1302 &keySym, &composeStatus
\r
1305 /* GLUT API tells us to have two separate callbacks... */
\r
1308 /* ...one for the ASCII translateable keypresses... */
\r
1311 fgSetWindow( window );
\r
1312 fgState.Modifiers = fgPlatformGetModifiers( event.xkey.state );
\r
1313 keyboard_cb( asciiCode[ 0 ],
\r
1314 event.xkey.x, event.xkey.y
\r
1316 fgState.Modifiers = INVALID_MODIFIERS;
\r
1324 * ...and one for all the others, which need to be
\r
1325 * translated to GLUT_KEY_Xs...
\r
1329 case XK_F1: special = GLUT_KEY_F1; break;
\r
1330 case XK_F2: special = GLUT_KEY_F2; break;
\r
1331 case XK_F3: special = GLUT_KEY_F3; break;
\r
1332 case XK_F4: special = GLUT_KEY_F4; break;
\r
1333 case XK_F5: special = GLUT_KEY_F5; break;
\r
1334 case XK_F6: special = GLUT_KEY_F6; break;
\r
1335 case XK_F7: special = GLUT_KEY_F7; break;
\r
1336 case XK_F8: special = GLUT_KEY_F8; break;
\r
1337 case XK_F9: special = GLUT_KEY_F9; break;
\r
1338 case XK_F10: special = GLUT_KEY_F10; break;
\r
1339 case XK_F11: special = GLUT_KEY_F11; break;
\r
1340 case XK_F12: special = GLUT_KEY_F12; break;
\r
1343 case XK_Left: special = GLUT_KEY_LEFT; break;
\r
1345 case XK_Right: special = GLUT_KEY_RIGHT; break;
\r
1347 case XK_Up: special = GLUT_KEY_UP; break;
\r
1349 case XK_Down: special = GLUT_KEY_DOWN; break;
\r
1352 case XK_Prior: special = GLUT_KEY_PAGE_UP; break;
\r
1354 case XK_Next: special = GLUT_KEY_PAGE_DOWN; break;
\r
1356 case XK_Home: special = GLUT_KEY_HOME; break;
\r
1358 case XK_End: special = GLUT_KEY_END; break;
\r
1359 case XK_KP_Insert:
\r
1360 case XK_Insert: special = GLUT_KEY_INSERT; break;
\r
1362 case XK_Num_Lock : special = GLUT_KEY_NUM_LOCK; break;
\r
1363 case XK_KP_Begin : special = GLUT_KEY_BEGIN; break;
\r
1364 case XK_KP_Delete: special = GLUT_KEY_DELETE; break;
\r
1366 case XK_Shift_L: special = GLUT_KEY_SHIFT_L; break;
\r
1367 case XK_Shift_R: special = GLUT_KEY_SHIFT_R; break;
\r
1368 case XK_Control_L: special = GLUT_KEY_CTRL_L; break;
\r
1369 case XK_Control_R: special = GLUT_KEY_CTRL_R; break;
\r
1370 case XK_Alt_L: special = GLUT_KEY_ALT_L; break;
\r
1371 case XK_Alt_R: special = GLUT_KEY_ALT_R; break;
\r
1375 * Execute the callback (if one has been specified),
\r
1376 * given that the special code seems to be valid...
\r
1378 if( special_cb && (special != -1) )
\r
1380 fgSetWindow( window );
\r
1381 fgState.Modifiers = fgPlatformGetModifiers( event.xkey.state );
\r
1382 special_cb( special, event.xkey.x, event.xkey.y );
\r
1383 fgState.Modifiers = INVALID_MODIFIERS;
\r
1390 case ReparentNotify:
\r
1391 break; /* XXX Should disable this event */
\r
1394 case GravityNotify:
\r
1398 /* enter handling of Extension Events here */
\r
1399 #ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
\r
1400 fgHandleExtensionEvents( &event );
\r
1408 static void fgPlatformMainLoopPreliminaryWork ( void )
\r
1413 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
\r
1416 * Executes a single iteration in the freeglut processing loop.
\r
1418 void FGAPIENTRY glutMainLoopEvent( void )
\r
1420 fgPlatformProcessSingleEvent ();
\r
1422 if( fgState.Timers.First )
\r
1423 fghCheckTimers( );
\r
1424 fghCheckJoystickPolls( );
\r
1427 fgCloseWindows( );
\r
1431 * Enters the freeglut processing loop.
\r
1432 * Stays until the "ExecState" changes to "GLUT_EXEC_STATE_STOP".
\r
1434 void FGAPIENTRY glutMainLoop( void )
\r
1438 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoop" );
\r
1440 fgPlatformMainLoopPreliminaryWork ();
\r
1442 fgState.ExecState = GLUT_EXEC_STATE_RUNNING ;
\r
1443 while( fgState.ExecState == GLUT_EXEC_STATE_RUNNING )
\r
1445 SFG_Window *window;
\r
1447 glutMainLoopEvent( );
\r
1449 * Step through the list of windows, seeing if there are any
\r
1450 * that are not menus
\r
1452 for( window = ( SFG_Window * )fgStructure.Windows.First;
\r
1454 window = ( SFG_Window * )window->Node.Next )
\r
1455 if ( ! ( window->IsMenu ) )
\r
1459 fgState.ExecState = GLUT_EXEC_STATE_STOP;
\r
1462 if( fgState.IdleCallback )
\r
1464 if( fgStructure.CurrentWindow &&
\r
1465 fgStructure.CurrentWindow->IsMenu )
\r
1467 fgSetWindow( window );
\r
1468 fgState.IdleCallback( );
\r
1471 fghSleepForEvents( );
\r
1476 * When this loop terminates, destroy the display, state and structure
\r
1477 * of a freeglut session, so that another glutInit() call can happen
\r
1479 * Save the "ActionOnWindowClose" because "fgDeinitialize" resets it.
\r
1481 action = fgState.ActionOnWindowClose;
\r
1482 fgDeinitialize( );
\r
1483 if( action == GLUT_ACTION_EXIT )
\r
1488 * Leaves the freeglut processing loop.
\r
1490 void FGAPIENTRY glutLeaveMainLoop( void )
\r
1492 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLeaveMainLoop" );
\r
1493 fgState.ExecState = GLUT_EXEC_STATE_STOP ;
\r
1498 /*** END OF FILE ***/
\r