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.
This commit is contained in:
edburns%acm.org 2005-05-16 13:39:22 +00:00
parent 26d416906e
commit 4e954005fe
4 changed files with 16 additions and 31 deletions

View File

@ -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);
}
}

View File

@ -30,7 +30,7 @@ class CocoaBrowserControlCanvas {
public:
static jint cocoaGetHandleToPeer(JNIEnv *env, jobject canvas, jobject graphics);
static jint cocoaGetHandleToPeer(JNIEnv *env, jobject canvas);
};

View File

@ -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);

View File

@ -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;
}