From 4e954005fe3f734bc6de13b8f06aba43b1757354 Mon Sep 17 00:00:00 2001 From: "edburns%acm.org" Date: Mon, 16 May 2005 13:39:22 +0000 Subject: [PATCH] Turns out the problem with the CocoaBrowserControlCanvas was that I was incorrectly interpreting the return value from Lock(). This works. Next step is to solve the nsWindow.cpp problem. --- .../CocoaBrowserControlCanvas.java | 36 ++++++------------- .../src_moz/cocoa/CocoaBrowserControlCanvas.h | 2 +- .../cocoa/CocoaBrowserControlCanvas.mm | 5 ++- .../cocoa/CocoaBrowserControlCanvasImpl.cpp | 4 +-- 4 files changed, 16 insertions(+), 31 deletions(-) diff --git a/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/CocoaBrowserControlCanvas.java b/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/CocoaBrowserControlCanvas.java index 591ee703967e..62ee281b3c62 100644 --- a/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/CocoaBrowserControlCanvas.java +++ b/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/CocoaBrowserControlCanvas.java @@ -44,11 +44,8 @@ public class CocoaBrowserControlCanvas extends BrowserControlCanvas { } //New method for obtaining access to the Native Peer handle - private native int getHandleToPeer(Graphics graphics); + private native int getHandleToPeer(); - private int nativeWindow = -1; - - /** * Obtain the native window handle for this * component's peer. @@ -56,27 +53,16 @@ public class CocoaBrowserControlCanvas extends BrowserControlCanvas { * @returns The native window handle. */ protected int getWindow() { - WCRunnable runner = new WCRunnable() { - public Object run() { - Integer result = - new Integer(CocoaBrowserControlCanvas.this.getHandleToPeer(null)); - return result; - } - }; - Integer result = null; - - this.setVisible(true); - repaint(); - while (-1 == nativeWindow) { - result = (Integer) NativeEventThread.instance.pushBlockingWCRunnable(runner); - nativeWindow = result.intValue(); - } - return nativeWindow; + Integer result = (Integer) + NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable(){ + public Object run() { + Integer result = + new Integer(CocoaBrowserControlCanvas.this.getHandleToPeer()); + return result; + } + }); + return result.intValue(); } - - public void paint(Graphics graphics) { - nativeWindow = getHandleToPeer(graphics); - } - + } diff --git a/java/webclient/src_moz/cocoa/CocoaBrowserControlCanvas.h b/java/webclient/src_moz/cocoa/CocoaBrowserControlCanvas.h index b2bf3d822542..9c895641fcdd 100644 --- a/java/webclient/src_moz/cocoa/CocoaBrowserControlCanvas.h +++ b/java/webclient/src_moz/cocoa/CocoaBrowserControlCanvas.h @@ -30,7 +30,7 @@ class CocoaBrowserControlCanvas { public: - static jint cocoaGetHandleToPeer(JNIEnv *env, jobject canvas, jobject graphics); + static jint cocoaGetHandleToPeer(JNIEnv *env, jobject canvas); }; diff --git a/java/webclient/src_moz/cocoa/CocoaBrowserControlCanvas.mm b/java/webclient/src_moz/cocoa/CocoaBrowserControlCanvas.mm index 595a37088d9f..0fc5762ab604 100644 --- a/java/webclient/src_moz/cocoa/CocoaBrowserControlCanvas.mm +++ b/java/webclient/src_moz/cocoa/CocoaBrowserControlCanvas.mm @@ -33,7 +33,7 @@ #include "jni_util.h" //for throwing Exceptions to Java -jint CocoaBrowserControlCanvas::cocoaGetHandleToPeer(JNIEnv *env, jobject canvas, jobject graphics) { +jint CocoaBrowserControlCanvas::cocoaGetHandleToPeer(JNIEnv *env, jobject canvas) { printf("debug: edburns: in CocoaBrowserControlCanvas::nativeGetHandleToPeer\n"); JAWT awt; JAWT_DrawingSurface* ds = NULL; @@ -77,10 +77,9 @@ jint CocoaBrowserControlCanvas::cocoaGetHandleToPeer(JNIEnv *env, jobject canvas printf("debug: edburns: acquired lock: %d\n", lock); fflush(stdout); - if (NULL == lock) { + if ((lock & JAWT_LOCK_ERROR) != 0) { util_ThrowExceptionToJava(env, "CocoaBrowserControlCanvas: can't lock drawing surface"); } - assert((lock & JAWT_LOCK_ERROR) == 0); // Get the drawing surface info dsi = ds->GetDrawingSurfaceInfo(ds); diff --git a/java/webclient/src_moz/cocoa/CocoaBrowserControlCanvasImpl.cpp b/java/webclient/src_moz/cocoa/CocoaBrowserControlCanvasImpl.cpp index e19d86ae76f8..46f1d2203e2c 100644 --- a/java/webclient/src_moz/cocoa/CocoaBrowserControlCanvasImpl.cpp +++ b/java/webclient/src_moz/cocoa/CocoaBrowserControlCanvasImpl.cpp @@ -37,12 +37,12 @@ * Signature: ()I */ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CocoaBrowserControlCanvas_getHandleToPeer - (JNIEnv *env, jobject canvas, jobject graphics) { + (JNIEnv *env, jobject canvas) { printf("debug: edburns: in CocoaBrowserControlCanvasImpl->nativeGetHandleToPeer\n"); fflush(stdout); jint result = -1; - result = CocoaBrowserControlCanvas::cocoaGetHandleToPeer(env, canvas, graphics); + result = CocoaBrowserControlCanvas::cocoaGetHandleToPeer(env, canvas); return result; }