4 * The windows message processing methods.
6 * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
7 * Written by Pawel W. Olszta, <olszta@sourceforge.net>
8 * Creation date: Fri Dec 3 1999
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 #include <GL/freeglut.h>
29 #include "freeglut_internal.h"
35 # define VFPRINTF(s,f,a) vfprintf((s),(f),(a))
36 #elif defined(HAVE__DOPRNT)
37 # define VFPRINTF(s,f,a) _doprnt((f),(a),(s))
39 # define VFPRINTF(s,f,a)
44 typedef struct GXDisplayProperties GXDisplayProperties;
45 typedef struct GXKeyList GXKeyList;
48 typedef struct GXKeyList (*GXGETDEFAULTKEYS)(int);
49 typedef int (*GXOPENINPUT)();
51 GXGETDEFAULTKEYS GXGetDefaultKeys_ = NULL;
52 GXOPENINPUT GXOpenInput_ = NULL;
54 struct GXKeyList gxKeyList;
56 #endif /* _WIN32_WCE */
59 * Try to get the maximum value allowed for ints, falling back to the minimum
60 * guaranteed by ISO C99 if there is no suitable header.
66 # define INT_MAX 32767
70 # define MIN(a,b) (((a)<(b)) ? (a) : (b))
75 * TODO BEFORE THE STABLE RELEASE:
77 * There are some issues concerning window redrawing under X11, and maybe
78 * some events are not handled. The Win32 version lacks some more features,
79 * but seems acceptable for not demanding purposes.
81 * Need to investigate why the X11 version breaks out with an error when
82 * closing a window (using the window manager, not glutDestroyWindow)...
85 /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
88 * Handle a window configuration change. When no reshape
89 * callback is hooked, the viewport size is updated to
90 * match the new window size.
92 static void fghReshapeWindow ( SFG_Window *window, int width, int height )
94 SFG_Window *current_window = fgStructure.CurrentWindow;
96 freeglut_return_if_fail( window != NULL );
99 #if TARGET_HOST_POSIX_X11
101 XResizeWindow( fgDisplay.Display, window->Window.Handle,
103 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
105 #elif TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE)
111 * For windowed mode, get the current position of the
112 * window and resize taking the size of the frame
113 * decorations into account.
116 /* "GetWindowRect" returns the pixel coordinates of the outside of the window */
117 GetWindowRect( window->Window.Handle, &winRect );
123 if ( window->Parent == NULL )
125 if ( ! window->IsMenu && (window != fgStructure.GameModeWindow) &&
126 !( fgState.DisplayMode & GLUT_BORDERLESS ))
128 w += GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
129 h += GetSystemMetrics( SM_CYSIZEFRAME ) * 2 +
130 GetSystemMetrics( SM_CYCAPTION );
136 GetWindowRect( window->Parent->Window.Handle, &parentRect );
137 x -= parentRect.left + GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
138 y -= parentRect.top + GetSystemMetrics( SM_CYSIZEFRAME ) * 2 +
139 GetSystemMetrics( SM_CYCAPTION );
143 * SWP_NOACTIVATE Do not activate the window
144 * SWP_NOOWNERZORDER Do not change position in z-order
145 * SWP_NOSENDCHANGING Supress WM_WINDOWPOSCHANGING message
146 * SWP_NOZORDER Retains the current Z order (ignore 2nd param)
149 SetWindowPos( window->Window.Handle,
152 SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING |
159 * XXX Should update {window->State.OldWidth, window->State.OldHeight}
160 * XXX to keep in lockstep with POSIX_X11 code.
162 if( FETCH_WCB( *window, Reshape ) )
163 INVOKE_WCB( *window, Reshape, ( width, height ) );
166 fgSetWindow( window );
167 glViewport( 0, 0, width, height );
171 * Force a window redraw. In Windows at least this is only a partial
172 * solution: if the window is increasing in size in either dimension,
173 * the already-drawn part does not get drawn again and things look funny.
174 * But without this we get this bad behaviour whenever we resize the
177 window->State.Redisplay = GL_TRUE;
180 fgSetWindow( current_window );
184 * Calls a window's redraw method. This is used when
185 * a redraw is forced by the incoming window messages.
187 static void fghRedrawWindow ( SFG_Window *window )
189 SFG_Window *current_window = fgStructure.CurrentWindow;
191 freeglut_return_if_fail( window );
192 freeglut_return_if_fail( FETCH_WCB ( *window, Display ) );
194 window->State.Redisplay = GL_FALSE;
196 freeglut_return_if_fail( window->State.Visible );
198 fgSetWindow( window );
200 if( window->State.NeedToResize )
208 window->State.NeedToResize = GL_FALSE;
211 INVOKE_WCB( *window, Display, ( ) );
213 fgSetWindow( current_window );
217 * A static helper function to execute display callback for a window
219 static void fghcbDisplayWindow( SFG_Window *window,
220 SFG_Enumerator *enumerator )
222 if( window->State.Redisplay &&
223 window->State.Visible )
225 window->State.Redisplay = GL_FALSE;
227 #if TARGET_HOST_POSIX_X11
228 fghRedrawWindow ( window ) ;
229 #elif TARGET_HOST_MS_WINDOWS
231 window->Window.Handle, NULL, NULL,
232 RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE | RDW_UPDATENOW
237 fgEnumSubWindows( window, fghcbDisplayWindow, enumerator );
241 * Make all windows perform a display call
243 static void fghDisplayAll( void )
245 SFG_Enumerator enumerator;
247 enumerator.found = GL_FALSE;
248 enumerator.data = NULL;
250 fgEnumWindows( fghcbDisplayWindow, &enumerator );
254 * Window enumerator callback to check for the joystick polling code
256 static void fghcbCheckJoystickPolls( SFG_Window *window,
257 SFG_Enumerator *enumerator )
259 long int checkTime = fgElapsedTime( );
261 if( window->State.JoystickLastPoll + window->State.JoystickPollRate <=
264 #if !defined(_WIN32_WCE)
265 fgJoystickPollWindow( window );
266 #endif /* !defined(_WIN32_WCE) */
267 window->State.JoystickLastPoll = checkTime;
270 fgEnumSubWindows( window, fghcbCheckJoystickPolls, enumerator );
274 * Check all windows for joystick polling
276 static void fghCheckJoystickPolls( void )
278 SFG_Enumerator enumerator;
280 enumerator.found = GL_FALSE;
281 enumerator.data = NULL;
283 fgEnumWindows( fghcbCheckJoystickPolls, &enumerator );
287 * Check the global timers
289 static void fghCheckTimers( void )
291 long checkTime = fgElapsedTime( );
293 while( fgState.Timers.First )
295 SFG_Timer *timer = fgState.Timers.First;
297 if( timer->TriggerTime > checkTime )
300 fgListRemove( &fgState.Timers, &timer->Node );
301 fgListAppend( &fgState.FreeTimers, &timer->Node );
303 timer->Callback( timer->ID );
308 /* Platform-dependent time in milliseconds, as an unsigned 32-bit integer.
309 * This value wraps every 49.7 days, but integer overflows cancel
310 * when subtracting an initial start time, unless the total time exceeds
311 * 32-bit, where the GLUT API return value is also overflowed.
313 unsigned long fgSystemTime(void) {
314 #if TARGET_HOST_SOLARIS || HAVE_GETTIMEOFDAY
316 gettimeofday( &now, NULL );
317 return now.tv_usec/1000 + now.tv_sec*1000;
318 #elif TARGET_HOST_MS_WINDOWS
319 # if defined(_WIN32_WCE)
320 return GetTickCount();
322 return timeGetTime();
330 long fgElapsedTime( void )
332 return (long) (fgSystemTime() - fgState.Time);
338 void fgError( const char *fmt, ... )
342 if (fgState.ErrorFunc) {
346 /* call user set error handler here */
347 fgState.ErrorFunc(fmt, ap);
355 fprintf( stderr, "freeglut ");
356 if( fgState.ProgramName )
357 fprintf( stderr, "(%s): ", fgState.ProgramName );
358 VFPRINTF( stderr, fmt, ap );
359 fprintf( stderr, "\n" );
363 if ( fgState.Initialised )
370 void fgWarning( const char *fmt, ... )
374 if (fgState.WarningFunc) {
378 /* call user set warning handler here */
379 fgState.WarningFunc(fmt, ap);
387 fprintf( stderr, "freeglut ");
388 if( fgState.ProgramName )
389 fprintf( stderr, "(%s): ", fgState.ProgramName );
390 VFPRINTF( stderr, fmt, ap );
391 fprintf( stderr, "\n" );
399 * Indicates whether Joystick events are being used by ANY window.
401 * The current mechanism is to walk all of the windows and ask if
402 * there is a joystick callback. We have a short-circuit early
403 * return if we find any joystick handler registered.
405 * The real way to do this is to make use of the glutTimer() API
406 * to more cleanly re-implement the joystick API. Then, this code
407 * and all other "joystick timer" code can be yanked.
410 static void fghCheckJoystickCallback( SFG_Window* w, SFG_Enumerator* e)
412 if( FETCH_WCB( *w, Joystick ) )
417 fgEnumSubWindows( w, fghCheckJoystickCallback, e );
419 static int fghHaveJoystick( void )
421 SFG_Enumerator enumerator;
423 enumerator.found = GL_FALSE;
424 enumerator.data = NULL;
425 fgEnumWindows( fghCheckJoystickCallback, &enumerator );
426 return !!enumerator.data;
428 static void fghHavePendingRedisplaysCallback( SFG_Window* w, SFG_Enumerator* e)
430 if( w->State.Redisplay && w->State.Visible )
435 fgEnumSubWindows( w, fghHavePendingRedisplaysCallback, e );
437 static int fghHavePendingRedisplays (void)
439 SFG_Enumerator enumerator;
441 enumerator.found = GL_FALSE;
442 enumerator.data = NULL;
443 fgEnumWindows( fghHavePendingRedisplaysCallback, &enumerator );
444 return !!enumerator.data;
447 * Returns the number of GLUT ticks (milliseconds) till the next timer event.
449 static long fghNextTimer( void )
452 SFG_Timer *timer = fgState.Timers.First;
455 ret = timer->TriggerTime - fgElapsedTime();
462 * Does the magic required to relinquish the CPU until something interesting
465 static void fghSleepForEvents( void )
469 if( fgState.IdleCallback || fghHavePendingRedisplays( ) )
472 msec = fghNextTimer( );
473 /* XXX Use GLUT timers for joysticks... */
474 /* XXX Dumb; forces granularity to .01sec */
475 if( fghHaveJoystick( ) && ( msec > 10 ) )
478 #if TARGET_HOST_POSIX_X11
480 * Possibly due to aggressive use of XFlush() and friends,
481 * it is possible to have our socket drained but still have
482 * unprocessed events. (Or, this may just be normal with
483 * X, anyway?) We do non-trivial processing of X events
484 * after the event-reading loop, in any case, so we
485 * need to allow that we may have an empty socket but non-
488 if( ! XPending( fgDisplay.Display ) )
495 socket = ConnectionNumber( fgDisplay.Display );
497 FD_SET( socket, &fdset );
498 wait.tv_sec = msec / 1000;
499 wait.tv_usec = (msec % 1000) * 1000;
500 err = select( socket+1, &fdset, NULL, NULL, &wait );
503 if( ( -1 == err ) && ( errno != EINTR ) )
504 fgWarning ( "freeglut select() error: %d", errno );
507 #elif TARGET_HOST_MS_WINDOWS
508 MsgWaitForMultipleObjects( 0, NULL, FALSE, msec, QS_ALLINPUT );
512 #if TARGET_HOST_POSIX_X11
514 * Returns GLUT modifier mask for the state field of an X11 event.
516 int fghGetXModifiers( int state )
520 if( state & ( ShiftMask | LockMask ) )
521 ret |= GLUT_ACTIVE_SHIFT;
522 if( state & ControlMask )
523 ret |= GLUT_ACTIVE_CTRL;
524 if( state & Mod1Mask )
525 ret |= GLUT_ACTIVE_ALT;
532 #if TARGET_HOST_POSIX_X11 && _DEBUG
534 static const char* fghTypeToString( int type )
537 case KeyPress: return "KeyPress";
538 case KeyRelease: return "KeyRelease";
539 case ButtonPress: return "ButtonPress";
540 case ButtonRelease: return "ButtonRelease";
541 case MotionNotify: return "MotionNotify";
542 case EnterNotify: return "EnterNotify";
543 case LeaveNotify: return "LeaveNotify";
544 case FocusIn: return "FocusIn";
545 case FocusOut: return "FocusOut";
546 case KeymapNotify: return "KeymapNotify";
547 case Expose: return "Expose";
548 case GraphicsExpose: return "GraphicsExpose";
549 case NoExpose: return "NoExpose";
550 case VisibilityNotify: return "VisibilityNotify";
551 case CreateNotify: return "CreateNotify";
552 case DestroyNotify: return "DestroyNotify";
553 case UnmapNotify: return "UnmapNotify";
554 case MapNotify: return "MapNotify";
555 case MapRequest: return "MapRequest";
556 case ReparentNotify: return "ReparentNotify";
557 case ConfigureNotify: return "ConfigureNotify";
558 case ConfigureRequest: return "ConfigureRequest";
559 case GravityNotify: return "GravityNotify";
560 case ResizeRequest: return "ResizeRequest";
561 case CirculateNotify: return "CirculateNotify";
562 case CirculateRequest: return "CirculateRequest";
563 case PropertyNotify: return "PropertyNotify";
564 case SelectionClear: return "SelectionClear";
565 case SelectionRequest: return "SelectionRequest";
566 case SelectionNotify: return "SelectionNotify";
567 case ColormapNotify: return "ColormapNotify";
568 case ClientMessage: return "ClientMessage";
569 case MappingNotify: return "MappingNotify";
570 default: return "UNKNOWN";
574 static const char* fghBoolToString( Bool b )
576 return b == False ? "False" : "True";
579 static const char* fghNotifyHintToString( char is_hint )
582 case NotifyNormal: return "NotifyNormal";
583 case NotifyHint: return "NotifyHint";
584 default: return "UNKNOWN";
588 static const char* fghNotifyModeToString( int mode )
591 case NotifyNormal: return "NotifyNormal";
592 case NotifyGrab: return "NotifyGrab";
593 case NotifyUngrab: return "NotifyUngrab";
594 case NotifyWhileGrabbed: return "NotifyWhileGrabbed";
595 default: return "UNKNOWN";
599 static const char* fghNotifyDetailToString( int detail )
602 case NotifyAncestor: return "NotifyAncestor";
603 case NotifyVirtual: return "NotifyVirtual";
604 case NotifyInferior: return "NotifyInferior";
605 case NotifyNonlinear: return "NotifyNonlinear";
606 case NotifyNonlinearVirtual: return "NotifyNonlinearVirtual";
607 case NotifyPointer: return "NotifyPointer";
608 case NotifyPointerRoot: return "NotifyPointerRoot";
609 case NotifyDetailNone: return "NotifyDetailNone";
610 default: return "UNKNOWN";
614 static const char* fghVisibilityToString( int state ) {
616 case VisibilityUnobscured: return "VisibilityUnobscured";
617 case VisibilityPartiallyObscured: return "VisibilityPartiallyObscured";
618 case VisibilityFullyObscured: return "VisibilityFullyObscured";
619 default: return "UNKNOWN";
623 static const char* fghConfigureDetailToString( int detail )
626 case Above: return "Above";
627 case Below: return "Below";
628 case TopIf: return "TopIf";
629 case BottomIf: return "BottomIf";
630 case Opposite: return "Opposite";
631 default: return "UNKNOWN";
635 static const char* fghPlaceToString( int place )
638 case PlaceOnTop: return "PlaceOnTop";
639 case PlaceOnBottom: return "PlaceOnBottom";
640 default: return "UNKNOWN";
644 static const char* fghMappingRequestToString( int request )
647 case MappingModifier: return "MappingModifier";
648 case MappingKeyboard: return "MappingKeyboard";
649 case MappingPointer: return "MappingPointer";
650 default: return "UNKNOWN";
654 static const char* fghPropertyStateToString( int state )
657 case PropertyNewValue: return "PropertyNewValue";
658 case PropertyDelete: return "PropertyDelete";
659 default: return "UNKNOWN";
663 static const char* fghColormapStateToString( int state )
666 case ColormapUninstalled: return "ColormapUninstalled";
667 case ColormapInstalled: return "ColormapInstalled";
668 default: return "UNKNOWN";
672 static void fghPrintEvent( XEvent *event )
674 switch( event->type ) {
678 XKeyEvent *e = &event->xkey;
679 fgWarning( "%s: window=0x%x, root=0x%x, subwindow=0x%x, time=%lu, "
680 "(x,y)=(%d,%d), (x_root,y_root)=(%d,%d), state=0x%x, "
681 "keycode=%u, same_screen=%s", fghTypeToString( e->type ),
682 e->window, e->root, e->subwindow, (unsigned long)e->time,
683 e->x, e->y, e->x_root, e->y_root, e->state, e->keycode,
684 fghBoolToString( e->same_screen ) );
689 case ButtonRelease: {
690 XButtonEvent *e = &event->xbutton;
691 fgWarning( "%s: window=0x%x, root=0x%x, subwindow=0x%x, time=%lu, "
692 "(x,y)=(%d,%d), (x_root,y_root)=(%d,%d), state=0x%x, "
693 "button=%u, same_screen=%d", fghTypeToString( e->type ),
694 e->window, e->root, e->subwindow, (unsigned long)e->time,
695 e->x, e->y, e->x_root, e->y_root, e->state, e->button,
696 fghBoolToString( e->same_screen ) );
701 XMotionEvent *e = &event->xmotion;
702 fgWarning( "%s: window=0x%x, root=0x%x, subwindow=0x%x, time=%lu, "
703 "(x,y)=(%d,%d), (x_root,y_root)=(%d,%d), state=0x%x, "
704 "is_hint=%s, same_screen=%d", fghTypeToString( e->type ),
705 e->window, e->root, e->subwindow, (unsigned long)e->time,
706 e->x, e->y, e->x_root, e->y_root, e->state,
707 fghNotifyHintToString( e->is_hint ),
708 fghBoolToString( e->same_screen ) );
714 XCrossingEvent *e = &event->xcrossing;
715 fgWarning( "%s: window=0x%x, root=0x%x, subwindow=0x%x, time=%lu, "
716 "(x,y)=(%d,%d), mode=%s, detail=%s, same_screen=%d, "
717 "focus=%d, state=0x%x", fghTypeToString( e->type ),
718 e->window, e->root, e->subwindow, (unsigned long)e->time,
719 e->x, e->y, fghNotifyModeToString( e->mode ),
720 fghNotifyDetailToString( e->detail ), (int)e->same_screen,
721 (int)e->focus, e->state );
727 XFocusChangeEvent *e = &event->xfocus;
728 fgWarning( "%s: window=0x%x, mode=%s, detail=%s",
729 fghTypeToString( e->type ), e->window,
730 fghNotifyModeToString( e->mode ),
731 fghNotifyDetailToString( e->detail ) );
736 XKeymapEvent *e = &event->xkeymap;
737 char buf[32 * 2 + 1];
739 for ( i = 0; i < 32; i++ ) {
740 snprintf( &buf[ i * 2 ], sizeof( buf ) - i * 2,
741 "%02x", e->key_vector[ i ] );
744 fgWarning( "%s: window=0x%x, %s", fghTypeToString( e->type ), e->window,
750 XExposeEvent *e = &event->xexpose;
751 fgWarning( "%s: window=0x%x, (x,y)=(%d,%d), (width,height)=(%d,%d), "
752 "count=%d", fghTypeToString( e->type ), e->window, e->x,
753 e->y, e->width, e->height, e->count );
757 case GraphicsExpose: {
758 XGraphicsExposeEvent *e = &event->xgraphicsexpose;
759 fgWarning( "%s: drawable=0x%x, (x,y)=(%d,%d), (width,height)=(%d,%d), "
760 "count=%d, (major_code,minor_code)=(%d,%d)",
761 fghTypeToString( e->type ), e->drawable, e->x, e->y,
762 e->width, e->height, e->count, e->major_code,
768 XNoExposeEvent *e = &event->xnoexpose;
769 fgWarning( "%s: drawable=0x%x, (major_code,minor_code)=(%d,%d)",
770 fghTypeToString( e->type ), e->drawable, e->major_code,
775 case VisibilityNotify: {
776 XVisibilityEvent *e = &event->xvisibility;
777 fgWarning( "%s: window=0x%x, state=%s", fghTypeToString( e->type ),
778 e->window, fghVisibilityToString( e->state) );
783 XCreateWindowEvent *e = &event->xcreatewindow;
784 fgWarning( "%s: (x,y)=(%d,%d), (width,height)=(%d,%d), border_width=%d, "
785 "window=0x%x, override_redirect=%s",
786 fghTypeToString( e->type ), e->x, e->y, e->width, e->height,
787 e->border_width, e->window,
788 fghBoolToString( e->override_redirect ) );
792 case DestroyNotify: {
793 XDestroyWindowEvent *e = &event->xdestroywindow;
794 fgWarning( "%s: event=0x%x, window=0x%x",
795 fghTypeToString( e->type ), e->event, e->window );
800 XUnmapEvent *e = &event->xunmap;
801 fgWarning( "%s: event=0x%x, window=0x%x, from_configure=%s",
802 fghTypeToString( e->type ), e->event, e->window,
803 fghBoolToString( e->from_configure ) );
808 XMapEvent *e = &event->xmap;
809 fgWarning( "%s: event=0x%x, window=0x%x, override_redirect=%s",
810 fghTypeToString( e->type ), e->event, e->window,
811 fghBoolToString( e->override_redirect ) );
816 XMapRequestEvent *e = &event->xmaprequest;
817 fgWarning( "%s: parent=0x%x, window=0x%x",
818 fghTypeToString( event->type ), e->parent, e->window );
822 case ReparentNotify: {
823 XReparentEvent *e = &event->xreparent;
824 fgWarning( "%s: event=0x%x, window=0x%x, parent=0x%x, (x,y)=(%d,%d), "
825 "override_redirect=%s", fghTypeToString( e->type ),
826 e->event, e->window, e->parent, e->x, e->y,
827 fghBoolToString( e->override_redirect ) );
831 case ConfigureNotify: {
832 XConfigureEvent *e = &event->xconfigure;
833 fgWarning( "%s: event=0x%x, window=0x%x, (x,y)=(%d,%d), "
834 "(width,height)=(%d,%d), border_width=%d, above=0x%x, "
835 "override_redirect=%s", fghTypeToString( e->type ), e->event,
836 e->window, e->x, e->y, e->width, e->height, e->border_width,
837 e->above, fghBoolToString( e->override_redirect ) );
841 case ConfigureRequest: {
842 XConfigureRequestEvent *e = &event->xconfigurerequest;
843 fgWarning( "%s: parent=0x%x, window=0x%x, (x,y)=(%d,%d), "
844 "(width,height)=(%d,%d), border_width=%d, above=0x%x, "
845 "detail=%s, value_mask=%lx", fghTypeToString( e->type ),
846 e->parent, e->window, e->x, e->y, e->width, e->height,
847 e->border_width, e->above,
848 fghConfigureDetailToString( e->detail ), e->value_mask );
852 case GravityNotify: {
853 XGravityEvent *e = &event->xgravity;
854 fgWarning( "%s: event=0x%x, window=0x%x, (x,y)=(%d,%d)",
855 fghTypeToString( e->type ), e->event, e->window, e->x, e->y );
859 case ResizeRequest: {
860 XResizeRequestEvent *e = &event->xresizerequest;
861 fgWarning( "%s: window=0x%x, (width,height)=(%d,%d)",
862 fghTypeToString( e->type ), e->window, e->width, e->height );
866 case CirculateNotify: {
867 XCirculateEvent *e = &event->xcirculate;
868 fgWarning( "%s: event=0x%x, window=0x%x, place=%s",
869 fghTypeToString( e->type ), e->event, e->window,
870 fghPlaceToString( e->place ) );
874 case CirculateRequest: {
875 XCirculateRequestEvent *e = &event->xcirculaterequest;
876 fgWarning( "%s: parent=0x%x, window=0x%x, place=%s",
877 fghTypeToString( e->type ), e->parent, e->window,
878 fghPlaceToString( e->place ) );
882 case PropertyNotify: {
883 XPropertyEvent *e = &event->xproperty;
884 fgWarning( "%s: window=0x%x, atom=%lu, time=%lu, state=%s",
885 fghTypeToString( e->type ), e->window,
886 (unsigned long)e->atom, (unsigned long)e->time,
887 fghPropertyStateToString( e->state ) );
891 case SelectionClear: {
892 XSelectionClearEvent *e = &event->xselectionclear;
893 fgWarning( "%s: window=0x%x, selection=%lu, time=%lu",
894 fghTypeToString( e->type ), e->window,
895 (unsigned long)e->selection, (unsigned long)e->time );
899 case SelectionRequest: {
900 XSelectionRequestEvent *e = &event->xselectionrequest;
901 fgWarning( "%s: owner=0x%x, requestor=0x%x, selection=0x%x, "
902 "target=0x%x, property=%lu, time=%lu",
903 fghTypeToString( e->type ), e->owner, e->requestor,
904 (unsigned long)e->selection, (unsigned long)e->target,
905 (unsigned long)e->property, (unsigned long)e->time );
909 case SelectionNotify: {
910 XSelectionEvent *e = &event->xselection;
911 fgWarning( "%s: requestor=0x%x, selection=0x%x, target=0x%x, "
912 "property=%lu, time=%lu", fghTypeToString( e->type ),
913 e->requestor, (unsigned long)e->selection,
914 (unsigned long)e->target, (unsigned long)e->property,
915 (unsigned long)e->time );
919 case ColormapNotify: {
920 XColormapEvent *e = &event->xcolormap;
921 fgWarning( "%s: window=0x%x, colormap=%lu, new=%s, state=%s",
922 fghTypeToString( e->type ), e->window,
923 (unsigned long)e->colormap, fghBoolToString( e->new ),
924 fghColormapStateToString( e->state ) );
928 case ClientMessage: {
929 XClientMessageEvent *e = &event->xclient;
932 char* end = buf + sizeof( buf );
934 switch( e->format ) {
936 for ( i = 0; i < 20; i++, p += 3 ) {
937 snprintf( p, end - p, " %02x", e->data.b[ i ] );
941 for ( i = 0; i < 10; i++, p += 5 ) {
942 snprintf( p, end - p, " %04x", e->data.s[ i ] );
946 for ( i = 0; i < 5; i++, p += 9 ) {
947 snprintf( p, end - p, " %08lx", e->data.l[ i ] );
952 fgWarning( "%s: window=0x%x, message_type=%lu, format=%d, data=(%s )",
953 fghTypeToString( e->type ), e->window,
954 (unsigned long)e->message_type, e->format, buf );
958 case MappingNotify: {
959 XMappingEvent *e = &event->xmapping;
960 fgWarning( "%s: window=0x%x, request=%s, first_keycode=%d, count=%d",
961 fghTypeToString( e->type ), e->window,
962 fghMappingRequestToString( e->request ), e->first_keycode,
968 fgWarning( "%s", fghTypeToString( event->type ) );
976 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
979 * Executes a single iteration in the freeglut processing loop.
981 void FGAPIENTRY glutMainLoopEvent( void )
983 #if TARGET_HOST_POSIX_X11
987 /* This code was repeated constantly, so here it goes into a definition: */
988 #define GETWINDOW(a) \
989 window = fgWindowByHandle( event.a.window ); \
990 if( window == NULL ) \
993 #define GETMOUSE(a) \
994 window->State.MouseX = event.a.x; \
995 window->State.MouseY = event.a.y;
997 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoopEvent" );
999 while( XPending( fgDisplay.Display ) )
1001 XNextEvent( fgDisplay.Display, &event );
1003 fghPrintEvent( &event );
1006 switch( event.type )
1009 if(fgIsSpaceballXEvent(&event)) {
1010 fgSpaceballHandleXEvent(&event);
1013 /* Destroy the window when the WM_DELETE_WINDOW message arrives */
1014 if( (Atom) event.xclient.data.l[ 0 ] == fgDisplay.DeleteWindow )
1016 GETWINDOW( xclient );
1018 fgDestroyWindow ( window );
1020 if( fgState.ActionOnWindowClose == GLUT_ACTION_EXIT )
1025 else if( fgState.ActionOnWindowClose == GLUT_ACTION_GLUTMAINLOOP_RETURNS )
1026 fgState.ExecState = GLUT_EXEC_STATE_STOP;
1033 * CreateNotify causes a configure-event so that sub-windows are
1034 * handled compatibly with GLUT. Otherwise, your sub-windows
1035 * (in freeglut only) will not get an initial reshape event,
1036 * which can break things.
1038 * GLUT presumably does this because it generally tries to treat
1039 * sub-windows the same as windows.
1042 case ConfigureNotify:
1045 if( event.type == CreateNotify ) {
1046 GETWINDOW( xcreatewindow );
1047 width = event.xcreatewindow.width;
1048 height = event.xcreatewindow.height;
1050 GETWINDOW( xconfigure );
1051 width = event.xconfigure.width;
1052 height = event.xconfigure.height;
1055 if( ( width != window->State.OldWidth ) ||
1056 ( height != window->State.OldHeight ) )
1058 SFG_Window *current_window = fgStructure.CurrentWindow;
1060 window->State.OldWidth = width;
1061 window->State.OldHeight = height;
1062 if( FETCH_WCB( *window, Reshape ) )
1063 INVOKE_WCB( *window, Reshape, ( width, height ) );
1066 fgSetWindow( window );
1067 glViewport( 0, 0, width, height );
1069 glutPostRedisplay( );
1070 if( window->IsMenu )
1071 fgSetWindow( current_window );
1078 * This is sent to confirm the XDestroyWindow call.
1080 * XXX WHY is this commented out? Should we re-enable it?
1082 /* fgAddToWindowDestroyList ( window ); */
1087 * We are too dumb to process partial exposes...
1089 * XXX Well, we could do it. However, it seems to only
1090 * XXX be potentially useful for single-buffered (since
1091 * XXX double-buffered does not respect viewport when we
1092 * XXX do a buffer-swap).
1095 if( event.xexpose.count == 0 )
1097 GETWINDOW( xexpose );
1098 window->State.Redisplay = GL_TRUE;
1106 /* We get this when iconifying a window. */
1107 GETWINDOW( xunmap );
1108 INVOKE_WCB( *window, WindowStatus, ( GLUT_HIDDEN ) );
1109 window->State.Visible = GL_FALSE;
1114 * Have the client's keyboard knowledge updated (xlib.ps,
1115 * page 206, says that's a good thing to do)
1117 XRefreshKeyboardMapping( (XMappingEvent *) &event );
1120 case VisibilityNotify:
1123 * Sending this event, the X server can notify us that the window
1124 * has just acquired one of the three possible visibility states:
1125 * VisibilityUnobscured, VisibilityPartiallyObscured or
1126 * VisibilityFullyObscured. Note that we DO NOT receive a
1127 * VisibilityNotify event when iconifying a window, we only get an
1130 GETWINDOW( xvisibility );
1131 switch( event.xvisibility.state )
1133 case VisibilityUnobscured:
1134 INVOKE_WCB( *window, WindowStatus, ( GLUT_FULLY_RETAINED ) );
1135 window->State.Visible = GL_TRUE;
1138 case VisibilityPartiallyObscured:
1139 INVOKE_WCB( *window, WindowStatus,
1140 ( GLUT_PARTIALLY_RETAINED ) );
1141 window->State.Visible = GL_TRUE;
1144 case VisibilityFullyObscured:
1145 INVOKE_WCB( *window, WindowStatus, ( GLUT_FULLY_COVERED ) );
1146 window->State.Visible = GL_FALSE;
1150 fgWarning( "Unknown X visibility state: %d",
1151 event.xvisibility.state );
1159 GETWINDOW( xcrossing );
1160 GETMOUSE( xcrossing );
1161 if( ( event.type == LeaveNotify ) && window->IsMenu &&
1162 window->ActiveMenu && window->ActiveMenu->IsActive )
1163 fgUpdateMenuHighlight( window->ActiveMenu );
1165 INVOKE_WCB( *window, Entry, ( ( EnterNotify == event.type ) ?
1172 GETWINDOW( xmotion );
1173 GETMOUSE( xmotion );
1175 if( window->ActiveMenu )
1177 if( window == window->ActiveMenu->ParentWindow )
1179 window->ActiveMenu->Window->State.MouseX =
1180 event.xmotion.x_root - window->ActiveMenu->X;
1181 window->ActiveMenu->Window->State.MouseY =
1182 event.xmotion.y_root - window->ActiveMenu->Y;
1185 fgUpdateMenuHighlight( window->ActiveMenu );
1191 * XXX For more than 5 buttons, just check {event.xmotion.state},
1192 * XXX rather than a host of bit-masks? Or maybe we need to
1193 * XXX track ButtonPress/ButtonRelease events in our own
1196 fgState.Modifiers = fghGetXModifiers( event.xmotion.state );
1197 if ( event.xmotion.state & ( Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask ) ) {
1198 INVOKE_WCB( *window, Motion, ( event.xmotion.x,
1199 event.xmotion.y ) );
1201 INVOKE_WCB( *window, Passive, ( event.xmotion.x,
1202 event.xmotion.y ) );
1204 fgState.Modifiers = INVALID_MODIFIERS;
1211 GLboolean pressed = GL_TRUE;
1214 if( event.type == ButtonRelease )
1215 pressed = GL_FALSE ;
1218 * A mouse button has been pressed or released. Traditionally,
1219 * break if the window was found within the freeglut structures.
1221 GETWINDOW( xbutton );
1222 GETMOUSE( xbutton );
1225 * An X button (at least in XFree86) is numbered from 1.
1226 * A GLUT button is numbered from 0.
1227 * Old GLUT passed through buttons other than just the first
1228 * three, though it only gave symbolic names and official
1229 * support to the first three.
1231 button = event.xbutton.button - 1;
1234 * Do not execute the application's mouse callback if a menu
1235 * is hooked to this button. In that case an appropriate
1236 * private call should be generated.
1238 if( fgCheckActiveMenu( window, button, pressed,
1239 event.xbutton.x_root, event.xbutton.y_root ) )
1243 * Check if there is a mouse or mouse wheel callback hooked to the
1246 if( ! FETCH_WCB( *window, Mouse ) &&
1247 ! FETCH_WCB( *window, MouseWheel ) )
1250 fgState.Modifiers = fghGetXModifiers( event.xbutton.state );
1252 /* Finally execute the mouse or mouse wheel callback */
1253 if( ( button < glutDeviceGet ( GLUT_NUM_MOUSE_BUTTONS ) ) || ( ! FETCH_WCB( *window, MouseWheel ) ) )
1254 INVOKE_WCB( *window, Mouse, ( button,
1255 pressed ? GLUT_DOWN : GLUT_UP,
1262 * Map 4 and 5 to wheel zero; EVEN to +1, ODD to -1
1263 * " 6 and 7 " " one; ...
1265 * XXX This *should* be behind some variables/macros,
1266 * XXX since the order and numbering isn't certain
1267 * XXX See XFree86 configuration docs (even back in the
1268 * XXX 3.x days, and especially with 4.x).
1270 * XXX Note that {button} has already been decremeted
1271 * XXX in mapping from X button numbering to GLUT.
1273 int wheel_number = (button - glutDeviceGet ( GLUT_NUM_MOUSE_BUTTONS )) / 2;
1279 INVOKE_WCB( *window, MouseWheel, ( wheel_number,
1285 fgState.Modifiers = INVALID_MODIFIERS;
1292 FGCBKeyboard keyboard_cb;
1293 FGCBSpecial special_cb;
1298 /* Detect auto repeated keys, if configured globally or per-window */
1300 if ( fgState.KeyRepeat==GLUT_KEY_REPEAT_OFF || window->State.IgnoreKeyRepeat==GL_TRUE )
1302 if (event.type==KeyRelease)
1305 * Look at X11 keystate to detect repeat mode.
1306 * While X11 says the key is actually held down, we'll ignore KeyRelease/KeyPress pairs.
1310 XQueryKeymap( fgDisplay.Display, keys ); /* Look at X11 keystate to detect repeat mode */
1312 if ( event.xkey.keycode<256 ) /* XQueryKeymap is limited to 256 keycodes */
1314 if ( keys[event.xkey.keycode>>3] & (1<<(event.xkey.keycode%8)) )
1315 window->State.KeyRepeating = GL_TRUE;
1317 window->State.KeyRepeating = GL_FALSE;
1322 window->State.KeyRepeating = GL_FALSE;
1324 /* Cease processing this event if it is auto repeated */
1326 if (window->State.KeyRepeating)
1328 if (event.type == KeyPress) window->State.KeyRepeating = GL_FALSE;
1332 if( event.type == KeyPress )
1334 keyboard_cb = (FGCBKeyboard)( FETCH_WCB( *window, Keyboard ));
1335 special_cb = (FGCBSpecial) ( FETCH_WCB( *window, Special ));
1339 keyboard_cb = (FGCBKeyboard)( FETCH_WCB( *window, KeyboardUp ));
1340 special_cb = (FGCBSpecial) ( FETCH_WCB( *window, SpecialUp ));
1343 /* Is there a keyboard/special callback hooked for this window? */
1344 if( keyboard_cb || special_cb )
1346 XComposeStatus composeStatus;
1347 char asciiCode[ 32 ];
1351 /* Check for the ASCII/KeySym codes associated with the event: */
1352 len = XLookupString( &event.xkey, asciiCode, sizeof(asciiCode),
1353 &keySym, &composeStatus
1356 /* GLUT API tells us to have two separate callbacks... */
1359 /* ...one for the ASCII translateable keypresses... */
1362 fgSetWindow( window );
1363 fgState.Modifiers = fghGetXModifiers( event.xkey.state );
1364 keyboard_cb( asciiCode[ 0 ],
1365 event.xkey.x, event.xkey.y
1367 fgState.Modifiers = INVALID_MODIFIERS;
1375 * ...and one for all the others, which need to be
1376 * translated to GLUT_KEY_Xs...
1380 case XK_F1: special = GLUT_KEY_F1; break;
1381 case XK_F2: special = GLUT_KEY_F2; break;
1382 case XK_F3: special = GLUT_KEY_F3; break;
1383 case XK_F4: special = GLUT_KEY_F4; break;
1384 case XK_F5: special = GLUT_KEY_F5; break;
1385 case XK_F6: special = GLUT_KEY_F6; break;
1386 case XK_F7: special = GLUT_KEY_F7; break;
1387 case XK_F8: special = GLUT_KEY_F8; break;
1388 case XK_F9: special = GLUT_KEY_F9; break;
1389 case XK_F10: special = GLUT_KEY_F10; break;
1390 case XK_F11: special = GLUT_KEY_F11; break;
1391 case XK_F12: special = GLUT_KEY_F12; break;
1394 case XK_Left: special = GLUT_KEY_LEFT; break;
1396 case XK_Right: special = GLUT_KEY_RIGHT; break;
1398 case XK_Up: special = GLUT_KEY_UP; break;
1400 case XK_Down: special = GLUT_KEY_DOWN; break;
1403 case XK_Prior: special = GLUT_KEY_PAGE_UP; break;
1405 case XK_Next: special = GLUT_KEY_PAGE_DOWN; break;
1407 case XK_Home: special = GLUT_KEY_HOME; break;
1409 case XK_End: special = GLUT_KEY_END; break;
1411 case XK_Insert: special = GLUT_KEY_INSERT; break;
1413 case XK_Num_Lock : special = GLUT_KEY_NUM_LOCK; break;
1414 case XK_KP_Begin : special = GLUT_KEY_BEGIN; break;
1415 case XK_KP_Delete: special = GLUT_KEY_DELETE; break;
1417 case XK_Shift_L: special = GLUT_KEY_SHIFT_L; break;
1418 case XK_Shift_R: special = GLUT_KEY_SHIFT_R; break;
1419 case XK_Control_L: special = GLUT_KEY_CTRL_L; break;
1420 case XK_Control_R: special = GLUT_KEY_CTRL_R; break;
1421 case XK_Alt_L: special = GLUT_KEY_ALT_L; break;
1422 case XK_Alt_R: special = GLUT_KEY_ALT_R; break;
1426 * Execute the callback (if one has been specified),
1427 * given that the special code seems to be valid...
1429 if( special_cb && (special != -1) )
1431 fgSetWindow( window );
1432 fgState.Modifiers = fghGetXModifiers( event.xkey.state );
1433 special_cb( special, event.xkey.x, event.xkey.y );
1434 fgState.Modifiers = INVALID_MODIFIERS;
1441 case ReparentNotify:
1442 break; /* XXX Should disable this event */
1449 /* enter handling of Extension Events here */
1450 #ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
1451 fgHandleExtensionEvents( &event );
1457 #elif TARGET_HOST_MS_WINDOWS
1461 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoopEvent" );
1463 while( PeekMessage( &stMsg, NULL, 0, 0, PM_NOREMOVE ) )
1465 if( GetMessage( &stMsg, NULL, 0, 0 ) == 0 )
1467 if( fgState.ActionOnWindowClose == GLUT_ACTION_EXIT )
1472 else if( fgState.ActionOnWindowClose == GLUT_ACTION_GLUTMAINLOOP_RETURNS )
1473 fgState.ExecState = GLUT_EXEC_STATE_STOP;
1478 TranslateMessage( &stMsg );
1479 DispatchMessage( &stMsg );
1483 if( fgState.Timers.First )
1485 fghCheckJoystickPolls( );
1492 * Enters the freeglut processing loop.
1493 * Stays until the "ExecState" changes to "GLUT_EXEC_STATE_STOP".
1495 void FGAPIENTRY glutMainLoop( void )
1499 #if TARGET_HOST_MS_WINDOWS
1500 SFG_Window *window = (SFG_Window *)fgStructure.Windows.First ;
1503 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoop" );
1505 #if TARGET_HOST_MS_WINDOWS
1507 * Processing before the main loop: If there is a window which is open and
1508 * which has a visibility callback, call it. I know this is an ugly hack,
1509 * but I'm not sure what else to do about it. Ideally we should leave
1510 * something uninitialized in the create window code and initialize it in
1511 * the main loop, and have that initialization create a "WM_ACTIVATE"
1512 * message. Then we would put the visibility callback code in the
1513 * "case WM_ACTIVATE" block below. - John Fay -- 10/24/02
1517 if ( FETCH_WCB( *window, Visibility ) )
1519 SFG_Window *current_window = fgStructure.CurrentWindow ;
1521 INVOKE_WCB( *window, Visibility, ( window->State.Visible ) );
1522 fgSetWindow( current_window );
1525 window = (SFG_Window *)window->Node.Next ;
1529 fgState.ExecState = GLUT_EXEC_STATE_RUNNING ;
1530 while( fgState.ExecState == GLUT_EXEC_STATE_RUNNING )
1534 glutMainLoopEvent( );
1536 * Step through the list of windows, seeing if there are any
1537 * that are not menus
1539 for( window = ( SFG_Window * )fgStructure.Windows.First;
1541 window = ( SFG_Window * )window->Node.Next )
1542 if ( ! ( window->IsMenu ) )
1546 fgState.ExecState = GLUT_EXEC_STATE_STOP;
1549 if( fgState.IdleCallback )
1551 if( fgStructure.CurrentWindow &&
1552 fgStructure.CurrentWindow->IsMenu )
1554 fgSetWindow( window );
1555 fgState.IdleCallback( );
1558 fghSleepForEvents( );
1563 * When this loop terminates, destroy the display, state and structure
1564 * of a freeglut session, so that another glutInit() call can happen
1566 * Save the "ActionOnWindowClose" because "fgDeinitialize" resets it.
1568 action = fgState.ActionOnWindowClose;
1570 if( action == GLUT_ACTION_EXIT )
1575 * Leaves the freeglut processing loop.
1577 void FGAPIENTRY glutLeaveMainLoop( void )
1579 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLeaveMainLoop" );
1580 fgState.ExecState = GLUT_EXEC_STATE_STOP ;
1584 #if TARGET_HOST_MS_WINDOWS
1586 * Determine a GLUT modifer mask based on MS-WINDOWS system info.
1588 static int fghGetWin32Modifiers (void)
1591 ( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
1592 ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
1593 ( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
1594 ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
1595 ( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
1596 ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
1600 * The window procedure for handling Win32 events
1602 LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
1605 static unsigned char lControl = 0, rControl = 0, lShift = 0,
1606 rShift = 0, lAlt = 0, rAlt = 0;
1612 FREEGLUT_INTERNAL_ERROR_EXIT_IF_NOT_INITIALISED ( "Event Handler" ) ;
1614 window = fgWindowByHandle( hWnd );
1616 if ( ( window == NULL ) && ( uMsg != WM_CREATE ) )
1617 return DefWindowProc( hWnd, uMsg, wParam, lParam );
1619 /* printf ( "Window %3d message <%04x> %12d %12d\n", window?window->ID:0,
1620 uMsg, wParam, lParam ); */
1624 /* Checking for CTRL, ALT, and SHIFT key positions: Key Down! */
1625 if ( !lControl && GetAsyncKeyState ( VK_LCONTROL ) )
1627 INVOKE_WCB ( *window, Special,
1628 ( GLUT_KEY_CTRL_L, window->State.MouseX, window->State.MouseY )
1634 if ( !rControl && GetAsyncKeyState ( VK_RCONTROL ) )
1636 INVOKE_WCB ( *window, Special,
1637 ( GLUT_KEY_CTRL_R, window->State.MouseX, window->State.MouseY )
1643 if ( !lShift && GetAsyncKeyState ( VK_LSHIFT ) )
1645 INVOKE_WCB ( *window, Special,
1646 ( GLUT_KEY_SHIFT_L, window->State.MouseX, window->State.MouseY )
1652 if ( !rShift && GetAsyncKeyState ( VK_RSHIFT ) )
1654 INVOKE_WCB ( *window, Special,
1655 ( GLUT_KEY_SHIFT_R, window->State.MouseX, window->State.MouseY )
1661 if ( !lAlt && GetAsyncKeyState ( VK_LMENU ) )
1663 INVOKE_WCB ( *window, Special,
1664 ( GLUT_KEY_ALT_L, window->State.MouseX, window->State.MouseY )
1670 if ( !rAlt && GetAsyncKeyState ( VK_RMENU ) )
1672 INVOKE_WCB ( *window, Special,
1673 ( GLUT_KEY_ALT_R, window->State.MouseX, window->State.MouseY )
1679 /* Checking for CTRL, ALT, and SHIFT key positions: Key Up! */
1680 if ( lControl && !GetAsyncKeyState ( VK_LCONTROL ) )
1682 INVOKE_WCB ( *window, SpecialUp,
1683 ( GLUT_KEY_CTRL_L, window->State.MouseX, window->State.MouseY )
1689 if ( rControl && !GetAsyncKeyState ( VK_RCONTROL ) )
1691 INVOKE_WCB ( *window, SpecialUp,
1692 ( GLUT_KEY_CTRL_R, window->State.MouseX, window->State.MouseY )
1698 if ( lShift && !GetAsyncKeyState ( VK_LSHIFT ) )
1700 INVOKE_WCB ( *window, SpecialUp,
1701 ( GLUT_KEY_SHIFT_L, window->State.MouseX, window->State.MouseY )
1707 if ( rShift && !GetAsyncKeyState ( VK_RSHIFT ) )
1709 INVOKE_WCB ( *window, SpecialUp,
1710 ( GLUT_KEY_SHIFT_R, window->State.MouseX, window->State.MouseY )
1716 if ( lAlt && !GetAsyncKeyState ( VK_LMENU ) )
1718 INVOKE_WCB ( *window, SpecialUp,
1719 ( GLUT_KEY_ALT_L, window->State.MouseX, window->State.MouseY )
1725 if ( rAlt && !GetAsyncKeyState ( VK_RMENU ) )
1727 INVOKE_WCB ( *window, SpecialUp,
1728 ( GLUT_KEY_ALT_R, window->State.MouseX, window->State.MouseY )
1738 /* The window structure is passed as the creation structure paramter... */
1739 window = (SFG_Window *) (((LPCREATESTRUCT) lParam)->lpCreateParams);
1740 FREEGLUT_INTERNAL_ERROR_EXIT ( ( window != NULL ), "Cannot create window",
1743 window->Window.Handle = hWnd;
1744 window->Window.Device = GetDC( hWnd );
1745 if( window->IsMenu )
1747 unsigned int current_DisplayMode = fgState.DisplayMode;
1748 fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH;
1749 #if !defined(_WIN32_WCE)
1750 fgSetupPixelFormat( window, GL_FALSE, PFD_MAIN_PLANE );
1752 fgState.DisplayMode = current_DisplayMode;
1754 if( fgStructure.MenuContext )
1755 wglMakeCurrent( window->Window.Device,
1756 fgStructure.MenuContext->MContext
1760 fgStructure.MenuContext =
1761 (SFG_MenuContext *)malloc( sizeof(SFG_MenuContext) );
1762 fgStructure.MenuContext->MContext =
1763 wglCreateContext( window->Window.Device );
1766 /* window->Window.Context = wglGetCurrentContext (); */
1767 window->Window.Context = wglCreateContext( window->Window.Device );
1771 #if !defined(_WIN32_WCE)
1772 fgSetupPixelFormat( window, GL_FALSE, PFD_MAIN_PLANE );
1775 if( ! fgState.UseCurrentContext )
1776 window->Window.Context =
1777 wglCreateContext( window->Window.Device );
1780 window->Window.Context = wglGetCurrentContext( );
1781 if( ! window->Window.Context )
1782 window->Window.Context =
1783 wglCreateContext( window->Window.Device );
1786 #if !defined(_WIN32_WCE)
1787 fgNewWGLCreateContext( window );
1791 window->State.NeedToResize = GL_TRUE;
1792 if( ( window->State.Width < 0 ) || ( window->State.Height < 0 ) )
1794 SFG_Window *current_window = fgStructure.CurrentWindow;
1796 fgSetWindow( window );
1797 window->State.Width = glutGet( GLUT_WINDOW_WIDTH );
1798 window->State.Height = glutGet( GLUT_WINDOW_HEIGHT );
1799 fgSetWindow( current_window );
1802 ReleaseDC( window->Window.Handle, window->Window.Device );
1804 #if defined(_WIN32_WCE)
1805 /* Take over button handling */
1807 HINSTANCE dxDllLib=LoadLibrary(_T("gx.dll"));
1810 GXGetDefaultKeys_=(GXGETDEFAULTKEYS)GetProcAddress(dxDllLib, _T("?GXGetDefaultKeys@@YA?AUGXKeyList@@H@Z"));
1811 GXOpenInput_=(GXOPENINPUT)GetProcAddress(dxDllLib, _T("?GXOpenInput@@YAHXZ"));
1816 if(GXGetDefaultKeys_)
1817 gxKeyList = (*GXGetDefaultKeys_)(GX_LANDSCAPEKEYS);
1820 #endif /* defined(_WIN32_WCE) */
1825 * If the window is visible, then it is the user manually resizing it.
1826 * If it is not, then it is the system sending us a dummy resize with
1827 * zero dimensions on a "glutIconifyWindow" call.
1829 if( window->State.Visible )
1831 window->State.NeedToResize = GL_TRUE;
1832 #if defined(_WIN32_WCE)
1833 window->State.Width = HIWORD(lParam);
1834 window->State.Height = LOWORD(lParam);
1836 window->State.Width = LOWORD(lParam);
1837 window->State.Height = HIWORD(lParam);
1838 #endif /* defined(_WIN32_WCE) */
1844 /* printf("WM_SETFOCUS: %p\n", window ); */
1845 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1846 INVOKE_WCB( *window, Entry, ( GLUT_ENTERED ) );
1850 /* printf("WM_KILLFOCUS: %p\n", window ); */
1851 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1852 INVOKE_WCB( *window, Entry, ( GLUT_LEFT ) );
1854 if( window->IsMenu &&
1855 window->ActiveMenu && window->ActiveMenu->IsActive )
1856 fgUpdateMenuHighlight( window->ActiveMenu );
1862 if (LOWORD(wParam) != WA_INACTIVE)
1864 /* printf("WM_ACTIVATE: fgSetCursor( %p, %d)\n", window,
1865 window->State.Cursor ); */
1866 fgSetCursor( window, window->State.Cursor );
1869 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1874 /* printf ( "Cursor event %x %x %x %x\n", window, window->State.Cursor, lParam, wParam ) ; */
1875 if( LOWORD( lParam ) == HTCLIENT )
1876 fgSetCursor ( window, window->State.Cursor ) ;
1878 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
1882 window->State.Visible = GL_TRUE;
1883 window->State.Redisplay = GL_TRUE;
1887 /* Turn on the visibility in case it was turned off somehow */
1888 window->State.Visible = GL_TRUE;
1889 BeginPaint( hWnd, &ps );
1890 fghRedrawWindow( window );
1891 EndPaint( hWnd, &ps );
1895 fgDestroyWindow ( window );
1896 if ( fgState.ActionOnWindowClose != GLUT_ACTION_CONTINUE_EXECUTION )
1902 * The window already got destroyed, so don't bother with it.
1908 #if defined(_WIN32_WCE)
1909 window->State.MouseX = 320-HIWORD( lParam );
1910 window->State.MouseY = LOWORD( lParam );
1912 window->State.MouseX = LOWORD( lParam );
1913 window->State.MouseY = HIWORD( lParam );
1914 #endif /* defined(_WIN32_WCE) */
1915 /* Restrict to [-32768, 32767] to match X11 behaviour */
1916 /* See comment in "freeglut_developer" mailing list 10/4/04 */
1917 if ( window->State.MouseX > 32767 ) window->State.MouseX -= 65536;
1918 if ( window->State.MouseY > 32767 ) window->State.MouseY -= 65536;
1920 if ( window->ActiveMenu )
1922 fgUpdateMenuHighlight( window->ActiveMenu );
1925 SetFocus(window->Window.Handle);
1927 fgState.Modifiers = fghGetWin32Modifiers( );
1929 if( ( wParam & MK_LBUTTON ) ||
1930 ( wParam & MK_MBUTTON ) ||
1931 ( wParam & MK_RBUTTON ) )
1932 INVOKE_WCB( *window, Motion, ( window->State.MouseX,
1933 window->State.MouseY ) );
1935 INVOKE_WCB( *window, Passive, ( window->State.MouseX,
1936 window->State.MouseY ) );
1938 fgState.Modifiers = INVALID_MODIFIERS;
1942 case WM_LBUTTONDOWN:
1943 case WM_MBUTTONDOWN:
1944 case WM_RBUTTONDOWN:
1949 GLboolean pressed = GL_TRUE;
1952 #if defined(_WIN32_WCE)
1953 window->State.MouseX = 320-HIWORD( lParam );
1954 window->State.MouseY = LOWORD( lParam );
1956 window->State.MouseX = LOWORD( lParam );
1957 window->State.MouseY = HIWORD( lParam );
1958 #endif /* defined(_WIN32_WCE) */
1960 /* Restrict to [-32768, 32767] to match X11 behaviour */
1961 /* See comment in "freeglut_developer" mailing list 10/4/04 */
1962 if ( window->State.MouseX > 32767 ) window->State.MouseX -= 65536;
1963 if ( window->State.MouseY > 32767 ) window->State.MouseY -= 65536;
1967 case WM_LBUTTONDOWN:
1969 button = GLUT_LEFT_BUTTON;
1971 case WM_MBUTTONDOWN:
1973 button = GLUT_MIDDLE_BUTTON;
1975 case WM_RBUTTONDOWN:
1977 button = GLUT_RIGHT_BUTTON;
1981 button = GLUT_LEFT_BUTTON;
1985 button = GLUT_MIDDLE_BUTTON;
1989 button = GLUT_RIGHT_BUTTON;
1997 #if !defined(_WIN32_WCE)
1998 if( GetSystemMetrics( SM_SWAPBUTTON ) )
2000 if( button == GLUT_LEFT_BUTTON )
2001 button = GLUT_RIGHT_BUTTON;
2003 if( button == GLUT_RIGHT_BUTTON )
2004 button = GLUT_LEFT_BUTTON;
2006 #endif /* !defined(_WIN32_WCE) */
2009 return DefWindowProc( hWnd, uMsg, lParam, wParam );
2012 * Do not execute the application's mouse callback if a menu
2013 * is hooked to this button. In that case an appropriate
2014 * private call should be generated.
2016 if( fgCheckActiveMenu( window, button, pressed,
2017 window->State.MouseX, window->State.MouseY ) )
2020 /* Set capture so that the window captures all the mouse messages */
2022 * XXX - Multiple button support: Under X11, the mouse is not released
2023 * XXX - from the window until all buttons have been released, even if the
2024 * XXX - user presses a button in another window. This will take more
2025 * XXX - code changes than I am up to at the moment (10/5/04). The present
2026 * XXX - is a 90 percent solution.
2028 if ( pressed == GL_TRUE )
2029 SetCapture ( window->Window.Handle ) ;
2033 if( ! FETCH_WCB( *window, Mouse ) )
2036 fgSetWindow( window );
2037 fgState.Modifiers = fghGetWin32Modifiers( );
2042 pressed ? GLUT_DOWN : GLUT_UP,
2043 window->State.MouseX,
2044 window->State.MouseY
2048 fgState.Modifiers = INVALID_MODIFIERS;
2053 /* Should be WM_MOUSEWHEEL but my compiler doesn't recognize it */
2056 * XXX THIS IS SPECULATIVE -- John Fay, 10/2/03
2057 * XXX Should use WHEEL_DELTA instead of 120
2059 int wheel_number = LOWORD( wParam );
2060 short ticks = ( short )HIWORD( wParam ) / 120;
2070 * The mouse cursor has moved. Remember the new mouse cursor's position
2072 /* window->State.MouseX = LOWORD( lParam ); */
2073 /* Need to adjust by window position, */
2074 /* window->State.MouseY = HIWORD( lParam ); */
2075 /* change "lParam" to other parameter */
2077 if( ! FETCH_WCB( *window, MouseWheel ) &&
2078 ! FETCH_WCB( *window, Mouse ) )
2081 fgSetWindow( window );
2082 fgState.Modifiers = fghGetWin32Modifiers( );
2085 if( FETCH_WCB( *window, MouseWheel ) )
2086 INVOKE_WCB( *window, MouseWheel,
2089 window->State.MouseX,
2090 window->State.MouseY
2093 else /* No mouse wheel, call the mouse button callback twice */
2096 * Map wheel zero to button 3 and 4; +1 to 3, -1 to 4
2097 * " " one +1 to 5, -1 to 6, ...
2099 * XXX The below assumes that you have no more than 3 mouse
2100 * XXX buttons. Sorry.
2102 int button = wheel_number * 2 + 3;
2105 INVOKE_WCB( *window, Mouse,
2106 ( button, GLUT_DOWN,
2107 window->State.MouseX, window->State.MouseY )
2109 INVOKE_WCB( *window, Mouse,
2111 window->State.MouseX, window->State.MouseY )
2115 fgState.Modifiers = INVALID_MODIFIERS;
2125 if( ( fgState.KeyRepeat==GLUT_KEY_REPEAT_OFF || window->State.IgnoreKeyRepeat==GL_TRUE ) && (HIWORD(lParam) & KF_REPEAT) )
2129 * Remember the current modifiers state. This is done here in order
2130 * to make sure the VK_DELETE keyboard callback is executed properly.
2132 fgState.Modifiers = fghGetWin32Modifiers( );
2134 GetCursorPos( &mouse_pos );
2135 ScreenToClient( window->Window.Handle, &mouse_pos );
2137 window->State.MouseX = mouse_pos.x;
2138 window->State.MouseY = mouse_pos.y;
2140 /* Convert the Win32 keystroke codes to GLUTtish way */
2141 # define KEY(a,b) case a: keypress = b; break;
2145 KEY( VK_F1, GLUT_KEY_F1 );
2146 KEY( VK_F2, GLUT_KEY_F2 );
2147 KEY( VK_F3, GLUT_KEY_F3 );
2148 KEY( VK_F4, GLUT_KEY_F4 );
2149 KEY( VK_F5, GLUT_KEY_F5 );
2150 KEY( VK_F6, GLUT_KEY_F6 );
2151 KEY( VK_F7, GLUT_KEY_F7 );
2152 KEY( VK_F8, GLUT_KEY_F8 );
2153 KEY( VK_F9, GLUT_KEY_F9 );
2154 KEY( VK_F10, GLUT_KEY_F10 );
2155 KEY( VK_F11, GLUT_KEY_F11 );
2156 KEY( VK_F12, GLUT_KEY_F12 );
2157 KEY( VK_PRIOR, GLUT_KEY_PAGE_UP );
2158 KEY( VK_NEXT, GLUT_KEY_PAGE_DOWN );
2159 KEY( VK_HOME, GLUT_KEY_HOME );
2160 KEY( VK_END, GLUT_KEY_END );
2161 KEY( VK_LEFT, GLUT_KEY_LEFT );
2162 KEY( VK_UP, GLUT_KEY_UP );
2163 KEY( VK_RIGHT, GLUT_KEY_RIGHT );
2164 KEY( VK_DOWN, GLUT_KEY_DOWN );
2165 KEY( VK_INSERT, GLUT_KEY_INSERT );
2166 KEY( VK_LCONTROL, GLUT_KEY_CTRL_L );
2167 KEY( VK_RCONTROL, GLUT_KEY_CTRL_R );
2168 KEY( VK_LSHIFT, GLUT_KEY_SHIFT_L );
2169 KEY( VK_RSHIFT, GLUT_KEY_SHIFT_R );
2170 KEY( VK_LMENU, GLUT_KEY_ALT_L );
2171 KEY( VK_RMENU, GLUT_KEY_ALT_R );
2174 /* The delete key should be treated as an ASCII keypress: */
2175 INVOKE_WCB( *window, Keyboard,
2176 ( 127, window->State.MouseX, window->State.MouseY )
2180 #if defined(_WIN32_WCE)
2181 if(!(lParam & 0x40000000)) /* Prevent auto-repeat */
2183 if(wParam==(unsigned)gxKeyList.vkRight)
2184 keypress = GLUT_KEY_RIGHT;
2185 else if(wParam==(unsigned)gxKeyList.vkLeft)
2186 keypress = GLUT_KEY_LEFT;
2187 else if(wParam==(unsigned)gxKeyList.vkUp)
2188 keypress = GLUT_KEY_UP;
2189 else if(wParam==(unsigned)gxKeyList.vkDown)
2190 keypress = GLUT_KEY_DOWN;
2191 else if(wParam==(unsigned)gxKeyList.vkA)
2192 keypress = GLUT_KEY_F1;
2193 else if(wParam==(unsigned)gxKeyList.vkB)
2194 keypress = GLUT_KEY_F2;
2195 else if(wParam==(unsigned)gxKeyList.vkC)
2196 keypress = GLUT_KEY_F3;
2197 else if(wParam==(unsigned)gxKeyList.vkStart)
2198 keypress = GLUT_KEY_F4;
2202 if( keypress != -1 )
2203 INVOKE_WCB( *window, Special,
2205 window->State.MouseX, window->State.MouseY )
2208 fgState.Modifiers = INVALID_MODIFIERS;
2219 * Remember the current modifiers state. This is done here in order
2220 * to make sure the VK_DELETE keyboard callback is executed properly.
2222 fgState.Modifiers = fghGetWin32Modifiers( );
2224 GetCursorPos( &mouse_pos );
2225 ScreenToClient( window->Window.Handle, &mouse_pos );
2227 window->State.MouseX = mouse_pos.x;
2228 window->State.MouseY = mouse_pos.y;
2231 * Convert the Win32 keystroke codes to GLUTtish way.
2232 * "KEY(a,b)" was defined under "WM_KEYDOWN"
2237 KEY( VK_F1, GLUT_KEY_F1 );
2238 KEY( VK_F2, GLUT_KEY_F2 );
2239 KEY( VK_F3, GLUT_KEY_F3 );
2240 KEY( VK_F4, GLUT_KEY_F4 );
2241 KEY( VK_F5, GLUT_KEY_F5 );
2242 KEY( VK_F6, GLUT_KEY_F6 );
2243 KEY( VK_F7, GLUT_KEY_F7 );
2244 KEY( VK_F8, GLUT_KEY_F8 );
2245 KEY( VK_F9, GLUT_KEY_F9 );
2246 KEY( VK_F10, GLUT_KEY_F10 );
2247 KEY( VK_F11, GLUT_KEY_F11 );
2248 KEY( VK_F12, GLUT_KEY_F12 );
2249 KEY( VK_PRIOR, GLUT_KEY_PAGE_UP );
2250 KEY( VK_NEXT, GLUT_KEY_PAGE_DOWN );
2251 KEY( VK_HOME, GLUT_KEY_HOME );
2252 KEY( VK_END, GLUT_KEY_END );
2253 KEY( VK_LEFT, GLUT_KEY_LEFT );
2254 KEY( VK_UP, GLUT_KEY_UP );
2255 KEY( VK_RIGHT, GLUT_KEY_RIGHT );
2256 KEY( VK_DOWN, GLUT_KEY_DOWN );
2257 KEY( VK_INSERT, GLUT_KEY_INSERT );
2258 KEY( VK_LCONTROL, GLUT_KEY_CTRL_L );
2259 KEY( VK_RCONTROL, GLUT_KEY_CTRL_R );
2260 KEY( VK_LSHIFT, GLUT_KEY_SHIFT_L );
2261 KEY( VK_RSHIFT, GLUT_KEY_SHIFT_R );
2262 KEY( VK_LMENU, GLUT_KEY_ALT_L );
2263 KEY( VK_RMENU, GLUT_KEY_ALT_R );
2266 /* The delete key should be treated as an ASCII keypress: */
2267 INVOKE_WCB( *window, KeyboardUp,
2268 ( 127, window->State.MouseX, window->State.MouseY )
2274 #if !defined(_WIN32_WCE)
2278 GetKeyboardState( state );
2280 if( ToAscii( (UINT)wParam, 0, state, code, 0 ) == 1 )
2283 INVOKE_WCB( *window, KeyboardUp,
2285 window->State.MouseX, window->State.MouseY )
2287 #endif /* !defined(_WIN32_WCE) */
2291 if( keypress != -1 )
2292 INVOKE_WCB( *window, SpecialUp,
2294 window->State.MouseX, window->State.MouseY )
2297 fgState.Modifiers = INVALID_MODIFIERS;
2304 if( (fgState.KeyRepeat==GLUT_KEY_REPEAT_OFF || window->State.IgnoreKeyRepeat==GL_TRUE) && (HIWORD(lParam) & KF_REPEAT) )
2307 fgState.Modifiers = fghGetWin32Modifiers( );
2308 INVOKE_WCB( *window, Keyboard,
2310 window->State.MouseX, window->State.MouseY )
2312 fgState.Modifiers = INVALID_MODIFIERS;
2316 case WM_CAPTURECHANGED:
2317 /* User has finished resizing the window, force a redraw */
2318 INVOKE_WCB( *window, Display, ( ) );
2320 /*lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ); */
2323 /* Other messages that I have seen and which are not handled already */
2324 case WM_SETTEXT: /* 0x000c */
2325 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
2326 /* Pass it on to "DefWindowProc" to set the window text */
2329 case WM_GETTEXT: /* 0x000d */
2330 /* Ideally we would copy the title of the window into "lParam" */
2331 /* strncpy ( (char *)lParam, "Window Title", wParam );
2332 lRet = ( wParam > 12 ) ? 12 : wParam; */
2333 /* the number of characters copied */
2334 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
2337 case WM_GETTEXTLENGTH: /* 0x000e */
2338 /* Ideally we would get the length of the title of the window */
2340 /* the number of characters in "Window Title\0" (see above) */
2343 case WM_ERASEBKGND: /* 0x0014 */
2344 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
2347 #if !defined(_WIN32_WCE)
2348 case WM_SYNCPAINT: /* 0x0088 */
2349 /* Another window has moved, need to update this one */
2350 window->State.Redisplay = GL_TRUE;
2351 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
2352 /* Help screen says this message must be passed to "DefWindowProc" */
2355 case WM_NCPAINT: /* 0x0085 */
2356 /* Need to update the border of this window */
2357 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
2358 /* Pass it on to "DefWindowProc" to repaint a standard border */
2361 case WM_SYSCOMMAND : /* 0x0112 */
2364 * We have received a system command message. Try to act on it.
2365 * The commands are passed in through the "wParam" parameter:
2366 * The least significant digit seems to be which edge of the window
2367 * is being used for a resize event:
2371 * Congratulations and thanks to Richard Rauch for figuring this out..
2373 switch ( wParam & 0xfff0 )
2382 /* User has clicked on the "-" to minimize the window */
2383 /* Turn off the visibility */
2384 window->State.Visible = GL_FALSE ;
2391 case SC_NEXTWINDOW :
2394 case SC_PREVWINDOW :
2398 /* Followed very closely by a WM_CLOSE message */
2422 case SC_SCREENSAVE :
2428 #if(WINVER >= 0x0400)
2432 case SC_MONITORPOWER :
2435 case SC_CONTEXTHELP :
2437 #endif /* WINVER >= 0x0400 */
2441 fgWarning( "Unknown wParam type 0x%x", wParam );
2446 #endif /* !defined(_WIN32_WCE) */
2448 /* We need to pass the message on to the operating system as well */
2449 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
2453 /* handle multi-touch messages */
2456 unsigned int numInputs = (unsigned int)wParam;
2458 TOUCHINPUT* ti = (TOUCHINPUT*)malloc( sizeof(TOUCHINPUT)*numInputs);
2459 if (GetTouchInputInfo( (HTOUCHINPUT)lParam, numInputs, ti, sizeof(TOUCHINPUT) )) {
2460 /* Handle each contact point */
2461 for (i = 0; i < numInputs; ++i ) {
2464 tp.x = TOUCH_COORD_TO_PIXEL(ti[i].x);
2465 tp.y = TOUCH_COORD_TO_PIXEL(ti[i].y);
2466 ScreenToClient( hWnd, &tp );
2468 ti[i].dwID = ti[i].dwID * 2;
2470 if (ti[i].dwFlags & TOUCHEVENTF_DOWN) {
2471 INVOKE_WCB( *window, MultiEntry, ( ti[i].dwID, GLUT_ENTERED ) );
2472 INVOKE_WCB( *window, MultiButton, ( ti[i].dwID, tp.x, tp.y, 0, GLUT_DOWN ) );
2473 } else if (ti[i].dwFlags & TOUCHEVENTF_MOVE) {
2474 INVOKE_WCB( *window, MultiMotion, ( ti[i].dwID, tp.x, tp.y ) );
2475 } else if (ti[i].dwFlags & TOUCHEVENTF_UP) {
2476 INVOKE_WCB( *window, MultiButton, ( ti[i].dwID, tp.x, tp.y, 0, GLUT_UP ) );
2477 INVOKE_WCB( *window, MultiEntry, ( ti[i].dwID, GLUT_LEFT ) );
2481 CloseTouchInputHandle((HTOUCHINPUT)lParam);
2483 lRet = 0; /*DefWindowProc( hWnd, uMsg, wParam, lParam );*/
2488 /* Handle unhandled messages */
2489 lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
2497 /*** END OF FILE ***/