[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[albireo-dev] SWT_AWT bridge enhancements for dual-process approaches

FYI... I'm forwarding this from platform-swt-dev, as background for my upcoming post.

Hi,

I noticed many stability issues with the SWT_AWT bridge (I am
reporting some bugs about it), and I came up with a solution that
favors a dual-process approach (which happens to be quite stable).

The idea is to get the handle of the Canvas from one VM, communicate
it to the second VM and use that handle to create a Shell. The problem
is that the APIs to create an embedded Shell using a handle are not an
official and uniform API, and to get the handle I have to use an
external library.

What I would love to have is an object that is serializable that
contains a native handle that can be passed to a Shell. Something
like:

SWT_AWT
  public static HandleData getHandleData(Canvas c) {}
  public static Shell newShell(Display display, HandleData parentHandleData) {}

HandleData implements Serializable
  int /* long */ handle;

What do you think? Any comments and suggestions?

-Christopher


Here is the code I use to create the Shell. It is only tested on a few of these systems in fact.


/* The handle is a long but contains the int if the platform uses int handles. */ public Shell createShell(long handle) throws Exception { // These are the methods that are in the Shell class, and can create the embedded shell: // win32: public static Shell win32_new (Display display, int handle) { // photon: public static Shell photon_new (Display display, int handle) { // motif: public static Shell motif_new (Display display, int handle) { // gtk: public static Shell gtk_new (Display display, int /*long*/ handle) { // carbon: Shell (Display display, Shell parent, int style, int handle) { Method shellCreationMethod = null; try { shellCreationMethod = Shell.class.getMethod(SWT.getPlatform() + "_new", Display.class, int.class); } catch(Exception e) {} if(shellCreationMethod != null) { return (Shell)shellCreationMethod.invoke(null, NativeInterfaceHandler.getDisplay(), (int)handle); } try { shellCreationMethod = Shell.class.getMethod(SWT.getPlatform() + "_new", Display.class, long.class); } catch(Exception e) {} if(shellCreationMethod != null) { return (Shell)shellCreationMethod.invoke(null, NativeInterfaceHandler.getDisplay(), handle); } Constructor<Shell> shellConstructor = null; try { shellConstructor = Shell.class.getConstructor(Display.class, Shell.class, int.class, int.class); } catch(Exception e) {} if(shellConstructor != null) { shellConstructor.setAccessible(true); return shellConstructor.newInstance(NativeInterfaceHandler.getDisplay(), null, SWT.NO_TRIM, (int)handle); } try { shellConstructor = Shell.class.getConstructor(Display.class, Shell.class, int.class, long.class); } catch(Exception e) {} if(shellConstructor != null) { shellConstructor.setAccessible(true); return shellConstructor.newInstance(NativeInterfaceHandler.getDisplay(), null, SWT.NO_TRIM, handle); } throw new IllegalStateException("Failed to create a Shell!"); }