Forráskód Böngészése

fix osx embedding

David Rose 16 éve
szülő
commit
18af305b4a

+ 37 - 35
direct/src/plugin/p3dInstance.cxx

@@ -191,6 +191,7 @@ set_p3d_filename(const string &p3d_filename) {
 ////////////////////////////////////////////////////////////////////
 void P3DInstance::
 set_wparams(const P3DWindowParams &wparams) {
+  nout << "set_wparams, _session = " << _session << "\n";
   _got_wparams = true;
   _wparams = wparams;
 
@@ -202,46 +203,47 @@ set_wparams(const P3DWindowParams &wparams) {
     _splash_window->set_wparams(_wparams);
   }
 
-  // Update the instance in the sub-process.
-  if (_session != NULL) {
-    TiXmlDocument *doc = new TiXmlDocument;
-    TiXmlElement *xcommand = new TiXmlElement("command");
-    xcommand->SetAttribute("cmd", "setup_window");
-    xcommand->SetAttribute("instance_id", get_instance_id());
-    TiXmlElement *xwparams = _wparams.make_xml();
-
 #ifdef __APPLE__
-    // On Mac, we have to communicate the results of the rendering
-    // back via shared memory, instead of directly parenting windows
-    // to the browser.  Set up this mechanism.
-    int x_size = _wparams.get_win_width();
-    int y_size = _wparams.get_win_height();
-    if (x_size != 0 && y_size != 0) {
-      if (_swbuffer == NULL || _swbuffer->get_x_size() != x_size ||
-          _swbuffer->get_y_size() != y_size) {
-        // We need to open a new shared buffer.
-        if (_swbuffer != NULL) {
-          SubprocessWindowBuffer::destroy_buffer(_shared_fd, _shared_mmap_size,
-                                                 _shared_filename, _swbuffer);
-          _swbuffer = NULL;
-        }
-        if (_reversed_buffer != NULL) {
-          delete[] _reversed_buffer;
-          _reversed_buffer = NULL;
-        }
-
-        _swbuffer = SubprocessWindowBuffer::new_buffer
-          (_shared_fd, _shared_mmap_size, _shared_filename, x_size, y_size);
-        if (_swbuffer != NULL) {
-          _reversed_buffer = new char[_swbuffer->get_framebuffer_size()];
-        }
+  // On Mac, we have to communicate the results of the rendering
+  // back via shared memory, instead of directly parenting windows
+  // to the browser.  Set up this mechanism.
+  int x_size = _wparams.get_win_width();
+  int y_size = _wparams.get_win_height();
+  nout << "x_size, y_size = " << x_size << ", " << y_size << "\n";
+  if (x_size != 0 && y_size != 0) {
+    if (_swbuffer == NULL || _swbuffer->get_x_size() != x_size ||
+        _swbuffer->get_y_size() != y_size) {
+      // We need to open a new shared buffer.
+      if (_swbuffer != NULL) {
+        SubprocessWindowBuffer::destroy_buffer(_shared_fd, _shared_mmap_size,
+                                               _shared_filename, _swbuffer);
+        _swbuffer = NULL;
       }
-
+      if (_reversed_buffer != NULL) {
+        delete[] _reversed_buffer;
+        _reversed_buffer = NULL;
+      }
+      
+      _swbuffer = SubprocessWindowBuffer::new_buffer
+        (_shared_fd, _shared_mmap_size, _shared_filename, x_size, y_size);
       if (_swbuffer != NULL) {
-        xwparams->SetAttribute("subprocess_window", _shared_filename);
+        _reversed_buffer = new char[_swbuffer->get_framebuffer_size()];
       }
     }
+    
+    if (_swbuffer == NULL) {
+      nout << "Could not open swbuffer\n";
+    }
+  }
 #endif   // __APPLE__
+
+  // Update the instance in the sub-process.
+  if (_session != NULL) {
+    TiXmlDocument *doc = new TiXmlDocument;
+    TiXmlElement *xcommand = new TiXmlElement("command");
+    xcommand->SetAttribute("cmd", "setup_window");
+    xcommand->SetAttribute("instance_id", get_instance_id());
+    TiXmlElement *xwparams = _wparams.make_xml(this);
     
     doc->LinkEndChild(xcommand);
     xcommand->LinkEndChild(xwparams);
@@ -674,7 +676,7 @@ make_xml() {
   xinstance->LinkEndChild(xfparams);
 
   if (_got_wparams) {
-    TiXmlElement *xwparams = _wparams.make_xml();
+    TiXmlElement *xwparams = _wparams.make_xml(this);
     xinstance->LinkEndChild(xwparams);
   }
 

+ 1 - 0
direct/src/plugin/p3dInstance.h

@@ -170,6 +170,7 @@ private:
 
   friend class P3DSession;
   friend class SplashDownload;
+  friend class P3DWindowParams;
 };
 
 #include "p3dInstance.I"

+ 2 - 2
direct/src/plugin/p3dWindowParams.cxx

@@ -67,7 +67,7 @@ operator = (const P3DWindowParams &other) {
 //               instance.
 ////////////////////////////////////////////////////////////////////
 TiXmlElement *P3DWindowParams::
-make_xml() {
+make_xml(P3DInstance *inst) {
   TiXmlElement *xwparams = new TiXmlElement("wparams");
 
   switch (_window_type) {
@@ -81,7 +81,7 @@ make_xml() {
     xwparams->SetAttribute("parent_hwnd", (int)_parent_window._hwnd);
 
 #elif defined(__APPLE__)
-    // The subprocess_window setting is applied by the caller.
+    xwparams->SetAttribute("subprocess_window", inst->_shared_filename);
 
 #elif defined(HAVE_X11)
     // TinyXml doesn't support a "long" attribute.  We'll use

+ 3 - 1
direct/src/plugin/p3dWindowParams.h

@@ -18,6 +18,8 @@
 #include "p3d_plugin_common.h"
 #include "get_tinyxml.h"
 
+class P3DInstance *inst;
+
 ////////////////////////////////////////////////////////////////////
 //       Class : P3DWindowParams
 // Description : Encapsulates the window parameters.
@@ -39,7 +41,7 @@ public:
   inline int get_win_height() const;
   inline P3D_window_handle get_parent_window() const;
 
-  TiXmlElement *make_xml();
+  TiXmlElement *make_xml(P3DInstance *inst);
 
 private:
   P3D_window_type _window_type;