Fixing bug 3048705 -- "fgOpenWindow should only return after the window opens". ...
[freeglut] / src / freeglut_spaceball.c
index 154e52d..7c9d073 100644 (file)
@@ -10,6 +10,8 @@
 #include <GL/freeglut.h>\r
 #include "freeglut_internal.h"\r
 \r
+/* -- PRIVATE FUNCTIONS --------------------------------------------------- */\r
+\r
 #if TARGET_HOST_POSIX_X11\r
 #include <X11/Xlib.h>\r
 \r
@@ -143,11 +145,13 @@ int fgIsSpaceballXEvent(const XEvent *xev)
 {\r
     spnav_event sev;\r
 \r
+    if(spnav_win != fgStructure.CurrentWindow) {\r
+        /* this will also initialize spaceball if needed (first call) */\r
+        fgSpaceballSetWindow(fgStructure.CurrentWindow);\r
+    }\r
+\r
     if(!sball_initialized) {\r
-        fgInitialiseSpaceball();\r
-        if(!sball_initialized) {\r
-            return 0;\r
-        }\r
+        return 0;\r
     }\r
 \r
     return spnav_x11_event(xev, &sev);\r
@@ -216,7 +220,7 @@ OF SUCH DAMAGE.
 #include <stdlib.h>\r
 #include <string.h>\r
 \r
-#if HAVE_ERRNO_H\r
+#ifdef HAVE_ERRNO_H\r
 #include <errno.h>\r
 #endif\r
 \r