From c0a1e344f22084a4e3e3a57ab08e0f036cb9d0ee Mon Sep 17 00:00:00 2001 From: "ashuk%eng.sun.com" Date: Fri, 25 May 2001 23:09:54 +0000 Subject: [PATCH] Bug=81648 author=ashuk r=edburns Files modified: M mozilla/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/win32/Win32BrowserControlCanvas.java M mozilla/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/motif/MotifBrowserControlCanvas.java M mozilla/java/webclient/classes_spec/org/mozilla/webclient/BrowserControlCanvas.java M mozilla/java/webclient/src_moz/motif/MotifBrowserControlCanvas.cpp M mozilla/java/webclient/src_moz/motif/MotifBrowserControlCanvas.h M mozilla/java/webclient/src_moz/motif/MotifBrowserControlCanvasStub.cpp M mozilla/java/webclient/src_moz/Makefile.in M mozilla/java/webclient/src_moz/Makefile.win A mozilla/java/webclient/src_moz/win32/Makefile.win A mozilla/java/webclient/src_moz/win32/Win32BrowserControlCanvas.cpp A mozilla/java/webclient/src_moz/win32/Win32BrowserControlCanvas.h This fix removes the deprecated methods used in Webclient and now uses the JAWT Native Interface for allowing the Java AWT canvas access to the native peer window. --- .../webclient/BrowserControlCanvas.java | 33 ++--- .../motif/MotifBrowserControlCanvas.java | 21 +-- .../win32/Win32BrowserControlCanvas.java | 9 +- java/webclient/src_moz/Makefile.in | 133 ++---------------- java/webclient/src_moz/Makefile.win | 10 +- .../motif/MotifBrowserControlCanvas.cpp | 70 +++++++++ .../src_moz/motif/MotifBrowserControlCanvas.h | 8 ++ .../motif/MotifBrowserControlCanvasStub.cpp | 15 ++ java/webclient/src_moz/win32/Makefile.win | 74 ++++++++++ .../win32/Win32BrowserControlCanvas.cpp | 99 +++++++++++++ .../src_moz/win32/Win32BrowserControlCanvas.h | 23 +++ 11 files changed, 332 insertions(+), 163 deletions(-) create mode 100755 java/webclient/src_moz/win32/Makefile.win create mode 100644 java/webclient/src_moz/win32/Win32BrowserControlCanvas.cpp create mode 100644 java/webclient/src_moz/win32/Win32BrowserControlCanvas.h diff --git a/java/webclient/classes_spec/org/mozilla/webclient/BrowserControlCanvas.java b/java/webclient/classes_spec/org/mozilla/webclient/BrowserControlCanvas.java index 67a87a14df59..d50dcdd9f486 100644 --- a/java/webclient/classes_spec/org/mozilla/webclient/BrowserControlCanvas.java +++ b/java/webclient/classes_spec/org/mozilla/webclient/BrowserControlCanvas.java @@ -52,7 +52,7 @@ import java.awt.*; * See concrete subclasses for scope info. - * @version $Id: BrowserControlCanvas.java,v 1.1 2000/03/04 01:10:51 edburns%acm.org Exp $ + * @version $Id: BrowserControlCanvas.java,v 1.2 2001/05/25 23:09:45 ashuk%eng.sun.com Exp $ * @see org.mozilla.webclient.win32.Win32BrowserControlCanvas @@ -121,11 +121,10 @@ protected void initialize(BrowserControl controlImpl) } /** - * Obtain the native window handle for this component's - * peer. + * Create the Native gtk window and get it's handle */ -abstract protected int getWindow(DrawingSurfaceInfo dsi); +abstract protected int getWindow(); // // Methods from Canvas @@ -138,16 +137,12 @@ abstract protected int getWindow(DrawingSurfaceInfo dsi); public void addNotify () { super.addNotify(); - - DrawingSurface ds = (DrawingSurface)this.getPeer(); - DrawingSurfaceInfo dsi = ds.getDrawingSurfaceInfo(); - + windowRelativeBounds = new Rectangle(); - - // We must lock() the DrawingSurfaceInfo before - // accessing its native window handle. - dsi.lock(); - nativeWindow = getWindow(dsi); + + //Create the Native gtkWindow and it's container and + //get a handle to this widget + nativeWindow = getWindow(); try { Rectangle r = new Rectangle(getBoundsRelativeToWindow()); @@ -155,21 +150,17 @@ public void addNotify () WindowControl wc = (WindowControl) webShell.queryInterface(BrowserControl.WINDOW_CONTROL_NAME); + //This createWindow call sets in motion the creation of the + //nativeInitContext and the creation of the Mozilla embedded + //webBrowser wc.createWindow(nativeWindow, r); } catch (Exception e) { - dsi.unlock(); System.out.println(e.toString()); return; } - - dsi.unlock(); - + initializeOK = true; webShellCount++; - - /* - requestFocus(); - */ } // addNotify() public BrowserControl getWebShell () diff --git a/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/motif/MotifBrowserControlCanvas.java b/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/motif/MotifBrowserControlCanvas.java index c60d221f65d2..6d4fcbdd802c 100644 --- a/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/motif/MotifBrowserControlCanvas.java +++ b/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/motif/MotifBrowserControlCanvas.java @@ -36,7 +36,7 @@ import org.mozilla.util.ParameterCheck; * There is one instance of the WebShellCanvas per top level awt Frame. - * @version $Id: MotifBrowserControlCanvas.java,v 1.2 2000/03/07 22:16:07 ashuk%eng.sun.com Exp $ + * @version $Id: MotifBrowserControlCanvas.java,v 1.3 2001/05/25 23:09:44 ashuk%eng.sun.com Exp $ * * @see org.mozilla.webclient.BrowserControlCanvasFactory * @@ -75,6 +75,8 @@ public class MotifBrowserControlCanvas extends BrowserControlCanvas /* implement private native void reparentWindow(int child, int parent); private native void processEvents(); private native void setGTKWindowSize(int gtkWinPtr, int width, int height); + //New method for obtaining access to the Native Peer handle + private native int getHandleToPeer(); public MotifBrowserControlCanvas() { super(); @@ -91,9 +93,12 @@ public class MotifBrowserControlCanvas extends BrowserControlCanvas /* implement if (firstTime) { synchronized(getTreeLock()) { - canvasWinID = this.drawingSurfaceInfo.getDrawable(); + //Use the AWT Native Peer interface to get the handle + //of this Canvas's native peer + canvasWinID = this.getHandleToPeer(); + //Set our canvas as a parent of the top-level gtk widget + //which contains Mozilla. this.reparentWindow(this.gtkWinID, this.canvasWinID); - firstTime = false; } } @@ -115,15 +120,14 @@ public class MotifBrowserControlCanvas extends BrowserControlCanvas /* implement } /** - * Obtain the native window handle for this - * component's peer. + * Create the top-level gtk window to be embedded in our AWT + * Window and return a handle to this window * * @returns The native window handle. */ - protected int getWindow(DrawingSurfaceInfo dsi) { + + protected int getWindow() { synchronized(getTreeLock()) { - this.drawingSurfaceInfo = (MDrawingSurfaceInfo) dsi; - this.gtkTopWindow = this.createTopLevelWindow(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); @@ -137,5 +141,6 @@ public class MotifBrowserControlCanvas extends BrowserControlCanvas /* implement return this.gtkWinPtr; } + } diff --git a/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/win32/Win32BrowserControlCanvas.java b/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/win32/Win32BrowserControlCanvas.java index 3987e48ab711..c0468a542760 100644 --- a/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/win32/Win32BrowserControlCanvas.java +++ b/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/win32/Win32BrowserControlCanvas.java @@ -37,7 +37,7 @@ import org.mozilla.util.ParameterCheck; * There is one instance of the BrowserControlCanvas per top level awt Frame. - * @version $Id: Win32BrowserControlCanvas.java,v 1.1 2000/03/04 01:10:58 edburns%acm.org Exp $ + * @version $Id: Win32BrowserControlCanvas.java,v 1.2 2001/05/25 23:09:42 ashuk%eng.sun.com Exp $ * * @see org.mozilla.webclient.BrowserControlCanvasFactory * @@ -59,6 +59,8 @@ public class Win32BrowserControlCanvas extends BrowserControlCanvas { System.loadLibrary("webclient"); } + //New method for obtaining access to the Native Peer handle + private native int getHandleToPeer(); /** * Obtain the native window handle for this @@ -66,8 +68,7 @@ public class Win32BrowserControlCanvas extends BrowserControlCanvas { * * @returns The native window handle. */ - protected int getWindow(DrawingSurfaceInfo dsi) { - WDrawingSurfaceInfo ds = (WDrawingSurfaceInfo)dsi; - return ds.getHWnd(); + protected int getWindow() { + return this.getHandleToPeer(); } } diff --git a/java/webclient/src_moz/Makefile.in b/java/webclient/src_moz/Makefile.in index d7f8c7155424..0ed13a90326b 100644 --- a/java/webclient/src_moz/Makefile.in +++ b/java/webclient/src_moz/Makefile.in @@ -99,11 +99,14 @@ ifdef MOZ_ENABLE_GTK ifndef MOZ_MONOLITHIC_TOOLKIT CXXFLAGS += $(MOZ_GTK_CFLAGS) CFLAGS += $(MOZ_GTK_CFLAGS) -EXTRA_DSO_LDOPTS += -lgtkxtbin -lgtksuperwin -lwc_share -lembed_base_s -L/usr/X11R6/lib -lXt +# Adding $(JDKHOME)/jre/lib/sparc because we need to link against +# the libjawt.so shared library for the JAWT Native Interface +# functionality to work correctly. +EXTRA_DSO_LDOPTS += -lgtkxtbin -lgtksuperwin -lwc_share -lembed_base_s -L$(JDKHOME)/jre/lib/sparc -ljawt -L/usr/X11R6/lib -lXt else CXXFLAGS += $(TK_CFLAGS) CFLAGS += $(TK_CFLAGS) -EXTRA_DSO_LDOPTS += -lgtkxtbin -lgtksuperwin -lwc_share -lembed_base_s -L/usr/X11R6/lib -lXt +EXTRA_DSO_LDOPTS += -lgtkxtbin -lgtksuperwin -lwc_share -lembed_base_s -L$(JDKHOME)/jre/lib/sparc -ljawt -L/usr/X11R6/lib -lXt endif endif @@ -122,67 +125,15 @@ endif ifeq ($(OS_ARCH),Linux) INCLUDES := -I$(JDKHOME)/include -I$(JDKHOME)/include/linux $(INCLUDES) \ - -I$(DEPTH)/widget/src/gtk -I../src_share + -I$(DEPTH)/widget/src/gtk -I../src_share -I../src_moz else INCLUDES := -I$(JDKHOME)/include -I$(JDKHOME)/include/solaris $(INCLUDES) \ - -I$(DEPTH)/widget/src/gtk -I../src_share + -I$(DEPTH)/widget/src/gtk -I../src_share -I../src_moz endif -ifneq ($(PACKAGE_BUILD),) -ifneq ($(VERSION_NUMBER),) -VERSION_NUMBER=0.9 -endif # VERSION_NUMBER -PACKAGE_DIR=$(topsrcdir)/dist/javadev -PACKAGE_LIB=$(PACKAGE_DIR)/lib -PACKAGE_EXAMPLE=$(PACKAGE_DIR)/example -endif # PACKAGE_BUILD - -ifneq ($(WEBCLIENT_PACKAGE_BUILD),) -PACKAGE_VER = 1_0 -PACKAGE_DIR = $(DIST)/javadev -PACKAGE_LIB = $(PACKAGE_DIR)/lib -PACKAGE_EXAMPLE = $(PACKAGE_DIR)/example -endif # WEBCLIENT_PACKAGE_BUILD - - - buildRunems: ifeq ($(BAL_INTERFACE),) -ifneq ($(WEBCLIENT_PACKAGE_BUILD),) - @echo +++ Creating Commercial Package. Use runem to run the test browser. - @echo +++ Checking for special libwidget_gtk.so. -ifeq ($(OS_ARCH),Linux) - @if test ! -f libwidget_gtk.so ; then echo "You don't have libwidget_gtk.so, see the IMPORTANT section in Makefile.in!!!"; stopbuild; else echo "Found libwidget_gtk.so, continuing."; fi ; - chmod 775 libwidget_gtk.so - cp -f libwidget_gtk.so $(PACKAGE_LIB) -endif - rm -f runem_unix_commercial - @echo "#!/bin/csh -x" >> runem_unix_commercial - @echo ln -s -f "$$"MOZILLA_FIVE_HOME/javadev/lib/libjavadom.so "$$"MOZILLA_FIVE_HOME/components/libjavadom.so >> runem_unix_commercial - @echo setenv CLASSPATH "$$"MOZILLA_FIVE_HOME/javadev/lib/$(LIBRARY_NAME)_$(PACKAGE_VER).jar>> runem_unix_commercial - @echo setenv LD_LIBRARY_PATH "$$"MOZILLA_FIVE_HOME'"':'"'"$$"MOZILLA_FIVE_HOME/components'"':'"'"$$"MOZILLA_FIVE_HOME/javadev/lib'"':'"'"$$"LD_LIBRARY_PATH>> runem_unix_commercial - @echo "$$"JDKHOME/bin/java org.mozilla.webclient.test.EmbeddedMozillaImpl "$$"MOZILLA_FIVE_HOME "$$"1 >> runem_unix_commercial - mkdir -p $(PACKAGE_EXAMPLE) - chmod 775 $(PACKAGE_EXAMPLE) - cp -f $(DIST)/bin/lib$(LIBRARY_NAME).so $(PACKAGE_LIB) - cp -f $(DIST)/bin/lib$(LIBRARY_NAME)stub.so $(PACKAGE_LIB) - cp -f $(DIST)/bin/libjavadomjni.so $(PACKAGE_LIB) - cp -f $(DIST)/bin/components/libjavadom.so $(PACKAGE_LIB) - chmod 775 $(PACKAGE_LIB)/lib$(LIBRARY_NAME).so - chmod 775 $(PACKAGE_LIB)/lib$(LIBRARY_NAME)stub.so - chmod 775 $(PACKAGE_LIB)/libjavadomjni.so - chmod 775 $(PACKAGE_LIB)/libjavadom.so - cp -f $(DEPTH)/java/webclient/src_moz/runem_unix_commercial $(PACKAGE_EXAMPLE)/runem - - chmod 775 $(PACKAGE_EXAMPLE)/runem - cp -f $(DEPTH)/java/webclient/src_moz/install_win32.js $(DIST)/install.js -ifeq ($(OS_ARCH),Linux) - cd $(DIST); zip -r $(LIBRARY_NAME)_$(PACKAGE_VER)_linux.xpi install.js javadev -else - cd $(DIST); zip -r $(LIBRARY_NAME)_$(PACKAGE_VER)_solaris.xpi install.js javadev -endif -endif ifeq ($(PACKAGE_BUILD),) @echo +++ Creating runem. Use this to run the test browser. rm -f runem @@ -190,69 +141,6 @@ ifeq ($(PACKAGE_BUILD),) @echo $(PERL) ../src_share/runem.pl org.mozilla.webclient.test.EmbeddedMozillaImpl $(DEPTH) "$$"1 "$$"2 "$$"3 "$$"4 "$$"4 "$$"6 >> runem chmod 755 runem else - @echo +++ Commercial Packaging - Copying runem_solaris. Used to run test - if test ! -d $(PACKAGE_EXAMPLE) ; then mkdir $(PACKAGE_EXAMPLE) ; else true ; fi ; - cp $(topsrcdir)/dist/bin/libwebclientstub.so $(PACKAGE_LIB)/libwebclientstub.so.$(VERSION_NUMBER) - cp $(topsrcdir)/dist/bin/libwebclient.so $(PACKAGE_LIB)/libwebclient.so.$(VERSION_NUMBER) - cp $(topsrcdir)/dist/lib/libwc_share.a $(PACKAGE_LIB)/libwc_share.a.$(VERSION_NUMBER) - cp $(topsrcdir)/dist/bin/libjavadomjni.so $(PACKAGE_LIB)/libjavadomjni.so.$(VERSION_NUMBER) - cp $(topsrcdir)/dist/bin/libplugletjni.so $(PACKAGE_LIB)/libplugletjni.so.$(VERSION_NUMBER) - cp $(topsrcdir)/dist/bin/components/libpluglet.so $(PACKAGE_LIB)/libpluglet.so.$(VERSION_NUMBER) - cp $(topsrcdir)/dist/bin/components/libjavadom.so $(PACKAGE_LIB)/libjavadom.so.$(VERSION_NUMBER) - cp $(topsrcdir)/dist/bin/components/libbcorb.so $(PACKAGE_LIB)/libbcorb.so.$(VERSION_NUMBER) - cp $(topsrcdir)/dist/bin/components/libbcjavastubs.so $(PACKAGE_LIB)/libbcjavastubs.so.$(VERSION_NUMBER) - cp $(topsrcdir)/dist/bin/components/libjavaloader.so $(PACKAGE_LIB)/libjavaloader.so.$(VERSION_NUMBER) - cp $(topsrcdir)/dist/bin/components/libjavaSample.so $(PACKAGE_LIB)/libjavaSample.so.$(VERSION_NUMBER) - cp $(topsrcdir)/dist/bin/components/libbcTest.so $(PACKAGE_LIB)/libbcTest.so.$(VERSION_NUMBER) - cp $(topsrcdir)/dist/bin/components/libbcxpcomstubs.so $(PACKAGE_LIB)/libbcxpcomstubs.so.$(VERSION_NUMBER) - rm -f $(topsrcdir)/dist/bin/libwebclientstub.so - rm -f $(topsrcdir)/dist/lib/libwebclientstub.so - rm -f $(topsrcdir)/dist/bin/libwebclient.so - rm -f $(topsrcdir)/dist/lib/libwebclient.so - rm -f $(topsrcdir)/dist/lib/libwc_share.a - rm -f $(topsrcdir)/dist/bin/libjavadomjni.so - rm -f $(topsrcdir)/dist/lib/libjavadomjni.so - rm -f $(topsrcdir)/dist/bin/libplugletjni.so - rm -f $(topsrcdir)/dist/lib/libplugletjni.so - rm -f $(topsrcdir)/dist/bin/components/libpluglet.so - rm -f $(topsrcdir)/dist/lib/components/libpluglet.so - rm -f $(topsrcdir)/dist/bin/components/libjavadom.so - rm -f $(topsrcdir)/dist/lib/components/libjavadom.so - rm -f $(topsrcdir)/dist/bin/components/libbcorb.so - rm -f $(topsrcdir)/dist/bin/components/libbcjavastubs.so - rm -f $(topsrcdir)/dist/bin/components/libjavaloader.so - rm -f $(topsrcdir)/dist/bin/components/libjavaSample.so - rm -f $(topsrcdir)/dist/bin/components/libbcTest.so - rm -f $(topsrcdir)/dist/bin/components/libbcxpcomstubs.so - chmod 555 $(PACKAGE_LIB)/libwebclientstub.so.$(VERSION_NUMBER) - chmod 555 $(PACKAGE_LIB)/libwebclient.so.$(VERSION_NUMBER) - chmod 555 $(PACKAGE_LIB)/libwc_share.a.$(VERSION_NUMBER) - chmod 555 $(PACKAGE_LIB)/libjavadomjni.so.$(VERSION_NUMBER) - chmod 555 $(PACKAGE_LIB)/libplugletjni.so.$(VERSION_NUMBER) - chmod 555 $(PACKAGE_LIB)/libpluglet.so.$(VERSION_NUMBER) - chmod 555 $(PACKAGE_LIB)/libjavadom.so.$(VERSION_NUMBER) - chmod 555 $(PACKAGE_LIB)/libbcorb.so.$(VERSION_NUMBER) - chmod 555 $(PACKAGE_LIB)/libbcjavastubs.so.$(VERSION_NUMBER) - chmod 555 $(PACKAGE_LIB)/libjavaloader.so.$(VERSION_NUMBER) - chmod 555 $(PACKAGE_LIB)/libjavaSample.so.$(VERSION_NUMBER) - chmod 555 $(PACKAGE_LIB)/libbcTest.so.$(VERSION_NUMBER) - chmod 555 $(PACKAGE_LIB)/libbcxpcomstubs.so.$(VERSION_NUMBER) - if test ! -d $(PACKAGE_LIB)/libbcorb.so ; then ln -s libbcorb.so.$(VERSION_NUMBER) $(PACKAGE_LIB)/libbcorb.so ; else true ; fi ; - if test ! -d $(PACKAGE_LIB)/libbcjavastubs.so ; then ln -s libbcjavastubs.so.$(VERSION_NUMBER) $(PACKAGE_LIB)/libbcjavastubs.so ; else true ; fi ; - if test ! -d $(PACKAGE_LIB)/libjavaloader.so ; then ln -s libjavaloader.so.$(VERSION_NUMBER) $(PACKAGE_LIB)/libjavaloader.so ; else true ; fi ; - if test ! -d $(PACKAGE_LIB)/libjavaSample.so ; then ln -s libjavaSample.so.$(VERSION_NUMBER) $(PACKAGE_LIB)/libjavaSample.so ; else true ; fi ; - if test ! -d $(PACKAGE_LIB)/libbcTest.so ; then ln -s libbcTest.so.$(VERSION_NUMBER) $(PACKAGE_LIB)/libbcTest.so ; else true ; fi ; - if test ! -d $(PACKAGE_LIB)/libbcxpcomstubs.so ; then ln -s libbcxpcomstubs.so.$(VERSION_NUMBER) $(PACKAGE_LIB)/libbcxpcomstubs.so ; else true ; fi ; - if test ! -d $(PACKAGE_LIB)/libwc_share.a ; then ln -s libwc_share.a.$(VERSION_NUMBER) $(PACKAGE_LIB)/libwc_share.a ; else true ; fi ; - if test ! -d $(PACKAGE_LIB)/libwebclientstub.so ; then ln -s libwebclientstub.so.$(VERSION_NUMBER) $(PACKAGE_LIB)/libwebclientstub.so ; else true ; fi ; - if test ! -d $(PACKAGE_LIB)/libwebclient.so ; then ln -s libwebclient.so.$(VERSION_NUMBER) $(PACKAGE_LIB)/libwebclient.so ; else true ; fi ; - if test ! -d $(PACKAGE_LIB)/libjavadomjni.so ; then ln -s libjavadomjni.so.$(VERSION_NUMBER) $(PACKAGE_LIB)/libjavadomjni.so ; else true ; fi ; - if test ! -d $(PACKAGE_LIB)/libplugletjni.so ; then ln -s libplugletjni.so.$(VERSION_NUMBER) $(PACKAGE_LIB)/libplugletjni.so ; else true ; fi ; - if test ! -d $(PACKAGE_LIB)/libpluglet.so ; then ln -s libpluglet.so.$(VERSION_NUMBER) $(PACKAGE_LIB)/libpluglet.so ; else true ; fi ; - if test ! -d $(PACKAGE_LIB)/libjavadom.so ; then ln -s libjavadom.so.$(VERSION_NUMBER) $(PACKAGE_LIB)/libjavadom.so ; else true ; fi ; - if test ! -d $(PACKAGE_EXAMPLE)/runem ; then cp $(topsrcdir)/java/webclient/src_share/runem_solaris $(PACKAGE_EXAMPLE)/runem ; else true ; fi ; - chmod 755 $(PACKAGE_EXAMPLE)/runem - cp $(topsrcdir)/java/README.commercial $(PACKAGE_DIR)/README endif # PACKAGE_BUILD endif # BAL_INTERFACE @@ -260,9 +148,4 @@ install:: buildRunems clobber_all:: clobber -ifneq ($(WEBCLIENT_PACKAGE_BUILD),) - rm -f runem_unix_commercial - rm -rf $(DIST)/javadev - rm -f $(DIST)/$(LIBRARY_NAME)_$(PACKAGE_VER)*.xpi - rm -f $(DIST)/install.js -endif + diff --git a/java/webclient/src_moz/Makefile.win b/java/webclient/src_moz/Makefile.win index ebd7e955e32e..557899c91bcf 100644 --- a/java/webclient/src_moz/Makefile.win +++ b/java/webclient/src_moz/Makefile.win @@ -26,6 +26,7 @@ MAKE_OBJ_TYPE = DLL MODULE=webclient +DIRS = win32 OBJS = \ .\$(OBJDIR)\ns_util.obj \ @@ -55,6 +56,7 @@ OBJS = \ .\$(OBJDIR)\PreferencesImpl.obj \ .\$(OBJDIR)\PreferencesActionEvents.obj \ .\$(OBJDIR)\ISupportsPeer.obj \ + .\win32\$(OBJDIR)\Win32BrowserControlCanvas.obj \ $(NULL) @@ -85,6 +87,7 @@ LLIBS = \ $(DIST)\lib\nspr4.lib \ $(DIST)\lib\plc4.lib \ $(DIST)\lib\plds4.lib \ + $(JDKHOME)\jre\lib\jawt.lib \ $(NULL) WIN_LIBS= \ @@ -111,6 +114,7 @@ include <$(DEPTH)\config\rules.mak> INCS = \ -I..\bal\ \ -I..\bal\win32 \ + -Iwin32 \ $(INCS) \ $(NULL) !else @@ -145,11 +149,7 @@ install:: $(DLL) buildRunems clobber_all:: clobber -!ifdef PACKAGE_BUILD - rm -rf $(DIST)\javadev - rm -f $(DIST)\$(DLLNAME)_$(PACKAGE_VER).xpi - rm -f $(DIST)\install.js -!endif + clobber:: rm -f $(DIST)\bin\$(DLLNAME).dll diff --git a/java/webclient/src_moz/motif/MotifBrowserControlCanvas.cpp b/java/webclient/src_moz/motif/MotifBrowserControlCanvas.cpp index 4dfa3c41bbc2..f8c86f349a1f 100644 --- a/java/webclient/src_moz/motif/MotifBrowserControlCanvas.cpp +++ b/java/webclient/src_moz/motif/MotifBrowserControlCanvas.cpp @@ -26,6 +26,8 @@ */ #include +#include +#include #include "MotifBrowserControlCanvas.h" #include @@ -40,6 +42,8 @@ #include +#include "ns_util.h" //for throwing Exceptions to Java + extern "C" void NS_SetupRegistry(); extern "C" { @@ -153,6 +157,72 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBro } } + +/* + * Class: org_mozilla_webclient_motif_MotifBrowserControlCanvas + * Method: getHandleToPeer + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_getHandleToPeer +(JNIEnv * env, jobject canvas) { + JAWT awt; + JAWT_DrawingSurface* ds; + JAWT_DrawingSurfaceInfo* dsi; + JAWT_X11DrawingSurfaceInfo* dsi_x11; + Drawable handle_x11; + jint lock; + + //Get the AWT + awt.version = JAWT_VERSION_1_3; + if (JAWT_GetAWT(env, &awt) == JNI_FALSE) { + printf(" +++ AWT Not Found +++ \n"); + ::util_ThrowExceptionToJava(env, "Exception: AWT Not Found"); + return 0; + } + + //Get the Drawing Surface + ds = awt.GetDrawingSurface(env, canvas); + if (ds == NULL) { + printf(" +++ NULL Drawing Surface +++ \n"); + ::util_ThrowExceptionToJava(env, "Exception: Null Drawing Surface"); + return 0; + } + + //Lock the Drawing Surface + lock = ds->Lock(ds); + if ((lock & JAWT_LOCK_ERROR) != 0) { + printf(" +++ Error Locking Surface +++ \n"); + ::util_ThrowExceptionToJava(env, "Exception: Error Locking Surface"); + awt.FreeDrawingSurface(ds); + return 0; + } + + //Get the Drawing Surface info + dsi = ds->GetDrawingSurfaceInfo(ds); + if (dsi == NULL) { + printf(" +++ Error Getting Surface Info +++ \n"); + ::util_ThrowExceptionToJava(env, "Exception: Error Getting Surface Info"); + ds->Unlock(ds); + awt.FreeDrawingSurface(ds); + return 0; + } + + //Get the Platform specific Drawing Info + dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo; + + //Get the Handle to the Native Drawing Surface info + handle_x11 = (Drawable) dsi_x11->drawable; + + //Clean up after us + ds->FreeDrawingSurfaceInfo(dsi); + ds->Unlock(ds); + awt.FreeDrawingSurface(ds); + + //return the native peer handle + return (jint) handle_x11; + +} + /* * Class: org_mozilla_webclient_motif_MotifBrowserControlCanvas * Method: loadMainDll diff --git a/java/webclient/src_moz/motif/MotifBrowserControlCanvas.h b/java/webclient/src_moz/motif/MotifBrowserControlCanvas.h index dfe97c2d9fee..479760749b72 100644 --- a/java/webclient/src_moz/motif/MotifBrowserControlCanvas.h +++ b/java/webclient/src_moz/motif/MotifBrowserControlCanvas.h @@ -45,6 +45,14 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBro JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_createTopLevelWindow (JNIEnv *, jobject); +/* + * Class: org_mozilla_webclient_wrapper_0005fnative_motif_MotifBrowserControlCanvas + * Method: getHandleToPeer + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_getHandleToPeer + (JNIEnv *, jobject); + /* * Class: org_mozilla_webclient_wrapper_0005fnative_motif_MotifBrowserControlCanvas * Method: getGTKWinID diff --git a/java/webclient/src_moz/motif/MotifBrowserControlCanvasStub.cpp b/java/webclient/src_moz/motif/MotifBrowserControlCanvasStub.cpp index f784f001e182..8d0bac60019f 100644 --- a/java/webclient/src_moz/motif/MotifBrowserControlCanvasStub.cpp +++ b/java/webclient/src_moz/motif/MotifBrowserControlCanvasStub.cpp @@ -43,6 +43,7 @@ jint (* getGTKWinID) (JNIEnv *, jobject, jint); void (* reparentWindow) (JNIEnv *, jobject, jint, jint); void (* processEvents) (JNIEnv *, jobject); void (* setGTKWindowSize) (JNIEnv *, jobject, jint, jint, jint); +jint (* getHandleToPeer) (JNIEnv *, jobject); void locateMotifBrowserControlStubFunctions(void * dll) { createTopLevelWindow = (jint (*) (JNIEnv *, jobject)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_createTopLevelWindow"); @@ -50,6 +51,11 @@ void locateMotifBrowserControlStubFunctions(void * dll) { printf("got dlsym error %s\n", dlerror()); } + getHandleToPeer = (jint (*) (JNIEnv *, jobject)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_getHandleToPeer"); + if (!getHandleToPeer) { + printf("got dlsym error %s\n", dlerror()); + } + createContainerWindow = (jint (*) (JNIEnv *, jobject, jint, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_createContainerWindow"); if (!createContainerWindow) { printf("got dlsym error %s\n", dlerror()); @@ -85,6 +91,15 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBro return (* createTopLevelWindow) (env, obj); } +/* + * Class: org_mozilla_webclient_motif_MotifBrowserControlCanvas + * Method: getHandleToPeer + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_motif_MotifBrowserControlCanvas_getHandleToPeer (JNIEnv * env, jobject obj) { + return (* getHandleToPeer) (env, obj); +} + /* * Class: org_mozilla_webclient_motif_MotifBrowserControlCanvas * Method: createContainerWindow diff --git a/java/webclient/src_moz/win32/Makefile.win b/java/webclient/src_moz/win32/Makefile.win new file mode 100755 index 000000000000..3cc578cbab01 --- /dev/null +++ b/java/webclient/src_moz/win32/Makefile.win @@ -0,0 +1,74 @@ +#!nmake +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is Sun Microsystems, +# Inc. Portions created by Sun are +# Copyright (C) 1999 Sun Microsystems, Inc. All +# Rights Reserved. +# +# Contributor(s): + +DEPTH=..\..\..\.. +MODULE=wc_win32 +include <$(DEPTH)/config/config.mak> + +OBJS = \ + .\$(OBJDIR)\Win32BrowserControlCanvas.obj \ + $(NULL) + +LCFLAGS = \ + -DDEBUG_RAPTOR_CANVAS \ + $(NULL) + +!ifdef BAL_INTERFACE +LCFLAGS = \ + $(LCFLAGS) \ + -DBAL_INTERFACE \ + $(NULL) + +LIBRARY_NAME = wc_win32_bal +!else +LIBRARY_NAME = wc_win32 +!endif + +LLIBS = \ + $(NULL) + +WIN_LIBS = \ + version.lib + +include <$(DEPTH)\config\rules.mak> + +INCS=-I.. -I..\..\src_share $(INCS) + +!ifdef BAL_INTERFACE +INCS = \ + -I..\..\bal\ \ + -I..\..\bal\win32 \ + $(INCS) \ + $(NULL) +!else +INCS = \ + -I$(JDKHOME)\include \ + -I$(JDKHOME)\include\win32 \ + $(INCS) \ + $(NULL) +!endif + +!CMDSWITCHES -S + +clobber_all:: clobber + +edburns: + @echo $(INCS) diff --git a/java/webclient/src_moz/win32/Win32BrowserControlCanvas.cpp b/java/webclient/src_moz/win32/Win32BrowserControlCanvas.cpp new file mode 100644 index 000000000000..6d2ac5160b69 --- /dev/null +++ b/java/webclient/src_moz/win32/Win32BrowserControlCanvas.cpp @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): Ashu Kulkarni + */ + + +/* + * Win32BrowserControlCanvas.cpp + */ + +#include +#include +#include + +#include "Win32BrowserControlCanvas.h" +#include "ns_util.h" //for throwing Exceptions to Java + + +/* + * Class: org_mozilla_webclient_wrapper_0005fnative_win32_Win32BrowserControlCanvas + * Method: getHandleToPeer + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_win32_Win32BrowserControlCanvas_getHandleToPeer + (JNIEnv *env, jobject canvas) { + JAWT awt; + JAWT_DrawingSurface* ds; + JAWT_DrawingSurfaceInfo* dsi; + JAWT_Win32DrawingSurfaceInfo* dsi_win; + HWND handle_win; + jint lock; + + //Get the AWT + awt.version = JAWT_VERSION_1_3; + if (JAWT_GetAWT(env, &awt) == JNI_FALSE) { + printf(" +++ AWT Not Found +++ \n"); + ::util_ThrowExceptionToJava(env, "Exception: AWT Not Found"); + return 0; + } + + //Get the Drawing Surface + ds = awt.GetDrawingSurface(env, canvas); + if (ds == NULL) { + printf(" +++ NULL Drawing Surface +++ \n"); + ::util_ThrowExceptionToJava(env, "Exception: Null Drawing Surface"); + return 0; + } + + //Lock the Drawing Surface + lock = ds->Lock(ds); + if ((lock & JAWT_LOCK_ERROR) != 0) { + printf(" +++ Error Locking Surface +++ \n"); + ::util_ThrowExceptionToJava(env, "Exception: Error Locking Surface"); + awt.FreeDrawingSurface(ds); + return 0; + } + + //Get the Drawing Surface info + dsi = ds->GetDrawingSurfaceInfo(ds); + if (dsi == NULL) { + printf(" +++ Error Getting Surface Info +++ \n"); + ::util_ThrowExceptionToJava(env, "Exception: Error Getting Surface Info"); + ds->Unlock(ds); + awt.FreeDrawingSurface(ds); + return 0; + } + + //Get the Platform specific Drawing Info + dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo; + + //Get the Handle to the Native Drawing Surface info + handle_win = (HWND) dsi_win->hwnd; + + //Clean up after us + ds->FreeDrawingSurfaceInfo(dsi); + ds->Unlock(ds); + awt.FreeDrawingSurface(ds); + + //return the native peer handle + return (jint) handle_win; + +} diff --git a/java/webclient/src_moz/win32/Win32BrowserControlCanvas.h b/java/webclient/src_moz/win32/Win32BrowserControlCanvas.h new file mode 100644 index 000000000000..dc11cda432e6 --- /dev/null +++ b/java/webclient/src_moz/win32/Win32BrowserControlCanvas.h @@ -0,0 +1,23 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class org_mozilla_webclient_wrapper_0005fnative_win32_Win32BrowserControlCanvas */ + +#ifndef _Included_org_mozilla_webclient_wrapper_0005fnative_win32_Win32BrowserControlCanvas +#define _Included_org_mozilla_webclient_wrapper_0005fnative_win32_Win32BrowserControlCanvas +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Class: org_mozilla_webclient_wrapper_0005fnative_win32_Win32BrowserControlCanvas + * Method: getHandleToPeer + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_win32_Win32BrowserControlCanvas_getHandleToPeer + (JNIEnv *, jobject); + + +#ifdef __cplusplus +} +#endif +#endif