[xiph-commits] r3385 - in liboggplay/trunk/plugin: . support

laser13 at svn.annodex.net laser13 at svn.annodex.net
Thu Jan 24 22:48:02 PST 2008


Author: laser13
Date: 2008-01-24 22:48:00 -0800 (Thu, 24 Jan 2008)
New Revision: 3385

Modified:
   liboggplay/trunk/plugin/nsILibOggPlugin.idl
   liboggplay/trunk/plugin/plugin.cpp
   liboggplay/trunk/plugin/plugin.h
   liboggplay/trunk/plugin/plugin_c.h
   liboggplay/trunk/plugin/plugin_gui_win32.c
   liboggplay/trunk/plugin/support/nsScriptablePeer.cpp
Log:
Added OnMouseClick callback to Mozilla plugin Javascript API for Win32.

Modified: liboggplay/trunk/plugin/nsILibOggPlugin.idl
===================================================================
--- liboggplay/trunk/plugin/nsILibOggPlugin.idl	2008-01-25 05:05:52 UTC (rev 3384)
+++ liboggplay/trunk/plugin/nsILibOggPlugin.idl	2008-01-25 06:48:00 UTC (rev 3385)
@@ -76,6 +76,7 @@
   boolean retrieveAnnotations(in nsILibOggCallbackString callback);
   void registerCMMLCallback(in nsILibOggCallbackString callback);
   void registerEndPlayCallback(in nsILibOggCallbackNoArg callback);
+  void registerOnMouseClickCallback(in nsILibOggCallbackNoArg callback);
 
   /* playlist functions */
   void freezePlaylistProgression();

Modified: liboggplay/trunk/plugin/plugin.cpp
===================================================================
--- liboggplay/trunk/plugin/plugin.cpp	2008-01-25 05:05:52 UTC (rev 3384)
+++ liboggplay/trunk/plugin/plugin.cpp	2008-01-25 06:48:00 UTC (rev 3385)
@@ -860,6 +860,19 @@
   SEM_SIGNAL(mCrossThreadSem);
 }
 
+void 
+nsPluginInstance::registerOnMouseClickCallback(nsILibOggCallbackNoArg *cbObj) {
+  SEM_WAIT(mCrossThreadSem);
+  if (this->mMouseClickCallback != NULL) {
+    NS_RELEASE(mPlaylistCallback);
+  }
+  mPlaylistCallback = cbObj;
+  if (mMouseClickCallback != NULL) {
+    NS_ADDREF(mMouseClickCallback);
+  }
+  SEM_SIGNAL(mCrossThreadSem);
+}
+
 ////////////////////////////////////////
 //
 // Cross-thread event handling
@@ -924,6 +937,14 @@
   printf("Movie Downloaded\n");
 }
 
+
+void nsPluginInstance::onMouseClick() {
+  SEM_WAIT(mCrossThreadSem);
+  mMouseButtonDown = TRUE;
+  printf("Mouse was clicked in plugin area\n");
+  SEM_SIGNAL(mCrossThreadSem);
+}
+
 // C hooks for the callback notification functions
 extern "C" {
 void
@@ -941,6 +962,11 @@
   i->onMovieDownload();
 }
 
+void
+onMouseClick(nsPluginInstance *i) {
+  i->onMouseClick();
+}
+
 } // extern "C"
 
 
@@ -1001,6 +1027,11 @@
       }
     }
   }
+  
+  if (mMouseButtonDown) {
+    mMouseButtonDown = FALSE;
+    mMouseClickCallback->Call();
+  }
 
   if (useSemaphore) {
     SEM_SIGNAL(mCrossThreadSem);

Modified: liboggplay/trunk/plugin/plugin.h
===================================================================
--- liboggplay/trunk/plugin/plugin.h	2008-01-25 05:05:52 UTC (rev 3384)
+++ liboggplay/trunk/plugin/plugin.h	2008-01-25 06:48:00 UTC (rev 3385)
@@ -119,9 +119,13 @@
   void    registerCMMLCallback(nsILibOggCallbackString *cbObj);
   void    registerEndPlayCallback(nsILibOggCallbackNoArg *cbObj);
   void    registerPlaylistCallback(nsILibOggCallbackNoArg *cbObj);
+  void    registerOnMouseClickCallback(nsILibOggCallbackNoArg *cbObj);
   void    onCMMLData(char **cmml_data, int cmml_size, int async);
   void    onEndOfMovie();
   void    onMovieDownload();
+#ifdef WIN32
+  void    onMouseClick();
+#endif
 
   // This is only public so the Windows "heartbeat" function can
   // access it. If you're not PluginCallbackProc, don't touch!
@@ -148,12 +152,14 @@
   bool                        mPlaylistFreeze;
   bool                        mPlaylistFrozen;
   bool                        mReachedEndOfMovie;
+  bool                        mMouseButtonDown;
   std::vector<char*>          mCmmlStrings;
   char                      * mAsyncCmmlString;
   nsILibOggCallbackString   * mCmmlCallback;
   nsILibOggCallbackString   * mAsyncCmmlCallback;
   nsILibOggCallbackNoArg    * mEndPlayCallback;
   nsILibOggCallbackNoArg    * mPlaylistCallback;
+  nsILibOggCallbackNoArg    * mMouseClickCallback;
   semaphore                   mCrossThreadSem;
 
 #if defined(XP_WIN)

Modified: liboggplay/trunk/plugin/plugin_c.h
===================================================================
--- liboggplay/trunk/plugin/plugin_c.h	2008-01-25 05:05:52 UTC (rev 3384)
+++ liboggplay/trunk/plugin/plugin_c.h	2008-01-25 06:48:00 UTC (rev 3385)
@@ -13,4 +13,7 @@
 void
 onMovieDownload(nsPluginInstance *i);
 
+void 
+onMouseClick(nsPluginInstance *i);
+
 #endif

Modified: liboggplay/trunk/plugin/plugin_gui_win32.c
===================================================================
--- liboggplay/trunk/plugin/plugin_gui_win32.c	2008-01-25 05:05:52 UTC (rev 3384)
+++ liboggplay/trunk/plugin/plugin_gui_win32.c	2008-01-25 06:48:00 UTC (rev 3385)
@@ -502,6 +502,9 @@
     case WM_DESTROY : 
       PostQuitMessage(0);
       break;
+    case WM_MBUTTONDOWN : 
+      //onMouseClick(info->plugin_instance);
+      break;
     default:
       break;
   }

Modified: liboggplay/trunk/plugin/support/nsScriptablePeer.cpp
===================================================================
--- liboggplay/trunk/plugin/support/nsScriptablePeer.cpp	2008-01-25 05:05:52 UTC (rev 3384)
+++ liboggplay/trunk/plugin/support/nsScriptablePeer.cpp	2008-01-25 06:48:00 UTC (rev 3385)
@@ -339,3 +339,9 @@
     mPlugin->registerPlaylistCallback(cbObj);
   return NS_OK;
 }
+
+NS_IMETHODIMP nsScriptablePeer::RegisterOnMouseClickCallback(nsILibOggCallbackNoArg *cbObj) {
+    if(mPlugin)
+      mPlugin->registerOnMouseClickCallback(cbObj);
+    return NS_OK;
+}



More information about the commits mailing list