Browse Source

Fix for OS X system menu

Josh Engebretson 10 years ago
parent
commit
9a07d8999a

+ 5 - 6
Source/AtomicEditor/Application/AEEditorCommon.cpp

@@ -62,6 +62,11 @@ void AEEditorCommon::Start()
 {
     ValidateWindow();
 
+#ifdef ATOMIC_WEBVIEW
+    // Initialize in Start so window already exists
+    context_->RegisterSubsystem(new WebBrowserHost(context_));
+#endif
+
     Input* input = GetSubsystem<Input>();
     input->SetMouseVisible(true);
 
@@ -115,12 +120,6 @@ void AEEditorCommon::Setup()
 
 #endif
 
-#ifdef ATOMIC_WEBVIEW
-
-    context_->RegisterSubsystem(new WebBrowserHost(context_));
-
-#endif
-
 #ifdef ATOMIC_DOTNET
 
     // Instantiate and register the AtomicNET subsystem

+ 31 - 2
Source/AtomicWebView/WebBrowserHost.cpp

@@ -2,12 +2,40 @@
 #include <ThirdParty/CEF/include/cef_app.h>
 #include <ThirdParty/CEF/include/cef_client.h>
 #include <ThirdParty/CEF/include/cef_render_handler.h>
+#include <ThirdParty/CEF/include/wrapper/cef_helpers.h>
+
 
 #include <Atomic/Core/ProcessUtils.h>
 #include <Atomic/IO/Log.h>
 
 #include "WebBrowserHost.h"
 
+class SimpleApp : public CefApp,
+                  public CefBrowserProcessHandler {
+ public:
+  SimpleApp();
+
+  // CefApp methods:
+  virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler()
+      OVERRIDE { return this; }
+
+  // CefBrowserProcessHandler methods:
+  virtual void OnContextInitialized() OVERRIDE;
+
+ private:
+  // Include the default reference counting implementation.
+  IMPLEMENT_REFCOUNTING(SimpleApp);
+};
+
+SimpleApp::SimpleApp() {
+}
+
+void SimpleApp::OnContextInitialized() {
+
+  CEF_REQUIRE_UI_THREAD();
+
+}
+
 namespace Atomic
 {
 
@@ -32,9 +60,10 @@ WebBrowserHost::WebBrowserHost(Context* context) : Object (context)
 
     CefSettings settings;
 
-    // TODO: We're losing the main system menu items on OSX and cmd-q no longer works
-    // when we call CefInitialize
+    settings.windowless_rendering_enabled = true;
 
+    // If losing OSX system menu, it means we're calling this
+    // before initializing graphics subsystem
     if (!CefInitialize(args, settings, nullptr, nullptr))
     {
         LOGERROR("CefInitialize - Error");