]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/FGEventHandler.cxx
Merge branch 'attenuation' into navaids-radio
[flightgear.git] / src / Main / FGEventHandler.cxx
index 91d830e6dff1a561b9df7d1d4eb7a8b91e31b3d7..562d807918ec13dc3729d5b32c70163109d50432 100644 (file)
 #include "CameraGroup.hxx"
 #include "FGEventHandler.hxx"
 #include "WindowSystemAdapter.hxx"
+#include "renderer.hxx"
 
 #if !defined(X_DISPLAY_MISSING)
 #define X_DOUBLE_SCROLL_BUG 1
 #endif
 
+#ifdef SG_MAC
+// hack - during interactive resize on Mac, OSG queues and then flushes
+// a large number of resize events, without doing any drawing.
+extern void puCleanUpJunk ( void ) ;
+#endif
+
 namespace flightgear
 {
 const int displayStatsKey = 1;
@@ -29,12 +36,10 @@ const int printStatsKey = 2;
 
 FGEventHandler::FGEventHandler() :
     idleHandler(0),
-    drawHandler(0),
-    windowResizeHandler(0),
     keyHandler(0),
     mouseClickHandler(0),
     mouseMotionHandler(0),
-    statsHandler(new osgViewer::StatsHandler),
+    statsHandler(new FGStatsHandler),
     statsEvent(new osgGA::GUIEventAdapter),
     statsType(osgViewer::StatsHandler::NO_STATS),
     currentModifiers(0),
@@ -208,13 +213,15 @@ bool FGEventHandler::handle(const osgGA::GUIEventAdapter& ea,
         if (ea.getScrollingMotion() == osgGA::GUIEventAdapter::SCROLL_2D) {
             if (ea.getScrollingDeltaY() > 0)
                 button = 3;
-            else
+            else if (ea.getScrollingDeltaY() < 0)
                 button = 4;
+            else
+                button = -1;
         } else if (ea.getScrollingMotion() == osgGA::GUIEventAdapter::SCROLL_UP)
             button = 3;
         else
             button = 4;
-        if (mouseClickHandler) {
+        if (mouseClickHandler && button != -1) {
             (*mouseClickHandler)(button, 0, x, y, mainWindow, &ea);
             (*mouseClickHandler)(button, 1, x, y, mainWindow, &ea);
         }
@@ -233,8 +240,15 @@ bool FGEventHandler::handle(const osgGA::GUIEventAdapter& ea,
         return true;
     case osgGA::GUIEventAdapter::RESIZE:
         CameraGroup::getDefault()->resized();
-        if (resizable && windowResizeHandler)
-            (*windowResizeHandler)(ea.getWindowWidth(), ea.getWindowHeight());
+        if (resizable)
+          globals->get_renderer()->resize(ea.getWindowWidth(), ea.getWindowHeight());
+        statsHandler->handle(ea, us);
+      #ifdef SG_MAC
+        // work around OSG Cocoa-Viewer issue with resize event handling,
+        // where resize events are queued up, then dispatched in a batch, with
+        // no interveningd drawing calls.
+        puCleanUpJunk();
+      #endif
         return true;
      case osgGA::GUIEventAdapter::CLOSE_WINDOW:
     case osgGA::GUIEventAdapter::QUIT_APPLICATION: