2
0
Эх сурвалжийг харах

add P3D_PLUGIN_VERSION_STR, a few other minor changes

David Rose 14 жил өмнө
parent
commit
5e026c36a2

+ 1 - 1
direct/src/plugin/p3d_lock.h

@@ -81,7 +81,7 @@ public:
     pthread_mutexattr_t attr;                                  \
     pthread_mutexattr_t attr;                                  \
     pthread_mutexattr_init(&attr);                             \
     pthread_mutexattr_init(&attr);                             \
     pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); \
     pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); \
-    int result = pthread_mutex_init(&(lock), &attr);           \
+    pthread_mutex_init(&(lock), &attr);                        \
     pthread_mutexattr_destroy(&attr);                          \
     pthread_mutexattr_destroy(&attr);                          \
   }
   }
 #define ACQUIRE_LOCK(lock) pthread_mutex_lock(&(lock))
 #define ACQUIRE_LOCK(lock) pthread_mutex_lock(&(lock))

+ 3 - 0
direct/src/plugin/p3d_plugin_config.h.pp

@@ -14,6 +14,9 @@
    pandaVersion.h. */
    pandaVersion.h. */
 #$[]define P3D_COREAPI_VERSION_STR "$[join .,$[P3D_COREAPI_VERSION]]"
 #$[]define P3D_COREAPI_VERSION_STR "$[join .,$[P3D_COREAPI_VERSION]]"
 
 
+/* As does the plugin version number. */
+#$[]define P3D_PLUGIN_VERSION_STR "$[join .,$[P3D_PLUGIN_VERSION]]"
+
 /* The filename(s) to generate output to when the plugin is running.
 /* The filename(s) to generate output to when the plugin is running.
    For debugging purposes only. */
    For debugging purposes only. */
 #$[]define P3D_PLUGIN_LOG_DIRECTORY "$[subst \,\\,$[osfilename $[P3D_PLUGIN_LOG_DIRECTORY]]]"
 #$[]define P3D_PLUGIN_LOG_DIRECTORY "$[subst \,\\,$[osfilename $[P3D_PLUGIN_LOG_DIRECTORY]]]"

+ 12 - 4
direct/src/plugin_npapi/ppInstance.cxx

@@ -135,10 +135,13 @@ PPInstance(NPMIMEType pluginType, NPP instance, uint16_t mode,
 #endif // _WIN32
 #endif // _WIN32
 
 
 #ifndef _WIN32
 #ifndef _WIN32
-  // Save the startup time to improve precision of gettimeofday().
+  // Save the startup time to improve precision of gettimeofday().  We
+  // also use this to measure elapsed time from the window parameters
+  // having been received.
   struct timeval tv;
   struct timeval tv;
   gettimeofday(&tv, (struct timezone *)NULL);
   gettimeofday(&tv, (struct timezone *)NULL);
   _init_sec = tv.tv_sec;
   _init_sec = tv.tv_sec;
+  _init_usec = tv.tv_usec;
 #endif  // !_WIN32
 #endif  // !_WIN32
 
 
 #ifdef __APPLE__
 #ifdef __APPLE__
@@ -2642,10 +2645,15 @@ paint_twirl_osx_cgcontext(CGContextRef context) {
 
 
   struct timeval tv;
   struct timeval tv;
   gettimeofday(&tv, (struct timezone *)NULL);
   gettimeofday(&tv, (struct timezone *)NULL);
-  double now = (double)(tv.tv_sec - _init_sec) + (double)tv.tv_usec / 1000000.0;
-  int step = ((int)(now * 10.0)) % twirl_num_steps;
+  double now = (double)(tv.tv_sec - _init_sec) + (double)(tv.tv_usec - _init_usec) / 1000000.0;
 
 
-  osx_paint_image(context, _twirl_images[step]);
+  // Don't draw the twirling icon until at least half a second has
+  // passed, so we don't distract people by drawing it
+  // unnecessarily.
+  if (now >= 0.5) {
+    int step = ((int)(now * 10.0)) % twirl_num_steps;
+    osx_paint_image(context, _twirl_images[step]);
+  }
 }
 }
 #endif  // MACOSX_HAS_EVENT_MODELS
 #endif  // MACOSX_HAS_EVENT_MODELS
 
 

+ 1 - 0
direct/src/plugin_npapi/ppInstance.h

@@ -246,6 +246,7 @@ private:
 
 
 #ifndef _WIN32
 #ifndef _WIN32
   long _init_sec;
   long _init_sec;
+  long _init_usec;
 #endif  // _WIN32
 #endif  // _WIN32
 
 
   bool _python_window_open;
   bool _python_window_open;

+ 3 - 3
direct/src/plugin_npapi/startup.cxx

@@ -163,7 +163,7 @@ NP_Initialize(NPNetscapeFuncs *browserFuncs,
 
 
   // open_logfile() also assigns global_root_dir.
   // open_logfile() also assigns global_root_dir.
   open_logfile();
   open_logfile();
-  nout << "initializing\n";
+  nout << "Initializing Panda3D plugin version " << P3D_PLUGIN_VERSION_STR << "\n";
 
 
   nout << "browserFuncs = " << browserFuncs << "\n";
   nout << "browserFuncs = " << browserFuncs << "\n";
 
 
@@ -177,12 +177,12 @@ NP_Initialize(NPNetscapeFuncs *browserFuncs,
 
 
   int browser_major = (browser->version >> 8) && 0xff;
   int browser_major = (browser->version >> 8) && 0xff;
   int browser_minor = browser->version & 0xff;
   int browser_minor = browser->version & 0xff;
-  nout << "Browser version " << browser_major << "." << browser_minor << "\n";
+  nout << "Browser NPAPI version " << browser_major << "." << browser_minor << "\n";
 
 
   int expected_major = NP_VERSION_MAJOR;
   int expected_major = NP_VERSION_MAJOR;
   int expected_minor = NP_VERSION_MINOR;
   int expected_minor = NP_VERSION_MINOR;
 
 
-  nout << "Plugin compiled with version "
+  nout << "Plugin compiled with NPAPI version "
        << expected_major << "." << expected_minor << "\n";
        << expected_major << "." << expected_minor << "\n";
 
 
   has_plugin_thread_async_call = false;
   has_plugin_thread_async_call = false;