From f3751431b5124c0a8d0876683236b84502c2feb9 Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 4 Aug 2009 23:29:40 +0000 Subject: [PATCH] hidden plugins --- direct/src/plugin/binaryXml.cxx | 2 +- direct/src/plugin/p3dInstance.cxx | 75 ++++++++++++------------ direct/src/plugin/p3dOsxSplashWindow.cxx | 6 +- direct/src/plugin_npapi/ppInstance.cxx | 12 +++- direct/src/plugin_npapi/startup.cxx | 10 ++++ 5 files changed, 64 insertions(+), 41 deletions(-) diff --git a/direct/src/plugin/binaryXml.cxx b/direct/src/plugin/binaryXml.cxx index e46abd54ea..338a0f0e85 100644 --- a/direct/src/plugin/binaryXml.cxx +++ b/direct/src/plugin/binaryXml.cxx @@ -16,7 +16,7 @@ #include -static const bool debug_xml_output = false; +static const bool debug_xml_output = true; #define DO_BINARY_XML 1 diff --git a/direct/src/plugin/p3dInstance.cxx b/direct/src/plugin/p3dInstance.cxx index aea4e26b7c..39cbfb1e68 100644 --- a/direct/src/plugin/p3dInstance.cxx +++ b/direct/src/plugin/p3dInstance.cxx @@ -184,48 +184,51 @@ set_wparams(const P3DWindowParams &wparams) { nout << "set_wparams, _session = " << _session << "\n"; _got_wparams = true; _wparams = wparams; + nout << "set window_type = " << _wparams.get_window_type() << "\n"; - // Update or create the splash window. - if (!_instance_window_opened) { - if (_splash_window == NULL) { - make_splash_window(); - } - _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 (_wparams.get_window_type() != P3D_WT_hidden) { + // Update or create the splash window. + if (!_instance_window_opened) { + if (_splash_window == NULL) { + make_splash_window(); } + _splash_window->set_wparams(_wparams); } - if (_swbuffer == NULL) { - nout << "Could not open swbuffer\n"; +#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. if (_session != NULL) { diff --git a/direct/src/plugin/p3dOsxSplashWindow.cxx b/direct/src/plugin/p3dOsxSplashWindow.cxx index 4a87e33360..d46e0e44c9 100644 --- a/direct/src/plugin/p3dOsxSplashWindow.cxx +++ b/direct/src/plugin/p3dOsxSplashWindow.cxx @@ -257,10 +257,10 @@ paint_window() { PaintRect(&rdone); EraseRect(&rneed); + RGBColor black = { 0, 0, 0 }; + RGBForeColor(&black); + if (!_install_label.empty()) { - RGBColor black = { 0, 0, 0 }; - RGBForeColor(&black); - TextFont(0); TextFace(bold); TextMode(srcOr); diff --git a/direct/src/plugin_npapi/ppInstance.cxx b/direct/src/plugin_npapi/ppInstance.cxx index 9aed862627..8c394ac136 100644 --- a/direct/src/plugin_npapi/ppInstance.cxx +++ b/direct/src/plugin_npapi/ppInstance.cxx @@ -1064,8 +1064,18 @@ send_window() { } #endif + P3D_window_type window_type = P3D_WT_embedded; + if (_window.window == NULL) { + // No parent window: it must be a hidden window. + window_type = P3D_WT_hidden; + } else if (_window.width == 0 || _window.height == 0) { + // No size: hidden. + window_type = P3D_WT_hidden; + } + nout << "window_type = " << window_type << "\n"; + P3D_instance_setup_window - (_p3d_inst, P3D_WT_embedded, + (_p3d_inst, window_type, x, y, _window.width, _window.height, parent_window); } diff --git a/direct/src/plugin_npapi/startup.cxx b/direct/src/plugin_npapi/startup.cxx index a2227d8818..a70722d785 100644 --- a/direct/src/plugin_npapi/startup.cxx +++ b/direct/src/plugin_npapi/startup.cxx @@ -20,6 +20,10 @@ #include #endif +#ifdef __APPLE__ +#include +#endif + static ofstream logfile; ostream *nout_stream = &logfile; @@ -129,6 +133,12 @@ NP_Initialize(NPNetscapeFuncs *browserFuncs, } #endif +#ifdef __APPLE__ + // On Mac, we'd better ignore SIGPIPE, or this signal will shut down + // the application if the plugin exits unexpectedly. + signal(SIGPIPE, SIG_IGN); +#endif // __APPLE__ + return NPERR_NO_ERROR; }