fix osx embedding

This commit is contained in:
David Rose 2009-07-29 20:29:28 +00:00
parent 7293844e4a
commit 18af305b4a
4 changed files with 43 additions and 38 deletions

View File

@ -191,6 +191,7 @@ set_p3d_filename(const string &p3d_filename) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void P3DInstance:: void P3DInstance::
set_wparams(const P3DWindowParams &wparams) { set_wparams(const P3DWindowParams &wparams) {
nout << "set_wparams, _session = " << _session << "\n";
_got_wparams = true; _got_wparams = true;
_wparams = wparams; _wparams = wparams;
@ -202,46 +203,47 @@ set_wparams(const P3DWindowParams &wparams) {
_splash_window->set_wparams(_wparams); _splash_window->set_wparams(_wparams);
} }
#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();
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) {
_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. // Update the instance in the sub-process.
if (_session != NULL) { if (_session != NULL) {
TiXmlDocument *doc = new TiXmlDocument; TiXmlDocument *doc = new TiXmlDocument;
TiXmlElement *xcommand = new TiXmlElement("command"); TiXmlElement *xcommand = new TiXmlElement("command");
xcommand->SetAttribute("cmd", "setup_window"); xcommand->SetAttribute("cmd", "setup_window");
xcommand->SetAttribute("instance_id", get_instance_id()); xcommand->SetAttribute("instance_id", get_instance_id());
TiXmlElement *xwparams = _wparams.make_xml(); TiXmlElement *xwparams = _wparams.make_xml(this);
#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()];
}
}
if (_swbuffer != NULL) {
xwparams->SetAttribute("subprocess_window", _shared_filename);
}
}
#endif // __APPLE__
doc->LinkEndChild(xcommand); doc->LinkEndChild(xcommand);
xcommand->LinkEndChild(xwparams); xcommand->LinkEndChild(xwparams);
@ -674,7 +676,7 @@ make_xml() {
xinstance->LinkEndChild(xfparams); xinstance->LinkEndChild(xfparams);
if (_got_wparams) { if (_got_wparams) {
TiXmlElement *xwparams = _wparams.make_xml(); TiXmlElement *xwparams = _wparams.make_xml(this);
xinstance->LinkEndChild(xwparams); xinstance->LinkEndChild(xwparams);
} }

View File

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

View File

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

View File

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