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
74 typedef BOOL (WINAPI *pGetTouchInputInfo)(HTOUCHINPUT,UINT,PTOUCHINPUT,int);
\r
75 typedef BOOL (WINAPI *pCloseTouchInputHandle)(HTOUCHINPUT);
\r
76 static pGetTouchInputInfo fghGetTouchInputInfo = (pGetTouchInputInfo)0xDEADBEEF;
\r
77 static pCloseTouchInputHandle fghCloseTouchInputHandle = (pCloseTouchInputHandle)0xDEADBEEF;
\r
80 extern void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height );
\r
81 extern void fgPlatformDisplayWindow ( SFG_Window *window );
\r
82 extern void fgPlatformSleepForEvents( long msec );
\r
83 extern void fgPlatformProcessSingleEvent ( void );
\r
84 extern void fgPlatformMainLoopPreliminaryWork ( void );
\r
88 * TODO BEFORE THE STABLE RELEASE:
\r
90 * There are some issues concerning window redrawing under X11, and maybe
\r
91 * some events are not handled. The Win32 version lacks some more features,
\r
92 * but seems acceptable for not demanding purposes.
\r
94 * Need to investigate why the X11 version breaks out with an error when
\r
95 * closing a window (using the window manager, not glutDestroyWindow)...
\r
98 /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
\r
101 * Handle a window configuration change. When no reshape
\r
102 * callback is hooked, the viewport size is updated to
\r
103 * match the new window size.
\r
105 #if TARGET_HOST_POSIX_X11
\r
106 static void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height )
\r
108 XResizeWindow( fgDisplay.Display, window->Window.Handle,
\r
110 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
\r
114 static void fghReshapeWindow ( SFG_Window *window, int width, int height )
\r
116 SFG_Window *current_window = fgStructure.CurrentWindow;
\r
118 freeglut_return_if_fail( window != NULL );
\r
120 fgPlatformReshapeWindow ( window, width, height );
\r
122 if( FETCH_WCB( *window, Reshape ) )
\r
123 INVOKE_WCB( *window, Reshape, ( width, height ) );
\r
126 fgSetWindow( window );
\r
127 glViewport( 0, 0, width, height );
\r
131 * Force a window redraw. In Windows at least this is only a partial
\r
132 * solution: if the window is increasing in size in either dimension,
\r
133 * the already-drawn part does not get drawn again and things look funny.
\r
134 * But without this we get this bad behaviour whenever we resize the
\r
137 window->State.Redisplay = GL_TRUE;
\r
139 if( window->IsMenu )
\r
140 fgSetWindow( current_window );
\r
144 * Calls a window's redraw method. This is used when
\r
145 * a redraw is forced by the incoming window messages.
\r
147 void fghRedrawWindow ( SFG_Window *window )
\r
149 SFG_Window *current_window = fgStructure.CurrentWindow;
\r
151 freeglut_return_if_fail( window );
\r
152 freeglut_return_if_fail( FETCH_WCB ( *window, Display ) );
\r
154 window->State.Redisplay = GL_FALSE;
\r
156 freeglut_return_if_fail( window->State.Visible );
\r
158 fgSetWindow( window );
\r
160 if( window->State.NeedToResize )
\r
164 window->State.Width,
\r
165 window->State.Height
\r
168 window->State.NeedToResize = GL_FALSE;
\r
171 INVOKE_WCB( *window, Display, ( ) );
\r
173 fgSetWindow( current_window );
\r
177 * A static helper function to execute display callback for a window
\r
179 #if TARGET_HOST_POSIX_X11
\r
180 static void fgPlatformDisplayWindow ( SFG_Window *window )
\r
182 fghRedrawWindow ( window ) ;
\r
186 static void fghcbDisplayWindow( SFG_Window *window,
\r
187 SFG_Enumerator *enumerator )
\r
189 if( window->State.Redisplay &&
\r
190 window->State.Visible )
\r
192 window->State.Redisplay = GL_FALSE;
\r
193 fgPlatformDisplayWindow ( window );
\r
196 fgEnumSubWindows( window, fghcbDisplayWindow, enumerator );
\r
200 * Make all windows perform a display call
\r
202 static void fghDisplayAll( void )
\r
204 SFG_Enumerator enumerator;
\r
206 enumerator.found = GL_FALSE;
\r
207 enumerator.data = NULL;
\r
209 fgEnumWindows( fghcbDisplayWindow, &enumerator );
\r
213 * Window enumerator callback to check for the joystick polling code
\r
215 static void fghcbCheckJoystickPolls( SFG_Window *window,
\r
216 SFG_Enumerator *enumerator )
\r
218 long int checkTime = fgElapsedTime( );
\r
220 if( window->State.JoystickLastPoll + window->State.JoystickPollRate <=
\r
223 #if !defined(_WIN32_WCE)
\r
224 fgJoystickPollWindow( window );
\r
225 #endif /* !defined(_WIN32_WCE) */
\r
226 window->State.JoystickLastPoll = checkTime;
\r
229 fgEnumSubWindows( window, fghcbCheckJoystickPolls, enumerator );
\r
233 * Check all windows for joystick polling
\r
235 static void fghCheckJoystickPolls( void )
\r
237 SFG_Enumerator enumerator;
\r
239 enumerator.found = GL_FALSE;
\r
240 enumerator.data = NULL;
\r
242 fgEnumWindows( fghcbCheckJoystickPolls, &enumerator );
\r
246 * Check the global timers
\r
248 static void fghCheckTimers( void )
\r
250 long checkTime = fgElapsedTime( );
\r
252 while( fgState.Timers.First )
\r
254 SFG_Timer *timer = fgState.Timers.First;
\r
256 if( timer->TriggerTime > checkTime )
\r
259 fgListRemove( &fgState.Timers, &timer->Node );
\r
260 fgListAppend( &fgState.FreeTimers, &timer->Node );
\r
262 timer->Callback( timer->ID );
\r
267 /* Platform-dependent time in milliseconds, as an unsigned 32-bit integer.
\r
268 * This value wraps every 49.7 days, but integer overflows cancel
\r
269 * when subtracting an initial start time, unless the total time exceeds
\r
270 * 32-bit, where the GLUT API return value is also overflowed.
\r
272 unsigned long fgSystemTime(void) {
\r
273 #if TARGET_HOST_SOLARIS || HAVE_GETTIMEOFDAY
\r
274 struct timeval now;
\r
275 gettimeofday( &now, NULL );
\r
276 return now.tv_usec/1000 + now.tv_sec*1000;
\r
277 #elif TARGET_HOST_MS_WINDOWS
\r
278 # if defined(_WIN32_WCE)
\r
279 return GetTickCount();
\r
281 return timeGetTime();
\r
289 long fgElapsedTime( void )
\r
291 return (long) (fgSystemTime() - fgState.Time);
\r
297 void fgError( const char *fmt, ... )
\r
301 if (fgState.ErrorFunc) {
\r
303 va_start( ap, fmt );
\r
305 /* call user set error handler here */
\r
306 fgState.ErrorFunc(fmt, ap);
\r
312 va_start( ap, fmt );
\r
314 fprintf( stderr, "freeglut ");
\r
315 if( fgState.ProgramName )
\r
316 fprintf( stderr, "(%s): ", fgState.ProgramName );
\r
317 VFPRINTF( stderr, fmt, ap );
\r
318 fprintf( stderr, "\n" );
\r
322 if ( fgState.Initialised )
\r
329 void fgWarning( const char *fmt, ... )
\r
333 if (fgState.WarningFunc) {
\r
335 va_start( ap, fmt );
\r
337 /* call user set warning handler here */
\r
338 fgState.WarningFunc(fmt, ap);
\r
344 va_start( ap, fmt );
\r
346 fprintf( stderr, "freeglut ");
\r
347 if( fgState.ProgramName )
\r
348 fprintf( stderr, "(%s): ", fgState.ProgramName );
\r
349 VFPRINTF( stderr, fmt, ap );
\r
350 fprintf( stderr, "\n" );
\r
358 * Indicates whether Joystick events are being used by ANY window.
\r
360 * The current mechanism is to walk all of the windows and ask if
\r
361 * there is a joystick callback. We have a short-circuit early
\r
362 * return if we find any joystick handler registered.
\r
364 * The real way to do this is to make use of the glutTimer() API
\r
365 * to more cleanly re-implement the joystick API. Then, this code
\r
366 * and all other "joystick timer" code can be yanked.
\r
369 static void fghCheckJoystickCallback( SFG_Window* w, SFG_Enumerator* e)
\r
371 if( FETCH_WCB( *w, Joystick ) )
\r
373 e->found = GL_TRUE;
\r
376 fgEnumSubWindows( w, fghCheckJoystickCallback, e );
\r
378 static int fghHaveJoystick( void )
\r
380 SFG_Enumerator enumerator;
\r
382 enumerator.found = GL_FALSE;
\r
383 enumerator.data = NULL;
\r
384 fgEnumWindows( fghCheckJoystickCallback, &enumerator );
\r
385 return !!enumerator.data;
\r
387 static void fghHavePendingRedisplaysCallback( SFG_Window* w, SFG_Enumerator* e)
\r
389 if( w->State.Redisplay && w->State.Visible )
\r
391 e->found = GL_TRUE;
\r
394 fgEnumSubWindows( w, fghHavePendingRedisplaysCallback, e );
\r
396 static int fghHavePendingRedisplays (void)
\r
398 SFG_Enumerator enumerator;
\r
400 enumerator.found = GL_FALSE;
\r
401 enumerator.data = NULL;
\r
402 fgEnumWindows( fghHavePendingRedisplaysCallback, &enumerator );
\r
403 return !!enumerator.data;
\r
406 * Returns the number of GLUT ticks (milliseconds) till the next timer event.
\r
408 static long fghNextTimer( void )
\r
410 long ret = INT_MAX;
\r
411 SFG_Timer *timer = fgState.Timers.First;
\r
414 ret = timer->TriggerTime - fgElapsedTime();
\r
421 * Does the magic required to relinquish the CPU until something interesting
\r
425 #if TARGET_HOST_POSIX_X11
\r
426 static void fgPlatformSleepForEvents( long msec )
\r
429 * Possibly due to aggressive use of XFlush() and friends,
\r
430 * it is possible to have our socket drained but still have
\r
431 * unprocessed events. (Or, this may just be normal with
\r
432 * X, anyway?) We do non-trivial processing of X events
\r
433 * after the event-reading loop, in any case, so we
\r
434 * need to allow that we may have an empty socket but non-
\r
435 * empty event queue.
\r
437 if( ! XPending( fgDisplay.Display ) )
\r
442 struct timeval wait;
\r
444 socket = ConnectionNumber( fgDisplay.Display );
\r
446 FD_SET( socket, &fdset );
\r
447 wait.tv_sec = msec / 1000;
\r
448 wait.tv_usec = (msec % 1000) * 1000;
\r
449 err = select( socket+1, &fdset, NULL, NULL, &wait );
\r
451 #ifdef HAVE_ERRNO_H
\r
452 if( ( -1 == err ) && ( errno != EINTR ) )
\r
453 fgWarning ( "freeglut select() error: %d", errno );
\r
459 static void fghSleepForEvents( void )
\r
463 if( fgState.IdleCallback || fghHavePendingRedisplays( ) )
\r
466 msec = fghNextTimer( );
\r
467 /* XXX Use GLUT timers for joysticks... */
\r
468 /* XXX Dumb; forces granularity to .01sec */
\r
469 if( fghHaveJoystick( ) && ( msec > 10 ) )
\r
472 fgPlatformSleepForEvents ( msec );
\r
475 #if TARGET_HOST_POSIX_X11
\r
477 * Returns GLUT modifier mask for the state field of an X11 event.
\r
479 int fgPlatformGetModifiers( int state )
\r
483 if( state & ( ShiftMask | LockMask ) )
\r
484 ret |= GLUT_ACTIVE_SHIFT;
\r
485 if( state & ControlMask )
\r
486 ret |= GLUT_ACTIVE_CTRL;
\r
487 if( state & Mod1Mask )
\r
488 ret |= GLUT_ACTIVE_ALT;
\r
495 static const char* fghTypeToString( int type )
\r
498 case KeyPress: return "KeyPress";
\r
499 case KeyRelease: return "KeyRelease";
\r
500 case ButtonPress: return "ButtonPress";
\r
501 case ButtonRelease: return "ButtonRelease";
\r
502 case MotionNotify: return "MotionNotify";
\r
503 case EnterNotify: return "EnterNotify";
\r
504 case LeaveNotify: return "LeaveNotify";
\r
505 case FocusIn: return "FocusIn";
\r
506 case FocusOut: return "FocusOut";
\r
507 case KeymapNotify: return "KeymapNotify";
\r
508 case Expose: return "Expose";
\r
509 case GraphicsExpose: return "GraphicsExpose";
\r
510 case NoExpose: return "NoExpose";
\r
511 case VisibilityNotify: return "VisibilityNotify";
\r
512 case CreateNotify: return "CreateNotify";
\r
513 case DestroyNotify: return "DestroyNotify";
\r
514 case UnmapNotify: return "UnmapNotify";
\r
515 case MapNotify: return "MapNotify";
\r
516 case MapRequest: return "MapRequest";
\r
517 case ReparentNotify: return "ReparentNotify";
\r
518 case ConfigureNotify: return "ConfigureNotify";
\r
519 case ConfigureRequest: return "ConfigureRequest";
\r
520 case GravityNotify: return "GravityNotify";
\r
521 case ResizeRequest: return "ResizeRequest";
\r
522 case CirculateNotify: return "CirculateNotify";
\r
523 case CirculateRequest: return "CirculateRequest";
\r
524 case PropertyNotify: return "PropertyNotify";
\r
525 case SelectionClear: return "SelectionClear";
\r
526 case SelectionRequest: return "SelectionRequest";
\r
527 case SelectionNotify: return "SelectionNotify";
\r
528 case ColormapNotify: return "ColormapNotify";
\r
529 case ClientMessage: return "ClientMessage";
\r
530 case MappingNotify: return "MappingNotify";
\r
531 default: return "UNKNOWN";
\r
535 static const char* fghBoolToString( Bool b )
\r
537 return b == False ? "False" : "True";
\r
540 static const char* fghNotifyHintToString( char is_hint )
\r
542 switch( is_hint ) {
\r
543 case NotifyNormal: return "NotifyNormal";
\r
544 case NotifyHint: return "NotifyHint";
\r
545 default: return "UNKNOWN";
\r
549 static const char* fghNotifyModeToString( int mode )
\r
552 case NotifyNormal: return "NotifyNormal";
\r
553 case NotifyGrab: return "NotifyGrab";
\r
554 case NotifyUngrab: return "NotifyUngrab";
\r
555 case NotifyWhileGrabbed: return "NotifyWhileGrabbed";
\r
556 default: return "UNKNOWN";
\r
560 static const char* fghNotifyDetailToString( int detail )
\r
563 case NotifyAncestor: return "NotifyAncestor";
\r
564 case NotifyVirtual: return "NotifyVirtual";
\r
565 case NotifyInferior: return "NotifyInferior";
\r
566 case NotifyNonlinear: return "NotifyNonlinear";
\r
567 case NotifyNonlinearVirtual: return "NotifyNonlinearVirtual";
\r
568 case NotifyPointer: return "NotifyPointer";
\r
569 case NotifyPointerRoot: return "NotifyPointerRoot";
\r
570 case NotifyDetailNone: return "NotifyDetailNone";
\r
571 default: return "UNKNOWN";
\r
575 static const char* fghVisibilityToString( int state ) {
\r
577 case VisibilityUnobscured: return "VisibilityUnobscured";
\r
578 case VisibilityPartiallyObscured: return "VisibilityPartiallyObscured";
\r
579 case VisibilityFullyObscured: return "VisibilityFullyObscured";
\r
580 default: return "UNKNOWN";
\r
584 static const char* fghConfigureDetailToString( int detail )
\r
587 case Above: return "Above";
\r
588 case Below: return "Below";
\r
589 case TopIf: return "TopIf";
\r
590 case BottomIf: return "BottomIf";
\r
591 case Opposite: return "Opposite";
\r
592 default: return "UNKNOWN";
\r
596 static const char* fghPlaceToString( int place )
\r
599 case PlaceOnTop: return "PlaceOnTop";
\r
600 case PlaceOnBottom: return "PlaceOnBottom";
\r
601 default: return "UNKNOWN";
\r
605 static const char* fghMappingRequestToString( int request )
\r
607 switch( request ) {
\r
608 case MappingModifier: return "MappingModifier";
\r
609 case MappingKeyboard: return "MappingKeyboard";
\r
610 case MappingPointer: return "MappingPointer";
\r
611 default: return "UNKNOWN";
\r
615 static const char* fghPropertyStateToString( int state )
\r
618 case PropertyNewValue: return "PropertyNewValue";
\r
619 case PropertyDelete: return "PropertyDelete";
\r
620 default: return "UNKNOWN";
\r
624 static const char* fghColormapStateToString( int state )
\r
627 case ColormapUninstalled: return "ColormapUninstalled";
\r
628 case ColormapInstalled: return "ColormapInstalled";
\r
629 default: return "UNKNOWN";
\r
633 static void fghPrintEvent( XEvent *event )
\r
635 switch( event->type ) {
\r
639 XKeyEvent *e = &event->xkey;
\r
640 fgWarning( "%s: window=0x%x, root=0x%x, subwindow=0x%x, time=%lu, "
\r
641 "(x,y)=(%d,%d), (x_root,y_root)=(%d,%d), state=0x%x, "
\r
642 "keycode=%u, same_screen=%s", fghTypeToString( e->type ),
\r
643 e->window, e->root, e->subwindow, (unsigned long)e->time,
\r
644 e->x, e->y, e->x_root, e->y_root, e->state, e->keycode,
\r
645 fghBoolToString( e->same_screen ) );
\r
650 case ButtonRelease: {
\r
651 XButtonEvent *e = &event->xbutton;
\r
652 fgWarning( "%s: window=0x%x, root=0x%x, subwindow=0x%x, time=%lu, "
\r
653 "(x,y)=(%d,%d), (x_root,y_root)=(%d,%d), state=0x%x, "
\r
654 "button=%u, same_screen=%d", fghTypeToString( e->type ),
\r
655 e->window, e->root, e->subwindow, (unsigned long)e->time,
\r
656 e->x, e->y, e->x_root, e->y_root, e->state, e->button,
\r
657 fghBoolToString( e->same_screen ) );
\r
661 case MotionNotify: {
\r
662 XMotionEvent *e = &event->xmotion;
\r
663 fgWarning( "%s: window=0x%x, root=0x%x, subwindow=0x%x, time=%lu, "
\r
664 "(x,y)=(%d,%d), (x_root,y_root)=(%d,%d), state=0x%x, "
\r
665 "is_hint=%s, same_screen=%d", fghTypeToString( e->type ),
\r
666 e->window, e->root, e->subwindow, (unsigned long)e->time,
\r
667 e->x, e->y, e->x_root, e->y_root, e->state,
\r
668 fghNotifyHintToString( e->is_hint ),
\r
669 fghBoolToString( e->same_screen ) );
\r
674 case LeaveNotify: {
\r
675 XCrossingEvent *e = &event->xcrossing;
\r
676 fgWarning( "%s: window=0x%x, root=0x%x, subwindow=0x%x, time=%lu, "
\r
677 "(x,y)=(%d,%d), mode=%s, detail=%s, same_screen=%d, "
\r
678 "focus=%d, state=0x%x", fghTypeToString( e->type ),
\r
679 e->window, e->root, e->subwindow, (unsigned long)e->time,
\r
680 e->x, e->y, fghNotifyModeToString( e->mode ),
\r
681 fghNotifyDetailToString( e->detail ), (int)e->same_screen,
\r
682 (int)e->focus, e->state );
\r
688 XFocusChangeEvent *e = &event->xfocus;
\r
689 fgWarning( "%s: window=0x%x, mode=%s, detail=%s",
\r
690 fghTypeToString( e->type ), e->window,
\r
691 fghNotifyModeToString( e->mode ),
\r
692 fghNotifyDetailToString( e->detail ) );
\r
696 case KeymapNotify: {
\r
697 XKeymapEvent *e = &event->xkeymap;
\r
698 char buf[32 * 2 + 1];
\r
700 for ( i = 0; i < 32; i++ ) {
\r
701 snprintf( &buf[ i * 2 ], sizeof( buf ) - i * 2,
\r
702 "%02x", e->key_vector[ i ] );
\r
705 fgWarning( "%s: window=0x%x, %s", fghTypeToString( e->type ), e->window,
\r
711 XExposeEvent *e = &event->xexpose;
\r
712 fgWarning( "%s: window=0x%x, (x,y)=(%d,%d), (width,height)=(%d,%d), "
\r
713 "count=%d", fghTypeToString( e->type ), e->window, e->x,
\r
714 e->y, e->width, e->height, e->count );
\r
718 case GraphicsExpose: {
\r
719 XGraphicsExposeEvent *e = &event->xgraphicsexpose;
\r
720 fgWarning( "%s: drawable=0x%x, (x,y)=(%d,%d), (width,height)=(%d,%d), "
\r
721 "count=%d, (major_code,minor_code)=(%d,%d)",
\r
722 fghTypeToString( e->type ), e->drawable, e->x, e->y,
\r
723 e->width, e->height, e->count, e->major_code,
\r
729 XNoExposeEvent *e = &event->xnoexpose;
\r
730 fgWarning( "%s: drawable=0x%x, (major_code,minor_code)=(%d,%d)",
\r
731 fghTypeToString( e->type ), e->drawable, e->major_code,
\r
736 case VisibilityNotify: {
\r
737 XVisibilityEvent *e = &event->xvisibility;
\r
738 fgWarning( "%s: window=0x%x, state=%s", fghTypeToString( e->type ),
\r
739 e->window, fghVisibilityToString( e->state) );
\r
743 case CreateNotify: {
\r
744 XCreateWindowEvent *e = &event->xcreatewindow;
\r
745 fgWarning( "%s: (x,y)=(%d,%d), (width,height)=(%d,%d), border_width=%d, "
\r
746 "window=0x%x, override_redirect=%s",
\r
747 fghTypeToString( e->type ), e->x, e->y, e->width, e->height,
\r
748 e->border_width, e->window,
\r
749 fghBoolToString( e->override_redirect ) );
\r
753 case DestroyNotify: {
\r
754 XDestroyWindowEvent *e = &event->xdestroywindow;
\r
755 fgWarning( "%s: event=0x%x, window=0x%x",
\r
756 fghTypeToString( e->type ), e->event, e->window );
\r
760 case UnmapNotify: {
\r
761 XUnmapEvent *e = &event->xunmap;
\r
762 fgWarning( "%s: event=0x%x, window=0x%x, from_configure=%s",
\r
763 fghTypeToString( e->type ), e->event, e->window,
\r
764 fghBoolToString( e->from_configure ) );
\r
769 XMapEvent *e = &event->xmap;
\r
770 fgWarning( "%s: event=0x%x, window=0x%x, override_redirect=%s",
\r
771 fghTypeToString( e->type ), e->event, e->window,
\r
772 fghBoolToString( e->override_redirect ) );
\r
777 XMapRequestEvent *e = &event->xmaprequest;
\r
778 fgWarning( "%s: parent=0x%x, window=0x%x",
\r
779 fghTypeToString( event->type ), e->parent, e->window );
\r
783 case ReparentNotify: {
\r
784 XReparentEvent *e = &event->xreparent;
\r
785 fgWarning( "%s: event=0x%x, window=0x%x, parent=0x%x, (x,y)=(%d,%d), "
\r
786 "override_redirect=%s", fghTypeToString( e->type ),
\r
787 e->event, e->window, e->parent, e->x, e->y,
\r
788 fghBoolToString( e->override_redirect ) );
\r
792 case ConfigureNotify: {
\r
793 XConfigureEvent *e = &event->xconfigure;
\r
794 fgWarning( "%s: event=0x%x, window=0x%x, (x,y)=(%d,%d), "
\r
795 "(width,height)=(%d,%d), border_width=%d, above=0x%x, "
\r
796 "override_redirect=%s", fghTypeToString( e->type ), e->event,
\r
797 e->window, e->x, e->y, e->width, e->height, e->border_width,
\r
798 e->above, fghBoolToString( e->override_redirect ) );
\r
802 case ConfigureRequest: {
\r
803 XConfigureRequestEvent *e = &event->xconfigurerequest;
\r
804 fgWarning( "%s: parent=0x%x, window=0x%x, (x,y)=(%d,%d), "
\r
805 "(width,height)=(%d,%d), border_width=%d, above=0x%x, "
\r
806 "detail=%s, value_mask=%lx", fghTypeToString( e->type ),
\r
807 e->parent, e->window, e->x, e->y, e->width, e->height,
\r
808 e->border_width, e->above,
\r
809 fghConfigureDetailToString( e->detail ), e->value_mask );
\r
813 case GravityNotify: {
\r
814 XGravityEvent *e = &event->xgravity;
\r
815 fgWarning( "%s: event=0x%x, window=0x%x, (x,y)=(%d,%d)",
\r
816 fghTypeToString( e->type ), e->event, e->window, e->x, e->y );
\r
820 case ResizeRequest: {
\r
821 XResizeRequestEvent *e = &event->xresizerequest;
\r
822 fgWarning( "%s: window=0x%x, (width,height)=(%d,%d)",
\r
823 fghTypeToString( e->type ), e->window, e->width, e->height );
\r
827 case CirculateNotify: {
\r
828 XCirculateEvent *e = &event->xcirculate;
\r
829 fgWarning( "%s: event=0x%x, window=0x%x, place=%s",
\r
830 fghTypeToString( e->type ), e->event, e->window,
\r
831 fghPlaceToString( e->place ) );
\r
835 case CirculateRequest: {
\r
836 XCirculateRequestEvent *e = &event->xcirculaterequest;
\r
837 fgWarning( "%s: parent=0x%x, window=0x%x, place=%s",
\r
838 fghTypeToString( e->type ), e->parent, e->window,
\r
839 fghPlaceToString( e->place ) );
\r
843 case PropertyNotify: {
\r
844 XPropertyEvent *e = &event->xproperty;
\r
845 fgWarning( "%s: window=0x%x, atom=%lu, time=%lu, state=%s",
\r
846 fghTypeToString( e->type ), e->window,
\r
847 (unsigned long)e->atom, (unsigned long)e->time,
\r
848 fghPropertyStateToString( e->state ) );
\r
852 case SelectionClear: {
\r
853 XSelectionClearEvent *e = &event->xselectionclear;
\r
854 fgWarning( "%s: window=0x%x, selection=%lu, time=%lu",
\r
855 fghTypeToString( e->type ), e->window,
\r
856 (unsigned long)e->selection, (unsigned long)e->time );
\r
860 case SelectionRequest: {
\r
861 XSelectionRequestEvent *e = &event->xselectionrequest;
\r
862 fgWarning( "%s: owner=0x%x, requestor=0x%x, selection=0x%x, "
\r
863 "target=0x%x, property=%lu, time=%lu",
\r
864 fghTypeToString( e->type ), e->owner, e->requestor,
\r
865 (unsigned long)e->selection, (unsigned long)e->target,
\r
866 (unsigned long)e->property, (unsigned long)e->time );
\r
870 case SelectionNotify: {
\r
871 XSelectionEvent *e = &event->xselection;
\r
872 fgWarning( "%s: requestor=0x%x, selection=0x%x, target=0x%x, "
\r
873 "property=%lu, time=%lu", fghTypeToString( e->type ),
\r
874 e->requestor, (unsigned long)e->selection,
\r
875 (unsigned long)e->target, (unsigned long)e->property,
\r
876 (unsigned long)e->time );
\r
880 case ColormapNotify: {
\r
881 XColormapEvent *e = &event->xcolormap;
\r
882 fgWarning( "%s: window=0x%x, colormap=%lu, new=%s, state=%s",
\r
883 fghTypeToString( e->type ), e->window,
\r
884 (unsigned long)e->colormap, fghBoolToString( e->new ),
\r
885 fghColormapStateToString( e->state ) );
\r
889 case ClientMessage: {
\r
890 XClientMessageEvent *e = &event->xclient;
\r
893 char* end = buf + sizeof( buf );
\r
895 switch( e->format ) {
\r
897 for ( i = 0; i < 20; i++, p += 3 ) {
\r
898 snprintf( p, end - p, " %02x", e->data.b[ i ] );
\r
902 for ( i = 0; i < 10; i++, p += 5 ) {
\r
903 snprintf( p, end - p, " %04x", e->data.s[ i ] );
\r
907 for ( i = 0; i < 5; i++, p += 9 ) {
\r
908 snprintf( p, end - p, " %08lx", e->data.l[ i ] );
\r
913 fgWarning( "%s: window=0x%x, message_type=%lu, format=%d, data=(%s )",
\r
914 fghTypeToString( e->type ), e->window,
\r
915 (unsigned long)e->message_type, e->format, buf );
\r
919 case MappingNotify: {
\r
920 XMappingEvent *e = &event->xmapping;
\r
921 fgWarning( "%s: window=0x%x, request=%s, first_keycode=%d, count=%d",
\r
922 fghTypeToString( e->type ), e->window,
\r
923 fghMappingRequestToString( e->request ), e->first_keycode,
\r
929 fgWarning( "%s", fghTypeToString( event->type ) );
\r
936 void fgPlatformProcessSingleEvent ( void )
\r
938 SFG_Window* window;
\r
941 /* This code was repeated constantly, so here it goes into a definition: */
\r
942 #define GETWINDOW(a) \
\r
943 window = fgWindowByHandle( event.a.window ); \
\r
944 if( window == NULL ) \
\r
947 #define GETMOUSE(a) \
\r
948 window->State.MouseX = event.a.x; \
\r
949 window->State.MouseY = event.a.y;
\r
951 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoopEvent" );
\r
953 while( XPending( fgDisplay.Display ) )
\r
955 XNextEvent( fgDisplay.Display, &event );
\r
957 fghPrintEvent( &event );
\r
960 switch( event.type )
\r
962 case ClientMessage:
\r
963 if(fgIsSpaceballXEvent(&event)) {
\r
964 fgSpaceballHandleXEvent(&event);
\r
967 /* Destroy the window when the WM_DELETE_WINDOW message arrives */
\r
968 if( (Atom) event.xclient.data.l[ 0 ] == fgDisplay.DeleteWindow )
\r
970 GETWINDOW( xclient );
\r
972 fgDestroyWindow ( window );
\r
974 if( fgState.ActionOnWindowClose == GLUT_ACTION_EXIT )
\r
979 else if( fgState.ActionOnWindowClose == GLUT_ACTION_GLUTMAINLOOP_RETURNS )
\r
980 fgState.ExecState = GLUT_EXEC_STATE_STOP;
\r
987 * CreateNotify causes a configure-event so that sub-windows are
\r
988 * handled compatibly with GLUT. Otherwise, your sub-windows
\r
989 * (in freeglut only) will not get an initial reshape event,
\r
990 * which can break things.
\r
992 * GLUT presumably does this because it generally tries to treat
\r
993 * sub-windows the same as windows.
\r
996 case ConfigureNotify:
\r
999 if( event.type == CreateNotify ) {
\r
1000 GETWINDOW( xcreatewindow );
\r
1001 width = event.xcreatewindow.width;
\r
1002 height = event.xcreatewindow.height;
\r
1004 GETWINDOW( xconfigure );
\r
1005 width = event.xconfigure.width;
\r
1006 height = event.xconfigure.height;
\r
1009 if( ( width != window->State.OldWidth ) ||
\r
1010 ( height != window->State.OldHeight ) )
\r
1012 SFG_Window *current_window = fgStructure.CurrentWindow;
\r
1014 window->State.OldWidth = width;
\r
1015 window->State.OldHeight = height;
\r
1016 if( FETCH_WCB( *window, Reshape ) )
\r
1017 INVOKE_WCB( *window, Reshape, ( width, height ) );
\r
1020 fgSetWindow( window );
\r
1021 glViewport( 0, 0, width, height );
\r
1023 glutPostRedisplay( );
\r
1024 if( window->IsMenu )
\r
1025 fgSetWindow( current_window );
\r
1030 case DestroyNotify:
\r
1032 * This is sent to confirm the XDestroyWindow call.
\r
1034 * XXX WHY is this commented out? Should we re-enable it?
\r
1036 /* fgAddToWindowDestroyList ( window ); */
\r
1041 * We are too dumb to process partial exposes...
\r
1043 * XXX Well, we could do it. However, it seems to only
\r
1044 * XXX be potentially useful for single-buffered (since
\r
1045 * XXX double-buffered does not respect viewport when we
\r
1046 * XXX do a buffer-swap).
\r
1049 if( event.xexpose.count == 0 )
\r
1051 GETWINDOW( xexpose );
\r
1052 window->State.Redisplay = GL_TRUE;
\r
1060 /* We get this when iconifying a window. */
\r
1061 GETWINDOW( xunmap );
\r
1062 INVOKE_WCB( *window, WindowStatus, ( GLUT_HIDDEN ) );
\r
1063 window->State.Visible = GL_FALSE;
\r
1066 case MappingNotify:
\r
1068 * Have the client's keyboard knowledge updated (xlib.ps,
\r
1069 * page 206, says that's a good thing to do)
\r
1071 XRefreshKeyboardMapping( (XMappingEvent *) &event );
\r
1074 case VisibilityNotify:
\r
1077 * Sending this event, the X server can notify us that the window
\r
1078 * has just acquired one of the three possible visibility states:
\r
1079 * VisibilityUnobscured, VisibilityPartiallyObscured or
\r
1080 * VisibilityFullyObscured. Note that we DO NOT receive a
\r
1081 * VisibilityNotify event when iconifying a window, we only get an
\r
1082 * UnmapNotify then.
\r
1084 GETWINDOW( xvisibility );
\r
1085 switch( event.xvisibility.state )
\r
1087 case VisibilityUnobscured:
\r
1088 INVOKE_WCB( *window, WindowStatus, ( GLUT_FULLY_RETAINED ) );
\r
1089 window->State.Visible = GL_TRUE;
\r
1092 case VisibilityPartiallyObscured:
\r
1093 INVOKE_WCB( *window, WindowStatus,
\r
1094 ( GLUT_PARTIALLY_RETAINED ) );
\r
1095 window->State.Visible = GL_TRUE;
\r
1098 case VisibilityFullyObscured:
\r
1099 INVOKE_WCB( *window, WindowStatus, ( GLUT_FULLY_COVERED ) );
\r
1100 window->State.Visible = GL_FALSE;
\r
1104 fgWarning( "Unknown X visibility state: %d",
\r
1105 event.xvisibility.state );
\r
1113 GETWINDOW( xcrossing );
\r
1114 GETMOUSE( xcrossing );
\r
1115 if( ( event.type == LeaveNotify ) && window->IsMenu &&
\r
1116 window->ActiveMenu && window->ActiveMenu->IsActive )
\r
1117 fgUpdateMenuHighlight( window->ActiveMenu );
\r
1119 INVOKE_WCB( *window, Entry, ( ( EnterNotify == event.type ) ?
\r
1124 case MotionNotify:
\r
1126 GETWINDOW( xmotion );
\r
1127 GETMOUSE( xmotion );
\r
1129 if( window->ActiveMenu )
\r
1131 if( window == window->ActiveMenu->ParentWindow )
\r
1133 window->ActiveMenu->Window->State.MouseX =
\r
1134 event.xmotion.x_root - window->ActiveMenu->X;
\r
1135 window->ActiveMenu->Window->State.MouseY =
\r
1136 event.xmotion.y_root - window->ActiveMenu->Y;
\r
1139 fgUpdateMenuHighlight( window->ActiveMenu );
\r
1145 * XXX For more than 5 buttons, just check {event.xmotion.state},
\r
1146 * XXX rather than a host of bit-masks? Or maybe we need to
\r
1147 * XXX track ButtonPress/ButtonRelease events in our own
\r
1150 fgState.Modifiers = fgPlatformGetModifiers( event.xmotion.state );
\r
1151 if ( event.xmotion.state & ( Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask ) ) {
\r
1152 INVOKE_WCB( *window, Motion, ( event.xmotion.x,
\r
1153 event.xmotion.y ) );
\r
1155 INVOKE_WCB( *window, Passive, ( event.xmotion.x,
\r
1156 event.xmotion.y ) );
\r
1158 fgState.Modifiers = INVALID_MODIFIERS;
\r
1162 case ButtonRelease:
\r
1165 GLboolean pressed = GL_TRUE;
\r
1168 if( event.type == ButtonRelease )
\r
1169 pressed = GL_FALSE ;
\r
1172 * A mouse button has been pressed or released. Traditionally,
\r
1173 * break if the window was found within the freeglut structures.
\r
1175 GETWINDOW( xbutton );
\r
1176 GETMOUSE( xbutton );
\r
1179 * An X button (at least in XFree86) is numbered from 1.
\r
1180 * A GLUT button is numbered from 0.
\r
1181 * Old GLUT passed through buttons other than just the first
\r
1182 * three, though it only gave symbolic names and official
\r
1183 * support to the first three.
\r
1185 button = event.xbutton.button - 1;
\r
1188 * Do not execute the application's mouse callback if a menu
\r
1189 * is hooked to this button. In that case an appropriate
\r
1190 * private call should be generated.
\r
1192 if( fgCheckActiveMenu( window, button, pressed,
\r
1193 event.xbutton.x_root, event.xbutton.y_root ) )
\r
1197 * Check if there is a mouse or mouse wheel callback hooked to the
\r
1200 if( ! FETCH_WCB( *window, Mouse ) &&
\r
1201 ! FETCH_WCB( *window, MouseWheel ) )
\r
1204 fgState.Modifiers = fgPlatformGetModifiers( event.xbutton.state );
\r
1206 /* Finally execute the mouse or mouse wheel callback */
\r
1207 if( ( button < glutDeviceGet ( GLUT_NUM_MOUSE_BUTTONS ) ) || ( ! FETCH_WCB( *window, MouseWheel ) ) )
\r
1208 INVOKE_WCB( *window, Mouse, ( button,
\r
1209 pressed ? GLUT_DOWN : GLUT_UP,
\r
1216 * Map 4 and 5 to wheel zero; EVEN to +1, ODD to -1
\r
1217 * " 6 and 7 " " one; ...
\r
1219 * XXX This *should* be behind some variables/macros,
\r
1220 * XXX since the order and numbering isn't certain
\r
1221 * XXX See XFree86 configuration docs (even back in the
\r
1222 * XXX 3.x days, and especially with 4.x).
\r
1224 * XXX Note that {button} has already been decremented
\r
1225 * XXX in mapping from X button numbering to GLUT.
\r
1227 * XXX Should add support for partial wheel turns as Windows does -- 5/27/11
\r
1229 int wheel_number = (button - glutDeviceGet ( GLUT_NUM_MOUSE_BUTTONS )) / 2;
\r
1230 int direction = -1;
\r
1235 INVOKE_WCB( *window, MouseWheel, ( wheel_number,
\r
1241 fgState.Modifiers = INVALID_MODIFIERS;
\r
1248 FGCBKeyboard keyboard_cb;
\r
1249 FGCBSpecial special_cb;
\r
1251 GETWINDOW( xkey );
\r
1254 /* Detect auto repeated keys, if configured globally or per-window */
\r
1256 if ( fgState.KeyRepeat==GLUT_KEY_REPEAT_OFF || window->State.IgnoreKeyRepeat==GL_TRUE )
\r
1258 if (event.type==KeyRelease)
\r
1261 * Look at X11 keystate to detect repeat mode.
\r
1262 * While X11 says the key is actually held down, we'll ignore KeyRelease/KeyPress pairs.
\r
1266 XQueryKeymap( fgDisplay.Display, keys ); /* Look at X11 keystate to detect repeat mode */
\r
1268 if ( event.xkey.keycode<256 ) /* XQueryKeymap is limited to 256 keycodes */
\r
1270 if ( keys[event.xkey.keycode>>3] & (1<<(event.xkey.keycode%8)) )
\r
1271 window->State.KeyRepeating = GL_TRUE;
\r
1273 window->State.KeyRepeating = GL_FALSE;
\r
1278 window->State.KeyRepeating = GL_FALSE;
\r
1280 /* Cease processing this event if it is auto repeated */
\r
1282 if (window->State.KeyRepeating)
\r
1284 if (event.type == KeyPress) window->State.KeyRepeating = GL_FALSE;
\r
1288 if( event.type == KeyPress )
\r
1290 keyboard_cb = (FGCBKeyboard)( FETCH_WCB( *window, Keyboard ));
\r
1291 special_cb = (FGCBSpecial) ( FETCH_WCB( *window, Special ));
\r
1295 keyboard_cb = (FGCBKeyboard)( FETCH_WCB( *window, KeyboardUp ));
\r
1296 special_cb = (FGCBSpecial) ( FETCH_WCB( *window, SpecialUp ));
\r
1299 /* Is there a keyboard/special callback hooked for this window? */
\r
1300 if( keyboard_cb || special_cb )
\r
1302 XComposeStatus composeStatus;
\r
1303 char asciiCode[ 32 ];
\r
1307 /* Check for the ASCII/KeySym codes associated with the event: */
\r
1308 len = XLookupString( &event.xkey, asciiCode, sizeof(asciiCode),
\r
1309 &keySym, &composeStatus
\r
1312 /* GLUT API tells us to have two separate callbacks... */
\r
1315 /* ...one for the ASCII translateable keypresses... */
\r
1318 fgSetWindow( window );
\r
1319 fgState.Modifiers = fgPlatformGetModifiers( event.xkey.state );
\r
1320 keyboard_cb( asciiCode[ 0 ],
\r
1321 event.xkey.x, event.xkey.y
\r
1323 fgState.Modifiers = INVALID_MODIFIERS;
\r
1331 * ...and one for all the others, which need to be
\r
1332 * translated to GLUT_KEY_Xs...
\r
1336 case XK_F1: special = GLUT_KEY_F1; break;
\r
1337 case XK_F2: special = GLUT_KEY_F2; break;
\r
1338 case XK_F3: special = GLUT_KEY_F3; break;
\r
1339 case XK_F4: special = GLUT_KEY_F4; break;
\r
1340 case XK_F5: special = GLUT_KEY_F5; break;
\r
1341 case XK_F6: special = GLUT_KEY_F6; break;
\r
1342 case XK_F7: special = GLUT_KEY_F7; break;
\r
1343 case XK_F8: special = GLUT_KEY_F8; break;
\r
1344 case XK_F9: special = GLUT_KEY_F9; break;
\r
1345 case XK_F10: special = GLUT_KEY_F10; break;
\r
1346 case XK_F11: special = GLUT_KEY_F11; break;
\r
1347 case XK_F12: special = GLUT_KEY_F12; break;
\r
1350 case XK_Left: special = GLUT_KEY_LEFT; break;
\r
1352 case XK_Right: special = GLUT_KEY_RIGHT; break;
\r
1354 case XK_Up: special = GLUT_KEY_UP; break;
\r
1356 case XK_Down: special = GLUT_KEY_DOWN; break;
\r
1359 case XK_Prior: special = GLUT_KEY_PAGE_UP; break;
\r
1361 case XK_Next: special = GLUT_KEY_PAGE_DOWN; break;
\r
1363 case XK_Home: special = GLUT_KEY_HOME; break;
\r
1365 case XK_End: special = GLUT_KEY_END; break;
\r
1366 case XK_KP_Insert:
\r
1367 case XK_Insert: special = GLUT_KEY_INSERT; break;
\r
1369 case XK_Num_Lock : special = GLUT_KEY_NUM_LOCK; break;
\r
1370 case XK_KP_Begin : special = GLUT_KEY_BEGIN; break;
\r
1371 case XK_KP_Delete: special = GLUT_KEY_DELETE; break;
\r
1373 case XK_Shift_L: special = GLUT_KEY_SHIFT_L; break;
\r
1374 case XK_Shift_R: special = GLUT_KEY_SHIFT_R; break;
\r
1375 case XK_Control_L: special = GLUT_KEY_CTRL_L; break;
\r
1376 case XK_Control_R: special = GLUT_KEY_CTRL_R; break;
\r
1377 case XK_Alt_L: special = GLUT_KEY_ALT_L; break;
\r
1378 case XK_Alt_R: special = GLUT_KEY_ALT_R; break;
\r
1382 * Execute the callback (if one has been specified),
\r
1383 * given that the special code seems to be valid...
\r
1385 if( special_cb && (special != -1) )
\r
1387 fgSetWindow( window );
\r
1388 fgState.Modifiers = fgPlatformGetModifiers( event.xkey.state );
\r
1389 special_cb( special, event.xkey.x, event.xkey.y );
\r
1390 fgState.Modifiers = INVALID_MODIFIERS;
\r
1397 case ReparentNotify:
\r
1398 break; /* XXX Should disable this event */
\r
1401 case GravityNotify:
\r
1405 /* enter handling of Extension Events here */
\r
1406 #ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
\r
1407 fgHandleExtensionEvents( &event );
\r
1415 static void fgPlatformMainLoopPreliminaryWork ( void )
\r
1420 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
\r
1423 * Executes a single iteration in the freeglut processing loop.
\r
1425 void FGAPIENTRY glutMainLoopEvent( void )
\r
1427 fgPlatformProcessSingleEvent ();
\r
1429 if( fgState.Timers.First )
\r
1430 fghCheckTimers( );
\r
1431 fghCheckJoystickPolls( );
\r
1434 fgCloseWindows( );
\r
1438 * Enters the freeglut processing loop.
\r
1439 * Stays until the "ExecState" changes to "GLUT_EXEC_STATE_STOP".
\r
1441 void FGAPIENTRY glutMainLoop( void )
\r
1445 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoop" );
\r
1447 fgPlatformMainLoopPreliminaryWork ();
\r
1449 fgState.ExecState = GLUT_EXEC_STATE_RUNNING ;
\r
1450 while( fgState.ExecState == GLUT_EXEC_STATE_RUNNING )
\r
1452 SFG_Window *window;
\r
1454 glutMainLoopEvent( );
\r
1456 * Step through the list of windows, seeing if there are any
\r
1457 * that are not menus
\r
1459 for( window = ( SFG_Window * )fgStructure.Windows.First;
\r
1461 window = ( SFG_Window * )window->Node.Next )
\r
1462 if ( ! ( window->IsMenu ) )
\r
1466 fgState.ExecState = GLUT_EXEC_STATE_STOP;
\r
1469 if( fgState.IdleCallback )
\r
1471 if( fgStructure.CurrentWindow &&
\r
1472 fgStructure.CurrentWindow->IsMenu )
\r
1474 fgSetWindow( window );
\r
1475 fgState.IdleCallback( );
\r
1478 fghSleepForEvents( );
\r
1483 * When this loop terminates, destroy the display, state and structure
\r
1484 * of a freeglut session, so that another glutInit() call can happen
\r
1486 * Save the "ActionOnWindowClose" because "fgDeinitialize" resets it.
\r
1488 action = fgState.ActionOnWindowClose;
\r
1489 fgDeinitialize( );
\r
1490 if( action == GLUT_ACTION_EXIT )
\r
1495 * Leaves the freeglut processing loop.
\r
1497 void FGAPIENTRY glutLeaveMainLoop( void )
\r
1499 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLeaveMainLoop" );
\r
1500 fgState.ExecState = GLUT_EXEC_STATE_STOP ;
\r
1505 /*** END OF FILE ***/
\r