From 1ec9d615ff6c2472f57776eb9e88c008ef2675f6 Mon Sep 17 00:00:00 2001
From: timoore <timoore>
Date: Wed, 12 Dec 2007 08:24:27 +0000
Subject: [PATCH] Handle warped pointer in embedded GLUT osgViewer

Signal the FGManipulator that a warp has occured so that it can drain its
event queue, but otherwise no warp handling is done in GLUT specific code.
---
 src/Main/fg_os.cxx | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/src/Main/fg_os.cxx b/src/Main/fg_os.cxx
index bdd3ba4db..27360a061 100644
--- a/src/Main/fg_os.cxx
+++ b/src/Main/fg_os.cxx
@@ -22,13 +22,6 @@
 #include "renderer.hxx"
 #include "fg_props.hxx"
 
-// We need to flush all pending mouse move events past a mouse warp to avoid
-// a race condition ending in warping twice and having huge increments for the
-// second warp.
-// I am not aware of such a flush function in glut. So we emulate that by
-// ignoring mouse move events between a warp mouse and the next frame.
-static bool mouseWarped = false;
-
 //
 // Native glut callbacks.
 // These translate the glut event model into osgGA events
@@ -85,7 +78,7 @@ static void callKeyHandler(int k, int mods, int x, int y)
 
 static void GLUTmotion (int x, int y)
 {
-    if (mouseWarped || !gw.valid())
+    if (!gw.valid())
         return;
     gw->getEventQueue()->mouseMotion(x, y);
 }
@@ -143,7 +136,6 @@ static void GLUTdraw()
     viewer->frame();
     glutSwapBuffers();
     glutPostRedisplay();
-    mouseWarped = false;
 }
 
 static void GLUTreshape(int w, int h)
@@ -199,7 +191,7 @@ void fgSetMouseCursor(int cursor)
 
 void fgWarpMouse(int x, int y)
 {
-    mouseWarped = true;
+    globals->get_renderer()->getManipulator()->setMouseWarped();
     glutWarpPointer(x, y);
 }