]> git.mxchange.org Git - flightgear.git/commitdiff
Fix native menubar in Mac builds with Qt
authorJames Turner <zakalawe@mac.com>
Wed, 7 Jan 2015 09:19:04 +0000 (09:19 +0000)
committerJames Turner <zakalawe@mac.com>
Wed, 7 Jan 2015 09:19:04 +0000 (09:19 +0000)
- where we don’t use the launcher, we must pass tell OSG we
  want to pose as standalone when setting the window traits.

src/Main/main.cxx
src/Viewer/WindowBuilder.cxx
src/Viewer/WindowBuilder.hxx

index 581bc7aa38a61a6b766fe56a2b13a3890d353fcf..b578e464a4b9a67c8de9432c96a9935943f3dd03 100644 (file)
@@ -67,6 +67,7 @@ extern bool global_crashRptEnabled;
 #include <Viewer/WindowSystemAdapter.hxx>
 #include <Navaids/NavDataCache.hxx>
 #include <Include/version.h>
+#include <Viewer/WindowBuilder.hxx>
 
 #include "fg_commands.hxx"
 #include "fg_io.hxx"
@@ -464,6 +465,10 @@ int fgMainInit( int argc, char **argv )
     showLauncher |= (::getenv("FG_LAUNCHER") != 0);
 
     if (showLauncher) {
+        // avoid double Apple menu and other weirdness if both Qt and OSG
+        // try to initialise various Cocoa structures.
+        flightgear::WindowBuilder::setPoseAsStandaloneApp(false);
+
         if (!QtLauncher::runLauncherDialog()) {
             return EXIT_SUCCESS;
         }
index 901b72e14d8e0c23bf051a8f569e106c6ad848c3..06d94e1184c09f5da54bbdb289e85159c600103f 100644 (file)
@@ -45,6 +45,10 @@ ref_ptr<WindowBuilder> WindowBuilder::windowBuilder;
 
 const string WindowBuilder::defaultWindowName("FlightGear");
 
+// default to true (historical behaviour), we will clear the flag if
+// we run another GUI.
+bool WindowBuilder::poseAsStandaloneApp = true;
+
 void WindowBuilder::initWindowBuilder(bool stencil)
 {
     windowBuilder = new WindowBuilder(stencil);
@@ -250,9 +254,13 @@ GraphicsWindow* WindowBuilder::getDefaultWindow()
     traits->windowName = "FlightGear";
 
 #if defined(HAVE_QT) && defined(SG_MAC)
+    int flags = osgViewer::GraphicsWindowCocoa::WindowData::CheckForEvents;
+
     // avoid both QApplication and OSG::CocoaViewer doing single-application
     // init (Apple menu, making front process, etc)
-    int flags = osgViewer::GraphicsWindowCocoa::WindowData::CheckForEvents;
+    if (poseAsStandaloneApp) {
+        flags |= osgViewer::GraphicsWindowCocoa::WindowData::PoseAsStandaloneApp;
+    }
     traits->inheritedWindowData = new osgViewer::GraphicsWindowCocoa::WindowData(flags);
 #endif
 
@@ -266,4 +274,10 @@ GraphicsWindow* WindowBuilder::getDefaultWindow()
         return 0;
     }
 }
+
+void WindowBuilder::setPoseAsStandaloneApp(bool b)
+{
+    poseAsStandaloneApp = b;
 }
+
+} // of namespace flightgear
index 92e158bb84bdedc1d51a37d49556b4671ce6b583..8836d6956ed6a86ecadda0226279f14c291fcae1 100644 (file)
@@ -57,6 +57,8 @@ public:
     /** Get the name used to look up the default window.
      */
     const std::string& getDefaultWindowName() { return defaultWindowName; }
+
+    static void setPoseAsStandaloneApp(bool b);
 protected:
     WindowBuilder(bool stencil);
     static osg::GraphicsContext::Traits* makeDefaultTraits(bool stencil);
@@ -64,6 +66,7 @@ protected:
     int defaultCounter;
     static osg::ref_ptr<WindowBuilder> windowBuilder;
     static const std::string defaultWindowName;
+    static bool poseAsStandaloneApp;
 };
 
 /** Silly function for making the default window and camera