From 7bb5885fc3a904f49e22f0c8cbf747d9b189a7ba Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Wed, 25 Jul 2012 04:23:35 +0200
Subject: SWT Update: SWT GLCanvas creates lazy when resource is ready; Create
 new NewtCanvasSWT allowing to parent NEWT windows natively.

SWT GLCanvas creates lazy when resource is ready
  - Ensures drawable and context are created when size > zero and native visualID is valid.
    The latter is platform dependent.
  - Note that you cannot utilize custom GLCapabilities w/ this one,
    since the configurations is already realized - use NewtCanvasSWT.

Create new NewtCanvasSWT allowing to parent NEWT windows natively:
  - Similar to NewtCanvasAWT
  - Allows attaching / detaching NEWT windows

NewtCanvasAWT: Public setNEWTChild(..) fixed

Added test cases for the above - tested on Linux, OSX and Windows w/ SWT

Note: As usual for OSX, add -XstartOnFirstThread

Details:

- NEWT Display has new method: 'EDTUtil setEDTUtil(EDTUtil)'
  allowing to set a custom event dispatch utility.
  We use this to set our SWTEDTUtil for using NEWT w/ SWT
  complying w/ SWT threading constraints.
---
 .../com/jogamp/nativewindow/swt/SWTAccessor.java   | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

(limited to 'src/nativewindow/classes/com')

diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java
index 0494bb408..ba07d97dc 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java
@@ -34,16 +34,21 @@ import java.lang.reflect.Method;
 import org.eclipse.swt.graphics.GCData;
 import org.eclipse.swt.widgets.Control;
 
+import javax.media.nativewindow.AbstractGraphicsScreen;
+import javax.media.nativewindow.DefaultGraphicsScreen;
 import javax.media.nativewindow.NativeWindowException;
 import javax.media.nativewindow.AbstractGraphicsDevice;
 import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.nativewindow.VisualIDHolder;
 
 import com.jogamp.common.util.ReflectionUtil;
 import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice;
 import com.jogamp.nativewindow.windows.WindowsGraphicsDevice;
 import com.jogamp.nativewindow.x11.X11GraphicsDevice;
+import com.jogamp.nativewindow.x11.X11GraphicsScreen;
 
 import jogamp.nativewindow.macosx.OSXUtil;
+import jogamp.nativewindow.x11.X11Lib;
 
 public class SWTAccessor {
     static final Field swt_control_handle;
@@ -213,6 +218,26 @@ public class SWTAccessor {
         }
         throw new UnsupportedOperationException("n/a for this windowing system: "+NativeWindowFactory.getNativeWindowType(false));
     }
+    public static AbstractGraphicsScreen getScreen(AbstractGraphicsDevice device, int screen) {
+        if( null != OS_gtk_class ) {
+            return new X11GraphicsScreen((X11GraphicsDevice)device, screen);
+        } 
+        if( NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(false) ||
+            NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false) ) {
+            return new DefaultGraphicsScreen(device, screen);
+        }
+        throw new UnsupportedOperationException("n/a for this windowing system: "+NativeWindowFactory.getNativeWindowType(false));        
+    }
+    public static int getNativeVisualID(AbstractGraphicsDevice device, long windowHandle) {
+        if( null != OS_gtk_class ) {
+            return X11Lib.GetVisualIDFromWindow(device.getHandle(), windowHandle);
+        }
+        if( NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(false) ||
+            NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false) ) {
+            return VisualIDHolder.VID_UNDEFINED;
+        }
+        throw new UnsupportedOperationException("n/a for this windowing system: "+NativeWindowFactory.getNativeWindowType(false));        
+    }
     
     public static long getWindowHandle(Control swtControl) {
         long handle = getHandle(swtControl);        
-- 
cgit v1.2.3