Re: Using JavaXPCOM and XulRunner under linux
Sergio <[email protected]> Fri, 6 Feb 2009 04:54:03 -0800 (PST)
| Newsgroups | gmane.comp.mozilla.devel.java |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <[email protected]> |
On 3 feb, 12:22, Sergio <[email protected]> wrote: > Hi everybody, > > I've seen somepost about embedding xulrunner with JavaXPCOM and I > wonder if you can help me. > > I've managed to create an embedded browser in swing using javaxpcom > and xulrunner-1.8.0.4 on windows. I use a canvas to embed the browser, > getting the handle of the canvas natively from the SO. > > My code is very similar to JWeb one posted herehttp://groups.google.com/group/mozilla.dev.tech.java/browse_thread/th.... > The only exception is the way of getting the canvas handle. > > Anyway, my code is working on windows but I need to make this work on > linux. I've seen on a previous post(http://osdir.com/ml/ > mozilla.devel.oji/2007-07/msg00025.html) that a GTK window is needed > to make it work on linux. > > Do you have an example of this? , I need to use JAVA1.4 due to some > software restrictions. > > I have been capable of creating a gtk window using the canvas handle, > then getting the peer of this gtk window and do a basewindow.init with > this peer. Everything seems correct, except nothing is shown on my > canvas. > > I have use some code from MozSwing to create the gtk windows, but > mozSwing only works under Java 6.0, so I'am afraid it can`t be done > with Java 1.4. > > I will really appreciate any kind of help. > > Thaks in advance, > > Sergio Ballestero Ok, I have finally made it. If anyone cares, I've used org.mozilla.browser.impl.jna.Gdk org.mozilla.browser.impl.jna.Glib org.mozilla.browser.impl.jna.Gtk org.mozilla.browser.impl.jna.LibC org.mozilla.browser.impl.jna.X11 from MozSwing project. and I used this function to create handle, also taken from MozSwing with little changes. public long createHandle(Rectangle dim) { long mozHandle=0; Toolkit.getDefaultToolkit().sync(); // HANDLE FROM CANVAS NATIVELY OBTAINED int hw = (int) getHandleCanvas(); X11.Window awtID = new X11.Window(hw); Gtk.gtk.gtk_init(null,null); Gtk.gtk.gdk_error_trap_push(); gtkPtr = Gtk.gtk.gtk_window_new(Gtk.GTK_WINDOW_POPUP); Gtk.gtk.gtk_window_set_default_size(gtkPtr, 300, 300); Gtk.gtk.gtk_window_set_title(gtkPtr, "Mozilla Wrapper Window"); Toolkit.getDefaultToolkit().sync(); Gtk.gtk.gtk_widget_set_usize(gtkPtr, dim.width, dim.height); Gtk.gtk.gtk_widget_show(gtkPtr); Toolkit.getDefaultToolkit().sync(); X11.Window gtkID = Gtk.gtk.gdk_x11_drawable_get_xid (gtkPtr.window); GdkDisplay display = Gtk.gtk.gdk_display_get_default(); X11.Display xdisplay = Gtk.gtk.gdk_x11_display_get_xdisplay (display); X11.INSTANCE.XReparentWindow(xdisplay, gtkID, awtID, 0, 0); mozHandle = gtkPtr.getPeer(); return mozHandle; }