Bug 335696 - Provide helper method for embedding in AWT/Swing (Mac only for the moment). r=bsmeberg

git-svn-id: svn://10.0.0.236/trunk@216856 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
pedemont%us.ibm.com
2006-12-11 21:07:02 +00:00
parent 58b58f6992
commit a696c4c0e4
10 changed files with 152 additions and 20 deletions

View File

@@ -48,6 +48,10 @@
#include "nsXULAppAPI.h"
#include "nsILocalFile.h"
#ifdef XP_MACOSX
#include "jawt.h"
#endif
extern "C" NS_EXPORT void
MOZILLA_NATIVE(initialize) (JNIEnv* env, jobject)
@@ -314,3 +318,41 @@ GRE_NATIVE(notifyProfile) (JNIEnv *env, jobject)
XRE_NotifyProfile();
}
#ifdef XP_MACOSX
extern PRUint64 GetPlatformHandle(JAWT_DrawingSurfaceInfo* dsi);
#endif
extern "C" NS_EXPORT jlong
MOZILLA_NATIVE(getNativeHandleFromAWT) (JNIEnv* env, jobject clazz,
jobject widget)
{
PRUint64 handle = 0;
#ifdef XP_MACOSX
JAWT awt;
awt.version = JAWT_VERSION_1_4;
jboolean result = JAWT_GetAWT(env, &awt);
if (result == JNI_FALSE)
return 0;
JAWT_DrawingSurface* ds = awt.GetDrawingSurface(env, widget);
if (ds != nsnull) {
jint lock = ds->Lock(ds);
if (!(lock & JAWT_LOCK_ERROR)) {
JAWT_DrawingSurfaceInfo* dsi = ds->GetDrawingSurfaceInfo(ds);
if (dsi) {
handle = GetPlatformHandle(dsi);
ds->FreeDrawingSurfaceInfo(dsi);
}
ds->Unlock(ds);
}
awt.FreeDrawingSurface(ds);
}
#else
NS_WARNING("getNativeHandleFromAWT JNI method not implemented");
#endif
return handle;
}