From 5f6affba782dce4b1b2e4d057c102aa86dc84e47 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 14 Sep 2011 23:00:27 +0000 Subject: [PATCH] several Linux fixes --- direct/src/plugin/p3dX11SplashWindow.cxx | 5 ++++ direct/src/plugin_npapi/ppInstance.cxx | 35 +++++++++++++++--------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/direct/src/plugin/p3dX11SplashWindow.cxx b/direct/src/plugin/p3dX11SplashWindow.cxx index a7843d08d6..18bc7d537d 100755 --- a/direct/src/plugin/p3dX11SplashWindow.cxx +++ b/direct/src/plugin/p3dX11SplashWindow.cxx @@ -684,6 +684,11 @@ subprocess_run() { if (input_ready) { receive_command(); } + + struct timespec req; + req.tv_sec = 0; + req.tv_nsec = 50000000; // 50 ms + nanosleep(&req, NULL); } close_window(); diff --git a/direct/src/plugin_npapi/ppInstance.cxx b/direct/src/plugin_npapi/ppInstance.cxx index 5dee70ac57..c9b1c4bf2c 100644 --- a/direct/src/plugin_npapi/ppInstance.cxx +++ b/direct/src/plugin_npapi/ppInstance.cxx @@ -353,21 +353,29 @@ set_window(NPWindow *window) { #endif // MACOSX_HAS_EVENT_MODELS } +#if defined(HAVE_GTK) && defined(HAVE_X11) + if (_use_xembed) { + if (!_got_window || _window.window != window->window) { + // The window has changed. Destroy the old GtkPlug. + if (_plug != NULL) { + gtk_widget_destroy(_plug); + _plug = NULL; + } + + // Create a new GtkPlug to bind to the XEmbed socket. + _plug = gtk_plug_new((GdkNativeWindow) reinterpret_cast(window->window)); + gtk_widget_show(_plug); + + nout << "original XID is " << window->window << ", created X11 window " + << GDK_DRAWABLE_XID(_plug->window) << "\n"; + } + } +#endif // HAVE_GTK && HAVE_X11 + _window = *window; _got_window = true; #ifdef HAVE_X11 -#ifdef HAVE_GTK - if (_use_xembed) { - // Create a GtkPlug to bind to the XEmbed socket. - _plug = gtk_plug_new((GdkNativeWindow) reinterpret_cast(_window.window)); - gtk_widget_show(_plug); - - nout << "original XID is " << _window.window << ", created X11 window " - << GDK_DRAWABLE_XID(_plug->window) << "\n"; - } -#endif // HAVE_GTK - if (!_failed && !_started) { x11_start_twirl_subprocess(); } @@ -2837,7 +2845,7 @@ twirl_timer_callback() { //////////////////////////////////////////////////////////////////// void PPInstance:: x11_start_twirl_subprocess() { - if (_twirl_subprocess_pid == -1) { + if (_twirl_subprocess_pid != -1) { // Already started. return; } @@ -2857,7 +2865,7 @@ x11_start_twirl_subprocess() { // In the parent process. _twirl_subprocess_pid = child; - cerr << "Started twirl subprocess, pid " << _twirl_subprocess_pid + nout << "Started twirl subprocess, pid " << _twirl_subprocess_pid << "\n"; } #endif // HAVE_X11 @@ -2890,6 +2898,7 @@ x11_stop_twirl_subprocess() { } else if (WIFSTOPPED(status)) { nout << " stopped by " << WSTOPSIG(status) << "\n"; } + _twirl_subprocess_pid = -1; } #endif // HAVE_X11