1
0
Fork 0

Fix native menubar in Mac builds with Qt

- where we don’t use the launcher, we must pass tell OSG we
  want to pose as standalone when setting the window traits.
This commit is contained in:
James Turner 2015-01-07 09:19:04 +00:00
parent c8c2da1b78
commit 1ba62acfcc
3 changed files with 23 additions and 1 deletions

View 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;
}

View 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

View 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