X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fglut%2Fglx%2Fglut_event.c;h=d6d963896a6fff8143f914956e60f4f774eac377;hb=5340b6dff73a0a23531ce2a5f28fba8303adab6e;hp=d10cc159b618cda261ed4d859e290080ad67bc53;hpb=a3bcbfaeb1faf1c38a6816064597cd0c1e6639a0;p=mesa.git diff --git a/src/glut/glx/glut_event.c b/src/glut/glx/glut_event.c index d10cc159b61..d6d963896a6 100644 --- a/src/glut/glx/glut_event.c +++ b/src/glut/glx/glut_event.c @@ -5,6 +5,10 @@ and is provided without guarantee or warrantee expressed or implied. This program is -not- in the public domain. */ +#ifdef __VMS +#include +#endif + #include #include #include @@ -20,7 +24,7 @@ # ifdef __sgi # include /* prototype for bzero used by FD_ZERO */ # endif -# if (defined(SVR4) || defined(CRAY) || defined(AIXV3)) && !defined(FD_SETSIZE) +# if (defined(__FreeBSD__) || defined(SVR4) || defined(CRAY) || defined(AIXV3)) && !defined(FD_SETSIZE) # include /* select system call interface */ # ifdef luna # include @@ -60,18 +64,18 @@ # endif #endif /* !_WIN32 */ +#include "glutint.h" + #if defined(__vms) && ( __VMS_VER < 70000000 ) #include #include extern int SYS$CLREF(int efn); -extern int SYS$SETIMR(unsigned int efn, struct timeval *timeout, void *ast, +extern int SYS$SETIMR(unsigned int efn, struct timeval6 *timeout, void *ast, unsigned int request_id, unsigned int flags); extern int SYS$WFLOR(unsigned int efn, unsigned int mask); extern int SYS$CANTIM(unsigned int request_id, unsigned int mode); #endif /* __vms, VMs 6.2 or earlier */ -#include "glutint.h" - static GLUTtimer *freeTimerList = NULL; GLUTidleCB __glutIdleFunc = NULL; @@ -99,19 +103,23 @@ Atom __glutMotifHints = None; unsigned int __glutModifierMask = (unsigned int) ~0; int __glutWindowDamaged = 0; -void APIENTRY +void GLUTAPIENTRY glutIdleFunc(GLUTidleCB idleFunc) { __glutIdleFunc = idleFunc; } -void APIENTRY +void GLUTAPIENTRY glutTimerFunc(unsigned int interval, GLUTtimerCB timerFunc, int value) { GLUTtimer *timer, *other; GLUTtimer **prevptr; - struct timeval now; - +#ifdef OLD_VMS + struct timeval6 now; +#else + struct timeval now; +#endif + if (!timerFunc) return; @@ -152,18 +160,26 @@ glutTimerFunc(unsigned int interval, GLUTtimerCB timerFunc, int value) void handleTimeouts(void) { - struct timeval now; - GLUTtimer *timer; +#ifdef OLD_VMS + struct timeval6 now; +#else + struct timeval now; +#endif + GLUTtimer *timer; /* Assumption is that __glutTimerList is already determined to be non-NULL. */ GETTIMEOFDAY(&now); while (IS_AT_OR_AFTER(__glutTimerList->timeout, now)) { timer = __glutTimerList; + /* call the timer function */ timer->func(timer->value); + /* remove from the linked list */ __glutTimerList = timer->next; + /* put this timer on the "free" list */ timer->next = freeTimerList; freeTimerList = timer; + if (!__glutTimerList) break; } @@ -203,7 +219,7 @@ __glutPostRedisplay(GLUTwindow * window, int layerMask) } /* CENTRY */ -void APIENTRY +void GLUTAPIENTRY glutPostRedisplay(void) { __glutPostRedisplay(__glutCurrentWindow, GLUT_REDISPLAY_WORK); @@ -213,7 +229,7 @@ glutPostRedisplay(void) glutSetWindow call (entailing an expensive OpenGL context switch), particularly useful when multiple windows need redisplays posted at the same times. See also glutPostWindowOverlayRedisplay. */ -void APIENTRY +void GLUTAPIENTRY glutPostWindowRedisplay(int win) { __glutPostRedisplay(__glutWindowList[win - 1], GLUT_REDISPLAY_WORK); @@ -302,17 +318,16 @@ interruptibleXNextEvent(Display * dpy, XEvent * event) return 1; } #ifndef VMS - /* the combination ConectionNumber-select is buggy on VMS. Sometimes it - * fails. This part of the code hangs the program on VMS7.2. But even - * without it the program seems to run correctly. - * Note that this is a bug in the VMS/DECWindows run-time-libraries. - * Compaq engeneering does not want or is not able to make a fix. - * (last sentence is a quotation from Compaq when I reported the - * problem January 2000) */ - FD_ZERO(&fds); + /* the combination ConectionNumber-select is buggy on VMS. Sometimes it + * fails. This part of the code hangs the program on VMS7.2. But even + * without it the program seems to run correctly. + * Note that this is a bug in the VMS/DECWindows run-time-libraries. + * Compaq engeneering does not want or is not able to make a fix. + * (last sentence is a quotation from Compaq when I reported the + * problem January 2000) */ + FD_ZERO(&fds); FD_SET(__glutConnectionFD, &fds); - rc = select(__glutConnectionFD + 1, &fds, - NULL, NULL, NULL); + rc = select(__glutConnectionFD + 1, &fds, NULL, NULL, NULL); if (rc < 0) { if (errno == EINTR) { return 0; @@ -427,11 +442,16 @@ processEventsAndTimeouts(void) __glutFinishMenu(event.xbutton.window, event.xbutton.x, event.xbutton.y); } else { window = __glutGetWindow(event.xbutton.window); + /* added button check for mice with > 3 buttons */ if (window) { GLUTmenu *menu; int menuNum; - menuNum = window->menu[event.xbutton.button - 1]; + if (event.xbutton.button <= GLUT_MAX_MENUS) + menuNum = window->menu[event.xbutton.button - 1]; + else + menuNum = 0; + /* Make sure that __glutGetMenuByNum is only called if there really is a menu present. */ if ((menuNum > 0) && (menu = __glutGetMenuByNum(menuNum))) { @@ -836,7 +856,7 @@ static void waitForSomething(void) { #if defined(__vms) && ( __VMS_VER < 70000000 ) - static struct timeval zerotime = + static struct timeval6 zerotime = {0}; unsigned int timer_efn; #define timer_id 'glut' /* random :-) number */ @@ -848,7 +868,11 @@ waitForSomething(void) fd_set fds; #endif #endif - struct timeval now, timeout, waittime; +#ifdef OLD_VMS + struct timeval6 now, timeout, waittime; +#else + struct timeval now, timeout, waittime; +#endif #if !defined(_WIN32) int rc; #endif @@ -1297,7 +1321,12 @@ processWindowWorkList(GLUTwindow * window) is where the finish works gets queued for indirect contexts. */ __glutSetWindow(window); - glFinish(); +#if !defined(_WIN32) + if (!window->isDirect) +#endif + { + glFinish(); + } } if (workMask & GLUT_DEBUG_WORK) { __glutSetWindow(window); @@ -1314,9 +1343,7 @@ processWindowWorkList(GLUTwindow * window) } } -#ifndef _WIN32 static /* X11 implementations do not need this global. */ -#endif void __glutProcessWindowWorkLists(void) { @@ -1336,7 +1363,7 @@ __glutProcessWindowWorkLists(void) } /* CENTRY */ -void APIENTRY +void GLUTAPIENTRY glutMainLoop(void) { #if !defined(_WIN32)