Hi Javier,
there is another question about JavaXPCOM events handling. On Windows
there is an SWT message loop, which is roughly
while (::GetMessage) {
::TranslateMessage
::DispatchMessage
}
As each native window (be it an SWT widget or embedded Mozilla browser)
has its own WindowProc, this loop dispatches any message to the proper
WindowProc, that's fine.
Another situation is on Linux. There are no WindowProcs in X Window
systems, and I need to call to XNextEvent(display) and get all the
events (all the selected events to be more precise) for those windows
that were created using 'display'. Embedded browser opens a separate
connection to X server (XtOpenDisplay) and creates all its windows using
this connection. Thus, all the events for these windows (event if they
were created on the same thread as my own ones) will not be caught with
XNextEvent, so I have to use nsIAppShell.run() method and proxy objects.
I tried proxy objects but without any success: I always get 'Xlib:
unexpected async reply' messages.
I have noticed that AbstractMozillaBrowser doesn't call
nsIAppShell.run() method, on Linux. I have also tried to launch a simple
SWT application with embedded browser, on Linux, but it doesn't displays
too. The source is below. Are there any thought how to handle events on
Linux?
Thanks,
Artem
----
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.browser.*;
import org.mozilla.xpcom.*;
public class MozTest
{
public static void main(String[] args)
{
System.setProperty("GRE_HOME", "/export/art/xulrunner-bin");
Display display = new Display();
Shell shell = new Shell(display);
shell.setBounds(300, 300, 300, 300);
shell.setLayout(new GridLayout());
Composite comp = new Composite(shell, SWT.EMBEDDED);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
comp.setLayout(layout);
MozillaBrowser mb = new MozillaBrowser(comp, SWT.EMBEDDED);
GridData data = new GridData();
data.horizontalAlignment = GridData.FILL;
data.verticalAlignment = GridData.FILL;
data.horizontalSpan = 1;
data.verticalSpan = 1;
mb.setLayoutData(data);
mb.setText("<html>aaa</html>");
mb.setFocus();
/*
MozillaBrowser mb2 = new MozillaBrowser(comp, SWT.EMBEDDED);
data = new GridData();
data.horizontalAlignment = GridData.FILL;
data.verticalAlignment = GridData.FILL;
data.horizontalSpan = 1;
data.verticalSpan = 1;
mb2.setLayoutData(data);
mb2.setText("<html>bbb</html>");
*/
Button swtButton2 = new Button(shell, SWT.PUSH);
swtButton2.setText("SWT Button2");
swtButton2.setLayoutData(new
GridData(GridData.HORIZONTAL_ALIGN_CENTER));
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
}
}
----
Javier Pedemonte wrote:
On 8/11/06, *Artem Ananiev* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
I have also noticed that the whole application is frozen if I don't call
run() method of nsIAppStartup service.
Correct, you need a way to dispatch Mozilla events, and you can do that
by calling nsIAppShell.run (). However, this means that once you call
run(), you can no longer do anything on that thread.
Under the covers, run() starts the native message loop.
This method is blocking and
starts a native messages loop, but I haven't found it being called in
SWT or ATF. It seems that there is another way to get browser's messages
dispatched.
SWT has its own message loop, which also calls the native message loop
under the covers. This makes an embedded Mozilla function fine without
calling nsIAppShell.run().
At last, I can't make my application to exit gracefully. I try to call
to destroy() method of nsIBaseWindow and/or Mozilla.termEmbedding() but
my application hangs or crashes. The only way to terminate it is to call
to System.exit().
Hmm, that sounds right. In the SWT widget, we call
nsIBaseWindow.destroy(), followed by nsIAppShell.spindown() and
Mozilla.termEmbedding(). What is the error you get?
I have attached this app to the letter, it's quite small.
I imported your test app code into Eclipse. It shows that getPeer() is
deprecated and should no longer be used. Also, there is no getHwnd()
method on WComponentPeer.
javier
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding