From: Ioannis P. <ioa...@gm...> - 2017-05-25 07:09:50
|
> > > I don't know what you are trying to achieve with null events, as you > > didn't quote any relevant context, so I can't help with alternative > > suggestions without more info. Is this about a bug which affects the X11 > > back-end? If so let me know how to reproduce it, and I'll give it a > > look. > Try the following code. Make sure that before you run, the mouse pointer is moved outside the window. Then press ESC and wait 1 sec. The program should exit (which in my case doesn't). Then, if you hover the mouse over the window, it exits. Without the 1 sec delay it sometimes exits immediately. I have only tested it on Windows XP, neither X11 nor android. Ioannis #include <GL/freeglut.h> #include <stdio.h> #include <time.h> void ReshapeWindow(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho (0.0, (float)w, 0.0,(float)h, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity (); } void Print2d(int x, int y, char *msg) { unsigned int i; glRasterPos2i(x, y); for (i=0;i<(int)strlen(msg);i++) glutBitmapCharacter(GLUT_BITMAP_8_BY_13, msg[i]); } void DrawWindow() { glDrawBuffer(GL_BACK); glClear(GL_COLOR_BUFFER_BIT); Print2d(10, 10, "Press ESC to exit after 1 sec"); glutSwapBuffers(); } void KeyCallback(unsigned char key, int x, int y) { time_t t0; if (key!=27) return; t0=clock(); while (clock()-t0<1000); glutLeaveMainLoop(); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_RGB); glutCreateWindow (" glutLeaveMainLoop bug! "); glutReshapeFunc (ReshapeWindow); glutDisplayFunc (DrawWindow); glutKeyboardFunc (KeyCallback); glClearColor(0., 0., 1., 1.); glutMainLoop(); return 0; } |