瀏覽代碼

several Linux fixes

David Rose 14 年之前
父節點
當前提交
5f6affba78
共有 2 個文件被更改,包括 27 次插入13 次删除
  1. 5 0
      direct/src/plugin/p3dX11SplashWindow.cxx
  2. 22 13
      direct/src/plugin_npapi/ppInstance.cxx

+ 5 - 0
direct/src/plugin/p3dX11SplashWindow.cxx

@@ -684,6 +684,11 @@ subprocess_run() {
     if (input_ready) {
     if (input_ready) {
       receive_command();
       receive_command();
     }
     }
+
+    struct timespec req;
+    req.tv_sec = 0;
+    req.tv_nsec = 50000000;  // 50 ms
+    nanosleep(&req, NULL);
   }
   }
 
 
   close_window();
   close_window();

+ 22 - 13
direct/src/plugin_npapi/ppInstance.cxx

@@ -353,21 +353,29 @@ set_window(NPWindow *window) {
 #endif  // MACOSX_HAS_EVENT_MODELS
 #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<XID>(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;
   _window = *window;
   _got_window = true;
   _got_window = true;
 
 
 #ifdef HAVE_X11
 #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<XID>(_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) {
   if (!_failed && !_started) {
     x11_start_twirl_subprocess();
     x11_start_twirl_subprocess();
   }
   }
@@ -2837,7 +2845,7 @@ twirl_timer_callback() {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void PPInstance::
 void PPInstance::
 x11_start_twirl_subprocess() {
 x11_start_twirl_subprocess() {
-  if (_twirl_subprocess_pid == -1) {
+  if (_twirl_subprocess_pid != -1) {
     // Already started.
     // Already started.
     return;
     return;
   }
   }
@@ -2857,7 +2865,7 @@ x11_start_twirl_subprocess() {
 
 
   // In the parent process.
   // In the parent process.
   _twirl_subprocess_pid = child;
   _twirl_subprocess_pid = child;
-  cerr << "Started twirl subprocess, pid " << _twirl_subprocess_pid
+  nout << "Started twirl subprocess, pid " << _twirl_subprocess_pid
        << "\n";
        << "\n";
 }
 }
 #endif  // HAVE_X11
 #endif  // HAVE_X11
@@ -2890,6 +2898,7 @@ x11_stop_twirl_subprocess() {
   } else if (WIFSTOPPED(status)) {
   } else if (WIFSTOPPED(status)) {
     nout << "  stopped by " << WSTOPSIG(status) << "\n";
     nout << "  stopped by " << WSTOPSIG(status) << "\n";
   }
   }
+  _twirl_subprocess_pid = -1;
 }
 }
 #endif  // HAVE_X11
 #endif  // HAVE_X11