4 * The windows message processing methods.
6 * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
7 * Written by Pawel W. Olszta, <olszta@sourceforge.net>
8 * Creation date: Fri Dec 3 1999
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 #define G_LOG_DOMAIN "freeglut-main"
34 #include "../include/GL/freeglut.h"
35 #include "freeglut_internal.h"
38 #if TARGET_HOST_UNIX_X11
39 #include <sys/types.h>
44 #elif TARGET_HOST_WIN32
48 #define MAX(a,b) (((a)>(b)) ? (a) : (b))
52 #define MIN(a,b) (((a)<(b)) ? (a) : (b))
57 * TODO BEFORE THE STABLE RELEASE:
59 * There are some issues concerning window redrawing under X11, and maybe
60 * some events are not handled. The Win32 version lacks some more features,
61 * but seems acceptable for not demanding purposes.
63 * Need to investigate why the X11 version breaks out with an error when
64 * closing a window (using the window manager, not glutDestroyWindow)...
67 /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
70 * Calls a window's redraw method. This is used when
71 * a redraw is forced by the incoming window messages.
74 static void fghRedrawWindowByHandle
75 #if TARGET_HOST_UNIX_X11
77 #elif TARGET_HOST_WIN32
81 SFG_Window* window = fgWindowByHandle( handle );
82 freeglut_return_if_fail( window != NULL );
83 freeglut_return_if_fail( window->Callbacks.Display != NULL );
84 freeglut_return_if_fail( window->State.Visible == TRUE );
86 fgSetWindow( window );
87 window->State.Redisplay = FALSE;
88 window->Callbacks.Display();
92 * Handle a window configuration change. When no reshape
93 * callback is hooked, the viewport size is updated to
94 * match the new window size.
96 static void fghReshapeWindowByHandle
97 #if TARGET_HOST_UNIX_X11
98 ( Window handle, int width, int height )
99 #elif TARGET_HOST_WIN32
100 ( HWND handle, int width, int height )
103 SFG_Window *current_window = fgStructure.Window ;
105 SFG_Window* window = fgWindowByHandle( handle );
106 freeglut_return_if_fail( window != NULL );
108 fgSetWindow( window );
109 if( window->Callbacks.Reshape != NULL )
110 window->Callbacks.Reshape( width, height );
112 glViewport( 0, 0, width, height );
115 * Force a window redraw. In Windows at least this is only a partial
116 * solution: if the window is increasing in size in either dimension,
117 * the already-drawn part does not get drawn again and things look funny.
118 * But without this we get this bad behaviour whenever we resize the
121 window->State.Redisplay = TRUE ;
123 if ( window->IsMenu )
124 fgSetWindow ( current_window ) ;
128 * A static helper function to execute display callback for a window
130 static void fghcbDisplayWindow( SFG_Window *window, SFG_Enumerator *enumerator )
132 #if TARGET_HOST_UNIX_X11
133 if( (window->Callbacks.Display != NULL) &&
134 (window->State.Redisplay == TRUE) &&
135 (window->State.Visible == TRUE) )
137 SFG_Window *current_window = fgStructure.Window ;
139 fgSetWindow( window );
140 window->State.Redisplay = FALSE;
141 window->Callbacks.Display();
142 fgSetWindow ( current_window ) ;
145 #elif TARGET_HOST_WIN32
147 if( window->State.NeedToResize )
149 SFG_Window *current_window = fgStructure.Window ;
151 fgSetWindow( window );
153 fghReshapeWindowByHandle(
154 window->Window.Handle,
155 glutGet( GLUT_WINDOW_WIDTH ),
156 glutGet( GLUT_WINDOW_HEIGHT )
159 window->State.NeedToResize = FALSE;
160 fgSetWindow ( current_window ) ;
163 if( (window->Callbacks.Display != NULL) &&
164 (window->State.Redisplay == TRUE) &&
165 (window->State.Visible == TRUE) )
167 window->State.Redisplay = FALSE;
170 window->Window.Handle, NULL, NULL,
171 RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE | RDW_UPDATENOW
177 fgEnumSubWindows( window, fghcbDisplayWindow, enumerator );
181 * Make all windows perform a display call
183 static void fghDisplayAll( void )
185 SFG_Enumerator enumerator;
187 enumerator.found = FALSE;
188 enumerator.data = NULL;
190 fgEnumWindows( fghcbDisplayWindow, &enumerator );
194 * Window enumerator callback to check for the joystick polling code
196 static void fghcbCheckJoystickPolls( SFG_Window *window, SFG_Enumerator *enumerator )
198 long int checkTime = fgElapsedTime();
200 if( window->State.JoystickLastPoll + window->State.JoystickPollRate <= checkTime )
202 fgJoystickPollWindow( window );
203 window->State.JoystickLastPoll = checkTime;
206 fgEnumSubWindows( window, fghcbCheckJoystickPolls, enumerator );
210 * Check all windows for joystick polling
212 static void fghCheckJoystickPolls( void )
214 SFG_Enumerator enumerator;
216 enumerator.found = FALSE;
217 enumerator.data = NULL;
219 fgEnumWindows( fghcbCheckJoystickPolls, &enumerator );
223 * Check the global timers
225 static void fghCheckTimers( void )
227 long checkTime = fgElapsedTime();
228 SFG_Timer *timer, *next;
231 fgListInit(&timedOut);
234 * For every timer that is waiting for triggering
236 for( timer = (SFG_Timer *)fgState.Timers.First;
238 timer = (SFG_Timer *)next )
240 next = (SFG_Timer *)timer->Node.Next;
242 if( timer->TriggerTime <= checkTime )
244 fgListRemove( &fgState.Timers, &timer->Node );
245 fgListAppend( &timedOut, &timer->Node );
250 * Now feel free to execute all the hooked and timed out timer callbacks
251 * And delete the timed out timers...
253 while ( (timer = (SFG_Timer *)timedOut.First) )
255 if( timer->Callback != NULL )
256 timer->Callback( timer->ID );
257 fgListRemove( &timedOut, &timer->Node );
266 long fgElapsedTime( void )
268 #if TARGET_HOST_UNIX_X11
272 gettimeofday( &now, NULL );
274 elapsed = (now.tv_usec - fgState.Time.Value.tv_usec) / 1000;
275 elapsed += (now.tv_sec - fgState.Time.Value.tv_sec) * 1000;
278 #elif TARGET_HOST_WIN32
279 return (timeGetTime() - fgState.Time.Value);
286 void fgError( const char *fmt, ... )
292 fprintf( stderr, "freeglut ");
293 if( fgState.ProgramName )
294 fprintf (stderr, "(%s): ", fgState.ProgramName);
295 vfprintf( stderr, fmt, ap );
296 fprintf( stderr, "\n" );
303 void fgWarning( const char *fmt, ... )
309 fprintf( stderr, "freeglut ");
310 if( fgState.ProgramName )
311 fprintf( stderr, "(%s): ", fgState.ProgramName );
312 vfprintf( stderr, fmt, ap );
313 fprintf( stderr, "\n" );
319 * Indicates whether Joystick events are being used by ANY window.
321 * The current mechanism is to walk all of the windows and ask if
322 * there is a joystick callback. Certainly in some cases, maybe
323 * in all cases, the joystick is attached to the system and accessed
324 * from ONE point by GLUT/freeglut, so this is not the right way,
325 * in general, to do this. However, the Joystick code is segregated
326 * in its own little world, so we can't access the information that
327 * we need in order to do that nicely.
330 * * Store Joystick data into freeglut global state.
331 * * Provide NON-static functions or data from Joystick *.c file.
333 * Basically, the RIGHT way to do this requires knowing something
334 * about the Joystick. Right now, the Joystick code is behind
338 static void fgCheckJoystickCallback( SFG_Window* w, SFG_Enumerator* e)
340 if( w->Callbacks.Joystick )
345 fgEnumSubWindows( w, fgCheckJoystickCallback, e );
347 static int fgHaveJoystick( void )
349 SFG_Enumerator enumerator;
350 enumerator.found = FALSE;
351 enumerator.data = NULL;
352 fgEnumWindows( fgCheckJoystickCallback, &enumerator );
353 return !!enumerator.data;
355 static void fgHavePendingRedisplaysCallback( SFG_Window* w, SFG_Enumerator* e)
357 if( w->State.Redisplay )
362 fgEnumSubWindows( w, fgHavePendingRedisplaysCallback, e );
364 static int fgHavePendingRedisplays (void)
366 SFG_Enumerator enumerator;
367 enumerator.found = FALSE;
368 enumerator.data = NULL;
369 fgEnumWindows( fgHavePendingRedisplaysCallback, &enumerator );
370 return !!enumerator.data;
373 * Indicates whether there are any outstanding timers.
375 static int fgHaveTimers( void )
377 return !!fgState.Timers.First;
380 * Returns the number of GLUT ticks (milliseconds) till the next timer event.
382 static long fgNextTimer( void )
384 long now = fgElapsedTime();
388 for( timer = (SFG_Timer *)fgState.Timers.First;
390 timer = (SFG_Timer *)timer->Node.Next )
391 ret = MIN( ret, MAX( 0, (timer->TriggerTime) - now ) );
396 * Does the magic required to relinquish the CPU until something interesting
399 static void fgSleepForEvents( void )
401 #if TARGET_HOST_UNIX_X11
408 if( fgState.IdleCallback ||
409 fgHavePendingRedisplays() )
411 socket = ConnectionNumber( fgDisplay.Display );
413 FD_SET( socket, &fdset );
415 msec = fgNextTimer();
416 if( fgHaveJoystick() )
417 msec = MIN( msec, 10 );
419 wait.tv_sec = msec / 1000;
420 wait.tv_usec = (msec % 1000) * 1000;
421 err = select( socket+1, &fdset, NULL, NULL, &wait );
424 printf( "freeglut select() error: %d\n", errno );
426 #elif TARGET_HOST_WIN32
430 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
433 * Executes a single iteration in the freeglut processing loop.
435 void FGAPIENTRY glutMainLoopEvent( void )
437 #if TARGET_HOST_UNIX_X11
443 * This code was repeated constantly, so here it goes into a definition:
445 # define GETWINDOW(a) \
446 window = fgWindowByHandle( event.a.window ); \
447 if( window == NULL ) \
450 # define GETMOUSE(a) \
451 window->State.MouseX = event.a.x; \
452 window->State.MouseY = event.a.y;
454 freeglut_assert_ready;
456 while( XPending( fgDisplay.Display ) )
458 XNextEvent( fgDisplay.Display, &event );
464 * This is sent to confirm the XDestroyWindow call.
467 * Call the window closure callback, remove from the structure, etc.
469 /* fgAddToWindowDestroyList ( window, FALSE ); */
475 * Destroy the window when the WM_DELETE_WINDOW message arrives
477 if( (Atom) event.xclient.data.l[ 0 ] == fgDisplay.DeleteWindow )
479 GETWINDOW( xclient );
482 * Call the XWindows functions to close the window
484 fgCloseWindow ( window ) ;
487 * Call the window closure callback, remove from the structure, etc.
489 fgAddToWindowDestroyList ( window, FALSE );
495 * A window of ours has been unmapped...
501 * We are too dumb to process partial exposes...
503 if( event.xexpose.count == 0 )
504 fghRedrawWindowByHandle( event.xexpose.window );
508 * CreateNotify causes a configure-event so that sub-windows are
509 * handled compatibly with GLUT.
511 * NOTE that it is possible that you will more than one Reshape
512 * event for your top-level window, but something like this appears
513 * to be required for compatbility.
515 * GLUT presumably does this because it generally tries to treat
516 * sub-windows the same as windows.
520 case ConfigureNotify:
522 * The window gets resized
524 fghReshapeWindowByHandle(
525 event.xconfigure.window,
526 event.xconfigure.width,
527 event.xconfigure.height
533 * Have the client's keyboard knowledge updated (xlib.ps,
534 * page 206, says that's a good thing to do)
536 XRefreshKeyboardMapping( (XMappingEvent *) &event );
539 case VisibilityNotify:
542 * The window's visiblity might have changed
544 GETWINDOW( xvisibility );
547 * Break now if no window status callback has been hooked to that window
549 if( window->Callbacks.WindowStatus == NULL )
553 * We're going to send a callback to a window. Make it current.
555 fgSetWindow( window );
558 * Sending this event, the X server can notify us that the window has just
559 * acquired one of the three possible visibility states: VisibilityUnobscured,
560 * VisibilityPartiallyObscured or VisibilityFullyObscured
562 switch( event.xvisibility.state )
564 case VisibilityUnobscured:
566 * We are fully visible...
568 window->Callbacks.WindowStatus( GLUT_FULLY_RETAINED );
569 window->State.Visible = TRUE;
572 case VisibilityPartiallyObscured:
574 * The window is partially visible
576 window->Callbacks.WindowStatus( GLUT_PARTIALLY_RETAINED );
577 window->State.Visible = TRUE;
580 case VisibilityFullyObscured:
582 * The window is totally obscured
584 window->Callbacks.WindowStatus( GLUT_FULLY_COVERED );
585 window->State.Visible = FALSE;
594 * Mouse is over one of our windows
596 GETWINDOW( xcrossing ); GETMOUSE( xcrossing );
599 * Is there an entry callback hooked to the window?
601 if( window->Callbacks.Entry != NULL )
604 * Set the current window
606 fgSetWindow ( window ) ;
609 * Yeah. Notify the window about having the mouse cursor over
611 window->Callbacks.Entry( GLUT_ENTERED );
619 * Mouse is no longer over one of our windows
621 GETWINDOW( xcrossing ); GETMOUSE( xcrossing );
624 * Is there an entry callback hooked to the window?
626 if( window->Callbacks.Entry != NULL )
629 * Set the current window
631 fgSetWindow ( window ) ;
634 * Yeah. Notify the window about having the mouse cursor over
636 window->Callbacks.Entry( GLUT_LEFT );
644 * The mouse cursor was moved...
646 GETWINDOW( xmotion ); GETMOUSE( xmotion );
649 * Fallback if there's an active menu hooked to this window
651 if( window->ActiveMenu != NULL )
653 if ( window == window->ActiveMenu->ParentWindow )
655 window->ActiveMenu->Window->State.MouseX = event.xmotion.x_root - window->ActiveMenu->X ;
656 window->ActiveMenu->Window->State.MouseY = event.xmotion.y_root - window->ActiveMenu->Y ;
660 * Let's make the window redraw as a result of the mouse motion.
662 window->ActiveMenu->Window->State.Redisplay = TRUE ;
665 * Since the window is a menu, make the parent window current
667 fgSetWindow ( window->ActiveMenu->ParentWindow ) ;
673 * What kind of a movement was it?
675 if( (event.xmotion.state & Button1Mask) || (event.xmotion.state & Button2Mask) ||
676 (event.xmotion.state & Button3Mask) || (event.xmotion.state & Button4Mask) ||
677 (event.xmotion.state & Button5Mask) )
680 * A mouse button was pressed during the movement...
681 * Is there a motion callback hooked to the window?
683 if( window->Callbacks.Motion != NULL )
686 * Set the current window
688 fgSetWindow ( window ) ;
691 * Yup. Have it executed immediately
693 window->Callbacks.Motion( event.xmotion.x, event.xmotion.y );
699 * Otherwise it was a passive movement...
701 if( window->Callbacks.Passive != NULL )
704 * Set the current window
706 fgSetWindow ( window ) ;
709 * That's right, and there is a passive callback, too.
711 window->Callbacks.Passive( event.xmotion.x, event.xmotion.y );
720 GLboolean pressed = TRUE ;
723 if ( event.type == ButtonRelease ) pressed = FALSE ;
726 * A mouse button has been pressed or released. Traditionally,
727 * break if the window was found within the freeglut structures.
729 GETWINDOW( xbutton ); GETMOUSE( xbutton );
732 * An X button (at least in XFree86) is numbered from 1.
733 * A GLUT button is numbered from 0.
734 * Old GLUT passed through buttons other than just the first
735 * three, though it only gave symbolic names and official
736 * support to the first three.
739 button = event.xbutton.button - 1;
742 * Do not execute the application's mouse callback if a menu is hooked to this button.
743 * In that case an appropriate private call should be generated.
744 * Near as I can tell, this is the menu behaviour:
745 * - Down-click the menu button, menu not active: activate the menu with its upper left-hand corner at the mouse location.
746 * - Down-click any button outside the menu, menu active: deactivate the menu
747 * - Down-click any button inside the menu, menu active: select the menu entry and deactivate the menu
748 * - Up-click the menu button, menu not active: nothing happens
749 * - Up-click the menu button outside the menu, menu active: nothing happens
750 * - Up-click the menu button inside the menu, menu active: select the menu entry and deactivate the menu
752 if ( window->ActiveMenu != NULL ) /* Window has an active menu, it absorbs any mouse click */
754 if ( window == window->ActiveMenu->ParentWindow )
756 window->ActiveMenu->Window->State.MouseX = event.xbutton.x_root - window->ActiveMenu->X ;
757 window->ActiveMenu->Window->State.MouseY = event.xbutton.y_root - window->ActiveMenu->Y ;
760 if ( fgCheckActiveMenu ( window->ActiveMenu->Window, window->ActiveMenu ) == TRUE ) /* Inside the menu, invoke the callback and deactivate the menu*/
762 /* Save the current window and menu and set the current window to the window whose menu this is */
763 SFG_Window *save_window = fgStructure.Window ;
764 SFG_Menu *save_menu = fgStructure.Menu ;
765 SFG_Window *parent_window = window->ActiveMenu->ParentWindow ;
766 fgSetWindow ( parent_window ) ;
767 fgStructure.Menu = window->ActiveMenu ;
769 /* Execute the menu callback */
770 fgExecuteMenuCallback ( window->ActiveMenu ) ;
771 fgDeactivateMenu ( parent_window ) ;
773 /* Restore the current window and menu */
774 fgSetWindow ( save_window ) ;
775 fgStructure.Menu = save_menu ;
777 else /* Outside the menu, deactivate the menu if it's a downclick */
778 if ( pressed == TRUE )
779 fgDeactivateMenu ( window->ActiveMenu->ParentWindow ) ;
782 * Let's make the window redraw as a result of the mouse click and menu activity.
784 window->State.Redisplay = TRUE ;
790 * No active menu, let's check whether we need to activate one.
792 if (( 0 <= button ) && ( 2 >= button ) &&
793 ( window->Menu[ button ] != NULL ) && ( pressed == TRUE ) )
796 * Let's make the window redraw as a result of the mouse click.
798 window->State.Redisplay = TRUE ;
801 * Set the current window
803 fgSetWindow( window );
806 * Activate the appropriate menu structure...
808 fgActivateMenu( window, button );
814 * Check if there is a mouse or mouse wheel callback hooked to the window
816 if ( ( window->Callbacks.Mouse == NULL ) && ( window->Callbacks.MouseWheel == NULL ) )
820 * Set the current window
822 fgSetWindow ( window );
825 * Remember the current modifiers state
828 if (event.xbutton.state & (ShiftMask|LockMask))
829 modifiers |= GLUT_ACTIVE_SHIFT;
830 if (event.xbutton.state & ControlMask)
831 modifiers |= GLUT_ACTIVE_CTRL;
832 if (event.xbutton.state & Mod1Mask)
833 modifiers |= GLUT_ACTIVE_ALT;
834 fgStructure.Window->State.Modifiers = modifiers;
837 * Finally execute the mouse or mouse wheel callback
841 fgStructure.Window->Callbacks.Mouse(
843 event.type == ButtonPress ? GLUT_DOWN : GLUT_UP,
850 if ( window->Callbacks.MouseWheel != NULL )
852 int wheel_number = button / 2 - 2 ; /* Map 4 and 5 to wheel zero */
853 int direction = 9 - button * 2 ; /* Map 4 to +1 and 5 to -1 */
855 fgStructure.Window->Callbacks.MouseWheel(
864 fgStructure.Window->Callbacks.Mouse(
866 event.type == ButtonPress ? GLUT_DOWN : GLUT_UP,
874 * Trash the modifiers state
876 fgStructure.Window->State.Modifiers = 0xffffffff;
883 FGCBkeyboard keyboard_cb;
884 FGCBspecial special_cb;
887 * A key has been pressed, find the window that had the focus:
892 if( event.type == KeyPress )
894 keyboard_cb = window->Callbacks.Keyboard;
895 special_cb = window->Callbacks.Special;
899 keyboard_cb = window->Callbacks.KeyboardUp;
900 special_cb = window->Callbacks.SpecialUp;
904 * Is there a keyboard/special callback hooked for this window?
906 if( (keyboard_cb != NULL) || (special_cb != NULL) )
908 XComposeStatus composeStatus;
909 char asciiCode[ 32 ];
914 * Check for the ASCII/KeySym codes associated with the event:
916 len = XLookupString( &event.xkey, asciiCode, sizeof(asciiCode), &keySym, &composeStatus );
919 * GLUT API tells us to have two separate callbacks...
924 * ...one for the ASCII translateable keypresses...
926 if( keyboard_cb != NULL )
929 * Set the current window
931 fgSetWindow( window );
934 * Remember the current modifiers state
937 if (event.xkey.state & (ShiftMask|LockMask))
938 modifiers |= GLUT_ACTIVE_SHIFT;
939 if (event.xkey.state & ControlMask)
940 modifiers |= GLUT_ACTIVE_CTRL;
941 if (event.xkey.state & Mod1Mask)
942 modifiers |= GLUT_ACTIVE_ALT;
943 window->State.Modifiers = modifiers;
946 * Execute the callback
948 keyboard_cb( asciiCode[ 0 ], event.xkey.x, event.xkey.y );
951 * Trash the modifiers state
953 window->State.Modifiers = 0xffffffff;
961 * ...and one for all the others, which need to be translated to GLUT_KEY_Xs...
966 * First the function keys come:
968 case XK_F1: special = GLUT_KEY_F1; break;
969 case XK_F2: special = GLUT_KEY_F2; break;
970 case XK_F3: special = GLUT_KEY_F3; break;
971 case XK_F4: special = GLUT_KEY_F4; break;
972 case XK_F5: special = GLUT_KEY_F5; break;
973 case XK_F6: special = GLUT_KEY_F6; break;
974 case XK_F7: special = GLUT_KEY_F7; break;
975 case XK_F8: special = GLUT_KEY_F8; break;
976 case XK_F9: special = GLUT_KEY_F9; break;
977 case XK_F10: special = GLUT_KEY_F10; break;
978 case XK_F11: special = GLUT_KEY_F11; break;
979 case XK_F12: special = GLUT_KEY_F12; break;
982 * Then the arrows and stuff:
984 case XK_Left: special = GLUT_KEY_LEFT; break;
985 case XK_Right: special = GLUT_KEY_RIGHT; break;
986 case XK_Up: special = GLUT_KEY_UP; break;
987 case XK_Down: special = GLUT_KEY_DOWN; break;
990 case XK_Prior: special = GLUT_KEY_PAGE_UP; break;
992 case XK_Next: special = GLUT_KEY_PAGE_DOWN; break;
994 case XK_Home: special = GLUT_KEY_HOME; break;
996 case XK_End: special = GLUT_KEY_END; break;
998 case XK_Insert: special = GLUT_KEY_INSERT; break;
1002 * Execute the callback (if one has been specified),
1003 * given that the special code seems to be valid...
1005 if( (special_cb != NULL) && (special != -1) )
1007 fgSetWindow( window );
1010 * Remember the current modifiers state
1013 if (event.xkey.state & (ShiftMask|LockMask))
1014 modifiers |= GLUT_ACTIVE_SHIFT;
1015 if (event.xkey.state & ControlMask)
1016 modifiers |= GLUT_ACTIVE_CTRL;
1017 if (event.xkey.state & Mod1Mask)
1018 modifiers |= GLUT_ACTIVE_ALT;
1019 window->State.Modifiers = modifiers;
1021 special_cb( special, event.xkey.x, event.xkey.y );
1024 * Trash the modifiers state
1026 window->State.Modifiers = 0xffffffff;
1035 #elif TARGET_HOST_WIN32
1039 while ( PeekMessage( &stMsg, NULL, 0, 0, PM_NOREMOVE ) )
1041 if( GetMessage( &stMsg, NULL, 0, 0 ) == 0 )
1042 fgState.ExecState = GLUT_EXEC_STATE_STOP ;
1044 TranslateMessage( &stMsg );
1045 DispatchMessage( &stMsg );
1050 fghCheckJoystickPolls();
1057 * Enters the freeglut processing loop. Stays until the "ExecState" changes to "GLUT_EXEC_STATE_STOP".
1059 void FGAPIENTRY glutMainLoop( void )
1061 #if TARGET_HOST_WIN32
1062 SFG_Window *window = (SFG_Window *)fgStructure.Windows.First ;
1065 freeglut_assert_ready;
1067 #if TARGET_HOST_WIN32
1069 * Processing before the main loop: If there is a window which is open and
1070 * which has a visibility callback, call it. I know this is an ugly hack,
1071 * but I'm not sure what else to do about it. Ideally we should leave
1072 * something uninitialized in the create window code and initialize it in
1073 * the main loop, and have that initialization create a "WM_ACTIVATE"
1074 * message. Then we would put the visibility callback code in the
1075 * "case WM_ACTIVATE" block below. - John Fay -- 10/24/02
1077 while ( window != NULL )
1079 if ( window->Callbacks.Visibility != NULL )
1081 SFG_Window *current_window = fgStructure.Window ;
1083 fgSetWindow( window );
1084 window->Callbacks.Visibility ( window->State.Visible ) ;
1085 fgSetWindow( current_window );
1088 window = (SFG_Window *)window->Node.Next ;
1092 fgState.ExecState = GLUT_EXEC_STATE_RUNNING ;
1093 while ( fgState.ExecState == GLUT_EXEC_STATE_RUNNING )
1095 glutMainLoopEvent () ;
1097 if ( fgStructure.Windows.First == NULL )
1098 fgState.ExecState = GLUT_EXEC_STATE_STOP ;
1101 if ( fgState.IdleCallback )
1102 fgState.IdleCallback ();
1109 fgExecutionState execState = fgState.ActionOnWindowClose;
1112 * When this loop terminates, destroy the display, state and structure
1113 * of a freeglut session, so that another glutInit() call can happen
1117 if ( execState == GLUT_ACTION_EXIT )
1123 * Leaves the freeglut processing loop.
1125 void FGAPIENTRY glutLeaveMainLoop( void )
1127 fgState.ExecState = GLUT_EXEC_STATE_STOP ;
1131 * The window procedure for handling Win32 events
1133 #if TARGET_HOST_WIN32
1134 LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
1136 SFG_Window* window = fgWindowByHandle( hWnd );
1140 if ( ( window == NULL ) && ( uMsg != WM_CREATE ) )
1141 return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
1143 /* printf ( "Window %3d message <%04x> %12d %12d\n", window?window->ID:0, uMsg, wParam, lParam ) ; */
1148 * The window structure is passed as the creation structure paramter...
1150 window = (SFG_Window *) (((LPCREATESTRUCT) lParam)->lpCreateParams);
1151 assert( window != NULL );
1153 window->Window.Handle = hWnd;
1154 window->Window.Device = GetDC( hWnd );
1155 if ( fgState.BuildingAMenu )
1157 unsigned int current_DisplayMode = fgState.DisplayMode ;
1158 fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH ;
1159 fgSetupPixelFormat( window, FALSE, PFD_MAIN_PLANE );
1160 fgState.DisplayMode = current_DisplayMode ;
1162 if ( !fgStructure.MenuContext )
1164 fgStructure.MenuContext = (SFG_MenuContext *)malloc ( sizeof(SFG_MenuContext) ) ;
1165 fgStructure.MenuContext->Context = wglCreateContext( window->Window.Device );
1168 wglMakeCurrent ( window->Window.Device, fgStructure.MenuContext->Context ) ;
1170 /* window->Window.Context = wglGetCurrentContext () ; */
1171 window->Window.Context = wglCreateContext( window->Window.Device );
1175 fgSetupPixelFormat( window, FALSE, PFD_MAIN_PLANE );
1177 if ( fgState.UseCurrentContext == TRUE )
1179 window->Window.Context = wglGetCurrentContext();
1180 if ( ! window->Window.Context )
1181 window->Window.Context = wglCreateContext( window->Window.Device );
1184 window->Window.Context = wglCreateContext( window->Window.Device );
1187 window->State.NeedToResize = TRUE;
1188 ReleaseDC( window->Window.Handle, window->Window.Device );
1193 * We got resized... But check if the window has been already added...
1195 fghReshapeWindowByHandle( hWnd, LOWORD(lParam), HIWORD(lParam) );
1199 printf("WM_SETFOCUS: %p\n", window );
1200 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1204 if (LOWORD(wParam) != WA_INACTIVE)
1206 /* glutSetCursor( fgStructure.Window->State.Cursor ); */
1207 printf("WM_ACTIVATE: glutSetCursor( %p, %d)\n", window, window->State.Cursor );
1209 glutSetCursor( window->State.Cursor );
1212 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1218 * Windows seems to need reminding to erase the cursor for NONE.
1221 if ((LOWORD(lParam) == HTCLIENT) &&
1222 (fgStructure.Window->State.Cursor == GLUT_CURSOR_NONE))
1225 /* Set the cursor AND change it for this window class. */
1226 # define MAP_CURSOR(a,b) case a: SetCursor( LoadCursor( NULL, b ) ); \
1228 /* Nuke the cursor AND change it for this window class. */
1229 # define ZAP_CURSOR(a,b) case a: SetCursor( NULL ); \
1232 if (LOWORD(lParam) == HTCLIENT)
1233 switch( window->State.Cursor )
1235 MAP_CURSOR( GLUT_CURSOR_RIGHT_ARROW, IDC_ARROW );
1236 MAP_CURSOR( GLUT_CURSOR_LEFT_ARROW, IDC_ARROW );
1237 MAP_CURSOR( GLUT_CURSOR_INFO, IDC_HELP );
1238 MAP_CURSOR( GLUT_CURSOR_DESTROY, IDC_CROSS );
1239 MAP_CURSOR( GLUT_CURSOR_HELP, IDC_HELP );
1240 MAP_CURSOR( GLUT_CURSOR_CYCLE, IDC_SIZEALL );
1241 MAP_CURSOR( GLUT_CURSOR_SPRAY, IDC_CROSS );
1242 MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT );
1243 MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_UPARROW );
1244 MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS );
1245 /* MAP_CURSOR( GLUT_CURSOR_NONE, IDC_NO ); */
1246 ZAP_CURSOR( GLUT_CURSOR_NONE, NULL );
1249 MAP_CURSOR( GLUT_CURSOR_UP_DOWN, IDC_ARROW );
1253 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1257 window->State.Visible = TRUE;
1258 window->State.Redisplay = TRUE;
1262 BeginPaint( hWnd, &ps );
1263 fghRedrawWindowByHandle( hWnd );
1264 EndPaint( hWnd, &ps );
1269 * Make sure we don't close a window with current context active
1271 if( fgStructure.Window == window )
1276 wglMakeCurrent( NULL, NULL );
1277 /* Step through the list of windows. If the rendering context is not being used
1278 * by another window, then we delete it.
1280 for ( iter = (SFG_Window *)fgStructure.Windows.First; iter; iter = (SFG_Window *)iter->Node.Next )
1282 if ( ( iter->Window.Context == window->Window.Context ) && ( iter != window ) )
1286 if ( used == FALSE ) wglDeleteContext( window->Window.Context );
1290 * Put on a linked list of windows to be removed after all the callbacks have returned
1292 fgAddToWindowDestroyList ( window, FALSE ) ;
1293 DestroyWindow( hWnd );
1298 * The window already got destroyed, so don't bother with it.
1304 window->State.MouseX = LOWORD( lParam );
1305 window->State.MouseY = HIWORD( lParam );
1307 if ( window->ActiveMenu != NULL )
1309 window->State.Redisplay = TRUE ;
1312 * Since the window is a menu, make the parent window current
1314 fgSetWindow ( window->ActiveMenu->ParentWindow ) ;
1319 window->State.Modifiers =
1320 ( ( (GetKeyState( VK_LSHIFT ) < 0 ) || ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
1321 ( ( (GetKeyState( VK_LCONTROL ) < 0 ) || ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
1322 ( ( (GetKeyState( VK_LMENU ) < 0 ) || ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
1324 if( (wParam & MK_LBUTTON) || (wParam & MK_MBUTTON) || (wParam & MK_RBUTTON) )
1326 if( window->Callbacks.Motion != NULL )
1328 fgSetWindow( window );
1329 window->Callbacks.Motion( window->State.MouseX, window->State.MouseY );
1334 if( window->Callbacks.Passive != NULL )
1336 fgSetWindow( window );
1337 window->Callbacks.Passive( window->State.MouseX, window->State.MouseY );
1341 window->State.Modifiers = 0xffffffff;
1345 case WM_LBUTTONDOWN:
1346 case WM_MBUTTONDOWN:
1347 case WM_RBUTTONDOWN:
1352 GLboolean pressed = TRUE;
1355 window->State.MouseX = LOWORD( lParam );
1356 window->State.MouseY = HIWORD( lParam );
1360 case WM_LBUTTONDOWN: pressed = TRUE; button = GLUT_LEFT_BUTTON; break;
1361 case WM_MBUTTONDOWN: pressed = TRUE; button = GLUT_MIDDLE_BUTTON; break;
1362 case WM_RBUTTONDOWN: pressed = TRUE; button = GLUT_RIGHT_BUTTON; break;
1363 case WM_LBUTTONUP: pressed = FALSE; button = GLUT_LEFT_BUTTON; break;
1364 case WM_MBUTTONUP: pressed = FALSE; button = GLUT_MIDDLE_BUTTON; break;
1365 case WM_RBUTTONUP: pressed = FALSE; button = GLUT_RIGHT_BUTTON; break;
1366 default: pressed = FALSE; button = -1; break;
1369 if( GetSystemMetrics( SM_SWAPBUTTON ) )
1370 if( button == GLUT_LEFT_BUTTON ) button = GLUT_RIGHT_BUTTON;
1371 else if( button == GLUT_RIGHT_BUTTON ) button = GLUT_LEFT_BUTTON;
1374 return( DefWindowProc( hWnd, uMsg, lParam, wParam ) );
1377 * Do not execute the application's mouse callback if a menu is hooked to this button.
1378 * In that case an appropriate private call should be generated.
1379 * Near as I can tell, this is the menu behaviour:
1380 * - Down-click the menu button, menu not active: activate the menu with its upper left-hand corner at the mouse location.
1381 * - Down-click any button outside the menu, menu active: deactivate the menu
1382 * - Down-click any button inside the menu, menu active: select the menu entry and deactivate the menu
1383 * - Up-click the menu button, menu not active: nothing happens
1384 * - Up-click the menu button outside the menu, menu active: nothing happens
1385 * - Up-click the menu button inside the menu, menu active: select the menu entry and deactivate the menu
1387 if ( window->ActiveMenu != NULL ) /* Window has an active menu, it absorbs any mouse click */
1389 if ( fgCheckActiveMenu ( window, window->ActiveMenu ) == TRUE ) /* Inside the menu, invoke the callback and deactivate the menu*/
1391 /* Save the current window and menu and set the current window to the window whose menu this is */
1392 SFG_Window *save_window = fgStructure.Window ;
1393 SFG_Menu *save_menu = fgStructure.Menu ;
1394 SFG_Window *parent_window = window->ActiveMenu->ParentWindow ;
1395 fgSetWindow ( parent_window ) ;
1396 fgStructure.Menu = window->ActiveMenu ;
1398 /* Execute the menu callback */
1399 fgExecuteMenuCallback ( window->ActiveMenu ) ;
1400 fgDeactivateMenu ( parent_window ) ;
1402 /* Restore the current window and menu */
1403 fgSetWindow ( save_window ) ;
1404 fgStructure.Menu = save_menu ;
1406 else /* Outside the menu, deactivate the menu if it's a downclick */
1408 if ( pressed == TRUE ) fgDeactivateMenu ( window->ActiveMenu->ParentWindow ) ;
1412 * Let's make the window redraw as a result of the mouse click and menu activity.
1414 if ( ! window->IsMenu ) window->State.Redisplay = TRUE ;
1419 if ( ( window->Menu[ button ] != NULL ) && ( pressed == TRUE ) )
1421 window->State.Redisplay = TRUE ;
1422 fgSetWindow( window );
1423 fgActivateMenu( window, button );
1428 if( window->Callbacks.Mouse == NULL )
1431 fgSetWindow ( window );
1433 fgStructure.Window->State.Modifiers =
1434 ( ( (GetKeyState( VK_LSHIFT ) < 0 ) || ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
1435 ( ( (GetKeyState( VK_LCONTROL ) < 0 ) || ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
1436 ( ( (GetKeyState( VK_LMENU ) < 0 ) || ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
1438 window->Callbacks.Mouse(
1440 pressed == TRUE ? GLUT_DOWN : GLUT_UP,
1441 window->State.MouseX,
1442 window->State.MouseY
1445 fgStructure.Window->State.Modifiers = 0xffffffff;
1449 case 0x020a : /* Should be WM_MOUSEWHEEL but my compiler doesn't recognize it */
1451 int wheel_number = LOWORD ( lParam ) ; /* THIS IS SPECULATIVE -- John Fay, 10/2/03 */
1452 int direction = HIWORD ( lParam ) / 120 ; /* Should be WHEEL_DELTA instead of 120 */
1455 * The mouse cursor has moved. Remember the new mouse cursor's position
1457 // window->State.MouseX = LOWORD( lParam ); // Need to adjust by window position,
1458 // window->State.MouseY = HIWORD( lParam ); // change "lParam" to other parameter
1460 if ( ( window->Callbacks.MouseWheel == NULL ) && ( window->Callbacks.Mouse == NULL ) )
1463 fgSetWindow ( window );
1464 fgStructure.Window->State.Modifiers =
1465 ( ( (GetKeyState( VK_LSHIFT ) < 0 ) || ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
1466 ( ( (GetKeyState( VK_LCONTROL ) < 0 ) || ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
1467 ( ( (GetKeyState( VK_LMENU ) < 0 ) || ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
1469 if ( window->Callbacks.MouseWheel )
1470 window->Callbacks.MouseWheel(
1473 window->State.MouseX,
1474 window->State.MouseY
1476 else // No mouse wheel, call the mouse button callback twice
1478 window->Callbacks.Mouse ( ( direction > 0 ) ? 4 : 5, GLUT_DOWN, window->State.MouseX, window->State.MouseY ) ;
1479 window->Callbacks.Mouse ( ( direction > 0 ) ? 4 : 5, GLUT_UP, window->State.MouseX, window->State.MouseY ) ;
1482 fgStructure.Window->State.Modifiers = 0xffffffff;
1492 if( fgState.IgnoreKeyRepeat && (lParam & KF_REPEAT) )
1496 * Remember the current modifiers state. This is done here in order
1497 * to make sure the VK_DELETE keyboard callback is executed properly.
1499 window->State.Modifiers =
1500 ( ( (GetKeyState( VK_LSHIFT ) < 0 ) || ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
1501 ( ( (GetKeyState( VK_LCONTROL ) < 0 ) || ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
1502 ( ( (GetKeyState( VK_LMENU ) < 0 ) || ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
1504 GetCursorPos ( &mouse_pos ) ;
1505 ScreenToClient ( window->Window.Handle, &mouse_pos ) ;
1507 window->State.MouseX = mouse_pos.x ;
1508 window->State.MouseY = mouse_pos.y ;
1511 * Convert the Win32 keystroke codes to GLUTtish way
1513 # define KEY(a,b) case a: keypress = b; break;
1517 KEY( VK_F1, GLUT_KEY_F1 ); KEY( VK_F2, GLUT_KEY_F2 );
1518 KEY( VK_F3, GLUT_KEY_F3 ); KEY( VK_F4, GLUT_KEY_F4 );
1519 KEY( VK_F5, GLUT_KEY_F5 ); KEY( VK_F6, GLUT_KEY_F6 );
1520 KEY( VK_F7, GLUT_KEY_F7 ); KEY( VK_F8, GLUT_KEY_F8 );
1521 KEY( VK_F9, GLUT_KEY_F9 ); KEY( VK_F10, GLUT_KEY_F10 );
1522 KEY( VK_F11, GLUT_KEY_F11 ); KEY( VK_F12, GLUT_KEY_F12 );
1523 KEY( VK_PRIOR, GLUT_KEY_PAGE_UP ); KEY( VK_NEXT, GLUT_KEY_PAGE_DOWN );
1524 KEY( VK_HOME, GLUT_KEY_HOME ); KEY( VK_END, GLUT_KEY_END );
1525 KEY( VK_LEFT, GLUT_KEY_LEFT ); KEY( VK_UP, GLUT_KEY_UP );
1526 KEY( VK_RIGHT, GLUT_KEY_RIGHT ); KEY( VK_DOWN, GLUT_KEY_DOWN );
1527 KEY( VK_INSERT, GLUT_KEY_INSERT );
1531 * The delete key should be treated as an ASCII keypress:
1533 if( window->Callbacks.Keyboard != NULL )
1535 fgSetWindow( window );
1536 window->Callbacks.Keyboard( 127, window->State.MouseX, window->State.MouseY );
1540 if( (keypress != -1) && (window->Callbacks.Special != NULL) )
1542 fgSetWindow( window );
1543 window->Callbacks.Special( keypress, window->State.MouseX, window->State.MouseY );
1546 window->State.Modifiers = 0xffffffff;
1557 * Remember the current modifiers state. This is done here in order
1558 * to make sure the VK_DELETE keyboard callback is executed properly.
1560 window->State.Modifiers =
1561 ( ( (GetKeyState( VK_LSHIFT ) < 0 ) || ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
1562 ( ( (GetKeyState( VK_LCONTROL ) < 0 ) || ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
1563 ( ( (GetKeyState( VK_LMENU ) < 0 ) || ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
1565 GetCursorPos ( &mouse_pos ) ;
1566 ScreenToClient ( window->Window.Handle, &mouse_pos ) ;
1568 window->State.MouseX = mouse_pos.x ;
1569 window->State.MouseY = mouse_pos.y ;
1572 * Convert the Win32 keystroke codes to GLUTtish way. "KEY(a,b)" was defined under "WM_KEYDOWN"
1577 KEY( VK_F1, GLUT_KEY_F1 ); KEY( VK_F2, GLUT_KEY_F2 );
1578 KEY( VK_F3, GLUT_KEY_F3 ); KEY( VK_F4, GLUT_KEY_F4 );
1579 KEY( VK_F5, GLUT_KEY_F5 ); KEY( VK_F6, GLUT_KEY_F6 );
1580 KEY( VK_F7, GLUT_KEY_F7 ); KEY( VK_F8, GLUT_KEY_F8 );
1581 KEY( VK_F9, GLUT_KEY_F9 ); KEY( VK_F10, GLUT_KEY_F10 );
1582 KEY( VK_F11, GLUT_KEY_F11 ); KEY( VK_F12, GLUT_KEY_F12 );
1583 KEY( VK_PRIOR, GLUT_KEY_PAGE_UP ); KEY( VK_NEXT, GLUT_KEY_PAGE_DOWN );
1584 KEY( VK_HOME, GLUT_KEY_HOME ); KEY( VK_END, GLUT_KEY_END );
1585 KEY( VK_LEFT, GLUT_KEY_LEFT ); KEY( VK_UP, GLUT_KEY_UP );
1586 KEY( VK_RIGHT, GLUT_KEY_RIGHT ); KEY( VK_DOWN, GLUT_KEY_DOWN );
1587 KEY( VK_INSERT, GLUT_KEY_INSERT );
1591 * The delete key should be treated as an ASCII keypress:
1593 if( window->Callbacks.KeyboardUp != NULL )
1595 fgSetWindow ( window ) ;
1596 window->Callbacks.KeyboardUp( 127, window->State.MouseX, window->State.MouseY );
1605 GetKeyboardState(state);
1607 if ( ToAscii( wParam, 0, state, code, 0 ) == 1 )
1610 if( window->Callbacks.KeyboardUp != NULL )
1612 fgSetWindow( window );
1613 window->Callbacks.KeyboardUp( (char)wParam, window->State.MouseX, window->State.MouseY );
1618 if( (keypress != -1) && (window->Callbacks.SpecialUp != NULL) )
1620 fgSetWindow( window );
1621 window->Callbacks.SpecialUp( keypress, window->State.MouseX, window->State.MouseY );
1624 window->State.Modifiers = 0xffffffff;
1631 if( fgState.IgnoreKeyRepeat && (lParam & KF_REPEAT) )
1634 if( window->Callbacks.Keyboard != NULL )
1636 fgSetWindow( window );
1637 window->State.Modifiers =
1638 ( ( (GetKeyState( VK_LSHIFT ) < 0 ) || ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
1639 ( ( (GetKeyState( VK_LCONTROL ) < 0 ) || ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
1640 ( ( (GetKeyState( VK_LMENU ) < 0 ) || ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
1642 window->Callbacks.Keyboard( (char)wParam, window->State.MouseX, window->State.MouseY );
1643 window->State.Modifiers = 0xffffffff;
1648 case WM_CAPTURECHANGED : /* User has finished resizing the window, force a redraw */
1649 if ( window->Callbacks.Display )
1651 fgSetWindow( window );
1653 window->Callbacks.Display () ;
1656 /* lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ) ; */
1660 * Other messages that I have seen and which are not handled already
1662 case WM_SETTEXT : /* 0x000c */
1663 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ); /* Pass it on to "DefWindowProc" to set the window text */
1666 case WM_GETTEXT : /* 0x000d */
1667 /* Ideally we would copy the title of the window into "lParam" */
1668 /* strncpy ( (char *)lParam, "Window Title", wParam ) ;
1669 lRet = ( wParam > 12 ) ? 12 : wParam ; */ /* the number of characters copied */
1670 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1673 case WM_GETTEXTLENGTH : /* 0x000e */
1674 /* Ideally we would get the length of the title of the window */
1675 lRet = 12 ; /* the number of characters in "Window Title\0" (see above) */
1678 case WM_ERASEBKGND : /* 0x0014 */
1679 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1682 case WM_SYNCPAINT : /* 0x0088 */
1683 /* Another window has moved, need to update this one */
1684 window->State.Redisplay = TRUE ;
1685 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ); /* Help screen says this message must be passed to "DefWindowProc" */
1688 case WM_NCPAINT : /* 0x0085 */
1689 /* Need to update the border of this window */
1690 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ); /* Pass it on to "DefWindowProc" to repaint a standard border */
1695 * Handle unhandled messages
1697 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1705 /*** END OF FILE ***/