[libjogl2-java] 16/58: Imported Upstream version 2.0-rc5

Tony Mancill tmancill at moszumanska.debian.org
Thu Sep 4 03:59:10 UTC 2014


This is an automated email from the git hooks/post-receive script.

tmancill pushed a commit to branch master
in repository libjogl2-java.

commit ca5717a99f0a786fa55859d20342a13a74a56b8a
Author: tony mancill <tmancill at debian.org>
Date:   Fri Aug 29 18:43:06 2014 -0700

    Imported Upstream version 2.0-rc5
---
 doc/HowToBuild.html                                |   5 +-
 doc/Implementation/Lifecycle.txt                   |  41 ++
 etc/profile.jogl                                   |  18 +-
 etc/test.bat                                       |  17 +-
 etc/test.sh                                        |  10 +-
 etc/test_dbg.bat                                   |  13 +
 etc/{test.sh => test_dbg.sh}                       |  10 +-
 jnlp-files/jogl-all-awt-cg.jnlp                    |  89 +++
 make/build-common.xml                              |  30 +-
 make/build-jogl.xml                                |  44 +-
 make/build-nativewindow.xml                        |  67 +-
 make/build-newt.xml                                |  23 +-
 make/build-test.xml                                |  87 ++-
 make/config/jogl/cg-common.cfg                     |   1 +
 make/config/jogl/cgl-macosx.cfg                    |   7 +
 .../config/jogl/gl-impl-CustomJavaCode-common.java |   5 +
 make/config/nativewindow/jawt-CustomJavaCode.java  |  57 +-
 .../jawt-DrawingSurfaceInfo-CustomJavaCode.java    |  37 +-
 make/config/nativewindow/jawt-common.cfg           |   2 +
 make/config/nativewindow/jawt-macosx.cfg           |   5 +
 make/config/nativewindow/win32-CustomJavaCode.java |  58 --
 make/config/nativewindow/win32-lib.cfg             |   4 +-
 .../resources/android/AndroidManifest-launcher.xml |   2 +
 make/scripts/adb-logcat.sh                         |   4 +
 make/scripts/adb-reinstall-all.sh                  |   1 +
 make/scripts/check-junit.sh                        |  53 +-
 make/scripts/java-win32-dbg.bat                    |   7 +-
 make/scripts/java-win32.bat                        |   4 +-
 make/scripts/java-win64-dbg.bat                    |   4 +-
 make/scripts/java-win64.bat                        |   4 +-
 make/scripts/make.jogl.all.solaris-x86.sh          |  52 ++
 make/scripts/make.jogl.all.solaris-x86_64.sh       |  52 ++
 make/scripts/make.jogl.all.win32.bat               |   4 +-
 make/scripts/make.jogl.all.win64.bat               |   4 +-
 make/scripts/setenv-jogl.sh                        |  12 +-
 make/scripts/tests-armv7l_eabi.sh                  |   2 +-
 make/scripts/tests-javaws-x64.bat                  |   2 +-
 make/scripts/tests-osx-x64.sh                      |   7 +
 make/scripts/tests-osx.sh                          |   7 -
 make/scripts/{tests-x32.sh => tests-solx32.sh}     |   3 +-
 make/scripts/{tests-x64.sh => tests-solx64.sh}     |   2 +-
 make/scripts/tests-x32.bat                         |   5 +-
 make/scripts/tests-x32.sh                          |   2 +-
 make/scripts/tests-x64.bat                         |  10 +-
 make/scripts/tests-x64.sh                          |   2 +-
 make/scripts/tests.sh                              |  85 ++-
 make/stub_includes/cg/{CG => Cg}/cg.h              |  10 +-
 make/stub_includes/cg/{CG => Cg}/cgGL.h            |   2 +-
 make/stub_includes/cg/{CG => Cg}/cgGL_profiles.h   |   0
 .../stub_includes/cg/{CG => Cg}/cg_bindlocations.h |   0
 make/stub_includes/cg/{CG => Cg}/cg_datatypes.h    |   0
 make/stub_includes/cg/{CG => Cg}/cg_enums.h        |   0
 make/stub_includes/cg/{CG => Cg}/cg_errors.h       |   0
 make/stub_includes/cg/{CG => Cg}/cg_profiles.h     |   2 +-
 make/stub_includes/jni/macosx/jawt_md.h            |  20 +-
 make/stub_includes/macosx/AppKit/NSOpenGL.h        |   3 +
 make/stub_includes/macosx/AppKit/NSOpenGLLayer.h   |   1 +
 make/stub_includes/macosx/AppKit/NSOpenGLView.h    |   1 +
 make/stub_includes/macosx/OpenGL/CGLDevice.h       |   2 +
 make/stub_includes/macosx/OpenGL/OpenGL.h          |  45 +-
 make/stub_includes/macosx/QuartzCore/CALayer.h     |   1 +
 make/stub_includes/opengl/GL/glxext.h              |  33 +-
 make/stub_includes/opengl/cg.c                     |   2 +-
 make/stub_includes/opengl/macosx-window-system.h   |  71 +-
 make/stub_includes/win32/wingdi.h                  |   2 +
 nbproject/.gitignore                               |   1 +
 .../classes/com/jogamp/opengl/JoglVersion.java     |   2 +-
 .../opengl/cg/CgDynamicLibraryBundleInfo.java      |  18 +
 .../com/jogamp/opengl/util/AWTAnimatorImpl.java    |   4 +-
 .../classes/com/jogamp/opengl/util/Animator.java   |  24 +-
 .../com/jogamp/opengl/util/AnimatorBase.java       |   6 +-
 .../jogamp/opengl/util/DefaultAnimatorImpl.java    |   4 +-
 .../com/jogamp/opengl/util/GLArrayDataClient.java  |   9 +-
 .../jogamp/opengl/util/GLArrayDataEditable.java    |   2 +-
 .../com/jogamp/opengl/util/GLArrayDataServer.java  |  16 +-
 .../classes/com/jogamp/opengl/util/GLBuffers.java  |  45 +-
 .../classes/com/jogamp/opengl/util/PMVMatrix.java  | 425 ++++++-----
 .../com/jogamp/opengl/util/texture/Texture.java    |   4 +-
 .../media/opengl/DefaultGLCapabilitiesChooser.java |  10 +-
 .../classes/javax/media/opengl/GLAutoDrawable.java |   2 +-
 src/jogl/classes/javax/media/opengl/GLBase.java    |  11 +
 .../classes/javax/media/opengl/GLCapabilities.java |  58 +-
 .../media/opengl/GLCapabilitiesImmutable.java      |  34 +-
 src/jogl/classes/javax/media/opengl/GLContext.java |  66 +-
 .../classes/javax/media/opengl/GLDrawable.java     |   6 +
 .../javax/media/opengl/GLDrawableFactory.java      | 111 +--
 src/jogl/classes/javax/media/opengl/GLProfile.java | 428 +++++++-----
 .../classes/javax/media/opengl/awt/GLCanvas.java   | 109 ++-
 .../classes/javax/media/opengl/awt/GLJPanel.java   |  19 +-
 .../jogamp/graph/curve/text/GlyphString.java       |   2 +-
 .../opengl/DesktopGLDynamicLookupHelper.java       |   2 +-
 src/jogl/classes/jogamp/opengl/FPSCounterImpl.java |   6 +-
 src/jogl/classes/jogamp/opengl/GLContextImpl.java  | 211 ++++--
 .../classes/jogamp/opengl/GLContextShareSet.java   | 252 ++++---
 .../jogamp/opengl/GLDebugMessageHandler.java       |  14 +-
 .../jogamp/opengl/GLDrawableFactoryImpl.java       |  85 ++-
 .../classes/jogamp/opengl/GLDrawableHelper.java    | 110 ++-
 src/jogl/classes/jogamp/opengl/GLDrawableImpl.java |  21 +-
 .../jogamp/opengl/GLGraphicsConfigurationUtil.java |   5 +-
 src/jogl/classes/jogamp/opengl/GLPbufferImpl.java  |   2 +-
 src/jogl/classes/jogamp/opengl/ProjectFloat.java   |  36 +-
 .../jogamp/opengl/SharedResourceRunner.java        | 158 +++--
 .../classes/jogamp/opengl/awt/VersionApplet.java   |  10 +-
 src/jogl/classes/jogamp/opengl/egl/EGLContext.java |  42 +-
 .../classes/jogamp/opengl/egl/EGLDrawable.java     |  12 +-
 .../jogamp/opengl/egl/EGLDrawableFactory.java      | 126 ++--
 .../opengl/egl/EGLDynamicLibraryBundleInfo.java    |   7 -
 .../opengl/egl/EGLES1DynamicLibraryBundleInfo.java |   4 -
 .../opengl/egl/EGLES2DynamicLibraryBundleInfo.java |   4 -
 .../jogamp/opengl/egl/EGLExternalContext.java      |   4 +-
 .../jogamp/opengl/egl/EGLGLCapabilities.java       |  15 +-
 .../opengl/egl/EGLGraphicsConfiguration.java       |  53 +-
 .../egl/EGLGraphicsConfigurationFactory.java       |   8 +-
 .../jogamp/opengl/egl/EGLOnscreenDrawable.java     |  10 -
 .../jogamp/opengl/egl/EGLPbufferDrawable.java      |  39 +-
 .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 630 +++++++++++++----
 .../opengl/macosx/cgl/MacOSXCGLDrawable.java       |  87 ++-
 .../macosx/cgl/MacOSXCGLDrawableFactory.java       | 277 ++++++--
 .../macosx/cgl/MacOSXCGLGraphicsConfiguration.java | 171 ++++-
 .../cgl/MacOSXCGLGraphicsConfigurationFactory.java |   6 +-
 .../macosx/cgl/MacOSXExternalCGLContext.java       |  59 +-
 .../macosx/cgl/MacOSXOffscreenCGLDrawable.java     |   6 +-
 .../macosx/cgl/MacOSXOnscreenCGLContext.java       |  76 +-
 .../macosx/cgl/MacOSXOnscreenCGLDrawable.java      |  46 +-
 .../opengl/macosx/cgl/MacOSXPbufferCGLContext.java | 309 +-------
 .../macosx/cgl/MacOSXPbufferCGLDrawable.java       | 223 +++---
 .../MacOSXAWTCGLGraphicsConfigurationFactory.java  |   8 +-
 .../macosx/cgl/awt/MacOSXJava2DCGLContext.java     |  72 +-
 .../classes/jogamp/opengl/util/GLArrayHandler.java |   4 +-
 ...GLArrayHandler.java => GLArrayHandlerFlat.java} |  26 +-
 .../opengl/util/GLArrayHandlerInterleaved.java     |  18 +-
 .../jogamp/opengl/util/GLDataArrayHandler.java     |   6 +-
 .../jogamp/opengl/util/GLFixedArrayHandler.java    |   8 +-
 .../opengl/util/GLFixedArrayHandlerFlat.java       |  14 +-
 .../jogamp/opengl/util/glsl/GLSLArrayHandler.java  |   9 +-
 .../opengl/util/glsl/GLSLArrayHandlerFlat.java     |  39 +-
 .../GLSLArrayHandlerInterleaved.java}              |  58 +-
 .../windows/wgl/WindowsBitmapWGLDrawable.java      |  28 +-
 .../windows/wgl/WindowsDummyWGLDrawable.java       |   8 +-
 .../windows/wgl/WindowsExternalWGLContext.java     |   4 +-
 .../windows/wgl/WindowsPbufferWGLContext.java      |   9 +-
 .../windows/wgl/WindowsPbufferWGLDrawable.java     | 307 ++++----
 .../opengl/windows/wgl/WindowsWGLContext.java      |  49 +-
 .../opengl/windows/wgl/WindowsWGLDrawable.java     |   6 +-
 .../windows/wgl/WindowsWGLDrawableFactory.java     | 184 ++---
 .../wgl/WindowsWGLGraphicsConfiguration.java       |  10 +-
 .../WindowsWGLGraphicsConfigurationFactory.java    |  10 +-
 .../WindowsAWTWGLGraphicsConfigurationFactory.java |  23 +-
 .../classes/jogamp/opengl/x11/glx/GLXUtil.java     |  99 ++-
 .../jogamp/opengl/x11/glx/X11DummyGLXDrawable.java |  10 +-
 .../opengl/x11/glx/X11ExternalGLXContext.java      |   8 +-
 .../opengl/x11/glx/X11ExternalGLXDrawable.java     |   4 +-
 .../jogamp/opengl/x11/glx/X11GLXContext.java       | 131 ++--
 .../jogamp/opengl/x11/glx/X11GLXDrawable.java      |  10 +-
 .../opengl/x11/glx/X11GLXDrawableFactory.java      | 364 ++++++----
 .../x11/glx/X11GLXGraphicsConfiguration.java       |  38 +-
 .../glx/X11GLXGraphicsConfigurationFactory.java    |  52 +-
 .../opengl/x11/glx/X11OnscreenGLXDrawable.java     |   8 +-
 .../opengl/x11/glx/X11PbufferGLXDrawable.java      |  39 +-
 .../jogamp/opengl/x11/glx/X11PixmapGLXContext.java |   2 +-
 .../opengl/x11/glx/X11PixmapGLXDrawable.java       |  29 +-
 src/jogl/native/GLDebugMessageHandler.c            |  30 +-
 src/jogl/native/macosx/ContextUpdater.h            |  17 +-
 src/jogl/native/macosx/ContextUpdater.m            | 101 ++-
 src/jogl/native/macosx/MacOSXCustomCGLCode.c       |   5 +-
 .../macosx/MacOSXWindowSystemInterface-nsview.m    | 140 ++++
 .../macosx/MacOSXWindowSystemInterface-pbuffer.m   | 480 +++++++++++++
 .../native/macosx/MacOSXWindowSystemInterface.h    |  20 +
 .../native/macosx/MacOSXWindowSystemInterface.m    | 345 +++++----
 src/jogl/native/timespec.c                         |  63 ++
 src/jogl/native/timespec.h                         |  19 +
 .../AbstractGraphicsConfiguration.java             |  13 +-
 .../media/nativewindow/AbstractGraphicsDevice.java |   9 +-
 .../nativewindow/DefaultGraphicsConfiguration.java |   2 -
 .../media/nativewindow/DefaultGraphicsDevice.java  |  27 +-
 .../nativewindow/GraphicsConfigurationFactory.java |  63 +-
 .../javax/media/nativewindow/NativeSurface.java    |  23 +
 .../javax/media/nativewindow/NativeWindow.java     |  15 +-
 .../media/nativewindow/NativeWindowFactory.java    | 166 +++--
 .../media/nativewindow/OffscreenLayerOption.java}  |  73 +-
 .../media/nativewindow/OffscreenLayerSurface.java} |  51 +-
 .../javax/media/nativewindow/ProxySurface.java     |  38 +-
 .../media/nativewindow/SurfaceChangeable.java      |   8 +-
 .../media/nativewindow/SurfaceUpdatedListener.java |   6 +-
 .../nativewindow/awt/AWTGraphicsConfiguration.java |  61 +-
 .../media/nativewindow/awt/AWTGraphicsDevice.java  |  38 +-
 .../media/nativewindow/awt/AWTGraphicsScreen.java  |  10 +-
 .../javax/media/nativewindow/util/Point.java       |   6 +
 .../nativewindow/x11/X11GraphicsConfiguration.java |   6 +-
 .../media/nativewindow/x11/X11GraphicsDevice.java  |  32 +-
 .../media/nativewindow/x11/X11GraphicsScreen.java  |  13 +-
 .../MutableGraphicsConfiguration.java}             |  29 +-
 .../jogamp/nativewindow/NWJNILibLoader.java        |   4 +-
 .../nativewindow/NativeWindowFactoryImpl.java      |  19 +-
 .../jogamp/nativewindow/SurfaceUpdatedHelper.java  |  85 +++
 .../jogamp/nativewindow/WrappedSurface.java        |   4 +-
 .../jogamp/nativewindow/jawt/JAWTJNILibLoader.java |  10 +-
 .../classes/jogamp/nativewindow/jawt/JAWTUtil.java |  82 ++-
 .../jogamp/nativewindow/jawt/JAWTWindow.java       | 297 ++++++--
 .../nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 230 ++++--
 .../jawt/windows/Win32SunJDKReflection.java        |   2 +-
 .../jawt/windows/WindowsJAWTWindow.java            |  35 +-
 .../nativewindow/jawt/x11/X11JAWTToolkitLock.java  |  24 +-
 .../nativewindow/jawt/x11/X11JAWTWindow.java       |  56 +-
 .../nativewindow/jawt/x11/X11SunJDKReflection.java |  20 +-
 .../jogamp/nativewindow/macosx/OSXUtil.java        |  85 +++
 .../jogamp/nativewindow/swt/SWTAccessor.java       |  69 +-
 .../jogamp/nativewindow/windows/GDISurface.java    |  14 +-
 .../jogamp/nativewindow/windows/GDIUtil.java       | 101 +++
 .../windows/RegisteredClassFactory.java            |  45 +-
 .../x11/X11GraphicsConfigurationFactory.java       |  20 +-
 .../jogamp/nativewindow/x11/X11ToolkitLock.java    |  23 +-
 .../classes/jogamp/nativewindow/x11/X11Util.java   | 406 +++--------
 .../awt/X11AWTGraphicsConfigurationFactory.java}   | 108 +--
 src/nativewindow/native/JAWT_DrawingSurfaceInfo.c  |   7 +
 src/nativewindow/native/NativewindowCommon.c       |  27 +
 src/nativewindow/native/NativewindowCommon.h       |   2 +
 src/nativewindow/native/macosx/OSXmisc.c           | 106 ---
 src/nativewindow/native/macosx/OSXmisc.m           | 442 ++++++++++++
 src/nativewindow/native/windows/GDImisc.c          |  32 +-
 src/nativewindow/native/x11/XineramaHelper.c       |   4 +-
 src/nativewindow/native/x11/Xmisc.c                |  14 +-
 src/newt/classes/com/jogamp/newt/Display.java      |   7 +-
 src/newt/classes/com/jogamp/newt/NewtFactory.java  | 140 +++-
 src/newt/classes/com/jogamp/newt/Screen.java       |  20 +-
 src/newt/classes/com/jogamp/newt/Window.java       | 114 ++-
 .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 315 +++++++--
 .../jogamp/newt/awt/applet/JOGLNewtApplet1Run.java | 127 +++-
 .../jogamp/newt/awt/applet/JOGLNewtAppletBase.java |  52 +-
 .../classes/com/jogamp/newt/event/InputEvent.java  |  32 +-
 .../classes/com/jogamp/newt/event/KeyEvent.java    |   4 +
 .../classes/com/jogamp/newt/event/MouseEvent.java  |  15 +
 .../com/jogamp/newt/event/MouseListener.java       |   2 +
 .../classes/com/jogamp/newt/event/NEWTEvent.java   |   1 +
 .../jogamp/newt/event/awt/AWTWindowAdapter.java    |   6 +
 .../classes/com/jogamp/newt/opengl/GLWindow.java   | 120 +++-
 src/newt/classes/com/jogamp/newt/util/EDTUtil.java |  12 +-
 .../classes/com/jogamp/newt/util/MainThread.java   |  52 +-
 src/newt/classes/jogamp/newt/DefaultEDTUtil.java   |  11 +-
 src/newt/classes/jogamp/newt/DisplayImpl.java      |   8 +-
 src/newt/classes/jogamp/newt/NEWTJNILibLoader.java |   4 +-
 src/newt/classes/jogamp/newt/OffscreenWindow.java  |  37 +-
 src/newt/classes/jogamp/newt/ScreenImpl.java       | 174 +++--
 src/newt/classes/jogamp/newt/ScreenModeStatus.java |  27 +-
 src/newt/classes/jogamp/newt/WindowImpl.java       | 505 ++++++++-----
 .../newt/awt/{event => }/NewtFactoryAWT.java       |  36 +-
 .../jogamp/newt/awt/event/AWTNewtEventFactory.java |  14 +-
 .../newt/awt/event/AWTParentWindowAdapter.java     |  24 +-
 .../jogamp/newt/driver/DriverClearFocus.java       |  12 +
 .../jogamp/newt/driver/DriverUpdatePosition.java   |   9 +
 .../jogamp/newt/driver/android/AndroidWindow.java  |  25 +-
 .../newt/driver/android/NewtBaseActivity.java      |  16 +-
 .../android/event/AndroidNewtEventFactory.java     |  16 +-
 .../classes/jogamp/newt/driver/awt/AWTCanvas.java  |   8 +-
 .../classes/jogamp/newt/driver/awt/AWTDisplay.java |   4 +-
 .../classes/jogamp/newt/driver/awt/AWTEDTUtil.java |  14 +-
 .../classes/jogamp/newt/driver/awt/AWTWindow.java  |  36 +-
 .../jogamp/newt/driver/broadcom/egl/Window.java    |  21 +-
 .../jogamp/newt/driver/intel/gdl/Window.java       |   9 +-
 .../classes/jogamp/newt/driver/kd/KDWindow.java    |   9 +-
 .../jogamp/newt/driver/macosx/MacDisplay.java      |   4 +
 .../jogamp/newt/driver/macosx/MacKeyUtil.java      | 262 +++++++
 .../jogamp/newt/driver/macosx/MacWindow.java       | 525 +++++++-------
 .../jogamp/newt/driver/windows/WindowsScreen.java  |   5 -
 .../jogamp/newt/driver/windows/WindowsWindow.java  |  97 ++-
 .../classes/jogamp/newt/driver/x11/X11Display.java |  34 +-
 .../classes/jogamp/newt/driver/x11/X11Screen.java  |  51 +-
 .../classes/jogamp/newt/driver/x11/X11Window.java  | 108 ++-
 src/newt/native/MacWindow.m                        | 454 +++++++++---
 src/newt/native/NewtMacWindow.h                    |  64 +-
 src/newt/native/NewtMacWindow.m                    | 520 +++++++++++---
 src/newt/native/WindowsWindow.c                    | 145 +++-
 src/newt/native/X11Window.c                        | 245 +++++--
 .../opengl/test/android/NEWTElektronActivity.java  |   9 +-
 .../opengl/test/android/NEWTGearsES1Activity.java  |   7 +-
 .../opengl/test/android/NEWTGearsES2Activity.java  |  16 +-
 .../test/android/NEWTGearsES2TransActivity.java    |   6 +-
 .../opengl/test/android/NEWTGraphUI1pActivity.java |   2 +-
 .../opengl/test/android/NEWTGraphUI2pActivity.java |   2 +-
 .../test/android/NEWTRedSquareES1Activity.java     |   6 +-
 .../test/android/NEWTRedSquareES2Activity.java     |  15 +-
 .../test/junit/graph/TestRegionRendererNEWT01.java |   5 -
 .../test/junit/graph/TestTextRendererNEWT01.java   |   5 -
 .../junit/graph/demos/GPURegionNewtDemo01.java     |   1 -
 .../junit/graph/demos/GPURegionNewtDemo02.java     |   1 -
 .../test/junit/graph/demos/GPUTextNewtDemo01.java  |   1 -
 .../test/junit/graph/demos/GPUTextNewtDemo02.java  |   1 -
 .../junit/graph/demos/GPUUISceneGLListener0A.java  |  33 +-
 .../junit/graph/demos/GPUUISceneNewtDemo01.java    |   1 -
 .../junit/graph/demos/GPUUISceneNewtDemo02.java    |   1 -
 .../test/junit/graph/demos/ui/UINewtDemo01.java    |   1 -
 .../test/junit/jogl/acore/TestGLDebug00NEWT.java   |   5 -
 .../test/junit/jogl/acore/TestGLDebug01NEWT.java   |   6 -
 .../jogl/acore/TestGLExtensionQueryOffscreen.java  |   7 +-
 .../test/junit/jogl/acore/TestGLProfile01NEWT.java |  11 -
 .../junit/jogl/acore/TestInitConcurrentNEWT.java   | 230 ++++++
 .../acore/TestMainVersionGLCanvasAWT.java}         |  28 +-
 .../acore/TestMainVersionGLWindowNEWT.java}        |  26 +-
 .../test/junit/jogl/acore/TestNVSwapGroupNEWT.java |   1 -
 .../junit/jogl/acore/TestPBufferDeadlockAWT.java   | 127 ++++
 .../junit/jogl/acore/TestSharedContextListAWT.java |  49 +-
 .../jogl/acore/TestSharedContextListNEWT.java      |  19 +-
 ...stNEWT.java => TestSharedContextListNEWT2.java} |  58 +-
 .../jogl/acore/TestSharedContextNewtAWTBug523.java | 778 +++++++++++++++++++++
 .../jogl/acore/TestSharedContextVBOES1NEWT.java    |  15 +-
 .../jogl/acore/TestSharedContextVBOES2NEWT.java    |  15 +-
 ...NEWT.java => TestSharedContextVBOES2NEWT2.java} |  63 +-
 .../junit/jogl/acore/TestShutdownCompleteAWT.java  | 125 ++++
 .../junit/jogl/acore/TestShutdownCompleteNEWT.java | 144 ++++
 .../junit/jogl/acore/TestShutdownSharedAWT.java    | 124 ++++
 .../junit/jogl/acore/TestShutdownSharedNEWT.java   | 127 ++++
 .../TestBug461OffscreenSupersamplingSwingAWT.java  |  46 +-
 .../test/junit/jogl/caps/MultisampleDemo01.java    |   2 +-
 .../caps/TestTranslucencyAWT.java}                 | 155 ++--
 .../test/junit/jogl/caps/TestTranslucencyNEWT.java |   1 -
 .../opengl/test/junit/jogl/demos/es1/GearsES1.java |  15 +-
 .../jogl/demos/es1/newt/TestGearsES1NEWT.java      |   1 -
 .../jogl/demos/es1/newt/TestRedSquareES1NEWT.java  |   1 -
 .../opengl/test/junit/jogl/demos/es2/GearsES2.java |  89 ++-
 .../test/junit/jogl/demos/es2/RedSquareES2.java    |  50 +-
 .../es2/newt/TestElektronenMultipliziererNEWT.java |   5 -
 .../jogl/demos/es2/newt/TestGearsES2NEWT.java      | 144 +++-
 .../jogl/demos/es2/newt/TestRedSquareES2NEWT.java  |   1 -
 .../shader/elektronenmultiplizierer_development.fp |   4 +-
 .../test/junit/jogl/demos/es2/shader/gears.fp      |  11 +-
 .../junit/jogl/demos/gl2/awt/TestGearsAWT.java     |  30 +-
 ...earsAWT.java => TestGearsAWTAnalyzeBug455.java} |  77 +-
 .../junit/jogl/demos/gl2/newt/TestGearsNEWT.java   |   1 -
 .../junit/jogl/drawable/TestDrawable01NEWT.java    |   3 +-
 .../test/junit/jogl/glsl/GLSLMiscHelper.java       |   4 +-
 .../test/junit/jogl/glsl/TestFBOMRTNEWT01.java     |  13 +-
 .../junit/jogl/glsl/TestGLSLShaderState01NEWT.java |  17 +-
 .../junit/jogl/glsl/TestGLSLShaderState02NEWT.java |   7 +-
 .../test/junit/jogl/glsl/TestGLSLSimple01NEWT.java |  13 -
 .../test/junit/jogl/glsl/TestRulerNEWT01.java      |  25 +-
 .../TestTransformFeedbackVaryingsBug407NEWT.java   |  10 -
 ...TestSwingAWTRobotUsageBeforeJOGLInitBug411.java |   6 +-
 .../offscreen/TestOffscreen01GLPBufferNEWT.java    |   1 -
 .../jogl/offscreen/TestOffscreen02BitmapNEWT.java  |   1 -
 .../test/junit/jogl/offscreen/WindowUtilNEWT.java  |   2 +-
 .../opengl/test/junit/jogl/swt/TestSWT01GLn.java   |   1 -
 .../opengl/test/junit/jogl/swt/TestSWT02GLn.java   |  53 +-
 .../test/junit/jogl/swt/TestSWTAWT01GLn.java       |  92 +--
 .../opengl/test/junit/newt/TestCloseNewtAWT.java   |  12 +-
 .../junit/newt/TestDisplayLifecycle01NEWT.java     |   1 -
 .../junit/newt/TestDisplayLifecycle02NEWT.java     |   1 -
 .../test/junit/newt/TestEventSourceNotAWTBug.java  |   7 +-
 .../test/junit/newt/TestFocus01SwingAWTRobot.java  |  35 +-
 .../test/junit/newt/TestFocus02SwingAWTRobot.java  |  70 +-
 .../test/junit/newt/TestGLWindows00NEWT.java       |   2 -
 .../test/junit/newt/TestGLWindows01NEWT.java       |   2 -
 .../junit/newt/TestGLWindows02NEWTAnimated.java    |   1 -
 .../test/junit/newt/TestListenerCom01AWT.java      |  17 +-
 .../test/junit/newt/TestRemoteGLWindows01NEWT.java |  83 +--
 .../test/junit/newt/TestRemoteWindow01NEWT.java    |   4 +-
 .../test/junit/newt/TestScreenMode00NEWT.java      |  33 +-
 .../test/junit/newt/TestScreenMode00bNEWT.java     |  39 +-
 .../test/junit/newt/TestScreenMode01NEWT.java      |   9 +-
 .../test/junit/newt/TestScreenMode01bNEWT.java     |   3 +-
 .../test/junit/newt/TestScreenMode02NEWT.java      |   3 +-
 .../junit/newt/TestWindowClosingProtocol01AWT.java |   8 +-
 .../newt/TestWindowClosingProtocol03NewtAWT.java   |   4 +-
 .../opengl/test/junit/newt/TestWindows01NEWT.java  |   2 +-
 .../parenting/NewtAWTReparentingKeyAdapter.java    |   6 +-
 .../junit/newt/parenting/TestParenting01NEWT.java  |   3 +-
 .../junit/newt/parenting/TestParenting01aAWT.java  | 207 ++++--
 .../junit/newt/parenting/TestParenting01bAWT.java  |  43 +-
 .../junit/newt/parenting/TestParenting01cAWT.java  |  95 ++-
 .../newt/parenting/TestParenting01cSwingAWT.java   |  33 +-
 .../junit/newt/parenting/TestParenting02AWT.java   |  11 +-
 .../junit/newt/parenting/TestParenting02NEWT.java  |   5 +-
 .../junit/newt/parenting/TestParenting03AWT.java   | 134 ++--
 .../TestParentingFocusTraversal01AWT.java          | 334 +++++++++
 .../TestParentingOffscreenLayer01GLCanvasAWT.java  | 205 ++++++
 ...TestParentingOffscreenLayer02NewtCanvasAWT.java | 209 ++++++
 ...3bAWT.java => TestTranslucentParentingAWT.java} | 151 ++--
 .../opengl/test/junit/util/AWTFocusAdapter.java    |  24 +-
 .../opengl/test/junit/util/AWTRobotUtil.java       | 101 +--
 ...ocusAdapter.java => AWTWindowFocusAdapter.java} |  42 +-
 .../test/junit/util/FocusEventCountAdapter.java    |   3 +-
 .../opengl/test/junit/util/NEWTFocusAdapter.java   |  24 +-
 .../opengl/test/junit/util/NEWTGLContext.java      |   6 +-
 src/test/jogamp/newt/WindowImplAccess.java         |  16 +-
 src/test/native/displayMultiple02.c                |  86 ++-
 tools/jackpotc/.gitignore                          |   1 +
 tools/jackpotc/test/oldgears/.gitignore            |   4 +
 www/index.html                                     |  13 +-
 387 files changed, 14776 insertions(+), 6493 deletions(-)

diff --git a/doc/HowToBuild.html b/doc/HowToBuild.html
index 913eb13..ad965e1 100644
--- a/doc/HowToBuild.html
+++ b/doc/HowToBuild.html
@@ -207,7 +207,8 @@
                         </li>
 
                         <li> <b>Build the source tree:</b> <br/>
-                            Open a command shell in the "jogl/make" directory of the source tree and type <code>"ant"</code>.
+                            Open a command shell in the "gluegen/make" directory of the source tree and type <code>"ant"</code>.<br/>
+                            Then open a command shell in the "jogl/make" directory of the source tree and type <code>"ant"</code>.
                             <ul>
                                 <li>
                                     An experimental binding to the high-level <a href="http://developer.nvidia.com/view.asp?PAGE=cg_main">Cg</a>
@@ -219,7 +220,7 @@
 
                         <li> <b>Test your build:</b> <br/> Stay in your command shell in the "jogl/make" directory of the source tree and type <code>"ant junit.run"</code>.</li>
 
-                        <li> <b>Build Javadoc:</b> <br/> Stay in your command shell in the "jogl/make" directory of the source tree and type "<code>ant javadoc"</code>.
+                        <li> <b>Build Javadoc:</b> <br/> Stay in your command shell in the "jogl/make" directory of the source tree and type "<code>ant javadoc.all"</code>.
                             This will produce the end-user documentation for JOGL along with some auxiliary utility packages.
                         </li>
                     </ol>
diff --git a/doc/Implementation/Lifecycle.txt b/doc/Implementation/Lifecycle.txt
new file mode 100644
index 0000000..3bdeafb
--- /dev/null
+++ b/doc/Implementation/Lifecycle.txt
@@ -0,0 +1,41 @@
+
+Persistent Resources - JVM Lifetime (1)
+========================================
+
+- Platform 
+
+- JNILibLoaderBase
+    Contains a set of loaded JNI libraries via System.load(..)
+
+- JVMUtil
+    Only issues JVM startup initialization
+
+- TempJarCache
+    Contains a TempFileCache for all cached JarFile,
+    referenced by URL
+
+Initialization Sequence:
+==========================
+
+Deinitialization is reverse ofc.
+
+- GLProfile
+    - Platform (1)
+        - JVMUtil (1)
+        - JNILibLoaderBase (1)
+        - TempJarCache (1)
+
+    - NativeWindowFactory
+        - X11Util
+
+    - GLDrawableFactory / GLDrawableFactoryImpl
+        - X11GLXDrawableFactory, EGLDrawableFactory, ... (all platforms)
+            - *DynamicLookupHelper ..
+                - NativeLibrary ..
+
+    - GLContext 
+        - proc-address-tables (GL, GLX..)
+        - context version mapping
+
+
+
diff --git a/etc/profile.jogl b/etc/profile.jogl
index 9b38d6a..86eeb60 100755
--- a/etc/profile.jogl
+++ b/etc/profile.jogl
@@ -73,26 +73,34 @@ export JOGL_BUILD_DIR
 JOGL_LIB_DIR=$JOGL_BUILD_DIR/lib
 export JOGL_LIB_DIR
 
+JOGL_ALL_AWT_CLASSPATH=$(concat_jogl_list $JOGL_BUILD_DIR $JOGL_JAR_ALL $JOGL_TEST)
+JOGL_ALL_NOAWT_CLASSPATH=$(concat_jogl_list $JOGL_BUILD_DIR $JOGL_JAR_ALL_NOAWT $JOGL_TEST)
+JOGL_MOBILE_CLASSPATH=$(concat_jogl_list $JOGL_BUILD_DIR $JOGL_JAR_ALL_MOBILE)
+export JOGL_ALL_AWT_CLASSPATH JOGL_ALL_NOAWT_CLASSPATH JOGL_MOBILE_CLASSPATH
+
 if [ ! -z "$JOGL_PROFILE" ] ; then
     case "$JOGL_PROFILE" in
         JOGL_ALL)
-            JOGL_CLASSPATH=$(concat_jogl_list $JOGL_BUILD_DIR $JOGL_JAR_ALL $JOGL_TEST)
+            JOGL_CLASSPATH=$JOGL_ALL_AWT_CLASSPATH
             ;;
         JOGL_ALL_NOAWT)
-            JOGL_CLASSPATH=$(concat_jogl_list $JOGL_BUILD_DIR $JOGL_JAR_ALL_NOAWT)
+            JOGL_CLASSPATH=$JOGL_ALL_NOAWT_CLASSPATH
             ;;
         JOGL_ALL_MOBILE)
-            JOGL_CLASSPATH=$(concat_jogl_list $JOGL_BUILD_DIR $JOGL_JAR_ALL_MOBILE)
+            JOGL_CLASSPATH=$JOGL_MOBILE_CLASSPATH
             ;;
     esac
-
-    export JOGL_CLASSPATH
+else
+    JOGL_CLASSPATH=$JOGL_ALL_AWT_CLASSPATH
 fi
+export JOGL_CLASSPATH
 
 if [ "$KERNEL" = "linux" ] ; then
     SWT_SUB="gtk"
 elif [ "$KERNEL" = "darwin" ] ; then
     SWT_SUB="cocoa"
+    KERNEL="macosx"
+    ARCH="x86_64"
 fi
 if [ -z "$SWT_CLASSPATH" ] ; then
     SWT_CLASSPATH_0=$JOGL_BUILD_DIR/../make/lib/swt/$SWT_SUB-$KERNEL-$ARCH/swt-debug.jar
diff --git a/etc/test.bat b/etc/test.bat
index aa19ad9..0c82233 100755
--- a/etc/test.bat
+++ b/etc/test.bat
@@ -1,19 +1,18 @@
 
 set BLD_DIR=jar
-set LIB_DIR=lib
 
-set CP_ALL=.;%BLD_DIR%\gluegen-rt.jar;%BLD_DIR%\nativewindow.all.jar;%BLD_DIR%\jogl.all.jar;%BLD_DIR%\newt.all.jar
+set CP_ALL=.;%BLD_DIR%\gluegen-rt.jar;%BLD_DIR%\jogl.all.jar
 echo CP_ALL %CP_ALL%
 
 set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true"
 
-REM java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %X_ARGS% javax.media.opengl.awt.GLCanvas > java-win64.log 2>&1
+REM java -classpath %CP_ALL% %X_ARGS% javax.media.opengl.awt.GLCanvas > java-win64.log 2>&1
 
-REM java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %X_ARGS% com.jogamp.common.GlueGenVersion > test.log 2>&1
-REM java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %X_ARGS% com.jogamp.nativewindow.NativeWindowVersion >> test.log 2>&1
-REM java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %X_ARGS% com.jogamp.opengl.JoglVersion >> test.log 2>&1
-REM java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %X_ARGS% com.jogamp.newt.NewtVersion >> test.log 2>&1
-REM java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %X_ARGS% com.jogamp.newt.opengl.GLCanvas >> test.log 2>&1
-java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %X_ARGS% com.jogamp.newt.opengl.GLWindow >> test.log 2>&1
+REM java -classpath %CP_ALL% %X_ARGS% com.jogamp.common.GlueGenVersion > test.log 2>&1
+REM java -classpath %CP_ALL% %X_ARGS% com.jogamp.nativewindow.NativeWindowVersion >> test.log 2>&1
+REM java -classpath %CP_ALL% %X_ARGS% com.jogamp.opengl.JoglVersion >> test.log 2>&1
+REM java -classpath %CP_ALL% %X_ARGS% com.jogamp.newt.NewtVersion >> test.log 2>&1
+REM java -classpath %CP_ALL% %X_ARGS% com.jogamp.newt.opengl.GLCanvas >> test.log 2>&1
+java -classpath %CP_ALL% %X_ARGS% com.jogamp.newt.opengl.GLWindow >> test.log 2>&1
 
 type test.log
diff --git a/etc/test.sh b/etc/test.sh
index 09b97ce..1912a95 100755
--- a/etc/test.sh
+++ b/etc/test.sh
@@ -12,18 +12,14 @@ echo LIBGL_DRIVERS_PATH: $LIBGL_DRIVERS_PATH 2>&1 | tee -a $logfile
 echo LIBGL_DEBUG: $LIBGL_DEBUG 2>&1 | tee -a $logfile
 echo java $X_ARGS $D_ARGS $* 2>&1 | tee -a $logfile
 
-CLASSPATH=jar/gluegen-rt.jar:jar/nativewindow.all.jar:jar/jogl.all.jar:jar/newt.all.jar
+CLASSPATH=jar/gluegen-rt.jar:jar/jogl.all.jar
 export CLASSPATH
 
-export LD_LIBRARY_PATH=./lib:$LD_LIBRARY_PATH
-export DYLD_LIBRARY_PATH=./lib:$DYLD_LIBRARY_PATH
-echo LD_LIBRARY PATH: $LD_LIBRARY_PATH
-echo DYLD_LIBRARY PATH: $DYLD_LIBRARY_PATH
-echo
-
 echo CLASSPATH: $CLASSPATH
 echo
 
+# D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all"
+#
 # D_ARGS="-Djogamp.debug.TraceLock"
 # D_ARGS="-Dnewt.debug.EDT -Dnativewindow.debug.ToolkitLock.TraceLock -Dnativewindow.debug.NativeWindow"
 # D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT"
diff --git a/etc/test_dbg.bat b/etc/test_dbg.bat
new file mode 100755
index 0000000..33bbb91
--- /dev/null
+++ b/etc/test_dbg.bat
@@ -0,0 +1,13 @@
+
+set BLD_DIR=jar
+
+set CP_ALL=.;%BLD_DIR%\gluegen-rt.jar;%BLD_DIR%\jogl.all.jar
+echo CP_ALL %CP_ALL%
+
+set D_ARGS="-Djogamp.debug=all" "-Dnativewindow.debug=all" "-Djogl.debug=all" "-Dnewt.debug=all"
+set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true"
+
+REM java -classpath %CP_ALL% %X_ARGS% %D_ARGS% com.jogamp.newt.opengl.GLCanvas >> test.log 2>&1
+java -classpath %CP_ALL% %X_ARGS% %D_ARGS% com.jogamp.newt.opengl.GLWindow >> test_dbg.log 2>&1
+
+type test_dbg.log
diff --git a/etc/test.sh b/etc/test_dbg.sh
similarity index 88%
copy from etc/test.sh
copy to etc/test_dbg.sh
index 09b97ce..f7d0fd2 100755
--- a/etc/test.sh
+++ b/etc/test_dbg.sh
@@ -12,18 +12,14 @@ echo LIBGL_DRIVERS_PATH: $LIBGL_DRIVERS_PATH 2>&1 | tee -a $logfile
 echo LIBGL_DEBUG: $LIBGL_DEBUG 2>&1 | tee -a $logfile
 echo java $X_ARGS $D_ARGS $* 2>&1 | tee -a $logfile
 
-CLASSPATH=jar/gluegen-rt.jar:jar/nativewindow.all.jar:jar/jogl.all.jar:jar/newt.all.jar
+CLASSPATH=jar/gluegen-rt.jar:jar/jogl.all.jar
 export CLASSPATH
 
-export LD_LIBRARY_PATH=./lib:$LD_LIBRARY_PATH
-export DYLD_LIBRARY_PATH=./lib:$DYLD_LIBRARY_PATH
-echo LD_LIBRARY PATH: $LD_LIBRARY_PATH
-echo DYLD_LIBRARY PATH: $DYLD_LIBRARY_PATH
-echo
-
 echo CLASSPATH: $CLASSPATH
 echo
 
+D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all"
+
 # D_ARGS="-Djogamp.debug.TraceLock"
 # D_ARGS="-Dnewt.debug.EDT -Dnativewindow.debug.ToolkitLock.TraceLock -Dnativewindow.debug.NativeWindow"
 # D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT"
diff --git a/jnlp-files/jogl-all-awt-cg.jnlp b/jnlp-files/jogl-all-awt-cg.jnlp
new file mode 100644
index 0000000..18f8f49
--- /dev/null
+++ b/jnlp-files/jogl-all-awt-cg.jnlp
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="utf-8"?>
+<jnlp codebase="JOGL_CODEBASE_TAG/"
+      href="jogl-all-awt-cg.jnlp" version="JOGAMP_VERSION">
+  <information>
+    <title>Java(tm) Binding to the OpenGL(r) API (ALL.AWT.CG)</title>
+    <vendor>JogAmp Community</vendor>
+    <homepage href="http://jogamp.org/"/>
+    <description>Java Binding to the OpenGL API - 2.0.0 - ALL.AWT.CG</description>
+    <description kind="short">Java programming language binding for the OpenGL 3D graphics API - ALL.AWT.CG</description>
+    <offline-allowed/>
+  </information>
+  <update check="background" policy="always"/>
+  <security>
+      <all-permissions/>
+  </security>
+    <resources>
+      <jar href="jar/jogl.all.jar" />
+      <jar href="jar/atomic/jogl.cg.jar" />
+
+      <extension name="gluegen-rt"   href="GLUEGEN_CODEBASE_TAG/gluegen-rt.jnlp" />
+    </resources>
+
+    <resources os="Windows" arch="x86">
+      <nativelib href = "jar/jogl-all-natives-windows-i586.jar" />
+      <nativelib href = "jar/atomic/jogl_cg-natives-windows-i586.jar" />
+    </resources>
+    <resources os="Windows" arch="amd64">
+      <nativelib href = "jar/jogl-all-natives-windows-amd64.jar" />
+      <nativelib href = "jar/atomic/jogl_cg-natives-windows-amd64.jar" />
+    </resources>
+    <resources os="Windows" arch="x86_64">
+      <nativelib href = "jar/jogl-all-natives-windows-amd64.jar" />
+      <nativelib href = "jar/atomic/jogl_cg-natives-windows-amd64.jar" />
+    </resources>
+    <resources os="SunOS" arch="sparc">
+      <nativelib href = "jar/jogl-all-natives-solaris-sparc.jar" />
+      <nativelib href = "jar/atomic/jogl_cg-natives-solaris-sparc.jar" />
+    </resources>
+    <resources os="SunOS" arch="sparcv9">
+      <nativelib href = "jar/jogl-all-natives-solaris-sparcv9.jar" />
+      <nativelib href = "jar/atomic/jogl_cg-natives-solaris-sparcv9.jar" />
+    </resources>
+    <resources os="SunOS" arch="x86">
+      <nativelib href = "jar/jogl-all-natives-solaris-i586.jar" />
+      <nativelib href = "jar/atomic/jogl_cg-natives-solaris-i586.jar" />
+    </resources>
+    <resources os="SunOS" arch="amd64">
+      <nativelib href = "jar/jogl-all-natives-solaris-amd64.jar" />
+      <nativelib href = "jar/atomic/jogl_cg-natives-solaris-amd64.jar" />
+    </resources>
+    <resources os="SunOS" arch="x86_64">
+      <nativelib href = "jar/jogl-all-natives-solaris-amd64.jar" />
+      <nativelib href = "jar/atomic/jogl_cg-natives-solaris-amd64.jar" />
+    </resources>
+    <resources os="Linux" arch="i386">
+      <nativelib href = "jar/jogl-all-natives-linux-i586.jar" />
+      <nativelib href = "jar/atomic/jogl_cg-natives-linux-i586.jar" />
+    </resources>
+    <resources os="Linux" arch="x86">
+      <nativelib href = "jar/jogl-all-natives-linux-i586.jar" />
+      <nativelib href = "jar/atomic/jogl_cg-natives-linux-i586.jar" />
+    </resources>
+    <resources os="Linux" arch="amd64">
+      <nativelib href = "jar/jogl-all-natives-linux-amd64.jar" />
+      <nativelib href = "jar/atomic/jogl_cg-natives-linux-amd64.jar" />
+    </resources>
+    <resources os="Linux" arch="x86_64">
+      <nativelib href = "jar/jogl-all-natives-linux-amd64.jar" />
+      <nativelib href = "jar/atomic/jogl_cg-natives-linux-amd64.jar" />
+    </resources>
+    <resources os="Linux" arch="arm">
+      <nativelib href = "jar/jogl-all-natives-linux-armv7.jar" />
+      <nativelib href = "jar/atomic/jogl_cg-natives-linux-armv7.jar" />
+    </resources>
+    <resources os="Linux" arch="armv7">
+      <nativelib href = "jar/jogl-all-natives-linux-armv7.jar" />
+      <nativelib href = "jar/atomic/jogl_cg-natives-linux-armv7.jar" />
+    </resources>
+    <resources os="Mac OS X" arch="i386">
+      <nativelib href = "jar/jogl-all-natives-macosx-universal.jar" />
+      <nativelib href = "jar/atomic/jogl_cg-natives-macosx-universal.jar" />
+    </resources>
+    <resources os="Mac OS X" arch="x86_64">
+      <nativelib href = "jar/jogl-all-natives-macosx-universal.jar" />
+      <nativelib href = "jar/atomic/jogl_cg-natives-macosx-universal.jar" />
+    </resources>
+
+  <component-desc />
+</jnlp>
diff --git a/make/build-common.xml b/make/build-common.xml
index 58a829f..79d55b5 100644
--- a/make/build-common.xml
+++ b/make/build-common.xml
@@ -130,6 +130,9 @@
         <condition property="swt.jar" value="${project.root}/make/lib/swt/win32-win32-x86/swt-debug.jar">
           <istrue value="${isWindowsX86}" />
         </condition>
+        <condition property="swt.jar" value="${project.root}/make/lib/swt/gtk-freebsd-x86_64/swt.jar">
+          <istrue value="${isFreeBSDAMD64}" />
+        </condition>
         <condition property="swt.jar" value="${project.root}/make/lib/swt/gtk-linux-x86_64/swt-debug.jar">
           <istrue value="${isLinuxAMD64}" />
         </condition>
@@ -142,7 +145,8 @@
         <condition property="swt.jar" value="${project.root}/make/lib/swt/gtk-linux-x86/swt-debug.jar">
           <istrue value="${isAndroid}" /> <!-- FIXME JAU .. hack -->
         </condition>
-        <condition property="swt.jar" value="${project.root}/make/lib/swt/cocoa-macosx-x86_64/swt-debug.jar">
+        <property name="swt-cocoa-macosx-x86_64.jar" value="${project.root}/make/lib/swt/cocoa-macosx-x86_64/swt-debug.jar"/>
+        <condition property="swt.jar" value="${swt-cocoa-macosx-x86_64.jar}">
           <and>
             <istrue value="${isOSX}" />
             <or>
@@ -151,7 +155,8 @@
             </or>                
           </and>
         </condition>
-        <condition property="swt.jar" value="${project.root}/make/lib/swt/cocoa-macosx/swt-debug.jar">
+        <property name="swt-cocoa-macosx-x86_32.jar" value="${project.root}/make/lib/swt/cocoa-macosx/swt-debug.jar"/>
+        <condition property="swt.jar" value="${swt-cocoa-macosx-x86_32.jar}">
           <and>
             <istrue value="${isOSX}" />
             <or>
@@ -164,16 +169,29 @@
           <istrue value="${isSolarisX86}" />
         </condition>
         <condition property="swt.jar" value="${project.root}/make/lib/swt/gtk-solaris-x86/swt-debug.jar">
-          <istrue value="${isSolarisAMD64}" />
+          <istrue value="${isSolarisAMD64}" /> <!-- FIXME JAU .. hack -->
         </condition>
         <condition property="swt.jar" value="${project.root}/make/lib/swt/gtk-solaris-sparc/swt-debug.jar">
           <istrue value="${isSolarisSparc}" />
         </condition>
 		<condition property="swt.jar" value="${project.root}/make/lib/swt/gtk-solaris-sparc/swt-debug.jar">
-          <istrue value="${isSolarisSparcv9}" />
+          <istrue value="${isSolarisSparcv9}" /> <!-- FIXME JAU .. hack -->
         </condition>
         <echo message="swt.jar=${swt.jar}" />
 
+        <condition property="isSWTRuntimeAvailable">
+          <or>
+              <istrue value="${isWindowsAMD64}" />
+              <istrue value="${isWindowsX86}" />
+              <istrue value="${isLinuxAMD64}" />
+              <istrue value="${isLinuxX86}" />
+              <istrue value="${isOSX}" />
+              <istrue value="${isSolarisX86}" />
+              <istrue value="${isSolarisSparc}" />
+          </or>
+        </condition>
+        <echo message="isSWTRuntimeAvailable=${isSWTRuntimeAvailable}" />
+
         <property name="target.sourcelevel" value="1.5" />
         <property name="host.sourcelevel"   value="1.5" />
 
@@ -338,6 +356,7 @@
         <property name="newt.core.jar"                  value="${build.newt}/newt.core.jar" />
         <property name="newt.ogl.jar"                   value="${build.newt}/newt.ogl.jar" />
         <property name="newt.awt.jar"                   value="${build.newt}/newt.awt.jar" />
+        <property name="newt.event.jar"                 value="${build.newt}/newt.event.jar" />              <!-- using NEWT events w/o NEWT -->
         <property name="newt.driver.x11.jar"            value="${build.newt}/newt.driver.x11.jar" />
         <property name="newt.driver.win.jar"            value="${build.newt}/newt.driver.win.jar" />
         <property name="newt.driver.macosx.jar"         value="${build.newt}/newt.driver.macosx.jar" />
@@ -378,7 +397,6 @@
 
         <!-- JavaSE combinations . AWT -->
         <property name="jogl.all.jar"                   value="${jar}/jogl.all.jar" />
-        <property name="newt.event.jar"                 value="${jar}/newt.event.jar" />
 
         <!-- JavaSE combinations . NO.AWT -->
         <property name="jogl.all-noawt.jar"             value="${jar}/jogl.all-noawt.jar" />
@@ -478,6 +496,8 @@
         <property name="junit_jogl_android.run.jars"
                   value="${junit.jar}${path.separator}${ant.jar}${path.separator}${ant-junit.jar}${path.separator}${gluegen-rt.jar}${path.separator}${jogl.all-android.jar}${path.separator}${jogl.test.jar}"/>
 
+        <!-- Dummy extra CLASSPATH value, maybe overwritten -->  
+        <property name="junit_extra_classpath" value=""/>
 
         <!-- The location and name of the configuration ANT file that will 
            - validate to ensure that all user-define variables are set. -->
diff --git a/make/build-jogl.xml b/make/build-jogl.xml
index 0cf7c17..511f147 100644
--- a/make/build-jogl.xml
+++ b/make/build-jogl.xml
@@ -65,19 +65,23 @@
       <classpath> <pathelement location="${ant-contrib.jar}"/> </classpath>
     </taskdef>
 
-    <condition property="setup.addNativeNVidiaCG">
-        <or>
-            <isset property="${isWindows}" />
-            <isset property="${isOSX}" />
-            <isset property="${isX11}" />
-        </or>
-    </condition>
-
     <!-- ================================================================== -->
     <!-- 
        - Base initialization and detection of operating system.
       -->
     <target name="partitioning.setup" depends="common.init">
+        <echo message="isX11  : ${isX11}" />
+        <condition property="setup.addNativeNVidiaCG">
+            <or>
+                <isset property="isWindows" />
+                <isset property="isOSX" />
+                <isset property="isX11" />
+            </or>
+        </condition>
+        <echo message="setup.noNativeDesktop  : ${setup.noNativeDesktop}" />
+        <echo message="setup.addNativeOpenMAX : ${setup.addNativeOpenMAX}" />
+        <echo message="setup.addNativeNVidiaCG: ${setup.addNativeNVidiaCG}" />
+
         <property name="java.part.gluegen-gl" 
                   value="com/jogamp/gluegen/opengl/** com/jogamp/gluegen/runtime/opengl/*"/>
 
@@ -1069,32 +1073,26 @@
  
       <linker id="linker.cfg.freebsd.jogl.x11" extends="linker.cfg.freebsd">
         <syslibset dir="/usr/local/lib" libs="X11"/>
-        <syslibset dir="/usr/local/lib" libs="Xxf86vm" />
       </linker>
 
       <linker id="linker.cfg.freebsd.amd64.jogl.x11" extends="linker.cfg.freebsd.amd64">
         <syslibset dir="/usr/local/lib" libs="X11"/>
-        <syslibset dir="/usr/local/lib" libs="Xxf86vm" />
       </linker>
 
       <linker id="linker.cfg.linux.jogl.x11" extends="linker.cfg.linux">
         <syslibset libs="X11"/>
-        <syslibset libs="Xxf86vm" />
       </linker>
 
       <linker id="linker.cfg.linux.x86.jogl.x11" extends="linker.cfg.linux.x86">
         <syslibset libs="X11"/>
-        <syslibset libs="Xxf86vm" />
       </linker>
 
       <linker id="linker.cfg.linux.amd64.jogl.x11" extends="linker.cfg.linux.amd64">
         <syslibset libs="X11"/>
-        <syslibset libs="Xxf86vm" />
       </linker>
 
       <linker id="linker.cfg.linux.armv7.jogl.x11" extends="linker.cfg.linux.armv7">
         <syslibset dir="${env.TARGET_PLATFORM_LIBS}" libs="X11"/>
-        <syslibset dir="${env.TARGET_PLATFORM_LIBS}" libs="Xxf86vm" />
       </linker>
 
       <linker id="linker.cfg.android.jogl" extends="linker.cfg.android">
@@ -1105,13 +1103,13 @@
       </linker>
 
       <linker id="linker.cfg.solaris.sparcv9.jogl.x11" extends="linker.cfg.solaris.sparcv9">
-        <linkerarg value="-xarch=v9a" />
-        <syslibset dir="/usr/lib/sparcv9" libs="X11"/>
+        <linkerarg value="-L/usr/lib/sparcv9"/>
+        <syslibset libs="X11"/>
       </linker>
 
       <linker id="linker.cfg.solaris.amd64.jogl.x11" extends="linker.cfg.solaris.amd64">
-        <linkerarg value="-xarch=amd64" />
-        <syslibset dir="/usr/lib/amd64" libs="X11"/>
+        <linkerarg value="-L/usr/lib/amd64"/>
+        <syslibset libs="X11"/>
       </linker>
 
       <linker id="linker.cfg.win32.mingw.jogl" extends="linker.cfg.win32.mingw">
@@ -1132,6 +1130,8 @@
 
       <linker id="linker.cfg.macosx.jogl" extends="linker.cfg.macosx">
         <linkerarg value="-framework" />
+        <linkerarg value="QuartzCore" />
+        <linkerarg value="-framework" />
         <linkerarg value="Cocoa" />
         <linkerarg value="-framework" />
         <linkerarg value="OpenGL" />
@@ -1278,8 +1278,10 @@
         <patternset id="c.src.files.jogl.desktop">
           <include name="${rootrel.src.c}/JoglCommon.c"/>
           <include name="${rootrel.src.c}/GLDebugMessageHandler.c"/>
+          <include name="${rootrel.src.c}/timespec.c" if="isOSX"/> <!-- currently only used for OSX -->
           <include name="${rootrel.src.c}/macosx/MacOSXCustomCGLCode.c" if="isOSX"/>
           <include name="${rootrel.src.c}/macosx/MacOSXWindowSystemInterface.m" if="isOSX"/>
+          <include name="${rootrel.src.c}/macosx/MacOSXWindowSystemInterface-pbuffer.m" if="isOSX"/>
           <include name="${rootrel.src.c}/macosx/ContextUpdater.m" if="isOSX"/>
           <include name="${rootrel.src.c}/GLXGetProcAddressARB.c" if="isX11"/>
           <!-- FIXME: the Mixer should be moved to another library -->
@@ -1351,6 +1353,7 @@
                 <includepath path="stub_includes/cg" if="setup.addNativeNVidiaCG"/>        
       
                 <!-- This is for the generated headers for handwritten C code -->
+                <includepath path="${src.c}"/>
                 <includepath path="${src.generated.c}" />
                 <includepath path="${src.generated.c}/X11" if="isX11"/>
                 <includepath path="${src.generated.c}/MacOSX" if="isOSX"/>
@@ -1569,6 +1572,11 @@
               <exclude name="*jogl_cg.${native.library.suffix}" />
             </fileset>
         </jar>
+        <jar manifest="${build.jogl}/manifest.mf" destfile="${build.jogl}/jogl_cg-natives-${os.and.arch}.jar" filesonly="true">
+            <fileset dir="${obj.jogl}">
+              <include name="*jogl_cg.${native.library.suffix}" />
+            </fileset>
+        </jar>
     </target>
 
     <!-- ================================================================== -->
diff --git a/make/build-nativewindow.xml b/make/build-nativewindow.xml
index 244f610..7a06cef 100644
--- a/make/build-nativewindow.xml
+++ b/make/build-nativewindow.xml
@@ -76,13 +76,13 @@
                   value="javax/media/nativewindow/awt/* jogamp/nativewindow/jawt/** jogamp/nativewindow/**/awt/**"/>
 
         <property name="java.part.x11"
-                  value="jogamp/nativewindow/x11/** javax/media/nativewindow/x11/*" />
+                  value="jogamp/nativewindow/x11/* javax/media/nativewindow/x11/*" />
 
         <property name="java.part.windows"
-                  value="jogamp/nativewindow/windows/** javax/media/nativewindow/windows/*" />
+                  value="jogamp/nativewindow/windows/* javax/media/nativewindow/windows/*" />
 
         <property name="java.part.macosx"
-                  value="jogamp/nativewindow/macosx/** javax/media/nativewindow/macosx/*" />
+                  value="jogamp/nativewindow/macosx/* javax/media/nativewindow/macosx/*" />
 
         <!-- condition excludes -->
 
@@ -245,7 +245,9 @@
                  config="${jawt.cfg}"
                  includeRefid="stub.includes.fileset.platform"
                  literalInclude="${stub.includes.gluegen.gg}, ${stub.includes}/jni"
-                 emitter="com.jogamp.gluegen.JavaEmitter">
+                 emitter="com.jogamp.gluegen.JavaEmitter"
+                 debug="false"
+                 dumpCPP="false">
             <classpath refid="gluegen.classpath" />
         </gluegen>
     </target>
@@ -286,7 +288,7 @@
             <param name="jawt.platform.header"                   value="${stub.includes}/jni/win32/jawt_md.h" />
         </antcall>          
 
-        <echo message="Generating platform-specifics: MaxOsX" />
+        <echo message="Generating platform-specifics: MacOSX" />
         <antcall target="java.generate.platforms" inheritRefs="true">
           <param name="window.os.system"                     value="macosx"/>
           <param name="jawt.cfg"                             value="${config.nativewindow}/jawt-macosx.cfg" />
@@ -342,6 +344,22 @@
         <compilerarg value="/usr/include" />
       </compiler>
 
+      <compiler id="compiler.cfg.solaris.nativewindow.x11" extends="compiler.cfg.solaris">
+        <compilerarg value="-I/usr/X11R6/include" />
+      </compiler>
+
+      <compiler id="compiler.cfg.solaris.nativewindow.x11.sparcv9" extends="compiler.cfg.solaris.sparcv9">
+        <compilerarg value="-I/usr/X11R6/include" />
+      </compiler>
+
+      <compiler id="compiler.cfg.solaris.nativewindow.x11.amd64" extends="compiler.cfg.solaris.amd64">
+        <compilerarg value="-I/usr/X11R6/include" />
+      </compiler>
+
+      <compiler id="compiler.cfg.macosx.nativewindow" extends="compiler.cfg.macosx">
+        <compilerarg value="-I${java.osx.frameworks.dir}/JavaNativeFoundation.framework/Headers" />
+      </compiler>
+
       <!-- linker configuration -->
 
       <linker id="linker.cfg.freebsd.nativewindow.x11" extends="linker.cfg.freebsd">
@@ -387,15 +405,32 @@
       </linker>
 
       <linker id="linker.cfg.solaris.nativewindow.x11" extends="linker.cfg.solaris">
+        <linkerarg value="-L/usr/sfw/lib"/>
+        <syslibset libs="X11"/>
+        <syslibset libs="Xxf86vm" />
+        <syslibset libs="Xinerama"/>
+        <syslibset libs="Xrender"/>
         <syslibset libs="X11"/>
       </linker>
 
       <linker id="linker.cfg.solaris.sparcv9.nativewindow.x11" extends="linker.cfg.solaris.sparcv9">
-        <syslibset dir="/usr/lib/sparcv9" libs="X11"/>
+        <linkerarg value="-L/usr/lib/sparcv9"/>
+        <linkerarg value="-L/usr/sfw/lib/sparcv9"/>
+        <syslibset libs="X11"/>
+        <syslibset libs="Xxf86vm" />
+        <syslibset libs="Xinerama"/>
+        <syslibset libs="Xrender"/>
+        <syslibset libs="X11"/>
       </linker>
 
       <linker id="linker.cfg.solaris.amd64.nativewindow.x11" extends="linker.cfg.solaris.amd64">
-        <syslibset dir="/usr/lib/amd64" libs="X11"/>
+        <linkerarg value="-L/usr/lib/amd64"/>
+        <linkerarg value="-L/usr/sfw/lib/amd64"/>
+        <syslibset libs="X11"/>
+        <syslibset libs="Xxf86vm" />
+        <syslibset libs="Xinerama"/>
+        <syslibset libs="Xrender"/>
+        <syslibset libs="X11"/>
       </linker>
 
       <linker id="linker.cfg.win32.mingw.nativewindow" extends="linker.cfg.win32.mingw">
@@ -414,7 +449,13 @@
       
       <linker id="linker.cfg.macosx.nativewindow" extends="linker.cfg.macosx">
         <linkerarg value="-framework" />
+        <linkerarg value="QuartzCore" />
+        <linkerarg value="-framework" />
         <linkerarg value="Cocoa" />
+        <linkerarg value="-framework" />
+        <linkerarg value="JavaNativeFoundation" />
+        <linkerarg value="-F" />
+        <linkerarg value="${java.osx.frameworks.dir}" />
       </linker>
 
       <linker id="linker.cfg.hpux.nativewindow" extends="linker.cfg.hpux">
@@ -475,21 +516,21 @@
     
     <target name="c.configure.solaris32" depends="c.configure.x11" if="isSolaris32Bit">
       <echo message="Solaris" />
-      <property name="compiler.cfg.id"                      value="compiler.cfg.solaris" />
+      <property name="compiler.cfg.id"                      value="compiler.cfg.solaris.nativewindow.x11" />
       <property name="linker.cfg.id.oswin"                  value="linker.cfg.solaris.nativewindow.x11" />
     </target>
   
  
     <target name="c.configure.solaris.sparcv9" depends="c.configure.x11" if="isSolarisSparcv9">
       <echo message="SolarisSparcv9" />
-      <property name="compiler.cfg.id"                      value="compiler.cfg.solaris.sparcv9" />
+      <property name="compiler.cfg.id"                      value="compiler.cfg.solaris.nativewindow.x11.sparcv9" />
       <property name="linker.cfg.id.oswin"                  value="linker.cfg.solaris.sparcv9.nativewindow.x11" />
     </target>
    
 
     <target name="c.configure.solaris.amd64" depends="c.configure.x11" if="isSolarisAMD64">
       <echo message="SolarisAMD64" />
-      <property name="compiler.cfg.id"                      value="compiler.cfg.solaris.amd64" />
+      <property name="compiler.cfg.id"                      value="compiler.cfg.solaris.nativewindow.x11.amd64" />
       <property name="linker.cfg.id.oswin"                  value="linker.cfg.solaris.amd64.nativewindow.x11" />
     </target>
    
@@ -518,7 +559,7 @@
     <target name="c.configure.x11" if="isX11" />
 
     <target name="c.configure.macosx" if="isOSX">
-      <property name="compiler.cfg.id"                      value="compiler.cfg.macosx" />
+      <property name="compiler.cfg.id"                      value="compiler.cfg.macosx.nativewindow" />
       <property name="linker.cfg.id.oswin"                  value="linker.cfg.macosx.nativewindow" />
     </target>
     
@@ -586,7 +627,7 @@
         </patternset>
 
         <patternset id="c.src.files.macosx">
-          <include name="${rootrel.src.c}/macosx/OSXmisc.c"/>
+          <include name="${rootrel.src.c}/macosx/OSXmisc.m"/>
           <include name="${rootrel.src.c}/NativewindowCommon.c"/>
         </patternset>
 
@@ -696,6 +737,7 @@
 
     <target name="c.build.nativewindow.windowlib.windows" if="isWindows">
       <javah destdir="${src.generated.c}/Windows" classpath="${javah.classpath}" class="jogamp.nativewindow.windows.GDI" />
+      <javah destdir="${src.generated.c}/Windows" classpath="${javah.classpath}" class="jogamp.nativewindow.windows.GDIUtil" />
 
       <c.build c.compiler.src.files="c.src.files.windows"
                output.lib.name="nativewindow_win32"
@@ -705,6 +747,7 @@
 
     <target name="c.build.nativewindow.windowlib.macosx" if="isOSX">
       <javah destdir="${src.generated.c}/MacOSX" classpath="${javah.classpath}" class="jogamp.nativewindow.macosx.OSXUtil" />
+      <javah destdir="${src.generated.c}/MacOSX" classpath="${javah.classpath}" class="jogamp.nativewindow.jawt.macosx.MacOSXJAWTWindow" />
 
       <c.build c.compiler.src.files="c.src.files.macosx"
                output.lib.name="nativewindow_macosx"
diff --git a/make/build-newt.xml b/make/build-newt.xml
index e433b28..56ebfac 100644
--- a/make/build-newt.xml
+++ b/make/build-newt.xml
@@ -96,7 +96,7 @@
         <!-- partitioning -->
 
         <property name="java.part.core"
-                  value="com/jogamp/newt/* com/jogamp/newt/event/* com/jogamp/newt/util/* jogamp/newt/* jogamp/newt/event/*"/>
+                  value="com/jogamp/newt/* com/jogamp/newt/event/* com/jogamp/newt/util/* jogamp/newt/* jogamp/newt/event/* jogamp/newt/driver/*"/>
 
         <property name="java.part.opengl"
                   value="com/jogamp/newt/opengl/**"/>
@@ -239,15 +239,15 @@
       <!-- linker configuration -->
 
       <linker id="linker.cfg.freebsd.newt.x11" extends="linker.cfg.freebsd">
-        <syslibset dir="/usr/local/lib" libs="X11"/>
+        <linkerarg value="-L/usr/local/lib"/>
+        <syslibset libs="X11"/>
         <syslibset libs="Xrandr"/>
-        <syslibset dir="/usr/local/lib" libs="Xxf86vm" />
       </linker>
 
       <linker id="linker.cfg.freebsd.amd64.newt.x11" extends="linker.cfg.freebsd.amd64">
-        <syslibset dir="/usr/local/lib" libs="X11"/>
+        <linkerarg value="-L/usr/local/lib"/>
+        <syslibset libs="X11"/>
         <syslibset libs="Xrandr"/>
-        <syslibset dir="/usr/local/lib" libs="Xxf86vm" />
       </linker>
 
       <linker id="linker.cfg.linux.newt.broadcom_egl" extends="linker.cfg.linux">
@@ -258,25 +258,21 @@
       <linker id="linker.cfg.linux.newt.x11" extends="linker.cfg.linux">
         <syslibset libs="X11"/>
         <syslibset libs="Xrandr"/>
-        <syslibset libs="Xxf86vm" />
       </linker>
 
       <linker id="linker.cfg.linux.x86.newt.x11" extends="linker.cfg.linux.x86">
         <syslibset libs="X11"/>
         <syslibset libs="Xrandr"/>
-        <syslibset libs="Xxf86vm" />
       </linker>
 
       <linker id="linker.cfg.linux.amd64.newt.x11" extends="linker.cfg.linux.amd64">
         <syslibset libs="X11"/>
         <syslibset libs="Xrandr"/>
-        <syslibset libs="Xxf86vm" />
       </linker>
 
       <linker id="linker.cfg.linux.armv7.newt.x11" extends="linker.cfg.linux.armv7">
         <syslibset dir="${env.TARGET_PLATFORM_LIBS}" libs="X11" />
         <syslibset dir="${env.TARGET_PLATFORM_LIBS}" libs="Xrandr" />
-        <syslibset dir="${env.TARGET_PLATFORM_LIBS}" libs="Xxf86vm" />
       </linker>
 
       <linker id="linker.cfg.android.newt" extends="linker.cfg.android">
@@ -285,14 +281,19 @@
 
       <linker id="linker.cfg.solaris.newt.x11" extends="linker.cfg.solaris">
         <syslibset libs="X11"/>
+        <syslibset libs="Xrandr"/>
       </linker>
 
       <linker id="linker.cfg.solaris.sparcv9.newt.x11" extends="linker.cfg.solaris.sparcv9">
-        <syslibset dir="/usr/lib/sparcv9" libs="X11"/>
+        <linkerarg value="-L/usr/lib/sparcv9"/>
+        <syslibset libs="X11"/>
+        <syslibset libs="Xrandr"/>
       </linker>
 
       <linker id="linker.cfg.solaris.amd64.newt.x11" extends="linker.cfg.solaris.amd64">
-        <syslibset dir="/usr/lib/amd64" libs="X11"/>
+        <linkerarg value="-L/usr/lib/amd64"/>
+        <syslibset libs="X11"/>
+        <syslibset libs="Xrandr"/>
       </linker>
 
       <linker id="linker.cfg.win32.mingw.newt" extends="linker.cfg.win32.mingw">
diff --git a/make/build-test.xml b/make/build-test.xml
index f7f9760..533ca30 100644
--- a/make/build-test.xml
+++ b/make/build-test.xml
@@ -56,14 +56,6 @@
       <mkdir dir="${obj.test}" />
       <mkdir dir="${classes}" />
 
-      <!-- Clean the results -->
-      <delete quiet="true">
-        <fileset dir="${results.test}" includes="**"/>
-        <fileset file="${build}/${test.archive.name}.7z"/>
-        <fileset dir="." includes="*.tga" />
-      </delete>
-      <mkdir dir="${results.test}" />
-
       <property name="jogl.test.jar.path" location="${jogl.test.jar}"/> <!-- absolute path -->
       <echo message="jogl.test.jar ${jogl.test.jar.path}"/>
       <uptodate property="test.compile.skip">
@@ -132,6 +124,7 @@
                  output="${test.class.result.file}">
                 <env key="${system.env.library.path}" path="${obj.all.paths}"/>
                 <env key="CLASSPATH" value="${junit_jogl_awt.run.jars}"/>
+                <arg line="${jvmDataModel.arg}"/>
                 <arg value="-Djava.library.path=${obj.all.paths}"/>
                 <!--
                 <arg line="-Dnewt.debug.EDT"/>
@@ -151,6 +144,7 @@
         <!-- Test*NOUI* -->
         <junit forkmode="perTest" showoutput="true" fork="true" haltonerror="off" timeout="${batchtest.timeout}">
             <env key="${system.env.library.path}" path="${obj.all.paths}"/>
+            <jvmarg value="${jvmDataModel.arg}"/>
             <jvmarg value="-Djava.library.path=${obj.all.paths}"/>
 
             <!--
@@ -214,6 +208,7 @@
                  failonerror="false">
                 <env key="${system.env.library.path}" path="${obj.all.paths}"/>
                 <env key="CLASSPATH" value="${junit_jogl_noawt.run.jars}"/>
+                <arg line="${jvmDataModel.arg}"/>
                 <arg value="-Djava.library.path=${obj.all.paths}"/>
                 <arg line="${jvmarg.headless}"/>
                 <!--
@@ -243,12 +238,12 @@
     <!-- junit.run.newt is covered by junit.run.newt.headless, disable it for now, but may be checked manually.
          This test target would also overwrite the test result XML files, we would also need a solution here for hudson,
          if run in parallel.
-         NEWT is currently not supported on OSX 
       -->
     <target name="junit.run.newt" depends="test.compile">
         <!-- Test*NEWT* -->
         <junit forkmode="perTest" showoutput="true" fork="true" haltonerror="off" timeout="${batchtest.timeout}">
             <env key="${system.env.library.path}" path="${obj.all.paths}"/>
+            <jvmarg value="${jvmDataModel.arg}"/>
             <jvmarg value="-Djava.library.path=${obj.all.paths}"/>
 
             <!--
@@ -283,6 +278,7 @@
         <!-- Test*AWT* -->
         <junit forkmode="perTest" showoutput="true" fork="true" haltonerror="off" timeout="${batchtest.timeout}">
             <env key="${system.env.library.path}" path="${obj.all.paths}"/>
+            <jvmarg value="${jvmDataModel.arg}"/>
             <jvmarg value="-Djava.library.path=${obj.all.paths}"/>
 
             <!--
@@ -317,6 +313,7 @@
         <!-- Test*AWT* -->
         <junit forkmode="perTest" showoutput="true" fork="true" haltonerror="off" timeout="${batchtest.timeout}">
             <env key="${system.env.library.path}" path="${obj.all.paths}"/>
+            <jvmarg value="${jvmDataModel.arg}"/>
             <jvmarg value="-Djava.library.path=${obj.all.paths}"/>
 
             <!--
@@ -338,11 +335,10 @@
         </junit>
     </target>
 
-    <target name="junit.run.swt.headless" depends="test.compile" description="Runs all pure SWT tests.">
+    <target name="junit.run.swt.headless" depends="test.compile" description="Runs all pure SWT tests." if="isSWTRuntimeAvailable">
         <!-- Test*SWT* 
 
-             Emulation of junit task,
-             due to the fact that we have to place invoke our MainThread class first (-> MacOSX).
+             Emulation of junit task.
 
              Utilizing Ant-1.8.0 and ant-contrib-1.0b3 (loops, mutable properties).
           --> 
@@ -374,13 +370,14 @@
                  relative="true"
                  failonerror="false">
                 <env key="${system.env.library.path}" path="${obj.all.paths}"/>
-                <env key="CLASSPATH" value="${junit_jogl_swt.run.jars}"/>
+                <env key="CLASSPATH" value="${junit_extra_classpath}${junit_jogl_swt.run.jars}"/>
+                <arg line="${jvmDataModel.arg}"/>
                 <arg value="-Djava.library.path=${obj.all.paths}"/>
                 <arg line="${jvmarg.headless}"/>
                 <!--
                 <arg line="-Dnewt.debug.EDT"/>
                 -->
-                <arg line="com.jogamp.newt.util.MainThread"/>
+                <!-- arg line="com.jogamp.newt.util.MainThread"/-->
                 <arg line="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner"/>
                 <srcfile/>
                 <arg line="filtertrace=true"/>
@@ -401,12 +398,12 @@
         </for>
     </target>
 
-    <target name="junit.run.swt.awt" depends="test.compile" description="Runs all SWT_AWT tests.">
-      <!-- Test*SWT* -->
+    <target name="junit.run.swt.awt" depends="test.compile" description="Runs all SWT_AWT tests." if="isSWTRuntimeAvailable">
+      <!-- Test*SWT*AWT* -->
       <junit forkmode="perTest" showoutput="true" fork="true" haltonerror="off" timeout="${batchtest.timeout}">
           <env key="${system.env.library.path}" path="${obj.all.paths}"/>
+          <jvmarg value="${jvmDataModel.arg}"/>
           <jvmarg value="-Djava.library.path=${obj.all.paths}"/>
-          <jvmarg value="${jvmarg.mainthrd}"/>
 
           <!--
           <jvmarg value="-Djogl.debug=all"/>
@@ -421,7 +418,7 @@
 
           <formatter usefile="false" type="plain"/>
           <formatter usefile="true" type="xml"/>
-          <classpath refid="junit_jogl_swt.run.classpath"/>
+          <classpath path="${junit_extra_classpath}${junit_jogl_swt.run.jars}"/>
 
           <batchtest todir="${results.test}">
             <fileset dir="${classes}">
@@ -435,10 +432,10 @@
       </junit>
     </target>
 
-    <!-- NEWT is currently not supported on OSX -->
     <target name="junit.run.newt.awt" depends="test.compile">
         <!-- Test*AWT* -->
         <junit forkmode="perTest" showoutput="true" fork="true" haltonerror="off" timeout="${batchtest.timeout}">
+            <jvmarg value="${jvmDataModel.arg}"/>
             <env key="${system.env.library.path}" path="${obj.all.paths}"/>
             <jvmarg value="-Djava.library.path=${obj.all.paths}"/>
 
@@ -471,19 +468,57 @@
     </target>
 
     <target name="test.auto.run" depends="junit.run"/>
-    <target name="junit.run" depends="junit.run.noui,junit.run.newt.headless,junit.run.awt,junit.run.newt.awt,junit.run.swt.headless,junit.run.swt.awt">
-        <antcall target="test-zip-archive" inheritRefs="true" inheritAll="true"/>
+
+        <condition property="jvmarg.mainthrd" value="-XstartOnFirstThread"><isset property="isOSX"/></condition>
+
+    <target name="junit.run.tests" depends="junit.run.noui,junit.run.newt.headless,junit.run.awt,junit.run.newt.awt,junit.run.swt.headless,junit.run.swt.awt"/>
+
+    <target name="junit.run.d32" if="isOSX">
+        <var name="jvmDataModel.arg" unset="true"/>
+        <var name="jvmDataModel.arg" value="-d32"/>
+        <var name="junit_extra_classpath" unset="true"/>
+        <var name="junit_extra_classpath" value="${swt-cocoa-macosx-x86_32.jar}:"/>
+
+        <antcall target="junit.run.tests" inheritRefs="true" inheritAll="true"/>
+
+        <mkdir dir="${build}/test/results-x32"/>
+        <move todir="${build}/test/results-x32">
+            <fileset dir="." includes="*.tga" />
+        </move>
+        <move todir="${build}/test/results-x32">
+            <fileset dir="${results.test}" includes="**" />
+        </move>
+        <mkdir dir="${build}/test/results"/>
+
+        <var name="jvmDataModel.arg" unset="true"/>
+        <var name="jvmDataModel.arg" value="-d64"/>
+        <var name="junit_extra_classpath" unset="true"/>
+        <var name="junit_extra_classpath" value=""/>
     </target>
 
-    <!-- updates / create the test results zip file -->
-    <target name="test-zip-archive" depends="declare.common">
+    <target name="junit.run.settings">
+        <delete quiet="true">
+            <fileset dir="${results.test}" includes="**"/>
+            <fileset dir="${build}/test/results-x32" includes="**"/>
+            <fileset file="${build}/${test.archive.name}.7z"/>
+            <fileset dir="." includes="*.tga" />
+        </delete>
+        <mkdir dir="${results.test}" />
+    </target>
+
+    <target name="junit.run" depends="declare.common, junit.run.settings, junit.run.d32, junit.run.tests">
+        <mkdir dir="${results.test}" />
         <move todir="${results.test}">
             <fileset dir="." includes="*.tga" />
         </move>
-        <mkdir dir="${results.test}" />
+        <antcall target="test-zip-archive" inheritRefs="true" inheritAll="true"/>
+    </target>
+
+    <!-- updates / create the test results zip file -->
+    <target name="test-zip-archive" depends="declare.common">
         <archive.7z destfile="${build}/${test.archive.name}.7z"
-                    basedir="${results.test}" 
-                    includes="**" />
+                    basedir="${project.root}" 
+                    includes="${rootrel.build}/test/results ${rootrel.build}/test/results-x64 ${rootrel.build}/test/results-x32" />
     </target>
 
     <!-- ================================================================== -->
diff --git a/make/config/jogl/cg-common.cfg b/make/config/jogl/cg-common.cfg
index 606f86b..f21ece3 100644
--- a/make/config/jogl/cg-common.cfg
+++ b/make/config/jogl/cg-common.cfg
@@ -119,6 +119,7 @@ RuntimeExceptionType CgException
 # generated C code
 #
 
+CustomCCode #include <gluegen_stdint.h>
 CustomCCode #include <stdio.h> /* android */
 CustomCCode #include <stdlib.h>
 CustomCCode #include <Cg/cgGL.h>
diff --git a/make/config/jogl/cgl-macosx.cfg b/make/config/jogl/cgl-macosx.cfg
index 06bc946..7d17c4a 100644
--- a/make/config/jogl/cgl-macosx.cfg
+++ b/make/config/jogl/cgl-macosx.cfg
@@ -20,6 +20,13 @@ Opaque long CGLShareGroupObj
 Opaque long CGLPBufferObj
 Opaque long CGLPixelFormatObj
 
+Opaque long NSOpenGLPixelFormat *
+Opaque long NSOpenGLContext *
+Opaque long NSView *
+Opaque long NSOpenGLView *
+Opaque long NSOpenGLPixelBuffer *
+Opaque long NSOpenGLLayer *
+
 CustomCCode #include </usr/include/machine/types.h>
 CustomCCode #include "macosx-window-system.h"
 
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-common.java b/make/config/jogl/gl-impl-CustomJavaCode-common.java
index 0a8e901..0878bd2 100644
--- a/make/config/jogl/gl-impl-CustomJavaCode-common.java
+++ b/make/config/jogl/gl-impl-CustomJavaCode-common.java
@@ -35,6 +35,11 @@
       return _context.isExtensionAvailable(glExtensionName);
     }
 
+    public boolean isNPOTTextureAvailable() {
+      return isGL3() || isGLES2() || isExtensionAvailable(GL_ARB_texture_non_power_of_two);
+    }
+    private static final String GL_ARB_texture_non_power_of_two = "GL_ARB_texture_non_power_of_two";
+
     public Object getExtension(String extensionName) {
       // At this point we don't expose any extensions using this mechanism
       return null;
diff --git a/make/config/nativewindow/jawt-CustomJavaCode.java b/make/config/nativewindow/jawt-CustomJavaCode.java
index 3223a74..d3dc384 100644
--- a/make/config/nativewindow/jawt-CustomJavaCode.java
+++ b/make/config/nativewindow/jawt-CustomJavaCode.java
@@ -1,27 +1,38 @@
-private static volatile JAWT jawt;
+/** Available and recommended on Mac OS X >= 10.6 Update 4 */
+public static final int JAWT_MACOSX_USE_CALAYER = 0x80000000;
+public static final VersionNumber JAWT_MacOSXCALayerMinVersion = new VersionNumber(10,6,4);
+
+private int jawt_version_cached = 0;
+
+public final int getCachedVersion() {
+    return jawt_version_cached;
+}
 
 /** Helper routine for all users to call to access the JAWT. */
-public static JAWT getJAWT() {
-  if (jawt == null) {
-    synchronized (JAWT.class) {
-      if (jawt == null) {
-        JAWTUtil.initSingleton();
-        // Workaround for 4845371.
-        // Make sure the first reference to the JNI GetDirectBufferAddress is done
-        // from a privileged context so the VM's internal class lookups will succeed.
-        AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-              JAWT j = JAWT.create();
-              j.setVersion(JAWTFactory.JAWT_VERSION_1_4);
-              if (!JAWTFactory.JAWT_GetAWT(j)) {
-                throw new RuntimeException("Unable to initialize JAWT");
+public static JAWT getJAWT(final int jawt_version_flags) {
+    JAWTUtil.initSingleton();
+    // Workaround for 4845371.
+    // Make sure the first reference to the JNI GetDirectBufferAddress is done
+    // from a privileged context so the VM's internal class lookups will succeed.
+    return AccessController.doPrivileged(new PrivilegedAction<JAWT>() {
+        public JAWT run() {
+          int jawt_version_flags_mod = jawt_version_flags;
+          JAWT jawt = JAWT.create();
+          if( 0 != ( jawt_version_flags_mod & JAWT_MACOSX_USE_CALAYER ) ) {
+              jawt.setVersion(jawt_version_flags_mod);
+              if (JAWTFactory.JAWT_GetAWT(jawt)) {
+                  jawt.jawt_version_cached = jawt.getVersion();
+                  return jawt;
               }
-              jawt = j;
-              return null;
-            }
-          });
-      }
-    }
-  }
-  return jawt;
+              jawt_version_flags_mod &= ~JAWT_MACOSX_USE_CALAYER;
+              System.err.println("MacOSX "+Platform.OS_VERSION_NUMBER+" >= "+JAWT_MacOSXCALayerMinVersion+": Failed to use JAWT_MACOSX_USE_CALAYER");
+          }
+          jawt.setVersion(jawt_version_flags_mod);
+          if (!JAWTFactory.JAWT_GetAWT(jawt)) {
+            throw new RuntimeException("Unable to initialize JAWT: 0x"+Integer.toHexString(jawt_version_flags_mod));
+          }
+          jawt.jawt_version_cached = jawt.getVersion();
+          return jawt;
+        }
+      });
 }
diff --git a/make/config/nativewindow/jawt-DrawingSurfaceInfo-CustomJavaCode.java b/make/config/nativewindow/jawt-DrawingSurfaceInfo-CustomJavaCode.java
index 598ced3..4ff3a45 100644
--- a/make/config/nativewindow/jawt-DrawingSurfaceInfo-CustomJavaCode.java
+++ b/make/config/nativewindow/jawt-DrawingSurfaceInfo-CustomJavaCode.java
@@ -1,30 +1,29 @@
-public JAWT_PlatformInfo platformInfo() {
-  return newPlatformInfo(platformInfo0(getBuffer()));
+public JAWT_PlatformInfo platformInfo(final JAWT jawt) {
+  return newPlatformInfo(jawt, platformInfo0(getBuffer()));
 }
 
 private native ByteBuffer platformInfo0(Buffer jthis0);
 
 private static java.lang.reflect.Method platformInfoFactoryMethod;
 
-private static JAWT_PlatformInfo newPlatformInfo(ByteBuffer buf) {
+private static JAWT_PlatformInfo newPlatformInfo(JAWT jawt, ByteBuffer buf) {
   if (platformInfoFactoryMethod == null) {
-    String osName = (String) AccessController.doPrivileged(new PrivilegedAction() {
-        public Object run() {
-          return System.getProperty("os.name").toLowerCase();
-        }
-      });
     try {
-      Class factoryClass;
-      if (osName.startsWith("wind")) {
-        factoryClass = Class.forName("jogamp.nativewindow.jawt.windows.JAWT_Win32DrawingSurfaceInfo");
-      } else if (osName.startsWith("mac os x")) {
-        factoryClass = Class.forName("jogamp.nativewindow.jawt.macosx.JAWT_MacOSXDrawingSurfaceInfo");
-      } else {
-        // Assume Linux, Solaris, etc. Should probably test for these explicitly.
-        factoryClass = Class.forName("jogamp.nativewindow.jawt.x11.JAWT_X11DrawingSurfaceInfo");
-      }
-      platformInfoFactoryMethod = factoryClass.getMethod("create",
-                                                         new Class[] { ByteBuffer.class });
+        Class<?> factoryClass;
+        if (Platform.OS_TYPE == Platform.OSType.WINDOWS) {
+          factoryClass = Class.forName("jogamp.nativewindow.jawt.windows.JAWT_Win32DrawingSurfaceInfo");
+        } else if (Platform.OS_TYPE == Platform.OSType.MACOS) {
+          if( 0 != ( jawt.getCachedVersion() & JAWT.JAWT_MACOSX_USE_CALAYER ) ) {
+              factoryClass = Class.forName("jogamp.nativewindow.jawt.macosx.JAWT_SurfaceLayers");
+          } else {
+              factoryClass = Class.forName("jogamp.nativewindow.jawt.macosx.JAWT_MacOSXDrawingSurfaceInfo");
+          }
+        } else {
+          // Assume Linux, Solaris, etc. Should probably test for these explicitly.
+          factoryClass = Class.forName("jogamp.nativewindow.jawt.x11.JAWT_X11DrawingSurfaceInfo");
+        }
+        platformInfoFactoryMethod = factoryClass.getMethod("create",
+                                                           new Class[] { ByteBuffer.class });
     } catch (Exception e) {
       throw new RuntimeException(e);
     }
diff --git a/make/config/nativewindow/jawt-common.cfg b/make/config/nativewindow/jawt-common.cfg
index d633c47..55f3f36 100644
--- a/make/config/nativewindow/jawt-common.cfg
+++ b/make/config/nativewindow/jawt-common.cfg
@@ -22,5 +22,7 @@ CustomCCode #include <jawt.h>
 
 import java.security.*
 import jogamp.nativewindow.jawt.*
+import com.jogamp.common.os.Platform
+import com.jogamp.common.util.VersionNumber
 
 IncludeAs CustomJavaCode JAWT_DrawingSurfaceInfo jawt-DrawingSurfaceInfo-CustomJavaCode.java
diff --git a/make/config/nativewindow/jawt-macosx.cfg b/make/config/nativewindow/jawt-macosx.cfg
index c41367f..20260f6 100644
--- a/make/config/nativewindow/jawt-macosx.cfg
+++ b/make/config/nativewindow/jawt-macosx.cfg
@@ -5,6 +5,7 @@ NativeOutputDir gensrc/native/MacOSX
 
 Opaque long void *
 Opaque long NSView *
+Opaque long CALayer *
 
 CustomCCode #include <inttypes.h>
 CustomCCode #include </usr/include/machine/types.h>
@@ -12,3 +13,7 @@ CustomCCode #include </usr/include/machine/types.h>
 StructPackage JAWT_MacOSXDrawingSurfaceInfo jogamp.nativewindow.jawt.macosx
 EmitStruct JAWT_MacOSXDrawingSurfaceInfo
 Implements JAWT_MacOSXDrawingSurfaceInfo JAWT_PlatformInfo
+
+StructPackage JAWT_SurfaceLayers jogamp.nativewindow.jawt.macosx
+EmitStruct JAWT_SurfaceLayers
+Implements JAWT_SurfaceLayers JAWT_PlatformInfo
diff --git a/make/config/nativewindow/win32-CustomJavaCode.java b/make/config/nativewindow/win32-CustomJavaCode.java
index e14e4d1..5c484c2 100644
--- a/make/config/nativewindow/win32-CustomJavaCode.java
+++ b/make/config/nativewindow/win32-CustomJavaCode.java
@@ -1,60 +1,2 @@
   
-  private static final boolean DEBUG = Debug.debug("GDI");
-
-  private static final String dummyWindowClassNameBase = "_dummyWindow_clazz" ;
-  private static RegisteredClassFactory dummyWindowClassFactory;
-  private static boolean isInit = false;
-
-  private static native boolean initIDs0();
-  private static native long getDummyWndProc0();
-
-  public static synchronized void initSingleton(boolean firstX11ActionOnProcess) {
-    if(!isInit) {
-        NWJNILibLoader.loadNativeWindow("win32");
-        
-        if( !initIDs0() ) {
-            throw new NativeWindowException("GDI: Could not initialized native stub");
-        }
-
-        if(DEBUG) {
-            System.out.println("GDI.isFirstX11ActionOnProcess: "+firstX11ActionOnProcess);
-        }
-
-        dummyWindowClassFactory = new RegisteredClassFactory(dummyWindowClassNameBase, getDummyWndProc0());
-        isInit = true;
-    }
-  }
-
-  public static boolean requiresToolkitLock() { return false; }
-
-  private static RegisteredClass dummyWindowClass = null;
-  private static Object dummyWindowSync = new Object();
-
-  public static long CreateDummyWindow(int x, int y, int width, int height) {
-      synchronized(dummyWindowSync) {
-          dummyWindowClass = dummyWindowClassFactory.getSharedClass();
-          return CreateDummyWindow0(dummyWindowClass.getHandle(), dummyWindowClass.getName(), dummyWindowClass.getName(), x, y, width, height);
-      }
-  }
-
-  public static boolean DestroyDummyWindow(long hwnd) {
-      boolean res;
-      synchronized(dummyWindowSync) {
-          if( null == dummyWindowClass ) {
-              throw new InternalError("GDI Error ("+dummyWindowClassFactory.getSharedRefCount()+"): SharedClass is null");
-          }
-          res = DestroyWindow(hwnd);
-          dummyWindowClassFactory.releaseSharedClass();
-      }
-      return res;
-  }
-
-  public static Point GetRelativeLocation(long src_win, long dest_win, int src_x, int src_y) {
-      return (Point) GetRelativeLocation0(src_win, dest_win, src_x, src_y);
-  }
-  private static native Object GetRelativeLocation0(long src_win, long dest_win, int src_x, int src_y);
-
-  public static native boolean CreateWindowClass(long hInstance, String clazzName, long wndProc);
-  public static native boolean DestroyWindowClass(long hInstance, String className);
-  static native long CreateDummyWindow0(long hInstance, String className, String windowName, int x, int y, int width, int height);
 
diff --git a/make/config/nativewindow/win32-lib.cfg b/make/config/nativewindow/win32-lib.cfg
index b8ff424..26c744a 100644
--- a/make/config/nativewindow/win32-lib.cfg
+++ b/make/config/nativewindow/win32-lib.cfg
@@ -36,7 +36,5 @@ CustomCCode #include <gluegen_stddef.h>
 CustomCCode #include <wingdi.h>
 CustomCCode #include "WindowsDWM.h"
 
-CustomCCode extern HINSTANCE   GetApplicationHandle();
-
-IncludeAs CustomJavaCode GDI win32-CustomJavaCode.java
+CustomCCode extern HINSTANCE GetApplicationHandle();
 
diff --git a/make/resources/android/AndroidManifest-launcher.xml b/make/resources/android/AndroidManifest-launcher.xml
index 88abc8b..dda42b4 100644
--- a/make/resources/android/AndroidManifest-launcher.xml
+++ b/make/resources/android/AndroidManifest-launcher.xml
@@ -4,6 +4,8 @@
       package="com.jogamp.android.launcher">
 
     <uses-permission android:name="android.permission.INTERNET" /> <!-- required for NV's perfhud -->
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- required for Android trace -->
+
     <uses-sdk android:minSdkVersion="9" />
     <uses-library android:name="com.jogamp.common" android:required="true" />
     <uses-library android:name="javax.media.opengl" android:required="true" />
diff --git a/make/scripts/adb-logcat.sh b/make/scripts/adb-logcat.sh
new file mode 100755
index 0000000..ea4be3d
--- /dev/null
+++ b/make/scripts/adb-logcat.sh
@@ -0,0 +1,4 @@
+sdir=`dirname $0`
+
+adb $* logcat -c
+adb $* logcat
diff --git a/make/scripts/adb-reinstall-all.sh b/make/scripts/adb-reinstall-all.sh
index db366c4..f450a29 100755
--- a/make/scripts/adb-reinstall-all.sh
+++ b/make/scripts/adb-reinstall-all.sh
@@ -2,3 +2,4 @@ sdir=`dirname $0`
 
 $sdir/adb-uninstall-all.sh $*
 $sdir/adb-install-all.sh $*
+
diff --git a/make/scripts/check-junit.sh b/make/scripts/check-junit.sh
index 1b1ba78..474d074 100755
--- a/make/scripts/check-junit.sh
+++ b/make/scripts/check-junit.sh
@@ -3,25 +3,36 @@
 builddir=$1
 shift
 
-echo number of junit classes
-grep failures $builddir/test/results/* | wc
-echo
-echo number of passed junit classes - failures
-grep failures $builddir/test/results/* | grep "failures=\"0\"" | wc
-echo
-echo number of passed junit classes - errors
-grep failures $builddir/test/results/* | grep "errors=\"0\"" | wc
-echo
-echo number of failed junit classes - failures
-grep failures $builddir/test/results/* | grep -v "failures=\"0\"" | wc
-echo
-echo number of failed junit classes - errors
-grep failures $builddir/test/results/* | grep -v "errors=\"0\"" | wc
-echo
-echo failed junit classes - failures
-grep failures $builddir/test/results/* | grep -v "failures=\"0\""
-echo
-echo failed junit classes - errors
-grep failures $builddir/test/results/* | grep -v "errors=\"0\""
-echo
+function checkresult() {
+    resdir=$1
+    shift
+    if [ -e $builddir/test/$resdir ] ; then
+        echo
+        echo Results of $builddir/test/$resdir
+        echo
+        echo number of junit classes
+        grep failures $builddir/test/$resdir/* | wc
+        echo
+        echo number of passed junit classes - failures
+        grep failures $builddir/test/$resdir/* | grep "failures=\"0\"" | wc
+        echo
+        echo number of passed junit classes - errors
+        grep failures $builddir/test/$resdir/* | grep "errors=\"0\"" | wc
+        echo
+        echo number of failed junit classes - failures
+        grep failures $builddir/test/$resdir/* | grep -v "failures=\"0\"" | wc
+        echo
+        echo number of failed junit classes - errors
+        grep failures $builddir/test/$resdir/* | grep -v "errors=\"0\"" | wc
+        echo
+        echo failed junit classes - failures
+        grep failures $builddir/test/$resdir/* | grep -v "failures=\"0\""
+        echo
+        echo failed junit classes - errors
+        grep failures $builddir/test/$resdir/* | grep -v "errors=\"0\""
+        echo
+    fi
+}
 
+checkresult results
+checkresult results-x32
diff --git a/make/scripts/java-win32-dbg.bat b/make/scripts/java-win32-dbg.bat
index c97dd20..909a51c 100755
--- a/make/scripts/java-win32-dbg.bat
+++ b/make/scripts/java-win32-dbg.bat
@@ -1,7 +1,7 @@
 
 set BLD_SUB=build-win32
-set J2RE_HOME=c:\jre1.6.0_26_x32
-set JAVA_HOME=c:\jdk1.6.0_26_x32
+set J2RE_HOME=c:\jre1.6.0_29_x32
+set JAVA_HOME=c:\jdk1.6.0_29_x32
 set ANT_PATH=C:\apache-ant-1.8.2
 
 set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH%
@@ -19,7 +19,10 @@ REM set D_ARGS="-Dnewt.debug.Window" "-Dnativewindow.debug.TraceLock"
 REM set D_ARGS="-Dnativewindow.debug.TraceLock"
 REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display"
 set D_ARGS="-Djogl.debug=all"
+REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL"
+REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" "-Djogl.debug=all"
 REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.test.Window.reparent.incompatible=true"
+REM set D_ARGS="-Xcheck:jni" "-Xint" "-verbose:jni"
 
 set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true"
 
diff --git a/make/scripts/java-win32.bat b/make/scripts/java-win32.bat
index 280818c..536c3f2 100755
--- a/make/scripts/java-win32.bat
+++ b/make/scripts/java-win32.bat
@@ -1,7 +1,7 @@
 
 set BLD_SUB=build-win32
-set J2RE_HOME=c:\jre1.6.0_26_x32
-set JAVA_HOME=c:\jdk1.6.0_26_x32
+set J2RE_HOME=c:\jre1.6.0_29_x32
+set JAVA_HOME=c:\jdk1.6.0_29_x32
 set ANT_PATH=C:\apache-ant-1.8.2
 
 set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH%
diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat
index 1c2ba17..a195d72 100755
--- a/make/scripts/java-win64-dbg.bat
+++ b/make/scripts/java-win64-dbg.bat
@@ -1,7 +1,7 @@
 
 set BLD_SUB=build-win64
-set J2RE_HOME=c:\jre1.6.0_26_x64
-set JAVA_HOME=c:\jdk1.6.0_26_x64
+set J2RE_HOME=c:\jre1.6.0_29_x64
+set JAVA_HOME=c:\jdk1.6.0_29_x64
 set ANT_PATH=C:\apache-ant-1.8.2
 
 set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH%
diff --git a/make/scripts/java-win64.bat b/make/scripts/java-win64.bat
index 5e9af91..d7d3b6a 100755
--- a/make/scripts/java-win64.bat
+++ b/make/scripts/java-win64.bat
@@ -1,7 +1,7 @@
 
 set BLD_SUB=build-win64
-set J2RE_HOME=c:\jre1.6.0_26_x64
-set JAVA_HOME=c:\jdk1.6.0_26_x64
+set J2RE_HOME=c:\jre1.6.0_29_x64
+set JAVA_HOME=c:\jdk1.6.0_29_x64
 set ANT_PATH=C:\apache-ant-1.8.2
 
 set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH%
diff --git a/make/scripts/make.jogl.all.solaris-x86.sh b/make/scripts/make.jogl.all.solaris-x86.sh
new file mode 100755
index 0000000..a5b99e4
--- /dev/null
+++ b/make/scripts/make.jogl.all.solaris-x86.sh
@@ -0,0 +1,52 @@
+#! /bin/sh
+
+SDIR=`dirname $0` 
+
+if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86.sh ] ; then
+    . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86.sh
+fi
+
+if [ "$1" = "-libdir" ] ; then
+    shift
+    if [ -z "$1" ] ; then
+        echo libdir argument missing
+        print_usage
+        exit
+    fi
+    CUSTOMLIBDIR="-Dcustom.libdir=$1"
+    shift
+fi
+
+#    -Dc.compiler.debug=true \
+
+#    -Dgluegen.cpptasks.detected.os=true \
+#    -DisUnix=true \
+#    -DisLinux=true \
+#    -DisLinuxAMD64=true \
+#    -DisX11=true \
+
+#LD_LIBRARY_PATH=/opt-linux-x86/mesa-7.8.1/lib
+#export LD_LIBRARY_PATH
+
+LOGF=make.jogl.all.solaris-x86.log
+rm -f $LOGF
+
+# export LIBGL_DRIVERS_PATH=/usr/lib/fglrx/dri:/usr/lib32/fglrx/dri
+# export LIBGL_DEBUG=verbose
+echo LIBXCB_ALLOW_SLOPPY_LOCK: $LIBXCB_ALLOW_SLOPPY_LOCK 2>&1 | tee -a $LOGF
+echo LIBGL_DRIVERS_PATH: $LIBGL_DRIVERS_PATH 2>&1 | tee -a $LOGF
+echo LIBGL_DEBUG: $LIBGL_DEBUG 2>&1 | tee -a $LOGF
+
+#    -Dc.compiler.debug=true \
+#    -Djavacdebug="true" \
+#    -Djavacdebuglevel="source,lines,vars" \
+
+# BUILD_ARCHIVE=true \
+ant  \
+    $CUSTOMLIBDIR \
+    -Djavacdebuglevel="source,lines,vars" \
+    -Drootrel.build=build-solaris-x86 \
+    -Dsetup.addNativeOpenMAX=true \
+    -Dsetup.addNativeKD=true \
+    $* 2>&1 | tee -a $LOGF
+
diff --git a/make/scripts/make.jogl.all.solaris-x86_64.sh b/make/scripts/make.jogl.all.solaris-x86_64.sh
new file mode 100755
index 0000000..ff60319
--- /dev/null
+++ b/make/scripts/make.jogl.all.solaris-x86_64.sh
@@ -0,0 +1,52 @@
+#! /bin/sh
+
+SDIR=`dirname $0` 
+
+if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then
+    . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh
+fi
+
+if [ "$1" = "-libdir" ] ; then
+    shift
+    if [ -z "$1" ] ; then
+        echo libdir argument missing
+        print_usage
+        exit
+    fi
+    CUSTOMLIBDIR="-Dcustom.libdir=$1"
+    shift
+fi
+
+#    -Dc.compiler.debug=true \
+
+#    -Dgluegen.cpptasks.detected.os=true \
+#    -DisUnix=true \
+#    -DisLinux=true \
+#    -DisLinuxAMD64=true \
+#    -DisX11=true \
+
+#LD_LIBRARY_PATH=/opt-linux-x86_64/mesa-7.8.1/lib64
+#export LD_LIBRARY_PATH
+
+LOGF=make.jogl.all.solaris-x86_64.log
+rm -f $LOGF
+
+# export LIBGL_DRIVERS_PATH=/usr/lib/fglrx/dri:/usr/lib32/fglrx/dri
+# export LIBGL_DEBUG=verbose
+echo LIBXCB_ALLOW_SLOPPY_LOCK: $LIBXCB_ALLOW_SLOPPY_LOCK 2>&1 | tee -a $LOGF
+echo LIBGL_DRIVERS_PATH: $LIBGL_DRIVERS_PATH 2>&1 | tee -a $LOGF
+echo LIBGL_DEBUG: $LIBGL_DEBUG 2>&1 | tee -a $LOGF
+
+#    -Dc.compiler.debug=true \
+#    -Djavacdebug="true" \
+#    -Djavacdebuglevel="source,lines,vars" \
+
+# BUILD_ARCHIVE=true \
+ant  \
+    $CUSTOMLIBDIR \
+    -Djavacdebuglevel="source,lines,vars" \
+    -Drootrel.build=build-solaris-x86_64 \
+    -Dsetup.addNativeOpenMAX=true \
+    -Dsetup.addNativeKD=true \
+    $* 2>&1 | tee -a $LOGF
+
diff --git a/make/scripts/make.jogl.all.win32.bat b/make/scripts/make.jogl.all.win32.bat
index c9aac83..5094f1a 100755
--- a/make/scripts/make.jogl.all.win32.bat
+++ b/make/scripts/make.jogl.all.win32.bat
@@ -1,7 +1,7 @@
 set THISDIR="C:\JOGL"
 
-set J2RE_HOME=c:\jre1.6.0_26_x32
-set JAVA_HOME=c:\jdk1.6.0_26_x32
+set J2RE_HOME=c:\jre1.6.0_29_x32
+set JAVA_HOME=c:\jdk1.6.0_29_x32
 set ANT_PATH=C:\apache-ant-1.8.2
 
 set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH%
diff --git a/make/scripts/make.jogl.all.win64.bat b/make/scripts/make.jogl.all.win64.bat
index 5b1b10a..de98972 100755
--- a/make/scripts/make.jogl.all.win64.bat
+++ b/make/scripts/make.jogl.all.win64.bat
@@ -1,7 +1,7 @@
 set THISDIR="C:\JOGL"
 
-set J2RE_HOME=c:\jre1.6.0_26_x64
-set JAVA_HOME=c:\jdk1.6.0_26_x64
+set J2RE_HOME=c:\jre1.6.0_29_x64
+set JAVA_HOME=c:\jdk1.6.0_29_x64
 set ANT_PATH=C:\apache-ant-1.8.2
 
 set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw64\bin;c:\mingw\bin;%PATH%
diff --git a/make/scripts/setenv-jogl.sh b/make/scripts/setenv-jogl.sh
index e52c238..38fd8de 100755
--- a/make/scripts/setenv-jogl.sh
+++ b/make/scripts/setenv-jogl.sh
@@ -84,15 +84,21 @@ CP_SEP=:
 
 LIB=$THISDIR/lib
 
+JOGAMP_ALL_AWT_CLASSPATH=.:$GLUEGEN_JAR:$JOGL_ALL_AWT_CLASSPATH:$SWT_CLASSPATH:$JUNIT_JAR:$ANT_JARS
+JOGAMP_ALL_NOAWT_CLASSPATH=.:$GLUEGEN_JAR:$JOGL_ALL_NOAWT_CLASSPATH:$SWT_CLASSPATH:$JUNIT_JAR:$ANT_JARS
+JOGAMP_MOBILE_CLASSPATH=.:$GLUEGEN_JAR:$JOGL_MOBILE_CLASSPATH:$SWT_CLASSPATH:$JUNIT_JAR:$ANT_JARS
+export JOGAMP_ALL_AWT_CLASSPATH JOGAMP_ALL_NOAWT_CLASSPATH JOGAMP_MOBILE_CLASSPATH
+
 CLASSPATH=.:$GLUEGEN_JAR:$JOGL_CLASSPATH:$SWT_CLASSPATH:$JUNIT_JAR:$ANT_JARS
-for i in $LIB/*jar ; do
-    CLASSPATH=$CLASSPATH:$i
-done
 export CLASSPATH
+
 # We use TempJarCache per default now!
 #export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GLUEGEN_OS:$JOGL_LIB_DIR
 #export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$GLUEGEN_OS:$JOGL_LIB_DIR
 
+echo JOGAMP_ALL_AWT_CLASSPATH: $CLASSPATH
+echo JOGAMP_ALL_NOAWT_CLASSPATH: $CLASSPATH
+echo JOGAMP_MOBILE_CLASSPATH: $CLASSPATH
 echo CLASSPATH: $CLASSPATH
 echo
 echo MacOSX REMEMBER to add the JVM arguments "-XstartOnFirstThread -Djava.awt.headless=true" for running demos without AWT, e.g. NEWT
diff --git a/make/scripts/tests-armv7l_eabi.sh b/make/scripts/tests-armv7l_eabi.sh
index e7e3270..2ed3070 100755
--- a/make/scripts/tests-armv7l_eabi.sh
+++ b/make/scripts/tests-armv7l_eabi.sh
@@ -2,6 +2,6 @@
 
 spath=`dirname $0`
 
-. $spath/tests.sh  `which java` ../build-armv7l_eabi $*
+. $spath/tests.sh  `which java` -DummyArg ../build-armv7l_eabi $*
 
 
diff --git a/make/scripts/tests-javaws-x64.bat b/make/scripts/tests-javaws-x64.bat
index 23d01a2..1a67326 100755
--- a/make/scripts/tests-javaws-x64.bat
+++ b/make/scripts/tests-javaws-x64.bat
@@ -1,4 +1,4 @@
-set JRE_PATH=C:\jre1.6.0_26_x64\bin
+set JRE_PATH=C:\jre1.6.0_29_x64\bin
 set LOG_PATH=%USERPROFILE%\AppData\LocalLow\Sun\Java\Deployment\log
 
 %JRE_PATH%\javaws -uninstall
diff --git a/make/scripts/tests-osx-x64.sh b/make/scripts/tests-osx-x64.sh
new file mode 100755
index 0000000..e502668
--- /dev/null
+++ b/make/scripts/tests-osx-x64.sh
@@ -0,0 +1,7 @@
+#! /bin/bash
+
+spath=`dirname $0`
+
+. $spath/tests.sh  /usr/bin/java -d64 ../build-macosx $*
+
+
diff --git a/make/scripts/tests-osx.sh b/make/scripts/tests-osx.sh
deleted file mode 100755
index c6e8336..0000000
--- a/make/scripts/tests-osx.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#! /bin/bash
-
-spath=`dirname $0`
-
-. $spath/tests.sh  /usr/bin/java ../build-macosx $*
-
-
diff --git a/make/scripts/tests-x32.sh b/make/scripts/tests-solx32.sh
similarity index 75%
copy from make/scripts/tests-x32.sh
copy to make/scripts/tests-solx32.sh
index 8ac1dc5..996dcc6 100755
--- a/make/scripts/tests-x32.sh
+++ b/make/scripts/tests-solx32.sh
@@ -6,6 +6,5 @@ if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86.sh ] ; then
     . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86.sh
 fi
 
-. $SDIR/tests.sh  `which java` ../build-x86 $*
-
+. $SDIR/tests.sh  `which java` -d32 ../build-solaris-x86 $*
 
diff --git a/make/scripts/tests-x64.sh b/make/scripts/tests-solx64.sh
similarity index 75%
copy from make/scripts/tests-x64.sh
copy to make/scripts/tests-solx64.sh
index 1816f59..3500f1b 100755
--- a/make/scripts/tests-x64.sh
+++ b/make/scripts/tests-solx64.sh
@@ -6,5 +6,5 @@ if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then
     . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh
 fi
 
-. $SDIR/tests.sh  `which java` ../build-x86_64 $*
+. $SDIR/tests.sh  `which java` -d64 ../build-solaris-x86_64 $*
 
diff --git a/make/scripts/tests-x32.bat b/make/scripts/tests-x32.bat
index e7126d1..0caa0ef 100755
--- a/make/scripts/tests-x32.bat
+++ b/make/scripts/tests-x32.bat
@@ -18,7 +18,7 @@ REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01
 REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated
 REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT
 REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot
-REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot
+scripts\java-win32.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot
 REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.nativewindow.TestRecursiveToolkitLockCORE
 REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT -time 100000
 
@@ -41,5 +41,6 @@ REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAWT0
 REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $*
 REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $*
 
-scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01
+REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01
 REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.glsl.TestFBOMRTNEWT01
+
diff --git a/make/scripts/tests-x32.sh b/make/scripts/tests-x32.sh
index 8ac1dc5..a3aed84 100755
--- a/make/scripts/tests-x32.sh
+++ b/make/scripts/tests-x32.sh
@@ -6,6 +6,6 @@ if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86.sh ] ; then
     . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86.sh
 fi
 
-. $SDIR/tests.sh  `which java` ../build-x86 $*
+. $SDIR/tests.sh  `which java` -d32 ../build-x86 $*
 
 
diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat
index fe513da..308da58 100755
--- a/make/scripts/tests-x64.bat
+++ b/make/scripts/tests-x64.bat
@@ -6,6 +6,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GL
 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.awt.TestSwingAWT01GLn
 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT -time 5000
 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT -time 5000
+REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 %1 %2 %3 %4 %5
 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT %1 %2 %3 %4 %5 %6
 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT
 
@@ -24,16 +25,18 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestParenting01
 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %1 %2 %3 %4 %5 %6
 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT -time 50000
 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT
-scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %1 %2 %3 %4 %5 %6
+REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %1 %2 %3 %4 %5 %6
 
 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT
 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT
 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated
 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT
-REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot
-REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot %1 %2 %3 %4 %5 %6
+REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot %1 %2 %3 %4 %5 %6
+REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot %1 %2 %3 %4 %5 %6
 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.nativewindow.TestRecursiveToolkitLockCORE
 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT -time 100000
+REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %1 %2 %3
+REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01AWT %1 %2 %3
 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03bAWT -time 100000
 
 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot
@@ -79,6 +82,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDeb
 
 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $*
 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $*
+scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT
 
 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01
 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.glsl.TestFBOMRTNEWT01
diff --git a/make/scripts/tests-x64.sh b/make/scripts/tests-x64.sh
index 1816f59..ba70489 100755
--- a/make/scripts/tests-x64.sh
+++ b/make/scripts/tests-x64.sh
@@ -6,5 +6,5 @@ if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then
     . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh
 fi
 
-. $SDIR/tests.sh  `which java` ../build-x86_64 $*
+. $SDIR/tests.sh  `which java` -d64 ../build-x86_64 $*
 
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 69068a2..f8205b6 100755
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -1,12 +1,14 @@
 #! /bin/bash
 
-if [ -z "$1" -o -z "$2" ] ; then
-    echo Usage $0 java-exe build-dir
+if [ -z "$1" -o -z "$2" -o -z "$3" ] ; then
+    echo Usage $0 java-exe java-xargs build-dir
     exit 0
 fi
 
 javaexe=$1
 shift
+javaxargs=$1
+shift
 bdir=$1
 shift
 
@@ -24,6 +26,7 @@ rm -f java-run.log
 spath=`dirname $0`
 
 . $spath/setenv-jogl.sh $bdir JOGL_ALL
+unset CLASSPATH
 
 MOSX=0
 MOSX_MT=0
@@ -38,32 +41,39 @@ echo LIBXCB_ALLOW_SLOPPY_LOCK: $LIBXCB_ALLOW_SLOPPY_LOCK 2>&1 | tee -a java-run.
 echo LIBGL_DRIVERS_PATH: $LIBGL_DRIVERS_PATH 2>&1 | tee -a java-run.log
 echo LIBGL_DEBUG: $LIBGL_DEBUG 2>&1 | tee -a java-run.log
 echo SWT_CLASSPATH: $SWT_CLASSPATH 2>&1 | tee -a java-run.log
-echo $javaexe $X_ARGS $D_ARGS $* 2>&1 | tee -a java-run.log
-echo CLASSPATH $CLASSPATH 2>&1 | tee -a java-run.log
+echo $javaexe $javaxargs $X_ARGS $D_ARGS $* 2>&1 | tee -a java-run.log
 echo MacOsX $MOSX
 
 function jrun() {
     awton=$1
     shift
+    swton=$1
+    shift
 
     #D_ARGS="-Djogl.debug.ExtensionAvailabilityCache -Djogl.debug=all -Dnativewindow.debug=all -Djogamp.debug.ProcAddressHelper=true -Djogamp.debug.NativeLibrary=true -Djogamp.debug.NativeLibrary.Lookup=true"
+    #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all"
+    #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all"
+    #D_ARGS="-Dnewt.debug.MainThread"
     #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all"
     #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.ExtensionAvailabilityCache"
     #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable"
     #D_ARGS="-Djogl.debug.GLProfile"
     # D_ARGS="-Dnewt.debug.EDT -Dnativewindow.debug.ToolkitLock.TraceLock -Dnativewindow.debug.NativeWindow"
+    #D_ARGS="-Dnativewindow.debug.NativeWindow"
     #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT"
     #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Window -Djogl.debug.GLContext"
     #D_ARGS="-Dnativewindow.debug.ToolkitLock.TraceLock -Dnativewindow.debug.X11Util.TraceDisplayLifecycle=true -Dnativewindow.debug.X11Util"
     #D_ARGS="-Dnativewindow.debug.X11Util -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnewt.debug=all"
-    #D_ARGS="-Dnativewindow.debug.X11Util"
+    #D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext"
     #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock"
     #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=1000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock"
+    #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock -Dnativewindow.debug.ToolkitLock.TraceLock"
+    #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Dnativewindow.debug.X11Util"
     #D_ARGS="-Dnewt.debug.EDT -Djogamp.common.utils.locks.Lock.timeout=600000 -Djogl.debug.Animator -Dnewt.debug.Display -Dnewt.debug.Screen"
     #D_ARGS="-Dnewt.debug.Window -Djogamp.common.utils.locks.Lock.timeout=600000 -Djogl.debug.Animator"
     #D_ARGS="-Djogl.debug.Animator -Dnewt.debug=all"
     #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Display -Dnativewindow.debug.X11Util -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas"
-    #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all"
+    #D_ARGS="-Djogl.debug.GLContext"
     #D_ARGS="-Djogl.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser"
     #D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.EDT -Djogamp.debug.Lock"
     #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GraphicsConfiguration"
@@ -72,7 +82,8 @@ function jrun() {
     #D_ARGS="-Djogl.debug=all -Dnewt.debug=all"
     #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext"
     #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen"
-    #D_ARGS="-Dnewt.debug.Window"
+    #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.KeyEvent"
+    #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all"
     #D_ARGS="-Xprof"
     #D_ARGS="-Djogl.debug.Animator"
     #D_ARGS="-Dnativewindow.debug=all"
@@ -106,42 +117,48 @@ function jrun() {
     #X_ARGS="-verbose:jni"
 
     if [ $awton -eq 1 ] ; then
+        export CLASSPATH=$JOGAMP_ALL_AWT_CLASSPATH
+        echo CLASSPATH $CLASSPATH
         X_ARGS="-Djava.awt.headless=false"
     else
+        export CLASSPATH=$JOGAMP_ALL_NOAWT_CLASSPATH
+        echo CLASSPATH $CLASSPATH
         X_ARGS="-Djava.awt.headless=true"
     fi
     if [ $MOSX_MT -eq 1 ] ; then
         X_ARGS="-XstartOnFirstThread $X_ARGS"
-        C_ARG="com.jogamp.newt.util.MainThread"
+        if [ $swton -eq 0 ] ; then
+            C_ARG="com.jogamp.newt.util.MainThread"
+        fi
     fi
     echo
     echo "Test Start: $*"
     echo
     echo LD_LIBRARY_PATH $LD_LIBRARY_PATH
     echo
-    echo $javaexe $X_ARGS $D_ARGS $C_ARG $*
+    echo $javaexe $javaxargs $X_ARGS $D_ARGS $C_ARG $*
     #LD_LIBRARY_PATH=/usr/local/projects/Xorg.modular/build-x86_64/lib:$LD_LIBRARY_PATH \
     #LD_LIBRARY_PATH=/opt-linux-x86_64/x11lib-1.3:$LD_LIBRARY_PATH \
     #LD_LIBRARY_PATH=/opt-linux-x86_64/mesa-7.8.1/lib64:$LD_LIBRARY_PATH \
     #LIBGL_DRIVERS_PATH=/usr/lib/mesa:/usr/lib32/mesa \
     #LD_LIBRARY_PATH=/usr/lib/mesa:/usr/lib32/mesa:$LD_LIBRARY_PATH \
-    $javaexe $X_ARGS $D_ARGS $C_ARG $*
+    $javaexe $javaxargs $X_ARGS $D_ARGS $C_ARG $*
     echo
     echo "Test End: $*"
     echo
 }
 
 function testnoawt() {
-    jrun 0 $* 2>&1 | tee -a java-run.log
+    jrun 0 0 $* 2>&1 | tee -a java-run.log
 }
 
 function testawt() {
     MOSX_MT=0
-    jrun 1 $* 2>&1 | tee -a java-run.log
+    jrun 1 0 $* 2>&1 | tee -a java-run.log
 }
 
-function testawtmt() {
-    jrun 1 $* 2>&1 | tee -a java-run.log
+function testswt() {
+    jrun 0 1 $* 2>&1 | tee -a java-run.log
 }
 
 #
@@ -153,13 +170,18 @@ function testawtmt() {
 #testnoawt com.jogamp.newt.opengl.GLWindow $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownSharedNEWT $*
+testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $*
-#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $*
 #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteWindow01NEWT $*
 #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteGLWindows01NEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $*
@@ -167,7 +189,7 @@ function testawtmt() {
 #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $*
-testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $*
 #testnoawt com.jogamp.opengl.test.junit.newt.TestWindows01NEWT $*
 #testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $*
 #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $*
@@ -184,38 +206,46 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT
 #testnoawt com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT
 #testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $*
 #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT
-#testnoawt com.jogamp.opengl.test.junit.jogl.swt.TestSWT01GLn $*
-#testnoawt com.jogamp.opengl.test.junit.jogl.swt.TestSWT02GLn $*
-
 
 #
 # awt (testawt)
 #
 #testawt jogamp.newt.awt.opengl.VersionApplet $*
 #testawt javax.media.opengl.awt.GLCanvas $*
+#testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $*
 #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $*
 #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 $*
+#testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownSharedAWT $*
 #testawt com.jogamp.opengl.test.junit.jogl.awt.TestSwingAWT01GLn
 #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT03GLCanvasRecreate01 $*
 #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT02WindowClosing
 #testawt com.jogamp.opengl.test.junit.jogl.awt.text.TestAWTTextRendererUseVertexArrayBug464
 #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $*
 #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $*
 #testawt com.jogamp.opengl.test.junit.jogl.texture.TestTexture01AWT
-#testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleAWT
 #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461OffscreenSupersamplingSwingAWT
 #testawt com.jogamp.opengl.test.junit.jogl.texture.TestGrayTextureFromFileAWTBug417
 #testawt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAWT01GLn $*
 #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug463ScaleImageMemoryAWT $*
 
 #
+# swt (testswt)
+#
+#testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWT01GLn $*
+#testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWT02GLn $*
+
+#
 # newt.awt (testawt)
 #
 #testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411
 #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper
 #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug
 #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $*
-#testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot
+#testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $*
 #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT
 #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $*
 #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $*
@@ -223,11 +253,15 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT
 #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $*
 #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02AWT $*
 #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT $*
-#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT $*
-#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting03bAWT $*
+#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $*
+#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01GLCanvasAWT $*
+#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer02NewtCanvasAWT $*
+#testawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT $*
 #testawt com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT
 #testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleAWT $*
 #testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleNEWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyAWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT $*
 #testawt com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT
 
 #testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT $*
@@ -258,6 +292,11 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT
 #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $*
 
 #
+# osx bugs
+#
+#testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $*
+
+#
 # regressions
 #
 
diff --git a/make/stub_includes/cg/CG/cg.h b/make/stub_includes/cg/Cg/cg.h
similarity index 99%
rename from make/stub_includes/cg/CG/cg.h
rename to make/stub_includes/cg/Cg/cg.h
index ef045de..b40f0ee 100644
--- a/make/stub_includes/cg/CG/cg.h
+++ b/make/stub_includes/cg/Cg/cg.h
@@ -117,7 +117,7 @@ typedef enum
 // # define CG_DATATYPE_MACRO(name, compiler_name, enum_name, base_name, ncols, nrows, pc) \
 //   enum_name ,
 
-#include <CG/cg_datatypes.h>
+#include <Cg/cg_datatypes.h>
 
  } CGtype;
 
@@ -127,7 +127,7 @@ typedef enum
 //                                enum_int,addressable,param_type) \
 //   enum_name = enum_int,
 
-#include <CG/cg_bindlocations.h>
+#include <Cg/cg_bindlocations.h>
 
   CG_UNDEFINED,
 
@@ -141,7 +141,7 @@ typedef enum
 // # define CG_PROFILE_MACRO(name, compiler_id, compiler_id_caps, compiler_opt,int_id,vertex_profile) \
 //    CG_PROFILE_##compiler_id_caps = int_id,
   
-#include <CG/cg_profiles.h>
+#include <Cg/cg_profiles.h>
 
   CG_PROFILE_MAX = 7100,
  } CGprofile;
@@ -150,7 +150,7 @@ typedef enum
  {
 // # define CG_ERROR_MACRO(code, enum_name, message) \
 //    enum_name = code,
-# include <CG/cg_errors.h>
+# include <Cg/cg_errors.h>
  } CGerror;
 
 typedef enum
@@ -171,7 +171,7 @@ typedef enum
  {
 // # define CG_ENUM_MACRO(enum_name, enum_val) \
 //    enum_name = enum_val,
-# include <CG/cg_enums.h>
+# include <Cg/cg_enums.h>
  } CGenum;
 
 #include <stdarg.h>
diff --git a/make/stub_includes/cg/CG/cgGL.h b/make/stub_includes/cg/Cg/cgGL.h
similarity index 99%
rename from make/stub_includes/cg/CG/cgGL.h
rename to make/stub_includes/cg/Cg/cgGL.h
index f66ec06..d9595f3 100644
--- a/make/stub_includes/cg/CG/cgGL.h
+++ b/make/stub_includes/cg/Cg/cgGL.h
@@ -54,7 +54,7 @@
 
 
 
-#include <CG/cg.h>
+#include <Cg/cg.h>
 
 /* Set up for either Win32 import/export/lib. */
 #ifndef CGGLDLL_API
diff --git a/make/stub_includes/cg/CG/cgGL_profiles.h b/make/stub_includes/cg/Cg/cgGL_profiles.h
similarity index 100%
rename from make/stub_includes/cg/CG/cgGL_profiles.h
rename to make/stub_includes/cg/Cg/cgGL_profiles.h
diff --git a/make/stub_includes/cg/CG/cg_bindlocations.h b/make/stub_includes/cg/Cg/cg_bindlocations.h
similarity index 100%
rename from make/stub_includes/cg/CG/cg_bindlocations.h
rename to make/stub_includes/cg/Cg/cg_bindlocations.h
diff --git a/make/stub_includes/cg/CG/cg_datatypes.h b/make/stub_includes/cg/Cg/cg_datatypes.h
similarity index 100%
rename from make/stub_includes/cg/CG/cg_datatypes.h
rename to make/stub_includes/cg/Cg/cg_datatypes.h
diff --git a/make/stub_includes/cg/CG/cg_enums.h b/make/stub_includes/cg/Cg/cg_enums.h
similarity index 100%
rename from make/stub_includes/cg/CG/cg_enums.h
rename to make/stub_includes/cg/Cg/cg_enums.h
diff --git a/make/stub_includes/cg/CG/cg_errors.h b/make/stub_includes/cg/Cg/cg_errors.h
similarity index 100%
rename from make/stub_includes/cg/CG/cg_errors.h
rename to make/stub_includes/cg/Cg/cg_errors.h
diff --git a/make/stub_includes/cg/CG/cg_profiles.h b/make/stub_includes/cg/Cg/cg_profiles.h
similarity index 99%
rename from make/stub_includes/cg/CG/cg_profiles.h
rename to make/stub_includes/cg/Cg/cg_profiles.h
index 8217a56..3c3e68f 100644
--- a/make/stub_includes/cg/CG/cg_profiles.h
+++ b/make/stub_includes/cg/Cg/cg_profiles.h
@@ -78,7 +78,7 @@
 
 #define CG_IN_PROFILES_INCLUDE
 
-#include <CG/cgGL_profiles.h>
+#include <Cg/cgGL_profiles.h>
 
 
 /*CG_PROFILE_MACRO(DX9Vertex11,vs_1_1,*/CG_PROFILE_VS_1_1=/*,"vs_1_1",*/6153,//1)
diff --git a/make/stub_includes/jni/macosx/jawt_md.h b/make/stub_includes/jni/macosx/jawt_md.h
index aca47f6..3a371af 100644
--- a/make/stub_includes/jni/macosx/jawt_md.h
+++ b/make/stub_includes/jni/macosx/jawt_md.h
@@ -9,17 +9,35 @@
 
 #include <jawt.h>
 #include <AppKit/NSView.h>
+#include <QuartzCore/CALayer.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+/** 
+ * JAWT_DrawingSurfaceInfo.getPlatformInfo()
+ *
+ * Only if not JAWT_SurfaceLayers, see below!
+ */
 typedef struct JAWT_MacOSXDrawingSurfaceInfo
 {
-    NSView *cocoaViewRef; // the view is guaranteed to be valid only for the duration of Component.paint method
+    /** the view is guaranteed to be valid only for the duration of Component.paint method */
+    NSView *cocoaViewRef; 
 }
 JAWT_MacOSXDrawingSurfaceInfo;
 
+/** 
+ * JAWT_DrawingSurfaceInfo.getPlatformInfo()
+ *
+ * >= 10.6.4 if JAWT_MACOSX_USE_CALAYER is set in JAWT version
+ */
+typedef struct JAWT_SurfaceLayers
+{
+    CALayer *layer;
+}
+JAWT_SurfaceLayers;
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/make/stub_includes/macosx/AppKit/NSOpenGL.h b/make/stub_includes/macosx/AppKit/NSOpenGL.h
new file mode 100644
index 0000000..1b7656d
--- /dev/null
+++ b/make/stub_includes/macosx/AppKit/NSOpenGL.h
@@ -0,0 +1,3 @@
+typedef struct _NSOpenGLPixelFormat NSOpenGLPixelFormat;
+typedef struct _NSOpenGLContext NSOpenGLContext;
+typedef struct _NSOpenGLPixelBuffer NSOpenGLPixelBuffer;
diff --git a/make/stub_includes/macosx/AppKit/NSOpenGLLayer.h b/make/stub_includes/macosx/AppKit/NSOpenGLLayer.h
new file mode 100644
index 0000000..2e5e81a
--- /dev/null
+++ b/make/stub_includes/macosx/AppKit/NSOpenGLLayer.h
@@ -0,0 +1 @@
+typedef struct _NSOpenGLLayer NSOpenGLLayer;
diff --git a/make/stub_includes/macosx/AppKit/NSOpenGLView.h b/make/stub_includes/macosx/AppKit/NSOpenGLView.h
new file mode 100644
index 0000000..6492287
--- /dev/null
+++ b/make/stub_includes/macosx/AppKit/NSOpenGLView.h
@@ -0,0 +1 @@
+typedef struct _NSOpenGLView NSOpenGLView;
diff --git a/make/stub_includes/macosx/OpenGL/CGLDevice.h b/make/stub_includes/macosx/OpenGL/CGLDevice.h
new file mode 100644
index 0000000..1d41709
--- /dev/null
+++ b/make/stub_includes/macosx/OpenGL/CGLDevice.h
@@ -0,0 +1,2 @@
+typedef struct _cglShareGroupObj*  CGLShareGroupObj;
+
diff --git a/make/stub_includes/macosx/OpenGL/OpenGL.h b/make/stub_includes/macosx/OpenGL/OpenGL.h
index e6f3030..3347209 100644
--- a/make/stub_includes/macosx/OpenGL/OpenGL.h
+++ b/make/stub_includes/macosx/OpenGL/OpenGL.h
@@ -2,10 +2,13 @@
    OpenGL.h to expose portions of the low-level CGL API to Java */
 
 /* Typedefs to get things working */
-typedef struct _cglObj* CGLContextObj;
-typedef struct _cglObj* CGLShareGroupObj;
-typedef struct _cglObj* CGLPBufferObj;
-typedef struct _cglObj* CGLPixelFormatObj;
+typedef struct _cglContextObj*     CGLContextObj;
+typedef struct _cglPBufferObj*     CGLPBufferObj;
+typedef struct _cglPixelFormatObj* CGLPixelFormatObj;
+
+typedef int             GLint;          /* 4-byte signed */
+typedef unsigned int    GLenum;
+typedef int             GLsizei;        /* 4-byte signed */
 
 /*
 ** Attribute names for CGLChoosePixelFormat and CGLDescribePixelFormat.
@@ -45,10 +48,20 @@ typedef enum _CGLPixelFormatAttribute {
 	kCGLPFACompliant          =  83,	/* renderer is opengl compliant                 */
 	kCGLPFADisplayMask        =  84,	/* mask limiting supported displays             */
 	kCGLPFAPBuffer            =  90,	/* can be used to render to a pbuffer           */
-        kCGLPFARemotePBuffer	  =  91,    /* can be used to render offline to a pbuffer	*/
+    kCGLPFARemotePBuffer	  =  91,    /* can be used to render offline to a pbuffer	*/
+    kCGLPFAAcceleratedCompute =  97,    /* hardware accelerated                         */
+    kCGLPFAOpenGLProfile      =  99,    /* OpenGL Profile                               */
 	kCGLPFAVirtualScreenCount = 128 	/* number of virtual screens in this format     */
 } CGLPixelFormatAttribute;
 
+/**
+ * OpenGL Profiles Values
+ */
+typedef enum _CGLOpenGLProfile {
+    kCGLOGLPVersion_Legacy   = 0x1000,      /* Legacy/Pre-OpenGL 3.0 */
+    kCGLOGLPVersion_3_2_Core = 0x3200       /* OpenGL 3.2 Core */
+} CGLOpenGLProfile;
+
 /*
 ** Error return values from CGLGetError.
 */
@@ -95,7 +108,7 @@ typedef enum _CGLContextParameter {
 /* Pixel format manipulation */
 CGLError CGLChoosePixelFormat(const CGLPixelFormatAttribute *attribs,
                               CGLPixelFormatObj *pix,
-                              long *npix);
+                              GLint *npix);
 CGLError CGLDestroyPixelFormat(CGLPixelFormatObj pix);
 CGLPixelFormatObj CGLGetPixelFormat ( CGLContextObj ctx );
 
@@ -105,6 +118,8 @@ CGLError CGLCreateContext(CGLPixelFormatObj pix,
                           CGLContextObj* ctx);
 void CGLReleaseContext(CGLContextObj ctx);
 CGLError CGLDestroyContext(CGLContextObj ctx);
+CGLError CGLLockContext (CGLContextObj ctx);
+CGLError CGLUnlockContext (CGLContextObj ctx);
 CGLError CGLSetCurrentContext(CGLContextObj ctx);
 CGLContextObj CGLGetCurrentContext (void);
 CGLError CGLFlushDrawable ( CGLContextObj ctx);
@@ -113,16 +128,16 @@ CGLError CGLCopyContext ( CGLContextObj src, CGLContextObj dst, int mask );
 
 CGLShareGroupObj CGLGetShareGroup(CGLContextObj ctx);
 
-/* PBuffer manipulation */
-CGLError CGLCreatePBuffer(long width,
-                          long height,
-                          unsigned long target,
-                          unsigned long internalFormat,
-                          long max_level,
+/* PBuffer manipulation (deprecated in 10.7) */
+CGLError CGLCreatePBuffer(GLsizei width,
+                          GLsizei height,
+                          GLenum target,
+                          GLenum internalFormat,
+                          GLint max_level,
                           CGLPBufferObj* pbuffer);
 CGLError CGLDestroyPBuffer(CGLPBufferObj pbuffer);
 CGLError CGLSetPBuffer(CGLContextObj ctx,
                        CGLPBufferObj pbuffer,
-                       unsigned long face,
-                       long level,
-                       long screen);
+                       GLenum face,
+                       GLint level,
+                       GLint screen);
diff --git a/make/stub_includes/macosx/QuartzCore/CALayer.h b/make/stub_includes/macosx/QuartzCore/CALayer.h
new file mode 100644
index 0000000..a5a6579
--- /dev/null
+++ b/make/stub_includes/macosx/QuartzCore/CALayer.h
@@ -0,0 +1 @@
+typedef struct _CALayer CALayer;
diff --git a/make/stub_includes/opengl/GL/glxext.h b/make/stub_includes/opengl/GL/glxext.h
index c6f2fea..06dbb27 100644
--- a/make/stub_includes/opengl/GL/glxext.h
+++ b/make/stub_includes/opengl/GL/glxext.h
@@ -408,38 +408,7 @@ typedef unsigned int GLXVideoDeviceNV;
 #ifndef GLEXT_64_TYPES_DEFINED
 /* This code block is duplicated in glxext.h, so must be protected */
 #define GLEXT_64_TYPES_DEFINED
-/* Define int32_t, int64_t, and uint64_t types for UST/MSC */
-/* (as used in the GLX_OML_sync_control extension). */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-#include <inttypes.h>
-#elif defined(__sun__)
-#include <inttypes.h>
-#if defined(__STDC__)
-#if defined(__arch64__)
-typedef long int int64_t;
-typedef unsigned long int uint64_t;
-#else
-typedef long long int int64_t;
-typedef unsigned long long int uint64_t;
-#endif /* __arch64__ */
-#endif /* __STDC__ */
-#elif defined( __VMS )
-#include <inttypes.h>
-#elif defined(__SCO__) || defined(__USLC__)
-#include <stdint.h>
-#elif defined(__UNIXOS2__) || defined(__SOL64__)
-typedef long int int32_t;
-typedef long long int int64_t;
-typedef unsigned long long int uint64_t;
-#elif defined(WIN32) && defined(__GNUC__)
-#include <stdint.h>
-#elif defined(_WIN32)
-typedef __int32 int32_t;
-typedef __int64 int64_t;
-typedef unsigned __int64 uint64_t;
-#else
-#include <inttypes.h>     /* Fallback option */
-#endif
+#include "gl-64bit-types.h"
 #endif
 
 #ifndef GLX_ARB_get_proc_address
diff --git a/make/stub_includes/opengl/cg.c b/make/stub_includes/opengl/cg.c
index 98c8242..688e80c 100644
--- a/make/stub_includes/opengl/cg.c
+++ b/make/stub_includes/opengl/cg.c
@@ -21,6 +21,6 @@ typedef double          GLdouble;       /* double precision float */
 typedef double          GLclampd;       /* double precision float in [0,1] */
 
 #define CGDLL_API 
-#include <CG/cgGL.h>
+#include <Cg/cgGL.h>
 
 
diff --git a/make/stub_includes/opengl/macosx-window-system.h b/make/stub_includes/opengl/macosx-window-system.h
index 18cf6c7..347de62 100644
--- a/make/stub_includes/opengl/macosx-window-system.h
+++ b/make/stub_includes/opengl/macosx-window-system.h
@@ -7,54 +7,63 @@
    compilation then the build fails.
 */
 
+#include <AppKit/NSView.h>
+#include <AppKit/NSOpenGL.h>
+#include <AppKit/NSOpenGLView.h>
+#include <AppKit/NSOpenGLLayer.h>
+#include <OpenGL/CGLDevice.h>
+#include <OpenGL/OpenGL.h>
+
 typedef int Bool;
 
 // CGL ..
-void CGLQueryPixelFormat(void* pixelFormat, int* iattrs, int niattrs, int* ivalues);
+void CGLQueryPixelFormat(CGLPixelFormatObj fmt, int* iattrs, int niattrs, int* ivalues);
 
 // NS ..
-void* createPixelFormat(int* iattrs, int niattrs, int* ivalues);
-void queryPixelFormat(void* pixelFormat, int* iattrs, int niattrs, int* ivalues);
-void deletePixelFormat(void* pixelFormat);
+NSOpenGLPixelFormat* createPixelFormat(int* iattrs, int niattrs, int* ivalues);
+void queryPixelFormat(NSOpenGLPixelFormat* fmt, int* iattrs, int niattrs, int* ivalues);
+void deletePixelFormat(NSOpenGLPixelFormat* fmt);
 
 // NS ..
-void *getCurrentContext(void);
-void *getNSView(void* nsContext);
+NSOpenGLContext* getCurrentContext(void);
+CGLContextObj getCGLContext(NSOpenGLContext* ctx);
+NSView* getNSView(NSOpenGLContext* ctx);
 
-void* createContext(void* shareContext,
-                    void* nsView,
-                    void* pixelFormat,
+NSOpenGLContext* createContext(NSOpenGLContext* shareContext,
+                    NSView* nsView,
+                    Bool isBackingLayerView,
+                    NSOpenGLPixelFormat* pixelFormat,
                     Bool opaque,
                     int* viewNotReady);
-void *getCGLContext(void* nsContext);
-Bool  makeCurrentContext(void* nsContext);
-Bool  clearCurrentContext(void *nsContext);
-Bool  deleteContext(void* nsContext);
-Bool  flushBuffer(void* nsContext);
-void  setContextOpacity(void* nsContext, int opacity);
-void  updateContext(void* nsContext);
-void  copyContext(void* destContext, void* srcContext, int mask);
-
-void* updateContextRegister(void* nsContext, void* nsView);
+Bool  makeCurrentContext(NSOpenGLContext* ctx);
+Bool  clearCurrentContext(NSOpenGLContext *ctx);
+Bool  deleteContext(NSOpenGLContext* ctx, Bool releaseOnMainThread);
+Bool  flushBuffer(NSOpenGLContext* ctx);
+void  setContextOpacity(NSOpenGLContext* ctx, int opacity);
+void  updateContext(NSOpenGLContext* ctx);
+void  copyContext(NSOpenGLContext* dest, NSOpenGLContext* src, int mask);
+
+void* updateContextRegister(NSOpenGLContext* ctx, NSView* view);
+Bool updateContextNeedsUpdate(void* updater);
 void  updateContextUnregister(void* updater);
 
-void* createPBuffer(int renderTarget, int internalFormat, int width, int height);
-Bool destroyPBuffer(void* pBuffer);
-void setContextPBuffer(void* nsContext, void* pBuffer);
-void setContextTextureImageToPBuffer(void* nsContext, void* pBuffer, int colorBuffer);
+NSOpenGLPixelBuffer* createPBuffer(int renderTarget, int internalFormat, int width, int height);
+Bool destroyPBuffer(NSOpenGLPixelBuffer* pBuffer);
+void setContextPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* pBuffer);
+void setContextTextureImageToPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* pBuffer, GLenum colorBuffer);
+
+// NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSView* view, Bool opaque);
+NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSOpenGLPixelBuffer* pbuffer, Bool opaque, int texWidth, int texHeight);
+void setNSOpenGLLayerSwapInterval(NSOpenGLLayer* layer, int interval);
+void waitUntilNSOpenGLLayerIsReady(NSOpenGLLayer* layer, long to_ms);
+void setNSOpenGLLayerNeedsDisplay(NSOpenGLLayer* glLayer);
+void releaseNSOpenGLLayer(NSOpenGLLayer *glLayer);
 
 void* getProcAddress(const char *procName);
 
-void setSwapInterval(void* nsContext, int interval);
+void setSwapInterval(NSOpenGLContext* ctx, int interval);
 
 /* Gamma-related functionality */
 Bool setGammaRamp(int tableSize, float* redRamp, float* greenRamp, float* blueRamp);
 void resetGammaRamp();
 
-/****************************************************************************************/
-/* Java2D/JOGL bridge support; need to be able to create pbuffers and
-   contexts using the CGL APIs to be able to share textures, etc. with
-   contexts created by Java2D/JOGL bridge, which are CGLContextObjs */
-
-/* Pick up copies of CGL signatures from Mac OS X stub_includes/window-system-build directory */
-#include <OpenGL/OpenGL.h>
diff --git a/make/stub_includes/win32/wingdi.h b/make/stub_includes/win32/wingdi.h
index 23ac428..b02512c 100644
--- a/make/stub_includes/win32/wingdi.h
+++ b/make/stub_includes/win32/wingdi.h
@@ -195,6 +195,8 @@ WINUSERAPI HWND WINAPI WindowFromDC(HDC hDC); // avail in >= Win2k
 WINUSERAPI BOOL WINAPI GetClientRect(HWND hwnd, LPRECT lpRect);
 WINUSERAPI BOOL WINAPI DestroyWindow(HWND hWnd);
 WINUSERAPI DWORD WINAPI GetObjectType(HGDIOBJ h);
+WINUSERAPI BOOL WINAPI IsWindowVisible(HWND hWnd);
+WINUSERAPI BOOL WINAPI IsWindow(HWND hWnd);
 
 WINUSERAPI HANDLE WINAPI GetCurrentProcess(void);
 WINUSERAPI BOOL WINAPI GetProcessAffinityMask(HANDLE hProcess,PDWORD_PTR lpProcessAffinityMask,PDWORD_PTR lpSystemAffinityMask);
diff --git a/nbproject/.gitignore b/nbproject/.gitignore
new file mode 100644
index 0000000..3e18ebf
--- /dev/null
+++ b/nbproject/.gitignore
@@ -0,0 +1 @@
+private
diff --git a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java
index d162f2b..8cb2517 100644
--- a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java
+++ b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java
@@ -70,7 +70,7 @@ public class JoglVersion extends JogampVersion {
 
     public static StringBuilder getGLInfo(GL gl, StringBuilder sb) {
         AbstractGraphicsDevice device = gl.getContext().getGLDrawable().getNativeSurface()
-                                            .getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice();
+                                            .getGraphicsConfiguration().getScreen().getDevice();
         if(null==sb) {
             sb = new StringBuilder();
         }
diff --git a/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java b/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java
index 9e4d768..ba159b8 100644
--- a/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java
+++ b/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java
@@ -28,12 +28,30 @@
  
 package com.jogamp.opengl.cg;
 
+import com.jogamp.common.jvm.JNILibLoaderBase;
 import com.jogamp.common.os.DynamicLibraryBundleInfo;
+import com.jogamp.common.os.Platform;
+import com.jogamp.common.util.cache.TempJarCache;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.*;
 
 public class CgDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo {
     private static List<String> glueLibNames;
     static {
+        AccessController.doPrivileged(new PrivilegedAction<Object>() {
+            public Object run() {
+                Platform.initSingleton();
+                
+                if(TempJarCache.isInitialized()) {
+                   // Cg class and natives are available in their single atomic JAR files only 
+                   JNILibLoaderBase.addNativeJarLibs(CgDynamicLibraryBundleInfo.class, "jogl_cg", null);
+                }
+                return null;
+            }
+        });
+        
         glueLibNames = new ArrayList<String>();
         // glueLibNames.addAll(getGlueLibNamesPreload());
         glueLibNames.add("jogl_cg");
diff --git a/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java b/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java
index 93b75e7..26d2996 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java
@@ -164,7 +164,7 @@ class AWTAnimatorImpl implements AnimatorBase.AnimatorImpl {
             }
         };
 
-    public boolean skipWaitForCompletion(Thread thread) {
-        return ((Thread.currentThread() == thread) || EventQueue.isDispatchThread());
+    public boolean blockUntilDone(Thread thread) {
+        return ((Thread.currentThread() != thread) && !EventQueue.isDispatchThread());
     }
 }
diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java
index 16aac95..a902388 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java
@@ -59,7 +59,9 @@ import javax.media.opengl.GLAutoDrawable;
 */
 
 public class Animator extends AnimatorBase {
-
+    /** timeout in milliseconds, 15 frames @ 60Hz = 240ms, limiting {@link #finishLifecycleAction(Condition)} */
+    private static final long TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION = 15*16;
+    
     protected ThreadGroup threadGroup;
     private Runnable runnable;
     private boolean runAsFastAsPossible;
@@ -241,16 +243,20 @@ public class Animator extends AnimatorBase {
         // dependencies on the Animator's internal thread. Currently we
         // use a couple of heuristics to determine whether we should do
         // the blocking wait().
-        boolean doWait = !impl.skipWaitForCompletion(animThread);
-        if (doWait) {
-            while (condition.result()) {
-                try {
-                    wait();
-                } catch (InterruptedException ie) {  }
-            }
+        long remaining = impl.blockUntilDone(animThread) ? TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION : 0;
+        while (remaining>0 && condition.result()) {
+            long td = System.currentTimeMillis();
+            try {
+                wait(remaining);
+            } catch (InterruptedException ie) {  }
+            remaining -= (System.currentTimeMillis() - td) ;
         }
         if(DEBUG) {
-            System.err.println("finishLifecycleAction(" + condition.getClass().getName() + "): finished - waited " + doWait +
+            if(remaining<0) {
+                System.err.println("finishLifecycleAction(" + condition.getClass().getName() + "): ++++++ timeout reached ++++++ ");
+            }
+            System.err.println("finishLifecycleAction(" + condition.getClass().getName() + "): finished "+
+                    "- waited " + (TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION-remaining) + "/" + TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION + 
                     ", started: " + isStartedImpl() +", animating: " + isAnimatingImpl() +
                     ", paused: " + isPausedImpl() + ", drawables " + drawables.size());
         }
diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java
index e84a9bf..9bea27f 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java
@@ -56,7 +56,7 @@ public abstract class AnimatorBase implements GLAnimatorControl {
 
     public interface AnimatorImpl {
         void display(ArrayList<GLAutoDrawable> drawables, boolean ignoreExceptions, boolean printExceptions);
-        boolean skipWaitForCompletion(Thread thread);
+        boolean blockUntilDone(Thread thread);
     }
 
     protected ArrayList<GLAutoDrawable> drawables = new ArrayList<GLAutoDrawable>();
@@ -101,7 +101,7 @@ public abstract class AnimatorBase implements GLAnimatorControl {
         if(paused) {
             resume();
         }
-        if(!impl.skipWaitForCompletion(animThread)) {
+        if(impl.blockUntilDone(animThread)) {
             while(isStarted() && !isPaused() && !isAnimating()) {
                 try {
                     wait();
@@ -123,7 +123,7 @@ public abstract class AnimatorBase implements GLAnimatorControl {
         if(paused) {
             resume();
         }
-        if(!impl.skipWaitForCompletion(animThread)) {
+        if(impl.blockUntilDone(animThread)) {
             while(isStarted() && drawablesEmpty && isAnimating()) {
                 try {
                     wait();
diff --git a/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java b/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java
index bad268f..23b0845 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java
@@ -60,7 +60,7 @@ class DefaultAnimatorImpl implements AnimatorBase.AnimatorImpl {
         }
     }
 
-    public boolean skipWaitForCompletion(Thread thread) {
-        return (Thread.currentThread() == thread);
+    public boolean blockUntilDone(Thread thread) {
+        return (Thread.currentThread() != thread);
     }
 }
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java
index 99500ad..a61fe0d 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java
@@ -217,11 +217,11 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
     }
   }
 
-  public void padding(int done) {
+  public void padding(int doneInByteSize) {
     if ( buffer==null || sealed ) return;
-    while(done<strideL) {
+    while(doneInByteSize<strideB) {
         Buffers.putb(buffer, (byte)0);
-        done++;
+        doneInByteSize++;
     }
   }
 
@@ -233,9 +233,10 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
    */
   public void put(Buffer v) {
     if ( sealed ) return;
+    /** FIXME: isn't true for interleaved arrays !
     if(0!=(v.remaining() % strideL)) {
         throw new GLException("Buffer length ("+v.remaining()+") is not a multiple of component-stride:\n\t"+this);
-    }
+    } */
     growBufferIfNecessary(v.remaining());
     Buffers.put(buffer, v);
   }
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataEditable.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataEditable.java
index 0da7d11..bb22a4b 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataEditable.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataEditable.java
@@ -96,7 +96,7 @@ public interface GLArrayDataEditable extends GLArrayData {
     public void seal(boolean seal);
 
     public void rewind();
-    public void padding(int done);
+    public void padding(int doneInByteSize);
     public void put(Buffer v);
     public void putb(byte v);
     public void puts(short v);
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
index d3bb2e3..8d9d839 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
@@ -16,6 +16,7 @@ import jogamp.opengl.util.GLFixedArrayHandler;
 import jogamp.opengl.util.GLFixedArrayHandlerFlat;
 import jogamp.opengl.util.glsl.GLSLArrayHandler;
 import jogamp.opengl.util.glsl.GLSLArrayHandlerFlat;
+import jogamp.opengl.util.glsl.GLSLArrayHandlerInterleaved;
 
 
 public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataEditable {
@@ -224,15 +225,14 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
       if(usesGLSL) {
           throw new GLException("buffer uses GLSL");          
       }
-      GLArrayDataWrapper ad = GLArrayDataWrapper.createFixed(
+      final GLArrayDataWrapper ad = GLArrayDataWrapper.createFixed(
               index, comps, getComponentType(), 
               getNormalized(), getStride(), getBuffer(), 
               getVBOName(), interleavedOffset, getVBOUsage(), vboTarget);
       ad.setVBOEnabled(isVBO());
       interleavedOffset += comps * getComponentSizeInBytes();
       if(GL.GL_ARRAY_BUFFER == vboTarget) { 
-          GLArrayHandler handler = new GLFixedArrayHandlerFlat(ad);
-          glArrayHandler.addSubHandler(handler);
+          glArrayHandler.addSubHandler(new GLFixedArrayHandlerFlat(ad));
       }
       return ad;
   }
@@ -253,7 +253,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
     throws GLException
   {
     GLArrayDataServer ads = new GLArrayDataServer();
-    GLArrayHandler glArrayHandler = new GLArrayHandlerInterleaved(ads);
+    GLArrayHandler glArrayHandler = new GLSLArrayHandlerInterleaved(ads);
     ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, comps, dataType, false, 0, null, initialSize, false, glArrayHandler,
              0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true);
     return ads;
@@ -280,15 +280,14 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
       if(!usesGLSL) {
           throw new GLException("buffer uses fixed function");          
       }
-      GLArrayDataWrapper ad = GLArrayDataWrapper.createGLSL(
+      final GLArrayDataWrapper ad = GLArrayDataWrapper.createGLSL(
               name, comps, getComponentType(), 
               getNormalized(), getStride(), getBuffer(), 
               getVBOName(), interleavedOffset, getVBOUsage(), vboTarget);     
       ad.setVBOEnabled(isVBO());
       interleavedOffset += comps * getComponentSizeInBytes();
       if(GL.GL_ARRAY_BUFFER == vboTarget) { 
-          GLArrayHandler handler = new GLSLArrayHandlerFlat(ad);
-          glArrayHandler.addSubHandler(handler);
+          glArrayHandler.addSubHandler(new GLSLArrayHandlerFlat(ad));
       }
       return ad;
   }
@@ -371,6 +370,9 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
         int[] tmp = new int[1];
         gl.glGenBuffers(1, tmp, 0);
         vboName = tmp[0];
+        if(0 < interleavedOffset) {
+            glArrayHandler.setSubArrayVBOName(vboName);
+        }
     }
   }
   
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java b/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java
index f2e742c..4ab6035 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java
@@ -49,9 +49,8 @@ import java.nio.*;
 
 /**
  * Utility routines for dealing with direct buffers.
- * @author Kenneth Russel
- * @author Sven Gothel
- * @author Michael Bien
+ * 
+ * @author Kenneth Russel, et.al.
  */
 public class GLBuffers extends Buffers {
 
@@ -66,7 +65,8 @@ public class GLBuffers extends Buffers {
      *              GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV, 
      *              GL_UNSIGNED_INT_10_10_10_2, GL_UNSIGNED_INT_2_10_10_10_REV
      *              GL_UNSIGNED_INT_24_8, GL_UNSIGNED_INT_10F_11F_11F_REV,
-     *              GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT_32_UNSIGNED_INT_24_8_REV (25)         
+     *              GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT_32_UNSIGNED_INT_24_8_REV,         
+     *              GL_HILO16_NV, GL_SIGNED_HILO16_NV (27)         
      * @return -1 if glType is unhandled, otherwise the actual value > 0 
      */
     public static final int sizeOfGLType(int glType) {
@@ -97,6 +97,8 @@ public class GLBuffers extends Buffers {
             case GL2GL3.GL_UNSIGNED_INT_24_8:
             case GL2GL3.GL_UNSIGNED_INT_10F_11F_11F_REV:
             case GL2GL3.GL_UNSIGNED_INT_5_9_9_9_REV:
+            case GL2.GL_HILO16_NV:
+            case GL2.GL_SIGNED_HILO16_NV:
                 return SIZEOF_INT;
                 
             case GL2GL3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
@@ -122,7 +124,8 @@ public class GLBuffers extends Buffers {
      *              GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV, 
      *              GL_UNSIGNED_INT_10_10_10_2, GL_UNSIGNED_INT_2_10_10_10_REV
      *              GL_UNSIGNED_INT_24_8, GL_UNSIGNED_INT_10F_11F_11F_REV,
-     *              GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT_32_UNSIGNED_INT_24_8_REV (25)         
+     *              GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT_32_UNSIGNED_INT_24_8_REV,         
+     *              GL_HILO16_NV, GL_SIGNED_HILO16_NV (27)         
      * @return null if glType is unhandled, otherwise the new Buffer object 
      */
     public static final Buffer newDirectGLBuffer(int glType, int numElements) {
@@ -153,6 +156,8 @@ public class GLBuffers extends Buffers {
             case GL2GL3.GL_UNSIGNED_INT_24_8:
             case GL2GL3.GL_UNSIGNED_INT_10F_11F_11F_REV:
             case GL2GL3.GL_UNSIGNED_INT_5_9_9_9_REV:
+            case GL2.GL_HILO16_NV:
+            case GL2.GL_SIGNED_HILO16_NV:
                 return newDirectIntBuffer(numElements);
                 
             case GL2GL3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
@@ -178,7 +183,8 @@ public class GLBuffers extends Buffers {
      *              GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV, 
      *              GL_UNSIGNED_INT_10_10_10_2, GL_UNSIGNED_INT_2_10_10_10_REV
      *              GL_UNSIGNED_INT_24_8, GL_UNSIGNED_INT_10F_11F_11F_REV,
-     *              GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT_32_UNSIGNED_INT_24_8_REV (25)         
+     *              GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT_32_UNSIGNED_INT_24_8_REV,      
+     *              GL_HILO16_NV, GL_SIGNED_HILO16_NV (27)         
      * @return null if glType is unhandled or parent is null or bufLen is 0, otherwise the new Buffer object 
      */
     public static final Buffer sliceGLBuffer(ByteBuffer parent, int bytePos, int byteLen, int glType) {
@@ -215,6 +221,8 @@ public class GLBuffers extends Buffers {
             case GL2GL3.GL_UNSIGNED_INT_24_8:
             case GL2GL3.GL_UNSIGNED_INT_10F_11F_11F_REV:
             case GL2GL3.GL_UNSIGNED_INT_5_9_9_9_REV:
+            case GL2.GL_HILO16_NV:
+            case GL2.GL_SIGNED_HILO16_NV:
                 return parent.asIntBuffer();
                 
             case GL2GL3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
@@ -360,7 +368,7 @@ public class GLBuffers extends Buffers {
      *              GL_RGB, GL_BGR, GL_RGBA, GL_BGRA, GL_ABGR_EXT,
      *              GL_RED_INTEGER, GL_GREEN_INTEGER, GL_BLUE_INTEGER,
      *              GL_RG_INTEGER, GL_RGB_INTEGER, GL_BGR_INTEGER, 
-     *              GL_RGBA_INTEGER, GL_BGRA_INTEGER (24)
+     *              GL_RGBA_INTEGER, GL_BGRA_INTEGER, GL_HILO_NV, GL_SIGNED_HILO_NV (26)
      *           
      * @param type must be one of 
      *              GL_BITMAP, 
@@ -373,7 +381,8 @@ public class GLBuffers extends Buffers {
      *              GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV, 
      *              GL_UNSIGNED_INT_10_10_10_2, GL_UNSIGNED_INT_2_10_10_10_REV
      *              GL_UNSIGNED_INT_24_8, GL_UNSIGNED_INT_10F_11F_11F_REV,
-     *              GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT_32_UNSIGNED_INT_24_8_REV (26)         
+     *              GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT_32_UNSIGNED_INT_24_8_REV,
+     *              GL_HILO16_NV, GL_SIGNED_HILO16_NV (28)         
      * 
      * @param width in pixels
      * @param height in pixels
@@ -410,6 +419,8 @@ public class GLBuffers extends Buffers {
             case GL.GL_LUMINANCE_ALPHA:
             case GL2GL3.GL_RG:
             case GL2GL3.GL_RG_INTEGER:
+            case GL2.GL_HILO_NV:
+            case GL2.GL_SIGNED_HILO_NV:
               elements = 2;
               break;
             case GL.GL_RGB:
@@ -470,6 +481,11 @@ public class GLBuffers extends Buffers {
               esize = 2;
               elements = 1;
               break;
+            case GL2.GL_HILO16_NV:
+            case GL2.GL_SIGNED_HILO16_NV:
+              esize = 2;
+              elements = 2;
+              break;                
             case GL2GL3.GL_UNSIGNED_INT_8_8_8_8:
             case GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV:
             case GL2GL3.GL_UNSIGNED_INT_10_10_10_2:
@@ -491,6 +507,19 @@ public class GLBuffers extends Buffers {
         
         return sizeof(gl, tmp, elements * esize, width, height, depth, pack);
     }
+    
+    public static final int getNextPowerOf2(int number) {
+        if (((number-1) & number) == 0) {
+          //ex: 8 -> 0b1000; 8-1=7 -> 0b0111; 0b1000&0b0111 == 0
+          return number;
+        }
+        int power = 0;
+        while (number > 0) {
+          number = number>>1;
+          power++;
+        }
+        return (1<<power);
+    }    
       
     //----------------------------------------------------------------------
     // Conversion routines
diff --git a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java
index aba6c90..a86a2f4 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java
@@ -45,7 +45,30 @@ import javax.media.opengl.fixedfunc.GLMatrixFunc;
 
 public class PMVMatrix implements GLMatrixFunc {
 
+    protected final float[] matrixBufferArray;
+
+    /**
+     * Creates an instance of PMVMatrix {@link #PMVMatrix(boolean) PMVMatrix(boolean useBackingArray)},
+     * with <code>useBackingArray = true</code>. 
+     */
     public PMVMatrix() {
+        this(true);
+    }
+    
+    /**
+     * Creates an instance of PMVMatrix.
+     * 
+     * @param useBackingArray <code>true</code> for non direct NIO Buffers with guaranteed backing array,
+     *                        which allows faster access in Java computation.
+     *                        <p><code>false</code> for direct NIO buffers w/o a guaranteed backing array.
+     *                        In most Java implementations, direct NIO buffers have no backing array
+     *                        and hence the Java computation will be throttled down by direct IO get/put 
+     *                        operations.</p> 
+     *                        <p>Depending on the application, ie. weather the Java computation or
+     *                        JNI invocation and hence native data transfer part is heavier, 
+     *                        this flag shall be set to <code>true</code> or <code>false</code></p>.
+     */
+    public PMVMatrix(boolean useBackingArray) {
           projectFloat = new ProjectFloat();
 
           // I    Identity
@@ -54,33 +77,43 @@ public class PMVMatrix implements GLMatrixFunc {
           // Mv   ModelView
           // Mvi  Modelview-Inverse
           // Mvit Modelview-Inverse-Transpose
-          matrixBuffer = Buffers.newDirectByteBuffer(12*16 * Buffers.SIZEOF_FLOAT);
-                                                                   //  I + T + P  + Mv + Mvi + Mvit + Local
-          matrixIdent   = slice2Float(matrixBuffer,  0*16, 1*16);  //  I
-          matrixTex     = slice2Float(matrixBuffer,  1*16, 1*16);  //      T
-          matrixPMvMvit = slice2Float(matrixBuffer,  2*16, 4*16);  //          P  + Mv + Mvi + Mvit
-          matrixPMvMvi  = slice2Float(matrixBuffer,  2*16, 3*16);  //          P  + Mv + Mvi
-          matrixPMv     = slice2Float(matrixBuffer,  2*16, 2*16);  //          P  + Mv
-          matrixP       = slice2Float(matrixBuffer,  2*16, 1*16);  //          P
-          matrixMv      = slice2Float(matrixBuffer,  3*16, 1*16);  //               Mv
-          matrixMvi     = slice2Float(matrixBuffer,  4*16, 1*16);  //                    Mvi
-          matrixMvit    = slice2Float(matrixBuffer,  5*16, 1*16);  //                          Mvit
-          matrixMult    = slice2Float(matrixBuffer,  6*16, 1*16);
-          matrixTrans   = slice2Float(matrixBuffer,  7*16, 1*16);
-          matrixRot     = slice2Float(matrixBuffer,  8*16, 1*16);
-          matrixScale   = slice2Float(matrixBuffer,  9*16, 1*16);
-          matrixOrtho   = slice2Float(matrixBuffer, 10*16, 1*16);
-          matrixFrustum = slice2Float(matrixBuffer, 11*16, 1*16);
-          matrixBuffer.rewind();
+          if(useBackingArray) {
+              matrixBufferArray = new float[6*16];
+              matrixBuffer = null;
+              // matrixBuffer = FloatBuffer.wrap(new float[12*16]);
+          } else {
+              matrixBufferArray = null;
+              matrixBuffer = Buffers.newDirectByteBuffer(6*16 * Buffers.SIZEOF_FLOAT);
+              matrixBuffer.mark();
+          }
           
+          matrixIdent   = slice2Float(matrixBuffer, matrixBufferArray,  0*16, 1*16);  //  I
+          matrixTex     = slice2Float(matrixBuffer, matrixBufferArray,  1*16, 1*16);  //      T
+          matrixPMvMvit = slice2Float(matrixBuffer, matrixBufferArray,  2*16, 4*16);  //          P  + Mv + Mvi + Mvit          
+          matrixPMvMvi  = slice2Float(matrixBuffer, matrixBufferArray,  2*16, 3*16);  //          P  + Mv + Mvi
+          matrixPMv     = slice2Float(matrixBuffer, matrixBufferArray,  2*16, 2*16);  //          P  + Mv
+          matrixP       = slice2Float(matrixBuffer, matrixBufferArray,  2*16, 1*16);  //          P
+          matrixMv      = slice2Float(matrixBuffer, matrixBufferArray,  3*16, 1*16);  //               Mv
+          matrixMvi     = slice2Float(matrixBuffer, matrixBufferArray,  4*16, 1*16);  //                    Mvi
+          matrixMvit    = slice2Float(matrixBuffer, matrixBufferArray,  5*16, 1*16);  //                          Mvit
+          
+          if(null != matrixBuffer) {
+              matrixBuffer.reset();
+          }          
           ProjectFloat.gluMakeIdentityf(matrixIdent);
-          ProjectFloat.gluMakeIdentityf(matrixTrans);
-          ProjectFloat.gluMakeIdentityf(matrixRot);
-          ProjectFloat.gluMakeIdentityf(matrixScale);
-          ProjectFloat.gluMakeIdentityf(matrixOrtho);
-          ProjectFloat.gluMakeZero(matrixFrustum);
-
-          vec3f=new float[3];
+          
+          vec3f         = new float[3];
+          matrixMult    = new float[16];
+          matrixTrans   = new float[16];
+          matrixRot     = new float[16];
+          matrixScale   = new float[16];
+          matrixOrtho   = new float[16];
+          matrixFrustum = new float[16];
+          ProjectFloat.gluMakeIdentityf(matrixTrans, 0);
+          ProjectFloat.gluMakeIdentityf(matrixRot, 0);
+          ProjectFloat.gluMakeIdentityf(matrixScale, 0);
+          ProjectFloat.gluMakeIdentityf(matrixOrtho, 0);
+          ProjectFloat.gluMakeZero(matrixFrustum, 0);
 
           matrixPStack = new ArrayList<float[]>();
           matrixMvStack= new ArrayList<float[]>();
@@ -101,27 +134,30 @@ public class PMVMatrix implements GLMatrixFunc {
             projectFloat.destroy(); projectFloat=null;
         }
 
-        if(null!=matrixBuffer) {
-            matrixBuffer.clear(); matrixBuffer=null;
-        }
-
+        matrixBuffer=null;
+        matrixBuffer=null; matrixPMvMvit=null; matrixPMvMvi=null; matrixPMv=null; 
+        matrixP=null; matrixTex=null; matrixMv=null; matrixMvi=null; matrixMvit=null;        
+
+        vec3f         = null;
+        matrixMult    = null;
+        matrixTrans   = null;
+        matrixRot     = null;
+        matrixScale   = null;
+        matrixOrtho   = null;
+        matrixFrustum = null;
+        
         if(null!=matrixPStack) {
             matrixPStack.clear(); matrixPStack=null;
         }
-        vec3f=null;
         if(null!=matrixMvStack) {
             matrixMvStack.clear(); matrixMvStack=null;
         }
         if(null!=matrixPStack) {
-        matrixPStack.clear(); matrixPStack=null;
+            matrixPStack.clear(); matrixPStack=null;
         }
         if(null!=matrixTStack) {
             matrixTStack.clear(); matrixTStack=null;
         }
-
-        matrixBuffer=null; matrixPMvMvit=null; matrixPMvMvi=null; matrixPMv=null; 
-        matrixP=null; matrixTex=null; matrixMv=null; matrixMvi=null; matrixMvit=null;
-        matrixMult=null; matrixTrans=null; matrixRot=null; matrixScale=null; matrixOrtho=null; matrixFrustum=null;
     }
 
 
@@ -133,14 +169,33 @@ public class PMVMatrix implements GLMatrixFunc {
      * This bug is resolved at least in Android 3.2.
      * 
      * @param buf source ByteBuffer
+     * @param backing source float array
      * @param posFloat {@link Buffers#SIZEOF_FLOAT} position
      * @param lenFloat {@link Buffers#SIZEOF_FLOAT} size 
      * @return FloatBuffer w/ native byte order as given ByteBuffer
      */
-    private static FloatBuffer slice2Float(ByteBuffer buf, int posFloat, int lenFloat) {
-        buf.position( posFloat * Buffers.SIZEOF_FLOAT );
-        buf.limit( (posFloat + lenFloat) * Buffers.SIZEOF_FLOAT );
-        return buf.slice().order(buf.order()).asFloatBuffer(); // slice and duplicate may change byte order        
+    private static FloatBuffer slice2Float(Buffer buf, float[] backing, int posFloat, int lenFloat) {
+        if(buf instanceof ByteBuffer) {
+            ByteBuffer bb = (ByteBuffer) buf;
+            bb.position( posFloat * Buffers.SIZEOF_FLOAT );
+            bb.limit( (posFloat + lenFloat) * Buffers.SIZEOF_FLOAT );
+            FloatBuffer fb = bb.slice().order(bb.order()).asFloatBuffer(); // slice and duplicate may change byte order
+            fb.mark();
+            return fb;
+        } else if(null != backing) {
+            FloatBuffer fb  = FloatBuffer.wrap(backing, posFloat, lenFloat);
+            fb.mark();
+            return fb;
+        } else if(buf instanceof FloatBuffer) {
+            FloatBuffer fb = (FloatBuffer) buf;
+            fb.position( posFloat );
+            fb.limit( posFloat + lenFloat );
+            FloatBuffer fb0 = fb.slice(); // slice and duplicate may change byte order
+            fb0.mark();
+            return fb0;
+        } else {
+            throw new InternalError("XXX");
+        }
     }
 
     public static final boolean isMatrixModeName(final int matrixModeName) {
@@ -231,7 +286,6 @@ public class PMVMatrix implements GLMatrixFunc {
         if(0==modified) return false;
 
         final int res = modified;
-        // int res = DIRTY_MODELVIEW | DIRTY_PROJECTION ;
         if( (res&DIRTY_MODELVIEW)!=0 ) {
             setMviMvit();
         }
@@ -255,11 +309,8 @@ public class PMVMatrix implements GLMatrixFunc {
         return matrixMv;
     }
 
-    public final FloatBuffer glGetPMvMvitMatrixf() {
-        return matrixPMvMvit;
-    }
-
     public final FloatBuffer glGetPMvMviMatrixf() {
+        usesMviMvit |= 1;
         return matrixPMvMvi;
     }
 
@@ -268,9 +319,20 @@ public class PMVMatrix implements GLMatrixFunc {
     }
 
     public final FloatBuffer glGetMviMatrixf() {
+        usesMviMvit |= 1;
         return matrixMvi;
     }
 
+    public final FloatBuffer glGetPMvMvitMatrixf() {
+        usesMviMvit |= 1 | 2;
+        return matrixPMvMvit;
+    }
+    
+    public final FloatBuffer glGetMvitMatrixf() {
+        usesMviMvit |= 1 | 2;
+        return matrixMvit;
+    }
+    
    /*
     * @return the current matrix
     */
@@ -302,22 +364,27 @@ public class PMVMatrix implements GLMatrixFunc {
       glFrustumf(left, right, bottom, top, zNear, zFar);
     }
 
-    public static final void glMultMatrixf(final FloatBuffer a, final FloatBuffer b, FloatBuffer p) {
+    public static final void glMultMatrixf(final FloatBuffer a, final FloatBuffer b, FloatBuffer d) {
+       final int aP = a.position(); 
+       final int bP = b.position();
+       final int dP = d.position();
        for (int i = 0; i < 4; i++) {
-          final float ai0=a.get(i+0*4),  ai1=a.get(i+1*4),  ai2=a.get(i+2*4),  ai3=a.get(i+3*4);
-          p.put(i+0*4 , ai0 * b.get(0+0*4) + ai1 * b.get(1+0*4) + ai2 * b.get(2+0*4) + ai3 * b.get(3+0*4) );
-          p.put(i+1*4 , ai0 * b.get(0+1*4) + ai1 * b.get(1+1*4) + ai2 * b.get(2+1*4) + ai3 * b.get(3+1*4) );
-          p.put(i+2*4 , ai0 * b.get(0+2*4) + ai1 * b.get(1+2*4) + ai2 * b.get(2+2*4) + ai3 * b.get(3+2*4) );
-          p.put(i+3*4 , ai0 * b.get(0+3*4) + ai1 * b.get(1+3*4) + ai2 * b.get(2+3*4) + ai3 * b.get(3+3*4) );
+          final float ai0=a.get(aP+i+0*4),  ai1=a.get(aP+i+1*4),  ai2=a.get(aP+i+2*4),  ai3=a.get(aP+i+3*4);
+          d.put(dP+i+0*4 , ai0 * b.get(bP+0+0*4) + ai1 * b.get(bP+1+0*4) + ai2 * b.get(bP+2+0*4) + ai3 * b.get(bP+3+0*4) );
+          d.put(dP+i+1*4 , ai0 * b.get(bP+0+1*4) + ai1 * b.get(bP+1+1*4) + ai2 * b.get(bP+2+1*4) + ai3 * b.get(bP+3+1*4) );
+          d.put(dP+i+2*4 , ai0 * b.get(bP+0+2*4) + ai1 * b.get(bP+1+2*4) + ai2 * b.get(bP+2+2*4) + ai3 * b.get(bP+3+2*4) );
+          d.put(dP+i+3*4 , ai0 * b.get(bP+0+3*4) + ai1 * b.get(bP+1+3*4) + ai2 * b.get(bP+2+3*4) + ai3 * b.get(bP+3+3*4) );
        }
     }
-    public static final void glMultMatrixf(final FloatBuffer a, final float[] b, int b_off, FloatBuffer p) {
+    public static final void glMultMatrixf(final FloatBuffer a, final float[] b, int b_off, FloatBuffer d) {
+       final int aP = a.position(); 
+       final int dP = d.position();
        for (int i = 0; i < 4; i++) {
-          final float ai0=a.get(i+0*4),  ai1=a.get(i+1*4),  ai2=a.get(i+2*4),  ai3=a.get(i+3*4);
-          p.put(i+0*4 , ai0 * b[b_off+0+0*4] + ai1 * b[b_off+1+0*4] + ai2 * b[b_off+2+0*4] + ai3 * b[b_off+3+0*4] );
-          p.put(i+1*4 , ai0 * b[b_off+0+1*4] + ai1 * b[b_off+1+1*4] + ai2 * b[b_off+2+1*4] + ai3 * b[b_off+3+1*4] );
-          p.put(i+2*4 , ai0 * b[b_off+0+2*4] + ai1 * b[b_off+1+2*4] + ai2 * b[b_off+2+2*4] + ai3 * b[b_off+3+2*4] );
-          p.put(i+3*4 , ai0 * b[b_off+0+3*4] + ai1 * b[b_off+1+3*4] + ai2 * b[b_off+2+3*4] + ai3 * b[b_off+3+3*4] );
+          final float ai0=a.get(aP+i+0*4),  ai1=a.get(aP+i+1*4),  ai2=a.get(aP+i+2*4),  ai3=a.get(aP+i+3*4);
+          d.put(dP+i+0*4 , ai0 * b[b_off+0+0*4] + ai1 * b[b_off+1+0*4] + ai2 * b[b_off+2+0*4] + ai3 * b[b_off+3+0*4] );
+          d.put(dP+i+1*4 , ai0 * b[b_off+0+1*4] + ai1 * b[b_off+1+1*4] + ai2 * b[b_off+2+1*4] + ai3 * b[b_off+3+1*4] );
+          d.put(dP+i+2*4 , ai0 * b[b_off+0+2*4] + ai1 * b[b_off+1+2*4] + ai2 * b[b_off+2+2*4] + ai3 * b[b_off+3+2*4] );
+          d.put(dP+i+3*4 , ai0 * b[b_off+0+3*4] + ai1 * b[b_off+1+3*4] + ai2 * b[b_off+2+3*4] + ai3 * b[b_off+3+3*4] );
        }
     }
 
@@ -343,8 +410,8 @@ public class PMVMatrix implements GLMatrixFunc {
             params.put((float)matrixMode);
         } else {
             FloatBuffer matrix = glGetMatrixf(matrixGetName2MatrixModeName(matrixGetName));
-            params.put(matrix);
-            matrix.rewind();
+            params.put(matrix); // matrix -> params
+            matrix.reset();
         }
         params.position(pos);
     }
@@ -353,8 +420,8 @@ public class PMVMatrix implements GLMatrixFunc {
             params[params_offset]=(float)matrixMode;
         } else {
             FloatBuffer matrix = glGetMatrixf(matrixGetName2MatrixModeName(matrixGetName));
-            matrix.get(params, params_offset, 16);
-            matrix.rewind();
+            matrix.get(params, params_offset, 16); // matrix -> params
+            matrix.reset();
         }
     }
     public void glGetIntegerv(int pname, IntBuffer params) {
@@ -377,19 +444,16 @@ public class PMVMatrix implements GLMatrixFunc {
     public final void glLoadMatrixf(final float[] values, final int offset) {
         int len = values.length-offset;
         if(matrixMode==GL_MODELVIEW) {
-            matrixMv.clear();
             matrixMv.put(values, offset, len);
-            matrixMv.rewind();
+            matrixMv.reset();
             modified |= DIRTY_MODELVIEW ;
         } else if(matrixMode==GL_PROJECTION) {
-            matrixP.clear();
             matrixP.put(values, offset, len);
-            matrixP.rewind();
+            matrixP.reset();
             modified |= DIRTY_PROJECTION ;
         } else if(matrixMode==GL.GL_TEXTURE) {
-            matrixTex.clear();
             matrixTex.put(values, offset, len);
-            matrixTex.rewind();
+            matrixTex.reset();
             modified |= DIRTY_TEXTURE ;
         } 
     }
@@ -397,19 +461,16 @@ public class PMVMatrix implements GLMatrixFunc {
     public final void glLoadMatrixf(java.nio.FloatBuffer m) {
         int spos = m.position();
         if(matrixMode==GL_MODELVIEW) {
-            matrixMv.clear();
             matrixMv.put(m);
-            matrixMv.rewind();
+            matrixMv.reset();
             modified |= DIRTY_MODELVIEW ;
         } else if(matrixMode==GL_PROJECTION) {
-            matrixP.clear();
             matrixP.put(m);
-            matrixP.rewind();
+            matrixP.reset();
             modified |= DIRTY_PROJECTION ;
         } else if(matrixMode==GL.GL_TEXTURE) {
-            matrixTex.clear();
             matrixTex.put(m);
-            matrixTex.rewind();
+            matrixTex.reset();
             modified |= DIRTY_TEXTURE ;
         } 
         m.position(spos);
@@ -431,85 +492,60 @@ public class PMVMatrix implements GLMatrixFunc {
         float[] stackEntry = new float[1*16];
         if(matrixMode==GL_MODELVIEW) {
             matrixMv.get(stackEntry);
-            matrixMv.rewind();
+            matrixMv.reset();
             matrixMvStack.add(0, stackEntry);
         } else if(matrixMode==GL_PROJECTION) {
             matrixP.get(stackEntry);
-            matrixP.rewind();
+            matrixP.reset();
             matrixPStack.add(0, stackEntry);
         } else if(matrixMode==GL.GL_TEXTURE) {
             matrixTex.get(stackEntry);
-            matrixTex.rewind();
+            matrixTex.reset();
             matrixTStack.add(0, stackEntry);
         }
     }
 
     public final void glLoadIdentity() {
         if(matrixMode==GL_MODELVIEW) {
-            matrixMv.clear();
             matrixMv.put(matrixIdent);
-            matrixMv.rewind();
-            matrixIdent.rewind();
+            matrixMv.reset();
             modified |= DIRTY_MODELVIEW ;
         } else if(matrixMode==GL_PROJECTION) {
-            matrixP.clear();
             matrixP.put(matrixIdent);
-            matrixP.rewind();
-            matrixIdent.rewind();
+            matrixP.reset();
             modified |= DIRTY_PROJECTION ;
         } else if(matrixMode==GL.GL_TEXTURE) {
-            matrixTex.clear();
             matrixTex.put(matrixIdent);
-            matrixTex.rewind();
-            matrixIdent.rewind();
+            matrixTex.reset();
             modified |= DIRTY_TEXTURE ;
         } 
+        matrixIdent.reset();
     }
 
     public final void glMultMatrixf(final FloatBuffer m) {
         if(matrixMode==GL_MODELVIEW) {
-            glMultMatrixf(matrixMv, m, matrixMult);
-            matrixMv.clear();
-            matrixMv.put(matrixMult);
-            matrixMv.rewind();
+            glMultMatrixf(matrixMv, m, matrixMv);
             modified |= DIRTY_MODELVIEW ;
         } else if(matrixMode==GL_PROJECTION) {
-            glMultMatrixf(matrixP, m, matrixMult);
-            matrixP.clear();
-            matrixP.put(matrixMult);
-            matrixP.rewind();
+            glMultMatrixf(matrixP, m, matrixP);
             modified |= DIRTY_PROJECTION ;
         } else if(matrixMode==GL.GL_TEXTURE) {
-            glMultMatrixf(matrixTex, m, matrixMult);
-            matrixTex.clear();
-            matrixTex.put(matrixMult);
-            matrixTex.rewind();
+            glMultMatrixf(matrixTex, m, matrixTex);
             modified |= DIRTY_TEXTURE ;
         } 
-        matrixMult.rewind();
     }
 
     public void glMultMatrixf(float[] m, int m_offset) {
         if(matrixMode==GL_MODELVIEW) {
-            glMultMatrixf(matrixMv, m, m_offset, matrixMult);
-            matrixMv.clear();
-            matrixMv.put(matrixMult);
-            matrixMv.rewind();
+            glMultMatrixf(matrixMv, m, m_offset, matrixMv);
             modified |= DIRTY_MODELVIEW ;
         } else if(matrixMode==GL_PROJECTION) {
-            glMultMatrixf(matrixP, m, m_offset, matrixMult);
-            matrixP.clear();
-            matrixP.put(matrixMult);
-            matrixP.rewind();
+            glMultMatrixf(matrixP, m, m_offset, matrixP);
             modified |= DIRTY_PROJECTION ;
         } else if(matrixMode==GL.GL_TEXTURE) {
-            glMultMatrixf(matrixTex, m, m_offset, matrixMult);
-            matrixTex.clear();
-            matrixTex.put(matrixMult);
-            matrixTex.rewind();
+            glMultMatrixf(matrixTex, m, m_offset, matrixTex);
             modified |= DIRTY_TEXTURE ;
         } 
-        matrixMult.rewind();
     }
 
     public final void glTranslatef(final float x, final float y, final float z) {
@@ -518,17 +554,17 @@ public class PMVMatrix implements GLMatrixFunc {
         //  0 1 0 y
         //  0 0 1 z
         //  0 0 0 1
-        matrixTrans.put(0+4*3, x);
-        matrixTrans.put(1+4*3, y);
-        matrixTrans.put(2+4*3, z);
-        glMultMatrixf(matrixTrans);
+        matrixTrans[0+4*3] = x;
+        matrixTrans[1+4*3] = y;
+        matrixTrans[2+4*3] = z;
+        glMultMatrixf(matrixTrans, 0);
     }
 
     public final void glRotatef(final float angdeg, float x, float y, float z) {
-        float angrad = angdeg   * (float) Math.PI / 180.0f;
-        float c = (float)Math.cos(angrad);
-        float ic= 1.0f - c; 
-        float s = (float)Math.sin(angrad);
+        final float angrad = angdeg   * (float) Math.PI / 180.0f;
+        final float c = (float)Math.cos(angrad);
+        final float ic= 1.0f - c; 
+        final float s = (float)Math.sin(angrad);
 
         vec3f[0]=x; vec3f[1]=y; vec3f[2]=z;
         ProjectFloat.normalize(vec3f);
@@ -539,25 +575,25 @@ public class PMVMatrix implements GLMatrixFunc {
         //      xy(1−c)-zs yy(1−c)+c  yz(1−c)+xs 0
         //      xz(1−c)+ys yz(1−c)-xs zz(1−c)+c  0
         //      0          0          0          1
-        float xy = x*y;
-        float xz = x*z;
-        float xs = x*s;
-        float ys = y*s;
-        float yz = y*z;
-        float zs = z*s;
-        matrixRot.put(0*4+0, x*x*ic+c);
-        matrixRot.put(0*4+1, xy*ic+zs);
-        matrixRot.put(0*4+2, xz*ic-ys);
+        final float xy = x*y;
+        final float xz = x*z;
+        final float xs = x*s;
+        final float ys = y*s;
+        final float yz = y*z;
+        final float zs = z*s;
+        matrixRot[0*4+0] = x*x*ic+c;
+        matrixRot[0*4+1] = xy*ic+zs;
+        matrixRot[0*4+2] = xz*ic-ys;
 
-        matrixRot.put(1*4+0, xy*ic-zs);
-        matrixRot.put(1*4+1, y*y*ic+c);
-        matrixRot.put(1*4+2, yz*ic+xs);
+        matrixRot[1*4+0] = xy*ic-zs;
+        matrixRot[1*4+1] = y*y*ic+c;
+        matrixRot[1*4+2] = yz*ic+xs;
 
-        matrixRot.put(2*4+0, xz*ic+ys);
-        matrixRot.put(2*4+1, yz*ic-xs);
-        matrixRot.put(2*4+2, z*z*ic+c);
+        matrixRot[2*4+0] = xz*ic+ys;
+        matrixRot[2*4+1] = yz*ic-xs;
+        matrixRot[2*4+2] = z*z*ic+c;
 
-        glMultMatrixf(matrixRot);
+        glMultMatrixf(matrixRot, 0);
     }
 
     public final void glScalef(final float x, final float y, final float z) {
@@ -566,11 +602,11 @@ public class PMVMatrix implements GLMatrixFunc {
         //  0 y 0 0
         //  0 0 z 0
         //  0 0 0 1
-        matrixScale.put(0+4*0, x);
-        matrixScale.put(1+4*1, y);
-        matrixScale.put(2+4*2, z);
+        matrixScale[0+4*0] = x;
+        matrixScale[1+4*1] = y;
+        matrixScale[2+4*2] = z;
 
-        glMultMatrixf(matrixScale);
+        glMultMatrixf(matrixScale, 0);
     }
 
     public final void glOrthof(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) {
@@ -579,21 +615,21 @@ public class PMVMatrix implements GLMatrixFunc {
         //  0     2/dy  0    ty
         //  0     0     2/dz tz
         //  0     0     0    1
-        float dx=right-left;
-        float dy=top-bottom;
-        float dz=zFar-zNear;
-        float tx=-1.0f*(right+left)/dx;
-        float ty=-1.0f*(top+bottom)/dy;
-        float tz=-1.0f*(zFar+zNear)/dz;
+        final float dx=right-left;
+        final float dy=top-bottom;
+        final float dz=zFar-zNear;
+        final float tx=-1.0f*(right+left)/dx;
+        final float ty=-1.0f*(top+bottom)/dy;
+        final float tz=-1.0f*(zFar+zNear)/dz;
 
-        matrixOrtho.put(0+4*0, 2.0f/dx);
-        matrixOrtho.put(1+4*1, 2.0f/dy);
-        matrixOrtho.put(2+4*2, -2.0f/dz);
-        matrixOrtho.put(0+4*3, tx);
-        matrixOrtho.put(1+4*3, ty);
-        matrixOrtho.put(2+4*3, tz);
+        matrixOrtho[0+4*0] =  2.0f/dx;
+        matrixOrtho[1+4*1] =  2.0f/dy;
+        matrixOrtho[2+4*2] = -2.0f/dz;
+        matrixOrtho[0+4*3] = tx;
+        matrixOrtho[1+4*3] = ty;
+        matrixOrtho[2+4*3] = tz;
 
-        glMultMatrixf(matrixOrtho);
+        glMultMatrixf(matrixOrtho, 0);
     }
 
     public final void glFrustumf(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) {
@@ -608,52 +644,87 @@ public class PMVMatrix implements GLMatrixFunc {
         //  0            2*zNear/dy B  0
         //  0            0          C  D
         //  0            0         −1  0
-        float zNear2 = 2.0f*zNear;
-        float dx=right-left;
-        float dy=top-bottom;
-        float dz=zFar-zNear;
-        float A=(right+left)/dx;
-        float B=(top+bottom)/dy;
-        float C=-1.0f*(zFar+zNear)/dz;
-        float D=-2.0f*(zFar*zNear)/dz;
+        final float zNear2 = 2.0f*zNear;
+        final float dx=right-left;
+        final float dy=top-bottom;
+        final float dz=zFar-zNear;
+        final float A=(right+left)/dx;
+        final float B=(top+bottom)/dy;
+        final float C=-1.0f*(zFar+zNear)/dz;
+        final float D=-2.0f*(zFar*zNear)/dz;
 
-        matrixFrustum.put(0+4*0, zNear2/dx);
-        matrixFrustum.put(1+4*1, zNear2/dy);
-        matrixFrustum.put(2+4*2, C);
+        matrixFrustum[0+4*0] = zNear2/dx;
+        matrixFrustum[1+4*1] = zNear2/dy;
+        matrixFrustum[2+4*2] = C;
 
-        matrixFrustum.put(0+4*2, A);
-        matrixFrustum.put(1+4*2, B);
+        matrixFrustum[0+4*2] = A;
+        matrixFrustum[1+4*2] = B;
 
-        matrixFrustum.put(2+4*3, D);
-        matrixFrustum.put(3+4*2, -1.0f);
+        matrixFrustum[2+4*3] = D;
+        matrixFrustum[3+4*2] = -1.0f;
 
-        glMultMatrixf(matrixFrustum);
+        glMultMatrixf(matrixFrustum, 0);
     }
 
     //
     // private 
     //
+    private int nioBackupArraySupported = 0; // -1 not supported, 0 - TBD, 1 - supported
+    private final String msgCantComputeInverse = "Invalid source Mv matrix, can't compute inverse";
 
     private final void setMviMvit() {
-        if(!projectFloat.gluInvertMatrixf(matrixMv, matrixMvi)) {
-            throw new GLException("Invalid source Mv matrix, can't compute inverse");
+        if( 0 != (usesMviMvit & 1) ) {
+            if(nioBackupArraySupported>=0) {
+                try {
+                    setMviMvitNIOBackupArray();
+                    nioBackupArraySupported = 1;
+                    return;
+                } catch(UnsupportedOperationException uoe) {
+                    nioBackupArraySupported = -1;
+                }
+            }
+            setMviMvitNIODirectAccess();
         }
-
-        // transpose matrix 
-        for (int i = 0; i < 4; i++) {
-            for (int j = 0; j < 4; j++) {
-                matrixMvit.put(j+i*4, matrixMvi.get(i+j*4));
+    }
+    private final void setMviMvitNIOBackupArray() {
+        final float[] _matrixMvi = matrixMvi.array();
+        final int _matrixMviOffset = matrixMvi.position();
+        if(!projectFloat.gluInvertMatrixf(matrixMv.array(), matrixMv.position(), _matrixMvi, _matrixMviOffset)) {
+            throw new GLException(msgCantComputeInverse);
+        }
+        if( 0 != (usesMviMvit & 2) ) {
+            // transpose matrix 
+            final float[] _matrixMvit = matrixMvit.array();
+            final int _matrixMvitOffset = matrixMvit.position();
+            for (int i = 0; i < 4; i++) {
+                for (int j = 0; j < 4; j++) {
+                    _matrixMvit[_matrixMvitOffset+j+i*4] = _matrixMvi[_matrixMviOffset+i+j*4];
+                }
             }
+        }        
+    }
+    
+    private final void setMviMvitNIODirectAccess() {
+        if(!projectFloat.gluInvertMatrixf(matrixMv, matrixMvi)) {
+            throw new GLException(msgCantComputeInverse);
         }
+        if( 0 != (usesMviMvit & 2) ) {
+            // transpose matrix 
+            for (int i = 0; i < 4; i++) {
+                for (int j = 0; j < 4; j++) {
+                    matrixMvit.put(j+i*4, matrixMvi.get(i+j*4));
+                }
+            }
+        }        
     }
 
-    protected ByteBuffer matrixBuffer;
+    protected Buffer matrixBuffer;
     protected FloatBuffer matrixIdent, matrixPMvMvit, matrixPMvMvi, matrixPMv, matrixP, matrixTex, matrixMv, matrixMvi, matrixMvit;
-    protected FloatBuffer matrixMult, matrixTrans, matrixRot, matrixScale, matrixOrtho, matrixFrustum;
-    protected float[] vec3f;
+    protected float[] matrixMult, matrixTrans, matrixRot, matrixScale, matrixOrtho, matrixFrustum, vec3f;
     protected List<float[]> matrixTStack, matrixPStack, matrixMvStack;
     protected int matrixMode = GL_MODELVIEW;
     protected int modified = 0;
+    protected int usesMviMvit = 0; // 0 - none, 1 - Mvi, 2 - Mvit, 3 - MviMvit (ofc no Mvit w/o Mvi!)
     protected ProjectFloat projectFloat;
 
     public static final int DIRTY_MODELVIEW  = 1 << 0;
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java
index b6df365..7f3aa8a 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java
@@ -1055,9 +1055,7 @@ public class Texture {
 
     // Helper routines for disabling certain codepaths
     private static boolean haveNPOT(GL gl) {
-        return (!disableNPOT &&
-                ( gl.isGLES2() ||
-                  gl.isExtensionAvailable("GL_ARB_texture_non_power_of_two") ) );
+        return !disableNPOT && gl.isNPOTTextureAvailable();
     }
 
     private static boolean haveTexRect(GL gl) {
diff --git a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
index 0ad97c3..1bb5094 100644
--- a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
+++ b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
@@ -127,6 +127,7 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser {
     final int OPAQUE_MISMATCH_PENALTY = 750;
     final int STENCIL_MISMATCH_PENALTY = 500;
     final int MULTISAMPLE_MISMATCH_PENALTY = 500;
+    final int MULTISAMPLE_EXTENSION_MISMATCH_PENALTY = 250; // just a little drop, no scale
     // Pseudo attempt to keep equal rank penalties scale-equivalent
     // (e.g., stencil mismatch is 3 * accum because there are 3 accum
     // components)
@@ -187,8 +188,13 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser {
       if ((gldes.getStencilBits() > 0) && (cur.getStencilBits() == 0)) {
         score += sign(score) * STENCIL_MISMATCH_PENALTY;
       }
-      if ((gldes_samples > 0) && (cur_samples == 0)) {
-        score += sign(score) * MULTISAMPLE_MISMATCH_PENALTY;
+      if (gldes_samples > 0) {
+          if (cur_samples == 0) {
+            score += sign(score) * MULTISAMPLE_MISMATCH_PENALTY;
+          }
+          if (!gldes.getSampleExtension().equals(cur.getSampleExtension())) {
+            score += sign(score) * MULTISAMPLE_EXTENSION_MISMATCH_PENALTY;
+          }
       }
       scores[i] = score;
     }
diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java
index 90290d8..9484f06 100644
--- a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java
+++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java
@@ -249,7 +249,7 @@ public interface GLAutoDrawable extends GLDrawable {
       front and back buffers are swapped, displaying the results of
       the render. When disabled, the user is responsible for calling
       {@link #swapBuffers(..)} manually. */
-  public void setAutoSwapBufferMode(boolean onOrOff);
+  public void setAutoSwapBufferMode(boolean enable);
 
   /** Indicates whether automatic buffer swapping is enabled for this
       drawable. See {@link #setAutoSwapBufferMode}. */
diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java
index f93d443..534e449 100644
--- a/src/jogl/classes/javax/media/opengl/GLBase.java
+++ b/src/jogl/classes/javax/media/opengl/GLBase.java
@@ -294,6 +294,17 @@ public interface GLBase {
     */
    public boolean isExtensionAvailable(String glExtensionName);
 
+   /**
+    * Returns true if the GL context supports non power of two (NPOT) textures,
+    * otherwise false.
+    * <p>
+    * NPOT textures are supported in OpenGL >= 3, GLES2 or if the
+    * 'GL_ARB_texture_non_power_of_two' extension is available.
+    * </p>
+    * @return
+    */
+   public boolean isNPOTTextureAvailable();
+
    /** Provides a platform-independent way to specify the minimum swap
        interval for buffer swaps. An argument of 0 disables
        sync-to-vertical-refresh completely, while an argument of 1
diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilities.java b/src/jogl/classes/javax/media/opengl/GLCapabilities.java
index 4d9d088..9022c7d 100644
--- a/src/jogl/classes/javax/media/opengl/GLCapabilities.java
+++ b/src/jogl/classes/javax/media/opengl/GLCapabilities.java
@@ -69,6 +69,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
   // are unlikely to be supported on Windows anyway
 
   // Support for full-scene antialiasing (FSAA)
+  private String  sampleExtension = DEFAULT_SAMPLE_EXTENSION;
   private boolean sampleBuffers = false;
   private int     numSamples    = 2;
 
@@ -111,6 +112,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
     hash = ((hash << 5) - hash) + this.accumAlphaBits;
     hash = ((hash << 5) - hash) + ( this.sampleBuffers ? 1 : 0 );
     hash = ((hash << 5) - hash) + this.numSamples;
+    hash = ((hash << 5) - hash) + this.sampleExtension.hashCode();
     hash = ((hash << 5) - hash) + ( this.pbufferFloatingPointBuffers ? 1 : 0 );
     hash = ((hash << 5) - hash) + ( this.pbufferRenderToTexture ? 1 : 0 );
     hash = ((hash << 5) - hash) + ( this.pbufferRenderToTextureRectangle ? 1 : 0 );
@@ -139,7 +141,9 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
                   other.getPbufferRenderToTexture()==pbufferRenderToTexture &&
                   other.getPbufferRenderToTextureRectangle()==pbufferRenderToTextureRectangle;
     if(sampleBuffers) {
-        res = res && other.getNumSamples()==numSamples;
+        res = res &&
+              other.getNumSamples()==numSamples && 
+              other.getSampleExtension().equals(sampleExtension) ;
     }
     return res;
   }
@@ -147,7 +151,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
   /** comparing hw/sw, stereo, multisample, stencil, RGBA and depth only */
   public int compareTo(Object o) {
     if ( ! ( o instanceof GLCapabilities ) ) {
-        Class c = (null != o) ? o.getClass() : null ;
+        Class<?> c = (null != o) ? o.getClass() : null ;
         throw new ClassCastException("Not a GLCapabilities object: " + c);
     }
 
@@ -173,6 +177,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
     } else if( ms < xms ) {
         return -1;
     }
+    // ignore the sample extension 
 
     if(stencilBits > caps.stencilBits) {
         return 1;
@@ -194,7 +199,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
     return 0; // they are equal: hw/sw, stereo, multisample, stencil, RGBA and depth
   }
 
-  /** Returns the GL profile you desire or used by the drawable. */
   public GLProfile getGLProfile() {
     return glProfile;
   }
@@ -204,7 +208,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
     glProfile=profile;
   }
 
-  /** Indicates whether pbuffer is used/requested. */
   public boolean isPBuffer() {
     return pbuffer;
   }
@@ -233,7 +236,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
     super.setOnscreen(onscreen);
   }
 
-  /** Indicates whether double-buffering is enabled. */
   public boolean getDoubleBuffered() {
     return doubleBuffered;
   }
@@ -243,7 +245,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
     doubleBuffered = enable;
   }
 
-  /** Indicates whether stereo is enabled. */
   public boolean getStereo() {
     return stereo;
   }
@@ -253,7 +254,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
     stereo = enable;
   }
 
-  /** Indicates whether hardware acceleration is enabled. */
   public boolean getHardwareAccelerated() {
     return hardwareAccelerated;
   }
@@ -263,7 +263,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
     hardwareAccelerated = enable;
   }
 
-  /** Returns the number of bits requested for the depth buffer. */
   public int getDepthBits() {
     return depthBits;
   }
@@ -273,7 +272,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
     this.depthBits = depthBits;
   }
   
-  /** Returns the number of bits requested for the stencil buffer. */
   public int getStencilBits() {
     return stencilBits;
   }
@@ -283,10 +281,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
     this.stencilBits = stencilBits;
   }
   
-  /** Returns the number of bits requested for the accumulation
-      buffer's red component. On some systems only the accumulation
-      buffer depth, which is the sum of the red, green, and blue bits,
-      is considered. */
   public int getAccumRedBits() {
     return accumRedBits;
   }
@@ -299,10 +293,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
     this.accumRedBits = accumRedBits;
   }
 
-  /** Returns the number of bits requested for the accumulation
-      buffer's green component. On some systems only the accumulation
-      buffer depth, which is the sum of the red, green, and blue bits,
-      is considered. */
   public int getAccumGreenBits() {
     return accumGreenBits;
   }
@@ -315,10 +305,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
     this.accumGreenBits = accumGreenBits;
   }
 
-  /** Returns the number of bits requested for the accumulation
-      buffer's blue component. On some systems only the accumulation
-      buffer depth, which is the sum of the red, green, and blue bits,
-      is considered. */
   public int getAccumBlueBits() {
     return accumBlueBits;
   }
@@ -331,10 +317,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
     this.accumBlueBits = accumBlueBits;
   }
 
-  /** Returns the number of bits requested for the accumulation
-      buffer's alpha component. On some systems only the accumulation
-      buffer depth, which is the sum of the red, green, and blue bits,
-      is considered. */
   public int getAccumAlphaBits() {
     return accumAlphaBits;
   }
@@ -348,6 +330,18 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
   }
 
   /**
+   * Sets the desired extension for full-scene antialiasing
+   * (FSAA), default is {@link #DEFAULT_SAMPLE_EXTENSION}.
+   */
+  public void setSampleExtension(String se) { 
+      sampleExtension = se; 
+  }
+    
+  public String getSampleExtension() { 
+      return sampleExtension; 
+  }
+  
+  /**
    * Defaults to false.<br>
    * Indicates whether sample buffers for full-scene antialiasing
    * (FSAA) should be allocated for this drawable.<br>
@@ -362,9 +356,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
     }        
   }
 
-  /** Returns whether sample buffers for full-scene antialiasing
-      (FSAA) should be allocated for this drawable. Defaults to
-      false. */
   public boolean getSampleBuffers() {
     return sampleBuffers;
   }
@@ -375,8 +366,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
     this.numSamples = numSamples;
   }
 
-  /** Returns the number of sample buffers to be allocated if sample
-      buffers are enabled. Defaults to 2. */
   public int getNumSamples() {
     return numSamples;
   }
@@ -387,8 +376,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
     pbufferFloatingPointBuffers = enable;
   }
 
-  /** For pbuffers only, returns whether floating-point buffers should
-      be used if available. Defaults to false. */
   public boolean getPbufferFloatingPointBuffers() {
     return pbufferFloatingPointBuffers;
   }
@@ -399,8 +386,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
     pbufferRenderToTexture = enable;
   }
 
-  /** For pbuffers only, returns whether the render-to-texture
-      extension should be used if available.  Defaults to false. */
   public boolean getPbufferRenderToTexture() {
     return pbufferRenderToTexture;
   }
@@ -412,8 +397,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
     pbufferRenderToTextureRectangle = enable;
   }
 
-  /** For pbuffers only, returns whether the render-to-texture
-      extension should be used. Defaults to false. */
   public boolean getPbufferRenderToTextureRectangle() {
     return pbufferRenderToTextureRectangle;
   }
@@ -429,6 +412,9 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
 
     sink.append(", accum-rgba ").append(accumRedBits).append("/").append(accumGreenBits).append("/").append(accumBlueBits).append("/").append(accumAlphaBits);
     sink.append(", dp/st/ms: ").append(depthBits).append("/").append(stencilBits).append("/").append(samples);
+    if(samples>0) {
+        sink.append(", sample-ext ").append(sampleExtension);
+    }
     if(doubleBuffered) {
         sink.append(", dbl");
     } else {
diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java b/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java
index b91ceae..5f8795e 100644
--- a/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java
+++ b/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java
@@ -37,6 +37,17 @@ import javax.media.nativewindow.CapabilitiesImmutable;
  * @see javax.media.nativewindow.CapabilitiesImmutable
  */
 public interface GLCapabilitiesImmutable extends CapabilitiesImmutable {
+    /** 
+     * One of the platform's default sample extension 
+     * <code>EGL.EGL_SAMPLES, GLX.GLX_SAMPLES, WGLExt.WGL_SAMPLES_ARB</code>
+     * if available, or any other <i>known</i> fallback one, ie <code>EGLExt.EGL_COVERAGE_SAMPLES_NV</code>
+     */
+    public static final String DEFAULT_SAMPLE_EXTENSION = "default" ;
+    
+    /**
+     * Returns the GL profile you desire or used by the drawable.
+     */
+    GLProfile getGLProfile();
 
     /**
      * Returns the number of bits requested for the accumulation
@@ -81,14 +92,22 @@ public interface GLCapabilitiesImmutable extends CapabilitiesImmutable {
     boolean getDoubleBuffered();
 
     /**
-     * Returns the GL profile you desire or used by the drawable.
+     * Indicates whether hardware acceleration is enabled.
      */
-    GLProfile getGLProfile();
+    boolean getHardwareAccelerated();
 
     /**
-     * Indicates whether hardware acceleration is enabled.
+     * Returns the used extension for full-scene antialiasing
+     * (FSAA), default is {@link #DEFAULT_SAMPLE_EXTENSION}.
      */
-    boolean getHardwareAccelerated();
+    String getSampleExtension();
+    
+    /**
+     * Returns whether sample buffers for full-scene antialiasing
+     * (FSAA) should be allocated for this drawable. Defaults to
+     * false.
+     */
+    boolean getSampleBuffers();
 
     /**
      * Returns the number of sample buffers to be allocated if sample
@@ -115,13 +134,6 @@ public interface GLCapabilitiesImmutable extends CapabilitiesImmutable {
     boolean getPbufferRenderToTextureRectangle();
 
     /**
-     * Returns whether sample buffers for full-scene antialiasing
-     * (FSAA) should be allocated for this drawable. Defaults to
-     * false.
-     */
-    boolean getSampleBuffers();
-
-    /**
      * Returns the number of bits requested for the stencil buffer.
      */
     int getStencilBits();
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index a3aa369..38c2d79 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -45,6 +45,7 @@ import java.security.AccessControlContext;
 import java.security.AccessController;
 import java.util.HashMap;
 import java.util.HashSet;
+
 import javax.media.nativewindow.AbstractGraphicsDevice;
 
 import com.jogamp.common.util.IntObjectHashMap;
@@ -65,7 +66,8 @@ import jogamp.opengl.GLContextImpl;
     abstraction provides a stable object which clients can use to
     refer to a given context. */
 public abstract class GLContext {
-  
+  public static final boolean DEBUG = Debug.debug("GLContext");
+      
   /** Reflects property jogl.debug.DebugGL. If true, the debug pipeline is enabled at context creation. */
   public final static boolean DEBUG_GL;
   /** Reflects property jogl.debug.TraceGL. If true, the trace pipeline is enabled at context creation. */
@@ -377,7 +379,7 @@ public abstract class GLContext {
    */
   public String toString() {
     StringBuffer sb = new StringBuffer();
-    sb.append(getClass().getName());
+    sb.append(getClass().getSimpleName());
     sb.append(" [");
     this.append(sb);
     sb.append("] ");
@@ -767,12 +769,12 @@ public abstract class GLContext {
   /**
    * @see #getDeviceVersionAvailableKey(javax.media.nativewindow.AbstractGraphicsDevice, int, int) 
    */
-  protected static /*final*/ HashMap/*<DeviceVersionAvailableKey, Integer>*/ deviceVersionAvailable = new HashMap();
+  protected static /*final*/ HashMap<String, Integer> deviceVersionAvailable = new HashMap<String, Integer>();
 
   /**
    * @see #getUniqueDeviceString(javax.media.nativewindow.AbstractGraphicsDevice)
    */
-  private static /*final*/ HashSet/*<UniqueDeviceString>*/ deviceVersionsAvailableSet = new HashSet();
+  private static /*final*/ HashSet<String> deviceVersionsAvailableSet = new HashSet<String>();
 
   protected static String getDeviceVersionAvailableKey(AbstractGraphicsDevice device, int major, int profile) {
       return device.getUniqueID() + "-" + toHexString(compose8bit(major, profile, 0, 0));
@@ -791,18 +793,18 @@ public abstract class GLContext {
               throw new InternalError("Already set: "+devKey);
           }
           deviceVersionsAvailableSet.add(devKey);
-          if (GLContextImpl.DEBUG) {
-            String msg = getThreadName() + ": !!! createContextARB: SET mappedVersionsAvailableSet "+devKey;
-            // Throwable t = new Throwable(msg);
-            // t.printStackTrace();
-            System.err.println(msg);
+          if (DEBUG) {
+            System.err.println(getThreadName() + ": !!! createContextARB: SET mappedVersionsAvailableSet "+devKey);
+            // Thread.dumpStack();
           }
       }
   }
   
+  /** clears the device/context mappings as well as the GL/GLX proc address tables. */
   protected static void shutdown() {
       deviceVersionAvailable.clear();
-      deviceVersionsAvailableSet.clear();
+      deviceVersionsAvailableSet.clear();      
+      GLContextImpl.shutdownImpl(); // well ..
   }
 
   /**
@@ -826,7 +828,7 @@ public abstract class GLContext {
     String key = getDeviceVersionAvailableKey(device, reqMajor, profile);
     Integer val = new Integer(compose8bit(resMajor, resMinor, resCtp, 0));
     synchronized(deviceVersionAvailable) {
-        val = (Integer) deviceVersionAvailable.put( key, val );
+        val = deviceVersionAvailable.put( key, val );
     }
     return val;
   }
@@ -835,7 +837,7 @@ public abstract class GLContext {
     String key = getDeviceVersionAvailableKey(device, reqMajor, profile);
     Integer val;
     synchronized(deviceVersionAvailable) {
-        val = (Integer) deviceVersionAvailable.get( key );
+        val = deviceVersionAvailable.get( key );
     }
     return val;
   }
@@ -877,29 +879,29 @@ public abstract class GLContext {
       return null != getAvailableGLVersion(device, major, profile);
   }
 
-    public static boolean isGLES1Available(AbstractGraphicsDevice device) {
-        return isGLVersionAvailable(device, 1, GLContext.CTX_PROFILE_ES);
-    }
+  public static boolean isGLES1Available(AbstractGraphicsDevice device) {
+      return isGLVersionAvailable(device, 1, GLContext.CTX_PROFILE_ES);
+  }
 
-    public static boolean isGLES2Available(AbstractGraphicsDevice device) {
-        return isGLVersionAvailable(device, 2, GLContext.CTX_PROFILE_ES);
-    }
+  public static boolean isGLES2Available(AbstractGraphicsDevice device) {
+      return isGLVersionAvailable(device, 2, GLContext.CTX_PROFILE_ES);
+  }
 
-    public static boolean isGL4bcAvailable(AbstractGraphicsDevice device) {
-        return isGLVersionAvailable(device, 4, CTX_PROFILE_COMPAT);
-    }
+  public static boolean isGL4bcAvailable(AbstractGraphicsDevice device) {
+      return isGLVersionAvailable(device, 4, CTX_PROFILE_COMPAT);
+  }
 
-    public static boolean isGL4Available(AbstractGraphicsDevice device) {
-        return isGLVersionAvailable(device, 4, CTX_PROFILE_CORE);
-    }
+  public static boolean isGL4Available(AbstractGraphicsDevice device) {
+      return isGLVersionAvailable(device, 4, CTX_PROFILE_CORE);
+  }
 
-    public static boolean isGL3bcAvailable(AbstractGraphicsDevice device) {
-        return isGLVersionAvailable(device, 3, CTX_PROFILE_COMPAT);
-    }
+  public static boolean isGL3bcAvailable(AbstractGraphicsDevice device) {
+      return isGLVersionAvailable(device, 3, CTX_PROFILE_COMPAT);
+  }
 
-    public static boolean isGL3Available(AbstractGraphicsDevice device) {
-        return isGLVersionAvailable(device, 3, CTX_PROFILE_CORE);
-    }
+  public static boolean isGL3Available(AbstractGraphicsDevice device) {
+      return isGLVersionAvailable(device, 3, CTX_PROFILE_CORE);
+  }
 
   public static boolean isGL2Available(AbstractGraphicsDevice device) {
     return isGLVersionAvailable(device, 2, CTX_PROFILE_COMPAT);
@@ -943,6 +945,10 @@ public abstract class GLContext {
     return sb.toString();
   }
 
+  //
+  // internal string utils 
+  //
+  
   protected static String toString(int val, boolean hex) {
     if(hex) {
         return "0x" + Integer.toHexString(val);
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawable.java b/src/jogl/classes/javax/media/opengl/GLDrawable.java
index f4cd770..2b86a04 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawable.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawable.java
@@ -158,6 +158,12 @@ public interface GLDrawable {
     */
   public GLProfile getGLProfile();
 
+  /**
+   * Returns the underlying native surface which surface handle 
+   * represents this OpenGL drawable's native resource.
+   * 
+   * @see #getHandle()
+   */
   public NativeSurface getNativeSurface();
 
   /** 
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
index 1282eb1..3f97004 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
@@ -47,12 +47,14 @@ import java.util.List;
 
 import com.jogamp.common.JogampRuntimeException;
 import jogamp.common.Debug;
+
 import com.jogamp.common.util.ReflectionUtil;
 
 import javax.media.nativewindow.AbstractGraphicsDevice;
 import javax.media.nativewindow.NativeSurface;
 import javax.media.nativewindow.NativeWindowFactory;
 import javax.media.nativewindow.ProxySurface;
+import javax.media.opengl.GLProfile.ShutdownType;
 
 /** <P> Provides a virtual machine- and operating system-independent
     mechanism for creating {@link GLDrawable}s. </P>
@@ -87,14 +89,12 @@ import javax.media.nativewindow.ProxySurface;
     property <code>opengl.factory.class.name</code> to the
     fully-qualified name of the desired class. </P>
 */
-
 public abstract class GLDrawableFactory {
 
-  private static final String nativeOSType;
   static final String macosxFactoryClassNameCGL = "jogamp.opengl.macosx.cgl.MacOSXCGLDrawableFactory";
   static final String macosxFactoryClassNameAWTCGL = "jogamp.opengl.macosx.cgl.awt.MacOSXAWTCGLDrawableFactory";
   
-  private static volatile boolean initialized = false;
+  private static volatile boolean isInit = false;
   private static GLDrawableFactory eglFactory;
   private static GLDrawableFactory nativeOSFactory;
 
@@ -107,16 +107,20 @@ public abstract class GLDrawableFactory {
   /**
    * Instantiate singleton factories if available, EGLES1, EGLES2 and the OS native ones.
    */
-  static {
-    nativeOSType = NativeWindowFactory.getNativeWindowType(true);
-  }
-
-  protected static final void initialize() {
-    if(initialized) { return; }
-    initialized = true;
-    
+  public static final void initSingleton() { 
+      if (!isInit) { // volatile: ok
+          synchronized (GLDrawableFactory.class) {
+              if (!isInit) {
+                  isInit=true;
+                  initSingletonImpl();
+              }
+          }
+      }
+  }  
+  private static final void initSingletonImpl() {
     registerFactoryShutdownHook();
     
+    final String nativeOSType = NativeWindowFactory.getNativeWindowType(true);
     GLDrawableFactory tmp = null;
     String factoryClassName = Debug.getProperty("jogl.gldrawablefactory.class.name", true, AccessController.getContext());
     ClassLoader cl = GLDrawableFactory.class.getClassLoader();
@@ -165,16 +169,40 @@ public abstract class GLDrawableFactory {
     eglFactory = tmp;
   }
 
+  protected static void shutdown(ShutdownType shutdownType) {
+    if (isInit) { // volatile: ok
+      synchronized (GLDrawableFactory.class) {
+          if (isInit) {
+              isInit=false;
+              unregisterFactoryShutdownHook();
+              shutdownImpl(shutdownType);
+          }
+      }
+    }
+  }
+  private static void shutdownImpl(ShutdownType shutdownType) {
+    synchronized(glDrawableFactories) {
+        for(int i=0; i<glDrawableFactories.size(); i++) {
+            glDrawableFactories.get(i).destroy(shutdownType);
+        }
+        glDrawableFactories.clear();
+        
+        // both were members of glDrawableFactories and are shutdown already 
+        nativeOSFactory = null;
+        eglFactory = null;
+    }
+  }
+  
   private static synchronized void registerFactoryShutdownHook() {
     if (factoryShutdownHookRegistered) {
         return;
     }
     factoryShutdownHook = new Thread(new Runnable() {
         public void run() {
-            GLDrawableFactory.shutdownImpl();
+            GLDrawableFactory.shutdownImpl(GLProfile.ShutdownType.COMPLETE);
         }
     });
-    AccessController.doPrivileged(new PrivilegedAction() {
+    AccessController.doPrivileged(new PrivilegedAction<Object>() {
         public Object run() {
             Runtime.getRuntime().addShutdownHook(factoryShutdownHook);
             return null;
@@ -187,7 +215,7 @@ public abstract class GLDrawableFactory {
     if (!factoryShutdownHookRegistered) {
         return;
     }
-    AccessController.doPrivileged(new PrivilegedAction() {
+    AccessController.doPrivileged(new PrivilegedAction<Object>() {
         public Object run() {
             Runtime.getRuntime().removeShutdownHook(factoryShutdownHook);
             return null;
@@ -196,23 +224,6 @@ public abstract class GLDrawableFactory {
     factoryShutdownHookRegistered = false;
   }
 
-  private static void shutdownImpl() {
-    synchronized(glDrawableFactories) {
-        for(int i=0; i<glDrawableFactories.size(); i++) {
-            GLDrawableFactory factory = glDrawableFactories.get(i);
-            factory.shutdownInstance();
-        }
-        glDrawableFactories.clear();
-    }
-  }
-
-  protected static void shutdown() {
-    unregisterFactoryShutdownHook();
-    shutdownImpl();
-    eglFactory = null;
-    nativeOSFactory = null;    
-    initialized = false;    
-  }
 
   protected GLDrawableFactory() {
     synchronized(glDrawableFactories) {
@@ -223,7 +234,7 @@ public abstract class GLDrawableFactory {
   protected void enterThreadCriticalZone() {};
   protected void leaveThreadCriticalZone() {};
 
-  protected abstract void shutdownInstance();
+  protected abstract void destroy(ShutdownType shutdownType);
 
   /**
    * Retrieve the default <code>device</code> {@link AbstractGraphicsDevice#getConnection() connection},
@@ -258,34 +269,31 @@ public abstract class GLDrawableFactory {
   }
 
   /**
-   * Returns true if a shared context could be created while initialization 
-   * of shared resources for <code>device</code> {@link AbstractGraphicsDevice#getConnection()}.<br>
-   * This does not imply a shared context is mapped, but was available<br>.
-   *
-   * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be <code>null</code> for the platform's default device.
+   * Validate and start the shared resource runner thread if necessary and 
+   * if the implementation uses it.
+   * 
+   * @return the shared resource runner thread, if implementation uses it.
    */
-  public abstract boolean getWasSharedContextCreated(AbstractGraphicsDevice device);
-
+  protected abstract Thread getSharedResourceThread();
+  
   /**
-   * Returns the shared context mapped to the <code>device</code> {@link AbstractGraphicsDevice#getConnection()},
-   * either a pre-existing or newly created, or <code>null</code> if creation failed or not supported.<br>
-   * Creation of the shared context is tried only once.
+   * Create the shared resource used internally as a reference for capabilities etc.
+   * <p>
+   * Returns true if a shared resource could be created 
+   * for the <code>device</code> {@link AbstractGraphicsDevice#getConnection()}.<br>
+   * This does not imply a shared resource is mapped (ie. made persistent), but is available in general<br>.
+   * </p>
    *
    * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be <code>null</code> for the platform's default device.
+   * @return true if a shared resource could been created, otherwise false. 
    */
-  public final GLContext getOrCreateSharedContext(AbstractGraphicsDevice device) {
-      device = validateDevice(device);
-      if(null!=device) {
-        return getOrCreateSharedContextImpl(device);
-      }
-      return null;
-  }
-  protected abstract GLContext getOrCreateSharedContextImpl(AbstractGraphicsDevice device);
-
+  protected abstract boolean createSharedResource(AbstractGraphicsDevice device);
+  
   /**
    * Returns the sole GLDrawableFactory instance for the desktop (X11, WGL, ..) if exist or null
    */
   public static GLDrawableFactory getDesktopFactory() {
+    GLProfile.initSingleton();    
     return nativeOSFactory;
   }
 
@@ -293,6 +301,7 @@ public abstract class GLDrawableFactory {
    * Returns the sole GLDrawableFactory instance for EGL if exist or null
    */
   public static GLDrawableFactory getEGLFactory() {
+    GLProfile.initSingleton();    
     return eglFactory;
   }
 
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index 7367d58..6b39fe7 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -48,6 +48,8 @@ import com.jogamp.common.os.Platform;
 import com.jogamp.common.util.ReflectionUtil;
 import com.jogamp.common.util.VersionUtil;
 import com.jogamp.common.util.cache.TempJarCache;
+import com.jogamp.common.util.locks.LockFactory;
+import com.jogamp.common.util.locks.RecursiveThreadGroupLock;
 import com.jogamp.nativewindow.NativeWindowVersion;
 import com.jogamp.opengl.JoglVersion;
 
@@ -74,56 +76,80 @@ public class GLProfile {
     
     public static final boolean DEBUG = Debug.debug("GLProfile");
 
+    static {
+        // Also initializes TempJarCache if shall be used.
+        Platform.initSingleton();
+    }
+    
     /**
-     * Static one time initialization of JOGL.
+     * Static initialization of JOGL.
      * <p>
      * The parameter <code>firstUIActionOnProcess</code> has an impact on concurrent locking,<br>
      * see {@link javax.media.nativewindow.NativeWindowFactory#initSingleton(boolean) NativeWindowFactory.initSingleton(firstUIActionOnProcess)}.
      * </p>
      * <p>
-     * Applications shall call this methods <b>ASAP</b>, before any other UI invocation.<br>
-     * You may issue the call in your <code>main class</code> static block, which is the earliest point in your application/applet lifecycle,
-     * or within the <code>main function</code>.<br>
-     * In case applications are able to initialize JOGL before any other UI action,<br>
-     * they shall invoke this method with <code>firstUIActionOnProcess=true</code> and benefit from fast native multithreading support on all platforms if possible.</P>
+     * Applications using this method may place it's call before any other UI invocation
+     * in the <code>main class</code>'s static block or within the <code>main function</code>.
+     * In such case, applications may pass <code>firstUIActionOnProcess=true</code> to use native toolkit locking.</P>
      * <P>
-     * RCP Application (Applet's, Webstart, Netbeans, ..) using JOGL may not be able to initialize JOGL
-     * before the first UI action.<br>
-     * In such case you shall invoke this method with <code>firstUIActionOnProcess=false</code>.<br>
-     * On some platforms, notably X11 with AWT usage, JOGL will utilize special locking mechanisms which may slow down your
-     * application.</P>
+     * RCP Application (Applet's, Webstart, Netbeans, ..) using JOGL are not be able to initialize JOGL
+     * before the first UI action.
+     * In such case you shall pass <code>firstUIActionOnProcess=false</code>.</P>
      * <P>
-     * Remark: NEWT is currently not affected by this behavior, ie always uses native multithreading.</P>
-     * <P>
-     * However, in case this method is not invoked, hence GLProfile is not initialized explicitly by the user,<br>
-     * the first call to {@link #getDefault()}, {@link #get(java.lang.String)}, etc, will initialize with <code>firstUIActionOnProcess=false</code>,<br>
-     * hence without the possibility to enable native multithreading.<br>
-     * This is not the recommended way, since it may has a performance impact, but it allows you to run code without explicit initialization.</P>
+     * In case this method is not invoked, GLProfile is initialized implicit by
+     * the first call to {@link #getDefault()}, {@link #get(java.lang.String)} passing <code>firstUIActionOnProcess=false</code>.
      * <P>
      *
      * @param firstUIActionOnProcess Should be <code>true</code> if called before the first UI action of the running program,
      * otherwise <code>false</code>.
+     * 
+     * @deprecated This method shall not need to be called for other reasons than having a defined initialization sequence.
+     *             To ensure homogeneous behavior with application not calling this method, you shall pass <code>firstUIActionOnProcess=false</code>.
+     *             This method is subject to be removed in future versions of JOGL. 
      */
-    public static synchronized void initSingleton(final boolean firstUIActionOnProcess) {
-        if(!initialized) {
-            initialized = true;
-            // run the whole static initialization privileged to speed up,
-            // since this skips checking further access
-            AccessController.doPrivileged(new PrivilegedAction<Object>() {
-                public Object run() {
-                    if(TempJarCache.isInitialized()) {
-                       String[] atomicNativeJarBaseNames = new String[] { "nativewindow", "jogl", null };
-                       if( ReflectionUtil.isClassAvailable("com.jogamp.newt.NewtFactory", GLProfile.class.getClassLoader()) ) {
-                           atomicNativeJarBaseNames[2] = "newt";
-                       }
-                       JNILibLoaderBase.addNativeJarLibs(GLProfile.class, "jogl.all", "jogl-all", atomicNativeJarBaseNames);
-                    }
-                    initProfilesForDefaultDevices(firstUIActionOnProcess);
-                    return null;
+    public static void initSingleton(final boolean firstUIActionOnProcess) {
+        initLock.lock();
+        try {
+            if(!initialized) { // volatile: ok
+                initialized = true;
+                if(DEBUG) {
+                    System.err.println("GLProfile.initSingleton(firstUIActionOnProcess: "+firstUIActionOnProcess+") - thread "+Thread.currentThread().getName());
+                    Thread.dumpStack();
                 }
-            });
+    
+                // run the whole static initialization privileged to speed up,
+                // since this skips checking further access
+                AccessController.doPrivileged(new PrivilegedAction<Object>() {
+                    public Object run() {
+                        Platform.initSingleton();
+                        
+                        if(TempJarCache.isInitialized()) {
+                           String[] atomicNativeJarBaseNames = new String[] { "nativewindow", "jogl", null };
+                           if( ReflectionUtil.isClassAvailable("com.jogamp.newt.NewtFactory", GLProfile.class.getClassLoader()) ) {
+                               atomicNativeJarBaseNames[2] = "newt";
+                           }
+                           JNILibLoaderBase.addNativeJarLibs(GLProfile.class, "jogl-all", atomicNativeJarBaseNames);
+                        }
+                        initProfilesForDefaultDevices(firstUIActionOnProcess);
+                        return null;
+                    }
+                });
+            }
+        } finally {
+            initLock.unlock();
         }
     }
+    
+    /**
+     * Static initialization of JOGL.
+     *
+     * <p>
+     * This method shall not need to be called for other reasons than having a defined initialization sequence.
+     * </p>
+     */
+    public static void initSingleton() {
+        GLProfile.initSingleton(false);
+    }
 
     /**
      * Trigger eager initialization of GLProfiles for the given device,
@@ -132,21 +158,50 @@ public class GLProfile {
      * @throws GLException if no profile for the given device is available.
      */
     public static void initProfiles(AbstractGraphicsDevice device) throws GLException {
-        getProfileMap(device);
+        getProfileMap(device, true);
     }
 
+    /** 
+     * Shutdown type for {@link GLProfile#shutdown(ShutdownType)}.
+     * <p>
+     * {@link #SHARED_ONLY} For thread based resources only, suitable for eg. {@link java.applet.Applet Applet} restart.<br>
+     * {@link #COMPLETE} Everything.<br>
+     * </p>
+     */ 
+    public enum ShutdownType {
+        /* Shared thread based resources only, eg. for Applets */ 
+        SHARED_ONLY,
+        /* Everything */
+        COMPLETE;
+    }
+    
     /**
      * Manual shutdown method, may be called after your last JOGL use
      * within the running JVM.<br>
      * It releases all temporary created resources, ie issues {@link javax.media.opengl.GLDrawableFactory#shutdown()}.<br>
-     * The shutdown implementation is called via the JVM shutdown hook, if not manually invoked here.<br>
-     * Invoke <code>shutdown()</code> manually is recommended, due to the unreliable JVM state within the shutdown hook.<br>
+     * The shutdown implementation is called via the JVM shutdown hook, if not manually invoked.<br>
+     * <p>
+     * This method shall not need to be called for other reasons than issuing a proper shutdown of resources.
+     * </p>
+     * @param type the shutdown type, see {@link ShutdownType}.
      */
-    public static synchronized void shutdown() {
-        if(initialized) {
-            initialized = false;
-            GLDrawableFactory.shutdown();
-            GLContext.shutdown();
+    public static void shutdown(ShutdownType type) {
+        initLock.lock();
+        try {
+            if(initialized) { // volatile: ok
+                initialized = false;
+                if(DEBUG) {
+                    System.err.println("GLProfile.shutdown(type: "+type+") - thread "+Thread.currentThread().getName());
+                    Thread.dumpStack();
+                }                    
+                GLDrawableFactory.shutdown(type);
+                if(ShutdownType.COMPLETE == type) {
+                    GLContext.shutdown();
+                }
+                NativeWindowFactory.shutdown();
+            }
+        } finally {
+            initLock.unlock();
         }
     }
 
@@ -163,12 +218,13 @@ public class GLProfile {
      * @return true if the profile is available for the device, otherwise false.
      */
     public static boolean isAvailable(AbstractGraphicsDevice device, String profile) {
-        try {
-            return null != getProfileMap(device).get(profile);
-        } catch (GLException gle) { /* profiles for device n/a */ }
-        return false;
+        initSingleton();
+        return isAvailableImpl(getProfileMap(device, false), profile);
     }
-
+    private static boolean isAvailableImpl(HashMap<String /*GLProfile_name*/, GLProfile> map, String profile) {
+        return null != map && null != map.get(profile);
+    }
+    
     /** 
      * Returns the availability of a profile on the default device.
      * 
@@ -193,74 +249,71 @@ public class GLProfile {
         boolean avail;
         StringBuffer sb = new StringBuffer();
 
-        validateInitialization();
-
+        initSingleton();
+        
         if(null==device) {
             device = defaultDevice;
         }
-
+        final HashMap<String /*GLProfile_name*/, GLProfile> map = getProfileMap(device, false);
+        
         sb.append("GLAvailability[Native[GL4bc ");
-        avail=isAvailable(device, GL4bc);
+        avail=isAvailableImpl(map, GL4bc);
         sb.append(avail);
         if(avail) {
             glAvailabilityToString(device, sb, 4, GLContext.CTX_PROFILE_COMPAT);
         }
 
         sb.append(", GL4 ");
-        avail=isAvailable(device, GL4);
+        avail=isAvailableImpl(map, GL4);
         sb.append(avail);
         if(avail) {
             glAvailabilityToString(device, sb, 4, GLContext.CTX_PROFILE_CORE);
         }
 
         sb.append(", GL3bc ");
-        avail=isAvailable(device, GL3bc);
+        avail=isAvailableImpl(map, GL3bc);
         sb.append(avail);
         if(avail) {
             glAvailabilityToString(device, sb, 3, GLContext.CTX_PROFILE_COMPAT);
         }
 
         sb.append(", GL3 ");
-        avail=isAvailable(device, GL3);
+        avail=isAvailableImpl(map, GL3);
         sb.append(avail);
         if(avail) {
             glAvailabilityToString(device, sb, 3, GLContext.CTX_PROFILE_CORE);
         }
 
         sb.append(", GL2 ");
-        avail=isAvailable(device, GL2);
+        avail=isAvailableImpl(map, GL2);
         sb.append(avail);
         if(avail) {
             glAvailabilityToString(device, sb, 2, GLContext.CTX_PROFILE_COMPAT);
         }
 
         sb.append(", GL2ES1 ");
-        sb.append(isAvailable(device, GL2ES1));
+        sb.append(isAvailableImpl(map, GL2ES1));
 
         sb.append(", GLES1 ");
-        avail=isAvailable(device, GLES1);
+        avail=isAvailableImpl(map, GLES1);
         sb.append(avail);
         if(avail) {
             glAvailabilityToString(device, sb, 1, GLContext.CTX_PROFILE_ES);
         }
 
         sb.append(", GL2ES2 ");
-        sb.append(isAvailable(device, GL2ES2));
+        sb.append(isAvailableImpl(map, GL2ES2));
 
         sb.append(", GLES2 ");
-        avail=isAvailable(device, GLES2);
+        avail=isAvailableImpl(map, GLES2);
         sb.append(avail);
         if(avail) {
             glAvailabilityToString(device, sb, 2, GLContext.CTX_PROFILE_ES);
         }
 
         sb.append("], Profiles[");
-        HashMap<String /*GLProfile_name*/, GLProfile> profileMap = null;
-        try {
-            profileMap = getProfileMap(device);
-        } catch (GLException gle) { /* profiles for device n/a */ }
-        if(null != profileMap) {
-            for(Iterator<GLProfile> i=profileMap.values().iterator(); i.hasNext(); ) {
+        if(null != map) {
+            for(Iterator<GLProfile> i=map.values().iterator(); i.hasNext(); ) {
                 sb.append(i.next().toString());
                 sb.append(", ");
             }
@@ -275,7 +328,7 @@ public class GLProfile {
 
         return sb.toString();
     }
-
+    
     /** Uses the default device */
     public static String glAvailabilityToString() {
         return glAvailabilityToString(null);
@@ -416,31 +469,6 @@ public class GLProfile {
      */
     public static final String[] GL_PROFILE_LIST_MAX_PROGSHADER   = new String[] { GL4bc, GL4, GL3bc, GL3, GL2, GLES2 };
 
-    /**
-     * All GL2ES2 Profiles in the order of default detection.
-     *
-     * @see #GL_PROFILE_LIST_MAX_PROGSHADER
-     */
-    public static final String[] GL_PROFILE_LIST_GL2ES2 = GL_PROFILE_LIST_MAX_PROGSHADER;
-
-    /**
-     * All GL2ES1 Profiles in the order of default detection.
-     *
-     * @see #GL_PROFILE_LIST_MAX_FIXEDFUNC
-     */
-    public static final String[] GL_PROFILE_LIST_GL2ES1 = GL_PROFILE_LIST_MAX_FIXEDFUNC;
-
-    /**
-     * All GLES Profiles in the order of default detection.
-     *
-     * <ul>
-     *  <li> GLES2
-     *  <li> GLES1
-     * </ul>
-     *
-     */
-    public static final String[] GL_PROFILE_LIST_GLES = new String[] { GLES2, GLES1 };
-
     /** Returns a default GLProfile object, reflecting the best for the running platform.
      * It selects the first of the set {@link GLProfile#GL_PROFILE_LIST_ALL}
      * @throws GLException if no profile is available for the device.
@@ -551,56 +579,58 @@ public class GLProfile {
         return get(GL_PROFILE_LIST_MAX_PROGSHADER);
     }
 
-    /**
-     * Returns an available GL2ES1 compatible profile.
-     * It returns the first available of the set: {@link GLProfile#GL_PROFILE_LIST_GL2ES1}.
-     * 
-     * @throws GLException if no GL2ES1 compatible profile is available for the device.
-     * @see #GL_PROFILE_LIST_GL2ES1
+    /** 
+     * Returns the GL2ES1 profile implementation, hence compatible w/ GL2ES1.<br/>
+     * It returns:
+     * <pre>
+     *   GLProfile.get(device, GLProfile.GL2ES1).getImpl());
+     * </pre>
+     *
+     * @throws GLException if no GL2ES1 compatible profile is available for the default device.
+     * @see #get(AbstractGraphicsDevice, String)
+     * @see #getImpl()
      */
     public static GLProfile getGL2ES1(AbstractGraphicsDevice device)
         throws GLException
     {
-        return get(device, GL_PROFILE_LIST_GL2ES1);
+        return get(device, GL2ES1).getImpl();
     }
 
-    /**
-     * Returns an available GL2ES1 compatible profile.
-     * It returns the first available of the set: {@link GLProfile#GL_PROFILE_LIST_GL2ES1}.
-     * 
-     * @throws GLException if no GL2ES1 compatible profile is available for the default device.
-     * @see #GL_PROFILE_LIST_GL2ES1
+    /** 
+     * Calls {@link #getGL2ES1(AbstractGraphicsDevice)} using the default device. 
+     * @see #getGL2ES1(AbstractGraphicsDevice)
      */
     public static GLProfile getGL2ES1()
         throws GLException
     {
-        return get(GL_PROFILE_LIST_GL2ES1);
+        return get(defaultDevice, GL2ES1).getImpl();
     }
 
-    /**
-     * Returns an available GL2ES2 compatible profile.
-     * It returns the first available of the set: {@link GLProfile#GL_PROFILE_LIST_GL2ES2}.
+    /** 
+     * Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.<br/>
+     * It returns:
+     * <pre>
+     *   GLProfile.get(device, GLProfile.GL2ES2).getImpl());
+     * </pre>
      *
-     * @throws GLException if no GL2ES2 compatible profile is available for the device.
-     * @see #GL_PROFILE_LIST_GL2ES2
+     * @throws GLException if no GL2ES2 compatible profile is available for the default device.
+     * @see #get(AbstractGraphicsDevice, String)
+     * @see #getImpl()
      */
     public static GLProfile getGL2ES2(AbstractGraphicsDevice device)
         throws GLException
     {
-        return get(device, GL_PROFILE_LIST_GL2ES2);
+        return get(device, GL2ES2).getImpl();
     }
 
     /** 
-     * Returns an available GL2ES2 compatible profile
-     * It returns the first available of the set: {@link GLProfile#GL_PROFILE_LIST_GL2ES2}.
-     *
-     * @throws GLException if no GL2ES2 compatible profile is available for the default device.
-     * @see #GL_PROFILE_LIST_GL2ES2
+     * Calls {@link #getGL2ES2(AbstractGraphicsDevice)} using the default device. 
+     * @see #getGL2ES2(AbstractGraphicsDevice)
      */
     public static GLProfile getGL2ES2()
         throws GLException
     {
-        return get(GL_PROFILE_LIST_GL2ES2);
+        return get(defaultDevice, GL2ES2).getImpl();
     }
 
     /** Returns a GLProfile object.
@@ -619,7 +649,7 @@ public class GLProfile {
         if(null==profile || profile.equals("GL")) {
             profile = GL_DEFAULT;
         }
-        final HashMap<String /*GLProfile_name*/, GLProfile> glpMap = getProfileMap(device);
+        final HashMap<String /*GLProfile_name*/, GLProfile> glpMap = getProfileMap(device, true);
         final GLProfile glp = glpMap.get(profile);
         if(null == glp) {
             throw new GLException("Profile "+profile+" is not available on "+device+", but: "+glpMap.values());
@@ -649,7 +679,7 @@ public class GLProfile {
     public static GLProfile get(AbstractGraphicsDevice device, String[] profiles)
         throws GLException
     {
-        HashMap<String /*GLProfile_name*/, GLProfile> map = getProfileMap(device);
+        HashMap<String /*GLProfile_name*/, GLProfile> map = getProfileMap(device, true);
         for(int i=0; i<profiles.length; i++) {
             String profile = profiles[i];
             GLProfile glProfile = map.get(profile);
@@ -669,7 +699,7 @@ public class GLProfile {
     {
         return get(defaultDevice, profiles);
     }
-
+    
     /** Indicates whether the native OpenGL ES1 profile is in use. 
      * This requires an EGL interface.
      */
@@ -738,7 +768,7 @@ public class GLProfile {
     }
 
     public final String getGLImplBaseClassName() {
-        return getGLImplBaseClassName(profileImpl);
+        return getGLImplBaseClassName(getImplName());
     }
 
     /**
@@ -750,15 +780,15 @@ public class GLProfile {
         if(this==o) { return true; }
         if(o instanceof GLProfile) {
             GLProfile glp = (GLProfile)o;
-            return profile.equals(glp.getName()) && profileImpl.equals(glp.getImplName()) ;
+            return getName().equals(glp.getName()) && getImplName().equals(glp.getImplName()) ;
         }
         return false;
     }
 
     public int hashCode() {
         int hash = 5;
-        hash = 97 * hash + (this.profileImpl != null ? this.profileImpl.hashCode() : 0);
-        hash = 97 * hash + (this.profile != null ? this.profile.hashCode() : 0);
+        hash = 97 * hash + getImplName().hashCode();
+        hash = 97 * hash + getName().hashCode();
         return hash;
     }
  
@@ -772,12 +802,21 @@ public class GLProfile {
         }
     }
 
+    /** return this profiles name */
     public final String getName() {
         return profile;
     }
 
+    /** return this profiles implementation, eg. GL2ES2 -> GL2, or GL3 -> GL3 */
+    public final GLProfile getImpl() {
+        return null != profileImpl ? profileImpl : this;
+    }
+    
+    /** 
+     * return this profiles implementation name, eg. GL2ES2 -> GL2, or GL3 -> GL3 
+     */
     public final String getImplName() {
-        return profileImpl;
+        return null != profileImpl ? profileImpl.getName() : getName();
     }
 
     /** Indicates whether this profile is capable of GL4bc. */
@@ -837,12 +876,12 @@ public class GLProfile {
 
     /** Indicates whether this profile uses the native OpenGL ES1 implementations. */
     public final boolean usesNativeGLES1() {
-        return GLES1.equals(profileImpl);
+        return GLES1.equals(getImplName());
     }
 
     /** Indicates whether this profile uses the native OpenGL ES2 implementations. */
     public final boolean usesNativeGLES2() {
-        return GLES2.equals(profileImpl);
+        return GLES2.equals(getImplName());
     }
 
     /** Indicates whether this profile uses either of the native OpenGL ES implementations. */
@@ -1148,11 +1187,7 @@ public class GLProfile {
     }
 
     public String toString() {
-        return "GLProfile[" + profile + "/" + profileImpl + "]";
-    }
-
-    static {
-        Platform.initSingleton();
+        return "GLProfile[" + getName() + "/" + getImplName() + "]";
     }
 
     private static /*final*/ boolean isAWTAvailable;
@@ -1169,7 +1204,8 @@ public class GLProfile {
     private static /*final*/ AbstractGraphicsDevice defaultDesktopDevice;
     private static /*final*/ AbstractGraphicsDevice defaultEGLDevice;
 
-    static boolean initialized = false;
+    private static volatile boolean initialized = false;
+    private static RecursiveThreadGroupLock initLock = LockFactory.createRecursiveThreadGroupLock();
 
     /**
      * Tries the profiles implementation and native libraries.
@@ -1205,7 +1241,7 @@ public class GLProfile {
         // - Instantiate GLDrawableFactory incl its shared dummy drawable/context,
         //   which will register at GLContext ..
         //
-        GLDrawableFactory.initialize();
+        GLDrawableFactory.initSingleton();
         
         Throwable t=null;
         // if successfull it has a shared dummy drawable and context created
@@ -1309,19 +1345,24 @@ public class GLProfile {
      * @param device the device for which profiles shall be initialized
      * @return true if any profile for the device exists, otherwise false
      */
-    private static synchronized boolean initProfilesForDevice(AbstractGraphicsDevice device) {
+    private static boolean initProfilesForDevice(AbstractGraphicsDevice device) {
         if(null == device) {
             return false;
         }
-        GLDrawableFactory factory = GLDrawableFactory.getFactoryImpl(device);
-        factory.enterThreadCriticalZone();
+        initLock.lock();
         try {
-            return initProfilesForDeviceCritical(device);
+            GLDrawableFactory factory = GLDrawableFactory.getFactoryImpl(device);
+            factory.enterThreadCriticalZone();
+            try {
+                return initProfilesForDeviceCritical(device);
+            } finally {
+                factory.leaveThreadCriticalZone();
+            }
         } finally {
-            factory.leaveThreadCriticalZone();
+            initLock.unlock();
         }
     }
-    private static synchronized boolean initProfilesForDeviceCritical(AbstractGraphicsDevice device) {
+    private static boolean initProfilesForDeviceCritical(AbstractGraphicsDevice device) {
         boolean isSet = GLContext.getAvailableGLVersionsSet(device);
 
         if(DEBUG) {
@@ -1345,11 +1386,21 @@ public class GLProfile {
 
             // Triggers eager initialization of share context in GLDrawableFactory for the device,
             // hence querying all available GLProfiles
-            boolean desktopSharedCtxAvail = desktopFactory.getWasSharedContextCreated(device);
+            final Thread sharedResourceThread = desktopFactory.getSharedResourceThread();
+            if(null != sharedResourceThread) {
+                initLock.addOwner(sharedResourceThread);
+            }
+            boolean desktopSharedCtxAvail = desktopFactory.createSharedResource(device);
+            if(null != sharedResourceThread) {
+                initLock.removeOwner(sharedResourceThread);
+            }
+            if(!desktopSharedCtxAvail) {
+                hasDesktopGLFactory = false;
+            }
             if (DEBUG) {
                 System.err.println("GLProfile.initProfilesForDevice: "+device+": desktop Shared Ctx "+desktopSharedCtxAvail);
             }
-            if( null == GLContext.getAvailableGLVersion(device, 2, GLContext.CTX_PROFILE_COMPAT) ) {
+            if( hasDesktopGLFactory && null == GLContext.getAvailableGLVersion(device, 2, GLContext.CTX_PROFILE_COMPAT) ) {
                 // nobody yet set the available desktop versions, see {@link GLContextImpl#makeCurrent},
                 // so we have to add the usual suspect
                 GLContext.mapAvailableGLVersion(device,
@@ -1364,7 +1415,22 @@ public class GLProfile {
 
             // Triggers eager initialization of share context in GLDrawableFactory for the device,
             // hence querying all available GLProfiles
-            boolean eglSharedCtxAvail = eglFactory.getWasSharedContextCreated(device);
+            final Thread sharedResourceThread = eglFactory.getSharedResourceThread();
+            if(null != sharedResourceThread) {
+                initLock.addOwner(sharedResourceThread);
+            }
+            boolean eglSharedCtxAvail = eglFactory.createSharedResource(device);
+            if(null != sharedResourceThread) {
+                initLock.removeOwner(sharedResourceThread);
+            }
+            if(!eglSharedCtxAvail) {
+                // Remark: On Windows there is a libEGL.dll delivered w/ Chrome 15.0.874.121m and Firefox 8.0.1
+                // but it seems even EGL.eglInitialize(eglDisplay, null, null) 
+                // fails in some scenarios (eg VirtualBox 4.1.6) w/ EGL error 0x3001 (EGL_NOT_INITIALIZED).
+                hasEGLFactory = false;
+                hasGLES2Impl = false;
+                hasGLES1Impl = false;
+            }
             if (DEBUG) {
                 System.err.println("GLProfile.initProfilesForDevice: "+device+": egl Shared Ctx "+eglSharedCtxAvail);
             }
@@ -1437,30 +1503,20 @@ public class GLProfile {
     }
 
     public static AbstractGraphicsDevice getDefaultDevice() {
-        validateInitialization();
+        initSingleton();
         return defaultDevice;
     }
 
     public static AbstractGraphicsDevice getDefaultDesktopDevice() {
-        validateInitialization();
+        initSingleton();
         return defaultDesktopDevice;
     }
 
     public static AbstractGraphicsDevice getDefaultEGLDevice() {
-        validateInitialization();
+        initSingleton();
         return defaultEGLDevice;
     }
 
-    private static void validateInitialization() {
-        if(!initialized) {
-            synchronized(GLProfile.class) {
-                if(!initialized) {
-                    initSingleton(false);
-                }
-            }
-        }
-    }
-
     private static String array2String(String[] list) {
         StringBuffer msg = new StringBuffer();
         msg.append("[");
@@ -1493,7 +1549,16 @@ public class GLProfile {
             String profile = GL_PROFILE_LIST_ALL[i];
             String profileImpl = computeProfileImpl(device, profile, desktopCtxUndef, esCtxUndef);
             if(null!=profileImpl) {
-                GLProfile glProfile = new GLProfile(profile, profileImpl);
+                final GLProfile glProfile;
+                if(profile.equals(profileImpl)) {
+                    glProfile = new GLProfile(profile, null);
+                } else {
+                    final GLProfile _mglp = _mappedProfiles.get(profileImpl);
+                    if(null == _mglp) {
+                        throw new InternalError("XXX0");
+                    }
+                    glProfile = new GLProfile(profile, _mglp);
+                }
                 _mappedProfiles.put(profile, glProfile);
                 if (DEBUG) {
                     System.err.println("GLProfile.init map "+glProfile+" on devide "+device.getConnection());
@@ -1521,6 +1586,10 @@ public class GLProfile {
      * Returns the profile implementation
      */
     private static String computeProfileImpl(AbstractGraphicsDevice device, String profile, boolean desktopCtxUndef, boolean esCtxUndef) {
+        // OSX GL3.. doesn't support GLSL<150, 
+        // hence GL2ES2 and GL2GL3 need to be mapped on GL2 on OSX for GLSL compatibility.
+        final boolean isOSX = Platform.OS_TYPE == Platform.OSType.MACOS;
+        
         if (GL2ES1.equals(profile)) {
             if(hasGL234Impl) {
                 if(GLContext.isGL4bcAvailable(device)) {
@@ -1536,13 +1605,13 @@ public class GLProfile {
             }
         } else if (GL2ES2.equals(profile)) {
             if(hasGL234Impl) {
-                if(GLContext.isGL4bcAvailable(device)) {
+                if(!isOSX && GLContext.isGL4bcAvailable(device)) {
                     return GL4bc;
-                } else if(GLContext.isGL4Available(device)) {
+                } else if(!isOSX && GLContext.isGL4Available(device)) {
                     return GL4;
-                } else if(GLContext.isGL3bcAvailable(device)) {
+                } else if(!isOSX && GLContext.isGL3bcAvailable(device)) {
                     return GL3bc;
-                } else if(GLContext.isGL3Available(device)) {
+                } else if(!isOSX && GLContext.isGL3Available(device)) {
                     return GL3;
                 } else if(desktopCtxUndef || GLContext.isGL2Available(device)) {
                     return GL2;
@@ -1553,13 +1622,13 @@ public class GLProfile {
             }
         } else if(GL2GL3.equals(profile)) {
             if(hasGL234Impl) {
-                if(GLContext.isGL4bcAvailable(device)) {
+                if(!isOSX && GLContext.isGL4bcAvailable(device)) {
                     return GL4bc;
-                } else if(GLContext.isGL4Available(device)) {
+                } else if(!isOSX && GLContext.isGL4Available(device)) {
                     return GL4;
-                } else if(GLContext.isGL3bcAvailable(device)) {
+                } else if(!isOSX && GLContext.isGL3bcAvailable(device)) {
                     return GL3bc;
-                } else if(GLContext.isGL3Available(device)) {
+                } else if(!isOSX && GLContext.isGL3Available(device)) {
                     return GL3;
                 } else if(desktopCtxUndef || GLContext.isGL2Available(device)) {
                     return GL2;
@@ -1609,39 +1678,48 @@ public class GLProfile {
      *  - initialization<br<
      *
      * @param device the key 'device -> GLProfiles-Map'
+     * @param throwExceptionOnZeroProfile true if <code>GLException</code> shall be thrown in case of no mapped profile, otherwise false.
      * @return the GLProfile HashMap if exists, otherwise null 
      * @throws GLException if no profile for the given device is available.
      */
-    private static HashMap<String /*GLProfile_name*/, GLProfile> getProfileMap(AbstractGraphicsDevice device) throws GLException {
-        validateInitialization();
+    private static HashMap<String /*GLProfile_name*/, GLProfile> getProfileMap(AbstractGraphicsDevice device, boolean throwExceptionOnZeroProfile) 
+        throws GLException 
+    {
+        initSingleton();
+
         if(null==device) {
             device = defaultDevice;
         }
         String deviceKey = device.getUniqueID();
         HashMap<String /*GLProfile_name*/, GLProfile> map = deviceConn2ProfileMap.get(deviceKey);
-        if( null == map ) {
-            if( !initProfilesForDevice(device) ) {
+        if( null != map ) {
+            return map;
+        }
+        if( !initProfilesForDevice(device) ) {
+            if( throwExceptionOnZeroProfile ) {
                 throw new GLException("No Profile available for "+device);
+            } else {
+                return null;
             }
-            if( null == deviceConn2ProfileMap.get(deviceKey) ) {
-                throw new InternalError("initProfilesForDevice(..) didn't issue setProfileMap(..) on "+device);
-            }
+        }
+        map = deviceConn2ProfileMap.get(deviceKey);
+        if( null == map && throwExceptionOnZeroProfile ) {
+            throw new InternalError("initProfilesForDevice(..) didn't setProfileMap(..) for "+device);
         }
         return map;
     }
 
     private static void setProfileMap(AbstractGraphicsDevice device, HashMap<String /*GLProfile_name*/, GLProfile> mappedProfiles) {
-        validateInitialization();
         synchronized ( deviceConn2ProfileMap ) {
             deviceConn2ProfileMap.put(device.getUniqueID(), mappedProfiles);
         }
     }
 
-    private GLProfile(String profile, String profileImpl) {
+    private GLProfile(String profile, GLProfile profileImpl) {
         this.profile = profile;
         this.profileImpl = profileImpl;
     }
 
-    private String profileImpl = null;
+    private GLProfile profileImpl = null;
     private String profile = null;
 }
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 48c1c54..e909416 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -59,8 +59,8 @@ import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.media.nativewindow.OffscreenLayerOption;
 import javax.media.nativewindow.WindowClosingProtocol;
-import javax.media.nativewindow.AbstractGraphicsConfiguration;
 import javax.media.nativewindow.AbstractGraphicsDevice;
 import javax.media.nativewindow.AbstractGraphicsScreen;
 import javax.media.nativewindow.GraphicsConfigurationFactory;
@@ -92,6 +92,8 @@ import com.jogamp.opengl.JoglVersion;
 
 import com.jogamp.common.util.locks.LockFactory;
 import com.jogamp.common.util.locks.RecursiveLock;
+
+import jogamp.nativewindow.jawt.JAWTWindow;
 import jogamp.opengl.Debug;
 import jogamp.opengl.GLContextImpl;
 import jogamp.opengl.GLDrawableHelper;
@@ -136,7 +138,7 @@ import jogamp.opengl.ThreadingImpl;
  */
 
 @SuppressWarnings("serial")
-public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosingProtocol {
+public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosingProtocol, OffscreenLayerOption {
 
   private static final boolean DEBUG;
 
@@ -156,6 +158,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
   private GLContext shareWith;
   private int additionalCtxCreationFlags = 0;  
   private GraphicsDevice device;
+  private boolean shallUseOffscreenLayer = false;
 
   private AWTWindowClosingProtocol awtWindowClosingProtocol =
           new AWTWindowClosingProtocol(this, new Runnable() {
@@ -250,6 +253,22 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
     this.device = device;
   }
 
+  public void setShallUseOffscreenLayer(boolean v) {
+      shallUseOffscreenLayer = v;
+  }
+
+  public final boolean getShallUseOffscreenLayer() {
+      return shallUseOffscreenLayer;        
+  }
+
+  public final boolean isOffscreenLayerSurfaceEnabled() {
+      if(null != drawable) {
+          return ((JAWTWindow)drawable.getNativeSurface()).isOffscreenLayerSurfaceEnabled();
+      }
+      return false;
+  }
+
+  
   /**
    * Overridden to choose a GraphicsConfiguration on a parent container's
    * GraphicsDevice because both devices
@@ -279,7 +298,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
      * otherwise it is from an ancestor component that this Canvas is being
      * added to, and we go into this block.
      */
-    GraphicsConfiguration chosen =  awtConfig.getGraphicsConfiguration();
+    GraphicsConfiguration chosen =  awtConfig.getAWTGraphicsConfiguration();
 
     if (gc != null && chosen != null && !chosen.equals(gc)) {
       /*
@@ -308,7 +327,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
         AWTGraphicsConfiguration config = chooseGraphicsConfiguration( (GLCapabilitiesImmutable)awtConfig.getChosenCapabilities(),
                                                                        (GLCapabilitiesImmutable)awtConfig.getRequestedCapabilities(),
                                                                        chooser, gc.getDevice());
-        final GraphicsConfiguration compatible = (null!=config)?config.getGraphicsConfiguration():null;
+        final GraphicsConfiguration compatible = (null!=config)?config.getAWTGraphicsConfiguration():null;
         boolean equalCaps = config.getChosenCapabilities().equals(awtConfig.getChosenCapabilities());
         if(DEBUG) {
             Exception e = new Exception("Info: Call Stack: "+Thread.currentThread().getName());
@@ -406,15 +425,15 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
   private void dispose(boolean regenerate) {
     drawableSync.lock();
     try {
+        final GLAnimatorControl animator =  getAnimator();
         if(DEBUG) {
-            Exception ex1 = new Exception("Info: dispose("+regenerate+") - start, hasContext " +
-                    (null!=context) + ", hasDrawable " + (null!=drawable));
+            Exception ex1 = new Exception("Info: dispose("+regenerate+") - START, hasContext " +
+                    (null!=context) + ", hasDrawable " + (null!=drawable)+", "+animator);
             ex1.printStackTrace();
         }
 
         if(null!=context) {
             boolean animatorPaused = false;
-            GLAnimatorControl animator =  getAnimator();
             if(null!=animator) {
                 // can't remove us from animator for recreational addNotify()
                 animatorPaused = animator.pause();
@@ -452,7 +471,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
         }
 
         if(DEBUG) {
-            System.err.println("dispose("+regenerate+") - stop");
+            System.err.println("dispose("+regenerate+") - END, "+animator);
         }
     } finally {
         drawableSync.unlock();
@@ -495,7 +514,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
                    (int) ((getHeight() + bounds.getHeight()) / 2));
       return;
     }
-    if( ! this.drawableHelper.isExternalAnimatorAnimating() ) {
+    if( ! this.drawableHelper.isAnimatorAnimating() ) {
         display();
     }
   }
@@ -532,15 +551,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
             throw new GLException("Error: NULL AWTGraphicsConfiguration");
         }
 
-        if (!Beans.isDesignTime()) {
-            // no lock required, since this resource ain't available yet
-            drawable = GLDrawableFactory.getFactory(capsReqUser.getGLProfile())
-                           .createGLDrawable(NativeWindowFactory.getNativeWindow(this, awtConfig));
-            context = (GLContextImpl) drawable.createContext(shareWith);
-            context.setSynchronized(true);
-            context.setContextCreationFlags(additionalCtxCreationFlags);            
-        }
-
         // before native peer is valid: X11
         disableBackgroundErase();
 
@@ -550,6 +560,10 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
         // after native peer is valid: Windows
         disableBackgroundErase();
 
+        if (!Beans.isDesignTime()) {
+            createDrawableAndContext();
+        }
+
         // init drawable by paint/display makes the init sequence more equal
         // for all launch flavors (applet/javaws/..)
         // validateGLDrawable();
@@ -562,6 +576,21 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
     }
   }
 
+  private void createDrawableAndContext() {
+    // no lock required, since this resource ain't available yet
+    final JAWTWindow jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig);
+    jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer);
+    jawtWindow.lockSurface();
+    try {
+        drawable = GLDrawableFactory.getFactory(capsReqUser.getGLProfile()).createGLDrawable(jawtWindow);
+        context = (GLContextImpl) drawable.createContext(shareWith);
+        context.setSynchronized(true);
+        context.setContextCreationFlags(additionalCtxCreationFlags);
+    } finally {
+        jawtWindow.unlockSurface();
+    }
+  }
+  
   private boolean validateGLDrawable() {
     boolean realized = false;
     if (!Beans.isDesignTime()) {
@@ -636,7 +665,11 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
     @Override
   public void reshape(int x, int y, int width, int height) {
     super.reshape(x, y, width, height);
-    sendReshape = true;
+    if(null != drawable && drawable.isRealized() && !drawable.getChosenGLCapabilities().isOnscreen()) {
+        dispose(true);
+    } else {
+        sendReshape = true;
+    }
   }
 
   /** <B>Overrides:</B>
@@ -811,21 +844,24 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
       }
 
       if(null!=drawable) {
+          final JAWTWindow jawtWindow = (JAWTWindow)drawable.getNativeSurface();
           drawable.setRealized(false);
           drawable=null;
+          if(null!=jawtWindow) {
+            jawtWindow.destroy();
+          }          
       }
-
+      
       if(disposeRegenerate) {
-          // recreate GLDrawable to reflect it's new graphics configuration
-          drawable = GLDrawableFactory.getFactory(capsReqUser.getGLProfile())
-                        .createGLDrawable(NativeWindowFactory.getNativeWindow(GLCanvas.this, awtConfig));
+          // Similar process as in addNotify()!
+          
+          // Recreate GLDrawable/GLContext to reflect it's new graphics configuration
+          createDrawableAndContext();
+          
           if(DEBUG) {
             System.err.println("GLCanvas.dispose(true): new drawable: "+drawable);
           }
-          drawable.setRealized(true);
-          context = (GLContextImpl) drawable.createContext(shareWith);
-          context.setSynchronized(true);
-          sendReshape=true; // ensure a reshape is being send ..
+          validateGLDrawable(); // immediate attempt to recreate the drawable
       }
     }
   }
@@ -843,20 +879,20 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
 
   class DisposeAbstractGraphicsDeviceAction implements Runnable {
     public void run() {
-      AbstractGraphicsConfiguration aconfig = (null!=awtConfig) ? awtConfig.getNativeGraphicsConfiguration() : null;
-      AbstractGraphicsScreen ascreen = (null!=aconfig) ? aconfig.getScreen() : null;
-      AbstractGraphicsDevice adevice = (null!=ascreen) ? ascreen.getDevice() : null;
-      if(null!=adevice) {
-          String adeviceMsg=null;
+      if(null != awtConfig) {
+          final AbstractGraphicsDevice adevice = awtConfig.getScreen().getDevice();
+          final String adeviceMsg;
           if(DEBUG) {
             adeviceMsg = adevice.toString();
+          } else {
+            adeviceMsg = null;  
           }
-          boolean closed = adevice.close();
+          boolean closed = awtConfig.getScreen().getDevice().close();
           if(DEBUG) {
             System.err.println(Thread.currentThread().getName() + " - GLCanvas.dispose(false): closed GraphicsDevice: "+adeviceMsg+", result: "+closed);
           }
+          awtConfig=null;
       }
-      awtConfig=null;
     }
   }
   private DisposeAbstractGraphicsDeviceAction disposeAbstractGraphicsDeviceAction = new DisposeAbstractGraphicsDeviceAction();
@@ -1001,7 +1037,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
       return null;
     }
 
-    final AbstractGraphicsScreen aScreen = AWTGraphicsScreen.createScreenDevice(device, AbstractGraphicsDevice.DEFAULT_UNIT);
+    final AbstractGraphicsScreen aScreen = null != device ? 
+            AWTGraphicsScreen.createScreenDevice(device, AbstractGraphicsDevice.DEFAULT_UNIT):
+            AWTGraphicsScreen.createDefault();
     AWTGraphicsConfiguration config = null;
 
     if( EventQueue.isDispatchThread() || Thread.holdsLock(getTreeLock()) ) {
@@ -1045,7 +1083,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
     // System.err.println(NativeWindowVersion.getInstance());
     System.err.println(JoglVersion.getInstance());
 
-    GLProfile.initSingleton(false);
     GLDrawableFactory factory = GLDrawableFactory.getDesktopFactory();
     List<GLCapabilitiesImmutable> availCaps = factory.getAvailableCapabilities(null);
     for(int i=0; i<availCaps.size(); i++) {
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index 92be62b..dd55588 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -83,6 +83,8 @@ import javax.media.opengl.GLProfile;
 import javax.media.opengl.GLRunnable;
 import javax.media.opengl.Threading;
 import com.jogamp.opengl.util.FBObject;
+import com.jogamp.opengl.util.GLBuffers;
+
 import jogamp.opengl.Debug;
 import jogamp.opengl.GLContextImpl;
 import jogamp.opengl.GLDrawableFactoryImpl;
@@ -308,7 +310,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
       }
 
       if(!regenerate) {
-          AbstractGraphicsDevice adevice = disposeDrawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice();
+          AbstractGraphicsDevice adevice = disposeDrawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice();
           String adeviceMsg=null;
           if(DEBUG) {
             adeviceMsg = adevice.toString();
@@ -776,17 +778,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
     if (number == 0) {
       return 2;
     }
-
-    if (((number-1) & number) == 0) {
-      //ex: 8 -> 0b1000; 8-1=7 -> 0b0111; 0b1000&0b0111 == 0
-      return number;
-    }
-    int power = 0;
-    while (number > 0) {
-      number = number>>1;
-      power++;
-    }
-    return (1<<power);
+    return GLBuffers.getNextPowerOf2(number);
   }
 
   private int getGLInteger(GL gl, int which) {
@@ -1039,6 +1031,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
                                                 chooser,
                                                 Math.max(1, panelWidth),
                                                 Math.max(1, panelHeight));
+      offscreenDrawable.setRealized(true);
       offscreenContext = (GLContextImpl) offscreenDrawable.createContext(shareWith);
       offscreenContext.setSynchronized(true);
       offscreenContext.setContextCreationFlags(additionalCtxCreationFlags);
@@ -1641,7 +1634,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
                   }
                 }
                 if (joglContext == null) {
-                  AbstractGraphicsDevice device = j2dContext.getGLDrawable().getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice();
+                  AbstractGraphicsDevice device = j2dContext.getGLDrawable().getNativeSurface().getGraphicsConfiguration().getScreen().getDevice();
                   if (factory.canCreateExternalGLDrawable(device)) {
                     joglDrawable = factory.createExternalGLDrawable();
                     // FIXME: Need to share with j2d context, due to FBO resource .. 
diff --git a/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java b/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java
index 2fa7084..bc9a930 100644
--- a/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java
+++ b/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java
@@ -79,7 +79,7 @@ public class GlyphString {
      * @param shape is not null, add all {@link GlyphShape}'s {@link Outline} to this instance.
      * @param vertexFactory vertex impl factory {@link Factory}
      * @param font the target {@link Font} 
-     * @param size font size
+     * @param fontSize font size
      * @param str string text
      * @return the created {@link GlyphString} instance
      */
diff --git a/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLookupHelper.java b/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLookupHelper.java
index 2d2d1c5..ff49303 100644
--- a/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLookupHelper.java
+++ b/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLookupHelper.java
@@ -42,7 +42,7 @@ public class DesktopGLDynamicLookupHelper extends GLDynamicLookupHelper {
     public synchronized boolean loadGLULibrary() {
         /** hacky code .. where all platform GLU libs are tried ..*/
         if(null==gluLib) {
-            List/*<String>*/ gluLibNames = new ArrayList();
+            List<String> gluLibNames = new ArrayList<String>();
             gluLibNames.add("/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib"); // osx
             gluLibNames.add("libGLU.so"); // unix
             gluLibNames.add("GLU32"); // windows
diff --git a/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java b/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java
index 96d62fb..27569d2 100644
--- a/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java
+++ b/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java
@@ -28,6 +28,8 @@
 package jogamp.opengl;
 
 import java.io.PrintStream;
+import java.util.concurrent.TimeUnit;
+
 import javax.media.opengl.FPSCounter;
 
 /**
@@ -55,7 +57,7 @@ public class FPSCounterImpl implements FPSCounter {
     public final synchronized void tickFPS() {
         fpsTotalFrames++;
         if(fpsUpdateFramesInterval>0 && fpsTotalFrames%fpsUpdateFramesInterval == 0) {
-            final long now = System.currentTimeMillis();
+            final long now = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
             fpsLastPeriod = now - fpsLastUpdateTime;
             fpsLastPeriod = Math.max(fpsLastPeriod, 1); // div 0 
             fpsLast = ( (float)fpsUpdateFramesInterval * 1000f ) / ( (float) fpsLastPeriod ) ; 
@@ -96,7 +98,7 @@ public class FPSCounterImpl implements FPSCounter {
     }
     
     public final synchronized void resetFPSCounter() {
-        fpsStartTime = System.currentTimeMillis(); // overwrite startTime to real init one
+        fpsStartTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); // overwrite startTime to real init one
         fpsLastUpdateTime   = fpsStartTime;
         fpsLastPeriod = 0;
         fpsTotalFrames = 0;
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index 99693aa..28bb11f 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -69,8 +69,6 @@ import javax.media.opengl.GLPipelineFactory;
 import javax.media.opengl.GLProfile;
 
 public abstract class GLContextImpl extends GLContext {
-  public static final boolean DEBUG = Debug.debug("GLContext");
-    
   // RecursiveLock maintains a queue of waiting Threads, ensuring the longest waiting thread will be notified at unlock.  
   protected RecursiveLock lock = LockFactory.createRecursiveLock();
 
@@ -113,13 +111,19 @@ public abstract class GLContextImpl extends GLContext {
       mappedGLXProcAddress = new HashMap<String, ProcAddressTable>();
   }
 
+  public static void shutdownImpl() {
+      mappedExtensionAvailabilityCache.clear();
+      mappedGLProcAddress.clear();
+      mappedGLXProcAddress.clear();      
+  }
+  
   public GLContextImpl(GLDrawableImpl drawable, GLContext shareWith) {
     super();
 
     if (shareWith != null) {
       GLContextShareSet.registerSharing(this, shareWith);
     }
-    GLContextShareSet.registerForBufferObjectSharing(shareWith, this);
+    GLContextShareSet.synchronizeBufferObjectSharing(shareWith, this);
 
     this.drawable = drawable;
     this.drawableRead = drawable;
@@ -196,8 +200,18 @@ public abstract class GLContextImpl extends GLContext {
     return gl;
   }
 
-  // This is only needed for Mac OS X on-screen contexts
-  protected void update() throws GLException { }
+  /**
+   * Call this method to notify the OpenGL context
+   * that the drawable has changed (size or position).
+   * 
+   * <p>
+   * This is currently being used and overridden by Mac OSX, 
+   * which issues the {@link jogamp.opengl.macosx.cgl.CGL#updateContext(long) NSOpenGLContext update()} call.
+   * </p>
+   *  
+   * @throws GLException
+   */
+  protected void drawableUpdatedNotify() throws GLException { }
 
   boolean lockFailFast = true;
   Object lockFailFastSync = new Object();
@@ -256,23 +270,6 @@ public abstract class GLContextImpl extends GLContext {
     // don't destroy the context out from under another thread rendering to it
     lockConsiderFailFast();
     try {
-      /* FIXME: refactor dependence on Java 2D / JOGL bridge
-      if (tracker != null) {
-        // Don't need to do anything for contexts that haven't been
-        // created yet
-        if (isCreated()) {
-          // If we are tracking creation and destruction of server-side
-          // OpenGL objects, we must decrement the reference count of the
-          // GLObjectTracker upon context destruction.
-          //
-          // Note that we can only eagerly delete these server-side
-          // objects if there is another context currrent right now
-          // which shares textures and display lists with this one.
-          tracker.unref(deletedObjectTracker);
-        }
-      }
-      */
-
       if (contextHandle != 0) {
           int lockRes = drawable.lockSurface();
           if (NativeSurface.LOCK_SURFACE_NOT_READY == lockRes) {
@@ -280,10 +277,17 @@ public abstract class GLContextImpl extends GLContext {
                 throw new GLException("Surface not ready to lock: "+drawable);
           }
           try {
+              if (DEBUG) {
+                  System.err.println("GLContextImpl.destroy: " + toHexString(contextHandle) +
+                          ", isShared "+GLContextShareSet.isShared(this));
+              }
               destroyImpl();
               contextHandle = 0;
               glDebugHandler = null;
-              GLContextShareSet.contextDestroyed(this);
+              // this maybe impl. in a platform specific way to release remaining shared ctx.
+              if(GLContextShareSet.contextDestroyed(this) && !GLContextShareSet.hasCreatedSharedLeft(this)) {
+                  GLContextShareSet.unregisterSharing(this);
+              }
           } finally {
               drawable.unlockSurface();
           }
@@ -321,7 +325,10 @@ public abstract class GLContextImpl extends GLContext {
   //
 
   /**
-   * MakeCurrent functionality, which also issues the creation of the actual OpenGL context.<br>
+   * {@inheritDoc}
+   * <p>
+   * MakeCurrent functionality, which also issues the creation of the actual OpenGL context.
+   * </p>
    * The complete callgraph for general OpenGL context creation is:<br>
    * <ul>
    *    <li> {@link #makeCurrent} <i>GLContextImpl</i></li>
@@ -357,12 +364,12 @@ public abstract class GLContextImpl extends GLContext {
   public int makeCurrent() throws GLException {
     // One context can only be current by one thread,
     // and one thread can only have one context current!
-    GLContext current = getCurrent();
+    final GLContext current = getCurrent();
     if (current != null) {
       if (current == this) {
         // Assume we don't need to make this context current again
         // For Mac OS X, however, we need to update the context to track resizes
-        update();
+        drawableUpdatedNotify();
         return CONTEXT_CURRENT;
       } else {
         current.release();
@@ -451,26 +458,35 @@ public abstract class GLContextImpl extends GLContext {
           if (0 == drawable.getHandle()) {
               throw new GLException("drawable has invalid handle: "+drawable);
           }
-          boolean newCreated = false;
           if (!isCreated()) {
-            GLProfile.initProfiles(
-                    getGLDrawable().getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice());
-            newCreated = createImpl(); // may throws exception if fails!
+            final GLContextImpl shareWith = (GLContextImpl) GLContextShareSet.getShareContext(this);
+            if (null != shareWith) {
+                shareWith.getDrawableImpl().lockSurface();
+            }
+            boolean created;
+            try {
+                created = createImpl(shareWith); // may throws exception if fails!
+            } finally {
+                if (null != shareWith) {
+                    shareWith.getDrawableImpl().unlockSurface();
+                }                
+            }
             if (DEBUG) {
-                if(newCreated) {
+                if(created) {
                     System.err.println(getThreadName() + ": !!! Create GL context OK: " + toHexString(contextHandle) + " for " + getClass().getName());
                 } else {
                     System.err.println(getThreadName() + ": !!! Create GL context FAILED for " + getClass().getName());
                 }
             }
-            if(!newCreated) {
+            if(!created) {
                 shallUnlockSurface = true;
                 return CONTEXT_NOT_CURRENT;
             }
             GLContextShareSet.contextCreated(this);
+            return CONTEXT_CURRENT_NEW;
           }
-          makeCurrentImpl(newCreated);
-          return newCreated ? CONTEXT_CURRENT_NEW : CONTEXT_CURRENT ;
+          makeCurrentImpl();
+          return CONTEXT_CURRENT;
       } catch (RuntimeException e) {
         shallUnlockSurface = true;
         throw e;
@@ -481,26 +497,41 @@ public abstract class GLContextImpl extends GLContext {
       }
     }
   }
-  protected abstract void makeCurrentImpl(boolean newCreatedContext) throws GLException;
-  protected abstract boolean createImpl() throws GLException ;
+  protected abstract void makeCurrentImpl() throws GLException;
+  
+  /** 
+   * Platform dependent entry point for context creation.<br>
+   *
+   * This method is called from {@link #makeCurrentLocking()} .. {@link #makeCurrent()} .<br>
+   *
+   * The implementation shall verify this context with a 
+   * <code>MakeContextCurrent</code> call.<br>
+   *
+   * The implementation <b>must</b> leave the context current.<br>
+   * 
+   * @param share the shared context or null
+   * @return the valid and current context if successful, or null
+   * @throws GLException
+   */
+  protected abstract boolean createImpl(GLContextImpl sharedWith) throws GLException ;
 
   /** 
    * Platform dependent but harmonized implementation of the <code>ARB_create_context</code>
    * mechanism to create a context.<br>
    *
-   * This method is called from {@link #createContextARB}.<br>
+   * This method is called from {@link #createContextARB}, {@link #createImpl(GLContextImpl)} .. {@link #makeCurrent()} .<br>
    *
    * The implementation shall verify this context with a 
    * <code>MakeContextCurrent</code> call.<br>
    *
-   * The implementation shall leave the context current.<br>
+   * The implementation <b>must</b> leave the context current.<br>
    *
    * @param share the shared context or null
    * @param direct flag if direct is requested
    * @param ctxOptionFlags <code>ARB_create_context</code> related, see references below
    * @param major major number
    * @param minor minor number
-   * @return the valid context if successfull, or null
+   * @return the valid and current context if successful, or null
    *
    * @see #makeCurrent
    * @see #CTX_PROFILE_COMPAT
@@ -548,11 +579,11 @@ public abstract class GLContextImpl extends GLContext {
    */
   protected final long createContextARB(long share, boolean direct) 
   {
-    AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+    AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration();
     AbstractGraphicsDevice device = config.getScreen().getDevice();
     GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
     GLProfile glp = glCaps.getGLProfile();
-    GLProfile glpImpl = GLProfile.get(glp.getImplName());
+    GLProfile glpImpl = glp.getImpl();
 
     if (DEBUG) {
       System.err.println(getThreadName() + ": !!! createContextARB: mappedVersionsAvailableSet("+device.getConnection()+"): "+
@@ -583,7 +614,7 @@ public abstract class GLContextImpl extends GLContext {
         _ctp[0] |= additionalCtxCreationFlags;
         _ctx = createContextARBImpl(share, direct, _ctp[0], _major[0], _minor[0]);
         if(0!=_ctx) {
-            setGLFunctionAvailability(true, true, _major[0], _minor[0], _ctp[0]);
+            setGLFunctionAvailability(true, _major[0], _minor[0], _ctp[0]);
         }
     }
     return _ctx;
@@ -654,12 +685,11 @@ public abstract class GLContextImpl extends GLContext {
        }
     }
     if(0!=_context) {
-        AbstractGraphicsDevice device = drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice();
+        AbstractGraphicsDevice device = drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice();
         if( isExtensionAvailable("GL_ARB_ES2_compatibility") ) {
             ctp |= CTX_PROFILE_ES2_COMPAT;
         }
         GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, major[0], minor[0], ctp);
-        setGLFunctionAvailability(true, true, major[0], minor[0], ctp);
         destroyContextARBImpl(_context);
         if (DEBUG) {
           System.err.println(getThreadName() + ": !!! createContextARBMapVersionsAvailable HAVE: "+
@@ -677,8 +707,9 @@ public abstract class GLContextImpl extends GLContext {
     major[0]=majorMax;
     minor[0]=minorMax;
     long _context=0;
+    boolean ok = false;
 
-    while ( 0==_context &&
+    while ( !ok &&
             GLContext.isValidGLVersion(major[0], minor[0]) &&
             ( major[0]>majorMin || major[0]==majorMin && minor[0] >=minorMin ) ) {
 
@@ -687,15 +718,20 @@ public abstract class GLContextImpl extends GLContext {
         }
         _context = createContextARBImpl(share, direct, ctxOptionFlags, major[0], minor[0]);
 
-        boolean ok = 0!=_context;
+        if(0 != _context) {
+            ok = true;
+            setGLFunctionAvailability(true, major[0], minor[0], ctxOptionFlags);            
+        } else {
+            ok = false;            
+        }
         
         if(ok && major[0]>=3) {
             int[] hasMajor = new int[1]; int[] hasMinor = new int[1];
-            setGLFunctionAvailability(true, false, major[0], minor[0], ctxOptionFlags);
             gl.glGetIntegerv(GL3.GL_MAJOR_VERSION, hasMajor, 0);
             gl.glGetIntegerv(GL3.GL_MINOR_VERSION, hasMinor, 0);
             ok = hasMajor[0]>major[0] || ( hasMajor[0]==major[0] && hasMinor[0]>=minor[0] ) ;
             if(!ok) {
+                removeCachedVersion(major[0], minor[0], ctxOptionFlags);
                 destroyContextARBImpl(_context);
                 _context = 0;
             }
@@ -703,6 +739,7 @@ public abstract class GLContextImpl extends GLContext {
                 System.err.println(getThreadName() + ": createContextARBVersions: version verification - expected "+major[0]+"."+minor[0]+", has "+hasMajor[0]+"."+hasMinor[0]+" == "+ok);
             }
         }
+        
         if(!ok) {
             if(!GLContext.decrementGLVersion(major, minor)) break;
         }
@@ -854,15 +891,15 @@ public abstract class GLContextImpl extends GLContext {
    *
    * @param force force the setting, even if is already being set.
    *              This might be useful if you change the OpenGL implementation.
-   * @param cached whether this version's data shall be cached or not
    * @param major OpenGL major version
    * @param minor OpenGL minor version
    * @param ctxProfileBits OpenGL context profile and option bits, see {@link javax.media.opengl.GLContext#CTX_OPTION_ANY}
+   * 
    * @see #setContextVersion
    * @see javax.media.opengl.GLContext#CTX_OPTION_ANY
    * @see javax.media.opengl.GLContext#CTX_PROFILE_COMPAT
    */
-  protected final void setGLFunctionAvailability(boolean force, boolean cached, int major, int minor, int ctxProfileBits) {
+  protected final void setGLFunctionAvailability(boolean force, int major, int minor, int ctxProfileBits) {
     if(null!=this.gl && null!=glProcAddressTable && !force) {
         return; // already done and not forced
     }
@@ -873,7 +910,7 @@ public abstract class GLContextImpl extends GLContext {
 
     updateGLXProcAddressTable();
 
-    AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+    AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration();
     AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice();
     final int ctxImplBits = drawable.getChosenGLCapabilities().getHardwareAccelerated() ? GLContext.CTX_IMPL_ACCEL_HARD : GLContext.CTX_IMPL_ACCEL_SOFT;
     contextFQN = getContextFQN(adevice, major, minor, ctxProfileBits, ctxImplBits);
@@ -904,12 +941,10 @@ public abstract class GLContextImpl extends GLContext {
                                                                  new Object[] { new GLProcAddressResolver() } );
         }
         resetProcAddressTable(getGLProcAddressTable());
-        if(cached) {
-            synchronized(mappedContextTypeObjectLock) {
-                mappedGLProcAddress.put(contextFQN, getGLProcAddressTable());
-                if(DEBUG) {
-                    System.err.println(getThreadName() + ": !!! GLContext GL ProcAddressTable mapping key("+contextFQN+") -> "+getGLProcAddressTable().hashCode());
-                }
+        synchronized(mappedContextTypeObjectLock) {
+            mappedGLProcAddress.put(contextFQN, getGLProcAddressTable());
+            if(DEBUG) {
+                System.err.println(getThreadName() + ": !!! GLContext GL ProcAddressTable mapping key("+contextFQN+") -> "+getGLProcAddressTable().hashCode());
             }
         }
     }
@@ -919,34 +954,56 @@ public abstract class GLContextImpl extends GLContext {
     //
     setContextVersion(major, minor, ctxProfileBits);
 
-    if(cached) {
-        //
-        // Update ExtensionAvailabilityCache
-        //
-        ExtensionAvailabilityCache eCache;
-        synchronized(mappedContextTypeObjectLock) {
-            eCache = mappedExtensionAvailabilityCache.get( contextFQN );
+    //
+    // Update ExtensionAvailabilityCache
+    //
+    ExtensionAvailabilityCache eCache;
+    synchronized(mappedContextTypeObjectLock) {
+        eCache = mappedExtensionAvailabilityCache.get( contextFQN );
+    }
+    if(null !=  eCache) {
+        extensionAvailability = eCache;
+        if(DEBUG) {
+            System.err.println(getThreadName() + ": !!! GLContext GL ExtensionAvailabilityCache reusing key("+contextFQN+") -> "+eCache.hashCode());
         }
-        if(null !=  eCache) {
-            extensionAvailability = eCache;
+    } else {
+        if(null==extensionAvailability) {
+            extensionAvailability = new ExtensionAvailabilityCache(this);
+        }
+        extensionAvailability.reset();
+        synchronized(mappedContextTypeObjectLock) {
+            mappedExtensionAvailabilityCache.put(contextFQN, extensionAvailability);
             if(DEBUG) {
-                System.err.println(getThreadName() + ": !!! GLContext GL ExtensionAvailabilityCache reusing key("+contextFQN+") -> "+eCache.hashCode());
-            }
-        } else {
-            if(null==extensionAvailability) {
-                extensionAvailability = new ExtensionAvailabilityCache(this);
-            }
-            extensionAvailability.reset();
-            synchronized(mappedContextTypeObjectLock) {
-                mappedExtensionAvailabilityCache.put(contextFQN, extensionAvailability);
-                if(DEBUG) {
-                    System.err.println(getThreadName() + ": !!! GLContext GL ExtensionAvailabilityCache mapping key("+contextFQN+") -> "+extensionAvailability.hashCode());
-                }
+                System.err.println(getThreadName() + ": !!! GLContext GL ExtensionAvailabilityCache mapping key("+contextFQN+") -> "+extensionAvailability.hashCode());
             }
         }
     }
   }
 
+  protected final void removeCachedVersion(int major, int minor, int ctxProfileBits) {
+    AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration();
+    AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice();
+    final int ctxImplBits = drawable.getChosenGLCapabilities().getHardwareAccelerated() ? GLContext.CTX_IMPL_ACCEL_HARD : GLContext.CTX_IMPL_ACCEL_SOFT;
+    contextFQN = getContextFQN(adevice, major, minor, ctxProfileBits, ctxImplBits);
+    if (DEBUG) {
+      System.err.println(getThreadName() + ": !!! RM Context FQN: "+contextFQN);
+    }
+
+    synchronized(mappedContextTypeObjectLock) {
+        ProcAddressTable table = mappedGLProcAddress.remove( contextFQN );
+        if(DEBUG) {
+            System.err.println(getThreadName() + ": !!! RM GLContext GL ProcAddressTable mapping key("+contextFQN+") -> "+table.hashCode());
+        }
+    }
+
+    synchronized(mappedContextTypeObjectLock) {
+        ExtensionAvailabilityCache  eCache = mappedExtensionAvailabilityCache.get( contextFQN );
+        if(DEBUG) {
+            System.err.println(getThreadName() + ": !!! RM GLContext GL ExtensionAvailabilityCache reusing key("+contextFQN+") -> "+eCache.hashCode());
+        }
+    }
+  }
+  
   /**
    * Updates the platform's 'GLX' function cache
    */
diff --git a/src/jogl/classes/jogamp/opengl/GLContextShareSet.java b/src/jogl/classes/jogamp/opengl/GLContextShareSet.java
index bbb4614..b7acc0d 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextShareSet.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextShareSet.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2011 JogAmp Community. All rights reserved.
  * 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -39,39 +40,36 @@
 
 package jogamp.opengl;
 
-// FIXME: refactor Java SE dependencies
-// import java.awt.GraphicsConfiguration;
-// import java.awt.GraphicsDevice;
-// import java.awt.GraphicsEnvironment;
-import java.lang.ref.*;
-import java.util.*;
-import javax.media.opengl.*;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
 
-/** Provides a mechanism by which OpenGL contexts can share textures
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLException;
+
+
+/** Provides a deterministic mechanism by which OpenGL contexts can share textures
     and display lists in the face of multithreading and asynchronous
-    context creation as is inherent in the AWT and Swing. */
+    context creation. */
 
 public class GLContextShareSet {
-  // FIXME: refactor Java SE dependencies
-  //  private static boolean forceTracking = Debug.isPropertyDefined("jogl.glcontext.forcetracking");
-  private static final boolean DEBUG = Debug.debug("GLContext");
-
-  // This class is implemented with a WeakHashMap that goes from the
-  // contexts as keys to a complex data structure as value that tracks
-  // context creation and deletion.
+  private static final boolean DEBUG = GLContextImpl.DEBUG;
+  
+  // This class is implemented using a HashMap which maps from all shared contexts
+  // to a share set, containing all shared contexts itself.
 
-  private static Map/*<GLContext, ShareSet>*/ shareMap = new WeakHashMap();
-  private static Object dummyValue = new Object();
+  private static final Map<GLContext, ShareSet> shareMap = new HashMap<GLContext, ShareSet>();
+  private static final Object dummyValue = new Object();
 
   private static class ShareSet {
-    private Map allShares       = new WeakHashMap();
-    private Map createdShares   = new WeakHashMap();
-    private Map destroyedShares = new WeakHashMap();
+    private Map<GLContext, Object> allShares       = new HashMap<GLContext, Object>();
+    private Map<GLContext, Object> createdShares   = new HashMap<GLContext, Object>();
+    private Map<GLContext, Object> destroyedShares = new HashMap<GLContext, Object>();
 
     public void add(GLContext ctx) {
       if (allShares.put(ctx, dummyValue) == null) {
-        // FIXME: downcast to GLContextImpl undesirable
-        if (((GLContextImpl) ctx).isCreated()) {
+        if (ctx.isCreated()) {
           createdShares.put(ctx, dummyValue);
         } else {
           destroyedShares.put(ctx, dummyValue);
@@ -79,9 +77,17 @@ public class GLContextShareSet {
       }      
     }
 
+    public Set<GLContext> getCreatedShares() {
+        return createdShares.keySet();
+    }
+    
+    public Set<GLContext> getDestroyedShares() {
+        return destroyedShares.keySet();
+    }
+    
     public GLContext getCreatedShare(GLContext ignore) {
-      for (Iterator iter = createdShares.keySet().iterator(); iter.hasNext(); ) {
-        GLContext ctx = (GLContext) iter.next();
+      for (Iterator<GLContext> iter = createdShares.keySet().iterator(); iter.hasNext(); ) {
+        GLContext ctx = iter.next();
         if (ctx != ignore) {
           return ctx;
         }
@@ -126,8 +132,84 @@ public class GLContextShareSet {
     share.add(share2);
     addEntry(share1, share);
     addEntry(share2, share);
+    if (DEBUG) {
+      System.err.println("GLContextShareSet: registereSharing: 1: " + 
+              toHexString(share1.getHandle()) + ", 2: " + toHexString(share2.getHandle()));
+    }                  
   }
 
+  public static synchronized void unregisterSharing(GLContext lastContext) {
+    if (lastContext == null) {
+      throw new IllegalArgumentException("Last context is null");
+    }
+    ShareSet share = entryFor(lastContext);
+    if (share == null) {
+      throw new GLException("Last context is unknown: "+lastContext);
+    }
+    Set<GLContext> s = share.getCreatedShares();
+    if(s.size()>0) {
+        throw new GLException("Last context's share set contains "+s.size()+" non destroyed context");
+    }
+    s = share.getDestroyedShares();
+    if(s.size()==0) {
+        throw new GLException("Last context's share set contains no destroyed context");
+    }
+    if (DEBUG) {
+      System.err.println("GLContextShareSet: unregisterSharing: " + 
+              toHexString(lastContext.getHandle())+", entries: "+s.size());
+    }                  
+    for(Iterator<GLContext> iter = s.iterator() ; iter.hasNext() ; ) {
+        GLContext ctx = iter.next();
+        if(null == removeEntry(ctx)) {
+            throw new GLException("Removal of shareSet for context failed");
+        }
+    }
+  }
+  
+  private static synchronized Set<GLContext> getCreatedSharedImpl(GLContext context) {
+    if (context == null) {
+      throw new IllegalArgumentException("context is null");
+    }
+    final ShareSet share = entryFor(context);
+    if (share != null) {
+        return share.getCreatedShares();
+    }
+    return null;    
+  }
+  
+  public static synchronized boolean isShared(GLContext context) {
+    if (context == null) {
+      throw new IllegalArgumentException("context is null");
+    }
+    final ShareSet share = entryFor(context);
+    return share != null;
+  }
+  
+  public static synchronized boolean hasCreatedSharedLeft(GLContext context) {
+      final Set<GLContext> s = getCreatedSharedImpl(context);
+      return null != s && s.size()>0 ;
+  }
+  
+  /** currently not used ..
+  public static synchronized Set<GLContext> getCreatedShared(GLContext context) {
+    final Set<GLContext> s = getCreatedSharedImpl(context);
+    if (s == null) {
+      throw new GLException("context is unknown: "+context);
+    }
+    return s;
+  }
+    
+  public static synchronized Set<GLContext> getDestroyedShared(GLContext context) {
+    if (context == null) {
+      throw new IllegalArgumentException("context is null");
+    }
+    ShareSet share = entryFor(context);
+    if (share == null) {
+      throw new GLException("context is unknown: "+context);
+    }
+    return share.getDestroyedShares();
+  } */
+    
   public static synchronized GLContext getShareContext(GLContext contextToCreate) {
     ShareSet share = entryFor(contextToCreate);
     if (share == null) {
@@ -136,18 +218,22 @@ public class GLContextShareSet {
     return share.getCreatedShare(contextToCreate);
   }
 
-  public static synchronized void contextCreated(GLContext context) {
+  public static synchronized boolean contextCreated(GLContext context) {
     ShareSet share = entryFor(context);
     if (share != null) {
       share.contextCreated(context);
+      return true;
     }
+    return false;
   }
 
-  public static synchronized void contextDestroyed(GLContext context) {
+  public static synchronized boolean contextDestroyed(GLContext context) {
     ShareSet share = entryFor(context);
     if (share != null) {
       share.contextDestroyed(context);
+      return true;
     }
+    return false;
   }
 
   /** In order to avoid glGet calls for buffer object checks related
@@ -159,8 +245,7 @@ public class GLContextShareSet {
       currently only needed in a fairly esoteric case, when the
       Java2D/JOGL bridge is active, but the GLBufferSizeTracker
       mechanism is now always required.) */
-  public static void registerForBufferObjectSharing(GLContext olderContextOrNull, GLContext newContext) {
-    // FIXME: downcasts to GLContextImpl undesirable
+  public static void synchronizeBufferObjectSharing(GLContext olderContextOrNull, GLContext newContext) {
     GLContextImpl older = (GLContextImpl) olderContextOrNull;
     GLContextImpl newer = (GLContextImpl) newContext;
     GLBufferSizeTracker tracker = null;
@@ -175,98 +260,6 @@ public class GLContextShareSet {
     newer.setBufferSizeTracker(tracker);
   }
 
-  // FIXME: refactor Java SE dependencies
-  //  /** Indicates that the two supplied contexts (which must be able to
-  //      share textures and display lists) should be in the same
-  //      namespace for tracking of server-side object creation and
-  //      deletion. Because the sharing necessary behind the scenes is
-  //      different than that requested at the user level, the two notions
-  //      are different. This must be called immediately after the
-  //      creation of the new context (which is the second argument)
-  //      before any server-side OpenGL objects have been created in that
-  //      context. */
-  //  public static void registerForObjectTracking(GLContext olderContextOrNull,
-  //                                               GLContext newContext,
-  //                                               GLContext realShareContext) {
-  //    if (isObjectTrackingEnabled() || isObjectTrackingDebuggingEnabled()) {
-  //      GLContextImpl impl1 = null;      
-  //      GLContextImpl impl2 = null;      
-  //      GLObjectTracker tracker = null;
-  //
-  //      synchronized (GLContextShareSet.class) {
-  //        if (olderContextOrNull != null &&
-  //            newContext != null) {
-  //          if (entryFor(olderContextOrNull) != entryFor(newContext)) {
-  //            throw new IllegalArgumentException("old and new contexts must be able to share textures and display lists");
-  //          }
-  //        }
-  //
-  //        // FIXME: downcast to GLContextImpl undesirable
-  //        impl1 = (GLContextImpl) olderContextOrNull;
-  //        impl2 = (GLContextImpl) newContext;
-  //
-  //        GLObjectTracker deletedObjectTracker = null;
-  //        GLContextImpl shareImpl = (GLContextImpl) realShareContext;
-  //        // Before we zap the "user-level" object trackers, make sure
-  //        // that all contexts in the share set share the destroyed object
-  //        // tracker
-  //        if (shareImpl != null) {
-  //          deletedObjectTracker = shareImpl.getDeletedObjectTracker();
-  //        }
-  //        if (deletedObjectTracker == null) {
-  //          // Must create one and possibly set it up in the older context
-  //          deletedObjectTracker = new GLObjectTracker();
-  //          if (DEBUG) {
-  //            System.err.println("Created deletedObjectTracker " + deletedObjectTracker + " because " +
-  //                               ((shareImpl == null) ? "shareImpl was null" : "shareImpl's (" + shareImpl + ") deletedObjectTracker was null"));
-  //          }
-  //
-  //          if (shareImpl != null) {
-  //            // FIXME: think should really assert in this case
-  //            shareImpl.setDeletedObjectTracker(deletedObjectTracker);
-  //            if (DEBUG) {
-  //              System.err.println("Set deletedObjectTracker " + deletedObjectTracker + " in shareImpl context " + shareImpl);
-  //            }
-  //          }
-  //        }
-  //        impl2.setDeletedObjectTracker(deletedObjectTracker);
-  //        if (DEBUG) {
-  //          System.err.println("Set deletedObjectTracker " + deletedObjectTracker + " in impl2 context " + impl2);
-  //        }
-  //      }
-  //
-  //      // Must not hold lock around this operation
-  //      // Don't share object trackers with the primordial share context from Java2D
-  //      if (Java2D.isOGLPipelineActive()) {
-  //        // FIXME: probably need to do something different here
-  //        // Need to be able to figure out the GraphicsDevice for the
-  //        // older context if it's on-screen
-  //        GraphicsDevice device = GraphicsEnvironment.
-  //          getLocalGraphicsEnvironment().
-  //          getDefaultScreenDevice();
-  //        GLContext j2dShareContext = Java2D.getShareContext(device);
-  //        if (impl1 != null && impl1 == j2dShareContext) {
-  //          impl1 = null;
-  //        }
-  //      }
-  //
-  //      synchronized (GLContextShareSet.class) {
-  //        if (impl1 != null) {
-  //          tracker = impl1.getObjectTracker();
-  //          assert (tracker != null)
-  //            : "registerForObjectTracking was not called properly for the older context";
-  //        }
-  //        if (tracker == null) {
-  //          tracker = new GLObjectTracker();
-  //        }
-  //        // Note that we don't assert that the tracker is non-null for
-  //        // impl2 because the way we use this functionality we actually
-  //        // overwrite the initially-set object tracker in the new context
-  //        impl2.setObjectTracker(tracker);
-  //      }
-  //    }
-  //  }
-  
   //----------------------------------------------------------------------
   // Internals only below this point
   
@@ -280,14 +273,11 @@ public class GLContextShareSet {
       shareMap.put(context, share);
     }
   }
-
-  // FIXME: refactor Java SE dependencies
-  //  private static boolean isObjectTrackingEnabled() {
-  //    return ((Java2D.isOGLPipelineActive() && Java2D.isFBOEnabled()) ||
-  //            isObjectTrackingDebuggingEnabled());
-  //  }
-  //
-  //  private static boolean isObjectTrackingDebuggingEnabled() {
-  //    return forceTracking;
-  //  }
+  private static ShareSet removeEntry(GLContext context) {
+    return (ShareSet) shareMap.remove(context);
+  }
+  
+  protected static String toHexString(long hex) {
+    return "0x" + Long.toHexString(hex);
+  }  
 }
diff --git a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java
index 8ca0c01..b950c2f 100644
--- a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java
+++ b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java
@@ -35,6 +35,7 @@ import javax.media.opengl.GLDebugListener;
 import javax.media.opengl.GLDebugMessage;
 import javax.media.opengl.GLException;
 
+import com.jogamp.common.os.Platform;
 import com.jogamp.gluegen.runtime.ProcAddressTable;
 import jogamp.opengl.gl4.GL4bcProcAddressTable;
 
@@ -122,7 +123,14 @@ public class GLDebugMessageHandler {
             }
             return;            
         }
-        
+        if(Platform.OS_TYPE == Platform.OSType.WINDOWS && Platform.is32Bit()) {
+            // Currently buggy, ie. throws an exception after leaving the native callback.
+            // Probably a 32bit on 64bit JVM / OpenGL-driver issue.
+            if(DEBUG) {
+                System.err.println("GLDebugMessageHandler: Windows 32bit currently not supported!");
+            }
+            return;
+        }
         if( ctx.isExtensionAvailable(GL_ARB_debug_output) ) {
             extName = GL_ARB_debug_output;
             extType = EXT_ARB;
@@ -199,7 +207,7 @@ public class GLDebugMessageHandler {
      */
     public final void setSynchronous(boolean synchronous) {
         this.synchronous = synchronous;
-        if(isEnabled() && isExtensionARB()) {
+        if( isEnabled() ) {
             setSynchronousImpl();
         }
     }    
@@ -227,9 +235,9 @@ public class GLDebugMessageHandler {
         enableImpl(enable);
     }        
     final void enableImpl(boolean enable) throws GLException {
-        setSynchronousImpl();
         if(enable) {
             if(0 == handle) {
+                setSynchronousImpl();
                 handle = register0(glDebugMessageCallbackProcAddress, extType);
                 if(0 == handle) {
                     throw new GLException("Failed to register via \"glDebugMessageCallback*\" using "+extName);
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
index 704f714..e5f415a 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
@@ -40,11 +40,25 @@
 
 package jogamp.opengl;
 
-import java.nio.*;
-import javax.media.nativewindow.*;
-import javax.media.opengl.*;
-
-import com.jogamp.common.util.VersionNumber;
+import java.nio.Buffer;
+
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.nativewindow.OffscreenLayerSurface;
+import javax.media.nativewindow.ProxySurface;
+import javax.media.nativewindow.SurfaceChangeable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesChooser;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawable;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLPbuffer;
+import javax.media.opengl.GLProfile;
+
+import jogamp.nativewindow.MutableGraphicsConfiguration;
 
 /** Extends GLDrawableFactory with a few methods for handling
     typically software-accelerated offscreen rendering (Device
@@ -53,17 +67,28 @@ import com.jogamp.common.util.VersionNumber;
     they may be instantiated by the GLJPanel implementation. */
 public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
   protected static final boolean DEBUG = GLDrawableImpl.DEBUG;
-  public static final VersionNumber versionOneZero = new VersionNumber(1, 0, 0);
-  public static final VersionNumber versionOneOne = new VersionNumber(1, 1, 0);
-  public static final VersionNumber versionOneTwo = new VersionNumber(1, 2, 0);
-  public static final VersionNumber versionOneThree = new VersionNumber(1, 3, 0);
-  public static final VersionNumber versionOneFour = new VersionNumber(1, 4, 0);
 
   protected GLDrawableFactoryImpl() {
     super();
   }
 
   /**
+   * Returns the shared context mapped to the <code>device</code> {@link AbstractGraphicsDevice#getConnection()},
+   * either a pre-existing or newly created, or <code>null</code> if creation failed or not supported.<br>
+   * Creation of the shared context is tried only once.
+   *
+   * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be <code>null</code> for the platform's default device.
+   */
+  public final GLContext getOrCreateSharedContext(AbstractGraphicsDevice device) {
+      device = validateDevice(device);
+      if(null!=device) {
+        return getOrCreateSharedContextImpl(device);
+      }
+      return null;
+  }
+  protected abstract GLContext getOrCreateSharedContextImpl(AbstractGraphicsDevice device);
+  
+  /**
    * Returns the shared device mapped to the <code>device</code> {@link AbstractGraphicsDevice#getConnection()},
    * either a preexisting or newly created, or <code>null</code> if creation failed or not supported.<br>
    * Creation of the shared context is tried only once.
@@ -103,24 +128,40 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
     if (target == null) {
       throw new IllegalArgumentException("Null target");
     }
-    AbstractGraphicsConfiguration config = target.getGraphicsConfiguration().getNativeGraphicsConfiguration();
-    GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
+    final MutableGraphicsConfiguration config = (MutableGraphicsConfiguration) target.getGraphicsConfiguration();
+    GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
     AbstractGraphicsDevice adevice = config.getScreen().getDevice();
     GLDrawable result = null;
     adevice.lock();
     try {
-        if(caps.isOnscreen()) {
+        final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(target, true);
+        if(null != ols) {
+            // layered surface -> Offscreen/PBuffer
+            final GLCapabilities chosenCapsMod = (GLCapabilities) chosenCaps.cloneMutable();
+            chosenCapsMod.setOnscreen(false);
+            chosenCapsMod.setPBuffer(canCreateGLPbuffer(adevice));
+            config.setChosenCapabilities(chosenCapsMod);
+            if(DEBUG) {
+                System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OnscreenDrawable -> Offscreen-Layer: "+target);
+            }
+            if( ! ( target instanceof SurfaceChangeable ) ) {
+                throw new IllegalArgumentException("Passed NativeSurface must implement SurfaceChangeable for offscreen layered surface: "+target);
+            }
+            result = createOffscreenDrawableImpl(target);            
+        } else if(chosenCaps.isOnscreen()) {
+            // onscreen
             if(DEBUG) {
                 System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OnscreenDrawable: "+target);
             }
             result = createOnscreenDrawableImpl(target);
         } else {
+            // offscreen
+            if(DEBUG) {
+                System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OffScreenDrawable (PBuffer: "+chosenCaps.isPBuffer()+"): "+target);
+            }
             if( ! ( target instanceof SurfaceChangeable ) ) {
                 throw new IllegalArgumentException("Passed NativeSurface must implement SurfaceChangeable for offscreen: "+target);
             }
-            if(DEBUG) {
-                System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OffScreenDrawable (PBuffer: "+caps.isPBuffer()+"): "+target);
-            }
             result = createOffscreenDrawableImpl(target);
         }
     } finally {
@@ -171,6 +212,9 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
     device.lock();
     try {
         drawable = (GLDrawableImpl) createGLDrawable( createOffscreenSurfaceImpl(device, capsChosen, capsRequested, chooser, width, height) );
+        if(null != drawable) {
+            drawable.setRealized(true);
+        }
     } finally {
         device.unlock();
     }
@@ -287,15 +331,6 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
   // GLDrawableFactoryImpl details
   //
 
-  protected void maybeDoSingleThreadedWorkaround(Runnable action) {
-    if (Threading.isSingleThreaded() &&
-        !Threading.isOpenGLThread()) {
-      Threading.invokeOnOpenGLThread(action);
-    } else {
-      action.run();
-    }
-  }
-
   /**
    * Returns the sole GLDrawableFactoryImpl instance.
    *
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
index 5d91a5e..1453a85 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
@@ -40,19 +40,29 @@
 
 package jogamp.opengl;
 
-import java.util.*;
-import javax.media.opengl.*;
+import java.util.ArrayList;
+import java.util.HashSet;
+
+import javax.media.opengl.GLAnimatorControl;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLRunnable;
+
+import com.jogamp.opengl.util.Animator;
 
 /** Encapsulates the implementation of most of the GLAutoDrawable's
     methods to be able to share it between GLCanvas and GLJPanel. */
 
 public class GLDrawableHelper {
   protected static final boolean DEBUG = GLDrawableImpl.DEBUG;
-  private static final boolean VERBOSE = Debug.verbose();
   private Object listenersLock = new Object();
   private ArrayList<GLEventListener> listeners;
   private HashSet<GLEventListener> listenersToBeInit;
   private boolean autoSwapBufferMode;
+  private Thread skipContextReleaseThread;
   private Object glRunnablesLock = new Object();
   private ArrayList<GLRunnable> glRunnables;
   private GLAnimatorControl animatorCtrl;
@@ -67,6 +77,7 @@ public class GLDrawableHelper {
         listenersToBeInit = new HashSet<GLEventListener>();
     }
     autoSwapBufferMode = true;
+    skipContextReleaseThread = null;
     synchronized(glRunnablesLock) {
         glRunnables = new ArrayList<GLRunnable>();
     }
@@ -131,7 +142,7 @@ public class GLDrawableHelper {
       if(listenersToBeInit.remove(l)) {
           l.init(drawable);
           if(sendReshape) {
-              reshape(l, drawable, 0, 0, drawable.getWidth(), drawable.getHeight(), true /* setViewport */);
+              reshape(l, drawable, 0, 0, drawable.getWidth(), drawable.getHeight(), true /* setViewport */, false);
           }
           return true;
       }
@@ -174,7 +185,12 @@ public class GLDrawableHelper {
   }
 
   private void reshape(GLEventListener listener, GLAutoDrawable drawable,
-                             int x, int y, int width, int height, boolean setViewport) {
+                       int x, int y, int width, int height, boolean setViewport, boolean checkInit) {
+    if(checkInit) {
+        // GLEventListener may need to be init, 
+        // in case this one is added after the realization of the GLAutoDrawable      
+        init( listener, drawable, false ) ;
+    }
     if(setViewport) {
         drawable.getGL().glViewport(x, y, width, height);
     }
@@ -184,7 +200,7 @@ public class GLDrawableHelper {
   public final void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
     synchronized(listenersLock) {
         for (int i=0; i < listeners.size(); i++) {
-          reshape((GLEventListener) listeners.get(i), drawable, x, y, width, height, 0==i);
+          reshape((GLEventListener) listeners.get(i), drawable, x, y, width, height, 0==i, true);
         }
     }
   }
@@ -229,10 +245,18 @@ public class GLDrawableHelper {
     return ( null != animatorCtrl ) ? animatorCtrl.isStarted() && animatorCtrl.getThread() != Thread.currentThread() : false ;
   }
 
+  public final boolean isAnimatorRunning() {
+    return ( null != animatorCtrl ) ? animatorCtrl.isStarted() : false ;
+  }
+
   public final boolean isExternalAnimatorAnimating() {
     return ( null != animatorCtrl ) ? animatorCtrl.isAnimating() && animatorCtrl.getThread() != Thread.currentThread() : false ;
   }
 
+  public final boolean isAnimatorAnimating() {
+    return ( null != animatorCtrl ) ? animatorCtrl.isAnimating() : false ;
+  }
+
   public final void invoke(GLAutoDrawable drawable, boolean wait, GLRunnable glRunnable) {
     if( null == drawable || null == glRunnable ) {
         return;
@@ -270,14 +294,31 @@ public class GLDrawableHelper {
     }
   }
 
-  public final void setAutoSwapBufferMode(boolean onOrOff) {
-    autoSwapBufferMode = onOrOff;
+  public final void setAutoSwapBufferMode(boolean enable) {
+    autoSwapBufferMode = enable;
   }
 
   public final boolean getAutoSwapBufferMode() {
     return autoSwapBufferMode;
   }
 
+  /**
+   * @param t the thread for which context release shall be skipped, usually the animation thread,
+   *          ie. {@link Animator#getThread()}.
+   * @deprecated this is an experimental feature, 
+   *             intended for measuring performance in regards to GL context switch
+   */
+  public final void setSkipContextReleaseThread(Thread t) {
+    skipContextReleaseThread = t;
+  }
+
+  /**
+   * @deprecated see {@link #setSkipContextReleaseThread(Thread)} 
+   */
+  public final Thread getSkipContextReleaseThread() {
+    return skipContextReleaseThread;
+  }
+
   private static final ThreadLocal<Runnable> perThreadInitAction = new ThreadLocal<Runnable>();
 
   /** Principal helper method which runs a Runnable with the context
@@ -316,16 +357,31 @@ public class GLDrawableHelper {
 
     // Support for recursive makeCurrent() calls as well as calling
     // other drawables' display() methods from within another one's
-    // FIXME: re-evaluate due to possible expensive TLS access ? 
-    GLContext lastContext    = GLContext.getCurrent();
-    Runnable  lastInitAction = perThreadInitAction.get();
+    int res = GLContext.CONTEXT_NOT_CURRENT;
+    GLContext lastContext = GLContext.getCurrent();
+    Runnable  lastInitAction = null;
     if (lastContext != null) {
-      lastContext.release();
+        if (lastContext == context) {
+            res = GLContext.CONTEXT_CURRENT;
+            lastContext = null;
+        } else {
+            lastInitAction = perThreadInitAction.get();
+            lastContext.release();
+        }
     }
   
-    int res = 0;
+    /**
+    long t0 = System.currentTimeMillis();
+    long td1 = 0; // makeCurrent
+    long tdR = 0; // render time
+    long td2 = 0; // swapBuffers
+    long td3 = 0; // release
+    boolean scr = true; */
+    
     try {
-      res = context.makeCurrent();
+      if (res == GLContext.CONTEXT_NOT_CURRENT) {
+          res = context.makeCurrent();
+      }
       if (res != GLContext.CONTEXT_NOT_CURRENT) {
         if(null!=initAction) {
             perThreadInitAction.set(initAction);
@@ -336,32 +392,40 @@ public class GLDrawableHelper {
               initAction.run();
             }
         }
+        // tdR = System.currentTimeMillis();        
+        // td1 = tdR - t0; // makeCurrent
         if(null!=runnable) {
-            if (DEBUG && VERBOSE) {
-              System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running runnable");
-            }
             runnable.run();
+            // td2 = System.currentTimeMillis();
+            // tdR = td2 - tdR; // render time
             if (autoSwapBufferMode && null != initAction) {
               if (drawable != null) {
                 drawable.swapBuffers();
+                // td3 = System.currentTimeMillis();
+                // td2 = td3 - td2; // swapBuffers
               }
             }
         }
       }
     } finally {
-      try {
-        if (res != GLContext.CONTEXT_NOT_CURRENT) {
-          context.release();
-        }
-      } catch (Exception e) {
+      if(res != GLContext.CONTEXT_NOT_CURRENT &&
+         (null == skipContextReleaseThread || Thread.currentThread()!=skipContextReleaseThread) ) {
+          try {
+              context.release();
+              // scr = false;
+          } catch (Exception e) {
+          }
       }
+      // td3 = System.currentTimeMillis() - td3; // release
       if (lastContext != null) {
         int res2 = lastContext.makeCurrent();
-        if (res2 == GLContext.CONTEXT_CURRENT_NEW) {
+        if (null != lastInitAction && res2 == GLContext.CONTEXT_CURRENT_NEW) {
           lastInitAction.run();
         }
       }
     }
+    // long td0 = System.currentTimeMillis() - t0;
+    // System.err.println("td0 "+td0+"ms, fps "+(1.0/(td0/1000.0))+", td-makeCurrent: "+td1+"ms, td-render "+tdR+"ms, td-swap "+td2+"ms, td-release "+td3+"ms, skip ctx release: "+scr);
   }
 
 }
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java
index 15db80c..b9c216e 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java
@@ -40,8 +40,14 @@
 
 package jogamp.opengl;
 
-import javax.media.nativewindow.*;
-import javax.media.opengl.*;
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawable;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
 
 public abstract class GLDrawableImpl implements GLDrawable {
   protected static final boolean DEBUG = Debug.debug("GLDrawable");
@@ -52,7 +58,7 @@ public abstract class GLDrawableImpl implements GLDrawable {
       this.factory = factory;
       this.surface = comp;
       this.realized = realized;
-      this.requestedCapabilities = (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getNativeGraphicsConfiguration().getRequestedCapabilities();
+      this.requestedCapabilities = (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getRequestedCapabilities();
   }
 
   /** 
@@ -79,7 +85,7 @@ public abstract class GLDrawableImpl implements GLDrawable {
   }
 
   public final void swapBuffers() throws GLException {
-    GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)surface.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+    GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)surface.getGraphicsConfiguration().getChosenCapabilities();
     if ( caps.getDoubleBuffered() ) {
         if(!surface.surfaceSwap()) {
             int lockRes = lockSurface(); // it's recursive, so it's ok within [makeCurrent .. release]
@@ -114,7 +120,7 @@ public abstract class GLDrawableImpl implements GLDrawable {
   }
 
   public GLCapabilitiesImmutable getChosenGLCapabilities() {
-    return  (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+    return  (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getChosenCapabilities();
   }
 
   public GLCapabilitiesImmutable getRequestedGLCapabilities() {
@@ -125,7 +131,10 @@ public abstract class GLDrawableImpl implements GLDrawable {
     return surface;
   }
 
+  /** called with locked surface @ setRealized(false) */ 
   protected void destroyHandle() {}
+  
+  /** called with locked surface @ setRealized(true) or @ lockSurface(..) when surface changed */ 
   protected void updateHandle() {}
 
   public long getHandle() {
@@ -195,7 +204,7 @@ public abstract class GLDrawableImpl implements GLDrawable {
   }
 
   public String toString() {
-    return getClass().getName()+"[Realized "+isRealized()+
+    return getClass().getSimpleName()+"[Realized "+isRealized()+
                 ",\n\tFactory   "+getFactory()+
                 ",\n\thandle    "+toHexString(getHandle())+
                 ",\n\tWindow    "+getNativeSurface()+"]";
diff --git a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java
index cc7a578..6e2b7b7 100644
--- a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java
+++ b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java
@@ -29,10 +29,12 @@
 package jogamp.opengl;
 
 import java.util.ArrayList;
+
 import javax.media.opengl.GLCapabilities;
 import javax.media.opengl.GLCapabilitiesImmutable;
 
 public class GLGraphicsConfigurationUtil {
+    public static final String NV_coverage_sample = "NV_coverage_sample";
     public static final int WINDOW_BIT  = 1 << 0;
     public static final int BITMAP_BIT  = 1 << 1;
     public static final int PBUFFER_BIT = 1 << 2;
@@ -85,6 +87,7 @@ public class GLGraphicsConfigurationUtil {
         return getWinAttributeBits(caps.isOnscreen(), caps.isPBuffer());
     }
 
+    @SuppressWarnings({ "rawtypes", "unchecked" })
     public static final boolean addGLCapabilitiesPermutations(ArrayList capsBucket, GLCapabilitiesImmutable temp, int winattrbits) {
         int preSize = capsBucket.size();
         if( 0 != ( WINDOW_BIT & winattrbits )  )  {
@@ -137,7 +140,7 @@ public class GLGraphicsConfigurationUtil {
         if( capsRequested.getDoubleBuffered() || capsRequested.isOnscreen() || !capsRequested.isPBuffer()) {
             // fix caps ..
             GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable();
-            caps2.setDoubleBuffered(false); // FIXME DBLBUFOFFSCRN
+            caps2.setDoubleBuffered(false); // FIXME DBLBUFOFFSCRN - we don't need to be single buffered ..
             caps2.setOnscreen(false);
             caps2.setPBuffer(true);
             return caps2;
diff --git a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java
index d667fa5..e785d57 100644
--- a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java
@@ -70,7 +70,7 @@ public class GLPbufferImpl implements GLPbuffer {
   public GLPbufferImpl(GLDrawableImpl pbufferDrawable,
                        GLContext parentContext) {
     GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)
-         pbufferDrawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+         pbufferDrawable.getNativeSurface().getGraphicsConfiguration().getChosenCapabilities();
     if(caps.isOnscreen()) {
         if(caps.isPBuffer()) {
             throw new IllegalArgumentException("Error: Given drawable is Onscreen and Pbuffer: "+pbufferDrawable);
diff --git a/src/jogl/classes/jogamp/opengl/ProjectFloat.java b/src/jogl/classes/jogamp/opengl/ProjectFloat.java
index a6316b2..1c69fa3 100644
--- a/src/jogl/classes/jogamp/opengl/ProjectFloat.java
+++ b/src/jogl/classes/jogamp/opengl/ProjectFloat.java
@@ -235,9 +235,18 @@ public class ProjectFloat {
   /**
    * Make matrix an identity matrix
    */
-  public static void gluMakeIdentityf(float[] m) {
+  public static void gluMakeIdentityf(float[] m, int offset) {
     for (int i = 0; i < 16; i++) {
-      m[i] = IDENTITY_MATRIX[i];
+      m[i+offset] = IDENTITY_MATRIX[i];
+    }
+  }
+
+  /**
+   * Make matrix an zero matrix
+   */
+  public static void gluMakeZero(float[] m, int offset) {
+    for (int i = 0; i < 16; i++) {
+      m[i+offset] = 0;
     }
   }
 
@@ -280,21 +289,22 @@ public class ProjectFloat {
 
   /**
    * @param src
+   * @param srcOffset
    * @param inverse
-   * 
+   * @param inverseOffset
    * @return
    */
-  public boolean gluInvertMatrixf(float[] src, float[] inverse) {
+  public boolean gluInvertMatrixf(float[] src, int srcOffset, float[] inverse, int inverseOffset) {
     int i, j, k, swap;
     float t;
     float[][] temp = tempInvertMatrix;
 
     for (i = 0; i < 4; i++) {
       for (j = 0; j < 4; j++) {
-        temp[i][j] = src[i*4+j];
+        temp[i][j] = src[i*4+j+srcOffset];
       }
     }
-    gluMakeIdentityf(inverse);
+    gluMakeIdentityf(inverse, inverseOffset);
 
     for (i = 0; i < 4; i++) {
       //
@@ -316,9 +326,9 @@ public class ProjectFloat {
           temp[i][k] = temp[swap][k];
           temp[swap][k] = t;
 
-          t = inverse[i*4+k];
-          inverse[i*4+k] = inverse[swap*4+k];
-          inverse[swap*4+k] = t;
+          t = inverse[i*4+k+inverseOffset];
+          inverse[i*4+k+inverseOffset] = inverse[swap*4+k+inverseOffset];
+          inverse[swap*4+k+inverseOffset] = t;
         }
       }
 
@@ -333,14 +343,14 @@ public class ProjectFloat {
       t = temp[i][i];
       for (k = 0; k < 4; k++) {
         temp[i][k] /= t;
-        inverse[i*4+k] /= t;
+        inverse[i*4+k+inverseOffset] /= t;
       }
       for (j = 0; j < 4; j++) {
         if (j != i) {
           t = temp[j][i];
           for (k = 0; k < 4; k++) {
             temp[j][k] -= temp[i][k] * t;
-            inverse[j*4+k] -= inverse[i*4+k]*t;
+            inverse[j*4+k+inverseOffset] -= inverse[i*4+k+inverseOffset]*t;
           }
         }
       }
@@ -781,7 +791,7 @@ public class ProjectFloat {
 
     gluMultMatricesf(modelMatrix, modelMatrix_offset, projMatrix, projMatrix_offset, matrix);
 
-    if (!gluInvertMatrixf(matrix, matrix))
+    if (!gluInvertMatrixf(matrix, 0, matrix, 0))
       return false;
 
     in[0] = winx;
@@ -907,7 +917,7 @@ public class ProjectFloat {
 
     gluMultMatricesf(modelMatrix, modelMatrix_offset, projMatrix, projMatrix_offset, matrix);
 
-    if (!gluInvertMatrixf(matrix, matrix))
+    if (!gluInvertMatrixf(matrix, 0, matrix, 0))
       return false;
 
     in[0] = winx;
diff --git a/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java b/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java
index 2c396e2..a33e03a 100644
--- a/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java
+++ b/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java
@@ -44,24 +44,28 @@ public class SharedResourceRunner implements Runnable {
     }
 
     public static interface Implementation {
+        /**
+         * @param connection for creation a {@link AbstractGraphicsDevice} instance. 
+         * @return A new shared resource instance 
+         */
         Resource createSharedResource(String connection);
         void releaseSharedResource(Resource shared);
         void clear();
 
         Resource mapPut(String connection, Resource resource);
         Resource mapGet(String connection);
-        Collection/*<Resource>*/ mapValues();
+        Collection<Resource> mapValues();
     }
 
-    Implementation impl = null;
+    final HashSet<String> devicesTried = new HashSet<String>();
+    final Implementation impl;
 
-    boolean ready = false;
-    boolean released = false;
-    boolean shouldRelease = false;
-    String initConnection = null;
-    String releaseConnection = null;
-
-    HashSet devicesTried = new HashSet();
+    Thread thread;
+    boolean ready;
+    boolean released;
+    boolean shouldRelease;
+    String initConnection;
+    String releaseConnection;
 
     private boolean getDeviceTried(String connection) {
         synchronized (devicesTried) {
@@ -81,22 +85,82 @@ public class SharedResourceRunner implements Runnable {
 
     public SharedResourceRunner(Implementation impl) {
         this.impl = impl;
+        resetState();
+    }
+    
+    private void resetState() {
+        devicesTried.clear();
+        thread = null;
+        ready = false;
+        released = false;
+        shouldRelease = false;
+        initConnection = null;
+        releaseConnection = null;
     }
 
+    /** 
+     * Start the shared resource runner thread, if not running.
+     * <p>
+     * Validate the thread upfront and release all related resource if it was killed.
+     * </p>
+     * 
+     * @return the shared resource runner thread.
+     */
+    public Thread start() {
+        if(null != thread && !thread.isAlive()) {
+            // thread was killed unrecognized ..
+            if (DEBUG) {
+                System.err.println("SharedResourceRunner.start() - dead-old-thread cleanup - "+Thread.currentThread().getName());
+            }
+            releaseSharedResources();
+            thread = null;
+        }        
+        if(null == thread) {
+            if (DEBUG) {
+                System.err.println("SharedResourceRunner.start() - start new Thread - "+Thread.currentThread().getName());
+            }
+            resetState();
+            thread = new Thread(this, Thread.currentThread().getName()+"-SharedResourceRunner");
+            thread.setDaemon(true); // Allow JVM to exit, even if this one is running
+            thread.start();
+        }
+        return thread;
+    }
+    
+    public void stop() {
+        if(null != thread) {
+            if (DEBUG) {
+                System.err.println("SharedResourceRunner.stop() - "+Thread.currentThread().getName());
+            }
+            synchronized (this) {
+                shouldRelease = true;
+                this.notifyAll();
+    
+                while (!released) {
+                    try {
+                        this.wait();
+                    } catch (InterruptedException ex) {
+                    }
+                }
+            }
+        }
+    }
+    
     public SharedResourceRunner.Resource getOrCreateShared(AbstractGraphicsDevice device) {
         SharedResourceRunner.Resource sr = null;
         if(null != device) {
-            String connection = device.getConnection();
+            start();
+            final String connection = device.getConnection();
             sr = impl.mapGet(connection);
             if (null == sr && !getDeviceTried(connection)) {
                 addDeviceTried(connection);
                 if (DEBUG) {
-                    System.err.println("getOrCreateShared() " + connection + ": trying");
+                    System.err.println("SharedResourceRunner.getOrCreateShared() " + connection + ": trying - "+Thread.currentThread().getName());
                 }
                 doAndWait(connection, null);
                 sr = impl.mapGet(connection);
                 if (DEBUG) {
-                    System.err.println("getOrCreateShared() " + connection + ": "+ ( ( null != sr ) ? "success" : "failed" ) );               
+                    System.err.println("SharedResourceRunner.getOrCreateShared() " + connection + ": "+ ( ( null != sr ) ? "success" : "failed" ) +" - "+Thread.currentThread().getName());
                 }
             }
         }
@@ -111,11 +175,11 @@ public class SharedResourceRunner implements Runnable {
             if (null != sr) {
                 removeDeviceTried(connection);
                 if (DEBUG) {
-                    System.err.println("releaseShared() " + connection + ": trying");
+                    System.err.println("SharedResourceRunner.releaseShared() " + connection + ": trying - "+Thread.currentThread().getName());
                 }
                 doAndWait(null, connection);
                 if (DEBUG) {
-                    System.err.println("releaseShared() " + connection + ": done");
+                    System.err.println("SharedResourceRunner.releaseShared() " + connection + ": done - "+Thread.currentThread().getName());
                 }
             }
         }
@@ -125,9 +189,9 @@ public class SharedResourceRunner implements Runnable {
     private final void doAndWait(String initConnection, String releaseConnection) {
         // wait until thread becomes ready to init new device,
         // pass the device and release the sync
-        String threadName = Thread.currentThread().getName();
+        final String threadName = Thread.currentThread().getName();
         if (DEBUG) {
-            System.err.println(threadName + " doAndWait START init: " + initConnection + ", release: "+releaseConnection);
+            System.err.println("SharedResourceRunner.doAndWait() START init: " + initConnection + ", release: "+releaseConnection+" - "+threadName);
         }
         synchronized (this) {
             while (!ready) {
@@ -137,7 +201,7 @@ public class SharedResourceRunner implements Runnable {
                 }
             }
             if (DEBUG) {
-                System.err.println(threadName + " initializeAndWait set command init: " + initConnection + ", release: "+releaseConnection);
+                System.err.println("SharedResourceRunner.doAndWait() set command: " + initConnection + ", release: "+releaseConnection+" - "+threadName);
             }
             this.initConnection = initConnection;
             this.releaseConnection = releaseConnection;
@@ -151,31 +215,17 @@ public class SharedResourceRunner implements Runnable {
                 }
             }
             if (DEBUG) {
-                System.err.println(threadName + " initializeAndWait END init: " + initConnection + ", release: "+releaseConnection);
+                System.err.println("SharedResourceRunner.initializeAndWait END init: " + initConnection + ", release: "+releaseConnection+" - "+threadName);
             }
         }
         // done
     }
 
-    public final void releaseAndWait() {
-        synchronized (this) {
-            shouldRelease = true;
-            this.notifyAll();
-
-            while (!released) {
-                try {
-                    this.wait();
-                } catch (InterruptedException ex) {
-                }
-            }
-        }
-    }
-
     public final void run() {
-        String threadName = Thread.currentThread().getName();
+        final String threadName = Thread.currentThread().getName();
 
         if (DEBUG) {
-            System.err.println(threadName + " STARTED");
+            System.err.println("SharedResourceRunner.run(): STARTED - " + threadName);
         }
 
         synchronized (this) {
@@ -184,21 +234,27 @@ public class SharedResourceRunner implements Runnable {
                     // wait for stop or init
                     ready = true;
                     if (DEBUG) {
-                        System.err.println(threadName + " -> ready");
+                        System.err.println("SharedResourceRunner.run(): READY - " + threadName);
                     }
                     notifyAll();
                     this.wait();
-                } catch (InterruptedException ex) { }
+                } catch (InterruptedException ex) { 
+                    shouldRelease = true;
+                    if(DEBUG) {
+                        System.err.println("SharedResourceRunner.run(): INTERRUPTED - "+Thread.currentThread().getName());                        
+                        ex.printStackTrace();
+                    }
+                }
                 ready = false;
 
                 if (!shouldRelease) {
                     if (DEBUG) {
-                        System.err.println(threadName + " woke up for device connection init: " + initConnection +
-                                                        ", release: " + releaseConnection);
+                        System.err.println("SharedResourceRunner.run(): WOKE UP for device connection init: " + initConnection +
+                                           ", release: " + releaseConnection + " - " + threadName);
                     }
                     if(null != initConnection) {
                         if (DEBUG) {
-                            System.err.println(threadName + " create Shared for: " + initConnection);
+                            System.err.println("SharedResourceRunner.run(): create Shared for: " + initConnection + " - " + threadName);
                         }
                         Resource sr = null;
                         try {
@@ -212,7 +268,7 @@ public class SharedResourceRunner implements Runnable {
                     }
                     if(null != releaseConnection) {
                         if (DEBUG) {
-                            System.err.println(threadName + " release Shared for: " + releaseConnection);
+                            System.err.println("SharedResourceRunner.run(): release Shared for: " + releaseConnection + " - " + threadName);
                         }
                         Resource sr = impl.mapGet(releaseConnection);
                         if (null != sr) {
@@ -230,26 +286,34 @@ public class SharedResourceRunner implements Runnable {
             }
 
             if (DEBUG) {
-                System.err.println(threadName + " release START");
+                System.err.println("SharedResourceRunner.run(): RELEASE START - " + threadName);
             }
 
             releaseSharedResources();
 
             if (DEBUG) {
-                System.err.println(threadName + " release END");
+                System.err.println("SharedResourceRunner.run(): RELEASE END - " + threadName);
             }
 
+            shouldRelease = false;
             released = true;
-            ready = false;
+            thread = null;
             notifyAll();
         }
     }
 
     private void releaseSharedResources() {
-        Collection/*<Resource>*/ sharedResources = impl.mapValues();
-        for (Iterator iter = sharedResources.iterator(); iter.hasNext();) {
-            Resource sr = (Resource) iter.next();
-            impl.releaseSharedResource(sr);
+        synchronized (devicesTried) {
+            devicesTried.clear();
+        }
+        Collection<Resource> sharedResources = impl.mapValues();
+        for (Iterator<Resource> iter = sharedResources.iterator(); iter.hasNext();) {
+            try {
+                impl.releaseSharedResource(iter.next());
+            } catch (Throwable t) {
+                System.err.println("Catched Exception: "+t.getStackTrace()+" - "+Thread.currentThread().getName());
+                t.printStackTrace();
+            }
         }
         impl.clear();
     }
diff --git a/src/jogl/classes/jogamp/opengl/awt/VersionApplet.java b/src/jogl/classes/jogamp/opengl/awt/VersionApplet.java
index 5856bf3..55fb3f9 100644
--- a/src/jogl/classes/jogamp/opengl/awt/VersionApplet.java
+++ b/src/jogl/classes/jogamp/opengl/awt/VersionApplet.java
@@ -67,6 +67,8 @@ public class VersionApplet extends Applet {
   private synchronized void my_init() {
     if(null != canvas) { return; }
 
+    setEnabled(true);
+    
     GLProfile glp = GLProfile.getDefault();
     GLCapabilities glcaps = new GLCapabilities(glp);
 
@@ -120,8 +122,10 @@ public class VersionApplet extends Applet {
           remove(canvas);
           canvas.destroy();
           canvas = null;
-          remove(tareaVersion);
-          tareaVersion=null;
+          remove(tareaVersion.getParent()); // remove the grid
+          tareaVersion = null;
+          tareaCaps = null;
+          setEnabled(false);
       }
   }
 
@@ -133,11 +137,13 @@ public class VersionApplet extends Applet {
 
   public void start() {
     System.err.println("VersionApplet: start() - begin");
+    canvas.setVisible(true);
     System.err.println("VersionApplet: start() - end");
   }
 
   public void stop() {
     System.err.println("VersionApplet: stop() - begin");
+    canvas.setVisible(false);
     System.err.println("VersionApplet: stop() - end");
   }
 
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
index 2deae65..62ee20f 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
@@ -35,16 +35,20 @@
 
 package jogamp.opengl.egl;
 
-import javax.media.opengl.*;
-import jogamp.opengl.*;
-
-import com.jogamp.gluegen.runtime.ProcAddressTable;
-import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver;
-import java.nio.*;
-import java.util.*;
+import java.nio.ByteBuffer;
+import java.util.Map;
 
 import javax.media.nativewindow.AbstractGraphicsConfiguration;
 import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
+
+import jogamp.opengl.GLContextImpl;
+import jogamp.opengl.GLDrawableImpl;
+
+import com.jogamp.gluegen.runtime.ProcAddressTable;
+import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver;
 
 public abstract class EGLContext extends GLContextImpl {
     private boolean eglQueryStringInitialized;
@@ -94,7 +98,7 @@ public abstract class EGLContext extends GLContextImpl {
         return true;
     }
 
-    protected void makeCurrentImpl(boolean newCreated) throws GLException {
+    protected void makeCurrentImpl() throws GLException {
         if(EGL.EGL_NO_DISPLAY==((EGLDrawable)drawable).getDisplay() ) {
             throw new GLException("drawable not properly initialized, NO DISPLAY: "+drawable);
         }
@@ -134,12 +138,12 @@ public abstract class EGLContext extends GLContextImpl {
         // FIXME
     }
 
-    protected boolean createImpl() throws GLException {
+    protected boolean createImpl(GLContextImpl shareWith) throws GLException {
         long eglDisplay = ((EGLDrawable)drawable).getDisplay();
         EGLGraphicsConfiguration config = ((EGLDrawable)drawable).getGraphicsConfiguration();
         GLProfile glProfile = drawable.getGLProfile();
         long eglConfig = config.getNativeConfig();
-        long shareWith = EGL.EGL_NO_CONTEXT;
+        long shareWithHandle = EGL.EGL_NO_CONTEXT;
 
         if (eglDisplay == 0) {
             throw new GLException("Error: attempted to create an OpenGL context without a display connection");
@@ -159,10 +163,9 @@ public abstract class EGLContext extends GLContextImpl {
             }
         }
 
-        EGLContext other = (EGLContext) GLContextShareSet.getShareContext(this);
-        if (other != null) {
-            shareWith = other.getHandle();
-            if (shareWith == 0) {
+        if (shareWith != null) {
+            shareWithHandle = shareWith.getHandle();
+            if (shareWithHandle == 0) {
                 throw new GLException("GLContextShareSet returned an invalid OpenGL context");
             }
         }
@@ -178,19 +181,18 @@ public abstract class EGLContext extends GLContextImpl {
         } else {
             throw new GLException("Error creating OpenGL context - invalid GLProfile: "+glProfile);
         }
-        contextHandle = EGL.eglCreateContext(eglDisplay, eglConfig, shareWith, contextAttrs, 0);
+        contextHandle = EGL.eglCreateContext(eglDisplay, eglConfig, shareWithHandle, contextAttrs, 0);
         if (contextHandle == 0) {
             throw new GLException("Error creating OpenGL context: eglDisplay "+toHexString(eglDisplay)+
-                                  ", eglConfig "+config+", "+glProfile+", shareWith "+toHexString(shareWith)+", error "+toHexString(EGL.eglGetError()));
+                                  ", eglConfig "+config+", "+glProfile+", shareWith "+toHexString(shareWithHandle)+", error "+toHexString(EGL.eglGetError()));
         }
-        GLContextShareSet.contextCreated(this);
         if (DEBUG) {
             System.err.println(getThreadName() + ": !!! Created OpenGL context 0x" +
                                Long.toHexString(contextHandle) + 
                                ",\n\twrite surface 0x" + Long.toHexString(drawable.getHandle()) +
                                ",\n\tread  surface 0x" + Long.toHexString(drawableRead.getHandle())+
                                ",\n\t"+this+
-                               ",\n\tsharing with 0x" + Long.toHexString(shareWith));
+                               ",\n\tsharing with 0x" + Long.toHexString(shareWithHandle));
         }
         if (!EGL.eglMakeCurrent(((EGLDrawable)drawable).getDisplay(),
                                 drawable.getHandle(),
@@ -207,12 +209,12 @@ public abstract class EGLContext extends GLContextImpl {
         } else {            
             major = 1;
         }
-        setGLFunctionAvailability(true, true, major, 0, ctp);
+        setGLFunctionAvailability(true, major, 0, ctp);
         return true;
     }
 
     protected final void updateGLXProcAddressTable() {
-        final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+        final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration();
         final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice();
         final String key = "EGL-"+adevice.getUniqueID();
         if (DEBUG) {
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java
index a9cc403..14a0a40 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java
@@ -99,7 +99,7 @@ public abstract class EGLDrawable extends GLDrawableImpl {
 
     protected void setRealizedImpl() {
         if (realized) {
-            AbstractGraphicsConfiguration aConfig = surface.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+            AbstractGraphicsConfiguration aConfig = surface.getGraphicsConfiguration();
             AbstractGraphicsDevice aDevice = aConfig.getScreen().getDevice();
             if(aDevice instanceof EGLGraphicsDevice) {
                 if(DEBUG) {
@@ -197,6 +197,16 @@ public abstract class EGLDrawable extends GLDrawableImpl {
         }
     }
 
+    protected final void swapBuffersImpl() {
+        // single-buffer is already filtered out @ GLDrawableImpl#swapBuffers()
+        if(!EGL.eglSwapBuffers(eglDisplay, eglSurface)) {
+            if(DEBUG) {
+                System.err.println("eglSwapBuffers failed:");
+                Thread.dumpStack();
+            }
+        }
+    }
+
     public int getWidth() {
         int[] tmp = new int[1];
         if (!EGL.eglQuerySurface(eglDisplay, eglSurface, EGL.EGL_WIDTH, tmp, 0)) {
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
index fb9c930..cd6d61a 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
@@ -39,6 +39,7 @@ package jogamp.opengl.egl;
 import javax.media.nativewindow.*;
 import javax.media.nativewindow.egl.EGLGraphicsDevice;
 import javax.media.opengl.*;
+import javax.media.opengl.GLProfile.ShutdownType;
 
 import com.jogamp.common.JogampRuntimeException;
 import com.jogamp.common.util.*;
@@ -50,13 +51,15 @@ import java.util.HashMap;
 import java.util.List;
 
 public class EGLDrawableFactory extends GLDrawableFactoryImpl {
-    private static final GLDynamicLookupHelper eglES1DynamicLookupHelper;
-    private static final GLDynamicLookupHelper eglES2DynamicLookupHelper;
-
-    static {
+    private static GLDynamicLookupHelper eglES1DynamicLookupHelper = null;
+    private static GLDynamicLookupHelper eglES2DynamicLookupHelper = null;
+    
+    public EGLDrawableFactory() {
+        super();
+        
         // Register our GraphicsConfigurationFactory implementations
         // The act of constructing them causes them to be registered
-        new EGLGraphicsConfigurationFactory();
+        EGLGraphicsConfigurationFactory.registerFactory();
 
         // Check for other underlying stuff ..
         if(NativeWindowFactory.TYPE_X11.equals(NativeWindowFactory.getNativeWindowType(true))) {
@@ -69,38 +72,69 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
         // to a dynamic one, where there can be 2 instances 
         // for each ES profile with their own ProcAddressTable.
 
-        GLDynamicLookupHelper tmp=null;
-        try {
-            tmp = new GLDynamicLookupHelper(new EGLES1DynamicLibraryBundleInfo());
-        } catch (GLException gle) {
-            if(DEBUG) {
-                gle.printStackTrace();
+        synchronized(EGLDrawableFactory.class) {
+            if(null==eglES1DynamicLookupHelper) {
+                GLDynamicLookupHelper tmp=null;
+                try {
+                    tmp = new GLDynamicLookupHelper(new EGLES1DynamicLibraryBundleInfo());
+                } catch (GLException gle) {
+                    if(DEBUG) {
+                        gle.printStackTrace();
+                    }
+                }
+                eglES1DynamicLookupHelper = tmp;
+                if(null!=eglES1DynamicLookupHelper && eglES1DynamicLookupHelper.isLibComplete()) {
+                    EGL.resetProcAddressTable(eglES1DynamicLookupHelper);
+                }
             }
         }
-        eglES1DynamicLookupHelper = tmp;
-        if(null!=eglES1DynamicLookupHelper && eglES1DynamicLookupHelper.isLibComplete()) {
-            EGL.resetProcAddressTable(eglES1DynamicLookupHelper);
-        }
 
-        tmp=null;
-        try {
-            tmp = new GLDynamicLookupHelper(new EGLES2DynamicLibraryBundleInfo());
-        } catch (GLException gle) {
-            if(DEBUG) {
-                gle.printStackTrace();
+        synchronized(EGLDrawableFactory.class) {
+            if(null==eglES2DynamicLookupHelper) {
+                GLDynamicLookupHelper tmp=null;
+                try {
+                    tmp = new GLDynamicLookupHelper(new EGLES2DynamicLibraryBundleInfo());
+                } catch (GLException gle) {
+                    if(DEBUG) {
+                        gle.printStackTrace();
+                    }
+                }
+                eglES2DynamicLookupHelper = tmp;
+                if(null!=eglES2DynamicLookupHelper && eglES2DynamicLookupHelper.isLibComplete()) {
+                    EGL.resetProcAddressTable(eglES2DynamicLookupHelper);
+                }
             }
         }
-        eglES2DynamicLookupHelper = tmp;
-        if(null!=eglES2DynamicLookupHelper && eglES2DynamicLookupHelper.isLibComplete()) {
-            EGL.resetProcAddressTable(eglES2DynamicLookupHelper);
+        if(null != eglES1DynamicLookupHelper || null != eglES2DynamicLookupHelper) {
+            defaultDevice = new EGLGraphicsDevice(AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT);
+            sharedMap = new HashMap();
         }
     }
 
-    public EGLDrawableFactory() {
-        super();
-        defaultDevice = new EGLGraphicsDevice(AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT);
+    protected final void destroy(ShutdownType shutdownType) {
+        if(null != sharedMap) {
+            sharedMap.clear();
+            sharedMap = null;
+        }
+        defaultDevice = null;
+        /**
+         * Pulling away the native library may cause havoc ..
+         * 
+        if(ShutdownType.COMPLETE == shutdownType) {
+            if(null != eglES1DynamicLookupHelper) {
+                eglES1DynamicLookupHelper.destroy();
+                eglES1DynamicLookupHelper = null;
+            }
+            if(null != eglES2DynamicLookupHelper) {
+                eglES2DynamicLookupHelper.destroy();
+                eglES2DynamicLookupHelper = null;
+            }
+        } */
     }
 
+    private HashMap/*<connection, SharedResource>*/ sharedMap;
+    private EGLGraphicsDevice defaultDevice;
+
     static class SharedResource {
       private EGLGraphicsDevice device;
       // private EGLDrawable drawable;
@@ -125,8 +159,6 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
       final boolean wasES1ContextAvailable() { return wasES1ContextCreated; }
       final boolean wasES2ContextAvailable() { return wasES2ContextCreated; }
     }
-    HashMap/*<connection, SharedResource>*/ sharedMap = new HashMap();
-    EGLGraphicsDevice defaultDevice;
 
     public final AbstractGraphicsDevice getDefaultDevice() {
       return defaultDevice;
@@ -136,6 +168,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
       return true; // via mappings (X11/WGL/.. -> EGL) we shall be able to handle all types.
     }
 
+    /**
     private boolean isEGLContextAvailable(EGLGraphicsDevice sharedDevice, String profile) {
         boolean madeCurrent = false;
         final GLCapabilities caps = new GLCapabilities(GLProfile.get(profile));
@@ -163,9 +196,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
             drawable.destroy();
         }
         return madeCurrent;
-    }
+    } */
     
-    private SharedResource getOrCreateShared(AbstractGraphicsDevice adevice) {
+    /* package */ SharedResource getOrCreateEGLSharedResource(AbstractGraphicsDevice adevice) {
         String connection = adevice.getConnection();
         SharedResource sr;
         synchronized(sharedMap) {
@@ -199,10 +232,21 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
         return sr;
     }
 
-    public final boolean getWasSharedContextCreated(AbstractGraphicsDevice device) {
-        SharedResource sr = getOrCreateShared(device);
-        if(null!=sr) {
-            return sr.wasES1ContextAvailable() || sr.wasES2ContextAvailable();
+    protected final Thread getSharedResourceThread() {
+        return null;
+    }
+    
+    protected final boolean createSharedResource(AbstractGraphicsDevice device) {
+        try {
+            SharedResource sr = getOrCreateEGLSharedResource(device);
+            if(null!=sr) {
+                return sr.wasES1ContextAvailable() || sr.wasES2ContextAvailable();
+            }
+        } catch (GLException gle) {
+            if(DEBUG) {
+                System.err.println("Catched Exception while EGL Shared Resource initialization");
+                gle.printStackTrace();
+            }
         }
         return false;        
     }
@@ -212,17 +256,13 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
     }
     
     protected AbstractGraphicsDevice getOrCreateSharedDeviceImpl(AbstractGraphicsDevice device) {
-        SharedResource sr = getOrCreateShared(device);
+        SharedResource sr = getOrCreateEGLSharedResource(device);
         if(null!=sr) {
             return sr.getDevice();
         }
         return null;
     }
 
-    SharedResource getOrCreateSharedResource(AbstractGraphicsDevice device) {
-        return (SharedResource) getOrCreateShared(device);
-    }
-
     public GLDynamicLookupHelper getGLDynamicLookupHelper(int esProfile) {
         if (2==esProfile) {
             if(null==eglES2DynamicLookupHelper) {
@@ -239,8 +279,6 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
         }
     }
 
-    protected final void shutdownInstance() {}
-
     protected List<GLCapabilitiesImmutable> getAvailableCapabilitiesImpl(AbstractGraphicsDevice device) {
         return EGLGraphicsConfigurationFactory.getAvailableCapabilities(this, device);
     }
@@ -256,7 +294,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
         if (target == null) {
           throw new IllegalArgumentException("Null target");
         }
-        AbstractGraphicsConfiguration config = target.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+        AbstractGraphicsConfiguration config = target.getGraphicsConfiguration();
         GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
         if(!caps.isPBuffer()) {
             throw new GLException("Non pbuffer not yet implemented");
@@ -271,7 +309,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
 
     protected NativeSurface createOffscreenSurfaceImpl(AbstractGraphicsDevice device, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height) {
         WrappedSurface ns = new WrappedSurface(EGLGraphicsConfigurationFactory.createOffscreenGraphicsConfiguration(device, capsChosen, capsRequested, chooser));
-        ns.setSize(width, height);
+        ns.surfaceSizeChanged(width, height);
         return ns;
     }
 
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java
index 33154b0..1f9254b 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java
@@ -29,18 +29,11 @@
 package jogamp.opengl.egl;
 
 import com.jogamp.common.os.AndroidVersion;
-import com.jogamp.common.os.DynamicLookupHelper;
-import com.jogamp.common.os.NativeLibrary;
-import com.jogamp.common.os.Platform;
 
 import java.util.*;
 
-import javax.media.nativewindow.*;
-import javax.media.opengl.*;
 import jogamp.opengl.*;
 
-import java.security.*;
-
 /**
  * Abstract implementation of the DynamicLookupHelper for EGL,
  * which decouples it's dependencies to EGLDrawable.
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java
index 3b0fc59..63109f4 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java
@@ -30,10 +30,6 @@ package jogamp.opengl.egl;
 
 import java.util.*;
 
-import com.jogamp.common.os.Platform;
-
-import jogamp.opengl.*;
-
 public class EGLES1DynamicLibraryBundleInfo extends EGLDynamicLibraryBundleInfo {
     protected EGLES1DynamicLibraryBundleInfo() {
         super();
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java
index 28c480b..b0748ad 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java
@@ -30,10 +30,6 @@ package jogamp.opengl.egl;
 
 import java.util.*;
 
-import com.jogamp.common.os.Platform;
-
-import jogamp.opengl.*;
-
 public class EGLES2DynamicLibraryBundleInfo extends EGLDynamicLibraryBundleInfo {
     protected EGLES2DynamicLibraryBundleInfo() {
         super();
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java
index 389daa7..796a431 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java
@@ -45,7 +45,7 @@ public class EGLExternalContext extends EGLContext {
     public EGLExternalContext(AbstractGraphicsScreen screen) {
         super(null, null);
         GLContextShareSet.contextCreated(this);
-        setGLFunctionAvailability(false, true, 0, 0, CTX_IS_ARB_CREATED|CTX_PROFILE_ES|CTX_OPTION_ANY);
+        setGLFunctionAvailability(false, 0, 0, CTX_IS_ARB_CREATED|CTX_PROFILE_ES|CTX_OPTION_ANY);
         getGLStateTracker().setEnabled(false); // external context usage can't track state in Java
     }
 
@@ -66,7 +66,7 @@ public class EGLExternalContext extends EGLContext {
         lastContext = null;
     }
 
-    protected void makeCurrentImpl(boolean newCreated) throws GLException {
+    protected void makeCurrentImpl() throws GLException {
     }
 
     protected void releaseImpl() throws GLException {
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
index 8a423c6..bd5eb1b 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
@@ -40,22 +40,11 @@ public class EGLGLCapabilities extends GLCapabilities {
   int nativeVisualID;
   
   /** Comparing EGLConfig ID only */
-  public static class EglCfgIDComparator implements Comparator {
+  public static class EglCfgIDComparator implements Comparator<EGLGLCapabilities> {
 
-      public int compare(Object o1, Object o2) {
-        if ( ! ( o1 instanceof EGLGLCapabilities ) ) {
-            Class c = (null != o1) ? o1.getClass() : null ;
-            throw new ClassCastException("arg1 not a EGLGLCapabilities object: " + c);
-        }
-        if ( ! ( o2 instanceof EGLGLCapabilities ) ) {
-            Class c = (null != o2) ? o2.getClass() : null ;
-            throw new ClassCastException("arg2 not a EGLGLCapabilities object: " + c);
-        }
-
-        final EGLGLCapabilities caps1 = (EGLGLCapabilities) o1;
+      public int compare(EGLGLCapabilities caps1, EGLGLCapabilities caps2) {
         final long id1 = caps1.getEGLConfigID();
 
-        final EGLGLCapabilities caps2 = (EGLGLCapabilities) o2;
         final long id2 = caps2.getEGLConfigID();
 
         if(id1 > id2) {
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
index 14e67a2..ea625fb 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
@@ -38,15 +38,25 @@ package jogamp.opengl.egl;
 
 import java.nio.IntBuffer;
 import java.util.ArrayList;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.egl.*;
-import javax.media.opengl.*;
+
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.AbstractGraphicsScreen;
+import javax.media.nativewindow.GraphicsConfigurationFactory;
+import javax.media.nativewindow.egl.EGLGraphicsDevice;
+import javax.media.opengl.DefaultGLCapabilitiesChooser;
+import javax.media.opengl.GLCapabilitiesChooser;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
+
+import jogamp.nativewindow.MutableGraphicsConfiguration;
+import jogamp.opengl.Debug;
+import jogamp.opengl.GLGraphicsConfigurationUtil;
 
 import com.jogamp.common.nio.Buffers;
 import com.jogamp.common.nio.PointerBuffer;
-import jogamp.opengl.*;
 
-public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration implements Cloneable {
+public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable {
     protected static final boolean DEBUG = Debug.debug("GraphicsConfiguration");
 
     public final long getNativeConfig() {
@@ -217,6 +227,17 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
             caps.setSampleBuffers(val.get(0)>0?true:false);
             caps.setNumSamples(val.get(0));
         }
+        if(!caps.getSampleBuffers()) {
+            // try NV_coverage_sample extension 
+            if(EGL.eglGetConfigAttrib(display, config, EGLExt.EGL_COVERAGE_BUFFERS_NV, val)) {
+                if(val.get(0)>0 &&
+                   EGL.eglGetConfigAttrib(display, config, EGLExt.EGL_COVERAGE_SAMPLES_NV, val)) {
+                    caps.setSampleExtension(GLGraphicsConfigurationUtil.NV_coverage_sample); 
+                    caps.setSampleBuffers(true);
+                    caps.setNumSamples(val.get(0));
+                }
+            }
+        }
         if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_TYPE, val)) {
             caps.setBackgroundOpaque(val.get(0) != EGL.EGL_TRANSPARENT_RGB);
         }
@@ -263,13 +284,25 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
         attrs[idx++] = EGL.EGL_DEPTH_SIZE;
         attrs[idx++] = caps.getDepthBits();
 
-        attrs[idx++] = EGL.EGL_SAMPLES;
-        attrs[idx++] = caps.getSampleBuffers() ? caps.getNumSamples() : 1;
+        if(caps.getSampleBuffers()) {
+            if(caps.getSampleExtension().equals(GLGraphicsConfigurationUtil.NV_coverage_sample)) {
+                attrs[idx++] = EGLExt.EGL_COVERAGE_BUFFERS_NV;
+                attrs[idx++] = 1;
+                attrs[idx++] = EGLExt.EGL_COVERAGE_SAMPLES_NV;
+                attrs[idx++] = caps.getNumSamples();
+            } else {
+                // try default ..
+                attrs[idx++] = EGL.EGL_SAMPLE_BUFFERS;
+                attrs[idx++] = 1;
+                attrs[idx++] = EGL.EGL_SAMPLES;
+                attrs[idx++] = caps.getNumSamples();
+            }
+        }
 
         attrs[idx++] = EGL.EGL_TRANSPARENT_TYPE;
         attrs[idx++] = caps.isBackgroundOpaque() ? EGL.EGL_NONE : EGL.EGL_TRANSPARENT_TYPE;
 
-        // 20
+        // 22
 
         if(!caps.isBackgroundOpaque()) {
             attrs[idx++] = EGL.EGL_TRANSPARENT_RED_VALUE;
@@ -286,7 +319,7 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
             attrs[idx++] = caps.getTransparentAlphaValue()>=0?caps.getTransparentAlphaValue():EGL.EGL_DONT_CARE; */
         }
 
-        // 26 
+        // 28 
         attrs[idx++] = EGL.EGL_RENDERABLE_TYPE;
         if(caps.getGLProfile().usesNativeGLES1()) {
             attrs[idx++] = EGL.EGL_OPENGL_ES_BIT;
@@ -296,7 +329,7 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
             attrs[idx++] = EGL.EGL_OPENGL_BIT;
         }
 
-        // 28
+        // 30
 
         attrs[idx++] = EGL.EGL_NONE;
 
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
index 8c1cf88..ceeebe6 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
@@ -69,9 +69,11 @@ import java.nio.IntBuffer;
 public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFactory {
     static EGLGLCapabilities.EglCfgIDComparator EglCfgIDComparator = new EGLGLCapabilities.EglCfgIDComparator();
 
-    EGLGraphicsConfigurationFactory() {
+    static void registerFactory() {
         // become the selector for KD/EGL ..
-        GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.egl.EGLGraphicsDevice.class, this);
+        GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.egl.EGLGraphicsDevice.class, new EGLGraphicsConfigurationFactory());
+    }
+    private EGLGraphicsConfigurationFactory() {
     }
 
     protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl (
@@ -101,7 +103,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
     }
 
     protected static List<GLCapabilitiesImmutable> getAvailableCapabilities(EGLDrawableFactory factory, AbstractGraphicsDevice device) {
-        EGLDrawableFactory.SharedResource sharedResource = factory.getOrCreateSharedResource(device);
+        EGLDrawableFactory.SharedResource sharedResource = factory.getOrCreateEGLSharedResource(device);
         if(null == sharedResource) {
             throw new GLException("Shared resource for device n/a: "+device);
         }
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java
index 7d5e044..42f067b 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java
@@ -55,15 +55,5 @@ public class EGLOnscreenDrawable extends EGLDrawable {
     protected long createSurface(long eglDpy, long eglNativeCfg, long surfaceHandle) {
         return EGL.eglCreateWindowSurface(eglDpy, eglNativeCfg, surfaceHandle, null);
     }
-
-    protected void swapBuffersImpl() {
-        if(!EGL.eglSwapBuffers(eglDisplay, eglSurface)) {
-            if(DEBUG) {
-                System.err.println("eglSwapBuffers failed:");
-                Thread.dumpStack();
-            }
-        }
-    }
-
 }
 
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java
index 5fb32e6..28a23d2 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java
@@ -40,48 +40,39 @@
 
 package jogamp.opengl.egl;
 
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
 import javax.media.nativewindow.NativeSurface;
 import javax.media.nativewindow.SurfaceChangeable;
 import javax.media.opengl.GLCapabilitiesImmutable;
 import javax.media.opengl.GLContext;
 import javax.media.opengl.GLException;
 
-import jogamp.opengl.x11.glx.GLX;
-
 public class EGLPbufferDrawable extends EGLDrawable {
     private int texFormat;
     protected static final boolean useTexture = false; // No yet ..
 
     protected EGLPbufferDrawable(EGLDrawableFactory factory, NativeSurface target) {
         super(factory, target);
+    }
 
-        // get choosen ones ..
-        GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)
-                   getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+    protected void destroyImpl() {
+        setRealized(false);
+    }
+    
+    protected long createSurface(long eglDpy, long eglNativeCfg, long surfaceHandle) {
+        final AbstractGraphicsConfiguration config = getNativeSurface().getGraphicsConfiguration();
+        final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
 
         if(useTexture) {
-            this.texFormat = caps.getAlphaBits() > 0 ? EGL.EGL_TEXTURE_RGBA : EGL.EGL_TEXTURE_RGB ;
+            texFormat = caps.getAlphaBits() > 0 ? EGL.EGL_TEXTURE_RGBA : EGL.EGL_TEXTURE_RGB ;
         } else {
-            this.texFormat = EGL.EGL_NO_TEXTURE;
+            texFormat = EGL.EGL_NO_TEXTURE;
         }
 
         if (DEBUG) {
-          System.out.println("Pbuffer config: " + getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration());
-        }
-
-        setRealized(true);
-
-        if (DEBUG) {
-          System.out.println("Created pbuffer: " + this);
+          System.out.println("Pbuffer config: " + config);
         }
 
-    }
-
-    protected void destroyImpl() {
-        setRealized(false);
-    }
-    
-    protected long createSurface(long eglDpy, long eglNativeCfg, long surfaceHandle) {
         NativeSurface nw = getNativeSurface();
         int[] attrs = EGLGraphicsConfiguration.CreatePBufferSurfaceAttribList(nw.getWidth(), nw.getHeight(), texFormat);
         long surf = EGL.eglCreatePbufferSurface(eglDpy, eglNativeCfg, attrs, 0);
@@ -97,11 +88,5 @@ public class EGLPbufferDrawable extends EGLDrawable {
     public GLContext createContext(GLContext shareWith) {
         return new EGLPbufferContext(this, shareWith);
     }
-
-    protected void swapBuffersImpl() { 
-        if(DEBUG) {
-            System.err.println("unhandled swapBuffersImpl() called for: "+this);
-        }
-    }
 }
 
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
index 6d6b79b..77da265 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
@@ -40,17 +40,94 @@
 
 package jogamp.opengl.macosx.cgl;
 
-import java.nio.*;
-import java.util.*;
-import javax.media.opengl.*;
-import javax.media.nativewindow.*;
-import jogamp.opengl.*;
+import java.nio.ByteBuffer;
+import java.util.Map;
+
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.nativewindow.OffscreenLayerSurface;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
+
+import jogamp.opengl.GLContextImpl;
+import jogamp.opengl.GLDrawableImpl;
+import jogamp.opengl.GLGraphicsConfigurationUtil;
+import jogamp.opengl.macosx.cgl.MacOSXCGLDrawable.GLBackendType;
+
+import com.jogamp.common.nio.PointerBuffer;
+import com.jogamp.common.os.Platform;
+import com.jogamp.common.util.VersionNumber;
 import com.jogamp.gluegen.runtime.ProcAddressTable;
 import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver;
 
 public abstract class MacOSXCGLContext extends GLContextImpl
 {    
-  protected boolean isNSContext;
+  // Abstract interface for implementation of this context (either
+  // NSOpenGL-based or CGL-based)
+  protected interface GLBackendImpl {
+        boolean isNSContext();
+        long create(long share, int ctp, int major, int minor);
+        boolean destroy(long ctx);
+        boolean copyImpl(long src, int mask);
+        boolean makeCurrent(long ctx);
+        boolean release(long ctx);
+        boolean setSwapInterval(int interval);
+        boolean swapBuffers();
+  }
+      
+  /* package */ static final boolean isTigerOrLater;
+  /* package */ static final boolean isLionOrLater;
+
+  static {
+    final VersionNumber osvn = Platform.getOSVersionNumber();
+    isTigerOrLater = osvn.getMajor() > 10 || ( osvn.getMajor() == 10 && osvn.getMinor() >= 4 );
+    isLionOrLater  = osvn.getMajor() > 10 || ( osvn.getMajor() == 10 && osvn.getMinor() >= 7 );
+  }
+
+  static boolean isGLProfileSupported(int ctp, int major, int minor) {
+    boolean ctBwdCompat = 0 != ( CTX_PROFILE_COMPAT & ctp ) ;
+    boolean ctCore      = 0 != ( CTX_PROFILE_CORE & ctp ) ;
+    
+    // We exclude 3.0, since we would map it's core to GL2. Hence we force mapping 2.1 to GL2
+    if(3==major && 1<=minor && minor<=2) {
+        // [3.1..3.2] -> GL3*
+        if(!isLionOrLater) {
+            // no GL3* on pre lion
+            return false;
+        }
+        if(ctBwdCompat) {
+            // no compatibility profile on OS X
+            return false;
+        }
+        return ctCore;
+    } else if(major<3) {
+        // < 3.0 -> GL2
+        return true;
+    }
+    return false; // 3.0 && > 3.2
+  }
+  static int GLProfile2CGLOGLProfileValue(int ctp, int major, int minor) {
+    if(!MacOSXCGLContext.isGLProfileSupported(ctp, major, minor)) {
+        throw new GLException("OpenGL profile not supported: "+getGLVersion(major, minor, ctp, "@GLProfile2CGLOGLProfileVersion"));
+    }
+    boolean ctCore      = 0 != ( CTX_PROFILE_CORE & ctp ) ;
+    if( major == 3 && minor >= 1 && ctCore ) {
+        return CGL.kCGLOGLPVersion_3_2_Core;
+    } else {
+        return CGL.kCGLOGLPVersion_Legacy;
+    }        
+  }  
+
+  private boolean haveSetOpenGLMode = false;
+  private GLBackendType openGLMode = GLBackendType.NSOPENGL;
+  
+  // Implementation object (either NSOpenGL-based or CGL-based)
+  protected GLBackendImpl impl;
+      
   private CGLExt _cglExt;
   // Table that holds the addresses of the native C-language entry points for
   // CGL extension functions.
@@ -59,11 +136,11 @@ public abstract class MacOSXCGLContext extends GLContextImpl
   protected MacOSXCGLContext(GLDrawableImpl drawable,
                    GLContext shareWith) {
     super(drawable, shareWith);
+    initOpenGLImpl(getOpenGLMode());
   }
   
   @Override
   protected void resetStates() {
-    isNSContext = false;
     // no inner state _cglExt = null;
     super.resetStates();
   }
@@ -72,7 +149,9 @@ public abstract class MacOSXCGLContext extends GLContextImpl
     return getCGLExt();
   }
 
-  protected boolean isNSContext() { return isNSContext; }
+  protected boolean isNSContext() { 
+      return (null != impl) ? impl.isNSContext() : this.openGLMode == GLBackendType.NSOPENGL; 
+  }
 
   public CGLExt getCGLExt() {
     if (_cglExt == null) {
@@ -94,146 +173,128 @@ public abstract class MacOSXCGLContext extends GLContextImpl
   protected Map<String, String> getExtensionNameMap() { return null; }
 
   protected long createContextARBImpl(long share, boolean direct, int ctp, int major, int minor) {
-      return 0; // FIXME
+    if(!isGLProfileSupported(ctp, major, minor)) {
+        if(DEBUG) {
+            System.err.println(getThreadName() + ": createContextARBImpl: Not supported "+getGLVersion(major, minor, ctp, "@creation on OSX "+Platform.getOSVersionNumber()));
+        }
+        return 0;
+    }
+
+    // Will throw exception upon error
+    long ctx = impl.create(share, ctp, major, minor);
+    if(0 != ctx) {
+        if (!impl.makeCurrent(ctx)) {
+          if(DEBUG) {
+              System.err.println(getThreadName() + ": createContextARB couldn't make current "+getGLVersion(major, minor, ctp, "@creation"));
+          }
+          impl.release(ctx);
+          impl.destroy(ctx);
+          ctx = 0;
+        } else if(DEBUG) {
+            System.err.println(getThreadName() + ": createContextARBImpl: OK "+getGLVersion(major, minor, ctp, "@creation")+", share "+share+", direct "+direct+" on OSX "+Platform.getOSVersionNumber());
+        }
+    } else if(DEBUG) {
+        System.err.println(getThreadName() + ": createContextARBImpl: NO "+getGLVersion(major, minor, ctp, "@creation on OSX "+Platform.getOSVersionNumber()));
+    }
+    return ctx;
   }
 
   protected void destroyContextARBImpl(long _context) {
-      // FIXME
+      impl.release(_context);
+      impl.destroy(_context);
   }
 
   public final boolean isGLReadDrawableAvailable() {
     return false;
   }
 
-  /**
-   * Creates and initializes an appropriate OpenGl Context (NS). Should only be
-   * called by {@link makeCurrentImpl()}.
-   */
-  protected boolean create(boolean pbuffer, boolean floatingPoint) {
-    MacOSXCGLContext other = (MacOSXCGLContext) GLContextShareSet.getShareContext(this);
+  protected long createImplPreset(GLContextImpl shareWith) throws GLException {
     long share = 0;
-    if (other != null) {
-      if (!other.isNSContext()) {
-        throw new GLException("GLContextShareSet is not a NS Context");
-      }
-      share = other.getHandle();
+    if (shareWith != null) {
+      // Change our OpenGL mode to match that of any share context before we create ourselves
+      setOpenGLMode(((MacOSXCGLContext)shareWith).getOpenGLMode());
+      share = shareWith.getHandle();
       if (share == 0) {
         throw new GLException("GLContextShareSet returned a NULL OpenGL context");
       }
     }
-    MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
-    GLCapabilitiesImmutable capabilitiesRequested = (GLCapabilitiesImmutable) config.getRequestedCapabilities();
-    GLProfile glProfile = capabilitiesRequested.getGLProfile();
-    if(glProfile.isGL3()) {
-        throw new GLException("GL3 profile currently not supported on MacOSX, due to the lack of a OpenGL 3.1 implementation");
-    }
-    // HACK .. bring in OnScreen/PBuffer selection to the DrawableFactory !!
-    GLCapabilities capabilities = (GLCapabilities) capabilitiesRequested.cloneMutable();
-    capabilities.setPBuffer(pbuffer);
-    capabilities.setPbufferFloatingPointBuffers(floatingPoint);
-
-    long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2NSPixelFormat(capabilities);
-    if (pixelFormat == 0) {
-      throw new GLException("Unable to allocate pixel format with requested GLCapabilities");
-    }
-    config.setChosenPixelFormat(pixelFormat);
-    try {
-      int[] viewNotReady = new int[1];
-      // Try to allocate a context with this
-      contextHandle = CGL.createContext(share,
-                                    drawable.getHandle(),
-                                    pixelFormat,
-                                    capabilities.isBackgroundOpaque(),
-                                    viewNotReady, 0);
-      if (contextHandle == 0) {
-        if (viewNotReady[0] == 1) {
-          if (DEBUG) {
-            System.err.println("!!! View not ready for " + getClass().getName());
-          }
-          // View not ready at the window system level -- this is OK
-          return false;
-        }
-        throw new GLException("Error creating NSOpenGLContext with requested pixel format");
-      }
-
-      if (!pbuffer && !capabilities.isBackgroundOpaque()) {
-          // Set the context opacity
-          CGL.setContextOpacity(contextHandle, 0);
-      }
-
-      GLCapabilitiesImmutable caps = MacOSXCGLGraphicsConfiguration.NSPixelFormat2GLCapabilities(glProfile, pixelFormat);
-      caps = GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(caps, capabilities.isBackgroundOpaque());
-      config.setChosenCapabilities(caps);
-    } finally {
-      CGL.deletePixelFormat(pixelFormat);
+    
+    MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration();
+    GLCapabilitiesImmutable capabilitiesChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities();
+    if (capabilitiesChosen.getPbufferFloatingPointBuffers() && !isTigerOrLater) {
+       throw new GLException("Floating-point pbuffers supported only on OS X 10.4 or later");
     }
-    if (!CGL.makeCurrentContext(contextHandle)) {
-      throw new GLException("Error making Context (NS) current");
+    GLProfile glp = capabilitiesChosen.getGLProfile();
+    if(glp.isGLES1() || glp.isGLES2() || glp.isGL4() || glp.isGL3() && !isLionOrLater) {
+        throw new GLException("OpenGL profile not supported on MacOSX "+Platform.getOSVersionNumber()+": "+glp);
     }
-    isNSContext = true;
-    setGLFunctionAvailability(true, true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
-    GLContextShareSet.contextCreated(this);
-    return true;
+    
+    if (DEBUG) {
+      System.err.println("!!! Share context is " + toHexString(share) + " for " + this);
+    }
+    return share;      
   }
-
-  protected void makeCurrentImpl(boolean newCreated) throws GLException {
-    if ( isNSContext ) {
-        if (!CGL.makeCurrentContext(contextHandle)) {
-          throw new GLException("Error making Context (NS) current");
-        }
-    } else {
-        if (CGL.kCGLNoError != CGL.CGLSetCurrentContext(contextHandle)) {
-          throw new GLException("Error making Context (CGL) current");
-        }
+  
+  protected boolean createImpl(GLContextImpl shareWith) throws GLException {
+    long share = createImplPreset(shareWith);
+    contextHandle = createContextARB(share, true);
+    return 0 != contextHandle;
+  }
+  
+  protected void makeCurrentImpl() throws GLException {
+    if (getOpenGLMode() != ((MacOSXCGLDrawable)drawable).getOpenGLMode()) {
+      setOpenGLMode(((MacOSXCGLDrawable)drawable).getOpenGLMode());
     }
+    if (!impl.makeCurrent(contextHandle)) {
+      throw new GLException("Error making Context current: "+this);
+    }      
   }
     
   protected void releaseImpl() throws GLException {
-    if ( isNSContext ) {
-        if (!CGL.clearCurrentContext(contextHandle)) {
-          throw new GLException("Error freeing OpenGL Context (NS)");
-        }
-    } else {
-        CGL.CGLReleaseContext(contextHandle);
+    if (!impl.release(contextHandle)) {
+      throw new GLException("Error releasing OpenGL Context: "+this);
     }
   }
-    
+
   protected void destroyImpl() throws GLException {
-    if ( !isNSContext ) {
-      if (CGL.kCGLNoError != CGL.CGLDestroyContext(contextHandle)) {
-        throw new GLException("Unable to delete OpenGL Context (CGL)");
-      }
-      if (DEBUG) {
-        System.err.println("!!! Destroyed OpenGL Context (CGL) " + contextHandle);
-      }
-    } else {
-      if (!CGL.deleteContext(contextHandle)) {
-        throw new GLException("Unable to delete OpenGL Context (NS)");
-      }
-      if (DEBUG) {
-        System.err.println("!!! Destroyed OpenGL Context (NS) " + contextHandle);
-      }
+    if(!impl.destroy(contextHandle)) {
+        throw new GLException("Error destroying OpenGL Context: "+this);
     }
   }
 
   protected void copyImpl(GLContext source, int mask) throws GLException {
-    long dst = getHandle();
-    long src = source.getHandle();
-    if( !isNSContext() ) {
-        if ( ((MacOSXCGLContext)source).isNSContext() ) {
-          throw new GLException("Source OpenGL Context is NS ; Destination Context is CGL.");
-        }
-        CGL.CGLCopyContext(src, dst, mask);
-    } else {
-        if ( !((MacOSXCGLContext)source).isNSContext() ) {
-          throw new GLException("Source OpenGL Context is CGL ; Destination Context is NS.");
-        }
-        CGL.copyContext(dst, src, mask);
+    if( isNSContext() != ((MacOSXCGLContext)source).isNSContext() ) {
+        throw new GLException("Source/Destination OpenGL Context tyoe mismatch: source "+source+", dest: "+this);
+    }
+    if(!impl.copyImpl(source.getHandle(), mask)) {
+        throw new GLException("Error copying OpenGL Context: source "+source+", dest: "+this);
     }
   }
 
+  protected void swapBuffers() {
+    // single-buffer is already filtered out @ GLDrawableImpl#swapBuffers()
+    if(!impl.swapBuffers()) {
+        throw new GLException("Error swapping buffers: "+this);        
+    }
+  }
+
+  protected void setSwapIntervalImpl(int interval) {
+    if( ! isCreated() ) {
+        throw new GLException("OpenGL context not created");
+    } 
+    if(!impl.setSwapInterval(interval)) {
+        throw new GLException("Error set swap-interval: "+this);        
+    }
+    currentSwapInterval = interval ;
+  }
+
+  public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) {
+    // FIXME: apparently the Apple extension doesn't require a custom memory allocator
+    throw new GLException("Not yet implemented");
+  }
+
   protected final void updateGLXProcAddressTable() {
-    final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+    final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration();
     final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice();
     final String key = "MacOSX-"+adevice.getUniqueID();
     if (DEBUG) {
@@ -250,8 +311,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl
         }
     } else {
         if (cglExtProcAddressTable == null) {
-          // FIXME: cache ProcAddressTables by capability bits so we can
-          // share them among contexts with the same capabilities
           cglExtProcAddressTable = new CGLExtProcAddressTable(new GLProcAddressResolver());
         }
         resetProcAddressTable(getCGLExtProcAddressTable());
@@ -268,40 +327,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl
     return new StringBuffer();
   }
     
-  protected void swapBuffers() {
-    DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
-    GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)config.getChosenCapabilities();
-    if(caps.isOnscreen()) {
-        if(isNSContext) {
-            if (!CGL.flushBuffer(contextHandle)) {
-              throw new GLException("Error swapping buffers (NS)");
-            }
-        } else {
-            if (CGL.kCGLNoError != CGL.CGLFlushDrawable(contextHandle)) {
-              throw new GLException("Error swapping buffers (CGL)");
-            }
-        }
-    }
-  }
-
-  protected void setSwapIntervalImpl(int interval) {
-    if( ! isCreated() ) {
-        throw new GLException("OpenGL context not created");
-    } 
-    if ( isNSContext ) {
-        CGL.setSwapInterval(contextHandle, interval);
-    } else {
-        int[] lval = new int[] { (int) interval } ;
-        CGL.CGLSetParameter(contextHandle, CGL.kCGLCPSwapInterval, lval, 0);
-    }
-    currentSwapInterval = interval ;
-  }
-
-  public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) {
-    // FIXME: apparently the Apple extension doesn't require a custom memory allocator
-    throw new GLException("Not yet implemented");
-  }
-
   public boolean isExtensionAvailable(String glExtensionName) {
     if (glExtensionName.equals("GL_ARB_pbuffer") ||
         glExtensionName.equals("GL_ARB_pixel_format")) {
@@ -331,6 +356,303 @@ public abstract class MacOSXCGLContext extends GLContextImpl
   }
     
   // Support for "mode switching" as described in MacOSXCGLDrawable
-  public abstract void setOpenGLMode(int mode);
-  public abstract int  getOpenGLMode();
+  public void setOpenGLMode(GLBackendType mode) {
+      if (mode == openGLMode) {
+        return;
+      }
+      if (haveSetOpenGLMode) {
+        throw new GLException("Can't switch between using NSOpenGLPixelBuffer and CGLPBufferObj more than once");
+      }
+      destroyImpl();
+      ((MacOSXCGLDrawable)drawable).setOpenGLMode(mode);
+      if (DEBUG) {
+        System.err.println("Switching context mode " + openGLMode + " -> " + mode);
+      }
+      initOpenGLImpl(mode);
+      openGLMode = mode;
+      haveSetOpenGLMode = true;      
+  }
+  public final GLBackendType getOpenGLMode() { return openGLMode; }
+  
+  protected void initOpenGLImpl(GLBackendType backend) {
+    switch (backend) {
+      case NSOPENGL:
+        impl = new NSOpenGLImpl();
+        break;
+      case CGL:
+        impl = new CGLImpl();
+        break;
+      default:
+        throw new InternalError("Illegal implementation mode " + backend);
+    }
+  }  
+  
+  public String toString() {
+    StringBuffer sb = new StringBuffer();
+    sb.append(getClass().getSimpleName());
+    sb.append(" [");
+    super.append(sb);
+    sb.append(", mode ");
+    sb.append(openGLMode);
+    sb.append("] ");
+    return sb.toString();
+  }
+  
+  // NSOpenGLContext-based implementation
+  class NSOpenGLImpl implements GLBackendImpl {
+    long nsOpenGLLayer = 0;
+    long nsOpenGLLayerPFmt = 0;
+    
+    public boolean isNSContext() { return true; }
+
+    public long create(long share, int ctp, int major, int minor) {
+        long ctx = 0;
+        final MacOSXCGLDrawable drawable = (MacOSXCGLDrawable) MacOSXCGLContext.this.drawable;
+        final NativeSurface surface = drawable.getNativeSurface();
+        final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) surface.getGraphicsConfiguration();
+        final OffscreenLayerSurface backingLayerHost = NativeWindowFactory.getOffscreenLayerSurface(surface, true);        
+        final GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
+        long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2NSPixelFormat(chosenCaps, ctp, major, minor);
+        if (pixelFormat == 0) {
+          throw new GLException("Unable to allocate pixel format with requested GLCapabilities");
+        }
+        config.setChosenPixelFormat(pixelFormat);
+        if(DEBUG) {
+            System.err.println("NS create OSX>=lion "+isLionOrLater);
+            System.err.println("NS create backingLayerHost: "+backingLayerHost);
+            System.err.println("NS create share: "+share);
+            System.err.println("NS create chosenCaps: "+chosenCaps);
+            System.err.println("NS create pixelFormat: "+toHexString(pixelFormat));
+            System.err.println("NS create drawable native-handle: "+toHexString(drawable.getHandle()));
+            System.err.println("NS create drawable NSView-handle: "+toHexString(drawable.getNSViewHandle()));
+            // Thread.dumpStack();
+        }
+        try {
+          int[] viewNotReady = new int[1];
+          // Try to allocate a context with this
+          ctx = CGL.createContext(share,
+                                  drawable.getNSViewHandle(), null!=backingLayerHost,
+                                  pixelFormat,
+                                  chosenCaps.isBackgroundOpaque(),
+                                  viewNotReady, 0);
+          if (0 == ctx) {
+            if(DEBUG) {
+                System.err.println("NS create failed: viewNotReady: "+ (1 == viewNotReady[0]));
+            }
+            return 0;
+          }
+    
+          if (!chosenCaps.isPBuffer() && !chosenCaps.isBackgroundOpaque()) {
+              // Set the context opacity
+              CGL.setContextOpacity(ctx, 0);
+          }
+
+          if(DEBUG) {
+              GLCapabilitiesImmutable caps0 = MacOSXCGLGraphicsConfiguration.NSPixelFormat2GLCapabilities(null, pixelFormat);
+              System.err.println("NS create pixelformat2GLCaps: "+caps0);
+          }
+          GLCapabilitiesImmutable fixedCaps = MacOSXCGLGraphicsConfiguration.NSPixelFormat2GLCapabilities(chosenCaps.getGLProfile(), pixelFormat);
+          fixedCaps = GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(fixedCaps, chosenCaps.isBackgroundOpaque());
+          config.setChosenCapabilities(fixedCaps);          
+          if(DEBUG) {
+              System.err.println("NS create fixedCaps: "+fixedCaps);
+          }
+          if(fixedCaps.isPBuffer()) {
+              // Must now associate the pbuffer with our newly-created context
+              CGL.setContextPBuffer(ctx, drawable.getHandle());
+          }
+          //
+          // handled layered surface
+          // 
+          if(null != backingLayerHost) {
+              nsOpenGLLayerPFmt = pixelFormat;
+              pixelFormat = 0;
+              final int texWidth, texHeight;
+              if(drawable instanceof MacOSXPbufferCGLDrawable) {
+                  final MacOSXPbufferCGLDrawable osxPDrawable = (MacOSXPbufferCGLDrawable)drawable;
+                  texWidth = osxPDrawable.getTextureWidth();
+                  texHeight = osxPDrawable.getTextureHeight();
+              } else {
+                  texWidth = drawable.getWidth();
+                  texHeight = drawable.getHeight();                  
+              }              
+              nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, nsOpenGLLayerPFmt, drawable.getHandle(), fixedCaps.isBackgroundOpaque(), texWidth, texHeight);
+              if(0>=texWidth || 0>=texHeight || !drawable.isRealized()) {
+                  throw new GLException("Drawable not realized yet or invalid texture size, texSize "+texWidth+"x"+texHeight+", "+drawable);
+              }
+              if (DEBUG) {
+                  System.err.println("NS create nsOpenGLLayer "+toHexString(nsOpenGLLayer)+", texSize "+texWidth+"x"+texHeight+", "+drawable);
+              }
+              backingLayerHost.attachSurfaceLayer(nsOpenGLLayer);
+          }
+        } finally {
+          if(0!=pixelFormat) {
+              CGL.deletePixelFormat(pixelFormat);
+          }
+        }
+        return ctx;        
+    }
+    
+    public boolean destroy(long ctx) {
+      if(0 != nsOpenGLLayer) {
+          final NativeSurface surface = drawable.getNativeSurface();
+          if (DEBUG) {
+              System.err.println("NS destroy nsOpenGLLayer "+toHexString(nsOpenGLLayer));
+          }
+          final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(surface, true);
+          if(null == ols) {
+              throw new InternalError("XXX: "+ols);
+          }
+          CGL.releaseNSOpenGLLayer(nsOpenGLLayer);
+          ols.detachSurfaceLayer(nsOpenGLLayer);
+          CGL.deletePixelFormat(nsOpenGLLayerPFmt);
+          nsOpenGLLayerPFmt = 0;
+          nsOpenGLLayer = 0;
+      }
+      return CGL.deleteContext(ctx, true);
+    }
+
+    public boolean copyImpl(long src, int mask) {
+        CGL.copyContext(contextHandle, src, mask);
+        return true;
+    }
+    
+    public boolean makeCurrent(long ctx) {
+      final long cglCtx = CGL.getCGLContext(ctx);
+      if(0 == cglCtx) {
+          throw new InternalError("Null CGLContext for: "+this);
+      }
+      int err = CGL.CGLLockContext(cglCtx);
+      if(CGL.kCGLNoError == err) {
+          return CGL.makeCurrentContext(ctx);
+      } else if(DEBUG) {
+          System.err.println("NSGL: Could not lock context: err 0x"+Integer.toHexString(err)+": "+this);
+      }
+      return false;
+    }
+
+    public boolean release(long ctx) {
+      final boolean res = CGL.clearCurrentContext(ctx);
+      final long cglCtx = CGL.getCGLContext(ctx);
+      if(0 == cglCtx) {
+          throw new InternalError("Null CGLContext for: "+this);
+      }
+      final int err = CGL.CGLUnlockContext(cglCtx);
+      if(DEBUG && CGL.kCGLNoError != err) {
+          System.err.println("CGL: Could not unlock context: err 0x"+Integer.toHexString(err)+": "+this);
+      }      
+      return res && CGL.kCGLNoError == err;
+    }
+
+    public boolean setSwapInterval(int interval) {
+      if(0 != nsOpenGLLayer) {
+        CGL.setNSOpenGLLayerSwapInterval(nsOpenGLLayer, interval);
+      }
+      CGL.setSwapInterval(contextHandle, interval);
+      return true;
+    }
+    
+    public boolean swapBuffers() {
+      if(0 != nsOpenGLLayer) {
+        // sync w/ CALayer renderer - wait until next frame is required (v-sync)
+        CGL.waitUntilNSOpenGLLayerIsReady(nsOpenGLLayer, 16); // timeout 16ms -> 60Hz
+      }
+      if(CGL.flushBuffer(contextHandle)) {
+          if(0 != nsOpenGLLayer) {
+              // trigger CALayer to update
+              CGL.setNSOpenGLLayerNeedsDisplay(nsOpenGLLayer);
+          }
+          return true;
+      }
+      return false;
+    }
+  }
+
+  class CGLImpl implements GLBackendImpl {
+    public boolean isNSContext() { return false; }
+    
+    public long create(long share, int ctp, int major, int minor) {
+      long ctx = 0;
+      MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration();
+      GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable)config.getChosenCapabilities();
+      long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2CGLPixelFormat(chosenCaps, ctp, major, minor);
+      if (pixelFormat == 0) {
+        throw new GLException("Unable to allocate pixel format with requested GLCapabilities");
+      }
+      config.setChosenPixelFormat(pixelFormat);
+      try {      
+          // Create new context
+          PointerBuffer ctxPB = PointerBuffer.allocateDirect(1);
+          if (DEBUG) {
+            System.err.println("Share context for CGL-based pbuffer context is " + toHexString(share));
+          }
+          int res = CGL.CGLCreateContext(pixelFormat, share, ctxPB);
+          if (res != CGL.kCGLNoError) {
+            throw new GLException("Error code " + res + " while creating context");
+          }
+          if(chosenCaps.isPBuffer()) {
+              // Attach newly-created context to the pbuffer
+              res = CGL.CGLSetPBuffer(ctxPB.get(0), drawable.getHandle(), 0, 0, 0);
+              if (res != CGL.kCGLNoError) {
+                throw new GLException("Error code " + res + " while attaching context to pbuffer");
+              }
+          }
+          ctx = ctxPB.get(0);
+          if(0!=ctx) {
+              if(DEBUG) {
+                  GLCapabilitiesImmutable caps0 = MacOSXCGLGraphicsConfiguration.CGLPixelFormat2GLCapabilities(pixelFormat);
+                  System.err.println("NS created: "+caps0);
+              }              
+          }
+      } finally {
+          CGL.CGLDestroyPixelFormat(pixelFormat);          
+      }
+      return ctx;
+    }
+    
+    public boolean destroy(long ctx) {
+      return CGL.CGLDestroyContext(ctx) == CGL.kCGLNoError;
+    }
+
+    public boolean copyImpl(long src, int mask) {
+        CGL.CGLCopyContext(src, contextHandle, mask);
+        return true;
+    }
+    
+    public boolean makeCurrent(long ctx) {
+      int err = CGL.CGLLockContext(ctx);
+      if(CGL.kCGLNoError == err) {
+          err = CGL.CGLSetCurrentContext(ctx);
+          if(CGL.kCGLNoError == err) {
+              return true;
+          } else if(DEBUG) {
+              System.err.println("CGL: Could not make context current: err 0x"+Integer.toHexString(err)+": "+this);
+          }
+      } else if(DEBUG) {
+          System.err.println("CGL: Could not lock context: err 0x"+Integer.toHexString(err)+": "+this);
+      }
+      return false;
+    }
+
+    public boolean release(long ctx) {
+      int err = CGL.CGLSetCurrentContext(0);
+      if(DEBUG && CGL.kCGLNoError != err) {
+          System.err.println("CGL: Could not release current context: err 0x"+Integer.toHexString(err)+": "+this);
+      }
+      int err2 = CGL.CGLUnlockContext(ctx);
+      if(DEBUG && CGL.kCGLNoError != err2) {
+          System.err.println("CGL: Could not unlock context: err 0x"+Integer.toHexString(err2)+": "+this);
+      }
+      return CGL.kCGLNoError == err && CGL.kCGLNoError == err2;
+    }
+    
+    public boolean setSwapInterval(int interval) {
+        int[] lval = new int[] { interval } ;
+        CGL.CGLSetParameter(contextHandle, CGL.kCGLCPSwapInterval, lval, 0);
+        return true;
+    }    
+    public boolean swapBuffers() {
+        return CGL.kCGLNoError == CGL.CGLFlushDrawable(contextHandle);
+    }    
+  }  
 }
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java
index 10e061d..12d480f 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java
@@ -40,9 +40,17 @@
 
 package jogamp.opengl.macosx.cgl;
 
-import javax.media.nativewindow.*;
-import javax.media.opengl.*;
-import jogamp.opengl.*;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.media.nativewindow.NativeSurface;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLException;
+
+import jogamp.opengl.GLDrawableImpl;
+import jogamp.opengl.GLDynamicLookupHelper;
 
 public abstract class MacOSXCGLDrawable extends GLDrawableImpl {
   // The Java2D/OpenGL pipeline on OS X uses low-level CGLContextObjs
@@ -74,17 +82,56 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl {
   // lifetime of a given GLPbuffer. This is not a fully general
   // solution (for example, you can't share textures among a
   // GLPbuffer, a GLJPanel and a GLCanvas simultaneously) but should
-  // be enough to get things off the ground.
-  public static final int NSOPENGL_MODE = 1;
-  public static final int CGL_MODE      = 2;
+  // be enough to get things off the ground.  
+  public enum GLBackendType {
+    NSOPENGL(0), CGL(1); 
+    
+    public final int id;
 
+    GLBackendType(int id){
+        this.id = id;
+    }
+  }
+  private List<WeakReference<MacOSXCGLContext>> createdContexts = new ArrayList<WeakReference<MacOSXCGLContext>>();
+  
+  private boolean haveSetOpenGLMode = false;
+  private GLBackendType openGLMode = GLBackendType.NSOPENGL;
+  
   public MacOSXCGLDrawable(GLDrawableFactory factory, NativeSurface comp, boolean realized) {
     super(factory, comp, realized);
- }
-
+    initOpenGLImpl(getOpenGLMode());
+  }
+  
   protected void setRealizedImpl() {
   }
 
+  protected long getNSViewHandle() {
+      return GLBackendType.NSOPENGL == openGLMode ? getHandle() : null;
+  }
+  
+  protected void registerContext(MacOSXCGLContext ctx) {
+    // NOTE: we need to keep track of the created contexts in order to
+    // implement swapBuffers() because of how Mac OS X implements its
+    // OpenGL window interface
+    synchronized (createdContexts) {
+      createdContexts.add(new WeakReference<MacOSXCGLContext>(ctx));
+    }
+  }
+  protected final void swapBuffersImpl() {
+    // single-buffer is already filtered out @ GLDrawableImpl#swapBuffers()
+    synchronized (createdContexts) {
+        for (Iterator<WeakReference<MacOSXCGLContext>> iter = createdContexts.iterator(); iter.hasNext(); ) {
+          WeakReference<MacOSXCGLContext> ref = iter.next();
+          MacOSXCGLContext ctx = ref.get();
+          if (ctx != null) {
+            ctx.swapBuffers();
+          } else {
+            iter.remove();
+          }
+        }
+    }
+  }  
+    
   public GLDynamicLookupHelper getGLDynamicLookupHelper() {
     return getFactoryImpl().getGLDynamicLookupHelper(0);
   }
@@ -93,7 +140,25 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl {
     return Thread.currentThread().getName();
   }
 
-  // Support for "mode switching" as per above
-  public abstract void setOpenGLMode(int mode);
-  public abstract int  getOpenGLMode();
+  // Support for "mode switching" as described in MacOSXCGLDrawable
+  public void setOpenGLMode(GLBackendType mode) {
+      if (mode == openGLMode) {
+        return;
+      }
+      if (haveSetOpenGLMode) {
+        throw new GLException("Can't switch between using NSOpenGLPixelBuffer and CGLPBufferObj more than once");
+      }
+    
+      destroyImpl();
+      if (DEBUG) {
+        System.err.println("Switching context mode " + openGLMode + " -> " + mode);
+      }
+      initOpenGLImpl(mode);
+      openGLMode = mode;
+      haveSetOpenGLMode = true;      
+  }
+  public final GLBackendType getOpenGLMode() { return openGLMode; }
+
+  protected void initOpenGLImpl(GLBackendType backend) { /* nop */ }
+  
 }
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
index 9023245..1e55879 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -40,70 +40,126 @@
 
 package jogamp.opengl.macosx.cgl;
 
-import java.nio.*;
+import java.nio.Buffer;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 
-import javax.media.nativewindow.*;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.AbstractGraphicsScreen;
+import javax.media.nativewindow.DefaultGraphicsScreen;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.nativewindow.ProxySurface;
 import javax.media.nativewindow.macosx.MacOSXGraphicsDevice;
-import javax.media.opengl.*;
+import javax.media.opengl.GL;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesChooser;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawable;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.GLProfile.ShutdownType;
 
-import com.jogamp.common.JogampRuntimeException;
-import com.jogamp.common.util.*;
-import java.util.ArrayList;
-import jogamp.opengl.*;
 import jogamp.nativewindow.WrappedSurface;
+import jogamp.opengl.DesktopGLDynamicLookupHelper;
+import jogamp.opengl.GLDrawableFactoryImpl;
+import jogamp.opengl.GLDrawableImpl;
+import jogamp.opengl.GLDynamicLookupHelper;
+
+import com.jogamp.common.JogampRuntimeException;
+import com.jogamp.common.util.ReflectionUtil;
 
 public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
-  private static final DesktopGLDynamicLookupHelper macOSXCGLDynamicLookupHelper;
-
-  static {
-        DesktopGLDynamicLookupHelper tmp = null;
-        try {
-            tmp = new DesktopGLDynamicLookupHelper(new MacOSXCGLDynamicLibraryBundleInfo());
-        } catch (GLException gle) {
-            if(DEBUG) {
-                gle.printStackTrace();
+  private static DesktopGLDynamicLookupHelper macOSXCGLDynamicLookupHelper = null;
+  
+  public MacOSXCGLDrawableFactory() {
+    super();
+
+    synchronized(MacOSXCGLDrawableFactory.class) {
+        if(null==macOSXCGLDynamicLookupHelper) {
+            DesktopGLDynamicLookupHelper tmp = null;
+            try {
+                tmp = new DesktopGLDynamicLookupHelper(new MacOSXCGLDynamicLibraryBundleInfo());
+            } catch (GLException gle) {
+                if(DEBUG) {
+                    gle.printStackTrace();
+                }
             }
+            macOSXCGLDynamicLookupHelper = tmp;
+            /** FIXME ?? 
+            if(null!=macOSXCGLDynamicLookupHelper) {
+                CGL.getCGLProcAddressTable().reset(macOSXCGLDynamicLookupHelper);
+            } */
+        }
+    }
+    
+    if(null!=macOSXCGLDynamicLookupHelper) {
+        // Register our GraphicsConfigurationFactory implementations
+        // The act of constructing them causes them to be registered
+        MacOSXCGLGraphicsConfigurationFactory.registerFactory();
+        if(GLProfile.isAWTAvailable()) {
+            try {
+              ReflectionUtil.callStaticMethod("jogamp.opengl.macosx.cgl.awt.MacOSXAWTCGLGraphicsConfigurationFactory", 
+                                              "registerFactory", null, null, getClass().getClassLoader());                
+            } catch (JogampRuntimeException jre) { /* n/a .. */ }
         }
-        macOSXCGLDynamicLookupHelper = tmp;
-        /** FIXME ?? 
-        if(null!=macOSXCGLDynamicLookupHelper) {
-            CGL.getCGLProcAddressTable().reset(macOSXCGLDynamicLookupHelper);
-        } */
+    
+        defaultDevice = new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT);
+        sharedMap = new HashMap<String, SharedResource>();
+    }     
+  }
+
+  protected final void destroy(ShutdownType shutdownType) {
+    if(null != sharedMap) {
+        sharedMap.clear();
+        sharedMap = null;
+    }
+    defaultDevice = null;
+    /**
+     * Pulling away the native library may cause havoc ..
+     * 
+    if(ShutdownType.COMPLETE == shutdownType && null != macOSXCGLDynamicLookupHelper) {
+        macOSXCGLDynamicLookupHelper.destroy();
+        macOSXCGLDynamicLookupHelper = null;
+    } */
   }
 
   public GLDynamicLookupHelper getGLDynamicLookupHelper(int profile) {
       return macOSXCGLDynamicLookupHelper;
   }
 
-  public MacOSXCGLDrawableFactory() {
-    super();
-
-    // Register our GraphicsConfigurationFactory implementations
-    // The act of constructing them causes them to be registered
-    new MacOSXCGLGraphicsConfigurationFactory();
-    if(GLProfile.isAWTAvailable()) {
-        try {
-          ReflectionUtil.createInstance("jogamp.opengl.macosx.cgl.awt.MacOSXAWTCGLGraphicsConfigurationFactory",
-                                        null, getClass().getClassLoader());
-        } catch (JogampRuntimeException jre) { /* n/a .. */ }
-    }
-
-    defaultDevice = new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT);
-  }
+  private HashMap<String, SharedResource> sharedMap = new HashMap<String, SharedResource>();
+  private MacOSXGraphicsDevice defaultDevice;
 
   static class SharedResource {
-      private MacOSXCGLDrawable drawable;
-      private MacOSXCGLContext context;
-
-      SharedResource(MacOSXCGLDrawable draw, MacOSXCGLContext ctx) {
-          drawable = draw;
-          context = ctx;
+      // private MacOSXCGLDrawable drawable;
+      // private MacOSXCGLContext context;
+      MacOSXGraphicsDevice device;
+      boolean wasContextCreated;
+      boolean hasNPOTTextures;
+      boolean hasRECTTextures;
+      boolean hasAppletFloatPixels;
+
+      SharedResource(MacOSXGraphicsDevice device, boolean wasContextCreated, 
+                     boolean hasNPOTTextures, boolean hasRECTTextures, boolean hasAppletFloatPixels
+                     /* MacOSXCGLDrawable draw, MacOSXCGLContext ctx */) {
+          // drawable = draw;
+          // context = ctx;
+          this.device = device;
+          this.wasContextCreated = wasContextCreated;
+          this.hasNPOTTextures = hasNPOTTextures;
+          this.hasRECTTextures = hasRECTTextures;
+          this.hasAppletFloatPixels = hasAppletFloatPixels;
       }
+      final MacOSXGraphicsDevice getDevice() { return device; }
+      final boolean wasContextAvailable() { return wasContextCreated; }
+      final boolean isNPOTTextureAvailable() { return hasNPOTTextures; }
+      final boolean isRECTTextureAvailable() { return hasRECTTextures; }
+      final boolean isAppletFloatPixelsAvailable() { return hasAppletFloatPixels; }
   }
-  HashMap/*<connection, SharedResource>*/ sharedMap = new HashMap();
-  MacOSXGraphicsDevice defaultDevice;
 
   public final AbstractGraphicsDevice getDefaultDevice() {
       return defaultDevice;
@@ -116,9 +172,105 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
       return false;
   }
 
-  public final boolean getWasSharedContextCreated(AbstractGraphicsDevice device) {
-      // FIXME: not implemented .. needs a dummy OSX surface
-      return false;
+  private HashSet<String> devicesTried = new HashSet<String>();
+
+  private boolean getDeviceTried(String connection) {
+      synchronized (devicesTried) {
+          return devicesTried.contains(connection);
+      }
+  }
+  private void addDeviceTried(String connection) {
+      synchronized (devicesTried) {
+          devicesTried.add(connection);
+      }
+  }
+  private void removeDeviceTried(String connection) {
+      synchronized (devicesTried) {
+          devicesTried.remove(connection);
+      }
+  }
+  
+  /* package */ SharedResource getOrCreateOSXSharedResource(AbstractGraphicsDevice adevice) {
+    final String connection = adevice.getConnection();
+    SharedResource sr;
+    synchronized(sharedMap) {
+        sr = sharedMap.get(connection);
+    }
+    if(null==sr && !getDeviceTried(connection)) {
+        addDeviceTried(connection);
+        final MacOSXGraphicsDevice sharedDevice = new MacOSXGraphicsDevice(adevice.getUnitID());
+        boolean madeCurrent = false;
+        boolean hasNPOTTextures = false;
+        boolean hasRECTTextures = false;
+        boolean hasAppletFloatPixels = false;
+        {
+            GLProfile glp = GLProfile.get(sharedDevice, GLProfile.GL_PROFILE_LIST_MIN_DESKTOP);
+            if (null == glp) {
+                throw new GLException("Couldn't get default GLProfile for device: "+sharedDevice);
+            }    
+            final GLCapabilities caps = new GLCapabilities(glp);
+            caps.setRedBits(5); caps.setGreenBits(5); caps.setBlueBits(5); caps.setAlphaBits(0);
+            caps.setDoubleBuffered(false);
+            caps.setOnscreen(false);
+            caps.setPBuffer(true);
+            final MacOSXCGLDrawable drawable = (MacOSXCGLDrawable) createGLDrawable( createOffscreenSurfaceImpl(sharedDevice, caps, caps, null, 64, 64) );        
+            if(null!=drawable) {
+                drawable.setRealized(true);
+                final GLContext context = drawable.createContext(null);
+                if (null != context) {
+                    context.setSynchronized(true);
+                    try {
+                        context.makeCurrent(); // could cause exception
+                        madeCurrent = context.isCurrent();
+                        if(madeCurrent) {
+                            GL gl = context.getGL();
+                            hasNPOTTextures = gl.isNPOTTextureAvailable();
+                            hasRECTTextures = gl.isExtensionAvailable("GL_EXT_texture_rectangle");
+                            hasAppletFloatPixels = gl.isExtensionAvailable("GL_APPLE_float_pixels");
+                        }
+                    } catch (GLException gle) {
+                        if (DEBUG) {
+                            System.err.println("MacOSXCGLDrawableFactory.createShared: INFO: makeCurrent failed");
+                            gle.printStackTrace();
+                        }
+                    } finally {
+                        context.release();
+                        context.destroy();
+                    }
+                }
+                drawable.destroy();
+            }
+        }
+        sr = new SharedResource(sharedDevice, madeCurrent, hasNPOTTextures, hasRECTTextures, hasAppletFloatPixels);
+        synchronized(sharedMap) {
+            sharedMap.put(connection, sr);
+        }
+        removeDeviceTried(connection);
+        if (DEBUG) {
+            System.err.println("MacOSXCGLDrawableFactory.createShared: device:  " + sharedDevice);
+            System.err.println("MacOSXCGLDrawableFactory.createShared: context: " + madeCurrent);
+        }                        
+    }
+    return sr;
+  }
+   
+  protected final Thread getSharedResourceThread() {
+    return null;
+  }
+  
+  protected final boolean createSharedResource(AbstractGraphicsDevice device) {
+    try {
+        SharedResource sr = getOrCreateOSXSharedResource(device);
+        if(null!=sr) {
+            return sr.wasContextAvailable();
+        }
+    } catch (GLException gle) {
+        if(DEBUG) {
+            System.err.println("Catched Exception while MaxOSXCGL Shared Resource initialization");
+            gle.printStackTrace();
+        }
+    }
+    return false;        
   }
   
   protected final GLContext getOrCreateSharedContextImpl(AbstractGraphicsDevice device) {
@@ -127,13 +279,15 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
   }
 
   protected AbstractGraphicsDevice getOrCreateSharedDeviceImpl(AbstractGraphicsDevice device) {
-      return device; // nothing to do, no native open device
+      SharedResource sr = getOrCreateOSXSharedResource(device);
+      if(null!=sr) {
+          return sr.getDevice();
+      }
+      return null;
   }
 
-  protected final void shutdownInstance() {}
-
   protected List<GLCapabilitiesImmutable> getAvailableCapabilitiesImpl(AbstractGraphicsDevice device) {
-      return new ArrayList<GLCapabilitiesImmutable>(0);
+      return MacOSXCGLGraphicsConfiguration.getAvailableCapabilities(this, device);
   }
 
   protected GLDrawableImpl createOnscreenDrawableImpl(NativeSurface target) {
@@ -144,26 +298,11 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
   }
 
   protected GLDrawableImpl createOffscreenDrawableImpl(NativeSurface target) {
-    AbstractGraphicsConfiguration config = target.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+    AbstractGraphicsConfiguration config = target.getGraphicsConfiguration();
     GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
     if(!caps.isPBuffer()) {
         return new MacOSXOffscreenCGLDrawable(this, target);
     }
-
-    // PBuffer GLDrawable Creation
-    /**
-     * FIXME: Think about this ..
-     * should not be necessary ? ..
-    final List returnList = new ArrayList();
-    final GLDrawableFactory factory = this;
-    Runnable r = new Runnable() {
-        public void run() {
-          returnList.add(new MacOSXPbufferCGLDrawable(factory, target));
-        }
-      };
-    maybeDoSingleThreadedWorkaround(r);
-    return (GLDrawableImpl) returnList.get(0);
-    */
     return new MacOSXPbufferCGLDrawable(this, target);
   }
 
@@ -174,7 +313,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
   protected NativeSurface createOffscreenSurfaceImpl(AbstractGraphicsDevice device,GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height) {
     AbstractGraphicsScreen screen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_MACOSX);
     WrappedSurface ns = new WrappedSurface(MacOSXCGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen, true));
-    ns.setSize(width, height);
+    ns.surfaceSizeChanged(width, height);
     return ns;
   }
 
@@ -185,7 +324,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
   }  
   
   protected GLContext createExternalGLContextImpl() {
-    return MacOSXExternalCGLContext.create(this, null);
+    return MacOSXExternalCGLContext.create(this);
   }
 
   public boolean canCreateExternalGLDrawable(AbstractGraphicsDevice device) {
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java
index 0d73b6b..f552ab3 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java
@@ -36,10 +36,21 @@
 
 package jogamp.opengl.macosx.cgl;
 
-import javax.media.nativewindow.*;
-import javax.media.opengl.*;
+import java.util.ArrayList;
+import java.util.List;
 
-public class MacOSXCGLGraphicsConfiguration extends DefaultGraphicsConfiguration implements Cloneable {
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.AbstractGraphicsScreen;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
+
+import jogamp.nativewindow.MutableGraphicsConfiguration;
+
+import com.jogamp.common.nio.PointerBuffer;
+
+public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable {
     long pixelformat;
 
     MacOSXCGLGraphicsConfiguration(AbstractGraphicsScreen screen, 
@@ -57,12 +68,20 @@ public class MacOSXCGLGraphicsConfiguration extends DefaultGraphicsConfiguration
         this.pixelformat=pixelformat;
     }
 
-    void setChosenCapabilities(GLCapabilitiesImmutable caps) {
-        super.setChosenCapabilities(caps);
+    protected static List<GLCapabilitiesImmutable> getAvailableCapabilities(MacOSXCGLDrawableFactory factory, AbstractGraphicsDevice device) {
+        MacOSXCGLDrawableFactory.SharedResource sharedResource = factory.getOrCreateOSXSharedResource(device);
+        if(null == sharedResource) {
+            throw new GLException("Shared resource for device n/a: "+device);
+        }
+        // MacOSXGraphicsDevice osxDevice = sharedResource.getDevice();
+        return new ArrayList<GLCapabilitiesImmutable>(0);
     }
-
+    
     static final int[] cglInternalAttributeToken = new int[] {
+        CGL.kCGLPFAOpenGLProfile,
         CGL.kCGLPFAColorFloat,
+        CGL.NSOpenGLPFANoRecovery,
+        CGL.NSOpenGLPFAAccelerated,
         CGL.NSOpenGLPFAPixelBuffer,
         CGL.NSOpenGLPFADoubleBuffer,
         CGL.NSOpenGLPFAStereo,
@@ -74,16 +93,33 @@ public class MacOSXCGLGraphicsConfiguration extends DefaultGraphicsConfiguration
         CGL.NSOpenGLPFASampleBuffers,
         CGL.NSOpenGLPFASamples };
 
-    static int[] GLCapabilities2AttribList(GLCapabilitiesImmutable caps) {
-        int[] ivalues = new int[cglInternalAttributeToken.length];
-
-        for (int idx = 0; idx < cglInternalAttributeToken.length; idx++) {
-          int attr = cglInternalAttributeToken[idx];
+    static int[] GLCapabilities2NSAttribList(GLCapabilitiesImmutable caps, int ctp, int major, int minor) {
+        int len = cglInternalAttributeToken.length;
+        int off = 0;
+        if ( !MacOSXCGLContext.isLionOrLater ) {
+            // no OpenGLProfile
+            off++;
+            len--;
+        }        
+        int[] ivalues = new int[len];
+
+        for (int idx = 0; idx < len; idx++) {
+          final int attr = cglInternalAttributeToken[idx+off];
           switch (attr) {
+              case CGL.kCGLPFAOpenGLProfile: 
+                ivalues[idx] = MacOSXCGLContext.GLProfile2CGLOGLProfileValue(ctp, major, minor);
+                break;
               case CGL.kCGLPFAColorFloat:
                 ivalues[idx] = caps.getPbufferFloatingPointBuffers() ? 1 : 0;
                 break;
 
+              case CGL.NSOpenGLPFANoRecovery:
+                ivalues[idx] = caps.getHardwareAccelerated() ? 1 : 0;
+                break;
+              case CGL.NSOpenGLPFAAccelerated:
+                ivalues[idx] = caps.getHardwareAccelerated() ? 1 : 0;
+                break;
+                  
               case CGL.NSOpenGLPFAPixelBuffer:
                 ivalues[idx] = caps.isPBuffer() ? 1 : 0;
                 break;
@@ -131,21 +167,88 @@ public class MacOSXCGLGraphicsConfiguration extends DefaultGraphicsConfiguration
         return ivalues;
     }
 
-    static long GLCapabilities2NSPixelFormat(GLCapabilitiesImmutable caps) {
-        int[] ivalues = GLCapabilities2AttribList(caps);
-        return CGL.createPixelFormat(cglInternalAttributeToken, 0, cglInternalAttributeToken.length, ivalues, 0);
+    static long GLCapabilities2NSPixelFormat(GLCapabilitiesImmutable caps, int ctp, int major, int minor) {
+        int len = cglInternalAttributeToken.length;
+        int off = 0;
+        if ( !MacOSXCGLContext.isLionOrLater ) {
+            // no OpenGLProfile
+            off++;
+            len--;
+        }        
+        int[] ivalues = GLCapabilities2NSAttribList(caps, ctp, major, minor);
+        return CGL.createPixelFormat(cglInternalAttributeToken, off, len, ivalues, 0);
     }
 
     static GLCapabilitiesImmutable NSPixelFormat2GLCapabilities(GLProfile glp, long pixelFormat) {
         return PixelFormat2GLCapabilities(glp, pixelFormat, true);
     }
 
-    static GLCapabilitiesImmutable CGLPixelFormat2GLCapabilities(GLProfile glp, long pixelFormat) {
-        return PixelFormat2GLCapabilities(glp, pixelFormat, false);
+    static long GLCapabilities2CGLPixelFormat(GLCapabilitiesImmutable caps, int ctp, int major, int minor) {
+      // Set up pixel format attributes
+      int[] attrs = new int[256];
+      int i = 0;
+      if(MacOSXCGLContext.isLionOrLater) {
+          attrs[i++] = CGL.kCGLPFAOpenGLProfile; 
+          attrs[i++] = MacOSXCGLContext.GLProfile2CGLOGLProfileValue(ctp, major, minor);
+      }
+      if(caps.isPBuffer()) {
+        attrs[i++] = CGL.kCGLPFAPBuffer;
+      }
+      if (caps.getPbufferFloatingPointBuffers()) {
+        attrs[i++] = CGL.kCGLPFAColorFloat;
+      }
+      if (caps.getDoubleBuffered()) {
+        attrs[i++] = CGL.kCGLPFADoubleBuffer;
+      }
+      if (caps.getStereo()) {
+        attrs[i++] = CGL.kCGLPFAStereo;
+      }
+      attrs[i++] = CGL.kCGLPFAColorSize;
+      attrs[i++] = (caps.getRedBits() +
+                    caps.getGreenBits() +
+                    caps.getBlueBits());
+      attrs[i++] = CGL.kCGLPFAAlphaSize;
+      attrs[i++] = caps.getAlphaBits();
+      attrs[i++] = CGL.kCGLPFADepthSize;
+      attrs[i++] = caps.getDepthBits();
+      // FIXME: should validate stencil size as is done in MacOSXWindowSystemInterface.m
+      attrs[i++] = CGL.kCGLPFAStencilSize;
+      attrs[i++] = caps.getStencilBits();
+      attrs[i++] = CGL.kCGLPFAAccumSize;
+      attrs[i++] = (caps.getAccumRedBits() +
+                    caps.getAccumGreenBits() +
+                    caps.getAccumBlueBits() +
+                    caps.getAccumAlphaBits());
+      if (caps.getSampleBuffers()) {
+        attrs[i++] = CGL.kCGLPFASampleBuffers;
+        attrs[i++] = 1;
+        attrs[i++] = CGL.kCGLPFASamples;
+        attrs[i++] = caps.getNumSamples();
+      }
+
+      // Use attribute array to select pixel format
+      PointerBuffer fmt = PointerBuffer.allocateDirect(1);
+      int[] numScreens = new int[1];
+      int res = CGL.CGLChoosePixelFormat(attrs, 0, fmt, numScreens, 0);
+      if (res != CGL.kCGLNoError) {
+        throw new GLException("Error code " + res + " while choosing pixel format");
+      }
+      return fmt.get(0);
+    }
+    
+    static GLCapabilitiesImmutable CGLPixelFormat2GLCapabilities(long pixelFormat) {
+        return PixelFormat2GLCapabilities(null, pixelFormat, false);
     }
 
     private static GLCapabilitiesImmutable PixelFormat2GLCapabilities(GLProfile glp, long pixelFormat, boolean nsUsage) {
-        int[] ivalues = new int[cglInternalAttributeToken.length];
+        int len = cglInternalAttributeToken.length;
+        int off = 0;
+        if ( !MacOSXCGLContext.isLionOrLater ) {
+            // no OpenGLProfile
+            off++;
+            len--;
+        }        
+        int[] ivalues = new int[len];
 
         // On this platform the pixel format is associated with the
         // context and not the drawable. However it's a reasonable
@@ -155,19 +258,43 @@ public class MacOSXCGLGraphicsConfiguration extends DefaultGraphicsConfiguration
         // Note: These restrictions of the platform's API might be considered as a bug anyways.
 
         // Figure out what attributes we really got
-        GLCapabilities caps = new GLCapabilities(glp);
         if(nsUsage) {
-            CGL.queryPixelFormat(pixelFormat, cglInternalAttributeToken, 0, cglInternalAttributeToken.length, ivalues, 0);
+            CGL.queryPixelFormat(pixelFormat, cglInternalAttributeToken, off, len, ivalues, 0);
         } else {
-            CGL.CGLQueryPixelFormat(pixelFormat, cglInternalAttributeToken, 0, cglInternalAttributeToken.length, ivalues, 0);
+            CGL.CGLQueryPixelFormat(pixelFormat, cglInternalAttributeToken, off, len, ivalues, 0);
+        }
+        if(null == glp && MacOSXCGLContext.isLionOrLater) {
+            // pre-scan for OpenGL Profile
+            for (int i = 0; i < len; i++) {
+                if(CGL.kCGLPFAOpenGLProfile == cglInternalAttributeToken[i+off]) {
+                    switch(ivalues[i]) {
+                        case CGL.kCGLOGLPVersion_3_2_Core:
+                            glp = GLProfile.get(GLProfile.GL3);
+                            break;
+                        case CGL.kCGLOGLPVersion_Legacy:
+                            glp = GLProfile.get(GLProfile.GL2);
+                            break;                            
+                        default:
+                            throw new RuntimeException("Unhandled OSX OpenGL Profile: 0x"+Integer.toHexString(ivalues[i]));
+                    }
+                }            
+            }
+        }
+        if(null == glp) {
+            glp = GLProfile.get(GLProfile.GL2);
         }
-        for (int i = 0; i < cglInternalAttributeToken.length; i++) {
-          int attr = cglInternalAttributeToken[i];
+        GLCapabilities caps = new GLCapabilities(glp);
+        for (int i = 0; i < len; i++) {
+          int attr = cglInternalAttributeToken[i+off];
           switch (attr) {
               case CGL.kCGLPFAColorFloat:
                 caps.setPbufferFloatingPointBuffers(ivalues[i] != 0);
                 break;
 
+              case CGL.NSOpenGLPFAAccelerated:
+                caps.setHardwareAccelerated(ivalues[i] != 0);
+                break;
+                
               case CGL.NSOpenGLPFAPixelBuffer:
                 caps.setPBuffer(ivalues[i] != 0);
                 break;
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
index d4526f0..0de290c 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
@@ -51,8 +51,10 @@ import javax.media.opengl.GLCapabilitiesImmutable;
 public class MacOSXCGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFactory {
     protected static final boolean DEBUG = jogamp.opengl.Debug.debug("GraphicsConfiguration");
 
-    MacOSXCGLGraphicsConfigurationFactory() {
-        GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.macosx.MacOSXGraphicsDevice.class, this);
+    static void registerFactory() {
+        GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.macosx.MacOSXGraphicsDevice.class, new MacOSXCGLGraphicsConfigurationFactory());
+    }
+    private MacOSXCGLGraphicsConfigurationFactory() {        
     }
 
     protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java
index 4786725..6ce2d7b 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java
@@ -40,26 +40,35 @@
 
 package jogamp.opengl.macosx.cgl;
 
-import javax.media.opengl.*;
-import jogamp.opengl.*;
+import javax.media.nativewindow.AbstractGraphicsScreen;
+import javax.media.nativewindow.DefaultGraphicsScreen;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLException;
 
-import javax.media.nativewindow.*;
 import jogamp.nativewindow.WrappedSurface;
+import jogamp.opengl.GLContextImpl;
+import jogamp.opengl.GLContextShareSet;
+import jogamp.opengl.macosx.cgl.MacOSXCGLDrawable.GLBackendType;
+
 
 public class MacOSXExternalCGLContext extends MacOSXCGLContext {
   private GLContext lastContext;
 
   private MacOSXExternalCGLContext(Drawable drawable, boolean isNSContext, long handle) {
     super(drawable, null);
-    drawable.setExternalCGLContext(this);
-    this.isNSContext = isNSContext;
+    setOpenGLMode(isNSContext ? GLBackendType.NSOPENGL : GLBackendType.CGL );
+    drawable.registerContext(this);
     this.contextHandle = handle;
     GLContextShareSet.contextCreated(this);
-    setGLFunctionAvailability(false, true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
+    setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
     getGLStateTracker().setEnabled(false); // external context usage can't track state in Java
   }
 
-  protected static MacOSXExternalCGLContext create(GLDrawableFactory factory, GLProfile glp) {
+  protected static MacOSXExternalCGLContext create(GLDrawableFactory factory) {
     long pixelFormat = 0;
     long currentDrawable = 0;
     long contextHandle = CGL.getCurrentContext(); // Check: MacOSX 10.3 ..
@@ -92,7 +101,7 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext {
     if (0 == pixelFormat) {
       throw new GLException("Error: current pixelformat of current Context 0x"+Long.toHexString(contextHandle)+" is null");
     }
-    GLCapabilitiesImmutable caps = MacOSXCGLGraphicsConfiguration.CGLPixelFormat2GLCapabilities(glp, pixelFormat);
+    GLCapabilitiesImmutable caps = MacOSXCGLGraphicsConfiguration.CGLPixelFormat2GLCapabilities(pixelFormat);
     if(DEBUG) {
         System.err.println("MacOSXExternalCGLContext Create "+caps);
     }
@@ -109,7 +118,7 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext {
     return new MacOSXExternalCGLContext(new Drawable(factory, ns), isNSContext, contextHandle);
   }
 
-  protected boolean createImpl() throws GLException {
+  protected boolean createImpl(GLContextImpl shareWith) throws GLException {
       return true;
   }
 
@@ -130,7 +139,7 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext {
     lastContext = null;
   }
 
-  protected void makeCurrentImpl(boolean newCreated) throws GLException {
+  protected void makeCurrentImpl() throws GLException {
   }
 
   protected void releaseImpl() throws GLException {
@@ -139,27 +148,12 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext {
   protected void destroyImpl() throws GLException {
   }
 
-  public void setOpenGLMode(int mode) {
-    if (mode != MacOSXCGLDrawable.CGL_MODE)
-      throw new GLException("OpenGL mode switching not supported for external GLContexts");
-  }
-    
-  public int  getOpenGLMode() {
-    return MacOSXCGLDrawable.CGL_MODE;
-  }
-
   // Need to provide the display connection to extension querying APIs
   static class Drawable extends MacOSXCGLDrawable {
-    MacOSXExternalCGLContext extCtx;
-
     Drawable(GLDrawableFactory factory, NativeSurface comp) {
       super(factory, comp, true);
     }
 
-    void setExternalCGLContext(MacOSXExternalCGLContext externalContext) {
-      extCtx = externalContext;
-    }
-
     public GLContext createContext(GLContext shareWith) {
       throw new GLException("Should not call this");
     }
@@ -175,20 +169,5 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext {
     public void setSize(int width, int height) {
       throw new GLException("Should not call this");
     }
-
-    protected void swapBuffersImpl() {
-      if (extCtx != null) {
-        extCtx.swapBuffers();
-      }
-    }
-  
-    public void setOpenGLMode(int mode) {
-        if (mode != CGL_MODE)
-          throw new GLException("OpenGL mode switching not supported for external GLContext's drawables");
-    }
-
-    public int  getOpenGLMode() {
-        return CGL_MODE;
-    }
   }
 }
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOffscreenCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOffscreenCGLDrawable.java
index bec4cf3..f81cd72 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOffscreenCGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOffscreenCGLDrawable.java
@@ -40,9 +40,9 @@
 
 package jogamp.opengl.macosx.cgl;
 
-import javax.media.opengl.*;
-import javax.media.nativewindow.*;
-import jogamp.opengl.*;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawableFactory;
 
 public class MacOSXOffscreenCGLDrawable extends MacOSXPbufferCGLDrawable {
 
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java
index 55d3a08..9e05131 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java
@@ -39,8 +39,10 @@
 
 package jogamp.opengl.macosx.cgl;
 
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLException;
 
-import javax.media.opengl.*;
+import jogamp.opengl.GLContextImpl;
 
 public class MacOSXOnscreenCGLContext extends MacOSXCGLContext {
 
@@ -49,42 +51,54 @@ public class MacOSXOnscreenCGLContext extends MacOSXCGLContext {
     super(drawable, shareWith);
   }
 
-    @Override
-  protected void makeCurrentImpl(boolean newCreated) throws GLException {
-      super.makeCurrentImpl(newCreated);
-      CGL.updateContext(contextHandle);
+  @Override
+  protected void makeCurrentImpl() throws GLException {
+      super.makeCurrentImpl();
+      drawableUpdatedNotify();  
   }
     
-    @Override
-  protected void releaseImpl() throws GLException {
-    super.releaseImpl();
-  }
-
-    @Override
-  protected void swapBuffers() {
-    if (!CGL.flushBuffer(contextHandle)) {
-      throw new GLException("Error swapping buffers");
+  @Override
+  protected void drawableUpdatedNotify() throws GLException {
+    final int w = drawable.getWidth();
+    final int h = drawable.getHeight();
+    final boolean updateContext = ( 0!=updateHandle && CGL.updateContextNeedsUpdate(updateHandle) ) ||
+                                  w != lastWidth || h != lastHeight;
+    if(updateContext) {
+        lastWidth = w;
+        lastHeight = h;
+        if (contextHandle == 0) {
+          throw new GLException("Context not created");
+        }
+        CGL.updateContext(contextHandle);
     }
   }
-
-    @Override
-  protected void update() throws GLException {
-    if (contextHandle == 0) {
-      throw new GLException("Context not created");
+  
+  @Override
+  protected boolean createImpl(GLContextImpl sharedWith) {
+    boolean res = super.createImpl(sharedWith);
+    lastWidth = -1; 
+    lastHeight = -1;    
+    if(res && isNSContext()) {
+        if(0 != updateHandle) {
+            throw new InternalError("XXX1");
+        }
+        updateHandle = CGL.updateContextRegister(contextHandle, drawable.getHandle());
+        if(0 == updateHandle) {
+            throw new InternalError("XXX2");
+        }
     }
-    CGL.updateContext(contextHandle);
-  }
-
-  protected boolean createImpl() {
-    return create(false, false);
+    return res;
   }
 
-  public void setOpenGLMode(int mode) {
-    if (mode != MacOSXCGLDrawable.NSOPENGL_MODE)
-      throw new GLException("OpenGL mode switching not supported for on-screen GLContexts");
-  }
-    
-  public int  getOpenGLMode() {
-    return MacOSXCGLDrawable.NSOPENGL_MODE;
+  @Override
+  protected void destroyImpl() throws GLException {
+    if ( 0 != updateHandle ) {
+        CGL.updateContextUnregister(updateHandle);
+        updateHandle = 0;
+    }
+    super.destroyImpl();    
   }
+  
+  private long updateHandle = 0;
+  private int lastWidth, lastHeight;
 }
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java
index 513dc3a..80c5404 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java
@@ -40,52 +40,20 @@
 
 package jogamp.opengl.macosx.cgl;
 
-import java.lang.ref.WeakReference;
-import java.util.*;
-
-import javax.media.nativewindow.*;
-import javax.media.opengl.*;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawableFactory;
 
 public class MacOSXOnscreenCGLDrawable extends MacOSXCGLDrawable {
-  private List/*<WeakReference<GLContext>>*/ createdContexts =
-    new ArrayList();
-
+  
   protected MacOSXOnscreenCGLDrawable(GLDrawableFactory factory, NativeSurface component) {
     super(factory, component, false);
   }
 
   public GLContext createContext(GLContext shareWith) {
-    MacOSXOnscreenCGLContext context =
-      new MacOSXOnscreenCGLContext(this, shareWith);
-    // NOTE: we need to keep track of the created contexts in order to
-    // implement swapBuffers() because of how Mac OS X implements its
-    // OpenGL window interface
-    synchronized (this) {
-      List newContexts = new ArrayList();
-      newContexts.addAll(createdContexts);
-      newContexts.add(new WeakReference(context));
-      createdContexts = newContexts;
-    }
-    return context;
-  }
-
-  protected void swapBuffersImpl() {
-    for (Iterator iter = createdContexts.iterator(); iter.hasNext(); ) {
-      WeakReference ref = (WeakReference) iter.next();
-      MacOSXOnscreenCGLContext ctx = (MacOSXOnscreenCGLContext) ref.get();
-      // FIXME: clear out unreachable contexts
-      if (ctx != null) {
-        ctx.swapBuffers();
-      }
-    }
-  }
-  
-  public void setOpenGLMode(int mode) {
-    if (mode != NSOPENGL_MODE)
-      throw new GLException("OpenGL mode switching not supported for on-screen GLDrawables");
+    final MacOSXOnscreenCGLContext ctx= new MacOSXOnscreenCGLContext(this, shareWith);
+    registerContext(ctx);
+    return ctx;
   }
 
-  public int  getOpenGLMode() {
-    return NSOPENGL_MODE;
-  }
 }
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java
index 75b5450..7ba7d2d 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java
@@ -33,39 +33,26 @@
 
 package jogamp.opengl.macosx.cgl;
 
-import com.jogamp.common.nio.PointerBuffer;
-import java.security.*;
-import java.util.*;
+import javax.media.opengl.GL;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLPbuffer;
 
-import javax.media.opengl.*;
-import javax.media.nativewindow.*;
-import jogamp.opengl.*;
+import jogamp.opengl.GLContextImpl;
 
 public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
 
   // State for render-to-texture and render-to-texture-rectangle support
-  private int textureTarget; // e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_NV
   private int texture;       // actual texture object
 
-  private static boolean isTigerOrLater;
-
-  static {
-    String osVersion = Debug.getProperty("os.version", false, AccessController.getContext());
-    StringTokenizer tok = new StringTokenizer(osVersion, ". ");
-    int major = Integer.parseInt(tok.nextToken());
-    int minor = Integer.parseInt(tok.nextToken());
-    isTigerOrLater = ((major > 10) || (minor > 3));
-  }
-
   public MacOSXPbufferCGLContext(MacOSXPbufferCGLDrawable drawable,
                                 GLContext shareWith) {
     super(drawable, shareWith);
-    initOpenGLImpl();
   }
 
   public void bindPbufferToTexture() {
     GL gl = getGL();
-    gl.glBindTexture(textureTarget, texture);
+    gl.glBindTexture(((MacOSXPbufferCGLDrawable)drawable).getTextureTarget(), texture);
     // FIXME: not clear whether this is really necessary, but since
     // the API docs seem to imply it is and since it doesn't seem to
     // impact performance, leaving it in
@@ -75,29 +62,14 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
   public void releasePbufferFromTexture() {
   }
 
-  protected void makeCurrentImpl(boolean newCreated) throws GLException {
-    if (getOpenGLMode() != ((MacOSXPbufferCGLDrawable)drawable).getOpenGLMode()) {
-      setOpenGLMode(((MacOSXPbufferCGLDrawable)drawable).getOpenGLMode());
-    }
-
-    if (!impl.makeCurrent(contextHandle)) {
-      throw new GLException("Error making Context (NS) current");
-    }
-            
-    if (newCreated) {
+  protected boolean createImpl(GLContextImpl shareWith) {
+    boolean res = super.createImpl(shareWith);
+    if(res) {  
       // Initialize render-to-texture support if requested
-      DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
-      GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getChosenCapabilities();
-      GL gl = getGL();
-      boolean rect = gl.isGL2GL3() && capabilities.getPbufferRenderToTextureRectangle();
-      if (rect) {
-        if (!gl.isExtensionAvailable("GL_EXT_texture_rectangle")) {
-          System.err.println("MacOSXPbufferCGLContext: WARNING: GL_EXT_texture_rectangle extension not " +
-                             "supported; skipping requested render_to_texture_rectangle support for pbuffer");
-          rect = false;
-        }
-      }
-      textureTarget = (rect ? GL2.GL_TEXTURE_RECTANGLE : GL.GL_TEXTURE_2D);
+      final GL gl = getGL();
+      final MacOSXPbufferCGLDrawable osxPDrawable = (MacOSXPbufferCGLDrawable)drawable;
+      final int textureTarget = osxPDrawable.getTextureTarget();
+  
       int[] tmp = new int[1];
       gl.glGenTextures(1, tmp, 0);
       texture = tmp[0];
@@ -106,261 +78,14 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
       gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
       gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);
       gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);
-      gl.glCopyTexImage2D(textureTarget, 0, GL.GL_RGB, 0, 0, drawable.getWidth(), drawable.getHeight(), 0);
+      gl.glTexImage2D(textureTarget, 0, GL.GL_RGB, osxPDrawable.getTextureWidth(), osxPDrawable.getTextureHeight(), 
+                      0, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, null);
+      gl.glCopyTexSubImage2D(textureTarget, 0, 0, 0, 0, 0, drawable.getWidth(), drawable.getHeight());
     }
-  }
-
-  protected void releaseImpl() throws GLException {
-    if (!impl.release(contextHandle)) {
-      throw new GLException("Error releasing OpenGL Context (NS)");
-    }
-  }
-
-  protected void destroyImpl() throws GLException {
-      if (!impl.destroy(contextHandle)) {
-        throw new GLException("Unable to delete OpenGL context");
-      }
-      if (DEBUG) {
-        System.err.println("!!! Destroyed OpenGL context " + contextHandle);
-      }
-  }
-
-  protected void setSwapIntervalImpl(int interval) {
-    impl.setSwapInterval(contextHandle, interval);
-    currentSwapInterval = impl.getSwapInterval() ;
+    return res;
   }
 
   public int getFloatingPointMode() {
     return GLPbuffer.APPLE_FLOAT;
   }
-
-  protected boolean createImpl() throws GLException {
-    DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
-    GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getChosenCapabilities();
-    if (capabilities.getPbufferFloatingPointBuffers() &&
-    !isTigerOrLater) {
-      throw new GLException("Floating-point pbuffers supported only on OS X 10.4 or later");
-    }
-    // Change our OpenGL mode to match that of any share context before we create ourselves
-    MacOSXCGLContext other = (MacOSXCGLContext) GLContextShareSet.getShareContext(this);
-    if (other != null) {
-      setOpenGLMode(other.getOpenGLMode());
-    }
-    // Will throw exception upon error
-    isNSContext = impl.isNSContext();
-    contextHandle = impl.create();
-
-    if (!impl.makeCurrent(contextHandle)) {
-      throw new GLException("Error making Context (NS:"+isNSContext()+") current");
-    }
-    if(!isNSContext()) { // FIXME: ??
-        throw new GLException("Not a NS Context");
-    }
-    setGLFunctionAvailability(true, true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
-    return true;
-  }
-
-  //---------------------------------------------------------------------------
-  // OpenGL "mode switching" functionality
-  //
-  private boolean haveSetOpenGLMode = false;
-  // FIXME: should consider switching the default mode based on
-  // whether the Java2D/JOGL bridge is active -- need to ask ourselves
-  // whether it's more likely that we will share with a GLCanvas or a
-  // GLJPanel when the bridge is turned on
-  private int     openGLMode = MacOSXCGLDrawable.NSOPENGL_MODE;
-  // Implementation object (either NSOpenGL-based or CGL-based)
-  protected Impl impl;
-
-  public void setOpenGLMode(int mode) {
-    if (mode == openGLMode) {
-      return;
-    }
-    if (haveSetOpenGLMode) {
-      throw new GLException("Can't switch between using NSOpenGLPixelBuffer and CGLPBufferObj more than once");
-    }
-    destroyImpl();
-    ((MacOSXPbufferCGLDrawable)drawable).setOpenGLMode(mode);
-    openGLMode = mode;
-    haveSetOpenGLMode = true;
-    if (DEBUG) {
-      System.err.println("Switching PBuffer context mode to " +
-                         ((mode == MacOSXCGLDrawable.NSOPENGL_MODE) ? "NSOPENGL_MODE" : "CGL_MODE"));
-    }
-    initOpenGLImpl();
-  }
-
-  public int  getOpenGLMode() {
-    return openGLMode;
-  }
-
-  private void initOpenGLImpl() {
-    switch (openGLMode) {
-      case MacOSXCGLDrawable.NSOPENGL_MODE:
-        impl = new NSOpenGLImpl();
-        break;
-      case MacOSXCGLDrawable.CGL_MODE:
-        impl = new CGLImpl();
-        break;
-      default:
-        throw new InternalError("Illegal implementation mode " + openGLMode);
-    }
-  }
-
-  // Abstract interface for implementation of this context (either
-  // NSOpenGL-based or CGL-based)
-  interface Impl {
-    public boolean isNSContext();
-    public long    create();
-    public boolean destroy(long ctx);
-    public boolean makeCurrent(long ctx);
-    public boolean release(long ctx);
-    public void    setSwapInterval(long ctx, int interval);
-    public int     getSwapInterval();
-  }
-
-  // NSOpenGLContext-based implementation
-  class NSOpenGLImpl implements Impl {
-    public boolean isNSContext() { return true; }
-    public long create() {
-      DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
-      GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getChosenCapabilities();
-      if (capabilities.getPbufferFloatingPointBuffers() &&
-          !isTigerOrLater) {
-        throw new GLException("Floating-point pbuffers supported only on OS X 10.4 or later");
-      }
-      if (!MacOSXPbufferCGLContext.this.create(true, capabilities.getPbufferFloatingPointBuffers())) {
-        throw new GLException("Error creating context for pbuffer");
-      }
-      // Must now associate the pbuffer with our newly-created context
-      CGL.setContextPBuffer(contextHandle, drawable.getHandle());
-      return contextHandle;
-    }
-
-    public boolean destroy(long ctx) {
-      return CGL.deleteContext(ctx);
-    }
-
-    public boolean makeCurrent(long ctx) {
-      return CGL.makeCurrentContext(ctx);
-    }
-
-    public boolean release(long ctx) {
-      return CGL.clearCurrentContext(ctx);
-    }
-
-    private int currentSwapInterval = 0 ;
-
-    public void setSwapInterval(long ctx, int interval) {
-      CGL.setSwapInterval(ctx, interval);      
-      currentSwapInterval = interval ;
-    }
-    public int getSwapInterval() {
-        return currentSwapInterval;
-    }
-  }
-
-  class CGLImpl implements Impl {
-    public boolean isNSContext() { return false; }
-    public long create() {
-      // Find and configure share context
-      MacOSXCGLContext other = (MacOSXCGLContext) GLContextShareSet.getShareContext(MacOSXPbufferCGLContext.this);
-      long share = 0;
-      if (other != null) {
-        // Reconfigure pbuffer-based GLContexts
-        if (other instanceof MacOSXPbufferCGLContext) {
-          MacOSXPbufferCGLContext ctx = (MacOSXPbufferCGLContext) other;
-          ctx.setOpenGLMode(MacOSXCGLDrawable.CGL_MODE);
-        } else {
-          if (other.isNSContext()) {
-            throw new GLException("Can't share between NSOpenGLContexts and CGLContextObjs");
-          }
-        }
-        share = other.getHandle();
-        // Note we don't check for a 0 return value, since switching
-        // the context's mode causes it to be destroyed and not
-        // re-initialized until the next makeCurrent
-      }
-
-      // Set up pixel format attributes
-      // FIXME: shall go into MacOSXCGLGraphicsConfiguration
-      int[] attrs = new int[256];
-      int i = 0;
-      attrs[i++] = CGL.kCGLPFAPBuffer;
-      DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
-      GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getChosenCapabilities();
-      if (capabilities.getPbufferFloatingPointBuffers())
-        attrs[i++] = CGL.kCGLPFAColorFloat;
-      if (capabilities.getDoubleBuffered())
-        attrs[i++] = CGL.kCGLPFADoubleBuffer;
-      if (capabilities.getStereo())
-        attrs[i++] = CGL.kCGLPFAStereo;
-      attrs[i++] = CGL.kCGLPFAColorSize;
-      attrs[i++] = (capabilities.getRedBits() +
-                    capabilities.getGreenBits() +
-                    capabilities.getBlueBits());
-      attrs[i++] = CGL.kCGLPFAAlphaSize;
-      attrs[i++] = capabilities.getAlphaBits();
-      attrs[i++] = CGL.kCGLPFADepthSize;
-      attrs[i++] = capabilities.getDepthBits();
-      // FIXME: should validate stencil size as is done in MacOSXWindowSystemInterface.m
-      attrs[i++] = CGL.kCGLPFAStencilSize;
-      attrs[i++] = capabilities.getStencilBits();
-      attrs[i++] = CGL.kCGLPFAAccumSize;
-      attrs[i++] = (capabilities.getAccumRedBits() +
-                    capabilities.getAccumGreenBits() +
-                    capabilities.getAccumBlueBits() +
-                    capabilities.getAccumAlphaBits());
-      if (capabilities.getSampleBuffers()) {
-        attrs[i++] = CGL.kCGLPFASampleBuffers;
-        attrs[i++] = 1;
-        attrs[i++] = CGL.kCGLPFASamples;
-        attrs[i++] = capabilities.getNumSamples();
-      }
-
-      // Use attribute array to select pixel format
-      PointerBuffer fmt = PointerBuffer.allocateDirect(1);
-      long[] numScreens = new long[1];
-      int res = CGL.CGLChoosePixelFormat(attrs, 0, fmt, numScreens, 0);
-      if (res != CGL.kCGLNoError) {
-        throw new GLException("Error code " + res + " while choosing pixel format");
-      }
-      
-      // Create new context
-      PointerBuffer ctx = PointerBuffer.allocateDirect(1);
-      if (DEBUG) {
-        System.err.println("Share context for CGL-based pbuffer context is " + toHexString(share));
-      }
-      res = CGL.CGLCreateContext(fmt.get(0), share, ctx);
-      CGL.CGLDestroyPixelFormat(fmt.get(0));
-      if (res != CGL.kCGLNoError) {
-        throw new GLException("Error code " + res + " while creating context");
-      }
-      // Attach newly-created context to the pbuffer
-      res = CGL.CGLSetPBuffer(ctx.get(0), drawable.getHandle(), 0, 0, 0);
-      if (res != CGL.kCGLNoError) {
-        throw new GLException("Error code " + res + " while attaching context to pbuffer");
-      }
-      return ctx.get(0);
-    }
-    
-    public boolean destroy(long ctx) {
-      return (CGL.CGLDestroyContext(ctx) == CGL.kCGLNoError);
-    }
-
-    public boolean makeCurrent(long ctx) {
-      return CGL.CGLSetCurrentContext(ctx) == CGL.kCGLNoError;
-    }
-
-    public boolean release(long ctx) {
-      return (CGL.CGLSetCurrentContext(0) == CGL.kCGLNoError);
-    }
-
-    public void setSwapInterval(long ctx, int interval) {
-      // For now not supported (not really relevant for off-screen contexts anyway)
-    }
-    public int getSwapInterval() {
-        return 0;
-    }
-  }
 }
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java
index ec9ff8d..e02c3ef 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java
@@ -40,188 +40,158 @@
 
 package jogamp.opengl.macosx.cgl;
 
+import javax.media.nativewindow.DefaultGraphicsConfiguration;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.SurfaceChangeable;
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
+
 import com.jogamp.common.nio.PointerBuffer;
-import javax.media.opengl.*;
-import javax.media.nativewindow.*;
-import jogamp.opengl.*;
+import com.jogamp.opengl.util.GLBuffers;
+
+public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {  
+  // Abstract interface for implementation of this drawable (either
+  // NSOpenGL-based or CGL-based)
+  interface GLBackendImpl {
+    public long create(int renderTarget, int internalFormat, int width, int height);
+    public void destroy(long pbuffer);
+  }
 
-public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
-  private static final boolean DEBUG = Debug.debug("MacOSXPbufferCGLDrawable");
+  // Implementation object (either NSOpenGL-based or CGL-based)
+  protected GLBackendImpl impl;
   
   // State for render-to-texture and render-to-texture-rectangle support
-  private int textureTarget; // e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_NV
-  private int texture;       // actual texture object
+  // private int textureTarget; // e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_NV
+  // private int texture;       // actual texture object
 
-  // NSOpenGLPbuffer (for normal mode)
-  // CGLPbufferObj (for CGL_MODE situation, i.e., when Java2D/JOGL bridge is active)
   // Note that we can not store this in the NativeSurface because the
   // semantic is that contains an NSView
   protected long pBuffer;
+  protected int pBufferTexTarget, pBufferTexWidth, pBufferTexHeight;
 
   public MacOSXPbufferCGLDrawable(GLDrawableFactory factory, NativeSurface target) {
-    super(factory, target, true);
-
-    if (DEBUG) {
-        System.out.println("Pbuffer config: " + getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration());
-    }
-
-    initOpenGLImpl();
-    createPbuffer();
-
-    if (DEBUG) {
-        System.err.println("Created pbuffer " + this);
-    }
+    super(factory, target, false);
   }
 
+  protected void destroyImpl() {
+    setRealized(false);  
+  }
+  
   protected void setRealizedImpl() {
     if(realized) {
         createPbuffer();
     } else {
-        destroyImpl();
+        destroyPbuffer();
     }
   }
 
   public GLContext createContext(GLContext shareWith) {
-    return new MacOSXPbufferCGLContext(this, shareWith);
+    final MacOSXPbufferCGLContext ctx = new MacOSXPbufferCGLContext(this, shareWith);
+    registerContext(ctx);
+    return ctx;
   }
 
-  protected void destroyImpl() {
+  @Override
+  protected long getNSViewHandle() {
+      // pbuffer handle is NSOpenGLPixelBuffer
+      return 0;
+  }
+  
+  @Override
+  public long getHandle() {
+    return pBuffer;
+  }
+  
+  protected int getTextureTarget() { return pBufferTexTarget;  }
+  protected int getTextureWidth() { return pBufferTexWidth; }
+  protected int getTextureHeight() { return pBufferTexHeight; }
+    
+  protected void destroyPbuffer() {
     if (this.pBuffer != 0) {
       NativeSurface ns = getNativeSurface();
       impl.destroy(pBuffer);
       this.pBuffer = 0;
       ((SurfaceChangeable)ns).setSurfaceHandle(0);
-      if (DEBUG) {
-        System.err.println("Destroyed pbuffer: " + pBuffer);
-      }
     }
   }
 
-  public long getHandle() {
-    return pBuffer;
-  }
-  
-  protected void swapBuffersImpl() {
-    if(DEBUG) {
-        System.err.println("unhandled swapBuffersImpl() called for: "+this);
+  private void createPbuffer() {
+    final NativeSurface ns = getNativeSurface();
+    final DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) ns.getGraphicsConfiguration();
+    final GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getChosenCapabilities();
+    final GLProfile glProfile = capabilities.getGLProfile();
+    MacOSXCGLDrawableFactory.SharedResource sr = ((MacOSXCGLDrawableFactory)factory).getOrCreateOSXSharedResource(config.getScreen().getDevice());
+    
+    if (DEBUG) {
+        System.out.println("Pbuffer config: " + config);
     }
-  }
 
-  private void createPbuffer() {
-    NativeSurface ns = getNativeSurface();
-    DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) ns.getGraphicsConfiguration().getNativeGraphicsConfiguration();
-    GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getChosenCapabilities();
-    GLProfile glProfile = capabilities.getGLProfile();
-    int renderTarget;
-    if (glProfile.isGL2GL3() && capabilities.getPbufferRenderToTextureRectangle()) {
-      renderTarget = GL2.GL_TEXTURE_RECTANGLE;
+    if ( capabilities.getPbufferRenderToTextureRectangle() && null!=sr && sr.isRECTTextureAvailable() ) {
+      pBufferTexTarget = GL2.GL_TEXTURE_RECTANGLE;
+    } else {
+      pBufferTexTarget = GL.GL_TEXTURE_2D;
+    }
+    if ( GL2.GL_TEXTURE_RECTANGLE == pBufferTexTarget || ( null!=sr && sr.isNPOTTextureAvailable() ) ) { 
+      pBufferTexWidth = getWidth();
+      pBufferTexHeight = getHeight();
     } else {
-      int w = getNextPowerOf2(getWidth());
-      int h = getNextPowerOf2(getHeight());
-      ((SurfaceChangeable)ns).setSize(w, h);
-      renderTarget = GL.GL_TEXTURE_2D;
+      pBufferTexWidth = GLBuffers.getNextPowerOf2(getWidth());
+      pBufferTexHeight = GLBuffers.getNextPowerOf2(getHeight());
     }
 
     int internalFormat = GL.GL_RGBA;
     if (capabilities.getPbufferFloatingPointBuffers()) {
-      // FIXME: want to check availability of GL_APPLE_float_pixels
-      // extension, but need valid OpenGL context in order to do so --
-      // in worst case would need to create dummy window / GLCanvas
-      // (undesirable) -- could maybe also do this with pbuffers
-      /*
-        if (!gl.isExtensionAvailable("GL_APPLE_float_pixels")) {
-        throw new GLException("Floating-point support (GL_APPLE_float_pixels) not available");
-        }
-      */
-      if(glProfile.isGL2GL3()) {
-        switch (capabilities.getRedBits()) {
+      if(!glProfile.isGL2GL3() || null==sr || sr.isAppletFloatPixelsAvailable()) {
+          throw new GLException("Floating-point support (GL_APPLE_float_pixels) not available");
+      }
+      switch (capabilities.getRedBits()) {
         case 16: internalFormat = GL2.GL_RGBA_FLOAT16_APPLE; break;
         case 32: internalFormat = GL2.GL_RGBA_FLOAT32_APPLE; break;
         default: throw new GLException("Invalid floating-point bit depth (only 16 and 32 supported)");
-        }
-      } else {
-        internalFormat = GL.GL_RGBA;
       }
     }
-            
-    pBuffer = impl.create(renderTarget, internalFormat, getWidth(), getHeight());
+    
+    pBuffer = impl.create(pBufferTexTarget, internalFormat, getWidth(), getHeight());
+    if(DEBUG) {
+        System.err.println("MacOSXPbufferCGLDrawable tex: target "+toHexString(pBufferTexTarget)+
+                            ", pbufferSize "+getWidth()+"x"+getHeight()+
+                            ", texSize "+pBufferTexWidth+"x"+pBufferTexHeight+
+                            ", internal-fmt "+toHexString(internalFormat));
+        System.err.println("MacOSXPbufferCGLDrawable pBuffer: "+toHexString(pBuffer));
+        // Thread.dumpStack();
+    }
     if (pBuffer == 0) {
       throw new GLException("pbuffer creation error: CGL.createPBuffer() failed");
     }
 
     ((SurfaceChangeable)ns).setSurfaceHandle(pBuffer);
-
-  }
-
-  private int getNextPowerOf2(int number) {
-    if (((number-1) & number) == 0) {
-      //ex: 8 -> 0b1000; 8-1=7 -> 0b0111; 0b1000&0b0111 == 0
-      return number;
-    }
-    int power = 0;
-    while (number > 0) {
-      number = number>>1;
-      power++;
-    }
-    return (1<<power);
-  }
-
-  //---------------------------------------------------------------------------
-  // OpenGL "mode switching" functionality
-  //
-  private boolean haveSetOpenGLMode = false;
-  // FIXME: should consider switching the default mode based on
-  // whether the Java2D/JOGL bridge is active -- need to ask ourselves
-  // whether it's more likely that we will share with a GLCanvas or a
-  // GLJPanel when the bridge is turned on
-  private int     openGLMode = NSOPENGL_MODE;
-  // Implementation object (either NSOpenGL-based or CGL-based)
-  protected Impl impl;
-
-  public void setOpenGLMode(int mode) {
-    if (mode == openGLMode) {
-      return;
-    }
-    if (haveSetOpenGLMode) {
-      throw new GLException("Can't switch between using NSOpenGLPixelBuffer and CGLPBufferObj more than once");
-    }
-    destroyImpl();
-    openGLMode = mode;
-    haveSetOpenGLMode = true;
-    if (DEBUG) {
-      System.err.println("Switching PBuffer drawable mode to " +
-                         ((mode == MacOSXCGLDrawable.NSOPENGL_MODE) ? "NSOPENGL_MODE" : "CGL_MODE"));
-    }
-    initOpenGLImpl();
-    createPbuffer();
   }
 
-  public int getOpenGLMode() {
-    return openGLMode;
+  public void setOpenGLMode(GLBackendType mode) {
+    super.setOpenGLMode(mode);
+    createPbuffer(); // recreate
   }
 
-  private void initOpenGLImpl() {
-    switch (openGLMode) {
-      case NSOPENGL_MODE:
+  protected void initOpenGLImpl(GLBackendType backend) {
+    switch (backend) {
+      case NSOPENGL:
         impl = new NSOpenGLImpl();
         break;
-      case CGL_MODE:
+      case CGL:
         impl = new CGLImpl();
         break;
       default:
-        throw new InternalError("Illegal implementation mode " + openGLMode);
+        throw new InternalError("Illegal implementation mode " + backend);
     }
-  }
-
-  // Abstract interface for implementation of this drawable (either
-  // NSOpenGL-based or CGL-based)
-  interface Impl {
-    public long create(int renderTarget, int internalFormat, int width, int height);
-    public void destroy(long pbuffer);
-  }
-
+  }  
+  
   // NSOpenGLPixelBuffer implementation
-  class NSOpenGLImpl implements Impl {
+  class NSOpenGLImpl implements GLBackendImpl {
     public long create(int renderTarget, int internalFormat, int width, int height) {
       return CGL.createPBuffer(renderTarget, internalFormat, width, height);
     }
@@ -232,7 +202,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
   }
 
   // CGL implementation
-  class CGLImpl implements Impl {
+  class CGLImpl implements GLBackendImpl {
     public long create(int renderTarget, int internalFormat, int width, int height) {
       PointerBuffer pbuffer = PointerBuffer.allocateDirect(1);
       int res = CGL.CGLCreatePBuffer(width, height, renderTarget, internalFormat, 0, pbuffer);
@@ -248,5 +218,6 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
         throw new GLException("Error destroying CGL-based pbuffer: error code " + res);
       }
     }
-  }
+  }  
+  
 }
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java
index 68e82dc..a8c04ee 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java
@@ -58,8 +58,10 @@ import jogamp.opengl.macosx.cgl.MacOSXCGLGraphicsConfiguration;
 public class MacOSXAWTCGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFactory {
     protected static final boolean DEBUG = jogamp.opengl.Debug.debug("GraphicsConfiguration");
 
-    public MacOSXAWTCGLGraphicsConfigurationFactory() {
-        GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.awt.AWTGraphicsDevice.class, this);
+    public static void registerFactory() {
+        GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.awt.AWTGraphicsDevice.class, new MacOSXAWTCGLGraphicsConfigurationFactory());
+    }    
+    private MacOSXAWTCGLGraphicsConfigurationFactory() {
     }
 
     protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
@@ -72,7 +74,7 @@ public class MacOSXAWTCGLGraphicsConfigurationFactory extends GLGraphicsConfigur
         }
 
         if(null==absScreen) {
-            absScreen = AWTGraphicsScreen.createScreenDevice(-1, AbstractGraphicsDevice.DEFAULT_UNIT);
+            absScreen = AWTGraphicsScreen.createDefault();
         }
         AWTGraphicsScreen awtScreen = (AWTGraphicsScreen) absScreen;
         device = ((AWTGraphicsDevice)awtScreen.getDevice()).getGraphicsDevice();
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXJava2DCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
index 8f64e0a..70416d1 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
@@ -39,13 +39,17 @@
 
 package jogamp.opengl.macosx.cgl.awt;
 
-import jogamp.opengl.macosx.cgl.*;
-
 import java.awt.Graphics;
-import javax.media.opengl.*;
-import jogamp.opengl.*;
-import jogamp.opengl.awt.*;
-import jogamp.opengl.macosx.cgl.*;
+
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLException;
+
+import jogamp.opengl.GLContextImpl;
+import jogamp.opengl.awt.Java2D;
+import jogamp.opengl.awt.Java2DGLContext;
+import jogamp.opengl.macosx.cgl.MacOSXCGLContext;
+import jogamp.opengl.macosx.cgl.MacOSXCGLDrawable.GLBackendType;
+
 
 /** MacOSXCGLContext implementation supporting the Java2D/JOGL bridge
  * on Mac OS X. The external GLDrawable mechanism does not work on Mac
@@ -70,44 +74,31 @@ public class MacOSXJava2DCGLContext extends MacOSXCGLContext implements Java2DGL
     this.graphics = g;
   }
 
-  protected void makeCurrentImpl(boolean newCreated) throws GLException {
+  protected void makeCurrentImpl() throws GLException {
     if (!Java2D.makeOGLContextCurrentOnSurface(graphics, contextHandle)) {
       throw new GLException("Error making context current");
     }            
   }
 
-  protected boolean createImpl() {
-    // Find and configure share context
-    MacOSXCGLContext other = (MacOSXCGLContext) GLContextShareSet.getShareContext(this);
-    long share = 0;
-    if (other != null) {
-      // Reconfigure pbuffer-based GLContexts
-      if (other instanceof MacOSXPbufferCGLContext) {
-        MacOSXPbufferCGLContext ctx = (MacOSXPbufferCGLContext) other;
-        ctx.setOpenGLMode(MacOSXCGLDrawable.CGL_MODE);
-      } else {
-        if (other.getOpenGLMode() != MacOSXCGLDrawable.CGL_MODE) {
-          throw new GLException("Can't share between NSOpenGLContexts and CGLContextObjs");
-        }
-      }
-      share = other.getHandle();
-      // Note we don't check for a 0 return value, since switching
-      // the context's mode causes it to be destroyed and not
-      // re-initialized until the next makeCurrent
-    }
-
-    if (DEBUG) {
-      System.err.println("!!! Share context is " + toHexString(share) + " for " + getClass().getName());
-    }
-
+  protected boolean createImpl(GLContextImpl shareWith) {
+    long share = createImplPreset(shareWith);
+    
     long ctx = Java2D.createOGLContextOnSurface(graphics, share);
     if (ctx == 0) {
+      if(DEBUG) { 
+          System.err.println("Error creating current: "+this);
+      }
+      return false;
+    }
+    if (!Java2D.makeOGLContextCurrentOnSurface(graphics, contextHandle)) {
+      Java2D.destroyOGLContext(ctx);
+      if(DEBUG) { 
+          System.err.println("Error making created context current: "+this);
+      }
       return false;
     }
-    setGLFunctionAvailability(true, true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY); // use GL_VERSION
-    // FIXME: think about GLContext sharing
+    setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY); // use GL_VERSION
     contextHandle = ctx;
-    isNSContext = true;
     return true;
   }
 
@@ -119,17 +110,12 @@ public class MacOSXJava2DCGLContext extends MacOSXCGLContext implements Java2DGL
 
   protected void destroyImpl() throws GLException {
       Java2D.destroyOGLContext(contextHandle);
-      if (DEBUG) {
-        System.err.println("!!! Destroyed OpenGL context " + contextHandle);
-      }
   }
 
-  public void setOpenGLMode(int mode) {
-    if (mode != MacOSXCGLDrawable.CGL_MODE)
+  public void setOpenGLMode(GLBackendType mode) {
+    if (mode != GLBackendType.CGL) {
       throw new GLException("OpenGL mode switching not supported for Java2D GLContexts");
-  }
-
-  public int  getOpenGLMode() {
-    return MacOSXCGLDrawable.CGL_MODE;
+    }
+    super.setOpenGLMode(mode);
   }
 }
diff --git a/src/jogl/classes/jogamp/opengl/util/GLArrayHandler.java b/src/jogl/classes/jogamp/opengl/util/GLArrayHandler.java
index 4a570d3..22690b0 100644
--- a/src/jogl/classes/jogamp/opengl/util/GLArrayHandler.java
+++ b/src/jogl/classes/jogamp/opengl/util/GLArrayHandler.java
@@ -63,7 +63,9 @@ public interface GLArrayHandler {
    * @param handler the sub handler
    * @throws UnsupportedOperationException if this array handler does not support interleaved arrays
    */
-  public void addSubHandler(GLArrayHandler handler) throws UnsupportedOperationException;
+  public void addSubHandler(GLArrayHandlerFlat handler) throws UnsupportedOperationException;
 
+  public void setSubArrayVBOName(int vboName);
+  
 }
 
diff --git a/src/jogl/classes/jogamp/opengl/util/GLArrayHandler.java b/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerFlat.java
similarity index 71%
copy from src/jogl/classes/jogamp/opengl/util/GLArrayHandler.java
copy to src/jogl/classes/jogamp/opengl/util/GLArrayHandlerFlat.java
index 4a570d3..dca9129 100644
--- a/src/jogl/classes/jogamp/opengl/util/GLArrayHandler.java
+++ b/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerFlat.java
@@ -1,5 +1,5 @@
 /**
- * Copyright 2010 JogAmp Community. All rights reserved.
+ * Copyright 2011 JogAmp Community. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without modification, are
  * permitted provided that the following conditions are met:
@@ -30,22 +30,22 @@ package jogamp.opengl.util;
 
 import javax.media.opengl.*;
 
+import com.jogamp.opengl.util.GLArrayDataWrapper;
+
 /**
- * Handles consistency of buffer data and array state.
- * Implementations shall consider buffer types (VBO, ..), interleaved, etc.
- * They also need to consider array state types, i.e. fixed function or GLSL.
+ * Handles consistency of interleaved array state.
  */
-public interface GLArrayHandler {
+public interface GLArrayHandlerFlat {
 
   /**
    * Implementation shall associate the data with the array
-   * and synchronize the data with the GPU.
    * 
    * @param gl current GL object
    * @param enable true if array data shall be valid, otherwise false.
+   * @param force true force data association, bypassing optimization
    * @param ext extension object allowing passing of an implementation detail 
    */
-  public void syncData(GL gl, boolean enable, Object ext);
+  public void syncData(GL gl, boolean enable, boolean force, Object ext);
   
   /**
    * Implementation shall enable or disable the array state.
@@ -54,16 +54,8 @@ public interface GLArrayHandler {
    * @param enable true if array shall be enabled, otherwise false.
    * @param ext extension object allowing passing of an implementation detail 
    */
-  public void enableState(GL gl, boolean enable, Object ext);
+  public void enableState(GL gl, boolean enable, Object ext);  
   
-  /**
-   * Supporting interleaved arrays, where sub handlers may handle 
-   * the array state and the <i>master</i> handler the buffer consistency.
-   *   
-   * @param handler the sub handler
-   * @throws UnsupportedOperationException if this array handler does not support interleaved arrays
-   */
-  public void addSubHandler(GLArrayHandler handler) throws UnsupportedOperationException;
-
+  public GLArrayDataWrapper getData();
 }
 
diff --git a/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerInterleaved.java b/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerInterleaved.java
index 8e813a7..d31b415 100644
--- a/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerInterleaved.java
+++ b/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerInterleaved.java
@@ -43,19 +43,25 @@ import com.jogamp.opengl.util.GLArrayDataEditable;
  */
 public class GLArrayHandlerInterleaved implements GLArrayHandler {
   private GLArrayDataEditable ad;
-  private List<GLArrayHandler> subArrays = new ArrayList<GLArrayHandler>();
+  private List<GLArrayHandlerFlat> subArrays = new ArrayList<GLArrayHandlerFlat>();
 
   public GLArrayHandlerInterleaved(GLArrayDataEditable ad) {
     this.ad = ad;
   }
   
-  public final void addSubHandler(GLArrayHandler handler) {
+  public final void setSubArrayVBOName(int vboName) {
+      for(int i=0; i<subArrays.size(); i++) {
+          subArrays.get(i).getData().setVBOName(vboName);
+      }      
+  }
+  
+  public final void addSubHandler(GLArrayHandlerFlat handler) {
       subArrays.add(handler);
   }
 
-  private final void syncSubData(GL gl, boolean enable, Object ext) {
+  private final void syncSubData(GL gl, boolean enable, boolean force, Object ext) {
       for(int i=0; i<subArrays.size(); i++) {
-          subArrays.get(i).syncData(gl, enable, ext);
+          subArrays.get(i).syncData(gl, enable, force, ext);
       }      
   }  
   
@@ -74,9 +80,9 @@ public class GLArrayHandlerInterleaved implements GLArrayHandler {
                 ad.setVBOWritten(true);
             }
         }
-        syncSubData(gl, true, ext);
+        syncSubData(gl, true, true, ext);
     } else {
-        syncSubData(gl, false, ext);
+        syncSubData(gl, false, true, ext);
         if(ad.isVBO()) {
             gl.glBindBuffer(ad.getVBOTarget(), 0);
         }
diff --git a/src/jogl/classes/jogamp/opengl/util/GLDataArrayHandler.java b/src/jogl/classes/jogamp/opengl/util/GLDataArrayHandler.java
index c91d6c9..6c8e2e7 100644
--- a/src/jogl/classes/jogamp/opengl/util/GLDataArrayHandler.java
+++ b/src/jogl/classes/jogamp/opengl/util/GLDataArrayHandler.java
@@ -45,7 +45,11 @@ public class GLDataArrayHandler implements GLArrayHandler {
     this.ad = ad;
   }
 
-  public final void addSubHandler(GLArrayHandler handler) {
+  public final void setSubArrayVBOName(int vboName) {
+      throw new UnsupportedOperationException();
+  }
+  
+  public final void addSubHandler(GLArrayHandlerFlat handler) {
       throw new UnsupportedOperationException();
   }
   
diff --git a/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandler.java b/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandler.java
index 8963b79..d8939dc 100644
--- a/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandler.java
+++ b/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandler.java
@@ -45,8 +45,12 @@ public class GLFixedArrayHandler implements GLArrayHandler {
   public GLFixedArrayHandler(GLArrayDataEditable ad) {
     this.ad = ad;
   }
-
-  public final void addSubHandler(GLArrayHandler handler) {
+  
+  public final void setSubArrayVBOName(int vboName) {
+      throw new UnsupportedOperationException();
+  }
+  
+  public final void addSubHandler(GLArrayHandlerFlat handler) {
       throw new UnsupportedOperationException();
   }
   
diff --git a/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandlerFlat.java b/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandlerFlat.java
index 81c782d..2937cc7 100644
--- a/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandlerFlat.java
+++ b/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandlerFlat.java
@@ -29,27 +29,27 @@
 package jogamp.opengl.util;
 
 import javax.media.opengl.GL;
-import javax.media.opengl.GLArrayData;
 import javax.media.opengl.GLException;
 import javax.media.opengl.fixedfunc.GLPointerFunc;
 
+import com.jogamp.opengl.util.GLArrayDataWrapper;
 
 /**
  * Used for interleaved fixed function arrays, i.e. where the buffer data itself is handled 
  * separately and interleaves many arrays.
  */
-public class GLFixedArrayHandlerFlat implements GLArrayHandler {
-  private GLArrayData ad;
+public class GLFixedArrayHandlerFlat implements GLArrayHandlerFlat {
+  private GLArrayDataWrapper ad;
 
-  public GLFixedArrayHandlerFlat(GLArrayData ad) {
+  public GLFixedArrayHandlerFlat(GLArrayDataWrapper ad) {
     this.ad = ad;
   }
 
-  public final void addSubHandler(GLArrayHandler handler) {
-      throw new UnsupportedOperationException();
+  public GLArrayDataWrapper getData() {
+      return ad;
   }
   
-  public final void syncData(GL gl, boolean enable, Object ext) {
+  public final void syncData(GL gl, boolean enable, boolean force, Object ext) {
     if(enable) {
         final GLPointerFunc glp = gl.getGL2ES1();
         switch(ad.getIndex()) {
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java
index 96bb02b..602d283 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java
@@ -34,6 +34,7 @@ import javax.media.opengl.GL;
 import javax.media.opengl.GL2ES2;
 
 import jogamp.opengl.util.GLArrayHandler;
+import jogamp.opengl.util.GLArrayHandlerFlat;
 
 import com.jogamp.opengl.util.GLArrayDataEditable;
 import com.jogamp.opengl.util.glsl.ShaderState;
@@ -48,8 +49,12 @@ public class GLSLArrayHandler implements GLArrayHandler {
   public GLSLArrayHandler(GLArrayDataEditable ad) {
     this.ad = ad;
   }
-
-  public final void addSubHandler(GLArrayHandler handler) {
+  
+  public final void setSubArrayVBOName(int vboName) {
+      throw new UnsupportedOperationException();
+  }
+  
+  public final void addSubHandler(GLArrayHandlerFlat handler) {
       throw new UnsupportedOperationException();
   }
   
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java
index 0d6da7b..c4b761b 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java
@@ -30,31 +30,48 @@ package jogamp.opengl.util.glsl;
 
 import javax.media.opengl.GL;
 import javax.media.opengl.GL2ES2;
-import javax.media.opengl.GLArrayData;
 
-import jogamp.opengl.util.GLArrayHandler;
+import jogamp.opengl.util.GLArrayHandlerFlat;
 
+import com.jogamp.opengl.util.GLArrayDataWrapper;
 import com.jogamp.opengl.util.glsl.ShaderState;
 
 /**
  * Used for interleaved GLSL arrays, i.e. where the buffer data itself is handled 
  * separately and interleaves many arrays.
  */
-public class GLSLArrayHandlerFlat implements GLArrayHandler {
-  private GLArrayData ad;
+public class GLSLArrayHandlerFlat implements GLArrayHandlerFlat {
+  private GLArrayDataWrapper ad;
 
-  public GLSLArrayHandlerFlat(GLArrayData ad) {
+  public GLSLArrayHandlerFlat(GLArrayDataWrapper ad) {
     this.ad = ad;
   }
 
-  public final void addSubHandler(GLArrayHandler handler) {
-      throw new UnsupportedOperationException();
+  public GLArrayDataWrapper getData() {
+      return ad;
   }
-  
-  public final void syncData(GL gl, boolean enable, Object ext) {
-    final ShaderState st = (ShaderState) ext;
+    
+  public final void syncData(GL gl, boolean enable, boolean force, Object ext) {
     if(enable) {
-        st.vertexAttribPointer(gl.getGL2ES2(), ad);
+        final GL2ES2 glsl = gl.getGL2ES2();
+        final ShaderState st = (ShaderState) ext;
+
+        st.vertexAttribPointer(glsl, ad);
+        /**
+         * Due to probable application VBO switching, this might not make any sense ..
+         * 
+        if(force) {
+            st.vertexAttribPointer(glsl, ad);
+        } else if(st.getAttribLocation(glsl, ad) >= 0) {
+            final int[] qi = new int[1];
+            glsl.glGetVertexAttribiv(ad.getLocation(), GL2ES2.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, qi, 0);
+            if(ad.getVBOName() != qi[0]) {
+                System.err.println("XXX1: "+ad.getName()+", vbo ad "+ad.getVBOName()+", gl "+qi[0]+", "+ad);
+                st.vertexAttribPointer(glsl, ad);
+            } else {
+                System.err.println("XXX0: "+ad.getName()+", vbo ad "+ad.getVBOName()+", gl "+qi[0]+", "+ad);
+            }
+        }*/
     }
   }
 
diff --git a/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerInterleaved.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java
similarity index 61%
copy from src/jogl/classes/jogamp/opengl/util/GLArrayHandlerInterleaved.java
copy to src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java
index 8e813a7..f504296 100644
--- a/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerInterleaved.java
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java
@@ -26,8 +26,7 @@
  * or implied, of JogAmp Community.
  */
 
-package jogamp.opengl.util;
-
+package jogamp.opengl.util.glsl;
 
 import java.nio.Buffer;
 import java.util.ArrayList;
@@ -35,51 +34,62 @@ import java.util.List;
 
 import javax.media.opengl.GL;
 
+import jogamp.opengl.util.GLArrayHandler;
+import jogamp.opengl.util.GLArrayHandlerFlat;
+
 import com.jogamp.opengl.util.GLArrayDataEditable;
 
 /**
  * Interleaved fixed function arrays, i.e. where this buffer data 
  * represents many arrays. 
  */
-public class GLArrayHandlerInterleaved implements GLArrayHandler {
+public class GLSLArrayHandlerInterleaved implements GLArrayHandler {
   private GLArrayDataEditable ad;
-  private List<GLArrayHandler> subArrays = new ArrayList<GLArrayHandler>();
+  private List<GLArrayHandlerFlat> subArrays = new ArrayList<GLArrayHandlerFlat>();
 
-  public GLArrayHandlerInterleaved(GLArrayDataEditable ad) {
+  public GLSLArrayHandlerInterleaved(GLArrayDataEditable ad) {
     this.ad = ad;
   }
   
-  public final void addSubHandler(GLArrayHandler handler) {
+  public final void setSubArrayVBOName(int vboName) {
+      for(int i=0; i<subArrays.size(); i++) {
+          subArrays.get(i).getData().setVBOName(vboName);
+      }      
+  }
+  
+  public final void addSubHandler(GLArrayHandlerFlat handler) {
       subArrays.add(handler);
   }
 
-  private final void syncSubData(GL gl, boolean enable, Object ext) {
+  private final void syncSubData(GL gl, boolean enable, boolean force, Object ext) {
       for(int i=0; i<subArrays.size(); i++) {
-          subArrays.get(i).syncData(gl, enable, ext);
+          subArrays.get(i).syncData(gl, enable, force, ext);
       }      
   }  
   
-  public final void syncData(GL gl, boolean enable, Object ext) {
+  public final void syncData(GL gl, boolean enable, Object ext) {    
+    if(!ad.isVBO()) {
+        throw new InternalError("Interleaved handle is not VBO: "+ad);
+    }
+    
     if(enable) {
         final Buffer buffer = ad.getBuffer();
-
-        if(ad.isVBO()) {
-            // always bind and refresh the VBO mgr, 
-            // in case more than one gl*Pointer objects are in use
-            gl.glBindBuffer(ad.getVBOTarget(), ad.getVBOName());
-            if(!ad.isVBOWritten()) {
-                if(null!=buffer) {
-                    gl.glBufferData(ad.getVBOTarget(), buffer.limit() * ad.getComponentSizeInBytes(), buffer, ad.getVBOUsage());
-                }
-                ad.setVBOWritten(true);
+        final boolean vboWritten = ad.isVBOWritten();
+        
+        // always bind and refresh the VBO mgr, 
+        // in case more than one gl*Pointer objects are in use
+        gl.glBindBuffer(ad.getVBOTarget(), ad.getVBOName());
+        if(!vboWritten) {
+            if(null!=buffer) {
+                gl.glBufferData(ad.getVBOTarget(), buffer.limit() * ad.getComponentSizeInBytes(), buffer, ad.getVBOUsage());
             }
+            ad.setVBOWritten(true);
         }
-        syncSubData(gl, true, ext);
+        // sub data will decide weather to update the vertex attrib pointer
+        syncSubData(gl, true, !vboWritten, ext);
     } else {
-        syncSubData(gl, false, ext);
-        if(ad.isVBO()) {
-            gl.glBindBuffer(ad.getVBOTarget(), 0);
-        }
+        // NOP on GLSL: syncSubData(gl, false, ext);
+        gl.glBindBuffer(ad.getVBOTarget(), 0);
     }
   }
   
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java
index 4df3b7e..5742265 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java
@@ -57,15 +57,18 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable {
   private long hbitmap;
 
   protected WindowsBitmapWGLDrawable(GLDrawableFactory factory, NativeSurface target) {
-    super(factory, target, true);
-    create();
+    super(factory, target, false);
   }
 
+  protected void destroyImpl() {
+      setRealized(false);
+  }
+  
   protected void setRealizedImpl() {
     if(realized) {
-        create();
+        createBitmap();
     } else {
-        destroyImpl();
+        destroyBitmap();
     }
   }
 
@@ -73,13 +76,13 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable {
     return new WindowsBitmapWGLContext(this, shareWith);
   }
 
-  private void create() {
+  private void createBitmap() {
     int werr;
     NativeSurface ns = getNativeSurface();
     if(DEBUG) {
         System.err.println("WindowsBitmapWGLDrawable (1): "+ns);
     }
-    WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+    WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration();
     GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getRequestedCapabilities();
     int width = getWidth();
     int height = getHeight();
@@ -93,7 +96,7 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable {
                         capabilities.getGreenBits() +
                         capabilities.getBlueBits() +
                         capabilities.getAlphaBits());
-    header.setBiSize(header.size());
+    header.setBiSize(BITMAPINFOHEADER.size());
     header.setBiWidth(width);
     // NOTE: negating the height causes the DIB to be in top-down row
     // order rather than bottom-up; ends up being correct during pixel
@@ -118,7 +121,7 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable {
         System.err.println("WindowsBitmapWGLDrawable: " + width+"x"+height +
                             ", bpp " + bitsPerPixel +
                             ", bytes " + byteNum +
-                            ", header sz " + header.size() +
+                            ", header sz " + BITMAPINFOHEADER.size() +
                             ", DIB ptr num " + pb.capacity()+
                             ", "+capabilities+
                             ", werr "+werr);
@@ -153,7 +156,7 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable {
     config.updateGraphicsConfiguration(getFactory(), ns, null);
   }
   
-  protected void destroyImpl() {
+  protected void destroyBitmap() {
     NativeSurface ns = getNativeSurface();
     if (ns.getSurfaceHandle() != 0) {
       // Must destroy bitmap and device context
@@ -165,11 +168,4 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable {
       ((SurfaceChangeable)ns).setSurfaceHandle(0);
     }
   }
-
-  protected void swapBuffersImpl() {
-    if(DEBUG) {
-        System.err.println("unhandled swapBuffersImpl() called for: "+this);
-    }
-  }
-
 }
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsDummyWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsDummyWGLDrawable.java
index 3d0cce7..0bd83b9 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsDummyWGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsDummyWGLDrawable.java
@@ -46,6 +46,8 @@ import javax.media.opengl.GLProfile;
 
 import javax.media.nativewindow.AbstractGraphicsScreen;
 import jogamp.nativewindow.windows.GDI;
+import jogamp.nativewindow.windows.GDIUtil;
+
 import javax.media.nativewindow.NativeSurface;
 import javax.media.opengl.GLCapabilities;
 import javax.media.opengl.GLException;
@@ -63,7 +65,7 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable {
         throw new GLException("WindowsDummyWGLDrawable: surface not ready (lockSurface)");
     }
     try {
-        WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+        WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration();
         config.updateGraphicsConfiguration(factory, ns, null);
         if (DEBUG) {
           System.err.println("!!! WindowsDummyWGLDrawable: "+config);
@@ -84,7 +86,7 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable {
     GLCapabilities caps = new GLCapabilities(glp);
     WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfigurationFactory.createDefaultGraphicsConfiguration(caps, absScreen);
     GDISurface ns = new GDISurface(cfg, windowHandle);
-    ns.setSize(width, height);
+    ns.surfaceSizeChanged(width, height);
     return new WindowsDummyWGLDrawable(factory, ns, handleWindowLifecycle);
   }
 
@@ -96,7 +98,7 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable {
   protected void destroyImpl() {
     if (handleHwndLifecycle && hwnd != 0) {
       GDI.ShowWindow(hwnd, GDI.SW_HIDE);
-      GDI.DestroyDummyWindow(hwnd);
+      GDIUtil.DestroyDummyWindow(hwnd);
       hwnd = 0;
     }
   }
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java
index c3588fd..f33dd21 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java
@@ -65,7 +65,7 @@ public class WindowsExternalWGLContext extends WindowsWGLContext {
       System.err.println(getThreadName() + ": !!! Created external OpenGL context " + toHexString(ctx) + " for " + this);
     }
     GLContextShareSet.contextCreated(this);
-    setGLFunctionAvailability(false, true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);  // use GL_VERSION
+    setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);  // use GL_VERSION
     getGLStateTracker().setEnabled(false); // external context usage can't track state in Java
   }
 
@@ -122,7 +122,7 @@ public class WindowsExternalWGLContext extends WindowsWGLContext {
     lastContext = null;
   }
 
-  protected void makeCurrentImpl(boolean newCreated) throws GLException {
+  protected void makeCurrentImpl() throws GLException {
   }
 
   protected void releaseImpl() throws GLException {
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLContext.java
index 97c63ea..0f61049 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLContext.java
@@ -42,6 +42,8 @@ package jogamp.opengl.windows.wgl;
 
 import javax.media.opengl.*;
 
+import jogamp.opengl.GLContextImpl;
+
 public class WindowsPbufferWGLContext extends WindowsWGLContext {
   // State for render-to-texture and render-to-texture-rectangle support
   private boolean rtt;       // render-to-texture?
@@ -86,9 +88,9 @@ public class WindowsPbufferWGLContext extends WindowsWGLContext {
     }
   }
 
-  protected void makeCurrentImpl(boolean newCreated) throws GLException {
-    super.makeCurrentImpl(newCreated);
-    if (newCreated) {
+  protected boolean createImpl(GLContextImpl shareWith) {
+    boolean res = super.createImpl(shareWith);
+    if(res) {
       GLCapabilitiesImmutable capabilities = drawable.getChosenGLCapabilities();
 
       // Initialize render-to-texture support if requested
@@ -135,6 +137,7 @@ public class WindowsPbufferWGLContext extends WindowsWGLContext {
         }
       }
     }
+    return res;
   }
 
   public int getFloatingPointMode() {
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java
index 83354a7..0988f3e 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java
@@ -41,15 +41,19 @@
 package jogamp.opengl.windows.wgl;
 
 import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.NativeWindowException;
 import javax.media.nativewindow.SurfaceChangeable;
 import javax.media.opengl.GL;
 import javax.media.opengl.GLContext;
 import javax.media.opengl.GLDrawableFactory;
 import javax.media.opengl.GLException;
-import javax.media.opengl.GLPbuffer;
+// import javax.media.opengl.GLPbuffer;
 import javax.media.opengl.GLProfile;
 
 import jogamp.nativewindow.windows.GDI;
+import jogamp.opengl.GLDrawableImpl;
+import jogamp.opengl.windows.wgl.WindowsWGLDrawableFactory.SharedResource;
+
 import javax.media.opengl.GLCapabilitiesImmutable;
 
 public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
@@ -58,27 +62,20 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
   private long buffer; // pbuffer handle
 
   private int floatMode;
-
-  protected WindowsPbufferWGLDrawable(GLDrawableFactory factory, NativeSurface target,
-                                      WindowsWGLDrawableFactory.SharedResource sharedResource) {
-    super(factory, target, true);
-
-    if (DEBUG) {
-        System.out.println("Pbuffer config: " + getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration());
-    }
-
-    createPbuffer(sharedResource);
-
-    if (DEBUG) {
-        System.err.println("Created pbuffer " + this);
-    }
+  
+  protected WindowsPbufferWGLDrawable(GLDrawableFactory factory, NativeSurface target) {
+    super(factory, target, false);
   }
 
+  protected void destroyImpl() {
+      setRealized(false);
+  }
+  
   protected void setRealizedImpl() {
     if(realized) {
-        throw new GLException("Recreation via setRealized not supported.");
+        createPbuffer();
     } else {
-        destroyImpl();
+        destroyPbuffer();
     }
   }
 
@@ -86,7 +83,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
     return new WindowsPbufferWGLContext(this, shareWith);
   }
 
-  protected void destroyImpl() {
+  protected void destroyPbuffer() {
     NativeSurface ns = getNativeSurface();
     if(0!=buffer) {
         WGLExt wglExt = cachedWGLExt;
@@ -118,146 +115,154 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
     return floatMode;
   }
 
-  protected void swapBuffersImpl() {
-    if(DEBUG) {
-        System.err.println("unhandled swapBuffersImpl() called for: "+this);
+  private void createPbuffer() {
+    WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) getNativeSurface().getGraphicsConfiguration();
+    SharedResource sharedResource = ((WindowsWGLDrawableFactory)factory).getOrCreateSharedResource(config.getScreen().getDevice());
+    NativeSurface sharedSurface = sharedResource.getDrawable().getNativeSurface();
+    if (NativeSurface.LOCK_SURFACE_NOT_READY >= sharedSurface.lockSurface()) {
+      throw new NativeWindowException("Could not lock (sharedSurface): "+this);
     }
-  }
-
-  private void createPbuffer(WindowsWGLDrawableFactory.SharedResource sharedResource) {
-    long parentHdc = sharedResource.getDrawable().getNativeSurface().getSurfaceHandle();
-    WGLExt wglExt = sharedResource.getContext().getWGLExt();
+    try {
+        long sharedHdc = sharedSurface.getSurfaceHandle();
+        WGLExt wglExt = sharedResource.getContext().getWGLExt();
+        
+        if (DEBUG) {
+            System.out.println("Pbuffer config: " + config);
+        }
     
-    int[]   iattributes = new int  [2*WindowsWGLGraphicsConfiguration.MAX_ATTRIBS];
-    float[] fattributes = new float[1];
-    int[]   floatModeTmp = new int[1];
-    int     niattribs   = 0;
-    int     width, height;
-
-    WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
-    GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable)config.getChosenCapabilities();
-    GLProfile glProfile = chosenCaps.getGLProfile();
-
-    if (DEBUG) {
-      System.out.println("Pbuffer parentHdc = " + toHexString(parentHdc));
-      System.out.println("Pbuffer chosenCaps: " + chosenCaps);
-    }
-
-    if(!WindowsWGLGraphicsConfiguration.GLCapabilities2AttribList(chosenCaps,
-                                    iattributes, sharedResource, -1, floatModeTmp)){
-      throw new GLException("Pbuffer-related extensions not supported");
-    }
-
-    floatMode = floatModeTmp[0];
-    boolean rtt      = chosenCaps.getPbufferRenderToTexture();
-    boolean rect     = chosenCaps.getPbufferRenderToTextureRectangle();
-    boolean useFloat = chosenCaps.getPbufferFloatingPointBuffers();
-    boolean ati      = false;
-
-    if (useFloat) {
-      ati = (floatMode == GLPbuffer.ATI_FLOAT);
-    }
-
-    int[] pformats = new int[WindowsWGLGraphicsConfiguration.MAX_PFORMATS];
-    int   nformats;
-    int[] nformatsTmp = new int[1];
-    if (!wglExt.wglChoosePixelFormatARB(parentHdc,
-                                        iattributes, 0,
-                                        fattributes, 0,
-                                        WindowsWGLGraphicsConfiguration.MAX_PFORMATS,
-                                        pformats, 0,
-                                        nformatsTmp, 0)) {
-      throw new GLException("pbuffer creation error: wglChoosePixelFormat() failed");
-    }
-    nformats = nformatsTmp[0];
-    if (nformats <= 0) {
-      throw new GLException("pbuffer creation error: Couldn't find a suitable pixel format");
-    }
-
-    if (DEBUG) {
-      System.err.println("" + nformats + " suitable pixel formats found");
-      for (int i = 0; i < nformats; i++) {
-        WGLGLCapabilities dbgCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedResource, parentHdc, pformats[i], glProfile, false, true);
-        System.err.println("pixel format " + pformats[i] + " (index " + i + "): " + dbgCaps);
-      }
-    }
-
-    int pfdid = 0;
-    long tmpBuffer = 0;
-    {
-        int whichFormat;
-        // Loop is a workaround for bugs in NVidia's recent drivers
-        for (whichFormat = 0; whichFormat < nformats; whichFormat++) {
-          int format = pformats[whichFormat];
-
-          // Create the p-buffer.
-          niattribs = 0;
-
-          if (rtt) {
-            iattributes[niattribs++]   = WGLExt.WGL_TEXTURE_FORMAT_ARB;
-            if (useFloat) {
-              iattributes[niattribs++] = WGLExt.WGL_TEXTURE_FLOAT_RGB_NV;
-            } else {
-              iattributes[niattribs++] = WGLExt.WGL_TEXTURE_RGBA_ARB;
+        int[]   iattributes = new int  [2*WindowsWGLGraphicsConfiguration.MAX_ATTRIBS];
+        float[] fattributes = new float[1];
+        int[]   floatModeTmp = new int[1];
+        int     niattribs   = 0;
+        int     width, height;
+    
+        GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable)config.getChosenCapabilities();
+        GLProfile glProfile = chosenCaps.getGLProfile();
+    
+        if (DEBUG) {
+          System.out.println("Pbuffer parentHdc = " + toHexString(sharedHdc));
+          System.out.println("Pbuffer chosenCaps: " + chosenCaps);
+        }
+    
+        if(!WindowsWGLGraphicsConfiguration.GLCapabilities2AttribList(chosenCaps,
+                                        iattributes, sharedResource, -1, floatModeTmp)){
+          throw new GLException("Pbuffer-related extensions not supported");
+        }
+    
+        floatMode = floatModeTmp[0];
+        boolean rtt      = chosenCaps.getPbufferRenderToTexture();
+        boolean rect     = chosenCaps.getPbufferRenderToTextureRectangle();
+        boolean useFloat = chosenCaps.getPbufferFloatingPointBuffers();
+        // boolean ati      = false;
+    
+        /**
+        if (useFloat) {
+          ati = (floatMode == GLPbuffer.ATI_FLOAT);
+        } */
+    
+        int[] pformats = new int[WindowsWGLGraphicsConfiguration.MAX_PFORMATS];
+        int   nformats;
+        int[] nformatsTmp = new int[1];
+        if (!wglExt.wglChoosePixelFormatARB(sharedHdc,
+                                            iattributes, 0,
+                                            fattributes, 0,
+                                            WindowsWGLGraphicsConfiguration.MAX_PFORMATS,
+                                            pformats, 0,
+                                            nformatsTmp, 0)) {
+          throw new GLException("pbuffer creation error: wglChoosePixelFormat() failed");
+        }
+        nformats = nformatsTmp[0];
+        if (nformats <= 0) {
+          throw new GLException("pbuffer creation error: Couldn't find a suitable pixel format");
+        }
+    
+        if (DEBUG) {
+          System.err.println("" + nformats + " suitable pixel formats found");
+          for (int i = 0; i < nformats; i++) {
+            WGLGLCapabilities dbgCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedResource, sharedHdc, pformats[i], glProfile, false, true);
+            System.err.println("pixel format " + pformats[i] + " (index " + i + "): " + dbgCaps);
+          }
+        }
+    
+        int pfdid = 0;
+        long tmpBuffer = 0;
+        {
+            int whichFormat;
+            // Loop is a workaround for bugs in NVidia's recent drivers
+            for (whichFormat = 0; whichFormat < nformats; whichFormat++) {
+              int format = pformats[whichFormat];
+    
+              // Create the p-buffer.
+              niattribs = 0;
+    
+              if (rtt) {
+                iattributes[niattribs++]   = WGLExt.WGL_TEXTURE_FORMAT_ARB;
+                if (useFloat) {
+                  iattributes[niattribs++] = WGLExt.WGL_TEXTURE_FLOAT_RGB_NV;
+                } else {
+                  iattributes[niattribs++] = WGLExt.WGL_TEXTURE_RGBA_ARB;
+                }
+    
+                iattributes[niattribs++] = WGLExt.WGL_TEXTURE_TARGET_ARB;
+                iattributes[niattribs++] = rect ? WGLExt.WGL_TEXTURE_RECTANGLE_NV : WGLExt.WGL_TEXTURE_2D_ARB;
+    
+                iattributes[niattribs++] = WGLExt.WGL_MIPMAP_TEXTURE_ARB;
+                iattributes[niattribs++] = GL.GL_FALSE;
+    
+                iattributes[niattribs++] = WGLExt.WGL_PBUFFER_LARGEST_ARB;
+                iattributes[niattribs++] = GL.GL_FALSE;
+              }
+    
+              iattributes[niattribs++] = 0;
+    
+              tmpBuffer = wglExt.wglCreatePbufferARB(sharedHdc, format, getWidth(), getHeight(), iattributes, 0);
+              if (tmpBuffer != 0) {
+                // Done
+                break;
+              }
             }
-
-            iattributes[niattribs++] = WGLExt.WGL_TEXTURE_TARGET_ARB;
-            iattributes[niattribs++] = rect ? WGLExt.WGL_TEXTURE_RECTANGLE_NV : WGLExt.WGL_TEXTURE_2D_ARB;
-
-            iattributes[niattribs++] = WGLExt.WGL_MIPMAP_TEXTURE_ARB;
-            iattributes[niattribs++] = GL.GL_FALSE;
-
-            iattributes[niattribs++] = WGLExt.WGL_PBUFFER_LARGEST_ARB;
-            iattributes[niattribs++] = GL.GL_FALSE;
+    
+            if (0 == tmpBuffer) {
+              throw new GLException("pbuffer creation error: wglCreatePbuffer() failed: tried " + nformats +
+                                    " pixel formats, last error was: " + wglGetLastError());
+            }
+            pfdid = pformats[whichFormat];
+        }
+    
+        // Get the device context.
+        long tmpHdc = wglExt.wglGetPbufferDCARB(tmpBuffer);
+        if (tmpHdc == 0) {
+          throw new GLException("pbuffer creation error: wglGetPbufferDC() failed");
+        }
+    
+        NativeSurface ns = getNativeSurface();
+        // Set up instance variables
+        buffer = tmpBuffer;
+        ((SurfaceChangeable)ns).setSurfaceHandle(tmpHdc);
+        cachedWGLExt = wglExt;   
+    
+        // Re-query chosen pixel format
+        {
+          WGLGLCapabilities newCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedResource, sharedHdc, pfdid, glProfile, false, true);
+          if(null == newCaps) {
+            throw new GLException("pbuffer creation error: unable to re-query chosen PFD ID: " + pfdid + ", hdc " + GLDrawableImpl.toHexString(tmpHdc));
           }
-
-          iattributes[niattribs++] = 0;
-
-          tmpBuffer = wglExt.wglCreatePbufferARB(parentHdc, format, getWidth(), getHeight(), iattributes, 0);
-          if (tmpBuffer != 0) {
-            // Done
-            break;
+          if(newCaps.isOnscreen() || !newCaps.isPBuffer()) {
+            throw new GLException("Error: Selected Onscreen Caps for PBuffer: "+newCaps);
           }
+          config.setCapsPFD(newCaps);
         }
-
-        if (0 == tmpBuffer) {
-          throw new GLException("pbuffer creation error: wglCreatePbuffer() failed: tried " + nformats +
-                                " pixel formats, last error was: " + wglGetLastError());
-        }
-        pfdid = pformats[whichFormat];
-    }
-
-    // Get the device context.
-    long tmpHdc = wglExt.wglGetPbufferDCARB(tmpBuffer);
-    if (tmpHdc == 0) {
-      throw new GLException("pbuffer creation error: wglGetPbufferDC() failed");
-    }
-
-    NativeSurface ns = getNativeSurface();
-    // Set up instance variables
-    buffer = tmpBuffer;
-    ((SurfaceChangeable)ns).setSurfaceHandle(tmpHdc);
-    cachedWGLExt = wglExt;   
-
-    // Re-query chosen pixel format
-    {
-      WGLGLCapabilities newCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedResource, parentHdc, pfdid, glProfile, false, true);
-      if(null == newCaps) {
-        throw new GLException("pbuffer creation error: unable to re-query chosen PFD ID: " + pfdid + ", hdc " + this.toHexString(tmpHdc));
-      }
-      if(newCaps.isOnscreen() || !newCaps.isPBuffer()) {
-        throw new GLException("Error: Selected Onscreen Caps for PBuffer: "+newCaps);
-      }
-      config.setCapsPFD(newCaps);
+    
+        // Determine the actual width and height we were able to create.
+        int[] tmp = new int[1];
+        wglExt.wglQueryPbufferARB( buffer, WGLExt.WGL_PBUFFER_WIDTH_ARB,  tmp, 0 );
+        width = tmp[0];
+        wglExt.wglQueryPbufferARB( buffer, WGLExt.WGL_PBUFFER_HEIGHT_ARB, tmp, 0 );
+        height = tmp[0];
+        ((SurfaceChangeable)ns).surfaceSizeChanged(width, height);
+    } finally {
+        sharedSurface.unlockSurface();
     }
-
-    // Determine the actual width and height we were able to create.
-    int[] tmp = new int[1];
-    wglExt.wglQueryPbufferARB( buffer, WGLExt.WGL_PBUFFER_WIDTH_ARB,  tmp, 0 );
-    width = tmp[0];
-    wglExt.wglQueryPbufferARB( buffer, WGLExt.WGL_PBUFFER_HEIGHT_ARB, tmp, 0 );
-    height = tmp[0];
-    ((SurfaceChangeable)ns).setSize(width, height);
   }
 
   private static String wglGetLastError() {
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
index b95b7ed..ff59e15 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
@@ -55,7 +55,6 @@ import com.jogamp.gluegen.runtime.ProcAddressTable;
 import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver;
 import jogamp.nativewindow.windows.GDI;
 import jogamp.opengl.GLContextImpl;
-import jogamp.opengl.GLContextShareSet;
 import jogamp.opengl.GLDrawableImpl;
 
 public class WindowsWGLContext extends GLContextImpl {
@@ -118,7 +117,7 @@ public class WindowsWGLContext extends GLContextImpl {
   public final boolean isGLReadDrawableAvailable() {
     if(!wglGLReadDrawableAvailableSet && null != getWGLExtProcAddressTable()) {
         WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory)drawable.getFactoryImpl();
-        AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+        AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration();
         AbstractGraphicsDevice device = config.getScreen().getDevice();
         switch( factory.isReadDrawableAvailable(device) ) {
             case  1:
@@ -244,12 +243,8 @@ public class WindowsWGLContext extends GLContextImpl {
             WGL.wglMakeCurrent(0, 0);
             WGL.wglDeleteContext(ctx);
             ctx = 0;
-        } else {
-            if (DEBUG) {
-                System.err.println(getThreadName() + ": createContextARBImpl: OK "+getGLVersion(major, minor, ctp, "@creation")+", share "+share+", direct "+direct);
-            }
-            // the following is issued by the caller 'GLContextImpl.createContextARB()'
-            // setGLFunctionAvailability(true, major, minor, ctp);
+        } else if (DEBUG) {
+            System.err.println(getThreadName() + ": createContextARBImpl: OK "+getGLVersion(major, minor, ctp, "@creation")+", share "+share+", direct "+direct);
         }
     } else if (DEBUG) {
         System.err.println(getThreadName() + ": createContextARBImpl: NO "+getGLVersion(major, minor, ctp, "@creation"));
@@ -261,20 +256,19 @@ public class WindowsWGLContext extends GLContextImpl {
    * Creates and initializes an appropriate OpenGL context. Should only be
    * called by {@link #makeCurrentImpl()}.
    */
-  protected boolean createImpl() {
-    WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory)drawable.getFactoryImpl();
-    AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+  protected boolean createImpl(GLContextImpl shareWith) {
+    AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration();
     AbstractGraphicsDevice device = config.getScreen().getDevice();
+    WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory)drawable.getFactoryImpl();
     WindowsWGLContext sharedContext = (WindowsWGLContext) factory.getOrCreateSharedContextImpl(device);
     GLCapabilitiesImmutable glCaps = drawable.getChosenGLCapabilities();
 
     isGLReadDrawableAvailable(); // trigger setup wglGLReadDrawableAvailable
 
     // Windows can set up sharing of display lists after creation time
-    WindowsWGLContext other = (WindowsWGLContext) GLContextShareSet.getShareContext(this);
     long share = 0;
-    if (other != null) {
-      share = other.getHandle();
+    if (null != shareWith) {
+      share = shareWith.getHandle();
       if (share == 0) {
         throw new GLException("GLContextShareSet returned an invalid OpenGL context");
       }
@@ -302,7 +296,7 @@ public class WindowsWGLContext extends GLContextImpl {
         if (!WGL.wglMakeCurrent(drawable.getHandle(), temp_ctx)) {
             throw new GLException("Error making temp context current: 0x" + toHexString(temp_ctx) + ", werr: "+GDI.GetLastError());
         }
-        setGLFunctionAvailability(true, true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);  // use GL_VERSION
+        setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);  // use GL_VERSION
         boolean isCreateContextAttribsARBAvailable = isFunctionAvailable("wglCreateContextAttribsARB");
         WGL.wglMakeCurrent(0, 0); // release temp context
 
@@ -338,7 +332,7 @@ public class WindowsWGLContext extends GLContextImpl {
         if(glCaps.getGLProfile().isGL3()) {
           WGL.wglMakeCurrent(0, 0);
           WGL.wglDeleteContext(temp_ctx);
-          throw new GLException("WindowsWGLContext.createContext failed, but context > GL2 requested "+getGLVersion()+", ");
+          throw new GLException("WindowsWGLContext.createContext ctx !ARB, context > GL2 requested "+getGLVersion());
         }
         if(DEBUG) {
           System.err.println("WindowsWGLContext.createContext failed, fall back to !ARB context "+getGLVersion());
@@ -351,29 +345,26 @@ public class WindowsWGLContext extends GLContextImpl {
             WGL.wglDeleteContext(contextHandle);
             throw new GLException("Error making old context current: 0x" + toHexString(contextHandle) + ", werr: " + GDI.GetLastError());
         }
+        if(0!=share) {
+            // Only utilize the classic GDI 'wglShareLists' shared context method 
+            // for traditional non ARB context.
+            if (!WGL.wglShareLists(share, contextHandle)) {
+                throw new GLException("wglShareLists(" + toHexString(share) +
+                                      ", " + toHexString(contextHandle) + ") failed: werr " + GDI.GetLastError());
+            }
+        }
         if (DEBUG) {
             System.err.println(getThreadName() + ": createImpl: OK (old) share "+share);
         }
     }
 
-    if(0!=share) {
-        if (!WGL.wglShareLists(share, contextHandle)) {
-            throw new GLException("wglShareLists(" + toHexString(share) +
-                                  ", " + toHexString(contextHandle) + ") failed: werr " + GDI.GetLastError());
-        }
-    }
     return true;
   }
   
-  protected void  makeCurrentImpl(boolean newCreated) throws GLException {
+  protected void  makeCurrentImpl() throws GLException {
     if (WGL.wglGetCurrentContext() != contextHandle) {
       if (!wglMakeContextCurrent(drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
         throw new GLException("Error making context current: 0x" + toHexString(contextHandle) + ", werr: " + GDI.GetLastError() + ", " + this);
-      } else {
-        if (DEBUG && newCreated) {
-          System.err.println(getThreadName() + ": wglMakeCurrent(hdc " + toHexString(drawable.getHandle()) +
-                             ", contextHandle " + toHexString(contextHandle) + ") succeeded");
-        }
       }
     }
   }
@@ -398,7 +389,7 @@ public class WindowsWGLContext extends GLContextImpl {
   }
 
   protected final void updateGLXProcAddressTable() {
-    final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+    final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration();
     final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice();
     final String key = "WGL-"+adevice.getUniqueID();
     if (DEBUG) {
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java
index 4ed9a00..2e0f6b8 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java
@@ -41,6 +41,7 @@
 package jogamp.opengl.windows.wgl;
 
 import java.security.AccessController;
+
 import javax.media.nativewindow.NativeSurface;
 import javax.media.opengl.GLDrawableFactory;
 import javax.media.opengl.GLException;
@@ -67,14 +68,15 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl {
     }
 
     NativeSurface ns = getNativeSurface();
-    WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+    WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration();
     config.updateGraphicsConfiguration(getFactory(), ns, null);
     if (DEBUG) {
       System.err.println("!!! WindowsWGLDrawable.setRealized(true): "+config);
     }
   }
 
-  protected void swapBuffersImpl() {
+  protected final void swapBuffersImpl() {
+    // single-buffer is already filtered out @ GLDrawableImpl#swapBuffers()        
     long startTime = 0;
     if (PROFILING) {
       startTime = System.currentTimeMillis();
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
index b7941c3..43c1624 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -42,7 +42,6 @@ package jogamp.opengl.windows.wgl;
 
 import java.nio.Buffer;
 import java.nio.ShortBuffer;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
@@ -62,6 +61,7 @@ import javax.media.opengl.GLContext;
 import javax.media.opengl.GLDrawable;
 import javax.media.opengl.GLException;
 import javax.media.opengl.GLProfile;
+import javax.media.opengl.GLProfile.ShutdownType;
 
 import com.jogamp.common.JogampRuntimeException;
 import com.jogamp.common.nio.PointerBuffer;
@@ -71,6 +71,7 @@ import com.jogamp.common.util.VersionNumber;
 
 import jogamp.nativewindow.WrappedSurface;
 import jogamp.nativewindow.windows.GDI;
+import jogamp.nativewindow.windows.GDIUtil;
 import jogamp.nativewindow.windows.GDISurface;
 import jogamp.nativewindow.windows.RegisteredClassFactory;
 import jogamp.opengl.DesktopGLDynamicLookupHelper;
@@ -80,60 +81,81 @@ import jogamp.opengl.GLDynamicLookupHelper;
 import jogamp.opengl.SharedResourceRunner;
 
 public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
-  private static final DesktopGLDynamicLookupHelper windowsWGLDynamicLookupHelper;
+  private static DesktopGLDynamicLookupHelper windowsWGLDynamicLookupHelper = null;
+  
+  public WindowsWGLDrawableFactory() {
+    super();
 
-  static {
-    DesktopGLDynamicLookupHelper tmp = null;
-    try {
-        tmp = new DesktopGLDynamicLookupHelper(new WindowsWGLDynamicLibraryBundleInfo());
-    } catch (GLException gle) {
-        if(DEBUG) {
-            gle.printStackTrace();
+    synchronized(WindowsWGLDrawableFactory.class) {
+        if(null==windowsWGLDynamicLookupHelper) {
+            DesktopGLDynamicLookupHelper tmp = null;
+            try {
+                tmp = new DesktopGLDynamicLookupHelper(new WindowsWGLDynamicLibraryBundleInfo());
+            } catch (GLException gle) {
+                if(DEBUG) {
+                    gle.printStackTrace();
+                }
+            }
+            windowsWGLDynamicLookupHelper = tmp;
+            if(null!=windowsWGLDynamicLookupHelper) {
+                WGL.getWGLProcAddressTable().reset(windowsWGLDynamicLookupHelper);
+            }               
         }
     }
-    windowsWGLDynamicLookupHelper = tmp;
+    
     if(null!=windowsWGLDynamicLookupHelper) {
-        WGL.getWGLProcAddressTable().reset(windowsWGLDynamicLookupHelper);
+        // Register our GraphicsConfigurationFactory implementations
+        // The act of constructing them causes them to be registered
+        WindowsWGLGraphicsConfigurationFactory.registerFactory();
+        if(GLProfile.isAWTAvailable()) {
+            try {
+              ReflectionUtil.callStaticMethod("jogamp.opengl.windows.wgl.awt.WindowsAWTWGLGraphicsConfigurationFactory", 
+                                              "registerFactory", null, null, getClass().getClassLoader());                
+            } catch (JogampRuntimeException jre) { /* n/a .. */ }
+        }
+    
+        defaultDevice = new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT);
+        sharedMap = new HashMap<String, SharedResourceRunner.Resource>();
+    
+        // Init shared resources off thread
+        // Will be released via ShutdownHook
+        sharedResourceRunner = new SharedResourceRunner(new SharedResourceImplementation());
+        sharedResourceRunner.start();
     }
   }
 
-  public GLDynamicLookupHelper getGLDynamicLookupHelper(int profile) {
-      return windowsWGLDynamicLookupHelper;
-  }
-
-  public WindowsWGLDrawableFactory() {
-    super();
-
-    // Register our GraphicsConfigurationFactory implementations
-    // The act of constructing them causes them to be registered
-    new WindowsWGLGraphicsConfigurationFactory();
-    if(GLProfile.isAWTAvailable()) {
-        try {
-          ReflectionUtil.createInstance("jogamp.opengl.windows.wgl.awt.WindowsAWTWGLGraphicsConfigurationFactory",
-                                        null, getClass().getClassLoader());
-        } catch (JogampRuntimeException jre) { /* n/a .. */ }
+  protected final void destroy(ShutdownType shutdownType) {
+    if(null != sharedResourceRunner) {
+        sharedResourceRunner.stop();
+        sharedResourceRunner = null;
     }
+    if(null != sharedMap) {
+        sharedMap.clear();
+        sharedMap = null;
+    }
+    defaultDevice = null;
+    /**
+     * Pulling away the native library may cause havoc ..
+     * 
+    if(ShutdownType.COMPLETE == shutdownType && null != windowsWGLDynamicLookupHelper) {
+        windowsWGLDynamicLookupHelper.destroy();
+        windowsWGLDynamicLookupHelper = null;
+    } */
+    
+    RegisteredClassFactory.shutdownSharedClasses();
+  }
 
-    defaultDevice = new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT);
-
-    // Init shared resources off thread
-    // Will be released via ShutdownHook
-    sharedResourceImpl = new SharedResourceImplementation();
-    sharedResourceRunner = new SharedResourceRunner(sharedResourceImpl);
-    sharedResourceThread = new Thread(sharedResourceRunner, Thread.currentThread().getName()+"-SharedResourceRunner");
-    sharedResourceThread.setDaemon(true); // Allow JVM to exit, even if this one is running
-    sharedResourceThread.start();
+  public GLDynamicLookupHelper getGLDynamicLookupHelper(int profile) {
+      return windowsWGLDynamicLookupHelper;
   }
 
-  WindowsGraphicsDevice defaultDevice;
-  SharedResourceImplementation sharedResourceImpl;
-  SharedResourceRunner sharedResourceRunner;
-  Thread sharedResourceThread;
-  HashMap/*<connection, SharedResource>*/ sharedMap = new HashMap();
+  private WindowsGraphicsDevice defaultDevice;
+  private SharedResourceRunner sharedResourceRunner;
+  private HashMap<String /*connection*/, SharedResourceRunner.Resource> sharedMap;
 
-  long processAffinityChanges = 0;
-  PointerBuffer procMask = PointerBuffer.allocateDirect(1);
-  PointerBuffer sysMask = PointerBuffer.allocateDirect(1);
+  private long processAffinityChanges = 0;
+  private PointerBuffer procMask = PointerBuffer.allocateDirect(1);
+  private PointerBuffer sysMask = PointerBuffer.allocateDirect(1);
 
   protected void enterThreadCriticalZone() {
     synchronized (sysMask) {
@@ -204,7 +226,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
           }
           
             if ( isVendorATI() ) {
-              final VersionNumber winVersion = new VersionNumber(Platform.getOSVersion(), ".");
+              final VersionNumber winVersion = Platform.getOSVersionNumber();
               final boolean isWinXPOrLess = winVersion.compareTo(winXPVersionNumber) <= 0;
               if(DEBUG) {
                   System.err.println("needsCurrenContext4ARBPFDQueries: "+winVersion+" <= "+winXPVersionNumber+" = "+isWinXPOrLess+" - "+Platform.getOSVersion());
@@ -251,15 +273,15 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
         }
         public SharedResourceRunner.Resource mapPut(String connection, SharedResourceRunner.Resource resource) {
             synchronized(sharedMap) {
-                return (SharedResourceRunner.Resource) sharedMap.put(connection, resource);
+                return sharedMap.put(connection, resource);
             }
         }
         public SharedResourceRunner.Resource mapGet(String connection) {
             synchronized(sharedMap) {
-                return (SharedResourceRunner.Resource) sharedMap.get(connection);
+                return sharedMap.get(connection);
             }
         }
-        public Collection/*<Resource>*/ mapValues() {
+        public Collection<SharedResourceRunner.Resource> mapValues() {
             synchronized(sharedMap) {
                 return sharedMap.values();
             }
@@ -270,15 +292,12 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
             sharedDevice.lock();
             try {
                 AbstractGraphicsScreen absScreen = new DefaultGraphicsScreen(sharedDevice, 0);
-                if (null == absScreen) {
-                    throw new GLException("Couldn't create shared screen for device: "+sharedDevice+", idx 0");
-                }
                 GLProfile glp = GLProfile.get(sharedDevice, GLProfile.GL_PROFILE_LIST_MIN_DESKTOP);
                 if (null == glp) {
                     throw new GLException("Couldn't get default GLProfile for device: "+sharedDevice);
                 }
                 final int f_dim = 64;
-                long hwnd = GDI.CreateDummyWindow(0, 0, f_dim, f_dim);
+                long hwnd = GDIUtil.CreateDummyWindow(0, 0, f_dim, f_dim);
                 WindowsDummyWGLDrawable sharedDrawable = WindowsDummyWGLDrawable.create(WindowsWGLDrawableFactory.this, glp, absScreen, hwnd, f_dim, f_dim, true);
                 if (null == sharedDrawable) {
                     throw new GLException("Couldn't create shared drawable for screen: "+absScreen+", "+glp);
@@ -373,10 +392,21 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
   final static String WGL_ARB_make_current_read = "WGL_ARB_make_current_read";
   final static String wglMakeContextCurrent = "wglMakeContextCurrent";
 
-  public final boolean getWasSharedContextCreated(AbstractGraphicsDevice device) {
-    SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
-    if(null!=sr) {
-      return null != sr.getContext();
+  protected final Thread getSharedResourceThread() {
+    return sharedResourceRunner.start();
+  }
+  
+  protected final boolean createSharedResource(AbstractGraphicsDevice device) {
+    try {
+        SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
+        if(null!=sr) {
+          return null != sr.getContext();
+        }
+    } catch (GLException gle) {
+        if(DEBUG) {
+            System.err.println("Catched Exception while WindowsWGL Shared Resource initialization");
+            gle.printStackTrace();
+        }
     }
     return false;
   }
@@ -409,11 +439,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
     return (SharedResource) sharedResourceRunner.getOrCreateShared(device);
   }
 
-  protected final void shutdownInstance() {
-    sharedResourceRunner.releaseAndWait();
-    RegisteredClassFactory.shutdownSharedClasses();
-  }
-
   protected List<GLCapabilitiesImmutable> getAvailableCapabilitiesImpl(AbstractGraphicsDevice device) {
     return WindowsWGLGraphicsConfigurationFactory.getAvailableCapabilities(this, device);
   }
@@ -429,40 +454,39 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
     if (target == null) {
       throw new IllegalArgumentException("Null target");
     }
-    AbstractGraphicsConfiguration config = target.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+    AbstractGraphicsConfiguration config = target.getGraphicsConfiguration();
     GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
     if(!chosenCaps.isPBuffer()) {
         return new WindowsBitmapWGLDrawable(this, target);
     }
 
     // PBuffer GLDrawable Creation
+    GLDrawableImpl pbufferDrawable;
     final AbstractGraphicsDevice device = config.getScreen().getDevice();
 
+    /**
+     * Similar to ATI Bug https://bugzilla.mozilla.org/show_bug.cgi?id=486277,
+     * we need to have a context current on the same Display to create a PBuffer.
+     */
     final SharedResource sr = (SharedResource) sharedResourceRunner.getOrCreateShared(device);
-    if(null==sr) {
-        throw new IllegalArgumentException("No shared resource for "+device);
-    }
-    final List returnList = new ArrayList();
-    Runnable r = new Runnable() {
-        public void run() {
-          GLContext lastContext = GLContext.getCurrent();
-          if (lastContext != null) {
+    if(null!=sr) {
+        GLContext lastContext = GLContext.getCurrent();
+        if (lastContext != null) {
             lastContext.release();
-          }
-          sr.context.makeCurrent();
-          try {
-            GLDrawableImpl pbufferDrawable = new WindowsPbufferWGLDrawable(WindowsWGLDrawableFactory.this, target, sr);
-            returnList.add(pbufferDrawable);
-          } finally {
+        }
+        sr.context.makeCurrent();
+        try {
+            pbufferDrawable = new WindowsPbufferWGLDrawable(WindowsWGLDrawableFactory.this, target);
+        } finally {
             sr.context.release();
             if (lastContext != null) {
               lastContext.makeCurrent();
             }
-          }
         }
-      };
-    maybeDoSingleThreadedWorkaround(r);
-    return (GLDrawableImpl) returnList.get(0);
+    } else {
+        pbufferDrawable = new WindowsPbufferWGLDrawable(WindowsWGLDrawableFactory.this, target);
+    }
+    return pbufferDrawable;
   }
 
   /**
@@ -489,7 +513,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
     AbstractGraphicsScreen screen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS);
     WrappedSurface ns = new WrappedSurface(WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
                                      capsChosen, capsRequested, chooser, screen) );
-    ns.setSize(width, height);
+    ns.surfaceSizeChanged(width, height);
     return ns;
   }
  
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
index 9899065..2fcded8 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
@@ -37,7 +37,6 @@ import java.util.ArrayList;
 import java.util.List;
 
 import javax.media.nativewindow.AbstractGraphicsScreen;
-import javax.media.nativewindow.DefaultGraphicsConfiguration;
 import javax.media.nativewindow.NativeSurface;
 import javax.media.nativewindow.AbstractGraphicsDevice;
 import javax.media.opengl.GL;
@@ -48,13 +47,14 @@ import javax.media.opengl.GLException;
 import javax.media.opengl.GLPbuffer;
 import javax.media.opengl.GLProfile;
 
+import jogamp.nativewindow.MutableGraphicsConfiguration;
 import jogamp.nativewindow.windows.DWM_BLURBEHIND;
 import jogamp.nativewindow.windows.GDI;
 import jogamp.nativewindow.windows.MARGINS;
 import jogamp.nativewindow.windows.PIXELFORMATDESCRIPTOR;
 import jogamp.opengl.GLGraphicsConfigurationUtil;
 
-public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguration implements Cloneable {
+public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable {
     // Keep this under the same debug flag as the drawable factory for convenience
     protected static final boolean DEBUG = jogamp.opengl.Debug.debug("GraphicsConfiguration");
     
@@ -149,7 +149,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
      * @see #isDetermined()
      */
     public final void preselectGraphicsConfiguration(GLDrawableFactory factory, int[] pfdIDs) {
-        AbstractGraphicsDevice device = getNativeGraphicsConfiguration().getScreen().getDevice();
+        AbstractGraphicsDevice device = getScreen().getDevice();
         WindowsWGLGraphicsConfigurationFactory.preselectGraphicsConfiguration(chooser, factory, device, this, pfdIDs);
     }
 
@@ -733,10 +733,10 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
 
   static PIXELFORMATDESCRIPTOR createPixelFormatDescriptor(long hdc, int pfdID) {
     PIXELFORMATDESCRIPTOR pfd = PIXELFORMATDESCRIPTOR.create();
-    pfd.setNSize((short) pfd.size());
+    pfd.setNSize((short) PIXELFORMATDESCRIPTOR.size());
     pfd.setNVersion((short) 1);
     if(0 != hdc && 1 <= pfdID) {
-        if (GDI.DescribePixelFormat(hdc, pfdID, pfd.size(), pfd) == 0) {
+        if (GDI.DescribePixelFormat(hdc, pfdID, PIXELFORMATDESCRIPTOR.size(), pfd) == 0) {
             // Accelerated pixel formats that are non displayable
             if(DEBUG) {
                 System.err.println("Info: Non displayable pixel format " + pfdID + " of device context: error code " + GDI.GetLastError());
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
index a485f8c..edcaa4a 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
@@ -67,8 +67,10 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
     protected static final boolean DEBUG = jogamp.opengl.Debug.debug("GraphicsConfiguration");
     static WGLGLCapabilities.PfdIDComparator PfdIDComparator = new WGLGLCapabilities.PfdIDComparator();
 
-    WindowsWGLGraphicsConfigurationFactory() {
-        GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.windows.WindowsGraphicsDevice.class, this);
+    static void registerFactory() {
+        GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.windows.WindowsGraphicsDevice.class, new WindowsWGLGraphicsConfigurationFactory());
+    }
+    private WindowsWGLGraphicsConfigurationFactory() {
     }
 
     protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
@@ -189,7 +191,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
             if (0 == hdc) {
                 throw new GLException("Error: HDC is null");
             }
-            WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) ns.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+            WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) ns.getGraphicsConfiguration();
 
             if( !config.isExternal() ) {
                 if( !config.isDetermined() ) {
@@ -236,7 +238,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
         }
 
         if(NativeSurface.LOCK_SURFACE_NOT_READY >= sharedDrawable.lockSurface()) {
-            throw new GLException("Surface not ready (lockSurface)");
+            throw new GLException("Shared Surface not ready (lockSurface): "+device+" -> "+sharedDrawable);
         }
         try {
             long hdc = sharedDrawable.getHandle();
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
index 1f09180..0f9786f 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
@@ -62,8 +62,10 @@ import javax.media.opengl.GLDrawableFactory;
 public class WindowsAWTWGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFactory {
     protected static final boolean DEBUG = jogamp.opengl.Debug.debug("GraphicsConfiguration");
 
-    public WindowsAWTWGLGraphicsConfigurationFactory() {
-        GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.awt.AWTGraphicsDevice.class, this);
+    public static void registerFactory() {
+        GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.awt.AWTGraphicsDevice.class, new WindowsAWTWGLGraphicsConfigurationFactory());
+    }
+    private WindowsAWTWGLGraphicsConfigurationFactory() {        
     }
 
     protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
@@ -76,7 +78,7 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GLGraphicsConfigu
         }
 
         if(null==absScreen) {
-            absScreen = AWTGraphicsScreen.createScreenDevice(-1, AbstractGraphicsDevice.DEFAULT_UNIT);
+            absScreen = AWTGraphicsScreen.createDefault();
             if(DEBUG) {
                 System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: creating default device: "+absScreen);
             }
@@ -122,12 +124,17 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GLGraphicsConfigu
         // otherwise no hardware accelerated PFD could be achieved.
         //   - preselect with no constrains
         //   - try to create dedicated GC
-        winConfig.preselectGraphicsConfiguration(drawableFactory, null);
-        if ( 1 <= winConfig.getPixelFormatID() ) {
-            chosenGC = Win32SunJDKReflection.graphicsConfigurationGet(device, winConfig.getPixelFormatID());
-            if(DEBUG) {
-                System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: Found new AWT PFD ID "+winConfig.getPixelFormatID()+" -> "+winConfig);
+        try {
+            winConfig.preselectGraphicsConfiguration(drawableFactory, null);
+            if ( 1 <= winConfig.getPixelFormatID() ) {
+                chosenGC = Win32SunJDKReflection.graphicsConfigurationGet(device, winConfig.getPixelFormatID());
+                if(DEBUG) {
+                    System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: Found new AWT PFD ID "+winConfig.getPixelFormatID()+" -> "+winConfig);
+                }
             }
+        } catch (GLException gle0) {
+            gle0.printStackTrace();
+            // go on ..
         }
 
         if( null == chosenGC ) {
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java b/src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java
index e95c802..33e85dd 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
  * 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -32,14 +33,40 @@
 
 package jogamp.opengl.x11.glx;
 
-import javax.media.opengl.*;
+import javax.media.nativewindow.x11.X11GraphicsDevice;
+import javax.media.opengl.GLException;
 
+import jogamp.opengl.Debug;
+
+import com.jogamp.common.util.VersionNumber;
 
 public class GLXUtil {
-    public static String getExtension(long display) {
-        return GLX.glXGetClientString(display, GLX.GLX_EXTENSIONS);
-    }
+    public static final boolean DEBUG = Debug.debug("GLXUtil");
+    
+    public static VersionNumber getGLXServerVersionNumber(long display) {
+        int[] major = new int[1];
+        int[] minor = new int[1];
+        
+        if (!GLX.glXQueryVersion(display, major, 0, minor, 0)) {
+          throw new GLException("glXQueryVersion failed");
+        }
 
+        // Work around bugs in ATI's Linux drivers where they report they
+        // only implement GLX version 1.2 on the server side
+        if (major[0] == 1 && minor[0] == 2) {
+          String str = GLX.glXGetClientString(display, GLX.GLX_VERSION);
+          try {
+              // e.g. "1.3"
+              major[0] = Integer.valueOf(str.substring(0, 1)).intValue();
+              minor[0] = Integer.valueOf(str.substring(2, 3)).intValue();
+          } catch (Exception e) {
+              major[0] = 1;
+              minor[0] = 2;
+          }
+        }                
+        return new VersionNumber(major[0], minor[0], 0);
+    }
+    
     public static boolean isMultisampleAvailable(String extensions) {
         if (extensions != null) {
             return (extensions.indexOf("GLX_ARB_multisample") >= 0);
@@ -47,16 +74,6 @@ public class GLXUtil {
         return false;
     }
 
-    public static boolean isMultisampleAvailable(long display) {
-        return isMultisampleAvailable(getExtension(display));
-    }
-
-    /** Workaround for apparent issue with ATI's proprietary drivers
-        where direct contexts still send GLX tokens for GL calls */
-    public static String getVendorName(long display) {
-        return GLX.glXGetClientString(display, GLX.GLX_VENDOR);
-    }
-
     public static boolean isVendorNVIDIA(String vendor) {
         return vendor != null && vendor.startsWith("NVIDIA") ;
     }
@@ -65,38 +82,48 @@ public class GLXUtil {
         return vendor != null && vendor.startsWith("ATI") ;
     }
 
-    public static boolean isVendorATI(long display) {
-        return isVendorATI(getVendorName(display));
+    public static boolean isClientMultisampleAvailable() {
+        return clientMultisampleAvailable;
     }
-
-    public static boolean isVendorNVIDIA(long display) {
-        return isVendorNVIDIA(getVendorName(display));
+    public static String getClientVendorName() {
+        return clientVendorName;
     }
-
-    public static void getGLXVersion(long display, int major[], int minor[]) { 
-        if(0 == display) {
-            throw new GLException("null display handle");
+    public static VersionNumber getClientVersionNumber() {
+        return clientVersionNumber;
+    }    
+    public static synchronized boolean initGLXClientDataSingleton(X11GraphicsDevice x11Device) { 
+        if(null != clientVendorName) {
+            return false;
         }
-        if(major.length<1||minor.length<1) {
-            throw new GLException("passed int arrays size is not >= 1");
+        if(DEBUG) {
+            System.err.println("initGLXClientDataSingleton: "+x11Device);
+            Thread.dumpStack();
         }
-
-        if (!GLX.glXQueryVersion(display, major, 0, minor, 0)) {
-          throw new GLException("glXQueryVersion failed");
+        if(null == x11Device) {
+            throw new GLException("null X11GraphicsDevice");
         }
-
-        // Work around bugs in ATI's Linux drivers where they report they
-        // only implement GLX version 1.2 on the server side
-        if (major[0] == 1 && minor[0] == 2) {
-          String str = GLX.glXGetClientString(display, GLX.GLX_VERSION);
-          try {
+        if(0 == x11Device.getHandle()) {
+            throw new GLException("null X11GraphicsDevice display handle");
+        }
+        
+        clientMultisampleAvailable = isMultisampleAvailable(GLX.glXGetClientString(x11Device.getHandle(), GLX.GLX_EXTENSIONS));
+        clientVendorName = GLX.glXGetClientString(x11Device.getHandle(), GLX.GLX_VENDOR);
+        
+        int[] major = new int[1];
+        int[] minor = new int[1];
+        final String str = GLX.glXGetClientString(x11Device.getHandle(), GLX.GLX_VERSION);
+        try {
               // e.g. "1.3"
               major[0] = Integer.valueOf(str.substring(0, 1)).intValue();
               minor[0] = Integer.valueOf(str.substring(2, 3)).intValue();
-          } catch (Exception e) {
+        } catch (Exception e) {
               major[0] = 1;
               minor[0] = 2;
-          }
         }
+        clientVersionNumber = new VersionNumber(major[0], minor[0], 0);
+        return true;
     }
+    private static boolean clientMultisampleAvailable = false;
+    private static String clientVendorName = null;
+    private static VersionNumber clientVersionNumber = null;
 }
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11DummyGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11DummyGLXDrawable.java
index 68bdb4a..6be74c0 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11DummyGLXDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11DummyGLXDrawable.java
@@ -50,16 +50,16 @@ public class X11DummyGLXDrawable extends X11OnscreenGLXDrawable {
     this.realized = true;
 
     WrappedSurface ns = (WrappedSurface) getNativeSurface();
-    X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)ns.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+    X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)ns.getGraphicsConfiguration();
 
     X11GraphicsDevice device = (X11GraphicsDevice) screen.getDevice();
     long dpy = device.getHandle();
     int scrn = screen.getIndex();
     long visualID = config.getVisualID();
 
-    dummyWindow = X11Util.CreateDummyWindow(dpy, scrn, visualID, f_dim, f_dim);
+    dummyWindow = X11Lib.CreateDummyWindow(dpy, scrn, visualID, f_dim, f_dim);
     ns.setSurfaceHandle( dummyWindow );
-    ns.setSize(f_dim, f_dim);
+    ns.surfaceSizeChanged(f_dim, f_dim);
 
     updateHandle();
   }
@@ -83,8 +83,8 @@ public class X11DummyGLXDrawable extends X11OnscreenGLXDrawable {
   protected void destroyImpl() {
     if(0!=dummyWindow) {
         destroyHandle();
-        X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
-        X11Util.DestroyDummyWindow(config.getScreen().getDevice().getHandle(), dummyWindow);
+        X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeSurface().getGraphicsConfiguration();
+        X11Lib.DestroyDummyWindow(config.getScreen().getDevice().getHandle(), dummyWindow);
     }
   }
 }
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java
index d0d9929..4a949ea 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java
@@ -53,7 +53,7 @@ public class X11ExternalGLXContext extends X11GLXContext {
     super(drawable, null);
     this.contextHandle = ctx;
     GLContextShareSet.contextCreated(this);
-    setGLFunctionAvailability(false, true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
+    setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
     getGLStateTracker().setEnabled(false); // external context usage can't track state in Java
   }
 
@@ -72,7 +72,7 @@ public class X11ExternalGLXContext extends X11GLXContext {
     }
     int[] val = new int[1];
     GLX.glXQueryContext(display, ctx, GLX.GLX_SCREEN, val, 0);
-    X11GraphicsScreen x11Screen = (X11GraphicsScreen) X11GraphicsScreen.createScreenDevice(display, val[0]);
+    X11GraphicsScreen x11Screen = (X11GraphicsScreen) X11GraphicsScreen.createScreenDevice(display, val[0], false);
 
     GLX.glXQueryContext(display, ctx, GLX.GLX_FBCONFIG_ID, val, 0);
     X11GLXGraphicsConfiguration cfg = null;
@@ -95,7 +95,7 @@ public class X11ExternalGLXContext extends X11GLXContext {
     return new X11ExternalGLXContext(new Drawable(factory, ns), ctx);
   }
 
-  protected boolean createImpl() {
+  protected boolean createImpl(GLContextImpl shareWith) {
       return true;
   }
 
@@ -116,7 +116,7 @@ public class X11ExternalGLXContext extends X11GLXContext {
     lastContext = null;
   }
 
-  protected void makeCurrentImpl(boolean newCreated) throws GLException {
+  protected void makeCurrentImpl() throws GLException {
   }
 
   protected void releaseImpl() throws GLException {
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java
index eb286cd..ca30fde 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java
@@ -66,7 +66,7 @@ public class X11ExternalGLXDrawable extends X11GLXDrawable {
     }
     int[] val = new int[1];
     GLX.glXQueryContext(display, context, GLX.GLX_SCREEN, val, 0);
-    X11GraphicsScreen x11Screen = (X11GraphicsScreen) X11GraphicsScreen.createScreenDevice(display, val[0]);
+    X11GraphicsScreen x11Screen = (X11GraphicsScreen) X11GraphicsScreen.createScreenDevice(display, val[0], false);
 
     GLX.glXQueryContext(display, context, GLX.GLX_FBCONFIG_ID, val, 0);
     X11GLXGraphicsConfiguration cfg = X11GLXGraphicsConfiguration.create(glp, x11Screen, val[0]);
@@ -85,7 +85,7 @@ public class X11ExternalGLXDrawable extends X11GLXDrawable {
     }
     WrappedSurface ns = new WrappedSurface(cfg);
     ns.setSurfaceHandle(drawable);
-    ns.setSize(w, h);
+    ns.surfaceSizeChanged(w, h);
     return new X11ExternalGLXDrawable(factory, ns);
   }
 
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
index 26ad41f..c860019 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
@@ -40,28 +40,33 @@
 
 package jogamp.opengl.x11.glx;
 
-import java.nio.*;
-import java.util.*;
-
-import javax.media.opengl.*;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.x11.X11GraphicsDevice;
+import java.nio.ByteBuffer;
+import java.nio.IntBuffer;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
+
+import jogamp.nativewindow.x11.X11Lib;
+import jogamp.nativewindow.x11.X11Util;
+import jogamp.opengl.GLContextImpl;
+import jogamp.opengl.GLDrawableImpl;
 
 import com.jogamp.common.nio.Buffers;
-import com.jogamp.common.util.VersionNumber;
-import jogamp.opengl.*;
 import com.jogamp.gluegen.runtime.ProcAddressTable;
 import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver;
-import jogamp.nativewindow.x11.X11Util;
 
 public abstract class X11GLXContext extends GLContextImpl {
   protected static final boolean TRACE_CONTEXT_CURRENT = false; // true;
 
   private static final Map<String, String> functionNameMap;
   private static final Map<String, String> extensionNameMap;
-  private VersionNumber glXVersion;
-  private boolean glXVersionOneOneCapable;
-  private boolean glXVersionOneThreeCapable;
   private GLXExt _glXExt;
   // Table that holds the addresses of the native C-language entry points for
   // GLX extension functions.
@@ -91,9 +96,6 @@ public abstract class X11GLXContext extends GLContextImpl {
   
   @Override
   protected void resetStates() {
-    glXVersion = null;
-    glXVersionOneOneCapable = false;
-    glXVersionOneThreeCapable = false;
     // no inner state _glXExt=null;
     glXExtProcAddressTable = null;
     hasSwapIntervalSGI = 0;
@@ -125,25 +127,10 @@ public abstract class X11GLXContext extends GLContextImpl {
 
   protected Map<String, String> getExtensionNameMap() { return extensionNameMap; }
 
-  private final void initGLXVersion() {
-    if(null == glXVersion) {
-        X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
-        X11GraphicsDevice device = (X11GraphicsDevice) config.getScreen().getDevice();
-
-        glXVersion = X11GLXDrawableFactory.getGLXVersion(device);
-        glXVersionOneOneCapable   = ( null != glXVersion ) ? glXVersion.compareTo(GLDrawableFactoryImpl.versionOneOne) >= 0 : false ;
-        glXVersionOneThreeCapable = ( null != glXVersion ) ? glXVersion.compareTo(GLDrawableFactoryImpl.versionOneThree) >= 0 : false ;
-    }      
-  }
-  public final boolean isGLXVersionGreaterEqualOneOne() {
-    initGLXVersion();
-    return glXVersionOneOneCapable;
+  protected final boolean isGLXVersionGreaterEqualOneThree() {
+    return ((X11GLXDrawableFactory)drawable.getFactoryImpl()).isGLXVersionGreaterEqualOneThree(drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice());      
   }
-  public final boolean isGLXVersionGreaterEqualOneThree() {
-    initGLXVersion();
-    return glXVersionOneThreeCapable;
-  }
-
+  
   public final boolean isGLReadDrawableAvailable() {
     return isGLXVersionGreaterEqualOneThree();
   }
@@ -154,10 +141,10 @@ public abstract class X11GLXContext extends GLContextImpl {
     try {
         if(TRACE_CONTEXT_CURRENT) {
             Throwable t = new Throwable(Thread.currentThread()+" - glXMakeContextCurrent("+toHexString(dpy)+", "+
-                    toHexString(writeDrawable)+", "+toHexString(readDrawable)+", "+toHexString(ctx)+") - GLX >= 1.3 "+ glXVersionOneThreeCapable);
+                    toHexString(writeDrawable)+", "+toHexString(readDrawable)+", "+toHexString(ctx)+") - GLX >= 1.3 "+ isGLXVersionGreaterEqualOneThree());
             t.printStackTrace();
         }
-        if ( glXVersionOneThreeCapable ) {
+        if ( isGLXVersionGreaterEqualOneThree() ) {
             res = GLX.glXMakeContextCurrent(dpy, writeDrawable, readDrawable, ctx);
         } else if ( writeDrawable == readDrawable ) {
             res = GLX.glXMakeCurrent(dpy, writeDrawable, ctx);
@@ -179,7 +166,7 @@ public abstract class X11GLXContext extends GLContextImpl {
   }
 
   protected void destroyContextARBImpl(long ctx) {
-    X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+    X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration();
     long display = config.getScreen().getDevice().getHandle();
 
     glXMakeContextCurrent(display, 0, 0, 0);
@@ -239,16 +226,16 @@ public abstract class X11GLXContext extends GLContextImpl {
         attribs.put(ctx_arb_attribs_idx_flags + 1, flags);
     }
 
-    X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+    X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration();
     AbstractGraphicsDevice device = config.getScreen().getDevice();
     long display = device.getHandle();
 
     try {
         // critical path, a remote display might not support this command,
         // hence we need to catch the X11 Error within this block.
-        X11Util.XSync(display, false);
+        X11Lib.XSync(display, false);
         ctx = _glXExt.glXCreateContextAttribsARB(display, config.getFBConfig(), share, direct, attribs);
-        X11Util.XSync(display, false);
+        X11Lib.XSync(display, false);
     } catch (RuntimeException re) {
         if(DEBUG) {
           Throwable t = new Throwable("Info: X11GLXContext.createContextARBImpl glXCreateContextAttribsARB failed with "+getGLVersion(major, minor, ctp, "@creation"), re);
@@ -264,12 +251,8 @@ public abstract class X11GLXContext extends GLContextImpl {
             glXMakeContextCurrent(display, 0, 0, 0);
             GLX.glXDestroyContext(display, ctx);
             ctx = 0;
-        } else {
-            if (DEBUG) {
-                System.err.println(getThreadName() + ": createContextARBImpl: OK "+getGLVersion(major, minor, ctp, "@creation")+", share "+share+", direct "+direct);
-            }
-            // the following is issued by the caller 'GLContextImpl.createContextARB()'
-            // setGLFunctionAvailability(true, major, minor, ctp);
+        } else if (DEBUG) {
+            System.err.println(getThreadName() + ": createContextARBImpl: OK "+getGLVersion(major, minor, ctp, "@creation")+", share "+share+", direct "+direct);
         }
     } else if (DEBUG) {
         System.err.println(getThreadName() + ": createContextARBImpl: NO "+getGLVersion(major, minor, ctp, "@creation"));
@@ -278,32 +261,29 @@ public abstract class X11GLXContext extends GLContextImpl {
     return ctx;
   }
 
-  protected boolean createImpl() {
+  protected boolean createImpl(GLContextImpl shareWith) {
       // covers the whole context creation loop incl createContextARBImpl and destroyContextARBImpl
       X11Util.setX11ErrorHandler(true, true);
       try {
-          return createImplRaw();
+          return createImplRaw(shareWith);
       } finally {
           X11Util.setX11ErrorHandler(false, false);
       }
   }
 
-  private boolean createImplRaw() {
+  private boolean createImplRaw(GLContextImpl shareWith) {
     boolean direct = true; // try direct always
     isDirect = false; // fall back
 
     X11GLXDrawableFactory factory = (X11GLXDrawableFactory)drawable.getFactoryImpl();
-    X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+    X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration();
     AbstractGraphicsDevice device = config.getScreen().getDevice();
     X11GLXContext sharedContext = (X11GLXContext) factory.getOrCreateSharedContextImpl(device);
     long display = device.getHandle();
 
-    isGLReadDrawableAvailable(); // trigger setup glXVersionOneThreeCapable
-
-    X11GLXContext other = (X11GLXContext) GLContextShareSet.getShareContext(this);
     long share = 0;
-    if (other != null) {
-      share = other.getHandle();
+    if (shareWith != null) {
+      share = shareWith.getHandle();
       if (share == 0) {
         throw new GLException("GLContextShareSet returned an invalid OpenGL context");
       }
@@ -325,7 +305,7 @@ public abstract class X11GLXContext extends GLContextImpl {
         if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
           throw new GLException("Error making temp context(0) current: display "+toHexString(display)+", context "+toHexString(contextHandle)+", drawable "+drawable);
         }
-        setGLFunctionAvailability(true, true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY); // use GL_VERSION
+        setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY); // use GL_VERSION
         isDirect = GLX.glXIsDirect(display, contextHandle);
         if (DEBUG) {
             System.err.println(getThreadName() + ": createContextImpl: OK (old-1) share "+share+", direct "+isDirect+"/"+direct);
@@ -355,7 +335,7 @@ public abstract class X11GLXContext extends GLContextImpl {
         if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), temp_ctx)) {
           throw new GLException("Error making temp context(1) current: display "+toHexString(display)+", context "+toHexString(temp_ctx)+", drawable "+drawable);
         }
-        setGLFunctionAvailability(true, true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY); // use GL_VERSION
+        setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY); // use GL_VERSION
         boolean isCreateContextAttribsARBAvailable = isFunctionAvailable("glXCreateContextAttribsARB");
         glXMakeContextCurrent(display, 0, 0, 0); // release temp context
 
@@ -390,7 +370,7 @@ public abstract class X11GLXContext extends GLContextImpl {
         if(glp.isGL3()) {
           glXMakeContextCurrent(display, 0, 0, 0);
           GLX.glXDestroyContext(display, temp_ctx);
-          throw new GLException("X11GLXContext.createContextImpl failed, but context > GL2 requested "+getGLVersion()+", ");
+          throw new GLException("X11GLXContext.createContextImpl ctx !ARB, context > GL2 requested - requested: "+glp+", current: "+getGLVersion()+", ");
         }
         if(DEBUG) {
           System.err.println("X11GLXContext.createContextImpl failed, fall back to !ARB context "+getGLVersion());
@@ -414,7 +394,7 @@ public abstract class X11GLXContext extends GLContextImpl {
     return true;
   }
 
-  protected void makeCurrentImpl(boolean newCreated) throws GLException {
+  protected void makeCurrentImpl() throws GLException {
     long dpy = drawable.getNativeSurface().getDisplayHandle();
 
     if (GLX.glXGetCurrentContext() != contextHandle) {
@@ -426,13 +406,6 @@ public abstract class X11GLXContext extends GLContextImpl {
         } finally {
             X11Util.setX11ErrorHandler(false, false);
         }
-        if (DEBUG && newCreated) {
-            System.err.println(getThreadName() + ": glXMakeCurrent(display " + 
-                               toHexString(dpy)+
-                               ", drawable " + toHexString(drawable.getHandle()) +
-                               ", drawableRead " + toHexString(drawableRead.getHandle()) +
-                               ", context " + toHexString(contextHandle) + ") succeeded");
-        }
     }
   }
 
@@ -449,17 +422,7 @@ public abstract class X11GLXContext extends GLContextImpl {
   }
 
   protected void destroyImpl() throws GLException {
-    long display = drawable.getNativeSurface().getDisplayHandle();
-    if (DEBUG) {
-      System.err.println("glXDestroyContext(dpy " +
-                         toHexString(display)+
-                         ", ctx " +
-                         toHexString(contextHandle) + ")");
-    }
-    GLX.glXDestroyContext(display, contextHandle);
-    if (DEBUG) {
-      System.err.println("!!! Destroyed OpenGL context " + contextHandle);
-    }
+    GLX.glXDestroyContext(drawable.getNativeSurface().getDisplayHandle(), contextHandle);
   }
 
   protected void copyImpl(GLContext source, int mask) throws GLException {
@@ -474,7 +437,7 @@ public abstract class X11GLXContext extends GLContextImpl {
   }
 
   protected final void updateGLXProcAddressTable() {
-    final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+    final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration();
     final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice();
     final String key = "GLX-"+adevice.getUniqueID();
     if (DEBUG) {
@@ -507,10 +470,12 @@ public abstract class X11GLXContext extends GLContextImpl {
   protected final StringBuffer getPlatformExtensionsStringImpl() {
     StringBuffer sb = new StringBuffer();
     if (DEBUG) {
-      System.err.println("!!! GLX Version "+glXVersion);
+      System.err.println("!!! GLX Version client version "+ GLXUtil.getClientVersionNumber()+
+                         ", server: "+         
+        ((X11GLXDrawableFactory)drawable.getFactoryImpl()).getGLXVersionNumber(drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice()));
     }
-    if(isGLXVersionGreaterEqualOneOne()) {
-        final NativeSurface ns = drawable.getNativeSurface();
+    final NativeSurface ns = drawable.getNativeSurface();
+    if(((X11GLXDrawableFactory)drawable.getFactoryImpl()).isGLXVersionGreaterEqualOneOne(ns.getGraphicsConfiguration().getScreen().getDevice())) {
         {
             final String ret = GLX.glXGetClientString(ns.getDisplayHandle(), GLX.GLX_EXTENSIONS);
             if (DEBUG) {
@@ -540,14 +505,14 @@ public abstract class X11GLXContext extends GLContextImpl {
     if (glExtensionName.equals("GL_ARB_pbuffer") ||
         glExtensionName.equals("GL_ARB_pixel_format")) {
       return getGLDrawable().getFactory().canCreateGLPbuffer(
-          drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice() );
+          drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice() );
     }
     return super.isExtensionAvailable(glExtensionName);
   }
 
   @Override
   protected void setSwapIntervalImpl(int interval) {
-    X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+    X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration();
     GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
     if(!glCaps.isOnscreen()) return;
 
@@ -652,7 +617,7 @@ public abstract class X11GLXContext extends GLContextImpl {
 
   public String toString() {
     StringBuffer sb = new StringBuffer();
-    sb.append(getClass().getName());
+    sb.append(getClass().getSimpleName());
     sb.append(" [");
     super.append(sb);
     sb.append(", direct ");
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawable.java
index d2ce629..28c02cd 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawable.java
@@ -42,6 +42,7 @@ package jogamp.opengl.x11.glx;
 
 import javax.media.nativewindow.*;
 import javax.media.opengl.*;
+
 import jogamp.opengl.*;
 
 public abstract class X11GLXDrawable extends GLDrawableImpl {
@@ -55,7 +56,7 @@ public abstract class X11GLXDrawable extends GLDrawableImpl {
 
   protected void setRealizedImpl() {
     if(realized) {
-        X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+        X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeSurface().getGraphicsConfiguration();
         config.updateGraphicsConfiguration();
 
         if (DEBUG) {
@@ -64,9 +65,10 @@ public abstract class X11GLXDrawable extends GLDrawableImpl {
     }
   }
 
-    protected void swapBuffersImpl() {
-        GLX.glXSwapBuffers(getNativeSurface().getDisplayHandle(), getHandle());
-    }
+  protected final void swapBuffersImpl() {
+    // single-buffer is already filtered out @ GLDrawableImpl#swapBuffers()
+    GLX.glXSwapBuffers(getNativeSurface().getDisplayHandle(), getHandle());
+  }
 
   //---------------------------------------------------------------------------
   // Internals only below this point
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
index 51316dc..235aea4 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
@@ -37,115 +37,156 @@
 
 package jogamp.opengl.x11.glx;
 
+import java.nio.Buffer;
+import java.nio.ShortBuffer;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
-import java.nio.*;
 
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.x11.*;
-import javax.media.opengl.*;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.AbstractGraphicsScreen;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.nativewindow.ProxySurface;
+import javax.media.nativewindow.x11.X11GraphicsDevice;
+import javax.media.nativewindow.x11.X11GraphicsScreen;
+import javax.media.opengl.GLCapabilitiesChooser;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawable;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.GLProfile.ShutdownType;
 
-import jogamp.opengl.*;
-
-import com.jogamp.common.JogampRuntimeException;
-import com.jogamp.common.util.*;
 import jogamp.nativewindow.WrappedSurface;
-import jogamp.nativewindow.x11.*;
+import jogamp.nativewindow.x11.X11Lib;
+import jogamp.nativewindow.x11.X11Util;
+import jogamp.opengl.DesktopGLDynamicLookupHelper;
+import jogamp.opengl.GLContextImpl;
+import jogamp.opengl.GLDrawableFactoryImpl;
+import jogamp.opengl.GLDrawableImpl;
+import jogamp.opengl.GLDynamicLookupHelper;
+import jogamp.opengl.SharedResourceRunner;
+
+import com.jogamp.common.util.VersionNumber;
 
 public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
   
-  private static final DesktopGLDynamicLookupHelper x11GLXDynamicLookupHelper;
+  public static final VersionNumber versionOneZero = new VersionNumber(1, 0, 0);
+  public static final VersionNumber versionOneOne = new VersionNumber(1, 1, 0);
+  public static final VersionNumber versionOneTwo = new VersionNumber(1, 2, 0);
+  public static final VersionNumber versionOneThree = new VersionNumber(1, 3, 0);
+  public static final VersionNumber versionOneFour = new VersionNumber(1, 4, 0);
 
-  static {
-    DesktopGLDynamicLookupHelper tmp = null;
-    try {
-        tmp = new DesktopGLDynamicLookupHelper(new X11GLXDynamicLibraryBundleInfo());
-    } catch (GLException gle) {
-        if(DEBUG) {
-            gle.printStackTrace();
+  private static DesktopGLDynamicLookupHelper x11GLXDynamicLookupHelper = null;
+  
+  public X11GLXDrawableFactory() {
+    super();
+
+    synchronized(X11GLXDrawableFactory.class) {
+        if(null==x11GLXDynamicLookupHelper) {
+            DesktopGLDynamicLookupHelper tmp = null;
+            try {
+                tmp = new DesktopGLDynamicLookupHelper(new X11GLXDynamicLibraryBundleInfo());
+            } catch (GLException gle) {
+                if(DEBUG) {
+                    gle.printStackTrace();
+                }
+            }
+            x11GLXDynamicLookupHelper = tmp;
+            if(null!=x11GLXDynamicLookupHelper) {
+                GLX.getGLXProcAddressTable().reset(x11GLXDynamicLookupHelper);
+            }
         }
     }
-    x11GLXDynamicLookupHelper = tmp;
-    if(null!=x11GLXDynamicLookupHelper) {
-        GLX.getGLXProcAddressTable().reset(x11GLXDynamicLookupHelper);
+    
+    if(null!=x11GLXDynamicLookupHelper) {        
+        // Register our GraphicsConfigurationFactory implementations
+        // The act of constructing them causes them to be registered
+        X11GLXGraphicsConfigurationFactory.registerFactory();
+        
+        defaultDevice = new X11GraphicsDevice(X11Util.getNullDisplayName(), AbstractGraphicsDevice.DEFAULT_UNIT);
+        sharedMap = new HashMap<String, SharedResourceRunner.Resource>();
+        
+        // Init shared resources off thread
+        // Will be released via ShutdownHook
+        sharedResourceRunner = new SharedResourceRunner(new SharedResourceImplementation());
+        sharedResourceRunner.start();
+    }    
+  }
+
+  protected final void destroy(ShutdownType shutdownType) {
+    if(null != sharedResourceRunner) {
+        sharedResourceRunner.stop();
+        sharedResourceRunner = null;
     }
-  }
+    if(null != sharedMap) {
+        sharedMap.clear();
+        sharedMap = null;
+    }
+    defaultDevice = null;
+    /**
+     * Pulling away the native library may cause havoc ..
+     * 
+    if(ShutdownType.COMPLETE == shutdownType && null != x11GLXDynamicLookupHelper) {
+        x11GLXDynamicLookupHelper.destroy();
+        x11GLXDynamicLookupHelper = null;
+    } */
 
-  public static VersionNumber getGLXVersion(X11GraphicsDevice device) {
-    int[] major = new int[1];
-    int[] minor = new int[1];
-    GLXUtil.getGLXVersion(device.getHandle(), major, minor);
-    return new VersionNumber(major[0], minor[0], 0);
+    // Don't really close pending Display connections,
+    // since this may trigger a JVM exception
+    X11Util.shutdown( false, DEBUG );
   }
 
   public GLDynamicLookupHelper getGLDynamicLookupHelper(int profile) {
       return x11GLXDynamicLookupHelper;
   }
 
-  public X11GLXDrawableFactory() {
-    super();
-    // Register our GraphicsConfigurationFactory implementations
-    // The act of constructing them causes them to be registered
-    new X11GLXGraphicsConfigurationFactory();
-    if(GLProfile.isAWTAvailable()) {
-        try {
-          ReflectionUtil.createInstance("jogamp.opengl.x11.glx.awt.X11AWTGLXGraphicsConfigurationFactory",
-                                        null, getClass().getClassLoader());
-        } catch (JogampRuntimeException jre) { /* n/a .. */ }
-    }
-
-    defaultDevice = new X11GraphicsDevice(X11Util.getNullDisplayName(), AbstractGraphicsDevice.DEFAULT_UNIT);
-
-    // Init shared resources off thread
-    // Will be released via ShutdownHook
-    sharedResourceImpl = new SharedResourceImplementation();
-    sharedResourceRunner = new SharedResourceRunner(sharedResourceImpl);
-    sharedResourceThread = new Thread(sharedResourceRunner, Thread.currentThread().getName()+"-SharedResourceRunner");
-    sharedResourceThread.setDaemon(true); // Allow JVM to exit, even if this one is running
-    sharedResourceThread.start();
-  }
-
-  X11GraphicsDevice defaultDevice;
-  SharedResourceImplementation sharedResourceImpl;
-  SharedResourceRunner sharedResourceRunner;
-  Thread sharedResourceThread;
-  HashMap/*<connection, SharedResource>*/ sharedMap = new HashMap();
+  private X11GraphicsDevice defaultDevice;
+  private SharedResourceRunner sharedResourceRunner;
+  private HashMap<String /* connection */, SharedResourceRunner.Resource> sharedMap;  
 
   static class SharedResource implements SharedResourceRunner.Resource {
       X11GraphicsDevice device;
       X11GraphicsScreen screen;
       X11DummyGLXDrawable drawable;
       X11GLXContext context;
-      String glXVendorName;
-      boolean isGLXVendorATI;
-      boolean isGLXVendorNVIDIA;
-      VersionNumber glXVersion;
+      String glXServerVendorName;
+      boolean isGLXServerVendorATI;
+      boolean isGLXServerVendorNVIDIA;
+      VersionNumber glXServerVersion;
+      boolean glXServerVersionOneOneCapable;
+      boolean glXServerVersionOneThreeCapable;
+      boolean glXMultisampleAvailable;
 
       SharedResource(X11GraphicsDevice dev, X11GraphicsScreen scrn,
                      X11DummyGLXDrawable draw, X11GLXContext ctx,
-                     VersionNumber glXVer, String glXVendor) {
+                     VersionNumber glXServerVer, String glXServerVendor, boolean glXServerMultisampleAvail) {
           device = dev;
           screen = scrn;
           drawable = draw;
           context = ctx;
-          glXVersion = glXVer;
-          glXVendorName = glXVendor;
-          isGLXVendorATI = GLXUtil.isVendorATI(glXVendorName);
-          isGLXVendorNVIDIA = GLXUtil.isVendorNVIDIA(glXVendorName);
+          glXServerVersion = glXServerVer;
+          glXServerVersionOneOneCapable = glXServerVersion.compareTo(versionOneOne) >= 0 ;        
+          glXServerVersionOneThreeCapable = glXServerVersion.compareTo(versionOneThree) >= 0 ;        
+          glXServerVendorName = glXServerVendor;
+          isGLXServerVendorATI = GLXUtil.isVendorATI(glXServerVendorName);
+          isGLXServerVendorNVIDIA = GLXUtil.isVendorNVIDIA(glXServerVendorName);
+          glXMultisampleAvailable = glXServerMultisampleAvail;
       }
       final public AbstractGraphicsDevice getDevice() { return device; }
       final public AbstractGraphicsScreen getScreen() { return screen; }
       final public GLDrawableImpl getDrawable() { return drawable; }
       final public GLContextImpl getContext() { return context; }
 
-      final String getGLXVendorName() { return glXVendorName; }
-      final boolean isGLXVendorATI() { return isGLXVendorATI; }
-      final boolean isGLXVendorNVIDIA() { return isGLXVendorNVIDIA; }
-      final VersionNumber getGLXVersion() { return glXVersion; }
-      final boolean isGLXVersionGreaterEqualOneThree() {
-        return ( null != glXVersion ) ? glXVersion.compareTo(versionOneThree) >= 0 : false ;
-      }
+      final String getGLXVendorName() { return glXServerVendorName; }
+      final boolean isGLXVendorATI() { return isGLXServerVendorATI; }
+      final boolean isGLXVendorNVIDIA() { return isGLXServerVendorNVIDIA; }
+      final VersionNumber getGLXVersion() { return glXServerVersion; }
+      final boolean isGLXVersionGreaterEqualOneOne() { return glXServerVersionOneOneCapable; }
+      final boolean isGLXVersionGreaterEqualOneThree() { return glXServerVersionOneThreeCapable; }
+      final boolean isGLXMultisampleAvailable() { return glXMultisampleAvailable; }
   }
 
   class SharedResourceImplementation implements SharedResourceRunner.Implementation {
@@ -156,27 +197,33 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
         }
         public SharedResourceRunner.Resource mapPut(String connection, SharedResourceRunner.Resource resource) {
             synchronized(sharedMap) {
-                return (SharedResourceRunner.Resource) sharedMap.put(connection, resource);
+                return sharedMap.put(connection, resource);
             }
         }
         public SharedResourceRunner.Resource mapGet(String connection) {
             synchronized(sharedMap) {
-                return (SharedResourceRunner.Resource) sharedMap.get(connection);
+                return sharedMap.get(connection);
             }
         }
-        public Collection/*<Resource>*/ mapValues() {
+        public Collection<SharedResourceRunner.Resource> mapValues() {
             synchronized(sharedMap) {
                 return sharedMap.values();
             }
         }
 
         public SharedResourceRunner.Resource createSharedResource(String connection) {
-            X11GraphicsDevice sharedDevice = new X11GraphicsDevice(X11Util.openDisplay(connection), AbstractGraphicsDevice.DEFAULT_UNIT);
-            sharedDevice.setCloseDisplay(true);
+            X11GraphicsDevice sharedDevice = 
+                    new X11GraphicsDevice(X11Util.openDisplay(connection), AbstractGraphicsDevice.DEFAULT_UNIT, 
+                                          true); // own non-shared display connection, no locking
+                    // new X11GraphicsDevice(X11Util.openDisplay(connection), AbstractGraphicsDevice.DEFAULT_UNIT, 
+                    //                       NativeWindowFactory.getNullToolkitLock(), true); // own non-shared display connection, no locking
             sharedDevice.lock();
             try {
-                String glXVendorName = GLXUtil.getVendorName(sharedDevice.getHandle());
-                if(X11Util.ATI_HAS_XCLOSEDISPLAY_BUG && GLXUtil.isVendorATI(glXVendorName)) {
+                GLXUtil.initGLXClientDataSingleton(sharedDevice);
+                final String glXServerVendorName = GLX.glXQueryServerString(sharedDevice.getHandle(), 0, GLX.GLX_VENDOR);
+                final VersionNumber glXServerVersion = GLXUtil.getGLXServerVersionNumber(sharedDevice.getHandle());
+                final boolean glXServerMultisampleAvailable = GLXUtil.isMultisampleAvailable(GLX.glXQueryServerString(sharedDevice.getHandle(), 0, GLX.GLX_EXTENSIONS));                
+                if(X11Util.ATI_HAS_XCLOSEDISPLAY_BUG && GLXUtil.isVendorATI(glXServerVendorName)) {
                     X11Util.setMarkAllDisplaysUnclosable(true);
                     X11Util.markDisplayUncloseable(sharedDevice.getHandle());
                 }
@@ -195,7 +242,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
                     throw new GLException("Couldn't create shared context for drawable: "+sharedDrawable);
                 }
                 sharedContext.setSynchronized(true);
-                VersionNumber glXVersion = getGLXVersion(sharedDevice);
                 boolean madeCurrent = false;
                 sharedContext.makeCurrent();
                 try {
@@ -207,11 +253,16 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
                     System.err.println("!!! SharedDevice:  " + sharedDevice);
                     System.err.println("!!! SharedScreen:  " + sharedScreen);
                     System.err.println("!!! SharedContext: " + sharedContext + ", madeCurrent " + madeCurrent);
-                    System.err.println("!!! GLX Vendor:    " + glXVendorName);
-                    System.err.println("!!! GLX Version:   " + glXVersion
-                            + " >= 1.3: " + (glXVersion.compareTo(versionOneThree) >= 0));
+                    System.err.println("!!! GLX Server Vendor:      " + glXServerVendorName);
+                    System.err.println("!!! GLX Server Version:     " + glXServerVersion);
+                    System.err.println("!!! GLX Server Multisample: " + glXServerMultisampleAvailable);
+                    System.err.println("!!! GLX Client Vendor:      " + GLXUtil.getClientVendorName());
+                    System.err.println("!!! GLX Client Version:     " + GLXUtil.getClientVersionNumber());
+                    System.err.println("!!! GLX Client Multisample: " + GLXUtil.isClientMultisampleAvailable());
                 }
-                return new SharedResource(sharedDevice, sharedScreen, sharedDrawable, sharedContext, glXVersion, glXVendorName);
+                return new SharedResource(sharedDevice, sharedScreen, sharedDrawable, sharedContext, 
+                                          glXServerVersion, glXServerVendorName, 
+                                          glXServerMultisampleAvailable && GLXUtil.isClientMultisampleAvailable());
             } catch (Throwable t) {
                 throw new GLException("X11GLXDrawableFactory - Could not initialize shared resources for "+connection, t);
             } finally {
@@ -227,15 +278,19 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
                 System.err.println("!!!   Screen  : " + sr.screen);
                 System.err.println("!!!   Drawable: " + sr.drawable);
                 System.err.println("!!!   CTX     : " + sr.context);
+                Thread.dumpStack();
             }
 
             if (null != sr.context) {
-                // may cause JVM SIGSEGV: sharedContext.destroy();
+                // may cause JVM SIGSEGV:
+                sr.context.makeCurrent();
+                sr.context.destroy();
                 sr.context = null;
             }
 
             if (null != sr.drawable) {
-                // may cause JVM SIGSEGV: sharedDrawable.destroy();
+                // may cause JVM SIGSEGV:
+                sr.drawable.destroy();
                 sr.drawable = null;
             }
 
@@ -244,6 +299,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
             }
 
             if (null != sr.device) {
+                // may cause JVM SIGSEGV:
                 sr.device.close();
                 sr.device = null;
             }
@@ -261,10 +317,21 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
       return false;
   }
 
-  public final boolean getWasSharedContextCreated(AbstractGraphicsDevice device) {
-    SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
-    if(null!=sr) {
-      return null != sr.getContext();
+  protected final Thread getSharedResourceThread() {
+    return sharedResourceRunner.start();
+  }
+    
+  protected final boolean createSharedResource(AbstractGraphicsDevice device) {
+    try {
+        SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
+        if(null!=sr) {
+          return null != sr.getContext();
+        }
+    } catch (GLException gle) {
+        if(DEBUG) {
+            System.err.println("Catched Exception while X11GLX Shared Resource initialization");
+            gle.printStackTrace();
+        }
     }
     return false;
   }
@@ -297,47 +364,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
     return (SharedResource) sharedResourceRunner.getOrCreateShared(device);
   }
 
-  public final String getGLXVendorName(AbstractGraphicsDevice device) {
-    if(null != device) {
-        SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
-        if(null!=sr) {
-          return ((SharedResource)sr).getGLXVendorName();
-        }
-        return GLXUtil.getVendorName(device.getHandle());
-    }
-    return null;
-  }
-
-  public final boolean isGLXVendorATI(AbstractGraphicsDevice device) {
-    if(null != device) {
-        SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
-        if(null!=sr) {
-          return ((SharedResource)sr).isGLXVendorATI();
-        }
-        return GLXUtil.isVendorATI(device.getHandle());
-    }
-    return false;
-  }
-
-  public final boolean isGLXVendorNVIDIA(AbstractGraphicsDevice device) {
-    if(null != device) {
-        SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
-        if(null!=sr) {
-          return ((SharedResource)sr).isGLXVendorNVIDIA();
-        }
-        return GLXUtil.isVendorNVIDIA(device.getHandle());
-    }
-    return false;
-  }
-
-  protected final void shutdownInstance() {
-    sharedResourceRunner.releaseAndWait();
-
-    // Don't really close pending Display connections,
-    // since this may trigger a JVM exception
-    X11Util.shutdown( false, DEBUG );
-  }
-
   protected List<GLCapabilitiesImmutable> getAvailableCapabilitiesImpl(AbstractGraphicsDevice device) {
     return X11GLXGraphicsConfigurationFactory.getAvailableCapabilities(this, device);
   }
@@ -353,7 +379,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
     if (target == null) {
       throw new IllegalArgumentException("Null target");
     }
-    AbstractGraphicsConfiguration config = target.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+    AbstractGraphicsConfiguration config = target.getGraphicsConfiguration();
     GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
     if(!caps.isPBuffer()) {
         return new X11PixmapGLXDrawable(this, target);
@@ -383,6 +409,43 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
     return pbufferDrawable;
   }
 
+  public final boolean isGLXMultisampleAvailable(AbstractGraphicsDevice device) {
+    if(null != device) {  
+        SharedResource sr = (SharedResource) sharedResourceRunner.getOrCreateShared(device);
+        if(null!=sr) {
+          return sr.isGLXMultisampleAvailable();
+        }
+    }
+    return false;
+  }
+
+  public final VersionNumber getGLXVersionNumber(AbstractGraphicsDevice device) {
+    if(null != device) {  
+        SharedResource sr = (SharedResource) sharedResourceRunner.getOrCreateShared(device);
+        if(null!=sr) {
+          return sr.getGLXVersion();
+        }
+        if( device instanceof X11GraphicsDevice ) {
+          return GLXUtil.getGLXServerVersionNumber(device.getHandle());
+        }
+    }
+    return null;
+  }
+  
+  public final boolean isGLXVersionGreaterEqualOneOne(AbstractGraphicsDevice device) {
+    if(null != device) {  
+        SharedResource sr = (SharedResource) sharedResourceRunner.getOrCreateShared(device);
+        if(null!=sr) {
+          return sr.isGLXVersionGreaterEqualOneOne();
+        }
+        if( device instanceof X11GraphicsDevice ) {
+          final VersionNumber glXServerVersion = GLXUtil.getGLXServerVersionNumber(device.getHandle());
+          return glXServerVersion.compareTo(versionOneOne) >= 0;
+        }
+    }
+    return false;
+  }
+  
   public final boolean isGLXVersionGreaterEqualOneThree(AbstractGraphicsDevice device) {
     if(null != device) {  
         SharedResource sr = (SharedResource) sharedResourceRunner.getOrCreateShared(device);
@@ -390,8 +453,8 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
           return sr.isGLXVersionGreaterEqualOneThree();
         }
         if( device instanceof X11GraphicsDevice ) {
-          VersionNumber v = getGLXVersion( (X11GraphicsDevice) device);
-          return ( null != v ) ? v.compareTo(versionOneThree) >= 0 : false ;
+          final VersionNumber glXServerVersion = GLXUtil.getGLXServerVersionNumber(device.getHandle());
+          return glXServerVersion.compareTo(versionOneThree) >= 0;
         }
     }
     return false;
@@ -407,23 +470,28 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
       return isGLXVersionGreaterEqualOneThree(device);
   }
 
-  protected final NativeSurface createOffscreenSurfaceImpl(AbstractGraphicsDevice device,
+  protected final NativeSurface createOffscreenSurfaceImpl(AbstractGraphicsDevice deviceReq,
                                                            GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested,
                                                            GLCapabilitiesChooser chooser,
                                                            int width, int height) {
-    X11GraphicsScreen screen = null;
-    SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
-    if(null!=sr) {
-        screen = (X11GraphicsScreen) sr.getScreen();
+    if(null == deviceReq) {
+        throw new InternalError("deviceReq is null");
     }
-    if(null==screen) {
-        return null;
+    final SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(deviceReq);
+    if(null==sr) {
+        throw new InternalError("No SharedResource for: "+deviceReq);
     }
+    final X11GraphicsScreen sharedScreen = (X11GraphicsScreen) sr.getScreen();
+    final AbstractGraphicsDevice sharedDevice = sharedScreen.getDevice(); // should be same ..
 
+    // create screen/device pair - Null X11 locking, due to private non-shared Display handle
+    final X11GraphicsDevice device = new X11GraphicsDevice(X11Util.openDisplay(sharedDevice.getConnection()), AbstractGraphicsDevice.DEFAULT_UNIT, NativeWindowFactory.getNullToolkitLock(), true);
+    final X11GraphicsScreen screen = new X11GraphicsScreen(device, sharedScreen.getIndex()); 
+    
     WrappedSurface ns = new WrappedSurface(
                X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen) );
     if(ns != null) {
-        ns.setSize(width, height);
+        ns.surfaceSizeChanged(width, height);
     }
     return ns;
   }
@@ -475,8 +543,8 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
     }
 
     int[] size = new int[1];
-    boolean res = X11Util.XF86VidModeGetGammaRampSize(display,
-                                                      X11Util.DefaultScreen(display),
+    boolean res = X11Lib.XF86VidModeGetGammaRampSize(display,
+                                                      X11Lib.DefaultScreen(display),
                                                       size, 0);
     if (!res) {
       return 0;
@@ -498,8 +566,8 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
       rampData[i] = (short) (ramp[i] * 65535);
     }
 
-    boolean res = X11Util.XF86VidModeSetGammaRamp(display,
-                                              X11Util.DefaultScreen(display),
+    boolean res = X11Lib.XF86VidModeSetGammaRamp(display,
+                                              X11Lib.DefaultScreen(display),
                                               rampData.length,
                                               rampData, 0,
                                               rampData, 0,
@@ -525,8 +593,8 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
     rampData.limit(3 * size);
     ShortBuffer blueRampData = rampData.slice();
 
-    boolean res = X11Util.XF86VidModeGetGammaRamp(display,
-                                              X11Util.DefaultScreen(display),
+    boolean res = X11Lib.XF86VidModeGetGammaRamp(display,
+                                              X11Lib.DefaultScreen(display),
                                               size,
                                               redRampData,
                                               greenRampData,
@@ -562,8 +630,8 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
     rampData.limit(3 * size);
     ShortBuffer blueRampData = rampData.slice();
 
-    X11Util.XF86VidModeSetGammaRamp(display,
-                                X11Util.DefaultScreen(display),
+    X11Lib.XF86VidModeSetGammaRamp(display,
+                                X11Lib.DefaultScreen(display),
                                 size,
                                 redRampData,
                                 greenRampData,
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java
index 68b8135..4d0c3ee 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java
@@ -35,13 +35,26 @@ package jogamp.opengl.x11.glx;
 
 import java.util.ArrayList;
 
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.x11.*;
-import javax.media.opengl.*;
+import javax.media.nativewindow.GraphicsConfigurationFactory;
+import javax.media.nativewindow.x11.X11GraphicsConfiguration;
+import javax.media.nativewindow.x11.X11GraphicsScreen;
+import javax.media.opengl.DefaultGLCapabilitiesChooser;
+import javax.media.opengl.GL;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesChooser;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
+
+import jogamp.nativewindow.x11.X11Lib;
+import jogamp.nativewindow.x11.XRenderDirectFormat;
+import jogamp.nativewindow.x11.XRenderPictFormat;
+import jogamp.nativewindow.x11.XVisualInfo;
+import jogamp.opengl.Debug;
+import jogamp.opengl.GLGraphicsConfigurationUtil;
 
 import com.jogamp.common.nio.PointerBuffer;
-import jogamp.opengl.*;
-import jogamp.nativewindow.x11.*;
 
 public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implements Cloneable {
     protected static final boolean DEBUG = Debug.debug("GraphicsConfiguration");
@@ -56,19 +69,20 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
     }
 
     static X11GLXGraphicsConfiguration create(GLProfile glp, X11GraphicsScreen x11Screen, int fbcfgID) {
-      long display = x11Screen.getDevice().getHandle();
+      final long display = x11Screen.getDevice().getHandle();
       if(0==display) {
           throw new GLException("Display null of "+x11Screen);
       }
-      int screen = x11Screen.getIndex();
-      long fbcfg = glXFBConfigID2FBConfig(display, screen, fbcfgID);
+      final int screen = x11Screen.getIndex();
+      final long fbcfg = glXFBConfigID2FBConfig(display, screen, fbcfgID);
       if(0==fbcfg) {
           throw new GLException("FBConfig null of "+toHexString(fbcfgID));
       }
       if(null==glp) {
         glp = GLProfile.getDefault(x11Screen.getDevice());
       }
-      X11GLCapabilities caps = GLXFBConfig2GLCapabilities(glp, display, fbcfg, true, true, true, GLXUtil.isMultisampleAvailable(display));
+      final X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory();
+      final X11GLCapabilities caps = GLXFBConfig2GLCapabilities(glp, display, fbcfg, true, true, true, factory.isGLXMultisampleAvailable(x11Screen.getDevice()));
       if(null==caps) {
           throw new GLException("GLCapabilities null of "+toHexString(fbcfg));
       }
@@ -100,10 +114,6 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
         }
     }
 
-    private static int nonZeroOrDontCare(int value) {
-        return value != 0 ? value : (int)GLX.GLX_DONT_CARE ;
-    }
-
     static int[] GLCapabilities2AttribList(GLCapabilitiesImmutable caps,
                                            boolean forFBAttr,
                                            boolean isMultisampleAvailable,
@@ -367,7 +377,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
       int[] count = new int[1];
       XVisualInfo template = XVisualInfo.create();
       template.setVisualid(visualID);
-      XVisualInfo[] infos = X11Util.XGetVisualInfo(display, X11Lib.VisualIDMask, template, count, 0);
+      XVisualInfo[] infos = X11Lib.XGetVisualInfo(display, X11Lib.VisualIDMask, template, count, 0);
       if (infos == null || infos.length == 0) {
             return null;
       }  
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java
index 0f8b948..a72de8c 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java
@@ -51,7 +51,6 @@ import javax.media.opengl.GLProfile;
 
 import com.jogamp.common.nio.PointerBuffer;
 import jogamp.nativewindow.x11.X11Lib;
-import jogamp.nativewindow.x11.X11Util;
 import jogamp.nativewindow.x11.XVisualInfo;
 import jogamp.opengl.Debug;
 import jogamp.opengl.GLGraphicsConfigurationFactory;
@@ -71,8 +70,10 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF
     protected static final boolean DEBUG = Debug.debug("GraphicsConfiguration");
     static X11GLCapabilities.XVisualIDComparator XVisualIDComparator = new X11GLCapabilities.XVisualIDComparator();
 
-    X11GLXGraphicsConfigurationFactory() {
-        GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.x11.X11GraphicsDevice.class, this);
+    static void registerFactory() {
+        GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.x11.X11GraphicsDevice.class, new X11GLXGraphicsConfigurationFactory());
+    }
+    private X11GLXGraphicsConfigurationFactory() {
     }
 
     protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
@@ -101,18 +102,19 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF
         if(null == sharedResource) {
             throw new GLException("Shared resource for device n/a: "+device);
         }
-        X11GraphicsScreen sharedScreen = (X11GraphicsScreen) sharedResource.getScreen();
-        X11GLXDrawable sharedDrawable = (X11GLXDrawable) sharedResource.getDrawable();
-        GLCapabilitiesImmutable capsChosen = sharedDrawable.getChosenGLCapabilities();
-        GLProfile glp = capsChosen.getGLProfile();
+        final X11GraphicsScreen sharedScreen = (X11GraphicsScreen) sharedResource.getScreen();
+        final boolean isMultisampleAvailable = factory.isGLXMultisampleAvailable(sharedScreen.getDevice());
+        final X11GLXDrawable sharedDrawable = (X11GLXDrawable) sharedResource.getDrawable();
+        final GLCapabilitiesImmutable capsChosen = sharedDrawable.getChosenGLCapabilities();
+        final GLProfile glp = capsChosen.getGLProfile();
 
         List<GLCapabilitiesImmutable> availableCaps = null;
 
         if( sharedResource.isGLXVersionGreaterEqualOneThree() ) {
-            availableCaps = getAvailableGLCapabilitiesFBConfig(sharedScreen, glp);
+            availableCaps = getAvailableGLCapabilitiesFBConfig(sharedScreen, glp, isMultisampleAvailable);
         }
         if( null == availableCaps || availableCaps.isEmpty() ) {
-            availableCaps = getAvailableGLCapabilitiesXVisual(sharedScreen, glp);
+            availableCaps = getAvailableGLCapabilitiesXVisual(sharedScreen, glp, isMultisampleAvailable);
         }
         if( null != availableCaps && availableCaps.size() > 1 ) {
             Collections.sort(availableCaps, XVisualIDComparator);
@@ -120,7 +122,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF
         return availableCaps;
     }
 
-    static List<GLCapabilitiesImmutable> getAvailableGLCapabilitiesFBConfig(X11GraphicsScreen x11Screen, GLProfile glProfile) {
+    static List<GLCapabilitiesImmutable> getAvailableGLCapabilitiesFBConfig(X11GraphicsScreen x11Screen, GLProfile glProfile, boolean isMultisampleAvailable) {
         PointerBuffer fbcfgsL = null;
 
         // Utilizing FBConfig
@@ -129,7 +131,6 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF
         long display = absDevice.getHandle();
 
         int screen = x11Screen.getIndex();
-        boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
         int[] count = { -1 };
         ArrayList<GLCapabilitiesImmutable> availableCaps = new ArrayList<GLCapabilitiesImmutable>();
 
@@ -150,17 +151,16 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF
         return availableCaps;
     }
 
-    static List<GLCapabilitiesImmutable> getAvailableGLCapabilitiesXVisual(X11GraphicsScreen x11Screen, GLProfile glProfile) {
+    static List<GLCapabilitiesImmutable> getAvailableGLCapabilitiesXVisual(X11GraphicsScreen x11Screen, GLProfile glProfile, boolean isMultisampleAvailable) {
         AbstractGraphicsDevice absDevice = x11Screen.getDevice();
         long display = absDevice.getHandle();
 
         int screen = x11Screen.getIndex();
-        boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
 
         int[] count = new int[1];
         XVisualInfo template = XVisualInfo.create();
         template.setScreen(screen);
-        XVisualInfo[] infos = X11Util.XGetVisualInfo(display, X11Lib.VisualScreenMask, template, count, 0);
+        XVisualInfo[] infos = X11Lib.XGetVisualInfo(display, X11Lib.VisualScreenMask, template, count, 0);
         if (infos == null || infos.length<1) {
             throw new GLException("Error while enumerating available XVisualInfos");
         }
@@ -213,18 +213,20 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF
     }
 
     static X11GLXGraphicsConfiguration fetchGraphicsConfigurationFBConfig(X11GraphicsScreen x11Screen, int fbID, GLProfile glp) {
-        AbstractGraphicsDevice absDevice = x11Screen.getDevice();
-        long display = absDevice.getHandle();
-        int screen = x11Screen.getIndex();
+        final AbstractGraphicsDevice absDevice = x11Screen.getDevice();
+        final long display = absDevice.getHandle();
+        final int screen = x11Screen.getIndex();
 
-        long fbcfg = X11GLXGraphicsConfiguration.glXFBConfigID2FBConfig(display, screen, fbID);
+        final long fbcfg = X11GLXGraphicsConfiguration.glXFBConfigID2FBConfig(display, screen, fbID);
         if( 0 == fbcfg || !X11GLXGraphicsConfiguration.GLXFBConfigValid( display, fbcfg ) ) {
             if(DEBUG) {
                 System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed - GLX FBConfig invalid: ("+x11Screen+","+toHexString(fbID)+"): fbcfg: "+toHexString(fbcfg));
             }
             return null;
         }
-        X11GLCapabilities caps = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glp, display, fbcfg, true, true, true, GLXUtil.isMultisampleAvailable(display));
+        final X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory();
+               
+        final X11GLCapabilities caps = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glp, display, fbcfg, true, true, true, factory.isGLXMultisampleAvailable(absDevice));
         return new X11GLXGraphicsConfiguration(x11Screen, caps, caps, new DefaultGLCapabilitiesChooser());
     }
 
@@ -242,9 +244,10 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF
         //
         AbstractGraphicsDevice absDevice = x11Screen.getDevice();
         long display = absDevice.getHandle();
-
         int screen = x11Screen.getIndex();
-        boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
+        
+        final X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory();                              
+        final boolean isMultisampleAvailable = factory.isGLXMultisampleAvailable(absDevice);
         int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capsChosen, true, isMultisampleAvailable, display, screen);
         int[] count = { -1 };
         ArrayList/*<X11GLCapabilities>*/ availableCaps = new ArrayList();
@@ -321,9 +324,10 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF
 
         AbstractGraphicsDevice absDevice = x11Screen.getDevice();
         long display = absDevice.getHandle();
-
         int screen = x11Screen.getIndex();
-        boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
+        
+        final X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory();                              
+        final boolean isMultisampleAvailable = factory.isGLXMultisampleAvailable(absDevice);        
         int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capsChosen, false, isMultisampleAvailable, display, screen);
 
         // 1st choice: get GLCapabilities based on users GLCapabilities setting recommendedIndex as preferred choice
@@ -341,7 +345,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF
         int[] count = new int[1];
         XVisualInfo template = XVisualInfo.create();
         template.setScreen(screen);
-        XVisualInfo[] infos = X11Util.XGetVisualInfo(display, X11Lib.VisualScreenMask, template, count, 0);
+        XVisualInfo[] infos = X11Lib.XGetVisualInfo(display, X11Lib.VisualScreenMask, template, count, 0);
         if (infos == null || infos.length<1) {
             throw new GLException("Error while enumerating available XVisualInfos");
         }
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java
index 8ef6423..333486a 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java
@@ -56,14 +56,16 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable {
   }
 
   @SuppressWarnings("unused")
+  @Override
   public long getHandle() {
     if(USE_GLXWINDOW && useGLXWindow) {
         return glXWindow; 
     } 
-    return getNativeSurface().getSurfaceHandle();
+    return super.getHandle();
   }
 
   @SuppressWarnings("unused")
+  @Override
   protected void destroyHandle() {
     if(USE_GLXWINDOW && 0!=glXWindow) {
         GLX.glXDestroyWindow(getNativeSurface().getDisplayHandle(), glXWindow);
@@ -72,10 +74,10 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable {
     }
   }
 
-  /** must be locked already */
+  @Override
   protected void updateHandle() {
     if(USE_GLXWINDOW) {
-        X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+        X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeSurface().getGraphicsConfiguration();
         if(config.getFBConfig()>=0) {
             useGLXWindow=true;
             long dpy = getNativeSurface().getDisplayHandle();
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java
index 8ea9892..da7b535 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java
@@ -48,24 +48,18 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
                                   /* GLCapabilities caps, 
                                   GLCapabilitiesChooser chooser,
                                   int width, int height */
-    super(factory, target, true);
-
-    if (DEBUG) {
-        System.out.println("Pbuffer config: " + getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration());
-    }
-
-    createPbuffer();
-
-    if (DEBUG) {
-        System.err.println("Created pbuffer " + this);
-    }
+    super(factory, target, false);
   }
 
+  protected void destroyImpl() {
+    setRealized(false);
+  }
+  
   protected void setRealizedImpl() {
     if(realized) {
         createPbuffer();
     } else {
-        destroyImpl();
+        destroyPbuffer();
     }
   }
 
@@ -73,7 +67,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
     return new X11PbufferGLXContext(this, shareWith);
   }
 
-  protected void destroyImpl() {
+  protected void destroyPbuffer() {
     NativeSurface ns = getNativeSurface();
     if (ns.getSurfaceHandle() != 0) {
       GLX.glXDestroyPbuffer(ns.getDisplayHandle(), ns.getSurfaceHandle());
@@ -82,11 +76,14 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
   }
 
   private void createPbuffer() {
-      X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration) getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+      X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration) getNativeSurface().getGraphicsConfiguration();
       AbstractGraphicsScreen aScreen = config.getScreen();
       AbstractGraphicsDevice aDevice = aScreen.getDevice();
       long display = aDevice.getHandle();
-      int screen = aScreen.getIndex();
+
+      if (DEBUG) {
+        System.out.println("Pbuffer config: " + config);
+      }
 
       if (display==0) {
         throw new GLException("Null display");
@@ -129,17 +126,15 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
       int width = tmp[0];
       GLX.glXQueryDrawable(display, pbuffer, GLX.GLX_HEIGHT, tmp, 0);
       int height = tmp[0];
-      ((SurfaceChangeable)ns).setSize(width, height);
+      ((SurfaceChangeable)ns).surfaceSizeChanged(width, height);
+      
+      if (DEBUG) {
+        System.err.println("Created pbuffer " + this);
+      }
   }
 
   public int getFloatingPointMode() {
     // Floating-point pbuffers currently require NVidia hardware on X11
     return GLPbuffer.NV_FLOAT;
   }
-
-  protected void swapBuffersImpl() {
-    if(DEBUG) {
-        System.err.println("unhandled swapBuffersImpl() called for: "+this);
-    }
-  }
 }
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXContext.java
index ef8007d..e19dfd1 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXContext.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXContext.java
@@ -55,7 +55,7 @@ public class X11PixmapGLXContext extends X11GLXContext {
   }
   
   public int getOffscreenContextReadBuffer() {
-    GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+    GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)drawable.getNativeSurface().getGraphicsConfiguration().getChosenCapabilities();
     if (caps.getDoubleBuffered()) {
       return GL.GL_BACK;
     }
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java
index f5d3215..7dae20f 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java
@@ -48,15 +48,18 @@ public class X11PixmapGLXDrawable extends X11GLXDrawable {
   private long pixmap;
 
   protected X11PixmapGLXDrawable(GLDrawableFactory factory, NativeSurface target) {
-    super(factory, target, true);
-    create();
+    super(factory, target, false);
   }
 
+  protected void destroyImpl() {
+    setRealized(false);
+  }
+  
   protected void setRealizedImpl() {
     if(realized) {
-        create();
+        createPixmap();
     } else {
-        destroyImpl();
+        destroyPixmap();
     }
   }
 
@@ -64,9 +67,9 @@ public class X11PixmapGLXDrawable extends X11GLXDrawable {
     return new X11PixmapGLXContext(this, shareWith);
   }
   
-  private void create() {
+  private void createPixmap() {
     NativeSurface ns = getNativeSurface();
-    X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration) ns.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+    X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration) ns.getGraphicsConfiguration();
     XVisualInfo vis = config.getXVisualInfo();
     int bitsPerPixel = vis.getDepth();
     AbstractGraphicsScreen aScreen = config.getScreen();
@@ -74,14 +77,14 @@ public class X11PixmapGLXDrawable extends X11GLXDrawable {
     long dpy = aDevice.getHandle();
     int screen = aScreen.getIndex();
 
-    pixmap = X11Util.XCreatePixmap(dpy, X11Util.RootWindow(dpy, screen),
+    pixmap = X11Lib.XCreatePixmap(dpy, X11Lib.RootWindow(dpy, screen),
                                   surface.getWidth(), surface.getHeight(), bitsPerPixel);
     if (pixmap == 0) {
         throw new GLException("XCreatePixmap failed");
     }
     long drawable = GLX.glXCreateGLXPixmap(dpy, vis, pixmap);
     if (drawable == 0) {
-        X11Util.XFreePixmap(dpy, pixmap);
+        X11Lib.XFreePixmap(dpy, pixmap);
         pixmap = 0;
         throw new GLException("glXCreateGLXPixmap failed");
     }
@@ -93,7 +96,7 @@ public class X11PixmapGLXDrawable extends X11GLXDrawable {
     }
   }
 
-  protected void destroyImpl() {
+  protected void destroyPixmap() {
     if (pixmap == 0) return;
 
     NativeSurface ns = getNativeSurface();
@@ -122,16 +125,10 @@ public class X11PixmapGLXDrawable extends X11GLXDrawable {
     GLX.glXMakeCurrent(display, 0, 0);
 
     GLX.glXDestroyGLXPixmap(display, drawable);
-    X11Util.XFreePixmap(display, pixmap);
+    X11Lib.XFreePixmap(display, pixmap);
     drawable = 0;
     pixmap = 0;
     ((SurfaceChangeable)ns).setSurfaceHandle(0);
     display = 0;
   }
-
-  protected void swapBuffersImpl() {
-    if(DEBUG) {
-        System.err.println("unhandled swapBuffersImpl() called for: "+this);
-    }
-  }
 }
diff --git a/src/jogl/native/GLDebugMessageHandler.c b/src/jogl/native/GLDebugMessageHandler.c
index 509c6f6..fea9d90 100644
--- a/src/jogl/native/GLDebugMessageHandler.c
+++ b/src/jogl/native/GLDebugMessageHandler.c
@@ -35,21 +35,22 @@ typedef void (GLAPIENTRY* _local_GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenu
 JNIEXPORT jboolean JNICALL Java_jogamp_opengl_GLDebugMessageHandler_initIDs0
   (JNIEnv *env, jclass clazz)
 {
+    jboolean res;
     JoglCommon_init(env);
 
     glDebugMessageARB = (*env)->GetMethodID(env, clazz, "glDebugMessageARB", "(IIIILjava/lang/String;)V");
     glDebugMessageAMD = (*env)->GetMethodID(env, clazz, "glDebugMessageAMD", "(IIILjava/lang/String;)V");
 
-    if ( NULL == glDebugMessageARB || NULL == glDebugMessageAMD ) {
-        return JNI_FALSE;
-    }
-    return JNI_TRUE;
+    res = ( NULL != glDebugMessageARB && NULL != glDebugMessageAMD ) ? JNI_TRUE : JNI_FALSE ;
+
+    DBG_PRINT("GLDebugMessageHandler.initIDS0: OK: %d, ARB %p, AMD %p\n", res, glDebugMessageARB, glDebugMessageAMD);
+
+    return res;
 }
 
 typedef struct {
     JavaVM *vm;
     int version;
-    JNIEnv *env;
     jobject obj;
     int extType;
 } DebugHandlerType;
@@ -65,10 +66,12 @@ static void GLDebugMessageARBCallback(GLenum source, GLenum type, GLuint id, GLe
     JNIEnv *curEnv = NULL;
     JNIEnv *newEnv = NULL;
     int envRes ;
-    DBG_PRINT("GLDebugMessageARBCallback: 01 - %s\n", message);
+    DBG_PRINT("GLDebugMessageARBCallback: 00 - %s, vm %p, version 0x%X, jobject %p, extType %d\n", 
+        message, handle->vm, handle->version, (void*)handle->obj, handle->extType);
 
     // retrieve this thread's JNIEnv curEnv - or detect it's detached
     envRes = (*vm)->GetEnv(vm, (void **) &curEnv, version) ;
+    DBG_PRINT("GLDebugMessageARBCallback: 01 - JVM Env: curEnv %p, res 0x%X\n", curEnv, envRes);
     if( JNI_EDETACHED == envRes ) {
         // detached thread - attach to JVM
         if( JNI_OK != ( envRes = (*vm)->AttachCurrentThread(vm, (void**) &newEnv, NULL) ) ) {
@@ -107,9 +110,12 @@ static void GLDebugMessageAMDCallback(GLuint id, GLenum category, GLenum severit
     JNIEnv *curEnv = NULL;
     JNIEnv *newEnv = NULL;
     int envRes ;
+    DBG_PRINT("GLDebugMessageAMDCallback: 00 - %s, vm %p, version 0x%X, jobject %p, extType %d\n", 
+        message, handle->vm, handle->version, (void*)handle->obj, handle->extType);
 
     // retrieve this thread's JNIEnv curEnv - or detect it's detached
     envRes = (*vm)->GetEnv(vm, (void **) &curEnv, version) ;
+    DBG_PRINT("GLDebugMessageAMDCallback: 01 - JVM Env: curEnv %p, res 0x%X\n", curEnv, envRes);
     if( JNI_EDETACHED == envRes ) {
         // detached thread - attach to JVM
         if( JNI_OK != ( envRes = (*vm)->AttachCurrentThread(vm, (void**) &newEnv, NULL) ) ) {
@@ -117,6 +123,7 @@ static void GLDebugMessageAMDCallback(GLuint id, GLenum category, GLenum severit
             return;
         }
         curEnv = newEnv;
+        DBG_PRINT("GLDebugMessageAMDCallback: 02 - attached .. \n");
     } else if( JNI_OK != envRes ) {
         // oops ..
         fprintf(stderr, "GLDebugMessageAMDCallback: can't GetEnv: %d\n", envRes);
@@ -128,7 +135,9 @@ static void GLDebugMessageAMDCallback(GLuint id, GLenum category, GLenum severit
     if( NULL != newEnv ) {
         // detached attached thread
         (*vm)->DetachCurrentThread(vm);
+        DBG_PRINT("GLDebugMessageAMDCallback: 04 - detached .. \n");
     }
+    DBG_PRINT("GLDebugMessageAMDCallback: 0X\n");
     /**
      * On Java 32bit on 64bit Windows,
      * the unit test com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT crashes after this point.
@@ -152,9 +161,10 @@ JNIEXPORT jlong JNICALL Java_jogamp_opengl_GLDebugMessageHandler_register0
     }
     handle->vm = vm;
     handle->version = (*env)->GetVersion(env);
-    handle->env = env;
     handle->obj = (*env)->NewGlobalRef(env, obj);
     handle->extType = extType;
+    DBG_PRINT("GLDebugMessageHandler.register0: vm %p, version 0x%X, jobject %p, extType %d\n", 
+        handle->vm, handle->version, (void*)handle->obj, handle->extType);
 
     if(jogamp_opengl_GLDebugMessageHandler_EXT_ARB == extType) {
         _local_PFNGLDEBUGMESSAGECALLBACKARBPROC ptr_glDebugMessageCallbackARB;
@@ -181,9 +191,9 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_GLDebugMessageHandler_unregister0
 {
     DebugHandlerType * handle = (DebugHandlerType*) (intptr_t) jhandle;
 
-    if(env != handle->env) {
-        JoglCommon_throwNewRuntimeException(env, "wrong handle (env doesn't match)");
-    }
+    DBG_PRINT("GLDebugMessageHandler.unregister0: vm %p, version 0x%X, jobject %p, extType %d\n", 
+        handle->vm, handle->version, (void*)handle->obj, handle->extType);
+
     if(JNI_FALSE == (*env)->IsSameObject(env, obj, handle->obj)) {
         JoglCommon_throwNewRuntimeException(env, "wrong handle (obj doesn't match)");
     }
diff --git a/src/jogl/native/macosx/ContextUpdater.h b/src/jogl/native/macosx/ContextUpdater.h
index f8ce93d..f00b2be 100644
--- a/src/jogl/native/macosx/ContextUpdater.h
+++ b/src/jogl/native/macosx/ContextUpdater.h
@@ -22,19 +22,20 @@ This notification is sent whenever an NSView that has an attached NSSurface chan
     #define UNLOCK_GL(func, line) [ContextUpdater unlock];
 #endif
 
-// gznote: OpenGL NOT thread safe - need to sync on update and paints
-
 @interface ContextUpdater : NSObject
 {
+ at protected
+    pthread_mutex_t resourceLock;
+    NSView * view;
+    NSRect viewRect;
+    NSOpenGLContext *ctx;
+    BOOL viewUpdated;
 }
 
-+ (void) lock;
-+ (void) lockInFunction:(char *)func atLine:(int)line;
-+ (void) unlock;
-+ (void) unlockInFunction:(char *)func atLine:(int)line;
-
-- (void) registerFor:(NSOpenGLContext *)context with: (NSView *)window;
+- (id) initWithContext:(NSOpenGLContext *)context view: (NSView *)nsView;
 
 - (void) update:(NSNotification *)notification;
 
+- (BOOL) needsUpdate;
+
 @end
diff --git a/src/jogl/native/macosx/ContextUpdater.m b/src/jogl/native/macosx/ContextUpdater.m
index 8596977..d01eaf9 100644
--- a/src/jogl/native/macosx/ContextUpdater.m
+++ b/src/jogl/native/macosx/ContextUpdater.m
@@ -1,83 +1,78 @@
 #import "ContextUpdater.h"
 #import <pthread.h>
 
- at implementation ContextUpdater
-{
-}
+// #define VERBOSE_ON 1
 
-static NSOpenGLContext *theContext;
-static pthread_mutex_t resourceLock = PTHREAD_MUTEX_INITIALIZER;
+#ifdef VERBOSE_ON
+    #define DBG_PRINT(...) NSLog(@ __VA_ARGS__)
+    // #define DBG_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr)
+#else
+    #define DBG_PRINT(...)
+#endif
 
-static void printLockDebugInfo(char *message, char *func, int line)
-{
-    fprintf(stderr, "%s in function: \"%s\" at line: %d\n", message, func, line);
-    fflush(stderr);
-}
+#ifndef CGL_VERSION_1_3
+    #warning this SDK doesn't support OpenGL profile
+#endif
 
-+ (void) lock
+ at implementation ContextUpdater
 {
-    if (theContext != NULL)
-    {
-        pthread_mutex_lock(&resourceLock);
-    }
 }
 
-+ (void) lockInFunction:(char *)func atLine:(int)line
+- (void) update:(NSNotification *)notification
 {
-    if (theContext != NULL)
-    {
-        printLockDebugInfo("locked  ", func, line);
-        [self lock];
+    pthread_mutex_lock(&resourceLock);
+    
+    NSRect r = [view frame];
+    if(viewRect.origin.x != r.origin.x || 
+       viewRect.origin.y != r.origin.y || 
+       viewRect.size.width != r.size.width ||
+       viewRect.size.height != r.size.height) {
+        viewUpdated = TRUE;
+        viewRect = r;
     }
-}
 
-+ (void) unlock
-{
-    if (theContext != NULL)
-    {
-        pthread_mutex_unlock(&resourceLock);
-    }
+    pthread_mutex_unlock(&resourceLock);
 }
 
-+ (void) unlockInFunction:(char *)func atLine:(int)line
+- (BOOL) needsUpdate
 {
-    if (theContext != NULL)
-    {
-        printLockDebugInfo("unlocked", func, line);
-        [self unlock];
-    }
-}
+    BOOL r;
+    pthread_mutex_lock(&resourceLock);
+    
+    r = viewUpdated;
+    viewUpdated = FALSE;
+    
+    pthread_mutex_unlock(&resourceLock);
 
-- (void) registerFor:(NSOpenGLContext *)context with: (NSView *)view
-{
-    if (view != NULL)
-    {
-        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(update:) name:NSViewGlobalFrameDidChangeNotification object: view];
-        theContext = context;
-    }
+    return r;
 }
 
-- (void) update:(NSNotification *)notification
+- (id) initWithContext:(NSOpenGLContext *)context view: (NSView *)nsView
 {
-    [ContextUpdater lock];
-    
-    [theContext update];
-    
-    [ContextUpdater unlock];
-}
+    DBG_PRINT("ContextUpdater::init.0 view %p, ctx %p\n", view, ctx);
+    pthread_mutex_init(&resourceLock, NULL); // fast non-recursive
+    ctx = context;
+    view = nsView;
+    [ctx retain];
+    [view retain];
+    viewRect = [view frame];
+    viewUpdated = TRUE;
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(update:) name:NSViewGlobalFrameDidChangeNotification object: view];
+    DBG_PRINT("ContextUpdater::init.X\n");
 
-- (id) init
-{    
-    theContext = NULL;
-    
     return [super init];
 }
 
 - (void) dealloc
 {
+    DBG_PRINT("ContextUpdater::dealloc.0 view %p, ctx %p\n", view, ctx);
     [[NSNotificationCenter defaultCenter] removeObserver:self];
+    [view release];
+    [ctx release];
+    pthread_mutex_destroy(&resourceLock);
+    DBG_PRINT("ContextUpdater::dealloc.X\n");
     
     [super dealloc];
 }
 
- at end
\ No newline at end of file
+ at end
diff --git a/src/jogl/native/macosx/MacOSXCustomCGLCode.c b/src/jogl/native/macosx/MacOSXCustomCGLCode.c
index c29be88..f8b7a80 100644
--- a/src/jogl/native/macosx/MacOSXCustomCGLCode.c
+++ b/src/jogl/native/macosx/MacOSXCustomCGLCode.c
@@ -5,8 +5,7 @@
 #include </usr/include/machine/types.h>
 #include "macosx-window-system.h"
 
-void CGLQueryPixelFormat(void* pixelFormat, int* iattrs, int niattrs, int* ivalues) {
-  CGLPixelFormatObj pix = (CGLPixelFormatObj) pixelFormat;
+void CGLQueryPixelFormat(CGLPixelFormatObj fmt, int* iattrs, int niattrs, int* ivalues) {
   // FIXME: think about how specifying this might affect the API
   int virtualScreen = 0;
 
@@ -14,7 +13,7 @@ void CGLQueryPixelFormat(void* pixelFormat, int* iattrs, int niattrs, int* ivalu
   GLint value;
   for (i = 0; i < niattrs && iattrs[i]>0; i++) {
     CGLPixelFormatAttribute attr = (CGLPixelFormatAttribute) iattrs[i];
-    if ( kCGLNoError == CGLDescribePixelFormat(pix, virtualScreen, attr, &value) ) {
+    if ( kCGLNoError == CGLDescribePixelFormat(fmt, virtualScreen, attr, &value) ) {
         ivalues[i] = value;
     } else {
         ivalues[i] = 0;
diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-nsview.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-nsview.m
new file mode 100644
index 0000000..7233f40
--- /dev/null
+++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-nsview.m
@@ -0,0 +1,140 @@
+
+ at interface MyNSOpenGLLayer: NSOpenGLLayer
+{
+ at protected
+    NSOpenGLContext*     ctxShared;
+    NSView*              view;
+    NSOpenGLPixelFormat* fmt;
+ at public
+    volatile BOOL        shallDraw;
+}
+
+- (id) initWithContext: (NSOpenGLContext*) ctx
+       pixelFormat: (NSOpenGLPixelFormat*) pfmt
+       view: (NSView*) v
+       opaque: (Bool) opaque;
+
+ at end
+
+ at implementation MyNSOpenGLLayer
+
+- (id) initWithContext: (NSOpenGLContext*) _ctx
+       pixelFormat: (NSOpenGLPixelFormat*) _fmt
+       view: (NSView*) _view
+       opaque: (Bool) opaque
+{
+    self = [super init];
+    ctxShared = _ctx;
+    [ctxShared retain];
+
+    fmt = _fmt;
+    [fmt retain];
+
+    view = _view;
+    [view retain];
+    [self setView: view];
+    [view setLayer: self];
+    [view setWantsLayer: YES];
+
+    [self setAsynchronous: NO];
+    // [self setAsynchronous: YES]; // FIXME: JAU
+    [self setNeedsDisplayOnBoundsChange: NO];
+    [self setOpaque: opaque ? YES : NO];
+    shallDraw = NO;
+    textureID = 0;
+    DBG_PRINT("MyNSOpenGLLayer::init %p, ctx %p, pfmt %p, view %p, opaque %d\n", self, ctx, fmt, view, opaque);
+    return self;
+}
+
+- (void)dealloc
+{
+    [fmt release];
+    [ctxShared release];
+    [view release];
+    DBG_PRINT("MyNSOpenGLLayer::dealloc %p\n", self);
+    [super dealloc];
+}
+
+- (void) setOpenGLContext: (NSOpenGLContext*) _ctx
+{
+    DBG_PRINT("MyNSOpenGLLayer::setOpenGLContext: %p %p -> %p\n", self, [self openGLContext], _ctx);
+    [super setOpenGLContext: _ctx];
+}
+
+- (void) setOpenGLPixelFormat: (NSOpenGLPixelFormat*) _fmt
+{
+    DBG_PRINT("MyNSOpenGLLayer::setOpenGLPixelFormat %p %p -> %p\n", self, fmt, _fmt);
+    [super setOpenGLPixelFormat: fmt];
+}
+
+- (NSOpenGLPixelFormat *) openGLPixelFormat
+{
+    return fmt;
+}
+
+- (void) setView: (NSView*) v
+{
+    DBG_PRINT("MyNSOpenGLLayer::setView %p %p -> %p (ignored/propagated)\n", self, view, v);
+    [super setView: view]; // propagate
+}
+
+- (NSOpenGLPixelFormat *)openGLPixelFormatForDisplayMask:(uint32_t)mask
+{
+    DBG_PRINT("MyNSOpenGLLayer::openGLPixelFormatForDisplayMask %p %d -> %p\n", self, mask, fmt);
+    return fmt;
+}
+
+- (NSOpenGLContext *)openGLContextForPixelFormat:(NSOpenGLPixelFormat *)pixelFormat
+{
+    NSOpenGLContext* ctx = NULL;
+    if(NULL == ctx) {
+        int viewNotReady[] = { 0 };
+        ctx = createContext(ctxShared, view, true, fmt, [self isOpaque], viewNotReady);
+    }
+    DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat %p, fmt %p/%p, view %p, shared %p -> %p\n", 
+        self, fmt, pixelFormat, view, ctxShared, ctx);
+    return ctx;
+}
+
+- (BOOL)canDrawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat 
+        forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp
+{
+    DBG_PRINT("MyNSOpenGLLayer::canDrawInOpenGLContext %p: %d\n", self, self->shallDraw);
+    return self->shallDraw;
+}
+
+- (void)drawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat 
+        forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp
+{
+    self->shallDraw = NO;
+
+    DBG_PRINT("MyNSOpenGLLayer::drawInOpenGLContext %p, ctx %p, pfmt %p\n", self, context, pixelFormat);
+
+    [super drawInOpenGLContext: context pixelFormat: pixelFormat forLayerTime: timeInterval displayTime: timeStamp];
+}
+
+ at end
+
+NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSView* view, Bool opaque) {
+  return [[MyNSOpenGLLayer alloc] initWithContext:ctx pixelFormat: fmt view: view opaque: opaque];
+}
+
+void setNSOpenGLLayerNeedsDisplay(NSOpenGLLayer* layer) {
+  MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer;
+  NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+  l->shallDraw = YES;
+  [l performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:YES];
+  // NSView* view = [l view];
+  // [view setNeedsDisplay: YES]; // FIXME: JAU
+  // [view performSelectorOnMainThread:@selector(setNeedsDisplay:) withObject:YES waitUntilDone:YES];
+  // [view performSelectorOnMainThread:@selector(display) withObject:nil waitUntilDone:YES];
+  DBG_PRINT("MyNSOpenGLLayer::setNSOpenGLLayerNeedsDisplay %p\n", l);
+  [pool release];
+}
+
+void releaseNSOpenGLLayer(NSOpenGLLayer* l) {
+  NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+  [l release];
+  [pool release];
+}
+
diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m
new file mode 100644
index 0000000..fe896cc
--- /dev/null
+++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m
@@ -0,0 +1,480 @@
+#import "MacOSXWindowSystemInterface.h"
+#import <QuartzCore/QuartzCore.h>
+#import <pthread.h>
+#include "timespec.h"
+
+// 
+// CADisplayLink only available on iOS >= 3.1, sad, since it's convenient.
+// Use CVDisplayLink otherwise.
+//
+// #define HAS_CADisplayLink 1
+//
+
+// lock/sync debug output
+//
+// #define DBG_SYNC 1
+//
+#ifdef DBG_SYNC
+    // #define SYNC_PRINT(...) NSLog(@ ## __VA_ARGS__)
+    #define SYNC_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr)
+#else
+    #define SYNC_PRINT(...)
+#endif
+
+// fps debug output
+//
+// #define DBG_PERF 1
+
+ at interface MyNSOpenGLLayer: NSOpenGLLayer
+{
+ at protected
+    NSOpenGLPixelBuffer* pbuffer;
+    int texWidth;
+    int texHeight;
+    GLuint textureID;
+    GLint swapInterval;
+#ifdef HAS_CADisplayLink
+    CADisplayLink* displayLink;
+#else
+    CVDisplayLinkRef displayLink;
+#endif
+    int tc;
+    struct timespec t0;
+ at public
+    pthread_mutex_t renderLock;
+    pthread_cond_t renderSignal;
+    BOOL shallDraw;
+}
+
+- (id) setupWithContext: (NSOpenGLContext*) ctx
+       pixelFormat: (NSOpenGLPixelFormat*) pfmt
+       pbuffer: (NSOpenGLPixelBuffer*) p
+       opaque: (Bool) opaque
+       texWidth: (int) texWidth 
+       texHeight: (int) texHeight;
+
+- (void)deallocTex;
+- (void)disableAnimation;
+- (void)releaseLayer;
+- (void)dealloc;
+- (int)getSwapInterval;
+- (void)setSwapInterval:(int)interval;
+- (void)tick;
+
+ at end
+
+#ifndef HAS_CADisplayLink
+
+static CVReturn renderMyNSOpenGLLayer(CVDisplayLinkRef displayLink, 
+                                      const CVTimeStamp *inNow, 
+                                      const CVTimeStamp *inOutputTime, 
+                                      CVOptionFlags flagsIn, 
+                                      CVOptionFlags *flagsOut, 
+                                      void *displayLinkContext)
+{
+    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+    MyNSOpenGLLayer* l = (MyNSOpenGLLayer*)displayLinkContext;
+    pthread_mutex_lock(&l->renderLock);
+    #ifdef DBG_PERF
+        [l tick];
+    #endif
+    pthread_cond_signal(&l->renderSignal);
+    SYNC_PRINT("-*-");
+    pthread_mutex_unlock(&l->renderLock);
+    [pool release];
+    return kCVReturnSuccess;
+}
+
+#endif
+
+ at implementation MyNSOpenGLLayer
+
+- (id) setupWithContext: (NSOpenGLContext*) _ctx
+       pixelFormat: (NSOpenGLPixelFormat*) _fmt
+       pbuffer: (NSOpenGLPixelBuffer*) p
+       opaque: (Bool) opaque
+       texWidth: (int) _texWidth 
+       texHeight: (int) _texHeight;
+{
+    pthread_mutexattr_t renderLockAttr;
+    pthread_mutexattr_init(&renderLockAttr);
+    pthread_mutexattr_settype(&renderLockAttr, PTHREAD_MUTEX_RECURSIVE);
+    pthread_mutex_init(&renderLock, &renderLockAttr); // recursive
+    pthread_cond_init(&renderSignal, NULL); // no attribute
+
+    // no animations for add/remove/swap sublayers etc 
+    [self removeAnimationForKey: kCAOnOrderIn];
+    [self removeAnimationForKey: kCAOnOrderOut];
+    [self removeAnimationForKey: kCATransition];
+
+    pbuffer = p;
+    [pbuffer retain];
+
+    // instantiate a deactivated displayLink
+#ifdef HAS_CADisplayLink
+    displayLink = [[CVDisplayLink displayLinkWithTarget:self selector:@selector(setNeedsDisplay)] retain];
+    [displayLink setPaused: YES];
+#else
+    CVReturn cvres;
+    {
+        int allDisplaysMask = 0;
+        int virtualScreen, accelerated, displayMask;
+        for (virtualScreen = 0; virtualScreen < [_fmt  numberOfVirtualScreens]; virtualScreen++) {
+            [_fmt getValues:&displayMask forAttribute:NSOpenGLPFAScreenMask forVirtualScreen:virtualScreen];
+            [_fmt getValues:&accelerated forAttribute:NSOpenGLPFAAccelerated forVirtualScreen:virtualScreen];
+            if (accelerated) {
+                allDisplaysMask |= displayMask;
+            }
+        }
+        cvres = CVDisplayLinkCreateWithOpenGLDisplayMask(allDisplaysMask, &displayLink);
+        if(kCVReturnSuccess != cvres) {
+            DBG_PRINT("MyNSOpenGLLayer::init %p, CVDisplayLinkCreateWithOpenGLDisplayMask %X failed: %d\n", self, allDisplaysMask, cvres);
+            displayLink = NULL;
+        }
+    }
+    if(NULL != displayLink) {
+        cvres = CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(displayLink, [_ctx CGLContextObj], [_fmt CGLPixelFormatObj]);
+        if(kCVReturnSuccess != cvres) {
+            DBG_PRINT("MyNSOpenGLLayer::init %p, CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext failed: %d\n", self, cvres);
+            displayLink = NULL;
+        }
+    }
+    if(NULL != displayLink) {
+        cvres = CVDisplayLinkSetOutputCallback(displayLink, renderMyNSOpenGLLayer, self);
+        if(kCVReturnSuccess != cvres) {
+            DBG_PRINT("MyNSOpenGLLayer::init %p, CVDisplayLinkSetOutputCallback failed: %d\n", self, cvres);
+            displayLink = NULL;
+        }
+    }
+    if(NULL != displayLink) {
+        CVDisplayLinkStop(displayLink);
+    }
+#endif
+    [self setAsynchronous: YES];
+
+    [self setNeedsDisplayOnBoundsChange: YES]; // FIXME: learn how to recreate on size change!
+    [self setOpaque: opaque ? YES : NO];
+    texWidth = _texWidth;
+    texHeight = _texHeight;
+    textureID = 0;
+    swapInterval = -1;
+    shallDraw = NO;
+
+    CGRect lRect = [self frame];
+
+    DBG_PRINT("MyNSOpenGLLayer::init %p, ctx %p, pfmt %p, pbuffer %p, opaque %d, pbuffer %dx%d -> tex %dx%d, frame: %lf/%lf %lfx%lf (refcnt %d)\n", 
+        self, _ctx, _fmt, pbuffer, opaque, [pbuffer pixelsWide], [pbuffer pixelsHigh], texWidth, texHeight,
+        lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, (int)[self retainCount]);
+    return self;
+}
+
+- (void)disableAnimation
+{
+    DBG_PRINT("MyNSOpenGLLayer::disableAnimation: %p (refcnt %d) - displayLink %p\n", self, (int)[self retainCount], displayLink);
+    pthread_mutex_lock(&renderLock);
+    [self setAsynchronous: NO];
+    if(NULL != displayLink) {
+#ifdef HAS_CADisplayLink
+        [displayLink setPaused: YES];
+        [displayLink release];
+#else
+        if(NULL!=displayLink) {
+            CVDisplayLinkStop(displayLink);
+            CVDisplayLinkRelease(displayLink);
+        }
+#endif
+        displayLink = NULL;
+    }
+    pthread_mutex_unlock(&renderLock);
+}
+
+- (void)deallocTex
+{
+    pthread_mutex_lock(&renderLock);
+    NSOpenGLContext* context = [self openGLContext];
+    DBG_PRINT("MyNSOpenGLLayer::deallocTex %p (refcnt %d) - context %p, pbuffer %p\n", self, (int)[self retainCount], context, pbuffer);
+    if(NULL != pbuffer) {
+        if(NULL!=context) {
+            [context makeCurrentContext];
+            if(0 != textureID) {
+                glDeleteTextures(1, &textureID);
+                textureID = 0;
+            }
+            [context clearDrawable];
+        }
+        [pbuffer release];
+        pbuffer = NULL;
+    }
+    pthread_mutex_unlock(&renderLock);
+}
+
+- (void)releaseLayer
+{
+    DBG_PRINT("MyNSOpenGLLayer::releaseLayer.0: %p (refcnt %d)\n", self, (int)[self retainCount]);
+    pthread_mutex_lock(&renderLock);
+    [self disableAnimation];
+    [self deallocTex];
+    [self release];
+    DBG_PRINT("MyNSOpenGLLayer::releaseLayer.X: %p (refcnt %d)\n", self, (int)[self retainCount]);
+    pthread_mutex_unlock(&renderLock);
+}
+
+- (void)dealloc
+{
+    DBG_PRINT("MyNSOpenGLLayer::dealloc.0 %p (refcnt %d)\n", self, (int)[self retainCount]);
+    // NSLog(@"MyNSOpenGLLayer::dealloc: %@",[NSThread callStackSymbols]);
+
+    [self disableAnimation];
+    [self deallocTex];
+    pthread_cond_destroy(&renderSignal);
+    pthread_mutex_destroy(&renderLock);
+    [super dealloc];
+    DBG_PRINT("MyNSOpenGLLayer::dealloc.X %p\n", self);
+}
+
+- (BOOL)canDrawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat 
+        forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp
+{
+    // assume both methods 'canDrawInOpenGLContext' and 'drawInOpenGLContext' 
+    // are called from the same thread subsequently
+    pthread_mutex_lock(&renderLock);
+    Bool res = NULL != pbuffer && YES == shallDraw;
+    if(!res) {
+        SYNC_PRINT("<0>");
+        pthread_mutex_unlock(&renderLock);
+    } else {
+        SYNC_PRINT("<");
+    }
+    return res;
+}
+
+- (void)drawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat 
+        forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp
+{
+    [context makeCurrentContext];
+   
+    /**
+     * v-sync doesn't works w/ NSOpenGLLayer's context .. well :(
+     * Using CVDisplayLink .. see setSwapInterval() below.
+     *
+    if(0 <= swapInterval) {
+        GLint si;
+        [context getValues: &si forParameter: NSOpenGLCPSwapInterval];
+        if(si != swapInterval) {
+            DBG_PRINT("MyNSOpenGLLayer::drawInOpenGLContext %p setSwapInterval: %d -> %d\n", self, si, swapInterval);
+            [context setValues: &swapInterval forParameter: NSOpenGLCPSwapInterval];
+        }
+    } */
+    GLenum textureTarget = [pbuffer textureTarget];
+    GLfloat tWidth, tHeight;
+    {
+        GLsizei pwidth = [pbuffer pixelsWide];
+        GLsizei pheight = [pbuffer pixelsHigh];
+        tWidth  = textureTarget == GL_TEXTURE_2D ? (GLfloat)pwidth /(GLfloat)texWidth  : pwidth;
+        tHeight = textureTarget == GL_TEXTURE_2D ? (GLfloat)pheight/(GLfloat)texHeight : pheight;
+    }
+    Bool texCreated = 0 == textureID;
+   
+    if(texCreated) {
+        glGenTextures(1, &textureID);
+        DBG_PRINT("MyNSOpenGLLayer::drawInOpenGLContext %p, ctx %p, pfmt %p tex %dx%d -> %fx%f 0x%X: creating texID 0x%X\n", 
+            self, context, pixelFormat, texWidth, texHeight, tWidth, tHeight, textureTarget, textureID);
+
+        CGRect lRect = [self frame];
+        DBG_PRINT("MyNSOpenGLLayer::drawInOpenGLContext %p frame0: %lf/%lf %lfx%lf\n", 
+            self, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height);
+    }
+
+    glBindTexture(textureTarget, textureID);
+
+    /**
+    if(texCreated) {
+      // proper tex size setup
+      glTexImage2D(textureTarget, 0, GL_RGB, texWidth, texHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
+    } */
+
+    [context setTextureImageToPixelBuffer: pbuffer colorBuffer: GL_FRONT];
+
+    glTexParameteri(textureTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+    glTexParameteri(textureTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+    glTexParameteri(textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    glTexParameteri(textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+   
+    glEnable(textureTarget);
+   
+    static GLfloat verts[] = {
+    -1.0, -1.0,
+    -1.0,  1.0,
+     1.0,  1.0,
+     1.0, -1.0
+    };
+   
+    GLfloat tex[] = {
+     0.0,    0.0,
+     0.0,    tHeight,
+     tWidth, tHeight,
+     tWidth, 0.0
+    };
+   
+    glEnableClientState(GL_VERTEX_ARRAY);
+    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+    glVertexPointer(2, GL_FLOAT, 0, verts);
+    glTexCoordPointer(2, GL_FLOAT, 0, tex);
+   
+    glDrawArrays(GL_QUADS, 0, 4);
+   
+    glDisableClientState(GL_VERTEX_ARRAY);
+    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+   
+    glDisable(textureTarget);
+    glBindTexture(textureTarget, 0);
+   
+    [super drawInOpenGLContext: context pixelFormat: pixelFormat forLayerTime: timeInterval displayTime: timeStamp];
+    shallDraw = NO;
+    if(0 >= swapInterval) {
+        pthread_cond_signal(&renderSignal);
+        SYNC_PRINT("*");
+    }
+    SYNC_PRINT("1>");
+    pthread_mutex_unlock(&renderLock);
+}
+
+- (int)getSwapInterval
+{
+    return swapInterval;
+}
+
+- (void)setSwapInterval:(int)interval
+{
+    DBG_PRINT("MyNSOpenGLLayer::setSwapInterval: %d\n", interval);
+    swapInterval = interval;
+    if(0 < swapInterval) {
+        tc = 0;
+        timespec_now(&t0);
+
+        [self setAsynchronous: NO];
+        #ifdef HAS_CADisplayLink
+            [displayLink setPaused: NO];
+            [displayLink setFrameInterval: interval];
+        #else
+            if(NULL!=displayLink) {
+                CVDisplayLinkStart(displayLink);
+                // FIXME: doesn't support interval ..
+            }
+        #endif
+    } else {
+        #ifdef HAS_CADisplayLink
+            [displayLink setPaused: YES];
+        #else
+            if(NULL!=displayLink) {
+                CVDisplayLinkStop(displayLink);
+            }
+        #endif
+        [self setAsynchronous: YES];
+    }
+}
+
+-(void)tick
+{
+    tc++;
+    if(tc%60==0) {
+        struct timespec t1, td;
+        timespec_now(&t1);
+        timespec_subtract(&td, &t1, &t0);
+        long td_ms = timespec_milliseconds(&td);
+        fprintf(stderr, "NSOpenGLLayer: %ld ms / %d frames, %ld ms / frame, %f fps\n",
+            td_ms, tc, td_ms/tc, (tc * 1000.0) / (float)td_ms );
+        fflush(NULL);
+    }
+}
+
+ at end
+
+NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSOpenGLPixelBuffer* p, Bool opaque, int texWidth, int texHeight) {
+  // This simply crashes after dealloc() has been called .. ie. ref-count -> 0 too early ?
+  // However using alloc/init, actual dealloc happens at JAWT destruction, hence too later IMHO.
+  // return [[MyNSOpenGLLayer layer] setupWithContext:ctx pixelFormat: fmt pbuffer: p opaque: opaque texWidth: texWidth texHeight: texHeight];
+
+  return [[[MyNSOpenGLLayer alloc] init] setupWithContext:ctx pixelFormat: fmt pbuffer: p opaque: opaque texWidth: texWidth texHeight: texHeight];
+}
+
+void setNSOpenGLLayerSwapInterval(NSOpenGLLayer* layer, int interval) {
+  MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer;
+  pthread_mutex_lock(&l->renderLock);
+  [l setSwapInterval: interval];
+  pthread_mutex_unlock(&l->renderLock);
+}
+
+void waitUntilNSOpenGLLayerIsReady(NSOpenGLLayer* layer, long to_ms) {
+    MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer;
+    BOOL ready = NO;
+    int wr = 0;
+    pthread_mutex_lock(&l->renderLock);
+    SYNC_PRINT("{");
+    do {
+        if([l getSwapInterval] <= 0) {
+            ready = !l->shallDraw;
+        }
+        if(NO == ready) {
+            if(0 < to_ms) {
+                struct timespec to_abs;
+                timespec_now(&to_abs);
+                timespec_addms(&to_abs, to_ms);
+                wr = pthread_cond_timedwait(&l->renderSignal, &l->renderLock, &to_abs);
+                #ifdef DBG_SYNC
+                    struct timespec t1, td;
+                    timespec_now(&t1);
+                    timespec_subtract(&td, &t1, &to_abs);
+                    long td_ms = timespec_milliseconds(&td);
+                    fprintf(stderr, "%ld ms", td_ms);
+                #endif
+            } else {
+                pthread_cond_wait (&l->renderSignal, &l->renderLock);
+            }
+            ready = !l->shallDraw;
+        }
+    } while (NO == ready && 0 == wr) ;
+    SYNC_PRINT("-%d}", ready);
+    pthread_mutex_unlock(&l->renderLock);
+}
+
+void setNSOpenGLLayerNeedsDisplay(NSOpenGLLayer* layer) {
+  MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer;
+  @synchronized(l) {
+      NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+      pthread_mutex_lock(&l->renderLock);
+      SYNC_PRINT("[");
+      l->shallDraw = YES;
+      if([l getSwapInterval] > 0) {
+          // only trigger update if async mode is off (swapInterval>0)
+          if ( [NSThread isMainThread] == YES ) {
+              [l setNeedsDisplay];
+          } else {
+              // can't wait, otherwise we may deadlock AWT
+              [l performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:NO];
+          }
+          SYNC_PRINT("1]");
+      } else {
+          SYNC_PRINT("0]");
+      }
+      pthread_mutex_unlock(&l->renderLock);
+      // DBG_PRINT("MyNSOpenGLLayer::setNSOpenGLLayerNeedsDisplay %p\n", l);
+      [pool release];
+  }
+}
+
+void releaseNSOpenGLLayer(NSOpenGLLayer* layer) {
+    MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer;
+    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+    DBG_PRINT("MyNSOpenGLLayer::releaseNSOpenGLLayer.0: %p\n", l);
+
+    if ( [NSThread isMainThread] == YES ) {
+        [l releaseLayer];
+    } else { 
+        [l performSelectorOnMainThread:@selector(releaseLayer) withObject:nil waitUntilDone:NO];
+    }
+
+    DBG_PRINT("MyNSOpenGLLayer::releaseNSOpenGLLayer.X: %p\n", l);
+    [pool release];
+}
+
diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface.h b/src/jogl/native/macosx/MacOSXWindowSystemInterface.h
new file mode 100644
index 0000000..138accb
--- /dev/null
+++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface.h
@@ -0,0 +1,20 @@
+#import <Cocoa/Cocoa.h>
+#import <OpenGL/gl.h>
+#import <OpenGL/CGLTypes.h>
+#import <jni.h>
+
+// #define VERBOSE_ON 1
+
+#ifdef VERBOSE_ON
+    #define DBG_PRINT(...) NSLog(@ __VA_ARGS__)
+    // #define DBG_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr)
+#else
+    #define DBG_PRINT(...)
+#endif
+
+#ifndef CGL_VERSION_1_3
+    #warning this SDK doesn't support OpenGL profile
+#endif
+
+#import "macosx-window-system.h"
+
diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m
index 5973ca4..b5979d5 100644
--- a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m
+++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m
@@ -14,13 +14,9 @@
 #endif
 */
 
-#import <Cocoa/Cocoa.h>
-#import <OpenGL/gl.h>
-#import <OpenGL/CGLTypes.h>
-#import <jni.h>
-#import "ContextUpdater.h"
+#import "MacOSXWindowSystemInterface.h"
 
-#import "macosx-window-system.h"
+#import "ContextUpdater.h"
 
 // see MacOSXPbufferGLContext.java createPbuffer
 #define USE_GL_TEXTURE_RECTANGLE_EXT
@@ -44,50 +40,50 @@
 
 struct _RendererInfo
 {
-    long id;                // kCGLRPRendererID
-    long displayMask;        // kCGLRPDisplayMask
+    GLint id;                // kCGLRPRendererID
+    GLint displayMask;        // kCGLRPDisplayMask
     
-    long accelerated;        // kCGLRPAccelerated
+    GLint accelerated;        // kCGLRPAccelerated
     
-    long window;            // kCGLRPWindow
-    long fullscreen;        // kCGLRPFullScreen
-    long multiscreen;        // kCGLRPMultiScreen
-    long offscreen;            // kCGLRPOffScreen
-    long floatPixels;        // see kCGLRPColorModes
-    long stereo;            // kCGLRPBufferModes
+    GLint window;            // kCGLRPWindow
+    GLint fullscreen;        // kCGLRPFullScreen
+    GLint multiscreen;        // kCGLRPMultiScreen
+    GLint offscreen;            // kCGLRPOffScreen
+    GLint floatPixels;        // see kCGLRPColorModes
+    GLint stereo;            // kCGLRPBufferModes
     
-    long auxBuffers;        // kCGLRPMaxAuxBuffers
-    long sampleBuffers;        // kCGLRPMaxSampleBuffers
-    long samples;            // kCGLRPMaxSamples
-    long samplesModes;        // kCGLRPSampleModes
-    long multiSample;        // see kCGLRPSampleModes
-    long superSample;        // see kCGLRPSampleModes
-    long alphaSample;        // kCGLRPSampleAlpha
+    GLint auxBuffers;        // kCGLRPMaxAuxBuffers
+    GLint sampleBuffers;        // kCGLRPMaxSampleBuffers
+    GLint samples;            // kCGLRPMaxSamples
+    GLint samplesModes;        // kCGLRPSampleModes
+    GLint multiSample;        // see kCGLRPSampleModes
+    GLint superSample;        // see kCGLRPSampleModes
+    GLint alphaSample;        // kCGLRPSampleAlpha
     
-    long colorModes;        // kCGLRPColorModes
-    long colorRGBSizeMAX;
-    long colorASizeMAX;
-    long colorFloatRGBSizeMAX;
-    long colorFloatASizeMAX;
-    long colorFloatRGBSizeMIN;
-    long colorFloatASizeMIN;
-    long colorModesCount;
-    long colorFloatModesCount;
-    long depthModes;        // kCGLRPDepthModes
-    long depthSizeMAX;
-    long depthModesCount;
-    long stencilModes;        // kCGLRPStencilModes
-    long stencilSizeMAX;
-    long stencilModesCount;
-    long accumModes;        // kCGLRPAccumModes
-    long accumRGBSizeMAX;
-    long accumASizeMAX;
-    long accumModesCount;
+    GLint colorModes;        // kCGLRPColorModes
+    GLint colorRGBSizeMAX;
+    GLint colorASizeMAX;
+    GLint colorFloatRGBSizeMAX;
+    GLint colorFloatASizeMAX;
+    GLint colorFloatRGBSizeMIN;
+    GLint colorFloatASizeMIN;
+    GLint colorModesCount;
+    GLint colorFloatModesCount;
+    GLint depthModes;        // kCGLRPDepthModes
+    GLint depthSizeMAX;
+    GLint depthModesCount;
+    GLint stencilModes;        // kCGLRPStencilModes
+    GLint stencilSizeMAX;
+    GLint stencilModesCount;
+    GLint accumModes;        // kCGLRPAccumModes
+    GLint accumRGBSizeMAX;
+    GLint accumASizeMAX;
+    GLint accumModesCount;
 }
 typedef RendererInfo;
 
 RendererInfo *gRenderers = NULL;
-long gRenderersCount = 0;
+GLint gRenderersCount = 0;
 
 long depthModes[] = {
                     kCGL0Bit,
@@ -372,7 +368,7 @@ long validateParameter(NSOpenGLPixelFormatAttribute attribute, long value)
   return value;
 }
 
-void* createPixelFormat(int* iattrs, int niattrs, int* ivalues) {
+NSOpenGLPixelFormat* createPixelFormat(int* iattrs, int niattrs, int* ivalues) {
   NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
 
   getRendererInfo();
@@ -385,6 +381,18 @@ void* createPixelFormat(int* iattrs, int niattrs, int* ivalues) {
   for (i = 0; i < niattrs && iattrs[i]>0; i++) {
     int attr = iattrs[i];
     switch (attr) {
+      case NSOpenGLPFANoRecovery:
+        if (ivalues[i] != 0) {
+          attribs[idx++] = NSOpenGLPFANoRecovery;
+        }
+        break;
+
+      case NSOpenGLPFAAccelerated:
+        if (ivalues[i] != 0) {
+          attribs[idx++] = NSOpenGLPFAAccelerated;
+        }
+        break;
+
       case NSOpenGLPFAPixelBuffer:
         if (ivalues[i] != 0) {
           attribs[idx++] = NSOpenGLPFAPixelBuffer;
@@ -409,6 +417,9 @@ void* createPixelFormat(int* iattrs, int niattrs, int* ivalues) {
         }
         break;
 
+#ifdef CGL_VERSION_1_3
+      case kCGLPFAOpenGLProfile:
+#endif
       case NSOpenGLPFAColorSize:
       case NSOpenGLPFAAlphaSize:
       case NSOpenGLPFADepthSize:
@@ -443,12 +454,11 @@ void* createPixelFormat(int* iattrs, int niattrs, int* ivalues) {
   return fmt;
 }
 
-void queryPixelFormat(void* pixelFormat, int* iattrs, int niattrs, int* ivalues) {
+void queryPixelFormat(NSOpenGLPixelFormat* fmt, int* iattrs, int niattrs, int* ivalues) {
   NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
-  NSOpenGLPixelFormat* fmt = (NSOpenGLPixelFormat*) pixelFormat;
-  long tmp;
+  GLint tmp;
   // FIXME: think about how specifying this might affect the API
-  int virtualScreen = 0;
+  GLint virtualScreen = 0;
 
   int i;
   for (i = 0; i < niattrs && iattrs[i]>0; i++) {
@@ -460,16 +470,43 @@ void queryPixelFormat(void* pixelFormat, int* iattrs, int niattrs, int* ivalues)
   [pool release];
 }
   
-void deletePixelFormat(void* pixelFormat) {
+void deletePixelFormat(NSOpenGLPixelFormat* fmt) {
   NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
-  NSOpenGLPixelFormat* fmt = (NSOpenGLPixelFormat*) pixelFormat;
   [fmt release];
   [pool release];
 }
 
-void* createContext(void* shareContext,
-                    void* view,
-                    void* pixelFormat,
+NSOpenGLContext* getCurrentContext() {
+  NSOpenGLContext *ctx = NULL;
+    
+  NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+  ctx = [NSOpenGLContext currentContext];
+  [pool release];
+  return ctx;
+}
+
+CGLContextObj getCGLContext(NSOpenGLContext* ctx) {
+  void * cglContext = NULL;
+    
+  NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+  cglContext = [ctx CGLContextObj];
+  [pool release];
+  return cglContext;
+}
+
+NSView* getNSView(NSOpenGLContext* ctx) {
+  NSView* view = NULL;
+    
+  NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+  view = [ctx view];
+  [pool release];
+  return view;
+}
+
+NSOpenGLContext* createContext(NSOpenGLContext* share,
+                    NSView* view,
+                    Bool isBackingLayerView,
+                    NSOpenGLPixelFormat* fmt,
                     Bool opaque,
                     int* viewNotReady)
 {
@@ -477,27 +514,22 @@ void* createContext(void* shareContext,
     
     NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
 
-    NSView *nsView = NULL;
-    NSObject *nsObj = (NSObject*) view;
-
-    if( nsObj != NULL && [nsObj isKindOfClass:[NSView class]] ) {
-        nsView = (NSView*)nsObj;
-    }
-
-    if (nsView != NULL)
-    {
+    if (view != NULL) {
         Bool viewReady = true;
 
-        if ([nsView lockFocusIfCanDraw] == NO)
-        {
-            viewReady = false;
+        if(!isBackingLayerView) {
+            if ([view lockFocusIfCanDraw] == NO) {
+                DBG_PRINT("createContext [view lockFocusIfCanDraw] failed\n");
+                viewReady = false;
+            }
         }
-        else
-        {
-            NSRect frame = [nsView frame];
-            if ((frame.size.width == 0) || (frame.size.height == 0))
-            {
-                [nsView unlockFocus];        
+        if(viewReady) {
+            NSRect frame = [view frame];
+            if ((frame.size.width == 0) || (frame.size.height == 0)) {
+                if(!isBackingLayerView) {
+                    [view unlockFocus];
+                }
+                DBG_PRINT("createContext view.frame size %dx%d\n", (int)frame.size.width, (int)frame.size.height);
                 viewReady = false;
             }
         }
@@ -515,124 +547,108 @@ void* createContext(void* shareContext,
         }
     }
     
-    NSOpenGLContext* nsContext = [[NSOpenGLContext alloc]
-                                       initWithFormat: (NSOpenGLPixelFormat*) pixelFormat
-                                       shareContext:   (NSOpenGLContext*) shareContext];
+    NSOpenGLContext* ctx = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:share];
         
-        if (nsContext != nil) {
-          if (nsView != nil) {
-            if(!opaque) {
-                long zeroOpacity = 0;
-                [nsContext setValues:&zeroOpacity forParameter:NSOpenGLCPSurfaceOpacity];
-            }
-            [nsContext setView:nsView];
-            [nsView unlockFocus];        
-          }
+    if (ctx != nil) {
+      if (view != nil) {
+        if(!opaque) {
+            GLint zeroOpacity = 0;
+            [ctx setValues:&zeroOpacity forParameter:NSOpenGLCPSurfaceOpacity];
         }
+        [ctx setView:view];
+        if(!isBackingLayerView) {
+            [view unlockFocus];        
+        }
+      }
+    }
 
     [pool release];
-    return nsContext;
-}
-
-void * getCurrentContext() {
-  NSOpenGLContext *nsContext = NULL;
-    
-  NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
-  nsContext = [NSOpenGLContext currentContext];
-  [pool release];
-  return nsContext;;
+    return ctx;
 }
 
-void * getCGLContext(void* nsJContext) {
-  NSOpenGLContext *nsContext = (NSOpenGLContext*)nsJContext;
-  void * cglContext = NULL;
-    
-  NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
-  cglContext = [nsContext CGLContextObj];
-  [pool release];
-  return cglContext;
-}
-
-void * getNSView(void* nsJContext) {
-  NSOpenGLContext *nsContext = (NSOpenGLContext*)nsJContext;
-  void * view = NULL;
-    
+Bool makeCurrentContext(NSOpenGLContext* ctx) {
+#if 0
+  // we issue the CGL Lock from Java upfront!
   NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
-  view = [nsContext view];
+  CGLError cglError = CGLLockContext([ctx CGLContextObj]);
+  if(0 == cglError) {
+      [ctx makeCurrentContext];
+  }
   [pool release];
-  return view;
-}
-
-Bool makeCurrentContext(void* nsJContext) {
-  NSOpenGLContext *nsContext = (NSOpenGLContext*)nsJContext;
-    
+  return 0 == cglError;
+#else
   NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
-  [nsContext makeCurrentContext];
+  [ctx makeCurrentContext];
   [pool release];
   return true;
+#endif
 }
 
-Bool clearCurrentContext(void* nsJContext) {
-  NSOpenGLContext *nsContext = (NSOpenGLContext*)nsJContext;
-
+Bool clearCurrentContext(NSOpenGLContext* ctx) {
   NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
   NSOpenGLContext *currentNSContext = [NSOpenGLContext currentContext];
-  if( currentNSContext != nsContext ) {
-      [nsContext makeCurrentContext];
+  if( currentNSContext != ctx ) {
+      [ctx makeCurrentContext];
   }
   [NSOpenGLContext clearCurrentContext];
+#if 0
+  // we issue the CGL Lock from Java upfront!
+  CGLUnlockContext([ctx CGLContextObj]);
+#endif
   [pool release];
   return true;
 }
 
-Bool deleteContext(void* nsJContext) {
-  NSOpenGLContext *nsContext = (NSOpenGLContext*)nsJContext;
-    
+Bool deleteContext(NSOpenGLContext* ctx, Bool releaseOnMainThread) {
   NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
-  [nsContext clearDrawable];
-  [nsContext release];
+  [ctx clearDrawable];
+  if(releaseOnMainThread && NO == [NSThread isMainThread]) {
+      [ctx performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];
+  } else {
+      // would hangs for ~10s for 1 of a shared context set or offscreen context, set releaseOnMainThread=true !
+      [ctx release]; 
+  }
   [pool release];
   return true;
 }
 
-Bool flushBuffer(void* nsJContext) {
-  NSOpenGLContext *nsContext = (NSOpenGLContext*)nsJContext;
-    
+Bool flushBuffer(NSOpenGLContext* ctx) {
   NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
-  [nsContext flushBuffer];
+  [ctx flushBuffer];
   [pool release];
   return true;
 }
 
-void setContextOpacity(void* nsJContext, int opacity) {
-  NSOpenGLContext *nsContext = (NSOpenGLContext*)nsJContext;
-  
-  [nsContext setValues:&opacity forParameter:NSOpenGLCPSurfaceOpacity];
+void setContextOpacity(NSOpenGLContext* ctx, int opacity) {
+  [ctx setValues:&opacity forParameter:NSOpenGLCPSurfaceOpacity];
 }
 
-void updateContext(void* nsJContext) {
-  NSOpenGLContext *nsContext = (NSOpenGLContext*)nsJContext;
-    
+void updateContext(NSOpenGLContext* ctx) {
   NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
-  [nsContext update];
+  [ctx update];
   [pool release];
 }
 
-void copyContext(void* destContext, void* srcContext, int mask) {
-  NSOpenGLContext *src = (NSOpenGLContext*) srcContext;
-  NSOpenGLContext *dst = (NSOpenGLContext*) destContext;
-  [dst copyAttributesFromContext: src withMask: mask];
+void copyContext(NSOpenGLContext* dest, NSOpenGLContext* src, int mask) {
+  [dest copyAttributesFromContext: src withMask: mask];
+}
+
+void* updateContextRegister(NSOpenGLContext* ctx, NSView* view) {
+  NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+  ContextUpdater *contextUpdater = [[ContextUpdater alloc] initWithContext: ctx view: view];
+  [pool release];
+  return contextUpdater;
 }
 
-void* updateContextRegister(void* nsJContext, void* view) {
-  NSOpenGLContext *nsContext = (NSOpenGLContext*)nsJContext;
-  NSView *nsView = (NSView*)view;
+Bool updateContextNeedsUpdate(void* updater) {
+  ContextUpdater *contextUpdater = (ContextUpdater *)updater;
+  BOOL res;
     
   NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
-  ContextUpdater *contextUpdater = [[ContextUpdater alloc] init];
-  [contextUpdater registerFor:nsContext with:nsView];
+  res = [contextUpdater needsUpdate];
   [pool release];
-  return NULL;
+
+  return ( res == TRUE ) ? true : false;
 }
 
 void updateContextUnregister(void* updater) {
@@ -643,7 +659,7 @@ void updateContextUnregister(void* updater) {
   [pool release];
 }
 
-void* createPBuffer(int renderTarget, int internalFormat, int width, int height) {
+NSOpenGLPixelBuffer* createPBuffer(int renderTarget, int internalFormat, int width, int height) {
   NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
   NSOpenGLPixelBuffer* pBuffer = [[NSOpenGLPixelBuffer alloc]
                                    initWithTextureTarget:renderTarget
@@ -655,41 +671,25 @@ void* createPBuffer(int renderTarget, int internalFormat, int width, int height)
   return pBuffer;
 }
 
-Bool destroyPBuffer(void* buffer) {
-  /* FIXME: not clear whether we need to perform the clearDrawable below */
-  NSOpenGLPixelBuffer *pBuffer = (NSOpenGLPixelBuffer*)buffer;
-    
+Bool destroyPBuffer(NSOpenGLPixelBuffer* pBuffer) {
   NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
-  /*
-  if (nsContext != NULL) {
-    [nsContext clearDrawable];
-  }
-  */
   [pBuffer release];
   [pool release];
-    
   return true;
 }
 
-void setContextPBuffer(void* nsJContext, void* buffer) {
-  NSOpenGLContext *nsContext = (NSOpenGLContext*)nsJContext;
-  NSOpenGLPixelBuffer *pBuffer = (NSOpenGLPixelBuffer*)buffer;
-
+void setContextPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* pBuffer) {
   NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
-  [nsContext setPixelBuffer: pBuffer
+  [ctx setPixelBuffer: pBuffer
              cubeMapFace: 0
              mipMapLevel: 0
-             currentVirtualScreen: [nsContext currentVirtualScreen]];
+             currentVirtualScreen: [ctx currentVirtualScreen]];
   [pool release];
 }
 
-void setContextTextureImageToPBuffer(void* nsJContext, void* buffer, int colorBuffer) {
-  NSOpenGLContext *nsContext = (NSOpenGLContext*)nsJContext;
-  NSOpenGLPixelBuffer *pBuffer = (NSOpenGLPixelBuffer*)buffer;
-
+void setContextTextureImageToPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* pBuffer, GLenum colorBuffer) {
   NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
-  [nsContext setTextureImageToPixelBuffer: pBuffer
-             colorBuffer: (unsigned long) colorBuffer];
+  [ctx setTextureImageToPixelBuffer: pBuffer colorBuffer: colorBuffer];
   [pool release];
 }
 
@@ -729,10 +729,9 @@ void* getProcAddress(const char *procname) {
   return NULL;
 }
 
-void setSwapInterval(void* nsJContext, int interval) {
-  NSOpenGLContext *nsContext = (NSOpenGLContext*)nsJContext;
-  long swapInterval = interval;
-  [nsContext setValues: &swapInterval forParameter: NSOpenGLCPSwapInterval];
+void setSwapInterval(NSOpenGLContext* ctx, int interval) {
+  GLint swapInterval = interval;
+  [ctx setValues: &swapInterval forParameter: NSOpenGLCPSwapInterval];
 }
 
 Bool setGammaRamp(int tableSize, float* redRamp, float* greenRamp, float* blueRamp) {
diff --git a/src/jogl/native/timespec.c b/src/jogl/native/timespec.c
new file mode 100644
index 0000000..74c1a69
--- /dev/null
+++ b/src/jogl/native/timespec.c
@@ -0,0 +1,63 @@
+#include "timespec.h"
+#include <sys/time.h>
+
+void timespec_now(struct timespec *ts)
+{
+    struct timeval  tv;
+
+    // not using clock_gettime() [of rt library] due to portability
+    gettimeofday(&tv, NULL);
+    ts->tv_sec  = tv.tv_sec;
+    ts->tv_nsec = tv.tv_usec*1000;  
+}
+
+void timespec_addms(struct timespec *ts, long ms)
+{
+    int sec=ms/1000;
+    ms=ms-sec*1000;
+
+    // perform the addition
+    ts->tv_nsec+=ms*1000000;
+
+    // adjust the time
+    ts->tv_sec+=ts->tv_nsec/1000000000 + sec;
+    ts->tv_nsec=ts->tv_nsec%1000000000;
+}
+
+void timespec_addns(struct timespec *ts, long ns)
+{
+    int sec=ns/1000000000;
+    ns=ns - sec*1000000000;
+
+    // perform the addition
+    ts->tv_nsec+=ns;
+
+    // adjust the time
+    ts->tv_sec+=ts->tv_nsec/1000000000 + sec;
+    ts->tv_nsec=ts->tv_nsec%1000000000;
+
+}
+
+int timespec_compare(struct timespec *a, struct timespec *b)
+{
+    if (a->tv_sec!=b->tv_sec)
+        return a->tv_sec-b->tv_sec;
+    return a->tv_nsec-b->tv_nsec;
+}
+
+void timespec_subtract(struct timespec *r, struct timespec *a, struct timespec *b)
+{
+    r->tv_sec = a->tv_sec;
+    r->tv_nsec = a->tv_nsec - b->tv_nsec;
+    if (r->tv_nsec < 0) {
+        // borrow.
+        r->tv_nsec += 1000000000;
+        r->tv_sec --;
+    }
+    r->tv_sec = r->tv_sec - b->tv_sec;
+}
+
+long timespec_milliseconds(struct timespec *a) 
+{
+    return a->tv_sec*1000 + a->tv_nsec/1000000;
+}
diff --git a/src/jogl/native/timespec.h b/src/jogl/native/timespec.h
new file mode 100644
index 0000000..671eb47
--- /dev/null
+++ b/src/jogl/native/timespec.h
@@ -0,0 +1,19 @@
+#ifndef _timespec_h
+#define _timespec_h
+
+#include <time.h>
+
+void timespec_now(struct timespec *ts);
+void timespec_addms(struct timespec *ts, long ms);
+void timespec_addns(struct timespec *ts, long ns);
+
+/** returns 0: a==b, >0: a>b, <0: a<b */
+int timespec_compare(struct timespec *a, struct timespec *b);
+
+/** computes r = a - b */
+void timespec_subtract(struct timespec *r, struct timespec *a, struct timespec *b);
+
+/** convert the timespec into milliseconds (may overflow) */
+long timespec_milliseconds(struct timespec *a);
+
+#endif /* _timespec_h */
diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java
index 784343c..1930bdd 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
  * 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -50,7 +51,7 @@ public interface AbstractGraphicsConfiguration extends Cloneable {
 
     /**
      * Return the capabilities reflecting this graphics configuration,
-     * which may differ from the capabilites used to choose this configuration.
+     * which may differ from the capabilities used to choose this configuration.
      *
      * @return An immutable instance of the Capabilities to avoid mutation by
      * the user.
@@ -61,7 +62,7 @@ public interface AbstractGraphicsConfiguration extends Cloneable {
      * Return the capabilities used to choose this graphics configuration.
      *
      * These may be used to reconfigure the NativeWindow in case
-     * the device changes in a multi screen environment.
+     * the device changes in a multiple screen environment.
      *
      * @return An immutable instance of the Capabilities to avoid mutation by
      * the user.
@@ -69,10 +70,10 @@ public interface AbstractGraphicsConfiguration extends Cloneable {
     public CapabilitiesImmutable getRequestedCapabilities();
 
     /**
-     * In case this instance already reflects a native configuration,
-     * return this one.
-     * Otherwise return the encapsuled native configuration, 
-     * as it shall be included e.g. in the AWT case.
+     * In case the implementation utilizes a delegation pattern to wrap abstract toolkits,
+     * this method shall return the native {@link AbstractGraphicsConfiguration},
+     * otherwise this instance.
+     * @see NativeSurface#getGraphicsConfiguration()
      */
     public AbstractGraphicsConfiguration getNativeGraphicsConfiguration();
 }
diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java
index 83b4376..fa25c21 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java
@@ -110,14 +110,15 @@ public interface AbstractGraphicsDevice extends Cloneable {
     public void unlock();
 
     /**
-     * Optionally closing the device.<br>
-     * The default implementation is a NOP operation, returning false.<br>
+     * Optionally closing the device.
+     * <p>
+     * The default implementation is a <code>NOP</code>, just setting the handle to <code>null</code>.
+     * </p>
      * The specific implementing, ie {@link javax.media.nativewindow.x11.X11GraphicsDevice},
      * shall have a enable/disable like {@link javax.media.nativewindow.x11.X11GraphicsDevice#setCloseDisplay(boolean, boolean)},<br>
      * which shall be invoked at creation time to determine ownership/role of freeing the resource.<br>
      *
-     * @return true if a specialized closing operation was successfully issued, otherwise false,
-     * ie no native closing operation was issued, which doesn't imply an error at all.
+     * @return true if the handle was not <code>null</code>, otherwise false.
      */
     public boolean close();
 }
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
index ffa8bfa..3eb7a6c 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
@@ -84,8 +84,6 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics
      * The use case for setting the Capabilities at a later time is
      * a change of the graphics device in a multi-screen environment.<br>
      *
-     * The objects reference is being used.
-     *
      * @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
      */
     protected void setChosenCapabilities(CapabilitiesImmutable capsChosen) {
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java
index c2aa6fa..187959a 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java
@@ -46,7 +46,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice
 
     /**
      * Create an instance with the system default {@link ToolkitLock},
-     * gathered via {@link NativeWindowFactory#createDefaultToolkitLock()}.
+     * gathered via {@link NativeWindowFactory#getDefaultToolkitLock(String)}.
      * @param type
      */
     public DefaultGraphicsDevice(String type, String connection, int unitID) {
@@ -55,12 +55,12 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice
         this.unitID = unitID;
         this.uniqueID = getUniqueID(type, connection, unitID);
         this.handle = 0;
-        setToolkitLock( NativeWindowFactory.getDefaultToolkitLock(type) );
+        this.toolkitLock = NativeWindowFactory.getDefaultToolkitLock(type);
     }
 
     /**
      * Create an instance with the system default {@link ToolkitLock}.
-     * gathered via {@link NativeWindowFactory#createDefaultToolkitLock()}.
+     * gathered via {@link NativeWindowFactory#createDefaultToolkitLock(String, long)}.
      * @param type
      * @param handle
      */
@@ -70,7 +70,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice
         this.unitID = unitID;
         this.uniqueID = getUniqueID(type, connection, unitID);
         this.handle = handle;
-        setToolkitLock( NativeWindowFactory.createDefaultToolkitLock(type, handle) );
+        this.toolkitLock = NativeWindowFactory.createDefaultToolkitLock(type, handle);
     }
 
     /**
@@ -85,7 +85,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice
         this.unitID = unitID;
         this.uniqueID = getUniqueID(type, connection, unitID);
         this.handle = handle;
-        setToolkitLock( locker );
+        this.toolkitLock = null != locker ? locker : NativeWindowFactoryImpl.getNullToolkitLock();
     }
 
     @Override
@@ -140,6 +140,10 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice
     }
 
     public boolean close() {
+        if(0 != handle) {
+            handle = 0;
+            return true;
+        }
         return false;
     }
 
@@ -152,10 +156,21 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice
      * Set the internal ToolkitLock, which is used within the
      * {@link #lock()} and {@link #unlock()} implementation.
      *
+     * <p>
+     * The current ToolkitLock is being locked/unlocked while swapping the reference,
+     * ensuring no concurrent access can occur during the swap.
+     * </p>
+     * 
      * @param locker the ToolkitLock, if null, {@link jogamp.nativewindow.NullToolkitLock} is being used
      */
     protected void setToolkitLock(ToolkitLock locker) {
-        this.toolkitLock = ( null == locker ) ? NativeWindowFactoryImpl.getNullToolkitLock() : locker ;
+        final ToolkitLock _toolkitLock = toolkitLock;
+        _toolkitLock.lock();
+        try {
+            toolkitLock = ( null == locker ) ? NativeWindowFactoryImpl.getNullToolkitLock() : locker ;
+        } finally {
+            _toolkitLock.unlock();
+        }
     }
 
     /**
diff --git a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
index fa3923d..2596444 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
@@ -40,7 +40,6 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
-
 /**
  * Provides the mechanism by which the graphics configuration for a
  * window can be chosen before the window is created. The graphics 
@@ -60,12 +59,34 @@ import java.util.Map;
 public abstract class GraphicsConfigurationFactory {
     protected static final boolean DEBUG = Debug.debug("GraphicsConfiguration");
 
-    private static Map/*<Class, NativeWindowFactory>*/ registeredFactories =
-        Collections.synchronizedMap(new HashMap());
-    private static Class abstractGraphicsDeviceClass;
+    private static Map<Class<?>, GraphicsConfigurationFactory> registeredFactories =
+        Collections.synchronizedMap(new HashMap<Class<?>, GraphicsConfigurationFactory>());
+    private static Class<?> abstractGraphicsDeviceClass;
 
     static {
-        initialize();
+        abstractGraphicsDeviceClass = javax.media.nativewindow.AbstractGraphicsDevice.class;
+        
+        // Register the default no-op factory for arbitrary
+        // AbstractGraphicsDevice implementations, including
+        // AWTGraphicsDevice instances -- the OpenGL binding will take
+        // care of handling AWTGraphicsDevices on X11 platforms (as
+        // well as X11GraphicsDevices in non-AWT situations)
+        registerFactory(abstractGraphicsDeviceClass, new DefaultGraphicsConfigurationFactoryImpl());
+        
+        if (NativeWindowFactory.TYPE_X11.equals(NativeWindowFactory.getNativeWindowType(true))) {
+            try {
+                ReflectionUtil.callStaticMethod("jogamp.nativewindow.x11.X11GraphicsConfigurationFactory", 
+                                                "registerFactory", null, null, GraphicsConfigurationFactory.class.getClassLoader());                
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+            if(NativeWindowFactory.isAWTAvailable()) {
+                try {
+                    ReflectionUtil.callStaticMethod("jogamp.nativewindow.x11.awt.X11AWTGraphicsConfigurationFactory", 
+                                                    "registerFactory", null, null, GraphicsConfigurationFactory.class.getClassLoader());                
+                } catch (Exception e) { /* n/a */ }
+            }
+        }
     }
 
     protected static String getThreadName() {
@@ -85,27 +106,6 @@ public abstract class GraphicsConfigurationFactory {
     protected GraphicsConfigurationFactory() {
     }
 
-    private static void initialize() {
-        abstractGraphicsDeviceClass = javax.media.nativewindow.AbstractGraphicsDevice.class;
-        
-        if (NativeWindowFactory.TYPE_X11.equals(NativeWindowFactory.getNativeWindowType(true))) {
-            try {
-                GraphicsConfigurationFactory factory = (GraphicsConfigurationFactory)
-                    ReflectionUtil.createInstance("jogamp.nativewindow.x11.X11GraphicsConfigurationFactory", null,
-                                                  GraphicsConfigurationFactory.class.getClassLoader());
-                registerFactory(javax.media.nativewindow.x11.X11GraphicsDevice.class, factory);
-            } catch (Exception e) {
-                throw new RuntimeException(e);
-            }
-        }
-        // Register the default no-op factory for arbitrary
-        // AbstractGraphicsDevice implementations, including
-        // AWTGraphicsDevice instances -- the OpenGL binding will take
-        // care of handling AWTGraphicsDevices on X11 platforms (as
-        // well as X11GraphicsDevices in non-AWT situations)
-        registerFactory(abstractGraphicsDeviceClass, new DefaultGraphicsConfigurationFactoryImpl());
-    }
-
     /** Returns the factory for use with the given type of
         AbstractGraphicsDevice. */
     public static GraphicsConfigurationFactory getFactory(AbstractGraphicsDevice device) {
@@ -122,7 +122,7 @@ public abstract class GraphicsConfigurationFactory {
      *
      * @throws IllegalArgumentException if the given class does not implement AbstractGraphicsDevice
      */
-    public static GraphicsConfigurationFactory getFactory(Class abstractGraphicsDeviceImplementor)
+    public static GraphicsConfigurationFactory getFactory(Class<?> abstractGraphicsDeviceImplementor)
         throws IllegalArgumentException, NativeWindowException
     {
         if (!(abstractGraphicsDeviceClass.isAssignableFrom(abstractGraphicsDeviceImplementor))) {
@@ -130,10 +130,9 @@ public abstract class GraphicsConfigurationFactory {
         }
 
         GraphicsConfigurationFactory factory = null;
-        Class clazz = abstractGraphicsDeviceImplementor;
+        Class<?> clazz = abstractGraphicsDeviceImplementor;
         while (clazz != null) {
-            factory =
-                (GraphicsConfigurationFactory) registeredFactories.get(clazz);
+            factory = registeredFactories.get(clazz);
             if (factory != null) {
                 if(DEBUG) {
                     System.err.println("GraphicsConfigurationFactory.getFactory() "+abstractGraphicsDeviceImplementor+" -> "+factory);
@@ -143,7 +142,7 @@ public abstract class GraphicsConfigurationFactory {
             clazz = clazz.getSuperclass();
         }
         // Return the default
-        factory = (GraphicsConfigurationFactory)registeredFactories.get(abstractGraphicsDeviceClass);
+        factory = registeredFactories.get(abstractGraphicsDeviceClass);
         if(DEBUG) {
             System.err.println("GraphicsConfigurationFactory.getFactory() DEFAULT "+abstractGraphicsDeviceClass+" -> "+factory);
         }
@@ -157,7 +156,7 @@ public abstract class GraphicsConfigurationFactory {
      *
      * @throws IllegalArgumentException if the given class does not implement AbstractGraphicsDevice
      */
-    protected static void registerFactory(Class abstractGraphicsDeviceImplementor, GraphicsConfigurationFactory factory)
+    protected static void registerFactory(Class<?> abstractGraphicsDeviceImplementor, GraphicsConfigurationFactory factory)
         throws IllegalArgumentException
     {
         if (!(abstractGraphicsDeviceClass.isAssignableFrom(abstractGraphicsDeviceImplementor))) {
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
index e691ba8..e255dc0 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
@@ -118,6 +118,24 @@ public interface NativeSurface extends SurfaceUpdatedListener {
    */
   public boolean surfaceSwap();
 
+  /** Appends the given {@link SurfaceUpdatedListener} to the end of the list. */
+  public void addSurfaceUpdatedListener(SurfaceUpdatedListener l);
+
+  /**
+   * Inserts the given {@link SurfaceUpdatedListener} at the
+   * specified position in the list.<br>
+   *
+   * @param index Position where the listener will be inserted.
+   * Should be within (0 <= index && index <= size()).
+   * An index value of -1 is interpreted as the end of the list, size().
+   * @param l The listener object to be inserted
+   * @throws IndexOutOfBoundsException If the index is not within (0 <= index && index <= size()), or -1
+   */
+  public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException;
+
+  /** Remove the specified {@link SurfaceUpdatedListener} from the list. */
+  public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l);
+  
   /**
    * Returns the handle to the surface for this NativeSurface. <P>
    * 
@@ -149,6 +167,11 @@ public interface NativeSurface extends SurfaceUpdatedListener {
 
   /**
    * Returns the graphics configuration corresponding to this window.
+   * <p>
+   * In case the implementation utilizes a delegation pattern to wrap abstract toolkits,
+   * this method shall return the native {@link AbstractGraphicsConfiguration} via {@link AbstractGraphicsConfiguration#getNativeGraphicsConfiguration()}.
+   * </p>
+   * @see AbstractGraphicsConfiguration#getNativeGraphicsConfiguration()
    * @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
    */
   public AbstractGraphicsConfiguration getGraphicsConfiguration();
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java
index 76ac729..2bc3521 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java
@@ -104,20 +104,26 @@ public interface NativeWindow extends NativeSurface {
   
   /** 
    * @return the current x position of the top-left corner
-   *         of the client area, hence excluding insets (window decorations).<br> 
+   *         of the client area relative to it's parent. 
+   *         Since the position reflects the client area, it does not include the insets.
    * @see #getInsets()
    */
   public int getX();
 
   /** 
    * @return the current y position of the top-left corner
-   *         of the client area, hence excluding insets (window decorations).<br> 
+   *         of the client area relative to it's parent. 
+   *         Since the position reflects the client area, it does not include the insets.
    * @see #getInsets()
    */
   public int getY();
 
   /** 
-   * Returns the current absolute location of this window. 
+   * Returns the current position of the top-left corner 
+   * of the client area in screen coordinates.
+   * <p>
+   * Since the position reflects the client area, it does not include the insets.
+   * </p> 
    * @param point if not null,
    *        {@link javax.media.nativewindow.util.Point#translate(javax.media.nativewindow.util.Point)}
    *        the passed {@link javax.media.nativewindow.util.Point} by this location on the screen and return it.
@@ -126,4 +132,7 @@ public interface NativeWindow extends NativeSurface {
    */
   public Point getLocationOnScreen(Point point);
   
+  /** Returns true if this native window owns the focus, otherwise false. */
+  boolean hasFocus();
+  
 }
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
index ef8876f..c69b18b 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
@@ -33,15 +33,20 @@
 
 package javax.media.nativewindow;
 
-import java.security.*;
-import java.util.*;
-
-import com.jogamp.common.util.*;
-import com.jogamp.common.os.Platform;
-
-import jogamp.nativewindow.*;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import jogamp.nativewindow.Debug;
+import jogamp.nativewindow.NativeWindowFactoryImpl;
+
+import com.jogamp.common.os.Platform;
+import com.jogamp.common.util.ReflectionUtil;
 
 /** Provides a pluggable mechanism for arbitrary window toolkits to
     adapt their components to the {@link NativeWindow} interface,
@@ -75,20 +80,25 @@ public abstract class NativeWindowFactory {
 
     private static NativeWindowFactory defaultFactory;
     private static Map<Class<?>, NativeWindowFactory> registeredFactories;
+    
     private static Class<?> nativeWindowClass;
     private static String nativeWindowingTypePure;
     private static String nativeWindowingTypeCustom;
     private static boolean isAWTAvailable;
-    public static final String AWTComponentClassName = "java.awt.Component" ;
-    public static final String JAWTUtilClassName = "jogamp.nativewindow.jawt.JAWTUtil" ;
-    public static final String X11UtilClassName = "jogamp.nativewindow.x11.X11Util";
-    public static final String OSXUtilClassName = "jogamp.nativewindow.macosx.OSXUtil";
-    public static final String GDIClassName = "jogamp.nativewindow.windows.GDI";
-    public static final String X11JAWTToolkitLockClassName = "jogamp.nativewindow.jawt.x11.X11JAWTToolkitLock" ;
-    public static final String X11ToolkitLockClassName = "jogamp.nativewindow.x11.X11ToolkitLock" ;
+    
+    private static final String JAWTUtilClassName = "jogamp.nativewindow.jawt.JAWTUtil" ;
+    private static final String X11UtilClassName = "jogamp.nativewindow.x11.X11Util";
+    private static final String OSXUtilClassName = "jogamp.nativewindow.macosx.OSXUtil";
+    private static final String GDIClassName = "jogamp.nativewindow.windows.GDIUtil";
+    
     private static Class<?>  jawtUtilClass;
     private static Method jawtUtilGetJAWTToolkitMethod;
     private static Method jawtUtilInitMethod;
+    
+    public static final String AWTComponentClassName = "java.awt.Component" ;
+    public static final String X11JAWTToolkitLockClassName = "jogamp.nativewindow.jawt.x11.X11JAWTToolkitLock" ;
+    public static final String X11ToolkitLockClassName = "jogamp.nativewindow.x11.X11ToolkitLock" ;
+    
     private static Class<?>  x11JAWTToolkitLockClass;
     private static Constructor<?> x11JAWTToolkitLockConstructor;
     private static Class<?>  x11ToolkitLockClass;
@@ -132,16 +142,18 @@ public abstract class NativeWindowFactory {
 
     static boolean initialized = false;
 
-    private static void initNativeImpl(final boolean firstUIActionOnProcess, final ClassLoader cl) {
+    private static void initSingletonNativeImpl(final boolean firstUIActionOnProcess, final ClassLoader cl) {
         isFirstUIActionOnProcess = firstUIActionOnProcess;
-
-        String clazzName = null;
+        
+        final String clazzName;
         if( TYPE_X11.equals(nativeWindowingTypePure) ) {
             clazzName = X11UtilClassName;
         } else if( TYPE_WINDOWS.equals(nativeWindowingTypePure) ) {
             clazzName = GDIClassName;
         } else if( TYPE_MACOSX.equals(nativeWindowingTypePure) ) {
             clazzName = OSXUtilClassName;
+        } else {
+            clazzName = null;
         }
         if( null != clazzName ) {
             ReflectionUtil.callStaticMethod(clazzName, "initSingleton",
@@ -152,7 +164,7 @@ public abstract class NativeWindowFactory {
             requiresToolkitLock = res.booleanValue();             
         } else {            
             requiresToolkitLock = false;
-        }
+        }        
     }
 
     /**
@@ -178,6 +190,8 @@ public abstract class NativeWindowFactory {
                 System.err.println(Thread.currentThread().getName()+" - NativeWindowFactory.initSingleton("+firstUIActionOnProcess+")");
             }
 
+            final ClassLoader cl = NativeWindowFactory.class.getClassLoader();
+
             // Gather the windowing OS first
             AccessControlContext acc = AccessController.getContext();
             nativeWindowingTypePure = _getNativeWindowingType();
@@ -188,12 +202,10 @@ public abstract class NativeWindowFactory {
                 nativeWindowingTypeCustom = tmp;
             }
 
-            final ClassLoader cl = NativeWindowFactory.class.getClassLoader();
-
             if(firstUIActionOnProcess) {
                 // X11 initialization before possible AWT initialization
-                initNativeImpl(true, cl);
-            }
+                initSingletonNativeImpl(true, cl);
+            }            
             isAWTAvailable = false; // may be set to true below
 
             if( !Debug.getBooleanProperty("java.awt.headless", true, acc) &&
@@ -203,7 +215,7 @@ public abstract class NativeWindowFactory {
                 AccessController.doPrivileged(new PrivilegedAction<Object>() {
                     public Object run() {
                         try {
-                            jawtUtilClass = Class.forName(JAWTUtilClassName, false, NativeWindowFactory.class.getClassLoader());
+                            jawtUtilClass = Class.forName(JAWTUtilClassName, true, NativeWindowFactory.class.getClassLoader());
                             jawtUtilInitMethod = jawtUtilClass.getDeclaredMethod("initSingleton", (Class[])null);
                             jawtUtilInitMethod.setAccessible(true);
                             jawtUtilGetJAWTToolkitMethod = jawtUtilClass.getDeclaredMethod("getJAWTToolkitLock", new Class[]{});
@@ -227,7 +239,7 @@ public abstract class NativeWindowFactory {
             }
             if(!firstUIActionOnProcess) {
                 // X11 initialization after possible AWT initialization
-                initNativeImpl(false, cl);
+                initSingletonNativeImpl(false, cl);
             }
             registeredFactories = Collections.synchronizedMap(new HashMap<Class<?>, NativeWindowFactory>());
 
@@ -260,6 +272,21 @@ public abstract class NativeWindowFactory {
         }
     }
 
+    public static synchronized void shutdown() {
+        if(initialized) {
+            initialized = false;
+            if(DEBUG) {
+                System.err.println(Thread.currentThread().getName()+" - NativeWindowFactory.shutdown() START");                
+            }
+            registeredFactories.clear();
+            registeredFactories = null;
+            // X11Util.shutdown(..) already called via GLDrawableFactory.shutdown() ..
+            if(DEBUG) {
+                System.err.println(Thread.currentThread().getName()+" - NativeWindowFactory.shutdown() END");                
+            }
+        }
+    }
+    
     /** @return true if initialized with <b>{@link #initSingleton(boolean) initSingleton(firstUIActionOnProcess==true)}</b>,
         otherwise false. */
     public static boolean isFirstUIActionOnProcess() {
@@ -319,31 +346,30 @@ public abstract class NativeWindowFactory {
      * <ul>
      *   <li> If {@link #initSingleton(boolean) initSingleton( <b>firstUIActionOnProcess := false</b> )} </li>
      *   <ul>
-     *     <li>If native <b>X11 type</b> with or w/o AWT</li>
-     *     <ul>
-     *       <li> If <b>AWT available</b> </li>
+     *     <li>If <b>AWT-type</b> and <b>native-X11-type</b> and <b>AWT-available</b></li>
      *       <ul>
      *         <li> return {@link jogamp.nativewindow.jawt.JAWTToolkitLock} </li>
      *       </ul>
-     *     </ul>
      *   </ul>
      *   <li> Otherwise return {@link jogamp.nativewindow.NullToolkitLock} </li>
      * </ul>
      */
     public static ToolkitLock getDefaultToolkitLock(String type) {
         if( requiresToolkitLock() ) {
-            if( TYPE_X11 == type || TYPE_AWT == type && TYPE_X11 == getNativeWindowType(false) ) {
-                if( isAWTAvailable() ) {
-                    return getAWTToolkitLock();
-                }
+            if( TYPE_AWT == type && TYPE_X11 == getNativeWindowType(false) && isAWTAvailable() ) {
+                return getAWTToolkitLock();
             }
         }
         return NativeWindowFactoryImpl.getNullToolkitLock();
     }
 
-    protected static ToolkitLock getAWTToolkitLock() {
+    private static ToolkitLock getAWTToolkitLock() {
         Object resO = ReflectionUtil.callMethod(null, jawtUtilGetJAWTToolkitMethod);
 
+        if(DEBUG) {
+            System.err.println("NativeWindowFactory.getAWTToolkitLock()");
+            Thread.dumpStack();
+        }            
         if(resO instanceof ToolkitLock) {
             return (ToolkitLock) resO;
         } else {
@@ -363,26 +389,49 @@ public abstract class NativeWindowFactory {
      *   <ul>
      *     <li>If <b>X11 type</b> </li>
      *     <ul>
-     *       <li> If <b>AWT available</b> </li>
+     *       <li> return {@link jogamp.nativewindow.x11.X11ToolkitLock} </li>
+     *     </ul>
+     *   </ul>
+     *   <li> Otherwise return {@link jogamp.nativewindow.NullToolkitLock} </li>
+     * </ul>
+     */
+    public static ToolkitLock createDefaultToolkitLock(String type, long deviceHandle) {
+        if( requiresToolkitLock() ) {
+            if( TYPE_X11 == type ) {
+                if( 0== deviceHandle ) {
+                    throw new RuntimeException("JAWTUtil.createDefaultToolkitLock() called with NULL device but on X11");
+                }
+                return createX11ToolkitLock(deviceHandle);
+            }
+        }
+        return NativeWindowFactoryImpl.getNullToolkitLock();
+    }
+    
+    /**
+     * Creates the default {@link ToolkitLock} for <code>type</code> and <code>deviceHandle</code>.
+     * <br>
+     * <ul>
+     *   <li> If {@link #initSingleton(boolean) initSingleton( <b>firstUIActionOnProcess := false</b> )} </li>
+     *   <ul>
+     *     <li>If <b>X11 type</b> </li>
+     *     <ul>
+     *       <li> If <b>shared-AWT-type</b> and <b>AWT available</b> </li>
      *       <ul>
      *         <li> return {@link jogamp.nativewindow.jawt.x11.X11JAWTToolkitLock} </li>
      *       </ul>
-     *       <li> If <b>AWT not available</b> </li>
-     *       <ul>
-     *         <li> return {@link jogamp.nativewindow.x11.X11ToolkitLock} </li>
-     *       </ul>
+     *       <li> else return {@link jogamp.nativewindow.x11.X11ToolkitLock} </li>
      *     </ul>
      *   </ul>
      *   <li> Otherwise return {@link jogamp.nativewindow.NullToolkitLock} </li>
      * </ul>
      */
-    public static ToolkitLock createDefaultToolkitLock(String type, long deviceHandle) {
+    public static ToolkitLock createDefaultToolkitLock(String type, String sharedType, long deviceHandle) {
         if( requiresToolkitLock() ) {
             if( TYPE_X11 == type ) {
                 if( 0== deviceHandle ) {
                     throw new RuntimeException("JAWTUtil.createDefaultToolkitLock() called with NULL device but on X11");
                 }
-                if( isAWTAvailable() ) {
+                if( TYPE_AWT == sharedType && isAWTAvailable() ) {
                     return createX11AWTToolkitLock(deviceHandle);
                 }
                 return createX11ToolkitLock(deviceHandle);
@@ -393,6 +442,10 @@ public abstract class NativeWindowFactory {
 
     protected static ToolkitLock createX11AWTToolkitLock(long deviceHandle) {
         try {
+            if(DEBUG) {
+                System.err.println("NativeWindowFactory.createX11AWTToolkitLock(0x"+Long.toHexString(deviceHandle)+")");
+                Thread.dumpStack();
+            }            
             return (ToolkitLock) x11JAWTToolkitLockConstructor.newInstance(new Object[]{new Long(deviceHandle)});
         } catch (Exception ex) {
             throw new RuntimeException(ex);
@@ -470,4 +523,37 @@ public abstract class NativeWindowFactory {
         NativeWindow. Implementors of concrete NativeWindowFactory
         subclasses should override this method. */
     protected abstract NativeWindow getNativeWindowImpl(Object winObj, AbstractGraphicsConfiguration config) throws IllegalArgumentException;
+    
+    /**
+     * Returns the {@link OffscreenLayerSurface} instance of this {@link NativeSurface}.
+     * <p>
+     * In case this surface is a {@link NativeWindow}, we traverse from the given surface 
+     * up to root until an implementation of {@link OffscreenLayerSurface} is found.
+     * In case <code>ifEnabled</code> is true, the surface must also implement {@link OffscreenLayerOption}
+     * where {@link OffscreenLayerOption#isOffscreenLayerSurfaceEnabled()} is <code>true</code>.  
+     * </p>
+     * 
+     * @param surface The surface to query.
+     * @param ifEnabled If true, only return the enabled {@link OffscreenLayerSurface}, see {@link OffscreenLayerOption#isOffscreenLayerSurfaceEnabled()}. 
+     * @return
+     */
+    public static OffscreenLayerSurface getOffscreenLayerSurface(NativeSurface surface, boolean ifEnabled) {
+        if(surface instanceof OffscreenLayerSurface && 
+           ( !ifEnabled || surface instanceof OffscreenLayerOption ) ) {
+            final OffscreenLayerSurface ols = (OffscreenLayerSurface) surface;
+            return ( !ifEnabled || ((OffscreenLayerOption)ols).isOffscreenLayerSurfaceEnabled() ) ? ols : null;
+        }
+        if(surface instanceof NativeWindow) {
+            NativeWindow nw = ((NativeWindow) surface).getParent();
+            while(null != nw) {
+                if(nw instanceof OffscreenLayerSurface &&
+                   ( !ifEnabled || nw instanceof OffscreenLayerOption ) ) {
+                    final OffscreenLayerSurface ols = (OffscreenLayerSurface) nw;
+                    return ( !ifEnabled || ((OffscreenLayerOption)ols).isOffscreenLayerSurfaceEnabled() ) ? ols : null;
+                }
+                nw = nw.getParent();                
+            }
+        }
+        return null;            
+    }
 }
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerOption.java
similarity index 56%
copy from src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java
copy to src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerOption.java
index 0d6da7b..12d30b3 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerOption.java
@@ -25,48 +25,37 @@
  * authors and should not be interpreted as representing official policies, either expressed
  * or implied, of JogAmp Community.
  */
-
-package jogamp.opengl.util.glsl;
-
-import javax.media.opengl.GL;
-import javax.media.opengl.GL2ES2;
-import javax.media.opengl.GLArrayData;
-
-import jogamp.opengl.util.GLArrayHandler;
-
-import com.jogamp.opengl.util.glsl.ShaderState;
+package javax.media.nativewindow;
 
 /**
- * Used for interleaved GLSL arrays, i.e. where the buffer data itself is handled 
- * separately and interleaves many arrays.
+ * Handling requests for using an {@link OffscreenLayerSurface}
+ * within the implementation.
  */
-public class GLSLArrayHandlerFlat implements GLArrayHandler {
-  private GLArrayData ad;
-
-  public GLSLArrayHandlerFlat(GLArrayData ad) {
-    this.ad = ad;
-  }
-
-  public final void addSubHandler(GLArrayHandler handler) {
-      throw new UnsupportedOperationException();
-  }
-  
-  public final void syncData(GL gl, boolean enable, Object ext) {
-    final ShaderState st = (ShaderState) ext;
-    if(enable) {
-        st.vertexAttribPointer(gl.getGL2ES2(), ad);
-    }
-  }
-
-  public final void enableState(GL gl, boolean enable, Object ext) {
-    final GL2ES2 glsl = gl.getGL2ES2();
-    final ShaderState st = (ShaderState) ext;
-    
-    if(enable) {
-        st.enableVertexAttribArray(glsl, ad);
-    } else {
-        st.disableVertexAttribArray(glsl, ad);
-    }
-  }  
-}
-
+public interface OffscreenLayerOption {
+    /** 
+     * Request an offscreen layer, if supported.
+     * <p>
+     * Shall be called before the first {@link NativeWindow#lockSurface()},
+     * and hence before realization.
+     * </p>
+     * 
+     * @see #getShallUseOffscreenLayer()
+     * @see #isOffscreenLayerSurfaceEnabled() 
+     */
+    public void setShallUseOffscreenLayer(boolean v);
+
+    /** Returns the property set by {@link #setShallUseOffscreenLayer(boolean)}. */
+    public boolean getShallUseOffscreenLayer();
+
+    /** 
+     * Returns true if this instance uses an offscreen layer, otherwise false.
+     * <p>
+     * This instance is an offscreen layer, if {@link #setShallUseOffscreenLayer(boolean) setShallUseOffscreenLayer(true)}
+     * has been called before it's realization and first lock and the underlying implementation supports it.
+     * </p>
+     * The return value is undefined before issuing the first {@link NativeWindow#lockSurface()}.
+     *  
+     * @see #setShallUseOffscreenLayer(boolean) 
+     */
+    public boolean isOffscreenLayerSurfaceEnabled();
+}
\ No newline at end of file
diff --git a/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java
similarity index 63%
copy from src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java
copy to src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java
index 2b6d3c0..dd36509 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java
@@ -1,16 +1,16 @@
 /**
- * Copyright 2010 JogAmp Community. All rights reserved.
+ * Copyright 2011 JogAmp Community. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without modification, are
  * permitted provided that the following conditions are met:
- * 
+ *
  *    1. Redistributions of source code must retain the above copyright notice, this list of
  *       conditions and the following disclaimer.
- * 
+ *
  *    2. Redistributions in binary form must reproduce the above copyright notice, this list
  *       of conditions and the following disclaimer in the documentation and/or other materials
  *       provided with the distribution.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,34 +20,29 @@
  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
+ *
  * The views and conclusions contained in the software and documentation are those of the
  * authors and should not be interpreted as representing official policies, either expressed
  * or implied, of JogAmp Community.
  */
- 
-
-package jogamp.nativewindow;
+package javax.media.nativewindow;
 
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-import com.jogamp.common.jvm.JNILibLoaderBase;
-import com.jogamp.common.util.cache.TempJarCache;
-
-public class NWJNILibLoader extends JNILibLoaderBase {
+/**
+ * Interface specifying the offscreen layer surface protocol.
+ */
+public interface OffscreenLayerSurface {
+  /** 
+   * Attach the offscreen layer to this offscreen layer surface.
+   * @see #isOffscreenLayerSurfaceEnabled()
+   * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false
+   */
+  public void attachSurfaceLayer(final long layerHandle) throws NativeWindowException;
   
-  public static void loadNativeWindow(final String ossuffix) {
-    AccessController.doPrivileged(new PrivilegedAction<Object>() {
-      public Object run() {
-        final String libName = "nativewindow_"+ossuffix ;
-        if(TempJarCache.isInitialized() && null == TempJarCache.findLibrary(libName)) {
-            addNativeJarLibs(NWJNILibLoader.class, "jogl.all", "jogl-all", new String[] { "nativewindow" } );
-        }
-        loadLibrary(libName, false);
-        return null;
-      }
-    });
-  }
-
+  /** 
+   * Detaches a previously attached offscreen layer from this offscreen layer surface.
+   * @see #attachSurfaceLayer(long)
+   * @see #isOffscreenLayerSurfaceEnabled()
+   * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false
+   */
+  public void detachSurfaceLayer(final long layerHandle) throws NativeWindowException;
 }
diff --git a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
index e344762..9100bea 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
@@ -28,12 +28,15 @@
 
 package javax.media.nativewindow;
 
+import jogamp.nativewindow.SurfaceUpdatedHelper;
+
 import com.jogamp.common.util.locks.LockFactory;
 import com.jogamp.common.util.locks.RecursiveLock;
 
 public abstract class ProxySurface implements NativeSurface {
+    private SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper();
+    private AbstractGraphicsConfiguration config; // control access due to delegation
     protected RecursiveLock surfaceLock = LockFactory.createRecursiveLock();
-    protected AbstractGraphicsConfiguration config;
     protected long displayHandle;
     protected int height;
     protected int scrnIndex;
@@ -42,7 +45,7 @@ public abstract class ProxySurface implements NativeSurface {
     public ProxySurface(AbstractGraphicsConfiguration cfg) {
         invalidate();
         config = cfg;
-        displayHandle=cfg.getScreen().getDevice().getHandle();
+        displayHandle=cfg.getNativeGraphicsConfiguration().getScreen().getDevice().getHandle();
     }
 
     void invalidate() {
@@ -55,12 +58,16 @@ public abstract class ProxySurface implements NativeSurface {
         return displayHandle;
     }
 
-    public final AbstractGraphicsConfiguration getGraphicsConfiguration() {
+    protected final AbstractGraphicsConfiguration getPrivateGraphicsConfiguration() {
         return config;
     }
+    
+    public final AbstractGraphicsConfiguration getGraphicsConfiguration() {
+        return config.getNativeGraphicsConfiguration();
+    }
 
     public final int getScreenIndex() {
-        return config.getScreen().getIndex();
+        return getGraphicsConfiguration().getScreen().getIndex();
     }
 
     public abstract long getSurfaceHandle();
@@ -73,7 +80,7 @@ public abstract class ProxySurface implements NativeSurface {
         return height;
     }
 
-    public void setSize(int width, int height) {
+    public void surfaceSizeChanged(int width, int height) {
         this.width = width;
         this.height = height;
     }
@@ -82,16 +89,29 @@ public abstract class ProxySurface implements NativeSurface {
         return false;
     }
 
-    public void surfaceUpdated(Object updater, NativeSurface ns, long when) {
+    public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+        surfaceUpdatedHelper.addSurfaceUpdatedListener(l);
     }
 
+    public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException {
+        surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l);
+    }
+
+    public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+        surfaceUpdatedHelper.removeSurfaceUpdatedListener(l);
+    }
+
+    public void surfaceUpdated(Object updater, NativeSurface ns, long when) {
+        surfaceUpdatedHelper.surfaceUpdated(updater, ns, when);
+    }    
+    
     public int lockSurface() throws NativeWindowException {
         surfaceLock.lock();
         int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ?
 
         if ( LOCK_SURFACE_NOT_READY == res ) {
             try {
-                final AbstractGraphicsDevice adevice = config.getScreen().getDevice();
+                final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice();
                 adevice.lock();
                 try {
                     res = lockSurfaceImpl();
@@ -113,7 +133,7 @@ public abstract class ProxySurface implements NativeSurface {
         surfaceLock.validateLocked();
 
         if (surfaceLock.getHoldCount() == 1) {
-            final AbstractGraphicsDevice adevice = config.getScreen().getDevice();
+            final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice();
             try {
                 unlockSurfaceImpl();
             } finally {
@@ -143,5 +163,5 @@ public abstract class ProxySurface implements NativeSurface {
         return surfaceLock.getOwner();
     }
 
-    public abstract String toString();
+    public abstract String toString();    
 }
diff --git a/src/nativewindow/classes/javax/media/nativewindow/SurfaceChangeable.java b/src/nativewindow/classes/javax/media/nativewindow/SurfaceChangeable.java
index fc32b57..956e68e 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/SurfaceChangeable.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/SurfaceChangeable.java
@@ -41,8 +41,14 @@ package javax.media.nativewindow;
 
 public interface SurfaceChangeable {
 
+  /** Sets the surface handle which is created outside of this implementation */
   public void setSurfaceHandle(long surfaceHandle);
-  public void setSize(int width, int height);
+  
+  /** 
+   * The surface's size has been determined or changed. 
+   * Implementation shall update the stored surface size with the given ones. 
+   */  
+  public void surfaceSizeChanged(int width, int height);
 
 }
 
diff --git a/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java b/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java
index 88e805d..0912b5a 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java
@@ -34,8 +34,12 @@
 
 package javax.media.nativewindow;
 
+/**
+ * Clients may add their SurfaceUpdateListener implementation to a {@link javax.media.nativewindow.NativeSurface}
+ * allowing to get notified after the surface has been updated, eg. after a swap buffer operation.
+ */
 public interface SurfaceUpdatedListener {
-    /** Notification of a surface update event. 
+    /** Notification of a surface update event, eg. after a swap buffer operation.
      *
      * @param updater is the caller object who updated the surface,
      *                e.g. a JOGL GLDrawable.
diff --git a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java
index d83a92a..45a3db8 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java
@@ -41,11 +41,13 @@
 package javax.media.nativewindow.awt;
 
 import javax.media.nativewindow.*;
+
 import java.awt.Component;
 import java.awt.GraphicsConfiguration;
 import java.awt.GraphicsDevice;
 import java.awt.image.ColorModel;
 import javax.media.nativewindow.AbstractGraphicsConfiguration;
+
 import jogamp.nativewindow.Debug;
 
 /** A wrapper for an AWT GraphicsConfiguration allowing it to be
@@ -63,56 +65,61 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple
     this.encapsulated=encapsulated;
   }
 
-  public AWTGraphicsConfiguration(AWTGraphicsScreen screen, CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested,
-                                  GraphicsConfiguration config) {
+  private AWTGraphicsConfiguration(AWTGraphicsScreen screen, CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested,
+                                   GraphicsConfiguration config) {
     super(screen, capsChosen, capsRequested);
     this.config = config;
     this.encapsulated=null;
   }
-
+  
   /**
    * @param capsChosen if null, <code>capsRequested</code> is copied and aligned 
-   *        with the graphics capabilties of the AWT Component to produce the chosen Capabilties.
+   *        with the graphics Capabilities of the AWT Component to produce the chosen Capabilities.
    *        Otherwise the <code>capsChosen</code> is used.
    */
-  public static AWTGraphicsConfiguration create(Component awtComp, CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested)
-  {
-      AWTGraphicsScreen awtScreen = null;
-      AWTGraphicsDevice awtDevice = null;
-      GraphicsDevice awtGraphicsDevice = null;
-      GraphicsConfiguration awtGfxConfig = awtComp.getGraphicsConfiguration();
-      if(null!=awtGfxConfig) {
-          awtGraphicsDevice = awtGfxConfig.getDevice();
-          if(null!=awtGraphicsDevice) {
-              // Create Device/Screen
-              awtDevice = new AWTGraphicsDevice(awtGraphicsDevice, AbstractGraphicsDevice.DEFAULT_UNIT);
-              awtScreen = new AWTGraphicsScreen(awtDevice);
-          }
+  public static AWTGraphicsConfiguration create(Component awtComp, CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested) {
+      final GraphicsConfiguration awtGfxConfig = awtComp.getGraphicsConfiguration();
+      if(null==awtGfxConfig) {
+          throw new NativeWindowException("AWTGraphicsConfiguration.create: Null AWT GraphicsConfiguration @ "+awtComp);          
       }
-      if(null==awtScreen) {
-          // use defaults since no native peer is available yet
-          awtScreen = (AWTGraphicsScreen) AWTGraphicsScreen.createScreenDevice(-1, AbstractGraphicsDevice.DEFAULT_UNIT);
-          awtDevice = (AWTGraphicsDevice) awtScreen.getDevice();
-          awtGraphicsDevice = awtDevice.getGraphicsDevice();
+      final GraphicsDevice awtGraphicsDevice = awtGfxConfig.getDevice();
+      if(null==awtGraphicsDevice) {
+          throw new NativeWindowException("AWTGraphicsConfiguration.create: Null AWT GraphicsDevice @ "+awtGfxConfig);
       }
 
+      // Create Device/Screen
+      final AWTGraphicsDevice awtDevice = new AWTGraphicsDevice(awtGraphicsDevice, AbstractGraphicsDevice.DEFAULT_UNIT);
+      final AWTGraphicsScreen awtScreen = new AWTGraphicsScreen(awtDevice);
+
       if(null==capsChosen) {
           GraphicsConfiguration gc = awtGraphicsDevice.getDefaultConfiguration();
-          capsChosen = setupCapabilitiesRGBABits(capsChosen, gc);
+          capsChosen = AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capsRequested, gc);
+      }
+      final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(awtDevice);
+      final AbstractGraphicsConfiguration config = factory.chooseGraphicsConfiguration(capsChosen, capsRequested, null, awtScreen);
+      if(config instanceof AWTGraphicsConfiguration) {
+          return (AWTGraphicsConfiguration) config;
       }
+      // System.err.println("Info: AWTGraphicsConfiguration.create: Expected AWTGraphicsConfiguration got: "+config.getClass()+" w/ factory "+factory.getClass()+" - Unable to encapsulate native GraphicsConfiguration.");
       return new AWTGraphicsConfiguration(awtScreen, capsChosen, capsRequested, awtGfxConfig);
   }
 
-    @Override
+  // open access to superclass method
+  public void setChosenCapabilities(CapabilitiesImmutable capsChosen) {
+      super.setChosenCapabilities(capsChosen);
+  }
+  
+  @Override
   public Object clone() {
       return super.clone();
   }
 
-  public GraphicsConfiguration getGraphicsConfiguration() {
+  /** Return the AWT {@link GraphicsConfiguration}. */
+  public GraphicsConfiguration getAWTGraphicsConfiguration() {
     return config;
   }
 
-    @Override
+  @Override
   public AbstractGraphicsConfiguration getNativeGraphicsConfiguration() {
     return (null!=encapsulated)?encapsulated:this;
   }
@@ -156,7 +163,7 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple
     return capabilities;
   }
 
-    @Override
+  @Override
   public String toString() {
     return getClass().getSimpleName()+"[" + getScreen() +
                                    ",\n\tchosen    " + capabilitiesChosen+
diff --git a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsDevice.java
index 66a63bf..8ebe376 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsDevice.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsDevice.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
  * 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -46,26 +47,20 @@ import javax.media.nativewindow.AbstractGraphicsDevice;
 
 /** A wrapper for an AWT GraphicsDevice allowing it to be
     handled in a toolkit-independent manner. */
-
 public class AWTGraphicsDevice extends DefaultGraphicsDevice implements Cloneable {
   private GraphicsDevice device;
-  private String subType;
 
-  protected AWTGraphicsDevice(GraphicsDevice device, int unitID) {
+  public AWTGraphicsDevice(GraphicsDevice device, int unitID) {
     super(NativeWindowFactory.TYPE_AWT, device.getIDstring(), unitID);
     this.device = device;
-    this.subType = null;
   }
 
-  public static AbstractGraphicsDevice createDevice(GraphicsDevice awtDevice, int unitID) {
-    if(null==awtDevice) {
-        awtDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
-        unitID = AbstractGraphicsDevice.DEFAULT_UNIT; 
-    }
-    return new AWTGraphicsDevice(awtDevice, unitID);
+  public static AWTGraphicsDevice createDefault() {
+    GraphicsDevice awtDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
+    return new AWTGraphicsDevice(awtDevice, AbstractGraphicsDevice.DEFAULT_UNIT);
   }
 
-    @Override
+  @Override
   public Object clone() {
       return super.clone();
   }
@@ -74,26 +69,9 @@ public class AWTGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl
     return device;
   }
 
-  /**
-   * In case the native handle was specified, e.g. using X11,
-   * we shall be able to mark it.<br>
-   * This will also set the subType, queried with {@link #getSubType()}
-   * and reset the ToolkitLock type with {@link NativeWindowFactory#createDefaultToolkitLock(java.lang.String, long)}
-   * and {@link #setToolkitLock(javax.media.nativewindow.ToolkitLock)}.
-   */
-  public void setSubType(String subType, long handle) {
-    this.handle = handle;
-    this.subType = subType;
-    setToolkitLock( NativeWindowFactory.createDefaultToolkitLock(subType, handle) );
-  }
-
-  public String getSubType() {
-    return subType;
-  }
-
-    @Override
+  @Override
   public String toString() {
-    return getClass().getSimpleName()+"[type "+getType()+"[subType "+getSubType()+"], connection "+getConnection()+", unitID "+getUnitID()+", awtDevice "+device+", handle 0x"+Long.toHexString(getHandle())+"]";
+    return getClass().getSimpleName()+"[type "+getType()+", connection "+getConnection()+", unitID "+getUnitID()+", awtDevice "+device+", handle 0x"+Long.toHexString(getHandle())+"]";
   }
 }
 
diff --git a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsScreen.java
index 383dcae..2978d78 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsScreen.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsScreen.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
  * 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -42,7 +43,6 @@ package javax.media.nativewindow.awt;
 import java.awt.GraphicsDevice;
 import java.awt.GraphicsEnvironment;
 import javax.media.nativewindow.*;
-import javax.media.nativewindow.AbstractGraphicsDevice;
 
 /** A wrapper for an AWT GraphicsDevice (screen) allowing it to be
     handled in a toolkit-independent manner. */
@@ -74,17 +74,15 @@ public class AWTGraphicsScreen extends DefaultGraphicsScreen implements Cloneabl
   }
 
   public static AbstractGraphicsScreen createScreenDevice(GraphicsDevice awtDevice, int unitID) {
-    AWTGraphicsDevice device = (AWTGraphicsDevice) AWTGraphicsDevice.createDevice(awtDevice, unitID);
-    return new AWTGraphicsScreen(device);
+    return new AWTGraphicsScreen(new AWTGraphicsDevice(awtDevice, unitID));
   }
 
   public static AbstractGraphicsScreen createScreenDevice(int index, int unitID) {
-    GraphicsDevice awtDevice = getScreenDevice(index);
-    return createScreenDevice(awtDevice, unitID);
+    return createScreenDevice(getScreenDevice(index), unitID);
   }
 
   public static AbstractGraphicsScreen createDefault() {
-    return createScreenDevice(-1, AbstractGraphicsDevice.DEFAULT_UNIT);
+    return new AWTGraphicsScreen(AWTGraphicsDevice.createDefault());
   }
 
   public Object clone() {
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java
index 0a5036e..c53b169 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java
@@ -97,4 +97,10 @@ public class Point implements Cloneable, PointImmutable {
         return this;
     }
 
+    public Point scale(int sx, int sy) {
+        x *= sx ;
+        y *= sy ;
+        return this;
+    }
+    
 }
diff --git a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsConfiguration.java
index 100b6b8..7443933 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsConfiguration.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
  * 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -32,8 +33,9 @@
 
 package javax.media.nativewindow.x11;
 
-import javax.media.nativewindow.*;
+import javax.media.nativewindow.CapabilitiesImmutable;
 
+import jogamp.nativewindow.MutableGraphicsConfiguration;
 import jogamp.nativewindow.x11.XVisualInfo;
 
 /** Encapsulates a graphics configuration, or OpenGL pixel format, on
@@ -42,7 +44,7 @@ import jogamp.nativewindow.x11.XVisualInfo;
     GraphicsConfigurationFactory.chooseGraphicsConfiguration()} on X11
     platforms when toolkits other than the AWT are being used.  */
 
-public class X11GraphicsConfiguration extends DefaultGraphicsConfiguration implements Cloneable {
+public class X11GraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable {
     private XVisualInfo info;
 
     public X11GraphicsConfiguration(X11GraphicsScreen screen, 
diff --git a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsDevice.java
index 48fd63e..73c8cfd 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsDevice.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsDevice.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
  * 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -33,6 +34,7 @@
 package javax.media.nativewindow.x11;
 
 import jogamp.nativewindow.Debug;
+import jogamp.nativewindow.x11.X11Lib;
 import jogamp.nativewindow.x11.X11Util;
 import javax.media.nativewindow.DefaultGraphicsDevice;
 import javax.media.nativewindow.NativeWindowException;
@@ -44,49 +46,49 @@ import javax.media.nativewindow.ToolkitLock;
 
 public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneable {
     public static final boolean DEBUG = Debug.debug("GraphicsDevice");
-    boolean closeDisplay = false;
+    final boolean closeDisplay;
 
     /** Constructs a new X11GraphicsDevice corresponding to the given connection and default
-     *  {@link javax.media.nativewindow.ToolkitLock} via {@link NativeWindowFactory#createDefaultToolkitLock(java.lang.String, long)}.<br>
+     *  {@link javax.media.nativewindow.ToolkitLock} via {@link NativeWindowFactory#getDefaultToolkitLock(String)}.<br>
      *  Note that this is not an open connection, ie no native display handle exist.
      *  This constructor exist to setup a default device connection.
+     *  @see DefaultGraphicsDevice#DefaultGraphicsDevice(String, String, int)
      */
     public X11GraphicsDevice(String connection, int unitID) {
         super(NativeWindowFactory.TYPE_X11, connection, unitID);
+        closeDisplay = false;
     }
 
     /** Constructs a new X11GraphicsDevice corresponding to the given native display handle and default
-     *  {@link javax.media.nativewindow.ToolkitLock} via {@link NativeWindowFactory#createDefaultToolkitLock(java.lang.String, long)}.
+     *  {@link javax.media.nativewindow.ToolkitLock} via {@link NativeWindowFactory#createDefaultToolkitLock(String, long)}.
+     *  @see DefaultGraphicsDevice#DefaultGraphicsDevice(String, String, int, long)
      */
-    public X11GraphicsDevice(long display, int unitID) {
+    public X11GraphicsDevice(long display, int unitID, boolean owner) {
         // FIXME: derive unitID from connection could be buggy, one DISPLAY for all screens for example..
-        super(NativeWindowFactory.TYPE_X11, X11Util.XDisplayString(display), unitID, display);
+        super(NativeWindowFactory.TYPE_X11, X11Lib.XDisplayString(display), unitID, display);
         if(0==display) {
             throw new NativeWindowException("null display");
         }
+        closeDisplay = owner;
     }
 
     /**
      * @param display the Display connection
      * @param locker custom {@link javax.media.nativewindow.ToolkitLock}, eg to force null locking in NEWT
+     * @see DefaultGraphicsDevice#DefaultGraphicsDevice(String, String, int, long, ToolkitLock)
      */
-    public X11GraphicsDevice(long display, int unitID, ToolkitLock locker) {
-        super(NativeWindowFactory.TYPE_X11, X11Util.XDisplayString(display), unitID, display, locker);
+    public X11GraphicsDevice(long display, int unitID, ToolkitLock locker, boolean owner) {
+        super(NativeWindowFactory.TYPE_X11, X11Lib.XDisplayString(display), unitID, display, locker);
         if(0==display) {
             throw new NativeWindowException("null display");
         }
+        closeDisplay = owner;
     }
 
     public Object clone() {
       return super.clone();
     }
 
-    public void setCloseDisplay(boolean close) {
-        closeDisplay = close;
-        if(DEBUG && close) {
-            System.err.println(Thread.currentThread().getName() + " - X11GraphicsDevice.setCloseDisplay(true): "+this);
-        }
-    }
     public boolean close() {
         // FIXME: shall we respect the unitID ?
         if(closeDisplay && 0 != handle) {
@@ -94,10 +96,8 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl
                 System.err.println(Thread.currentThread().getName() + " - X11GraphicsDevice.close(): "+this);
             }
             X11Util.closeDisplay(handle);
-            handle = 0;
-            return true;
         }
-        return false;
+        return super.close();
     }
 }
 
diff --git a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java
index ffe84cb..6473b9f 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
  * 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -33,6 +34,8 @@
 package javax.media.nativewindow.x11;
 
 import javax.media.nativewindow.*;
+
+import jogamp.nativewindow.x11.X11Lib;
 import jogamp.nativewindow.x11.X11Util;
 
 /** Encapsulates a screen index on X11
@@ -48,22 +51,22 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl
         super(device, fetchScreen(device, screen));
     }
 
-    public static AbstractGraphicsScreen createScreenDevice(long display, int screenIdx) {
+    public static AbstractGraphicsScreen createScreenDevice(long display, int screenIdx, boolean owner) {
         if(0==display) throw new NativeWindowException("display is null");
-        return new X11GraphicsScreen(new X11GraphicsDevice(display, AbstractGraphicsDevice.DEFAULT_UNIT), screenIdx);
+        return new X11GraphicsScreen(new X11GraphicsDevice(display, AbstractGraphicsDevice.DEFAULT_UNIT, owner), screenIdx);
     }
 
     public long getDefaultVisualID() {
         // It still could be an AWT hold handle ..
         long display = getDevice().getHandle();
-        int scrnIdx = X11Util.DefaultScreen(display);
-        return X11Util.DefaultVisualID(display, scrnIdx);
+        int scrnIdx = X11Lib.DefaultScreen(display);
+        return X11Lib.DefaultVisualID(display, scrnIdx);
     }
 
     private static int fetchScreen(X11GraphicsDevice device, int screen) {
         // It still could be an AWT hold handle ..
         long display = device.getHandle();
-        if(X11Util.XineramaEnabled(display)) {
+        if(X11Lib.XineramaEnabled(display)) {
             screen = 0; // Xinerama -> 1 screen
         }
         return screen;
diff --git a/src/test/com/jogamp/opengl/test/junit/util/FocusEventCountAdapter.java b/src/nativewindow/classes/jogamp/nativewindow/MutableGraphicsConfiguration.java
similarity index 68%
copy from src/test/com/jogamp/opengl/test/junit/util/FocusEventCountAdapter.java
copy to src/nativewindow/classes/jogamp/nativewindow/MutableGraphicsConfiguration.java
index b555515..ee3ab73 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/FocusEventCountAdapter.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/MutableGraphicsConfiguration.java
@@ -1,16 +1,16 @@
 /**
- * Copyright 2010 JogAmp Community. All rights reserved.
+ * Copyright 2011 JogAmp Community. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without modification, are
  * permitted provided that the following conditions are met:
- * 
+ *
  *    1. Redistributions of source code must retain the above copyright notice, this list of
  *       conditions and the following disclaimer.
- * 
+ *
  *    2. Redistributions in binary form must reproduce the above copyright notice, this list
  *       of conditions and the following disclaimer in the documentation and/or other materials
  *       provided with the distribution.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,15 +20,24 @@
  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
+ *
  * The views and conclusions contained in the software and documentation are those of the
  * authors and should not be interpreted as representing official policies, either expressed
  * or implied, of JogAmp Community.
  */
- 
-package com.jogamp.opengl.test.junit.util;
+package jogamp.nativewindow;
 
-public interface FocusEventCountAdapter extends EventCountAdapter {
-    boolean hasFocus();
-}
+import javax.media.nativewindow.AbstractGraphicsScreen;
+import javax.media.nativewindow.CapabilitiesImmutable;
+import javax.media.nativewindow.DefaultGraphicsConfiguration;
+
+public class MutableGraphicsConfiguration extends DefaultGraphicsConfiguration {
+    public MutableGraphicsConfiguration(AbstractGraphicsScreen screen,
+            CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested) {
+        super(screen, capsChosen, capsRequested);
+    }
 
+    public void setChosenCapabilities(CapabilitiesImmutable caps) {
+        super.setChosenCapabilities(caps);
+    }
+}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java b/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java
index 2b6d3c0..4cf8f44 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java
@@ -33,6 +33,7 @@ import java.security.AccessController;
 import java.security.PrivilegedAction;
 
 import com.jogamp.common.jvm.JNILibLoaderBase;
+import com.jogamp.common.os.Platform;
 import com.jogamp.common.util.cache.TempJarCache;
 
 public class NWJNILibLoader extends JNILibLoaderBase {
@@ -40,9 +41,10 @@ public class NWJNILibLoader extends JNILibLoaderBase {
   public static void loadNativeWindow(final String ossuffix) {
     AccessController.doPrivileged(new PrivilegedAction<Object>() {
       public Object run() {
+        Platform.initSingleton();
         final String libName = "nativewindow_"+ossuffix ;
         if(TempJarCache.isInitialized() && null == TempJarCache.findLibrary(libName)) {
-            addNativeJarLibs(NWJNILibLoader.class, "jogl.all", "jogl-all", new String[] { "nativewindow" } );
+            addNativeJarLibs(NWJNILibLoader.class, "jogl-all", new String[] { "nativewindow" } );
         }
         loadLibrary(libName, false);
         return null;
diff --git a/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java b/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java
index d34d4e5..223078e 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java
@@ -32,11 +32,15 @@
 
 package jogamp.nativewindow;
 
-import com.jogamp.common.os.Platform;
-import com.jogamp.common.util.*;
-import java.lang.reflect.*;
+import java.lang.reflect.Constructor;
+
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.NativeWindow;
+import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.nativewindow.ToolkitLock;
 
-import javax.media.nativewindow.*;
+import com.jogamp.common.os.Platform;
+import com.jogamp.common.util.ReflectionUtil;
 
 public class NativeWindowFactoryImpl extends NativeWindowFactory {
     private static final ToolkitLock nullToolkitLock = new NullToolkitLock();
@@ -44,13 +48,10 @@ public class NativeWindowFactoryImpl extends NativeWindowFactory {
     public static ToolkitLock getNullToolkitLock() {
             return nullToolkitLock;
     }
-
+    
     // This subclass of NativeWindowFactory handles the case of
     // NativeWindows being passed in
     protected NativeWindow getNativeWindowImpl(Object winObj, AbstractGraphicsConfiguration config) throws IllegalArgumentException {
-        if (null == winObj) {
-            throw new IllegalArgumentException("winObj is null");
-        }
         if (winObj instanceof NativeWindow) {
             // Use the NativeWindow directly
             return (NativeWindow) winObj;
@@ -69,7 +70,7 @@ public class NativeWindowFactoryImpl extends NativeWindowFactory {
                                            "javax.media.nativewindow.NativeWindow or "+AWTComponentClassName);
     }
     
-    private Constructor nativeWindowConstructor = null;
+    private Constructor<?> nativeWindowConstructor = null;
 
     private NativeWindow getAWTNativeWindow(Object winObj, AbstractGraphicsConfiguration config) {
         if (nativeWindowConstructor == null) {
diff --git a/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java b/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java
new file mode 100644
index 0000000..4877d5c
--- /dev/null
+++ b/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java
@@ -0,0 +1,85 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ * 
+ *    1. Redistributions of source code must retain the above copyright notice, this list of
+ *       conditions and the following disclaimer.
+ * 
+ *    2. Redistributions in binary form must reproduce the above copyright notice, this list
+ *       of conditions and the following disclaimer in the documentation and/or other materials
+ *       provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package jogamp.nativewindow;
+
+import java.util.ArrayList;
+
+import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.SurfaceUpdatedListener;
+
+public class SurfaceUpdatedHelper implements SurfaceUpdatedListener {
+    private Object surfaceUpdatedListenersLock = new Object();
+    private ArrayList<SurfaceUpdatedListener> surfaceUpdatedListeners = new ArrayList<SurfaceUpdatedListener>();
+
+    //
+    // Management Utils
+    // 
+    public int size() { return surfaceUpdatedListeners.size(); }
+    public SurfaceUpdatedListener get(int i) { return surfaceUpdatedListeners.get(i); }
+    
+    //
+    // Implementation of NativeSurface SurfaceUpdatedListener methods
+    // 
+    
+    public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+        addSurfaceUpdatedListener(-1, l);
+    }
+
+    public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) 
+        throws IndexOutOfBoundsException
+    {
+        if(l == null) {
+            return;
+        }
+        synchronized(surfaceUpdatedListenersLock) {
+            if(0>index) { 
+                index = surfaceUpdatedListeners.size(); 
+            }
+            surfaceUpdatedListeners.add(index, l);
+        }
+    }
+
+    public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+        if (l == null) {
+            return;
+        }
+        synchronized(surfaceUpdatedListenersLock) {
+            surfaceUpdatedListeners.remove(l);
+        }
+    }
+
+    public void surfaceUpdated(Object updater, NativeSurface ns, long when) {
+        synchronized(surfaceUpdatedListenersLock) {
+          for(int i = 0; i < surfaceUpdatedListeners.size(); i++ ) {
+            SurfaceUpdatedListener l = surfaceUpdatedListeners.get(i);
+            l.surfaceUpdated(updater, ns, when);
+          }
+        }
+    }
+}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java b/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java
index 4c2b1c8..59aa73b 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java
@@ -33,7 +33,7 @@ import javax.media.nativewindow.ProxySurface;
 import javax.media.nativewindow.SurfaceChangeable;
 
 
-public class WrappedSurface extends ProxySurface implements  SurfaceChangeable {
+public class WrappedSurface extends ProxySurface implements SurfaceChangeable {
   protected long surfaceHandle;
 
   public WrappedSurface(AbstractGraphicsConfiguration cfg) {
@@ -65,6 +65,6 @@ public class WrappedSurface extends ProxySurface implements  SurfaceChangeable {
   }
 
   public String toString() {
-    return "WrappedSurface[config " + config + ", displayHandle 0x" + Long.toHexString(getDisplayHandle()) + ", surfaceHandle 0x" + Long.toHexString(getSurfaceHandle()) + ", size " + getWidth() + "x" + getHeight() + "]";
+    return "WrappedSurface[config " + getPrivateGraphicsConfiguration() + ", displayHandle 0x" + Long.toHexString(getDisplayHandle()) + ", surfaceHandle 0x" + Long.toHexString(getSurfaceHandle()) + ", size " + getWidth() + "x" + getHeight() + "]";
   }
 }
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java
index 2c85382..354bb83 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java
@@ -40,14 +40,15 @@
 package jogamp.nativewindow.jawt;
 
 import javax.media.nativewindow.NativeWindowFactory;
+
 import jogamp.nativewindow.NWJNILibLoader;
 
 import java.awt.Toolkit;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
-public class JAWTJNILibLoader extends NWJNILibLoader {
-  public static void loadAWTImpl() {
+public class JAWTJNILibLoader extends NWJNILibLoader {  
+  static {
     AccessController.doPrivileged(new PrivilegedAction<Object>() {
       public Object run() {
         // Make sure that awt.dll is loaded before loading jawt.dll. Otherwise
@@ -73,4 +74,9 @@ public class JAWTJNILibLoader extends NWJNILibLoader {
       }
     });
   }
+  
+  public static void initSingleton() {
+      // just exist to ensure static init has been run      
+  }
+  
 }
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
index c1c97ee..21e9a3e 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
@@ -37,24 +37,28 @@
 
 package jogamp.nativewindow.jawt;
 
-import jogamp.nativewindow.*;
 import java.awt.EventQueue;
-
-import javax.media.nativewindow.*;
-
-
 import java.awt.GraphicsEnvironment;
 import java.awt.Toolkit;
-import java.lang.reflect.*;
-import java.security.*;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.Map;
 
+import javax.media.nativewindow.NativeWindowException;
+
+import jogamp.nativewindow.Debug;
+
+import com.jogamp.common.os.Platform;
+
 public class JAWTUtil {
   protected static final boolean DEBUG = Debug.debug("JAWT");
 
   // See whether we're running in headless mode
   private static final boolean headlessMode;
+  private static final JAWT jawtLockObject;
 
   // Java2D magic ..
   private static final Method isQueueFlusherThread;
@@ -75,31 +79,67 @@ public class JAWTUtil {
     boolean ok;
   }
   
+  /**
+   * Returns true if this platform's JAWT implementation supports 
+   * or uses offscreen layer.
+   */
+  public static boolean isOffscreenLayerSupported() {
+       return Platform.OS_TYPE == Platform.OSType.MACOS &&
+              Platform.OS_VERSION_NUMBER.compareTo(JAWT.JAWT_MacOSXCALayerMinVersion) >= 0;      
+  }
+ 
+  /**
+   * @param useOffscreenLayerIfAvailable
+   * @return
+   */
+  public static JAWT getJAWT(boolean useOffscreenLayerIfAvailable) {
+    int jawt_version_flags = JAWTFactory.JAWT_VERSION_1_4;
+    if(useOffscreenLayerIfAvailable) {
+        switch(Platform.OS_TYPE) {
+            case MACOS:
+                if(Platform.OS_VERSION_NUMBER.compareTo(JAWT.JAWT_MacOSXCALayerMinVersion) >= 0) {
+                    jawt_version_flags |= JAWT.JAWT_MACOSX_USE_CALAYER;
+                }
+        }
+    }
+    return JAWT.getJAWT(jawt_version_flags);
+  }
+  
+  public static boolean isJAWTUsingOffscreenLayer(JAWT jawt) {
+      return 0 != ( jawt.getCachedVersion() & JAWT.JAWT_MACOSX_USE_CALAYER );
+  }
+  
   static {
-    JAWTJNILibLoader.loadAWTImpl();
+    if(DEBUG) {
+        System.err.println("JAWTUtil initialization (JAWT/JNI/...");
+        // Thread.dumpStack();
+    }
+    JAWTJNILibLoader.initSingleton();
     JAWTJNILibLoader.loadNativeWindow("awt");
 
     headlessMode = GraphicsEnvironment.isHeadless();
-
     boolean ok = false;
-    Class jC = null;
+    Class<?> jC = null;
     Method m = null;
     if (!headlessMode) {
+        jawtLockObject = getJAWT(false); // don't care for offscreen layer here
         try {
             jC = Class.forName("jogamp.opengl.awt.Java2D");
             m = jC.getMethod("isQueueFlusherThread", (Class[])null);
             ok = true;
         } catch (Exception e) {
         }
+    } else {
+        jawtLockObject = null; // headless !
     }
     isQueueFlusherThread = m;
     j2dExist = ok;
 
-    PrivilegedDataBlob1 pdb1 = (PrivilegedDataBlob1) AccessController.doPrivileged(new PrivilegedAction() {        
+    PrivilegedDataBlob1 pdb1 = (PrivilegedDataBlob1) AccessController.doPrivileged(new PrivilegedAction<Object>() {        
         public Object run() {
             PrivilegedDataBlob1 d = new PrivilegedDataBlob1();
             try {                
-                final Class sunToolkitClass = Class.forName("sun.awt.SunToolkit");
+                final Class<?> sunToolkitClass = Class.forName("sun.awt.SunToolkit");
                 d.sunToolkitAWTLockMethod = sunToolkitClass.getDeclaredMethod("awtLock", new Class[]{});
                 d.sunToolkitAWTLockMethod.setAccessible(true);
                 d.sunToolkitAWTUnlockMethod = sunToolkitClass.getDeclaredMethod("awtUnlock", new Class[]{});
@@ -129,21 +169,21 @@ public class JAWTUtil {
     jawtToolkitLock = new JAWTToolkitLock();
 
     // trigger native AWT toolkit / properties initialization
-    Map desktophints = null;
+    Map<?,?> desktophints = null;
     try {
         if(EventQueue.isDispatchThread()) {
-            desktophints = (Map)(Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints"));
+            desktophints = (Map<?,?>)(Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints"));
         } else {
-            final ArrayList desktophintsBucket = new ArrayList(1);
+            final ArrayList<Map<?,?>> desktophintsBucket = new ArrayList<Map<?,?>>(1);
             EventQueue.invokeAndWait(new Runnable() {
                 public void run() {
-                    Map _desktophints = (Map)(Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints"));
+                    Map<?,?> _desktophints = (Map<?,?>)(Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints"));
                     if(null!=_desktophints) {
                         desktophintsBucket.add(_desktophints);
                     }
                 }
             });
-            desktophints = ( desktophintsBucket.size() > 0 ) ? (Map)desktophintsBucket.get(0) : null ;
+            desktophints = ( desktophintsBucket.size() > 0 ) ? desktophintsBucket.get(0) : null ;
         }
     } catch (InterruptedException ex) {
         ex.printStackTrace();
@@ -189,7 +229,7 @@ public class JAWTUtil {
    * JAWT's native Lock() function calls SunToolkit.awtLock(),
    * which just uses AWT's global ReentrantLock.<br>
    */
-  public static void awtLock() {
+  private static void awtLock() {
     if(hasSunToolkitAWTLock) {
         try {
             sunToolkitAWTLockMethod.invoke(null, (Object[])null);
@@ -197,7 +237,7 @@ public class JAWTUtil {
           throw new NativeWindowException("SunToolkit.awtLock failed", e);
         }
     } else {
-        JAWT.getJAWT().Lock();
+        jawtLockObject.Lock();
     }
   }
 
@@ -207,7 +247,7 @@ public class JAWTUtil {
    * JAWT's native Unlock() function calls SunToolkit.awtUnlock(),
    * which just uses AWT's global ReentrantLock.<br>
    */
-  public static void awtUnlock() {
+  private static void awtUnlock() {
     if(hasSunToolkitAWTLock) {
         try {
             sunToolkitAWTUnlockMethod.invoke(null, (Object[])null);
@@ -215,7 +255,7 @@ public class JAWTUtil {
           throw new NativeWindowException("SunToolkit.awtUnlock failed", e);
         }
     } else {
-        JAWT.getJAWT().Unlock();
+        jawtLockObject.Unlock();
     }
   }
 
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
index 2c80392..6d28603 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
@@ -41,73 +41,190 @@ import com.jogamp.common.util.locks.LockFactory;
 import com.jogamp.common.util.locks.RecursiveLock;
 
 import java.awt.Component;
-import java.awt.Window;
+import java.awt.Container;
+import java.applet.Applet;
 import javax.media.nativewindow.AbstractGraphicsConfiguration;
 import javax.media.nativewindow.AbstractGraphicsDevice;
 import javax.media.nativewindow.NativeSurface;
 import javax.media.nativewindow.NativeWindow;
 import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.OffscreenLayerOption;
+import javax.media.nativewindow.OffscreenLayerSurface;
+import javax.media.nativewindow.SurfaceUpdatedListener;
+import javax.media.nativewindow.awt.AWTGraphicsConfiguration;
 import javax.media.nativewindow.util.Insets;
 import javax.media.nativewindow.util.InsetsImmutable;
 import javax.media.nativewindow.util.Point;
 import javax.media.nativewindow.util.Rectangle;
 import javax.media.nativewindow.util.RectangleImmutable;
 
-public abstract class JAWTWindow implements NativeWindow {
+import jogamp.nativewindow.SurfaceUpdatedHelper;
+
+public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, OffscreenLayerOption {
   protected static final boolean DEBUG = JAWTUtil.DEBUG;
 
+  // user properties
+  protected boolean shallUseOffscreenLayer = false;
+  
   // lifetime: forever
   protected Component component;
-  protected AbstractGraphicsConfiguration config;
+  private AWTGraphicsConfiguration config; // control access due to delegation
+  private SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper();
 
-  // lifetime: valid after lock, forever until invalidate
+  // lifetime: valid after lock but may change with each 1st lock, purges after invalidate
+  private boolean isApplet;
+  private JAWT jawt;
+  private boolean isOffscreenLayerSurface;
   protected long drawable;
   protected Rectangle bounds;
-
-  public JAWTWindow(Object comp, AbstractGraphicsConfiguration config) {
+  protected Insets insets;
+  
+  /**
+   * Constructed by {@link jogamp.nativewindow.NativeWindowFactoryImpl#getNativeWindow(Object, AbstractGraphicsConfiguration)}
+   * via this platform's specialization (X11, OSX, Windows, ..).
+   * 
+   * @param comp
+   * @param config
+   */
+  protected JAWTWindow(Object comp, AbstractGraphicsConfiguration config) {
     if (config == null) {
         throw new NativeWindowException("Error: AbstractGraphicsConfiguration is null");
     }
-    this.config = config;
+    if(! ( config instanceof AWTGraphicsConfiguration ) ) {
+        throw new NativeWindowException("Error: AbstractGraphicsConfiguration is not an AWTGraphicsConfiguration: "+config);
+    }
+    this.config = (AWTGraphicsConfiguration) config;
     init((Component)comp);
   }
 
   private void init(Component windowObject) throws NativeWindowException {
     invalidate();
     this.component = windowObject;
-    validateNative();
+    this.isApplet = false;
   }
-  protected abstract void validateNative() throws NativeWindowException;
-
+  
+  public void setShallUseOffscreenLayer(boolean v) {
+      shallUseOffscreenLayer = v;
+  }
+  
+  public final boolean getShallUseOffscreenLayer() {
+      return shallUseOffscreenLayer;
+  }
+  
+  public final boolean isOffscreenLayerSurfaceEnabled() { 
+      return isOffscreenLayerSurface;
+  }
+  
   protected synchronized void invalidate() {
-    component = null;
+    invalidateNative();
+    jawt = null;
+    isOffscreenLayerSurface = false;
     drawable= 0;
     bounds = new Rectangle();
+    insets = new Insets();
   }
+  protected abstract void invalidateNative();
 
   protected final void updateBounds(JAWT_Rectangle jawtBounds) {
     bounds.setX(jawtBounds.getX());
     bounds.setY(jawtBounds.getY());
     bounds.setWidth(jawtBounds.getWidth());
     bounds.setHeight(jawtBounds.getHeight());
+    
+    if(component instanceof Container) {
+        java.awt.Insets contInsets = ((Container)component).getInsets();
+        insets.setLeftWidth(contInsets.left);
+        insets.setRightWidth(contInsets.right);
+        insets.setTopHeight(contInsets.top);
+        insets.setBottomHeight(contInsets.bottom);
+    }
   }
 
   /** @return the JAWT_DrawingSurfaceInfo's (JAWT_Rectangle) bounds, updated with lock */
   public final RectangleImmutable getBounds() { return bounds; }
   
-  public final InsetsImmutable getInsets() { return Insets.getZero(); }
+  public final InsetsImmutable getInsets() { return insets; }
 
   public final Component getAWTComponent() {
     return component;
   }
+  
+  /** 
+   * Returns true if the AWT component is parented to an {@link java.applet.Applet}, 
+   * otherwise false. This information is valid only after {@link #lockSurface()}. 
+   */
+  public final boolean isApplet() {
+      return isApplet;
+  }
 
+  /** Returns the underlying JAWT instance created @ {@link #lockSurface()}. */
+  public final JAWT getJAWT() {
+      return jawt;
+  }
+
+  /** 
+   * {@inheritDoc}
+   */
+  public final void attachSurfaceLayer(final long layerHandle) throws NativeWindowException {  
+      if( !isOffscreenLayerSurfaceEnabled() ) {
+          throw new NativeWindowException("Not an offscreen layer surface");
+      }
+      int lockRes = lockSurface();
+      if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) {
+          throw new NativeWindowException("Could not lock (offscreen layer): "+this);
+      }
+      try {
+          if(DEBUG) {
+            System.err.println("JAWTWindow.attachSurfaceHandle(): 0x"+Long.toHexString(layerHandle));
+          }
+          attachSurfaceLayerImpl(layerHandle);
+      } finally {
+          unlockSurface();
+      }
+  }  
+  protected abstract void attachSurfaceLayerImpl(final long layerHandle);
+  
+  /** 
+   * {@inheritDoc}
+   */
+  public final void detachSurfaceLayer(final long layerHandle) throws NativeWindowException {  
+      if( !isOffscreenLayerSurfaceEnabled() ) {
+          throw new java.lang.UnsupportedOperationException("Not an offscreen layer surface");
+      }
+      int lockRes = lockSurface();
+      if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) {
+          throw new NativeWindowException("Could not lock (offscreen layer): "+this);
+      }
+      try {
+          if(DEBUG) {
+            System.err.println("JAWTWindow.detachSurfaceHandle(): 0x"+Long.toHexString(layerHandle));
+          }
+          detachSurfaceLayerImpl(layerHandle);
+      } finally {
+          unlockSurface();
+      }
+  }  
+  protected abstract void detachSurfaceLayerImpl(final long layerHandle);
+  
   //
   // SurfaceUpdateListener
   //
 
-  public final void surfaceUpdated(Object updater, NativeSurface ns, long when) {
-      // nop
+  public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+      surfaceUpdatedHelper.addSurfaceUpdatedListener(l);
   }
+
+  public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException {
+      surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l);
+  }
+
+  public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+      surfaceUpdatedHelper.removeSurfaceUpdatedListener(l);
+  }
+
+  public void surfaceUpdated(Object updater, NativeSurface ns, long when) {
+      surfaceUpdatedHelper.surfaceUpdated(updater, ns, when);
+  }    
   
   //
   // NativeSurface
@@ -115,6 +232,24 @@ public abstract class JAWTWindow implements NativeWindow {
 
   private RecursiveLock surfaceLock = LockFactory.createRecursiveLock();
 
+  private void determineIfApplet() {
+    Component c = component;
+    while(!isApplet && null != c) {
+        isApplet = c instanceof Applet;
+        c = c.getParent();
+    }
+  }
+  
+  /**
+   * If JAWT offscreen layer is supported, 
+   * implementation shall respect {@link #getShallUseOffscreenLayer()}
+   * and may respect {@link #isApplet()}.
+   * 
+   * @return The JAWT instance reflecting offscreen layer support, etc.
+   * 
+   * @throws NativeWindowException
+   */
+  protected abstract JAWT fetchJAWTImpl() throws NativeWindowException;
   protected abstract int lockSurfaceImpl() throws NativeWindowException;
 
   public final int lockSurface() throws NativeWindowException {
@@ -122,10 +257,13 @@ public abstract class JAWTWindow implements NativeWindow {
     int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ?
 
     if ( LOCK_SURFACE_NOT_READY == res ) {
+        determineIfApplet();
         try {
-            final AbstractGraphicsDevice adevice = config.getScreen().getDevice();
+            final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice();
             adevice.lock();
             try {
+                jawt = fetchJAWTImpl();
+                isOffscreenLayerSurface = JAWTUtil.isJAWTUsingOffscreenLayer(jawt);
                 res = lockSurfaceImpl();
             } finally {
                 if (LOCK_SURFACE_NOT_READY >= res) {
@@ -147,7 +285,7 @@ public abstract class JAWTWindow implements NativeWindow {
     surfaceLock.validateLocked();
 
     if (surfaceLock.getHoldCount() == 1) {
-        final AbstractGraphicsDevice adevice = config.getScreen().getDevice();
+        final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice();
         try {
             unlockSurfaceImpl();
         } finally {
@@ -169,36 +307,35 @@ public abstract class JAWTWindow implements NativeWindow {
     return surfaceLock.getOwner();
   }
 
-  public final boolean surfaceSwap() {
+  public boolean surfaceSwap() {
     return false;
   }
 
-  public final void surfaceUpdated(Object updater, NativeWindow window, long when) { }
-
-  public final long getSurfaceHandle() {
+  public long getSurfaceHandle() {
     return drawable;
   }
-  public final AbstractGraphicsConfiguration getGraphicsConfiguration() {
+  
+  public final AWTGraphicsConfiguration getPrivateGraphicsConfiguration() {
     return config;
   }
+  
+  public final AbstractGraphicsConfiguration getGraphicsConfiguration() {
+    return config.getNativeGraphicsConfiguration();
+  }
 
   public final long getDisplayHandle() {
-    return config.getScreen().getDevice().getHandle();
+    return getGraphicsConfiguration().getScreen().getDevice().getHandle();
   }
 
   public final int getScreenIndex() {
-    return config.getScreen().getIndex();
-  }
-
-  public final void setSize(int width, int height) {
-    component.setSize(width, height);
+    return getGraphicsConfiguration().getScreen().getIndex();
   }
 
-  public final int getWidth() {
+  public int getWidth() {
     return component.getWidth();
   }
 
-  public final int getHeight() {
+  public int getHeight() {
     return component.getHeight();
   }
 
@@ -207,12 +344,8 @@ public abstract class JAWTWindow implements NativeWindow {
   //
 
   public synchronized void destroy() {
-    if(null!=component) {
-        if(component instanceof Window) {
-            ((Window)component).dispose();
-        }
-    }
-    invalidate();
+    invalidate();    
+    component = null; // don't dispose the AWT component, since we are merely an immutable uplink 
   }
 
   public final NativeWindow getParent() {
@@ -222,7 +355,7 @@ public abstract class JAWTWindow implements NativeWindow {
   public long getWindowHandle() {
     return drawable;
   }
-
+  
   public final int getX() {
       return component.getX();
   }
@@ -230,52 +363,94 @@ public abstract class JAWTWindow implements NativeWindow {
   public final int getY() {
       return component.getY();
   }
-
+  
+  /**
+   * {@inheritDoc}
+   * 
+   * <p>
+   * This JAWT default implementation is currently still using 
+   * a blocking implementation. It first attempts to retrieve the location
+   * via a native implementation. If this fails, it tries the blocking AWT implementation.
+   * If the latter fails due to an external AWT tree-lock, the non block 
+   * implementation {@link #getLocationOnScreenNonBlocking(Point, Component)} is being used.
+   * The latter simply traverse up to the AWT component tree and sums the rel. position.
+   * We have to determine whether the latter is good enough for all cases,
+   * currently only OS X utilizes the non blocking method per default.
+   * </p>   
+   */
   public Point getLocationOnScreen(Point storage) {
+      Point los = getLocationOnScreenNative(storage);
+      if(null == los) {
+          if(!Thread.holdsLock(component.getTreeLock())) {
+              // avoid deadlock ..
+              if(DEBUG) {
+                  System.err.println("Warning: JAWT Lock hold, but not the AWT tree lock: "+this);
+                  Thread.dumpStack();
+              }
+              return getLocationOnScreenNonBlocking(storage, component);
+          }
+          java.awt.Point awtLOS = component.getLocationOnScreen();
+          if(null!=storage) {
+              los = storage.translate(awtLOS.x, awtLOS.y);
+          } else {
+              los = new Point(awtLOS.x, awtLOS.y);
+          }
+      }
+      return los;
+  }
+  
+  protected Point getLocationOnScreenNative(Point storage) {
       int lockRes = lockSurface();
       if(LOCK_SURFACE_NOT_READY == lockRes) {
-          // FIXME: Shall we deal with already locked or unrealized surfaces ?
-          System.err.println("Warning: JAWT Lock couldn't be acquired!");
-          Thread.dumpStack();
+          if(DEBUG) {
+              System.err.println("Warning: JAWT Lock couldn't be acquired: "+this);
+              Thread.dumpStack();
+          }
           return null;
       }
       try {
-          Point d = getLocationOnScreenImpl(0, 0);
+          Point d = getLocationOnScreenNativeImpl(0, 0);
           if(null!=d) {
             if(null!=storage) {
                 storage.translate(d.getX(),d.getY());
                 return storage;
             }
-            return d;
-          }
-          // fall through intended ..
-          if(!Thread.holdsLock(component.getTreeLock())) {
-              // FIXME: Verify if this check is still required!
-              System.err.println("Warning: JAWT Lock hold, but not the AWT tree lock!");
-              Thread.dumpStack();
-              return null; // avoid deadlock ..
           }
-          java.awt.Point awtLOS = component.getLocationOnScreen();
-          int dx = (int) ( awtLOS.getX() + .5 ) ;
-          int dy = (int) ( awtLOS.getY() + .5 ) ;
-          if(null!=storage) {
-              return storage.translate(dx, dy);
-          }
-          return new Point(dx, dy);
+          return d;
       } finally {
           unlockSurface();
+      }      
+  }
+  protected abstract Point getLocationOnScreenNativeImpl(int x, int y);
+
+  protected static Point getLocationOnScreenNonBlocking(Point storage, Component comp) {     
+      int x = 0; 
+      int y = 0;
+      while(null != comp) {
+          x += comp.getX();
+          y += comp.getY();
+          comp = comp.getParent();
       }
+      if(null!=storage) {
+          storage.translate(x, y);
+          return storage;
+      }
+      return new Point(x, y);
   }
-  protected abstract Point getLocationOnScreenImpl(int x, int y);
-
-    @Override
+  
+  public boolean hasFocus() {
+      return component.hasFocus();
+  }
+  
+  @Override
   public String toString() {
     StringBuilder sb = new StringBuilder();
 
     sb.append("JAWT-Window["+
                 "windowHandle 0x"+Long.toHexString(getWindowHandle())+
                 ", surfaceHandle 0x"+Long.toHexString(getSurfaceHandle())+
-                ", bounds "+bounds);
+                ", bounds "+bounds+", insets "+insets+
+                ", shallUseOffscreenLayer "+shallUseOffscreenLayer+", isOffscreenLayerSurface "+isOffscreenLayerSurface);
     if(null!=component) {
       sb.append(", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+
                 ", visible "+component.isVisible());
@@ -283,7 +458,7 @@ public abstract class JAWTWindow implements NativeWindow {
       sb.append(", component NULL");
     }
     sb.append(", lockedExt "+isSurfaceLockedByOtherThread()+
-              ",\n\tconfig "+config+
+              ",\n\tconfig "+getPrivateGraphicsConfiguration()+
               ",\n\tawtComponent "+getAWTComponent()+"]");
 
     return sb.toString();
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
index d0152ce..ab2986f 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
@@ -40,38 +40,94 @@
 
 package jogamp.nativewindow.jawt.macosx;
 
-import java.awt.Component;
+import java.nio.Buffer;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
 import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.Capabilities;
 import javax.media.nativewindow.NativeWindow;
 import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.SurfaceChangeable;
 import javax.media.nativewindow.util.Point;
 
+import jogamp.nativewindow.MutableGraphicsConfiguration;
 import jogamp.nativewindow.jawt.JAWT;
 import jogamp.nativewindow.jawt.JAWTFactory;
+import jogamp.nativewindow.jawt.JAWTUtil;
 import jogamp.nativewindow.jawt.JAWTWindow;
 import jogamp.nativewindow.jawt.JAWT_DrawingSurface;
 import jogamp.nativewindow.jawt.JAWT_DrawingSurfaceInfo;
 import jogamp.nativewindow.macosx.OSXUtil;
 
-public class MacOSXJAWTWindow extends JAWTWindow {
-
+public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable {
   public MacOSXJAWTWindow(Object comp, AbstractGraphicsConfiguration config) {
     super(comp, config);
+    if(DEBUG) {
+        dumpInfo();
+    }
   }
 
-  protected void validateNative() throws NativeWindowException {
+  protected void invalidateNative() {
+      surfaceHandle=0;
+      if(isOffscreenLayerSurfaceEnabled()) {
+          if(0 != drawable) {
+              OSXUtil.DestroyNSWindow(drawable);
+              drawable = 0;
+          }
+      }
   }
 
+  protected void attachSurfaceLayerImpl(final long layerHandle) {
+      OSXUtil.AddCASublayer(rootSurfaceLayerHandle, layerHandle);
+  }
+  
+  protected void detachSurfaceLayerImpl(final long layerHandle) {
+      OSXUtil.RemoveCASublayer(rootSurfaceLayerHandle, layerHandle);
+  }
+    
+  public long getSurfaceHandle() {
+    return isOffscreenLayerSurfaceEnabled() ? surfaceHandle : super.getSurfaceHandle() ;
+  }
+  
+  public void setSurfaceHandle(long surfaceHandle) {
+      if( !isOffscreenLayerSurfaceEnabled() ) {
+          throw new java.lang.UnsupportedOperationException("Not using CALAYER");
+      }
+      if(DEBUG) {
+        System.err.println("MacOSXJAWTWindow.setSurfaceHandle(): 0x"+Long.toHexString(surfaceHandle));
+      }
+      sscSet &= 0 != surfaceHandle; // reset ssc flag if NULL surfaceHandle, ie. back to JAWT
+      this.surfaceHandle = surfaceHandle;
+  }
+
+  public void surfaceSizeChanged(int width, int height) {
+      sscSet = true;
+      sscWidth = width;
+      sscHeight = height;
+  }
+
+  public int getWidth() {
+    return sscSet ? sscWidth : super.getWidth();
+  }
+
+  public int getHeight() {
+    return sscSet ? sscHeight: super.getHeight();
+  }
+
+  protected JAWT fetchJAWTImpl() throws NativeWindowException {
+       // use offscreen if supported and [ applet or requested ]
+      return JAWTUtil.getJAWT(getShallUseOffscreenLayer() || isApplet());
+  }
   protected int lockSurfaceImpl() throws NativeWindowException {
-    int ret = NativeWindow.LOCK_SUCCESS;
-    ds = JAWT.getJAWT().GetDrawingSurface(component);
-    if (ds == null) {
-      // Widget not yet realized
-      unlockSurfaceImpl();
-      return NativeWindow.LOCK_SURFACE_NOT_READY;
+    int ret = NativeWindow.LOCK_SURFACE_NOT_READY;
+    if(null == ds) {
+        ds = getJAWT().GetDrawingSurface(component);
+        if (ds == null) {
+          // Widget not yet realized
+          unlockSurfaceImpl();
+          return NativeWindow.LOCK_SURFACE_NOT_READY;
+        }
     }
     int res = ds.Lock();
     dsLocked = ( 0 == ( res & JAWTFactory.JAWT_LOCK_ERROR ) ) ;
@@ -87,37 +143,86 @@ public class MacOSXJAWTWindow extends JAWTWindow {
     if ((res & JAWTFactory.JAWT_LOCK_SURFACE_CHANGED) != 0) {
       ret = NativeWindow.LOCK_SURFACE_CHANGED;
     }
-    if (firstLock) {
-      AccessController.doPrivileged(new PrivilegedAction<Object>() {
-          public Object run() {
-            dsi = ds.GetDrawingSurfaceInfo();
-            return null;
-          }
-        });
-    } else {
-      dsi = ds.GetDrawingSurfaceInfo();
+    if(null == dsi) {
+        if (firstLock) {
+          AccessController.doPrivileged(new PrivilegedAction<Object>() {
+              public Object run() {
+                dsi = ds.GetDrawingSurfaceInfo();
+                return null;
+              }
+            });
+        } else {
+          dsi = ds.GetDrawingSurfaceInfo();
+        }
+        if (dsi == null) {
+          unlockSurfaceImpl();
+          return NativeWindow.LOCK_SURFACE_NOT_READY;
+        }
     }
-    if (dsi == null) {
-      unlockSurfaceImpl();
-      return NativeWindow.LOCK_SURFACE_NOT_READY;
+    updateBounds(dsi.getBounds());
+    if (DEBUG && firstLock ) {
+      dumpInfo();
     }
     firstLock = false;
-    macosxdsi = (JAWT_MacOSXDrawingSurfaceInfo) dsi.platformInfo();
-    if (macosxdsi == null) {
-      unlockSurfaceImpl();
-      return NativeWindow.LOCK_SURFACE_NOT_READY;
-    }
-    drawable = macosxdsi.getCocoaViewRef();
-
-    if (drawable == 0) {
-      unlockSurfaceImpl();
-      return NativeWindow.LOCK_SURFACE_NOT_READY;
+    if( !isOffscreenLayerSurfaceEnabled() ) {
+        macosxdsi = (JAWT_MacOSXDrawingSurfaceInfo) dsi.platformInfo(getJAWT());
+        if (macosxdsi == null) {
+          unlockSurfaceImpl();
+          return NativeWindow.LOCK_SURFACE_NOT_READY;
+        }
+        drawable = macosxdsi.getCocoaViewRef();
+    
+        if (drawable == 0) {
+          unlockSurfaceImpl();
+          return NativeWindow.LOCK_SURFACE_NOT_READY;
+        } else {
+          ret = NativeWindow.LOCK_SUCCESS;
+        }
     } else {
-      updateBounds(dsi.getBounds());
+        /**
+         * Only create a fake invisible NSWindow for the drawable handle
+         * to please frameworks requiring such (eg. NEWT).
+         * 
+         * The actual surface/ca-layer shall be created/attached 
+         * by the upper framework (JOGL) since they require more information. 
+         */
+        if(0 == drawable) {
+            drawable = OSXUtil.CreateNSWindow(0, 0, getBounds().getWidth(), getBounds().getHeight());
+            if(0 == drawable) {
+              unlockSurfaceImpl();
+              throw new NativeWindowException("Unable to created dummy NSWindow (layered case)");
+            }
+            // fix caps reflecting offscreen!
+            Capabilities caps = (Capabilities) getPrivateGraphicsConfiguration().getChosenCapabilities().cloneMutable();
+            caps.setOnscreen(false);
+            getPrivateGraphicsConfiguration().setChosenCapabilities(caps);
+            caps = (Capabilities) getGraphicsConfiguration().getChosenCapabilities().cloneMutable();
+            caps.setOnscreen(false);
+            ((MutableGraphicsConfiguration)getGraphicsConfiguration()).setChosenCapabilities(caps);
+        }
+        if(0 == rootSurfaceLayerHandle) {
+            rootSurfaceLayerHandle = OSXUtil.CreateCALayer();
+            if(0 == rootSurfaceLayerHandle) {
+              OSXUtil.DestroyNSWindow(drawable);
+              drawable = 0;
+              unlockSurfaceImpl();
+              throw new NativeWindowException("Could not create root CALayer: "+this);                
+            }
+            if(!AttachJAWTSurfaceLayer(dsi, rootSurfaceLayerHandle)) {
+              OSXUtil.DestroyCALayer(rootSurfaceLayerHandle);
+              rootSurfaceLayerHandle = 0;
+              OSXUtil.DestroyNSWindow(drawable);
+              drawable = 0;
+              unlockSurfaceImpl();
+              throw new NativeWindowException("Could not attach JAWT surfaceLayerHandle: "+this);
+            }
+        }
+        ret = NativeWindow.LOCK_SUCCESS;
     }
+    
     return ret;
   }
-    
+  
   protected void unlockSurfaceImpl() throws NativeWindowException {
     if(null!=ds) {
         if (null!=dsi) {
@@ -126,30 +231,65 @@ public class MacOSXJAWTWindow extends JAWTWindow {
         if (dsLocked) {
             ds.Unlock();
         }
-        JAWT.getJAWT().FreeDrawingSurface(ds);
+        getJAWT().FreeDrawingSurface(ds);
     }
     ds = null;
     dsi = null;
-    macosxdsi = null;
   }
 
-  protected Point getLocationOnScreenImpl(int x, int y) {
-      Component c = component;
-      while(null != c) {
-          x += c.getX();
-          y += c.getY();
-          c = c.getParent();
+  private void dumpInfo() {
+      System.err.println("MaxOSXJAWTWindow: 0x"+Integer.toHexString(this.hashCode())+" - thread: "+Thread.currentThread().getName());
+      if(null != getJAWT()) {
+          System.err.println("JAWT version: 0x"+Integer.toHexString(getJAWT().getCachedVersion())+
+                             ", CA_LAYER: "+ JAWTUtil.isJAWTUsingOffscreenLayer(getJAWT())+
+                             ", isLayeredSurface "+isOffscreenLayerSurfaceEnabled()+", bounds "+bounds+", insets "+insets);
+      } else {
+          System.err.println("JAWT n/a, bounds "+bounds+", insets "+insets);          
       }
-      // return OSXUtil.GetLocationOnScreen(getWindowHandle(), x, y);
-      return new Point(x, y);
+      // Thread.dumpStack();
   }
+  
+  /**
+   * {@inheritDoc}
+   * <p>
+   * On OS X locking the surface at this point (ie after creation and for location validation)
+   * is 'tricky' since the JVM traverses through many threads and crashes at:
+   *   lockSurfaceImpl() {
+   *      ..
+   *      ds = getJAWT().GetDrawingSurface(component);
+   * due to a SIGSEGV.
+   * 
+   * Hence we have some threading / sync issues with the native JAWT implementation.
+   * </p>      
+   */
+  @Override
+  public Point getLocationOnScreen(Point storage) {     
+      return getLocationOnScreenNonBlocking(storage, component);     
+  }  
+  protected Point getLocationOnScreenNativeImpl(final int x0, final int y0) { return null; }
 
+  private static boolean AttachJAWTSurfaceLayer(JAWT_DrawingSurfaceInfo dsi, long caLayer) {
+    if(0==caLayer) {
+        throw new IllegalArgumentException("caLayer 0x"+Long.toHexString(caLayer));
+    }
+    return AttachJAWTSurfaceLayer0(dsi.getBuffer(), caLayer);
+  }
+    
+  private static native boolean AttachJAWTSurfaceLayer0(Buffer jawtDrawingSurfaceInfoBuffer, long caLayer);
+  
   // Variables for lockSurface/unlockSurface
   private JAWT_DrawingSurface ds;
   private boolean dsLocked;
   private JAWT_DrawingSurfaceInfo dsi;
+  
   private JAWT_MacOSXDrawingSurfaceInfo macosxdsi;
-
+  
+  private long rootSurfaceLayerHandle = 0; // is autoreleased, once it is attached to the JAWT_SurfaceLayer
+  
+  private long surfaceHandle = 0;
+  private int sscWidth, sscHeight;
+  private boolean sscSet = false;
+   
   // Workaround for instance of 4796548
   private boolean firstLock = true;
 
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java
index 5ad2280..bf5c18e 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java
@@ -95,7 +95,7 @@ public class Win32SunJDKReflection {
   public static int graphicsConfigurationGetPixelFormatID(AbstractGraphicsConfiguration config) {
       try {
           if (config instanceof AWTGraphicsConfiguration) {
-              return graphicsConfigurationGetPixelFormatID(((AWTGraphicsConfiguration) config).getGraphicsConfiguration());
+              return graphicsConfigurationGetPixelFormatID(((AWTGraphicsConfiguration) config).getAWTGraphicsConfiguration());
           }
           return 0;
       } catch (Exception e) {
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java
index 982b948..43d4469 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java
@@ -47,10 +47,11 @@ import javax.media.nativewindow.util.Point;
 
 import jogamp.nativewindow.jawt.JAWT;
 import jogamp.nativewindow.jawt.JAWTFactory;
+import jogamp.nativewindow.jawt.JAWTUtil;
 import jogamp.nativewindow.jawt.JAWTWindow;
 import jogamp.nativewindow.jawt.JAWT_DrawingSurface;
 import jogamp.nativewindow.jawt.JAWT_DrawingSurfaceInfo;
-import jogamp.nativewindow.windows.GDI;
+import jogamp.nativewindow.windows.GDIUtil;
 
 public class WindowsJAWTWindow extends JAWTWindow {
 
@@ -58,18 +59,24 @@ public class WindowsJAWTWindow extends JAWTWindow {
     super(comp, config);
   }
 
-  protected void validateNative() throws NativeWindowException {
-  }
-
-  @Override
-  protected synchronized void invalidate() {
-    super.invalidate();
+  protected void invalidateNative() {
     windowHandle = 0;
   }
 
+  protected void attachSurfaceLayerImpl(final long layerHandle) {
+      throw new UnsupportedOperationException("offscreen layer not supported");
+  }
+  protected void detachSurfaceLayerImpl(final long layerHandle) {
+      throw new UnsupportedOperationException("offscreen layer not supported");
+  }
+  
+  protected JAWT fetchJAWTImpl() throws NativeWindowException {
+      return JAWTUtil.getJAWT(false); // no offscreen
+  }
+  
   protected int lockSurfaceImpl() throws NativeWindowException {
     int ret = NativeWindow.LOCK_SUCCESS;
-    ds = JAWT.getJAWT().GetDrawingSurface(component);
+    ds = getJAWT().GetDrawingSurface(component);
     if (ds == null) {
       // Widget not yet realized
       unlockSurfaceImpl();
@@ -94,7 +101,8 @@ public class WindowsJAWTWindow extends JAWTWindow {
       unlockSurfaceImpl();
       return LOCK_SURFACE_NOT_READY;
     }
-    win32dsi = (JAWT_Win32DrawingSurfaceInfo) dsi.platformInfo();
+    updateBounds(dsi.getBounds());
+    win32dsi = (JAWT_Win32DrawingSurfaceInfo) dsi.platformInfo(getJAWT());
     if (win32dsi == null) {
       unlockSurfaceImpl();
       return LOCK_SURFACE_NOT_READY;
@@ -104,14 +112,11 @@ public class WindowsJAWTWindow extends JAWTWindow {
     if (windowHandle == 0 || drawable == 0) {
       unlockSurfaceImpl();
       return LOCK_SURFACE_NOT_READY;
-    } else {
-      updateBounds(dsi.getBounds());
     }
     return ret;
   }
 
   protected void unlockSurfaceImpl() throws NativeWindowException {
-    long startTime = 0;
     if(null!=ds) {
         if (null!=dsi) {
             ds.FreeDrawingSurfaceInfo(dsi);
@@ -119,7 +124,7 @@ public class WindowsJAWTWindow extends JAWTWindow {
         if (dsLocked) {
             ds.Unlock();
         }
-        JAWT.getJAWT().FreeDrawingSurface(ds);
+        getJAWT().FreeDrawingSurface(ds);
     }
     ds = null;
     dsi = null;
@@ -131,8 +136,8 @@ public class WindowsJAWTWindow extends JAWTWindow {
     return windowHandle;
   }
 
-  protected Point getLocationOnScreenImpl(int x, int y) {
-    return GDI.GetRelativeLocation( getWindowHandle(), 0 /*root win*/, x, y);
+  protected Point getLocationOnScreenNativeImpl(int x, int y) {
+    return GDIUtil.GetRelativeLocation( getWindowHandle(), 0 /*root win*/, x, y);
   }
 
   // Variables for lockSurface/unlockSurface
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTToolkitLock.java
index 5d4fa0d..743d371 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTToolkitLock.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTToolkitLock.java
@@ -28,9 +28,13 @@
 package jogamp.nativewindow.jawt.x11;
 
 import jogamp.nativewindow.jawt.*;
+import jogamp.nativewindow.x11.X11Lib;
 import jogamp.nativewindow.x11.X11Util;
 import javax.media.nativewindow.ToolkitLock;
 
+import com.jogamp.common.util.locks.LockFactory;
+import com.jogamp.common.util.locks.RecursiveLock;
+
 /**
  * Implementing a recursive {@link javax.media.nativewindow.ToolkitLock}
  * utilizing JAWT's AWT lock via {@link JAWTUtil#lockToolkit()} and {@link X11Util#XLockDisplay(long)}.
@@ -41,20 +45,32 @@ import javax.media.nativewindow.ToolkitLock;
  */
 public class X11JAWTToolkitLock implements ToolkitLock {
     long displayHandle;
+    RecursiveLock lock;
 
     public X11JAWTToolkitLock(long displayHandle) {
         this.displayHandle = displayHandle;
+        if(!X11Util.isNativeLockAvailable()) {
+            lock = LockFactory.createRecursiveLock();
+        }
     }
 
     public final void lock() {
-        if(TRACE_LOCK) { System.err.println("X11JAWTToolkitLock.lock()"); }
+        if(TRACE_LOCK) { System.err.println("X11JAWTToolkitLock.lock() - native: "+(null==lock)); }
         JAWTUtil.lockToolkit();
-        X11Util.XLockDisplay(displayHandle);
+        if(null == lock) {
+            X11Lib.XLockDisplay(displayHandle);
+        } else {
+            lock.lock();
+        }
     }
 
     public final void unlock() {
-        if(TRACE_LOCK) { System.err.println("X11JAWTToolkitLock.unlock()"); }
-        X11Util.XUnlockDisplay(displayHandle);
+        if(TRACE_LOCK) { System.err.println("X11JAWTToolkitLock.unlock() - native: "+(null==lock)); }
+        if(null == lock) {
+            X11Lib.XUnlockDisplay(displayHandle);
+        } else {
+            lock.unlock();
+        }
         JAWTUtil.unlockToolkit();
     }
 }
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java
index 2319d62..35dc234 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java
@@ -38,20 +38,17 @@
 package jogamp.nativewindow.jawt.x11;
 
 import javax.media.nativewindow.AbstractGraphicsConfiguration;
-import javax.media.nativewindow.AbstractGraphicsDevice;
-import javax.media.nativewindow.AbstractGraphicsScreen;
 import javax.media.nativewindow.NativeWindow;
 import javax.media.nativewindow.NativeWindowException;
-import javax.media.nativewindow.NativeWindowFactory;
-import javax.media.nativewindow.awt.AWTGraphicsDevice;
 import javax.media.nativewindow.util.Point;
 
 import jogamp.nativewindow.jawt.JAWT;
 import jogamp.nativewindow.jawt.JAWTFactory;
+import jogamp.nativewindow.jawt.JAWTUtil;
 import jogamp.nativewindow.jawt.JAWTWindow;
 import jogamp.nativewindow.jawt.JAWT_DrawingSurface;
 import jogamp.nativewindow.jawt.JAWT_DrawingSurfaceInfo;
-import jogamp.nativewindow.x11.X11Util;
+import jogamp.nativewindow.x11.X11Lib;
 
 public class X11JAWTWindow extends JAWTWindow {
 
@@ -59,36 +56,22 @@ public class X11JAWTWindow extends JAWTWindow {
     super(comp, config);
   }
 
-  protected void validateNative() throws NativeWindowException {
-    AWTGraphicsDevice awtDevice = (AWTGraphicsDevice) config.getScreen().getDevice();
+  protected void invalidateNative() { }
 
-    if(awtDevice.getHandle() != 0) {
-        // subtype and handle set already, done
-        return;
-    }
-
-    long displayHandle = 0;
-    
-    // first try a pre-existing attached native configuration, ie native X11GraphicsDevice
-    AbstractGraphicsConfiguration aconfig = (null!=config) ? config.getNativeGraphicsConfiguration() : null;
-    AbstractGraphicsScreen ascreen = (null!=aconfig) ? aconfig.getScreen() : null;
-    AbstractGraphicsDevice adevice = (null!=ascreen) ? ascreen.getDevice() : null; // X11GraphicsDevice
-    if(null!=adevice) {
-        displayHandle = adevice.getHandle();
-    }
-
-    if(0 == displayHandle) {
-        displayHandle = X11SunJDKReflection.graphicsDeviceGetDisplay(awtDevice.getGraphicsDevice());
-    }
-    if(0==displayHandle) {
-        throw new InternalError("X11JAWTWindow: No X11 Display handle available");
-    }
-    awtDevice.setSubType(NativeWindowFactory.TYPE_X11, displayHandle);
+  protected void attachSurfaceLayerImpl(final long layerHandle) {
+      throw new UnsupportedOperationException("offscreen layer not supported");
   }
-
+  protected void detachSurfaceLayerImpl(final long layerHandle) {
+      throw new UnsupportedOperationException("offscreen layer not supported");
+  }
+  
+  protected JAWT fetchJAWTImpl() throws NativeWindowException {
+      return JAWTUtil.getJAWT(false); // no offscreen
+  }
+    
   protected int lockSurfaceImpl() throws NativeWindowException {
     int ret = NativeWindow.LOCK_SUCCESS;
-    ds = JAWT.getJAWT().GetDrawingSurface(component);
+    ds = getJAWT().GetDrawingSurface(component);
     if (ds == null) {
       // Widget not yet realized
       unlockSurfaceImpl();
@@ -113,7 +96,8 @@ public class X11JAWTWindow extends JAWTWindow {
       unlockSurfaceImpl();
       return LOCK_SURFACE_NOT_READY;
     }
-    x11dsi = (JAWT_X11DrawingSurfaceInfo) dsi.platformInfo();
+    updateBounds(dsi.getBounds());
+    x11dsi = (JAWT_X11DrawingSurfaceInfo) dsi.platformInfo(getJAWT());
     if (x11dsi == null) {
       unlockSurfaceImpl();
       return LOCK_SURFACE_NOT_READY;
@@ -122,8 +106,6 @@ public class X11JAWTWindow extends JAWTWindow {
     if (drawable == 0) {
       unlockSurfaceImpl();
       return LOCK_SURFACE_NOT_READY;
-    } else {
-      updateBounds(dsi.getBounds());
     }
     return ret;
   }
@@ -136,15 +118,15 @@ public class X11JAWTWindow extends JAWTWindow {
         if (dsLocked) {
             ds.Unlock();
         }
-        JAWT.getJAWT().FreeDrawingSurface(ds);
+        getJAWT().FreeDrawingSurface(ds);
     }
     ds = null;
     dsi = null;
     x11dsi = null;
   }
 
-  protected Point getLocationOnScreenImpl(int x, int y) {
-    return X11Util.GetRelativeLocation( getDisplayHandle(), getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y);
+  protected Point getLocationOnScreenNativeImpl(int x, int y) {
+    return X11Lib.GetRelativeLocation( getDisplayHandle(), getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y);
   }
   
   // Variables for lockSurface/unlockSurface
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java
index b576b0c..08d4714 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java
@@ -55,14 +55,14 @@ import javax.media.nativewindow.awt.AWTGraphicsConfiguration;
     the purposes of correctly enumerating the available visuals. */
 
 public class X11SunJDKReflection {
-  private static Class   x11GraphicsDeviceClass;
-  private static Method  x11GraphicsDeviceGetDisplayMethod;
-  private static Class   x11GraphicsConfigClass;
-  private static Method  x11GraphicsConfigGetVisualMethod;
-  private static boolean initted;
+  private static Class<?> x11GraphicsDeviceClass;
+  private static Method   x11GraphicsDeviceGetDisplayMethod;
+  private static Class<?> x11GraphicsConfigClass;
+  private static Method   x11GraphicsConfigGetVisualMethod;
+  private static boolean initialized;
 
   static {
-    AccessController.doPrivileged(new PrivilegedAction() {
+    AccessController.doPrivileged(new PrivilegedAction<Object>() {
         public Object run() {
           try {
             x11GraphicsDeviceClass = Class.forName("sun.awt.X11GraphicsDevice");
@@ -72,7 +72,7 @@ public class X11SunJDKReflection {
             x11GraphicsConfigClass = Class.forName("sun.awt.X11GraphicsConfig");
             x11GraphicsConfigGetVisualMethod = x11GraphicsConfigClass.getDeclaredMethod("getVisual", new Class[] {});
             x11GraphicsConfigGetVisualMethod.setAccessible(true);
-            initted = true;
+            initialized = true;
           } catch (Exception e) {
             // Either not a Sun JDK or the interfaces have changed since 1.4.2 / 1.5
           }
@@ -82,7 +82,7 @@ public class X11SunJDKReflection {
   }
 
   public static long graphicsDeviceGetDisplay(GraphicsDevice device) {
-    if (!initted) {
+    if (!initialized) {
       return 0;
     }
 
@@ -96,7 +96,7 @@ public class X11SunJDKReflection {
   public static int graphicsConfigurationGetVisualID(AbstractGraphicsConfiguration config) {
       try {
           if (config instanceof AWTGraphicsConfiguration) {
-              return graphicsConfigurationGetVisualID(((AWTGraphicsConfiguration) config).getGraphicsConfiguration());
+              return graphicsConfigurationGetVisualID(((AWTGraphicsConfiguration) config).getAWTGraphicsConfiguration());
           }
           return 0;
       } catch (Exception e) {
@@ -105,7 +105,7 @@ public class X11SunJDKReflection {
   }
 
   public static int graphicsConfigurationGetVisualID(GraphicsConfiguration config) {
-    if (!initted) {
+    if (!initialized) {
       return 0;
     }
 
diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
index ffd23fe..5b1e4b0 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
@@ -1,3 +1,30 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ *    1. Redistributions of source code must retain the above copyright notice, this list of
+ *       conditions and the following disclaimer.
+ *
+ *    2. Redistributions in binary form must reproduce the above copyright notice, this list
+ *       of conditions and the following disclaimer in the documentation and/or other materials
+ *       provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
 package jogamp.nativewindow.macosx;
 
 import javax.media.nativewindow.NativeWindowException;
@@ -34,6 +61,64 @@ public class OSXUtil {
       return (Point) GetLocationOnScreen0(windowOrView, src_x, src_y);
     }
     
+    public static long CreateNSView(int x, int y, int width, int height) {
+      return CreateNSView0(x, y, width, height);
+    }
+    public static void DestroyNSView(long nsView) {
+        DestroyNSView0(nsView);
+    }
+
+    public static long CreateNSWindow(int x, int y, int width, int height) {
+      return CreateNSWindow0(x, y, width, height);
+    }
+    public static void DestroyNSWindow(long nsWindow) {
+        DestroyNSWindow0(nsWindow);
+    }
+    
+    public static long CreateCALayer() {
+        return CreateCALayer0();
+    }
+    public static void AddCASublayer(long rootCALayer, long subCALayer) {
+        if(0==rootCALayer || 0==subCALayer) {
+            throw new IllegalArgumentException("rootCALayer 0x"+Long.toHexString(rootCALayer)+", subCALayer 0x"+Long.toHexString(subCALayer));
+        }
+        AddCASublayer0(rootCALayer, subCALayer);
+    }
+    public static void RemoveCASublayer(long rootCALayer, long subCALayer) {
+        if(0==rootCALayer || 0==subCALayer) {
+            throw new IllegalArgumentException("rootCALayer 0x"+Long.toHexString(rootCALayer)+", subCALayer 0x"+Long.toHexString(subCALayer));
+        }
+        RemoveCASublayer0(rootCALayer, subCALayer);
+    }
+    public static void DestroyCALayer(long caLayer) {
+        if(0==caLayer) {
+            throw new IllegalArgumentException("caLayer 0x"+Long.toHexString(caLayer));
+        }
+        DestroyCALayer0(caLayer);    
+    }
+    
+    public static void RunOnMainThread(boolean waitUntilDone, Runnable runnable) {
+        if(IsMainThread0()) {
+            runnable.run(); // don't leave the JVM
+        } else {
+            RunOnMainThread0(waitUntilDone, runnable);
+        }
+    }
+    
+    public static boolean IsMainThread() {
+        return IsMainThread0();
+    }
+    
     private static native boolean initIDs0();
     private static native Object GetLocationOnScreen0(long windowOrView, int src_x, int src_y);
+    private static native long CreateNSView0(int x, int y, int width, int height);
+    private static native void DestroyNSView0(long nsView);
+    private static native long CreateNSWindow0(int x, int y, int width, int height);
+    private static native void DestroyNSWindow0(long nsWindow);
+    private static native long CreateCALayer0();
+    private static native void AddCASublayer0(long rootCALayer, long subCALayer);
+    private static native void RemoveCASublayer0(long rootCALayer, long subCALayer);
+    private static native void DestroyCALayer0(long caLayer);
+    private static native void RunOnMainThread0(boolean waitUntilDone, Runnable runnable);
+    private static native boolean IsMainThread0();
 }
diff --git a/src/nativewindow/classes/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/jogamp/nativewindow/swt/SWTAccessor.java
index d1f5efc..aab1556 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/swt/SWTAccessor.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/swt/SWTAccessor.java
@@ -42,6 +42,8 @@ import javax.media.nativewindow.x11.X11GraphicsDevice;
 import com.jogamp.common.util.ReflectionUtil;
 import javax.media.nativewindow.macosx.MacOSXGraphicsDevice;
 
+import jogamp.nativewindow.macosx.OSXUtil;
+
 public class SWTAccessor {
     static final Field swt_control_handle;
     static final boolean swt_uses_long_handles;
@@ -60,7 +62,7 @@ public class SWTAccessor {
     static final String str_internal_dispose_GC = "internal_dispose_GC";
 
     static final String str_OS_gtk_class = "org.eclipse.swt.internal.gtk.OS";
-    static final Class OS_gtk_class;
+    static final Class<?> OS_gtk_class;
     static final Method OS_gtk_widget_realize;
     static final Method OS_gtk_widget_unrealize;
     static final Method OS_GTK_WIDGET_WINDOW;
@@ -113,9 +115,9 @@ public class SWTAccessor {
         }
         swt_control_internal_dispose_GC = m;
 
-        Class c=null;                
+        Class<?> c=null;                
         Method m1=null, m2=null, m3=null, m4=null, m5=null;
-        Class handleType = swt_uses_long_handles  ? long.class : int.class ;
+        Class<?> handleType = swt_uses_long_handles  ? long.class : int.class ;
         if( NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false) ) {
             try {
                 c = ReflectionUtil.getClass(str_OS_gtk_class, false, SWTAccessor.class.getClassLoader());
@@ -179,15 +181,19 @@ public class SWTAccessor {
         return h;
     }
 
-    public static void setRealized(Control swtControl, boolean realize) {
-        long handle = getHandle(swtControl);
+    public static void setRealized(final Control swtControl, final boolean realize) {
+        final long handle = getHandle(swtControl);
         
         if(null != OS_gtk_class) {
-            if(realize) {
-                callStaticMethodL2V(OS_gtk_widget_realize, handle);
-            } else {
-                callStaticMethodL2V(OS_gtk_widget_unrealize, handle);
-            }
+            invoke(true, new Runnable() {
+                public void run() {
+                    if(realize) {
+                        callStaticMethodL2V(OS_gtk_widget_realize, handle);
+                    } else {
+                        callStaticMethodL2V(OS_gtk_widget_unrealize, handle);
+                    }                    
+                }
+            });
         }
     }
     
@@ -196,7 +202,9 @@ public class SWTAccessor {
         if( null != OS_gtk_class ) {
             long widgedHandle = callStaticMethodL2L(OS_GTK_WIDGET_WINDOW, handle);
             long displayHandle = callStaticMethodL2L(OS_gdk_x11_drawable_get_xdisplay, widgedHandle);
-            return new X11GraphicsDevice(displayHandle, AbstractGraphicsDevice.DEFAULT_UNIT);
+            // FIXME: May think about creating a private non-shared X11 Display handle, like we use to for AWT
+            //        to avoid locking problems !
+            return new X11GraphicsDevice(displayHandle, AbstractGraphicsDevice.DEFAULT_UNIT, false);
         }
         if( NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(false) ) {
             return new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT);
@@ -220,21 +228,38 @@ public class SWTAccessor {
         throw new UnsupportedOperationException("n/a for this windowing system: "+NativeWindowFactory.getNativeWindowType(false));
     }
     
-    public static long newGC(Control swtControl, GCData gcData) {
-        Object o = ReflectionUtil.callMethod(swtControl, swt_control_internal_new_GC, new Object[] { gcData });
-        if(o instanceof Number) {
-            return ((Number)o).longValue();
+    public static long newGC(final Control swtControl, final GCData gcData) {
+        final Object[] o = new Object[1];
+        invoke(true, new Runnable() {
+            public void run() {
+                o[0] = ReflectionUtil.callMethod(swtControl, swt_control_internal_new_GC, new Object[] { gcData });
+            }
+        });
+        if(o[0] instanceof Number) {
+            return ((Number)o[0]).longValue();
         } else {
-            throw new InternalError("SWT internal_new_GC did not return int or long but "+o.getClass());
+            throw new InternalError("SWT internal_new_GC did not return int or long but "+o[0].getClass());
         }
     }
 
-    public static void disposeGC(Control swtControl, long gc, GCData gcData) {
-        if(swt_uses_long_handles) {
-            ReflectionUtil.callMethod(swtControl, swt_control_internal_dispose_GC, new Object[] { new Long(gc), gcData });
-        }  else {
-            ReflectionUtil.callMethod(swtControl, swt_control_internal_dispose_GC, new Object[] { new Integer((int)gc), gcData });
-        }
+    public static void disposeGC(final Control swtControl, final long gc, final GCData gcData) {
+        invoke(true, new Runnable() {
+            public void run() {
+                if(swt_uses_long_handles) {
+                    ReflectionUtil.callMethod(swtControl, swt_control_internal_dispose_GC, new Object[] { new Long(gc), gcData });
+                }  else {
+                    ReflectionUtil.callMethod(swtControl, swt_control_internal_dispose_GC, new Object[] { new Integer((int)gc), gcData });
+                }
+            }
+        });
+    }
+    
+    public static void invoke(boolean wait, Runnable runnable) {
+        if(Platform.OS_TYPE == Platform.OSType.MACOS) {
+            OSXUtil.RunOnMainThread(wait, runnable);
+        } else {
+            runnable.run();
+        }        
     }
     
 }
diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java
index 68cf8af..090ece5 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java
@@ -61,14 +61,22 @@ public class GDISurface extends ProxySurface {
         throw new InternalError("surface not released");
     }
     surfaceHandle = GDI.GetDC(windowHandle);
+    /*
+    if(0 == surfaceHandle) {
+        System.err.println("****** DC Acquire: 0x"+Long.toHexString(windowHandle)+", isWindow "+GDI.IsWindow(windowHandle)+", isVisible "+GDI.IsWindowVisible(windowHandle)+", GDI LastError: "+GDI.GetLastError()+", 0x"+Long.toHexString(surfaceHandle)+", GDI LastError: "+GDI.GetLastError()+", thread: "+Thread.currentThread().getName());
+        Thread.dumpStack();
+    }
+    */
     return (0 != surfaceHandle) ? LOCK_SUCCESS : LOCK_SURFACE_NOT_READY;
   }
 
   protected void unlockSurfaceImpl() {
     if (0 == surfaceHandle) {
-        throw new InternalError("surface not acquired");
+        throw new InternalError("surface not acquired: "+this+", thread: "+Thread.currentThread().getName());
+    }
+    if(0 == GDI.ReleaseDC(windowHandle, surfaceHandle)) {
+        throw new NativeWindowException("DC not released: "+this+", isWindow "+GDI.IsWindow(windowHandle)+", werr "+GDI.GetLastError()+", thread: "+Thread.currentThread().getName());        
     }
-    GDI.ReleaseDC(windowHandle, surfaceHandle);
     surfaceHandle=0;
   }
 
@@ -77,7 +85,7 @@ public class GDISurface extends ProxySurface {
   }
 
   public String toString() {
-    return "GDISurface[config "+config+
+    return "GDISurface[config "+getPrivateGraphicsConfiguration()+
                 ", displayHandle 0x"+Long.toHexString(getDisplayHandle())+
                 ", windowHandle 0x"+Long.toHexString(windowHandle)+
                 ", surfaceHandle 0x"+Long.toHexString(getSurfaceHandle())+
diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java
new file mode 100644
index 0000000..be531d9
--- /dev/null
+++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java
@@ -0,0 +1,101 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ *    1. Redistributions of source code must retain the above copyright notice, this list of
+ *       conditions and the following disclaimer.
+ *
+ *    2. Redistributions in binary form must reproduce the above copyright notice, this list
+ *       of conditions and the following disclaimer in the documentation and/or other materials
+ *       provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package jogamp.nativewindow.windows;
+
+import javax.media.nativewindow.util.Point;
+import javax.media.nativewindow.NativeWindowException;
+
+import jogamp.nativewindow.NWJNILibLoader;
+import jogamp.nativewindow.Debug;
+import jogamp.nativewindow.x11.X11Util;
+
+public class GDIUtil {
+    private static final boolean DEBUG = Debug.debug("GDIUtil");
+  
+    private static final String dummyWindowClassNameBase = "_dummyWindow_clazz" ;
+    private static RegisteredClassFactory dummyWindowClassFactory;
+    private static boolean isInit = false;
+  
+    public static synchronized void initSingleton(boolean firstX11ActionOnProcess) {
+        if(!isInit) {
+            synchronized(X11Util.class) {
+                if(!isInit) {
+                    isInit = true;
+                    NWJNILibLoader.loadNativeWindow("win32");
+
+                    if( !initIDs0() ) {
+                        throw new NativeWindowException("GDI: Could not initialized native stub");
+                    }
+
+                    if(DEBUG) {
+                        System.out.println("GDI.isFirstX11ActionOnProcess: "+firstX11ActionOnProcess);
+                    }
+
+                    dummyWindowClassFactory = new RegisteredClassFactory(dummyWindowClassNameBase, getDummyWndProc0());
+                }
+            }
+        }
+    }
+  
+    public static boolean requiresToolkitLock() { return false; }
+  
+    private static RegisteredClass dummyWindowClass = null;
+    private static Object dummyWindowSync = new Object();
+  
+    public static long CreateDummyWindow(int x, int y, int width, int height) {
+        synchronized(dummyWindowSync) {
+            dummyWindowClass = dummyWindowClassFactory.getSharedClass();
+            return CreateDummyWindow0(dummyWindowClass.getHandle(), dummyWindowClass.getName(), dummyWindowClass.getName(), x, y, width, height);
+        }
+    }
+  
+    public static boolean DestroyDummyWindow(long hwnd) {
+        boolean res;
+        synchronized(dummyWindowSync) {
+            if( null == dummyWindowClass ) {
+                throw new InternalError("GDI Error ("+dummyWindowClassFactory.getSharedRefCount()+"): SharedClass is null");
+            }
+            res = GDI.DestroyWindow(hwnd);
+            dummyWindowClassFactory.releaseSharedClass();
+        }
+        return res;
+    }
+  
+    public static Point GetRelativeLocation(long src_win, long dest_win, int src_x, int src_y) {
+        return (Point) GetRelativeLocation0(src_win, dest_win, src_x, src_y);
+    }
+    
+    public static native boolean CreateWindowClass(long hInstance, String clazzName, long wndProc);
+    public static native boolean DestroyWindowClass(long hInstance, String className);
+    
+    private static native boolean initIDs0();
+    private static native long getDummyWndProc0();  
+    private static native Object GetRelativeLocation0(long src_win, long dest_win, int src_x, int src_y);
+  
+    static native long CreateDummyWindow0(long hInstance, String className, String windowName, int x, int y, int width, int height);  
+}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java
index 15e0a67..00bedfc 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java
@@ -34,34 +34,44 @@ import javax.media.nativewindow.NativeWindowException;
 
 public class RegisteredClassFactory {
     static final boolean DEBUG = Debug.debug("RegisteredClass");
-    private static ArrayList sharedClasses = new ArrayList();
+    private static ArrayList<RegisteredClassFactory> registeredFactories = new ArrayList<RegisteredClassFactory>();    
+    
     private String classBaseName;
-    long wndProc;
+    private long wndProc;
 
     private RegisteredClass sharedClass = null;
     private int classIter = 0;
     private int sharedRefCount = 0;
-    private Object sync = new Object();
+    private final Object sync = new Object();
 
     /**
-     * Intended for a JVM shutdown hook, hence little synchronization
+     * Release the {@link RegisteredClass} of all {@link RegisteredClassFactory}. 
      */
     public static void shutdownSharedClasses() {
-        synchronized(sharedClasses) {
-            for(int i=0; i<sharedClasses.size(); i++) {
-                RegisteredClass sc = (RegisteredClass) sharedClasses.get(i);
-                GDI.DestroyWindowClass(sc.getHandle(), sc.getName());
-                if(DEBUG) {
-                  System.err.println("RegisteredClassFactory shutdownSharedClasses "+i+"/"+sharedClasses.size()+": "+sc);
+        synchronized(registeredFactories) {
+            for(int j=0; j<registeredFactories.size(); j++) {
+                final RegisteredClassFactory rcf = registeredFactories.get(j);
+                synchronized(rcf.sync) {
+                    if(null != rcf.sharedClass) {
+                        GDIUtil.DestroyWindowClass(rcf.sharedClass.getHandle(), rcf.sharedClass.getName());
+                        rcf.sharedClass = null;
+                        rcf.sharedRefCount = 0;
+                        rcf.classIter = 0;                 
+                        if(DEBUG) {
+                          System.err.println("RegisteredClassFactory #"+j+"/"+registeredFactories.size()+" shutdownSharedClasses : "+rcf.sharedClass);
+                        }
+                    }
                 }
             }
-            sharedClasses.clear();
         }
     }
 
     public RegisteredClassFactory(String classBaseName, long wndProc) {
         this.classBaseName = classBaseName;
         this.wndProc = wndProc;
+        synchronized(registeredFactories) {
+            registeredFactories.add(this);
+        }
     }
 
     public RegisteredClass getSharedClass() throws NativeWindowException {
@@ -76,19 +86,17 @@ public class RegisteredClassFactory {
               }
               String clazzName = null;
               boolean registered = false;
-              while ( !registered && Integer.MAX_VALUE >= classIter ) {
+              final int classIterMark = classIter - 1; 
+              while ( !registered && classIterMark != classIter ) {
                   // Retry with next clazz name, this could happen if more than one JVM is running
                   clazzName = classBaseName + classIter;
                   classIter++;
-                  registered = GDI.CreateWindowClass(hInstance, clazzName, wndProc);
+                  registered = GDIUtil.CreateWindowClass(hInstance, clazzName, wndProc);
               }
               if( !registered ) {
                   throw new NativeWindowException("Error: Could not create WindowClass: "+clazzName);
               }
               sharedClass = new RegisteredClass(hInstance, clazzName);
-              synchronized(sharedClasses) {
-                  sharedClasses.add(sharedClass);
-              }
               if(DEBUG) {
                   System.err.println("RegisteredClassFactory getSharedClass ("+sharedRefCount+") initialized: "+sharedClass);
               }
@@ -113,10 +121,7 @@ public class RegisteredClassFactory {
               throw new InternalError("Error ("+sharedRefCount+"): SharedClass is null");
           }
           if( 0 == sharedRefCount ) {
-              GDI.DestroyWindowClass(sharedClass.getHandle(), sharedClass.getName());
-              synchronized(sharedClasses) {
-                  sharedClasses.remove(sharedClass);
-              }
+              GDIUtil.DestroyWindowClass(sharedClass.getHandle(), sharedClass.getName());
               if(DEBUG) {
                   System.err.println("RegisteredClassFactory releaseSharedClass ("+sharedRefCount+") released: "+sharedClass);
               }
diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java
index b669bce..2684162 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java
@@ -33,10 +33,22 @@
 
 package jogamp.nativewindow.x11;
 
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.x11.*;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.AbstractGraphicsScreen;
+import javax.media.nativewindow.CapabilitiesChooser;
+import javax.media.nativewindow.CapabilitiesImmutable;
+import javax.media.nativewindow.GraphicsConfigurationFactory;
+import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.x11.X11GraphicsConfiguration;
+import javax.media.nativewindow.x11.X11GraphicsScreen;
 
 public class X11GraphicsConfigurationFactory extends GraphicsConfigurationFactory {
+    public static void registerFactory() {
+        GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.x11.X11GraphicsDevice.class, new X11GraphicsConfigurationFactory());
+    }    
+    private X11GraphicsConfigurationFactory() {
+    }
+    
     protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
         CapabilitiesImmutable  capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen screen)
         throws IllegalArgumentException, NativeWindowException {
@@ -55,7 +67,7 @@ public class X11GraphicsConfigurationFactory extends GraphicsConfigurationFactor
         int num[] = { -1 };
         long display = screen.getDevice().getHandle();
 
-        XVisualInfo[] xvis = X11Util.XGetVisualInfo(display, X11Lib.VisualIDMask|X11Lib.VisualScreenMask, xvi_temp, num, 0);
+        XVisualInfo[] xvis = X11Lib.XGetVisualInfo(display, X11Lib.VisualIDMask|X11Lib.VisualScreenMask, xvi_temp, num, 0);
 
         if(xvis==null || num[0]<1) {
             return null;
@@ -81,7 +93,7 @@ public class X11GraphicsConfigurationFactory extends GraphicsConfigurationFactor
         vinfo_template.setC_class(c_class);
         long display = screen.getDevice().getHandle();
 
-        XVisualInfo[] vinfos = X11Util.XGetVisualInfo(display, X11Lib.VisualScreenMask, vinfo_template, num, 0);
+        XVisualInfo[] vinfos = X11Lib.XGetVisualInfo(display, X11Lib.VisualScreenMask, vinfo_template, num, 0);
         XVisualInfo best=null;
         int rdepth = capabilities.getRedBits() + capabilities.getGreenBits() + capabilities.getBlueBits() + capabilities.getAlphaBits();
         for (int i = 0; vinfos!=null && i < num[0]; i++) {
diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11ToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11ToolkitLock.java
index fb0aff1..5166ef5 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11ToolkitLock.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11ToolkitLock.java
@@ -29,6 +29,9 @@ package jogamp.nativewindow.x11;
 
 import javax.media.nativewindow.ToolkitLock;
 
+import com.jogamp.common.util.locks.LockFactory;
+import com.jogamp.common.util.locks.RecursiveLock;
+
 /**
  * Implementing a recursive {@link javax.media.nativewindow.ToolkitLock}
  * utilizing {@link X11Util#XLockDisplay(long)}.
@@ -38,18 +41,30 @@ import javax.media.nativewindow.ToolkitLock;
  */
 public class X11ToolkitLock implements ToolkitLock {
     long displayHandle;
+    RecursiveLock lock;
 
     public X11ToolkitLock(long displayHandle) {
         this.displayHandle = displayHandle;
+        if(!X11Util.isNativeLockAvailable()) {
+            lock = LockFactory.createRecursiveLock();
+        }
     }
 
     public final void lock() {
-        if(TRACE_LOCK) { System.err.println("X11ToolkitLock.lock()"); }
-        X11Util.XLockDisplay(displayHandle);
+        if(TRACE_LOCK) { System.err.println("X11ToolkitLock.lock() - native: "+(null==lock)); }
+        if(null == lock) {
+            X11Lib.XLockDisplay(displayHandle);
+        } else {
+            lock.lock();
+        }
     }
 
     public final void unlock() {
-        if(TRACE_LOCK) { System.err.println("X11ToolkitLock.unlock()"); }
-        X11Util.XUnlockDisplay(displayHandle);
+        if(TRACE_LOCK) { System.err.println("X11ToolkitLock.unlock() - native: "+(null==lock)); }
+        if(null == lock) {
+            X11Lib.XUnlockDisplay(displayHandle);
+        } else {
+            lock.unlock();
+        }
     }
 }
diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java
index 5c18392..560130d 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java
@@ -33,19 +33,18 @@
 
 package jogamp.nativewindow.x11;
 
-import com.jogamp.common.util.LongObjectHashMap;
-import jogamp.nativewindow.Debug;
-import jogamp.nativewindow.NWJNILibLoader;
-
-import javax.media.nativewindow.*;
-
-import java.nio.Buffer;
-import java.nio.IntBuffer;
-import java.nio.ShortBuffer;
 import java.security.AccessController;
 import java.util.ArrayList;
 import java.util.List;
-import javax.media.nativewindow.util.Point;
+
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.NativeWindowFactory;
+
+import jogamp.nativewindow.Debug;
+import jogamp.nativewindow.NWJNILibLoader;
+
+import com.jogamp.common.util.LongObjectHashMap;
 
 /**
  * Contains a thread safe X11 utility to retrieve display connections.
@@ -53,54 +52,88 @@ import javax.media.nativewindow.util.Point;
 public class X11Util {
     /** 
      * See Bug 515 - https://jogamp.org/bugzilla/show_bug.cgi?id=515
-     * 
-     * It is observed that ATI X11 drivers, eg. fglrx 8.78.6 and fglrx 11.08/8.881,
+     * <p> 
+     * It is observed that ATI X11 drivers, eg.
+     * <ul> 
+     *   <li>fglrx 8.78.6,</li>
+     *   <li>fglrx 11.08/8.881 and </li>
+     *   <li>fglrx 11.11/8.911</li>
+     * </ul>  
      * are quite sensitive to multiple Display connections.
-     * Here, closing displays shall happen in the same order as
-     * they were opened, -OR- shall not be closed at all!
-     * Otherwise some driver related bug appears and brings down the JVM.
+     * </p>
+     * <p>
+     * With the above drivers closing displays shall happen in the same order as
+     * they were opened, <b>or</b> shall not be closed at all!
+     * If closed, some driver related bug appears and brings down the JVM.
+     * </p>
+     * <p>
      * You may test this, ie just reverse the destroy order below.
      * See also native test: jogl/test/native/displayMultiple02.c
-     * 
-     * Our current 'workaround' is to not close them at all if driver vendor is ATI.
+     * </p>
+     * <p>
+     * Workaround is to not close them at all if driver vendor is ATI.
+     * </p>
      */
     public static final boolean ATI_HAS_XCLOSEDISPLAY_BUG = true;
-    
-    public static final boolean XINITTHREADS_ALWAYS_ENABLED = true;
 
+    /** Value is <code>true</code>, best 'stable' results if always using XInitThreads(). */
+    public static final boolean XINITTHREADS_ALWAYS_ENABLED = true;
+    
+    /** Value is <code>true</code>, best 'stable' results if not using XLockDisplay/XUnlockDisplay at all. */
+    public static final boolean HAS_XLOCKDISPLAY_BUG = true;
+    
     private static final boolean DEBUG = Debug.debug("X11Util");
     private static final boolean TRACE_DISPLAY_LIFECYCLE = Debug.getBooleanProperty("nativewindow.debug.X11Util.TraceDisplayLifecycle", true, AccessController.getContext());
 
-    private static volatile String nullDisplayName = null;
-    private static boolean requiresX11Lock = false;
-    private static boolean isInit = false;
+    private static String nullDisplayName = null;
+    private static boolean isX11LockAvailable = false;
+    private static boolean requiresX11Lock = true;
+    private static volatile boolean isInit = false;
     private static boolean markAllDisplaysUnclosable = false; // ATI/AMD X11 driver issues
 
     private static int setX11ErrorHandlerRecCount = 0;
     private static Object setX11ErrorHandlerLock = new Object();
 
     
-    public static synchronized void initSingleton(final boolean firstX11ActionOnProcess) {
+    @SuppressWarnings("unused")
+    public static void initSingleton(final boolean firstX11ActionOnProcess) {
         if(!isInit) {
-            NWJNILibLoader.loadNativeWindow("x11");
-
-            /**
-             * Always issue XInitThreads() since we have independent
-             * off-thread created Display connections able to utilize multithreading, 
-             * ie NEWT (jogamp.newt.x11.X11Display.createNativeImpl()) !!
-             */
-            initialize0( XINITTHREADS_ALWAYS_ENABLED ? true : firstX11ActionOnProcess );
-
-            requiresX11Lock = !firstX11ActionOnProcess ;
-            
-            if(DEBUG) {
-                System.err.println("X11Util firstX11ActionOnProcess: "+firstX11ActionOnProcess+
-                                   ", XINITTHREADS_ALWAYS_ENABLED "+XINITTHREADS_ALWAYS_ENABLED+
-                                   ", requiresX11Lock "+requiresX11Lock); 
+            synchronized(X11Util.class) {
+                if(!isInit) {
+                    isInit = true;
+                    NWJNILibLoader.loadNativeWindow("x11");
+        
+                    final boolean callXInitThreads = XINITTHREADS_ALWAYS_ENABLED || firstX11ActionOnProcess;
+                    final boolean isXInitThreadsOK = initialize0( XINITTHREADS_ALWAYS_ENABLED || firstX11ActionOnProcess );
+                    isX11LockAvailable = isXInitThreadsOK && !HAS_XLOCKDISPLAY_BUG ;
+        
+                    final long dpy = X11Lib.XOpenDisplay(null);
+                    try {
+                        nullDisplayName = X11Lib.XDisplayString(dpy);
+                    } finally {
+                        X11Lib.XCloseDisplay(dpy);
+                    }
+                    
+                    if(DEBUG) {
+                        System.err.println("X11Util firstX11ActionOnProcess: "+firstX11ActionOnProcess+
+                                           ", requiresX11Lock "+requiresX11Lock+
+                                           ", XInitThreads [called "+callXInitThreads+", OK "+isXInitThreadsOK+"]"+
+                                           ", isX11LockAvailable "+isX11LockAvailable+
+                                           ", X11 Display(NULL) <"+nullDisplayName+">");
+                        // Thread.dumpStack();
+                    }
+                }
             }
-            isInit = true;
         }
     }
+    
+    public static synchronized boolean isNativeLockAvailable() {
+        return isX11LockAvailable;
+    }
+
+    public static synchronized boolean requiresToolkitLock() {
+        return requiresX11Lock;
+    }
 
     public static void setX11ErrorHandler(boolean onoff, boolean quiet) {
         synchronized(setX11ErrorHandlerLock) {
@@ -121,42 +154,7 @@ public class X11Util {
         }
     }
 
-    public static boolean requiresToolkitLock() {
-        return requiresX11Lock;
-    }
-
-    public static void lockDefaultToolkit(long dpyHandle) {
-        NativeWindowFactory.getDefaultToolkitLock().lock();
-        if(requiresX11Lock) {
-            X11Util.XLockDisplay(dpyHandle);
-        }
-    }
-
-    public static void unlockDefaultToolkit(long dpyHandle) {
-        if(requiresX11Lock) {
-            X11Util.XUnlockDisplay(dpyHandle);
-        }
-        NativeWindowFactory.getDefaultToolkitLock().unlock();
-    }
-
     public static String getNullDisplayName() {
-        if(null==nullDisplayName) { // volatile: ok
-            synchronized(X11Util.class) {
-                if(null==nullDisplayName) {
-                    NativeWindowFactory.getDefaultToolkitLock().lock();
-                    long dpy = X11Lib.XOpenDisplay(null);
-                    try {
-                        nullDisplayName = X11Lib.XDisplayString(dpy);
-                    } finally {
-                        X11Lib.XCloseDisplay(dpy);
-                        NativeWindowFactory.getDefaultToolkitLock().unlock();
-                    }
-                    if(DEBUG) {
-                        System.out.println("X11 Display(NULL) <"+nullDisplayName+">");
-                    }
-                }
-            }
-        }
         return nullDisplayName;
     }
     
@@ -224,7 +222,6 @@ public class X11Util {
 
         public final void setUncloseable(boolean v) { unCloseable = v; }
         public final boolean isUncloseable() { return unCloseable; }
-
         public final Throwable getCreationStack() { return creationStack; }
 
         @Override
@@ -238,20 +235,22 @@ public class X11Util {
         }
     }
 
-    /** Returns the number of unclosed X11 Displays.
+    /** 
+     * Cleanup resources. 
+     * If <code>realXCloseOpenAndPendingDisplays</code> is <code>false</code>, 
+     * keep alive all references (open display connection) for restart on same ClassLoader.
+     * 
+     * @return number of unclosed X11 Displays.<br>
      * @param realXCloseOpenAndPendingDisplays if true, {@link #closePendingDisplayConnections()} is called.
-      */
+     */
     public static int shutdown(boolean realXCloseOpenAndPendingDisplays, boolean verbose) {
         int num=0;
         if(DEBUG||verbose||pendingDisplayList.size() > 0) {
-            String msg = "X11Util.Display: Shutdown (close open / pending Displays: "+realXCloseOpenAndPendingDisplays+
-                         ", open (no close attempt): "+openDisplayMap.size()+"/"+openDisplayList.size()+
-                         ", pending (not closed, marked uncloseable): "+pendingDisplayList.size()+")" ;
+            System.err.println("X11Util.Display: Shutdown (close open / pending Displays: "+realXCloseOpenAndPendingDisplays+
+                               ", open (no close attempt): "+openDisplayMap.size()+"/"+openDisplayList.size()+
+                               ", pending (not closed, marked uncloseable): "+pendingDisplayList.size()+")");
             if(DEBUG) {
-                Exception e = new Exception(msg);
-                e.printStackTrace();
-            } else {
-                System.err.println(msg);
+                Thread.dumpStack();
             }
             if( openDisplayList.size() > 0) {
                 X11Util.dumpOpenDisplayConnections();
@@ -264,10 +263,11 @@ public class X11Util {
         synchronized(globalLock) {
             if(realXCloseOpenAndPendingDisplays) {
                 closePendingDisplayConnections();    
+                openDisplayList.clear();
+                pendingDisplayList.clear();
+                openDisplayMap.clear();
+                shutdown0();
             }
-            openDisplayList.clear();
-            pendingDisplayList.clear();
-            openDisplayMap.clear();
         }
         return num;
     }
@@ -304,9 +304,9 @@ public class X11Util {
     public static void dumpOpenDisplayConnections() {
         synchronized(globalLock) {
             System.err.println("X11Util: Open X11 Display Connections: "+openDisplayList.size());
-            for(int i=0; i<pendingDisplayList.size(); i++) {
+            for(int i=0; i<openDisplayList.size(); i++) {
                 NamedDisplay ndpy = openDisplayList.get(i);
-                System.err.println("X11Util: ["+i+"]: "+ndpy);
+                System.err.println("X11Util: Open["+i+"]: "+ndpy);
                 if(null!=ndpy) {
                     Throwable t = ndpy.getCreationStack();
                     if(null!=t) {
@@ -316,7 +316,7 @@ public class X11Util {
             }
         }
     }
-
+    
     public static int getPendingDisplayConnectionNumber() {
         synchronized(globalLock) {
             return pendingDisplayList.size();
@@ -328,7 +328,7 @@ public class X11Util {
             System.err.println("X11Util: Pending X11 Display Connections: "+pendingDisplayList.size());
             for(int i=0; i<pendingDisplayList.size(); i++) {
                 NamedDisplay ndpy = (NamedDisplay) pendingDisplayList.get(i);
-                System.err.println("X11Util: ["+i+"]: "+ndpy);
+                System.err.println("X11Util: Pending["+i+"]: "+ndpy);
                 if(null!=ndpy) {
                     Throwable t = ndpy.getCreationStack();
                     if(null!=t) {
@@ -384,8 +384,8 @@ public class X11Util {
             }
         }
         if(DEBUG) {
-            Exception e = new Exception("X11Util.Display: openDisplay [reuse "+reused+"] "+namedDpy+". Thread "+Thread.currentThread().getName());
-            e.printStackTrace();
+            System.err.println("X11Util.Display: openDisplay [reuse "+reused+"] "+namedDpy+". Thread "+Thread.currentThread().getName());
+            // Thread.dumpStack();
         }
         return namedDpy.getHandle();
     }
@@ -408,10 +408,6 @@ public class X11Util {
             if(!openDisplayList.remove(namedDpy)) { throw new RuntimeException("Internal: "+namedDpy); }
             
             if(!namedDpy.isUncloseable()) {
-                if(DEBUG) {
-                    System.err.println("X11Util.Display: XCloseDisplay "+namedDpy+". Thread "+Thread.currentThread().getName());
-                    Thread.dumpStack();
-                }
                 XCloseDisplay(namedDpy.getHandle());
             } else {
                 // for reuse
@@ -439,7 +435,7 @@ public class X11Util {
 
     public static String validateDisplayName(String name, long handle) {
         if( ( null==name || AbstractGraphicsDevice.DEFAULT_CONNECTION.equals(name) ) && 0!=handle) {
-            name = XDisplayString(handle);
+            name = X11Lib.XDisplayString(handle);
         }
         return validateDisplayName(name);
     }
@@ -455,8 +451,8 @@ public class X11Util {
         try {
             long handle = X11Lib.XOpenDisplay(arg0);
             if(TRACE_DISPLAY_LIFECYCLE) {
-                Throwable t = new Throwable(Thread.currentThread()+" - X11Util.XOpenDisplay("+arg0+") 0x"+Long.toHexString(handle));
-                t.printStackTrace();
+                System.err.println(Thread.currentThread()+" - X11Util.XOpenDisplay("+arg0+") 0x"+Long.toHexString(handle));
+                // Thread.dumpStack();
             }
             return handle;
         } finally {
@@ -468,8 +464,8 @@ public class X11Util {
         NativeWindowFactory.getDefaultToolkitLock().lock();
         try {
             if(TRACE_DISPLAY_LIFECYCLE) {
-                Throwable t = new Throwable(Thread.currentThread()+" - X11Util.XCloseDisplay() 0x"+Long.toHexString(display));
-                t.printStackTrace();
+                System.err.println(Thread.currentThread()+" - X11Util.XCloseDisplay() 0x"+Long.toHexString(display));
+                // Thread.dumpStack();
             }
             int res = -1;            
             X11Util.setX11ErrorHandler(true, DEBUG ? false : true);
@@ -487,209 +483,7 @@ public class X11Util {
         }
     }
 
-    public static int XFree(Buffer arg0)  {
-        NativeWindowFactory.getDefaultToolkitLock().lock();
-        try {
-            return X11Lib.XFree(arg0);
-        } finally {
-            NativeWindowFactory.getDefaultToolkitLock().unlock();
-        }
-    }
-
-    public static int XSync(long display, boolean discard) {
-        lockDefaultToolkit(display);
-        try {
-            return X11Lib.XSync(display, discard);
-        } finally {
-            unlockDefaultToolkit(display);
-        }
-    }
-
-    public static void XSynchronize(long display, boolean onoff) {
-        lockDefaultToolkit(display);
-        try {
-            X11Lib.XSynchronize(display, onoff);
-        } finally {
-            unlockDefaultToolkit(display);
-        }
-    }
-
-    public static boolean XineramaEnabled(long display) {
-        lockDefaultToolkit(display);
-        try {
-            return X11Lib.XineramaEnabled(display);
-        } finally {
-            unlockDefaultToolkit(display);
-        }
-    }
-
-    public static int DefaultScreen(long display) {
-        lockDefaultToolkit(display);
-        try {
-            return X11Lib.DefaultScreen(display);
-        } finally {
-            unlockDefaultToolkit(display);
-        }
-    }
-
-    public static long RootWindow(long display, int screen_number) {
-        lockDefaultToolkit(display);
-        try {
-            return X11Lib.RootWindow(display, screen_number);
-        } finally {
-            unlockDefaultToolkit(display);
-        }
-    }
-
-    public static long XCreatePixmap(long display, long arg1, int arg2, int arg3, int arg4) {
-        lockDefaultToolkit(display);
-        try {
-            return X11Lib.XCreatePixmap(display, arg1, arg2, arg3, arg4);
-        } finally {
-            unlockDefaultToolkit(display);
-        }
-    }
-
-    public static String XDisplayString(long display) {
-        lockDefaultToolkit(display);
-        try {
-            return X11Lib.XDisplayString(display);
-        } finally {
-            unlockDefaultToolkit(display);
-        }
-    }
-
-    public static int XFlush(long display) {
-        lockDefaultToolkit(display);
-        try {
-            return X11Lib.XFlush(display);
-        } finally {
-            unlockDefaultToolkit(display);
-        }
-    }
-
-    public static int XFreePixmap(long display, long arg1) {
-        lockDefaultToolkit(display);
-        try {
-            return X11Lib.XFreePixmap(display, arg1);
-        } finally {
-            unlockDefaultToolkit(display);
-        }
-    }
-
-    public static long DefaultVisualID(long display, int screen) {
-        lockDefaultToolkit(display);
-        try {
-            return X11Lib.DefaultVisualID(display, screen);
-        } finally {
-            unlockDefaultToolkit(display);
-        }
-    }
-
-    public static long CreateDummyWindow(long display, int screen_index, long visualID, int width, int height) {
-        lockDefaultToolkit(display);
-        try {
-            return X11Lib.CreateDummyWindow(display, screen_index, visualID, width, height);
-        } finally {
-            unlockDefaultToolkit(display);
-        }
-    }
-
-    public static void DestroyDummyWindow(long display, long window) {
-        lockDefaultToolkit(display);
-        try {
-            X11Lib.DestroyDummyWindow(display, window);
-        } finally {
-            unlockDefaultToolkit(display);
-        }
-    }
-
-    public static Point GetRelativeLocation(long display, int screen_index, long src_win, long dest_win, int src_x, int src_y) {
-        lockDefaultToolkit(display);
-        try {
-            return X11Lib.GetRelativeLocation(display, screen_index, src_win, dest_win, src_x, src_y);
-        } finally {
-            unlockDefaultToolkit(display);
-        }
-    }
-
-    public static XVisualInfo[] XGetVisualInfo(long display, long arg1, XVisualInfo arg2, int[] arg3, int arg3_offset) {
-        lockDefaultToolkit(display);
-        try {
-            return X11Lib.XGetVisualInfo(display, arg1, arg2, arg3, arg3_offset);
-        } finally {
-            unlockDefaultToolkit(display);
-        }
-    }
-
-    public static boolean XF86VidModeGetGammaRamp(long display, int screen, int size, ShortBuffer red_array, ShortBuffer green_array, ShortBuffer blue_array)  {
-        lockDefaultToolkit(display);
-        try {
-            return X11Lib.XF86VidModeGetGammaRamp(display, screen, size, red_array, green_array, blue_array);
-        } finally {
-            unlockDefaultToolkit(display);
-        }
-    }
-
-    public static boolean XF86VidModeGetGammaRamp(long display, int screen, int size, short[] red_array, int red_array_offset, short[] green_array, int green_array_offset, short[] blue_array, int blue_array_offset)  {
-        lockDefaultToolkit(display);
-        try {
-            return X11Lib.XF86VidModeGetGammaRamp(display, screen, size, red_array, red_array_offset, green_array, green_array_offset, blue_array, blue_array_offset);
-        } finally {
-            unlockDefaultToolkit(display);
-        }
-    }
-
-    public static boolean XF86VidModeGetGammaRampSize(long display, int screen, IntBuffer size)  {
-        lockDefaultToolkit(display);
-        try {
-            return X11Lib.XF86VidModeGetGammaRampSize(display, screen, size);
-        } finally {
-            unlockDefaultToolkit(display);
-        }
-    }
-
-    public static boolean XF86VidModeGetGammaRampSize(long display, int screen, int[] size, int size_offset)  {
-        lockDefaultToolkit(display);
-        try {
-            return X11Lib.XF86VidModeGetGammaRampSize(display, screen, size, size_offset);
-        } finally {
-            unlockDefaultToolkit(display);
-        }
-    }
-
-    public static boolean XF86VidModeSetGammaRamp(long display, int screen, int size, ShortBuffer red_array, ShortBuffer green_array, ShortBuffer blue_array)  {
-        lockDefaultToolkit(display);
-        try {
-            return X11Lib.XF86VidModeSetGammaRamp(display, screen, size, red_array, green_array, blue_array);
-        } finally {
-            unlockDefaultToolkit(display);
-        }
-    }
-
-    public static boolean XF86VidModeSetGammaRamp(long display, int screen, int size, short[] red_array, int red_array_offset, short[] green_array, int green_array_offset, short[] blue_array, int blue_array_offset)  {
-        lockDefaultToolkit(display);
-        try {
-            return X11Lib.XF86VidModeSetGammaRamp(display, screen, size, red_array, red_array_offset, green_array, green_array_offset, blue_array, blue_array_offset);
-        } finally {
-            unlockDefaultToolkit(display);
-        }
-    }
-
-    public static void XLockDisplay(long handle) {
-        if(ToolkitLock.TRACE_LOCK) {
-            System.out.println("+++ X11 Display Lock get 0x"+Long.toHexString(handle));
-        }
-        X11Lib.XLockDisplay(handle);
-    }
-
-    public static void XUnlockDisplay(long handle) {
-        if(ToolkitLock.TRACE_LOCK) {
-            System.out.println("--- X11 Display Lock rel 0x"+Long.toHexString(handle));
-        }
-        X11Lib.XUnlockDisplay(handle);
-    }
-
-    private static native void initialize0(boolean firstUIActionOnProcess);
+    private static native boolean initialize0(boolean firstUIActionOnProcess);
+    private static native void shutdown0();
     private static native void setX11ErrorHandler0(boolean onoff, boolean quiet);
 }
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java b/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java
similarity index 64%
rename from src/jogl/classes/jogamp/opengl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
rename to src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java
index 9ee20d8..efaf472 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java
@@ -31,65 +31,69 @@
  * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  */
 
-package jogamp.opengl.x11.glx.awt;
+package jogamp.nativewindow.x11.awt;
 
 import java.awt.GraphicsConfiguration;
 import java.awt.GraphicsDevice;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.x11.*;
-import javax.media.nativewindow.awt.*;
-import javax.media.opengl.*;
 
-import jogamp.opengl.*;
-import jogamp.nativewindow.jawt.x11.*;
-import jogamp.nativewindow.x11.*;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.AbstractGraphicsScreen;
+import javax.media.nativewindow.CapabilitiesChooser;
+import javax.media.nativewindow.CapabilitiesImmutable;
+import javax.media.nativewindow.GraphicsConfigurationFactory;
+import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.nativewindow.ToolkitLock;
+import javax.media.nativewindow.awt.AWTGraphicsConfiguration;
+import javax.media.nativewindow.awt.AWTGraphicsDevice;
+import javax.media.nativewindow.awt.AWTGraphicsScreen;
+import javax.media.nativewindow.x11.X11GraphicsConfiguration;
+import javax.media.nativewindow.x11.X11GraphicsDevice;
+import javax.media.nativewindow.x11.X11GraphicsScreen;
 
-public class X11AWTGLXGraphicsConfigurationFactory extends GLGraphicsConfigurationFactory {
-    protected static final boolean DEBUG = Debug.debug("GraphicsConfiguration");
+import jogamp.nativewindow.jawt.x11.X11SunJDKReflection;
+import jogamp.nativewindow.x11.X11Lib;
+import jogamp.nativewindow.x11.X11Util;
 
-    public X11AWTGLXGraphicsConfigurationFactory() {
-        GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.awt.AWTGraphicsDevice.class, this);
+public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFactory {
+    
+    public static void registerFactory() {
+        GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.awt.AWTGraphicsDevice.class, new X11AWTGraphicsConfigurationFactory());
+    }    
+    private X11AWTGraphicsConfigurationFactory() {
     }
 
     protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
             CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested,
-            CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
-        GraphicsDevice device = null;
+            CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {    
         if (absScreen != null &&
             !(absScreen instanceof AWTGraphicsScreen)) {
             throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only AWTGraphicsScreen objects");
         }
-
         if(null==absScreen) {
-            absScreen = AWTGraphicsScreen.createScreenDevice(-1, AbstractGraphicsDevice.DEFAULT_UNIT);
-        }
-        AWTGraphicsScreen awtScreen = (AWTGraphicsScreen) absScreen;
-        device = ((AWTGraphicsDevice)awtScreen.getDevice()).getGraphicsDevice();
-
-        if ( !(capsChosen instanceof GLCapabilitiesImmutable) ) {
-            throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only GLCapabilities objects - chosen");
-        }
-
-        if ( !(capsRequested instanceof GLCapabilitiesImmutable) ) {
-            throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only GLCapabilities objects - requested");
-        }
-
-        if (chooser != null &&
-            !(chooser instanceof GLCapabilitiesChooser)) {
-            throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only GLCapabilitiesChooser objects");
+            absScreen = AWTGraphicsScreen.createDefault();
         }
 
+        return chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, (AWTGraphicsScreen)absScreen);
+    }
+    
+    public static AWTGraphicsConfiguration chooseGraphicsConfigurationStatic(
+            CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested,
+            CapabilitiesChooser chooser, AWTGraphicsScreen awtScreen) {
         if(DEBUG) {
-            System.err.println("X11AWTGLXGraphicsConfigurationFactory: got "+absScreen);
+            System.err.println("X11AWTGraphicsConfigurationFactory: got "+awtScreen);
         }
         
+        final GraphicsDevice device = ((AWTGraphicsDevice)awtScreen.getDevice()).getGraphicsDevice();
+
         long displayHandle = X11SunJDKReflection.graphicsDeviceGetDisplay(device);
         boolean owner = false;
         if(0==displayHandle) {
             displayHandle = X11Util.openDisplay(null);
             owner = true;
             if(DEBUG) {
-                System.err.println(Thread.currentThread().getName() + " - X11AWTGLXGraphicsConfigurationFactory: create local X11 display");
+                System.err.println(Thread.currentThread().getName() + " - X11AWTGraphicsConfigurationFactory: create local X11 display");
             }
         } else {
             /**
@@ -98,23 +102,31 @@ public class X11AWTGLXGraphicsConfigurationFactory extends GLGraphicsConfigurati
              * some work, but some behave erratic. 
              * I.e. hangs in XQueryExtension(..) via X11GraphicsScreen.
              */
-            final String displayName = X11Util.XDisplayString(displayHandle);
+            final String displayName = X11Lib.XDisplayString(displayHandle);
             if(DEBUG) {
-                System.err.println(Thread.currentThread().getName() + " - X11AWTGLXGraphicsConfigurationFactory: create X11 display @ "+displayName+" / 0x"+Long.toHexString(displayHandle));
+                System.err.println(Thread.currentThread().getName() + " - X11AWTGraphicsConfigurationFactory: create X11 display @ "+displayName+" / 0x"+Long.toHexString(displayHandle));
             }
             displayHandle = X11Util.openDisplay(displayName);
             owner = true;
         }
-        ((AWTGraphicsDevice)awtScreen.getDevice()).setSubType(NativeWindowFactory.TYPE_X11, displayHandle);
-        X11GraphicsDevice x11Device = new X11GraphicsDevice(displayHandle, AbstractGraphicsDevice.DEFAULT_UNIT);
-        x11Device.setCloseDisplay(owner);
-        X11GraphicsScreen x11Screen = new X11GraphicsScreen(x11Device, awtScreen.getIndex());
+        final ToolkitLock lock = owner ? 
+                NativeWindowFactory.getDefaultToolkitLock(NativeWindowFactory.TYPE_AWT) : // own non-shared X11 display connection, no X11 lock
+                NativeWindowFactory.createDefaultToolkitLock(NativeWindowFactory.TYPE_X11, NativeWindowFactory.TYPE_AWT, displayHandle);
+        final X11GraphicsDevice x11Device = new X11GraphicsDevice(displayHandle, AbstractGraphicsDevice.DEFAULT_UNIT, lock, owner); 
+        final X11GraphicsScreen x11Screen = new X11GraphicsScreen(x11Device, awtScreen.getIndex());
         if(DEBUG) {
-            System.err.println("X11AWTGLXGraphicsConfigurationFactory: made "+x11Screen);
+            System.err.println("X11AWTGraphicsConfigurationFactory: made "+x11Screen);
         }
-        GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(x11Device);
-        GraphicsConfiguration[] configs = device.getConfigurations();
-
+        
+        final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(x11Device);
+        X11GraphicsConfiguration x11Config = (X11GraphicsConfiguration) factory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, x11Screen);
+        if (x11Config == null) {
+            throw new NativeWindowException("Unable to choose a GraphicsConfiguration (1): "+capsChosen+",\n\t"+chooser+"\n\t"+x11Screen);
+        }
+        if(DEBUG) {
+            System.err.println("X11AWTGraphicsConfigurationFactory: chosen x11Config: "+x11Config);
+        }
+        
         //
         // Match the X11/GL Visual with AWT:
         //   - choose a config AWT agnostic and then
@@ -122,11 +134,8 @@ public class X11AWTGLXGraphicsConfigurationFactory extends GLGraphicsConfigurati
         //
         // The resulting GraphicsConfiguration has to be 'forced' on the AWT native peer,
         // ie. returned by GLCanvas's getGraphicsConfiguration() befor call by super.addNotify().
-        //
-        X11GraphicsConfiguration x11Config = (X11GraphicsConfiguration) factory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, x11Screen);
-        if (x11Config == null) {
-            throw new GLException("Unable to choose a GraphicsConfiguration (1): "+capsChosen+",\n\t"+chooser+"\n\t"+x11Screen);
-        }
+        //        
+        final GraphicsConfiguration[] configs = device.getConfigurations();
         long visualID = x11Config.getVisualID();
         for (int i = 0; i < configs.length; i++) {
             GraphicsConfiguration gc = configs[i];
@@ -147,7 +156,7 @@ public class X11AWTGLXGraphicsConfigurationFactory extends GLGraphicsConfigurati
         capsChosen = AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capsChosen, gc);
         x11Config = (X11GraphicsConfiguration) factory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, x11Screen);
         if (x11Config == null) {
-            throw new GLException("Unable to choose a GraphicsConfiguration (2): "+capsChosen+",\n\t"+chooser+"\n\t"+x11Screen);
+            throw new NativeWindowException("Unable to choose a GraphicsConfiguration (2): "+capsChosen+",\n\t"+chooser+"\n\t"+x11Screen);
         }
         visualID = x11Config.getVisualID();
         for (int i = 0; i < configs.length; i++) {
@@ -173,3 +182,4 @@ public class X11AWTGLXGraphicsConfigurationFactory extends GLGraphicsConfigurati
         return new AWTGraphicsConfiguration(awtScreen, x11Config.getChosenCapabilities(), x11Config.getRequestedCapabilities(), gc, x11Config);
     }
 }
+
diff --git a/src/nativewindow/native/JAWT_DrawingSurfaceInfo.c b/src/nativewindow/native/JAWT_DrawingSurfaceInfo.c
index 470f03a..2a66510 100644
--- a/src/nativewindow/native/JAWT_DrawingSurfaceInfo.c
+++ b/src/nativewindow/native/JAWT_DrawingSurfaceInfo.c
@@ -59,6 +59,13 @@ Java_jogamp_nativewindow_jawt_JAWT_1DrawingSurfaceInfo_platformInfo0(JNIEnv* env
     return NULL;
   }
   if (dsi->platformInfo == NULL) {
+    (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/RuntimeException"),
+                     "platformInfo pointer is NULL");
+    return NULL;
+  }
+  if(0==PLATFORM_DSI_SIZE) {
+    (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/RuntimeException"),
+                     "platformInfo size is 0");
     return NULL;
   }
   return (*env)->NewDirectByteBuffer(env, dsi->platformInfo, PLATFORM_DSI_SIZE);
diff --git a/src/nativewindow/native/NativewindowCommon.c b/src/nativewindow/native/NativewindowCommon.c
index e357045..b866646 100644
--- a/src/nativewindow/native/NativewindowCommon.c
+++ b/src/nativewindow/native/NativewindowCommon.c
@@ -55,3 +55,30 @@ jchar* NativewindowCommon_GetNullTerminatedStringChars(JNIEnv* env, jstring str)
     return strChars;
 }
 
+JNIEnv* NativewindowCommon_GetJNIEnv (JavaVM * jvmHandle, int jvmVersion, int * shallBeDetached) {
+    JNIEnv* curEnv = NULL;
+    JNIEnv* newEnv = NULL;
+    int envRes;
+
+    // retrieve this thread's JNIEnv curEnv - or detect it's detached
+    envRes = (*jvmHandle)->GetEnv(jvmHandle, (void **) &curEnv, jvmVersion) ;
+    if( JNI_EDETACHED == envRes ) {
+        // detached thread - attach to JVM
+        if( JNI_OK != ( envRes = (*jvmHandle)->AttachCurrentThread(jvmHandle, (void**) &newEnv, NULL) ) ) {
+            fprintf(stderr, "JNIEnv: can't attach thread: %d\n", envRes);
+            return NULL;
+        }
+        curEnv = newEnv;
+    } else if( JNI_OK != envRes ) {
+        // oops ..
+        fprintf(stderr, "can't GetEnv: %d\n", envRes);
+        return NULL;
+    }
+    if (curEnv==NULL) {
+        fprintf(stderr, "env is NULL\n");
+        return NULL;
+    }
+    *shallBeDetached = NULL != newEnv;
+    return curEnv;
+}
+
diff --git a/src/nativewindow/native/NativewindowCommon.h b/src/nativewindow/native/NativewindowCommon.h
index 5dc5deb..41c4bd0 100644
--- a/src/nativewindow/native/NativewindowCommon.h
+++ b/src/nativewindow/native/NativewindowCommon.h
@@ -12,4 +12,6 @@ jchar* NativewindowCommon_GetNullTerminatedStringChars(JNIEnv* env, jstring str)
 void NativewindowCommon_FatalError(JNIEnv *env, const char* msg, ...);
 void NativewindowCommon_throwNewRuntimeException(JNIEnv *env, const char* msg, ...);
 
+JNIEnv* NativewindowCommon_GetJNIEnv (JavaVM * jvmHandle, int jvmVersion, int * shallBeDetached);
+
 #endif
diff --git a/src/nativewindow/native/macosx/OSXmisc.c b/src/nativewindow/native/macosx/OSXmisc.c
deleted file mode 100644
index 24cb8d4..0000000
--- a/src/nativewindow/native/macosx/OSXmisc.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- * Copyright 2011 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- * 
- *    1. Redistributions of source code must retain the above copyright notice, this list of
- *       conditions and the following disclaimer.
- * 
- *    2. Redistributions in binary form must reproduce the above copyright notice, this list
- *       of conditions and the following disclaimer in the documentation and/or other materials
- *       provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
- 
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <AppKit/AppKit.h>
-
-#include "NativewindowCommon.h"
-#include "jogamp_nativewindow_macosx_OSXUtil.h"
-
-static const char * const ClazzNamePoint = "javax/media/nativewindow/util/Point";
-static const char * const ClazzAnyCstrName = "<init>";
-static const char * const ClazzNamePointCstrSignature = "(II)V";
-static jclass pointClz = NULL;
-static jmethodID pointCstr = NULL;
-
-static int _initialized=0;
-
-JNIEXPORT jboolean JNICALL 
-Java_jogamp_nativewindow_macosx_OSXUtil_initIDs0(JNIEnv *env, jclass _unused) {
-    if(0==_initialized) {
-        jclass c;
-        c = (*env)->FindClass(env, ClazzNamePoint);
-        if(NULL==c) {
-            NativewindowCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't find %s", ClazzNamePoint);
-        }
-        pointClz = (jclass)(*env)->NewGlobalRef(env, c);
-        (*env)->DeleteLocalRef(env, c);
-        if(NULL==pointClz) {
-            NativewindowCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't use %s", ClazzNamePoint);
-        }
-        pointCstr = (*env)->GetMethodID(env, pointClz, ClazzAnyCstrName, ClazzNamePointCstrSignature);
-        if(NULL==pointCstr) {
-            NativewindowCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't fetch %s.%s %s",
-                ClazzNamePoint, ClazzAnyCstrName, ClazzNamePointCstrSignature);
-        }
-
-        _initialized=1;
-    }
-    return JNI_TRUE;
-}
-
-/*
- * Class:     jogamp_newt_driver_macosx_MacWindow
- * Method:    getLocationOnScreenImpl0
- * Signature: (JII)Ljavax/media/nativewindow/util/Point;
- */
-JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetLocationOnScreen0
-  (JNIEnv *env, jclass unused, jlong winOrView, jint src_x, jint src_y)
-{
-    NSRect r;
-    int dest_x=-1;
-    int dest_y=-1;
-
-    NSObject *nsObj = (NSObject*) ((intptr_t) winOrView);
-    NSWindow* win = NULL;
-
-    if( [nsObj isKindOfClass:[NSWindow class]] ) {
-        win = (NSWindow*) nsObj;
-    } else if( nsObj != NULL && [nsObj isKindOfClass:[NSView class]] ) {
-        NSView* view = (NSView*) nsObj;
-        win = [view window];
-    } else {
-        NativewindowCommon_throwNewRuntimeException(env, "neither win not view %p\n", nsObj);
-    }
-
-    r.origin.x = src_x;
-    r.origin.y = src_x;
-    r.size.width = 0;
-    r.size.height = 0;
-    // NSRect rS = [win convertRectToScreen: r]; // 10.7
-    NSPoint oS = [win convertBaseToScreen: r.origin];
-    dest_x = (int) oS.x;
-    dest_y = (int) oS.y;
-
-    return (*env)->NewObject(env, pointClz, pointCstr, (jint)dest_x, (jint)dest_y);
-}
-
diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m
new file mode 100644
index 0000000..d64973b
--- /dev/null
+++ b/src/nativewindow/native/macosx/OSXmisc.m
@@ -0,0 +1,442 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ * 
+ *    1. Redistributions of source code must retain the above copyright notice, this list of
+ *       conditions and the following disclaimer.
+ * 
+ *    2. Redistributions in binary form must reproduce the above copyright notice, this list
+ *       of conditions and the following disclaimer in the documentation and/or other materials
+ *       provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+ 
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <AppKit/AppKit.h>
+
+#include "NativewindowCommon.h"
+#include "jogamp_nativewindow_macosx_OSXUtil.h"
+#include "jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow.h"
+
+#include <jawt_md.h>
+#import <JavaNativeFoundation.h>
+
+// #define VERBOSE 1
+//
+#ifdef VERBOSE
+    // #define DBG_PRINT(...) NSLog(@ ## __VA_ARGS__)
+    #define DBG_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr)
+#else
+    #define DBG_PRINT(...)
+#endif
+
+static const char * const ClazzNameRunnable = "java/lang/Runnable";
+static jmethodID runnableRunID = NULL;
+
+static const char * const ClazzNamePoint = "javax/media/nativewindow/util/Point";
+static const char * const ClazzAnyCstrName = "<init>";
+static const char * const ClazzNamePointCstrSignature = "(II)V";
+static jclass pointClz = NULL;
+static jmethodID pointCstr = NULL;
+
+static int _initialized=0;
+
+JNIEXPORT jboolean JNICALL 
+Java_jogamp_nativewindow_macosx_OSXUtil_initIDs0(JNIEnv *env, jclass _unused) {
+    if(0==_initialized) {
+        jclass c;
+        c = (*env)->FindClass(env, ClazzNamePoint);
+        if(NULL==c) {
+            NativewindowCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't find %s", ClazzNamePoint);
+        }
+        pointClz = (jclass)(*env)->NewGlobalRef(env, c);
+        (*env)->DeleteLocalRef(env, c);
+        if(NULL==pointClz) {
+            NativewindowCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't use %s", ClazzNamePoint);
+        }
+        pointCstr = (*env)->GetMethodID(env, pointClz, ClazzAnyCstrName, ClazzNamePointCstrSignature);
+        if(NULL==pointCstr) {
+            NativewindowCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't fetch %s.%s %s",
+                ClazzNamePoint, ClazzAnyCstrName, ClazzNamePointCstrSignature);
+        }
+
+        c = (*env)->FindClass(env, ClazzNameRunnable);
+        if(NULL==c) {
+            NativewindowCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't find %s", ClazzNameRunnable);
+        }
+        runnableRunID = (*env)->GetMethodID(env, c, "run", "()V");
+        if(NULL==runnableRunID) {
+            NativewindowCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't fetch %s.run()V", ClazzNameRunnable);
+        }
+        _initialized=1;
+    }
+    return JNI_TRUE;
+}
+
+/*
+ * Class:     Java_jogamp_nativewindow_macosx_OSXUtil
+ * Method:    getLocationOnScreen0
+ * Signature: (JII)Ljavax/media/nativewindow/util/Point;
+ */
+JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetLocationOnScreen0
+  (JNIEnv *env, jclass unused, jlong winOrView, jint src_x, jint src_y)
+{
+    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+
+    /**
+     * return location in 0/0 top-left space,
+     * OSX is 0/0 bottom-left space naturally
+     */
+    NSRect r;
+    int dest_x=-1;
+    int dest_y=-1;
+
+    NSObject *nsObj = (NSObject*) (intptr_t) winOrView;
+    NSWindow* win = NULL;
+    NSView* view = NULL;
+
+    if( [nsObj isKindOfClass:[NSWindow class]] ) {
+        win = (NSWindow*) nsObj;
+        view = [win contentView];
+    } else if( nsObj != NULL && [nsObj isKindOfClass:[NSView class]] ) {
+        view = (NSView*) nsObj;
+        win = [view window];
+    } else {
+        NativewindowCommon_throwNewRuntimeException(env, "neither win not view %p\n", nsObj);
+    }
+    NSScreen* screen = [win screen];
+    NSRect screenRect = [screen frame];
+    NSRect winFrame = [win frame];
+
+    r.origin.x = src_x;
+    r.origin.y = winFrame.size.height - src_y; // y-flip for 0/0 top-left
+    r.size.width = 0;
+    r.size.height = 0;
+    // NSRect rS = [win convertRectToScreen: r]; // 10.7
+    NSPoint oS = [win convertBaseToScreen: r.origin];
+    /**
+    NSLog(@"LOS.1: (bottom-left) %d/%d, screen-y[0: %d, h: %d], (top-left) %d/%d\n", 
+        (int)oS.x, (int)oS.y, (int)screenRect.origin.y, (int) screenRect.size.height,
+        (int)oS.x, (int)(screenRect.origin.y + screenRect.size.height - oS.y)); */
+
+    dest_x = (int) oS.x;
+    dest_y = (int) screenRect.origin.y + screenRect.size.height - oS.y;
+
+    jobject res = (*env)->NewObject(env, pointClz, pointCstr, (jint)dest_x, (jint)dest_y);
+
+    [pool release];
+
+    return res;
+}
+
+/*
+ * Class:     Java_jogamp_nativewindow_macosx_OSXUtil
+ * Method:    CreateNSView0
+ * Signature: (IIIIZ)J
+ */
+JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSView0
+  (JNIEnv *env, jclass unused, jint x, jint y, jint width, jint height)
+{
+    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+    NSRect rect = NSMakeRect(x, y, width, height);
+    NSView * view = [[NSView alloc] initWithFrame: rect] ;
+    [view setCanDrawConcurrently: YES];
+    [pool release];
+
+    return (jlong) (intptr_t) view;
+}
+
+/*
+ * Class:     Java_jogamp_nativewindow_macosx_OSXUtil
+ * Method:    DestroyNSView0
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyNSView0
+  (JNIEnv *env, jclass unused, jlong nsView)
+{
+    NSView* view = (NSView*) (intptr_t) nsView;
+    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+    [view release];
+    [pool release];
+}
+
+/*
+ * Class:     Java_jogamp_nativewindow_macosx_OSXUtil
+ * Method:    CreateNSWindow0
+ * Signature: (IIIIZ)J
+ */
+JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSWindow0
+  (JNIEnv *env, jclass unused, jint x, jint y, jint width, jint height)
+{
+    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+    NSRect rect = NSMakeRect(x, y, width, height);
+
+    // Allocate the window
+    NSWindow* myWindow = [[NSWindow alloc] initWithContentRect: rect
+                                           styleMask: NSBorderlessWindowMask
+                                           backing: NSBackingStoreBuffered
+                                           defer: YES];
+    [myWindow setReleasedWhenClosed: YES]; // default
+    [myWindow setPreservesContentDuringLiveResize: YES];
+
+    // invisible ..
+    [myWindow setOpaque: NO];
+    [myWindow setBackgroundColor: [NSColor clearColor]];
+
+    [pool release];
+
+    return (jlong) ((intptr_t) myWindow);
+}
+
+/*
+ * Class:     Java_jogamp_nativewindow_macosx_OSXUtil
+ * Method:    DestroyNSWindow0
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyNSWindow0
+  (JNIEnv *env, jclass unused, jlong nsWindow)
+{
+    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+    NSWindow* mWin = (NSWindow*) ((intptr_t) nsWindow);
+
+    [mWin close]; // performs release!
+    [pool release];
+}
+
+/*
+ * Class:     Java_jogamp_nativewindow_macosx_OSXUtil
+ * Method:    CreateCALayer0
+ * Signature: (V)J
+ */
+JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateCALayer0
+  (JNIEnv *env, jclass unused)
+{
+    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+
+    // CALayer* layer = [[CALayer alloc] init];
+    CALayer* layer = [CALayer layer];
+
+    // no animations for add/remove/swap sublayers etc 
+    [layer removeAnimationForKey: kCAOnOrderIn];
+    [layer removeAnimationForKey: kCAOnOrderOut];
+    [layer removeAnimationForKey: kCATransition];
+
+    // initial dummy size !
+    CGRect lRect = [layer frame];
+    lRect.origin.x = 0;
+    lRect.origin.y = 0;
+    lRect.size.width = 32;
+    lRect.size.height = 32;
+    [layer setFrame: lRect];
+    DBG_PRINT("CALayer::CreateCALayer0: %p %lf/%lf %lfx%lf\n", layer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height);
+
+    [pool release];
+
+    return (jlong) ((intptr_t) layer);
+}
+
+/*
+ * Class:     Java_jogamp_nativewindow_macosx_OSXUtil
+ * Method:    AddCASublayer0
+ * Signature: (JJ)V
+ */
+JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0
+  (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer)
+{
+    JNF_COCOA_ENTER(env);
+    CALayer* rootLayer = (CALayer*) ((intptr_t) rootCALayer);
+    CALayer* subLayer = (CALayer*) ((intptr_t) subCALayer);
+
+    CGRect lRectRoot = [rootLayer frame];
+    DBG_PRINT("CALayer::AddCASublayer0.0: Origin %p frame0: %lf/%lf %lfx%lf\n", 
+        rootLayer, lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height);
+    if(lRectRoot.origin.x<0 || lRectRoot.origin.y<0) {
+        lRectRoot.origin.x = 0;
+        lRectRoot.origin.y = 0;
+        [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+            [rootLayer setFrame: lRectRoot];
+        }];
+        DBG_PRINT("CALayer::AddCASublayer0.1: Origin %p frame*: %lf/%lf %lfx%lf\n", 
+            rootLayer, lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height);
+    }
+    DBG_PRINT("CALayer::AddCASublayer0.2: %p . %p %lf/%lf %lfx%lf (refcnt %d)\n", 
+        rootLayer, subLayer, lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height, (int)[subLayer retainCount]);
+
+    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+        // simple 1:1 layout !
+        [subLayer setFrame:lRectRoot];
+        [rootLayer addSublayer:subLayer];
+    }];
+    DBG_PRINT("CALayer::AddCASublayer0.X: %p . %p (refcnt %d)\n", rootLayer, subLayer, (int)[subLayer retainCount]);
+    JNF_COCOA_EXIT(env);
+}
+
+/*
+ * Class:     Java_jogamp_nativewindow_macosx_OSXUtil
+ * Method:    RemoveCASublayer0
+ * Signature: (JJ)V
+ */
+JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_RemoveCASublayer0
+  (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer)
+{
+    JNF_COCOA_ENTER(env);
+    CALayer* rootLayer = (CALayer*) ((intptr_t) rootCALayer);
+    CALayer* subLayer = (CALayer*) ((intptr_t) subCALayer);
+
+    (void)rootLayer; // no warnings
+
+    DBG_PRINT("CALayer::RemoveCASublayer0.0: %p . %p (refcnt %d)\n", rootLayer, subLayer, (int)[subLayer retainCount]);
+    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+        [subLayer removeFromSuperlayer];
+    }];
+    DBG_PRINT("CALayer::RemoveCASublayer0.X: %p . %p (refcnt %d)\n", rootLayer, subLayer, (int)[subLayer retainCount]);
+    JNF_COCOA_EXIT(env);
+}
+
+/*
+ * Class:     Java_jogamp_nativewindow_macosx_OSXUtil
+ * Method:    DestroyCALayer0
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyCALayer0
+  (JNIEnv *env, jclass unused, jlong caLayer)
+{
+    JNF_COCOA_ENTER(env);
+    CALayer* layer = (CALayer*) ((intptr_t) caLayer);
+
+    DBG_PRINT("CALayer::DestroyCALayer0.0: %p (refcnt %d)\n", layer, (int)[layer retainCount]);
+    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+        [layer release]; // performs release!
+    }];
+    DBG_PRINT("CALayer::DestroyCALayer0.X: %p (refcnt %d)\n", layer, (int)[layer retainCount]);
+    JNF_COCOA_EXIT(env);
+}
+
+ at interface MainRunnable : NSObject
+
+{
+    JavaVM *jvmHandle;
+    int jvmVersion;
+    jobject runnableObj;
+}
+
+- (id) initWithRunnable: (jobject)runnable jvmHandle: (JavaVM*)jvm jvmVersion: (int)jvmVers;
+- (void) jRun;
+
+ at end
+
+ at implementation MainRunnable
+
+- (id) initWithRunnable: (jobject)runnable jvmHandle: (JavaVM*)jvm jvmVersion: (int)jvmVers
+{
+    jvmHandle = jvm;
+    jvmVersion = jvmVers;
+    runnableObj = runnable;
+    return [super init];
+}
+
+- (void) jRun
+{
+    int shallBeDetached = 0;
+    JNIEnv* env = NativewindowCommon_GetJNIEnv(jvmHandle, jvmVersion, &shallBeDetached);
+    if(NULL!=env) {
+        (*env)->CallVoidMethod(env, runnableObj, runnableRunID);
+
+        if (shallBeDetached) {
+            (*jvmHandle)->DetachCurrentThread(jvmHandle);
+        }
+    }
+}
+
+ at end
+
+
+/*
+ * Class:     Java_jogamp_nativewindow_macosx_OSXUtil
+ * Method:    RunOnMainThread0
+ * Signature: (ZLjava/lang/Runnable;)V
+ */
+JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_RunOnMainThread0
+  (JNIEnv *env, jclass unused, jboolean jwait, jobject runnable)
+{
+    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+
+    if ( NO == [NSThread isMainThread] ) {
+        jobject runnableGlob = (*env)->NewGlobalRef(env, runnable);
+
+        BOOL wait = (JNI_TRUE == jwait) ? YES : NO;
+        JavaVM *jvmHandle = NULL;
+        int jvmVersion = 0;
+
+        if(0 != (*env)->GetJavaVM(env, &jvmHandle)) {
+            jvmHandle = NULL;
+        } else {
+            jvmVersion = (*env)->GetVersion(env);
+        }
+
+        MainRunnable * mr = [[MainRunnable alloc] initWithRunnable: runnableGlob jvmHandle: jvmHandle jvmVersion: jvmVersion];
+        [mr performSelectorOnMainThread:@selector(jRun) withObject:nil waitUntilDone:wait];
+        [mr release];
+
+        (*env)->DeleteGlobalRef(env, runnableGlob);
+    } else {
+        (*env)->CallVoidMethod(env, runnable, runnableRunID);
+    }
+
+    [pool release];
+}
+
+/*
+ * Class:     Java_jogamp_nativewindow_macosx_OSXUtil
+ * Method:    RunOnMainThread0
+ * Signature: (V)V
+ */
+JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_IsMainThread0
+  (JNIEnv *env, jclass unused)
+{
+    return ( [NSThread isMainThread] == YES ) ? JNI_TRUE : JNI_FALSE ;
+}
+
+/*
+ * Class:     Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow
+ * Method:    AttachJAWTSurfaceLayer
+ * Signature: (JJ)Z
+ */
+JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_AttachJAWTSurfaceLayer0
+  (JNIEnv *env, jclass unused, jobject jawtDrawingSurfaceInfoBuffer, jlong caLayer)
+{
+    JNF_COCOA_ENTER(env);
+    JAWT_DrawingSurfaceInfo* dsi = (JAWT_DrawingSurfaceInfo*) (*env)->GetDirectBufferAddress(env, jawtDrawingSurfaceInfoBuffer);
+    if (NULL == dsi) {
+        NativewindowCommon_throwNewRuntimeException(env, "Argument \"jawtDrawingSurfaceInfoBuffer\" was not a direct buffer");
+        return JNI_FALSE;
+    }
+    CALayer* layer = (CALayer*) (intptr_t) caLayer;
+    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+        id <JAWT_SurfaceLayers> surfaceLayers = (id <JAWT_SurfaceLayers>)dsi->platformInfo;
+        DBG_PRINT("CALayer::attachJAWTSurfaceLayer: %p -> %p\n", surfaceLayers.layer, layer);
+        surfaceLayers.layer = [layer autorelease];
+    }];
+    JNF_COCOA_EXIT(env);
+    return JNI_TRUE;
+}
+
diff --git a/src/nativewindow/native/windows/GDImisc.c b/src/nativewindow/native/windows/GDImisc.c
index e828500..3ab7f98 100644
--- a/src/nativewindow/native/windows/GDImisc.c
+++ b/src/nativewindow/native/windows/GDImisc.c
@@ -14,7 +14,7 @@
 #include <stdio.h>
 
 #include "NativewindowCommon.h"
-#include "jogamp_nativewindow_windows_GDI.h"
+#include "jogamp_nativewindow_windows_GDIUtil.h"
 
 // #define VERBOSE_ON 1
 
@@ -36,12 +36,12 @@ HINSTANCE GetApplicationHandle() {
 }
 
 /*   Java->C glue code:
- *   Java package: jogamp.nativewindow.windows.GDI
+ *   Java package: jogamp.nativewindow.windows.GDIUtil
  *    Java method: boolean CreateWindowClass(long hInstance, java.lang.String clazzName, long wndProc)
  *     C function: BOOL CreateWindowClass(HANDLE hInstance, LPCSTR clazzName, HANDLE wndProc);
  */
 JNIEXPORT jboolean JNICALL
-Java_jogamp_nativewindow_windows_GDI_CreateWindowClass
+Java_jogamp_nativewindow_windows_GDIUtil_CreateWindowClass
     (JNIEnv *env, jclass _unused, jlong jHInstance, jstring jClazzName, jlong wndProc) 
 {
     HINSTANCE hInstance = (HINSTANCE) (intptr_t) jHInstance;
@@ -85,12 +85,12 @@ Java_jogamp_nativewindow_windows_GDI_CreateWindowClass
 }
 
 /*   Java->C glue code:
- *   Java package: jogamp.nativewindow.windows.GDI
+ *   Java package: jogamp.nativewindow.windows.GDIUtil
  *    Java method: boolean DestroyWindowClass(long hInstance, java.lang.String className)
  *     C function: BOOL DestroyWindowClass(HANDLE hInstance, LPCSTR className);
  */
 JNIEXPORT jboolean JNICALL
-Java_jogamp_nativewindow_windows_GDI_DestroyWindowClass
+Java_jogamp_nativewindow_windows_GDIUtil_DestroyWindowClass
     (JNIEnv *env, jclass _unused, jlong jHInstance, jstring jClazzName) 
 {
     HINSTANCE hInstance = (HINSTANCE) (intptr_t) jHInstance;
@@ -116,12 +116,12 @@ Java_jogamp_nativewindow_windows_GDI_DestroyWindowClass
 
 
 /*   Java->C glue code:
- *   Java package: jogamp.nativewindow.windows.GDI
+ *   Java package: jogamp.nativewindow.windows.GDIUtil
  *    Java method: long CreateDummyWindow0(long hInstance, java.lang.String className, java.lang.String windowName, int x, int y, int width, int height)
  *     C function: HANDLE CreateDummyWindow0(HANDLE hInstance, LPCSTR className, LPCSTR windowName, int x, int y, int width, int height);
  */
 JNIEXPORT jlong JNICALL
-Java_jogamp_nativewindow_windows_GDI_CreateDummyWindow0
+Java_jogamp_nativewindow_windows_GDIUtil_CreateDummyWindow0
     (JNIEnv *env, jclass _unused, jlong jHInstance, jstring jWndClassName, jstring jWndName, jint x, jint y, jint width, jint height) 
 {
     HINSTANCE hInstance = (HINSTANCE) (intptr_t) jHInstance;
@@ -162,26 +162,26 @@ Java_jogamp_nativewindow_windows_GDI_CreateDummyWindow0
 
 
 /*
- * Class:     jogamp_nativewindow_windows_GDI
+ * Class:     jogamp_nativewindow_windows_GDIUtil
  * Method:    initIDs0
  * Signature: ()Z
  */
-JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_windows_GDI_initIDs0
+JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_windows_GDIUtil_initIDs0
   (JNIEnv *env, jclass clazz)
 {
     if(NativewindowCommon_init(env)) {
         jclass c = (*env)->FindClass(env, ClazzNamePoint);
         if(NULL==c) {
-            NativewindowCommon_FatalError(env, "FatalError jogamp_nativewindow_windows_GDI: can't find %s", ClazzNamePoint);
+            NativewindowCommon_FatalError(env, "FatalError jogamp_nativewindow_windows_GDIUtil: can't find %s", ClazzNamePoint);
         }
         pointClz = (jclass)(*env)->NewGlobalRef(env, c);
         (*env)->DeleteLocalRef(env, c);
         if(NULL==pointClz) {
-            NativewindowCommon_FatalError(env, "FatalError jogamp_nativewindow_windows_GDI: can't use %s", ClazzNamePoint);
+            NativewindowCommon_FatalError(env, "FatalError jogamp_nativewindow_windows_GDIUtil: can't use %s", ClazzNamePoint);
         }
         pointCstr = (*env)->GetMethodID(env, pointClz, ClazzAnyCstrName, ClazzNamePointCstrSignature);
         if(NULL==pointCstr) {
-            NativewindowCommon_FatalError(env, "FatalError jogamp_nativewindow_windows_GDI: can't fetch %s.%s %s",
+            NativewindowCommon_FatalError(env, "FatalError jogamp_nativewindow_windows_GDIUtil: can't fetch %s.%s %s",
                 ClazzNamePoint, ClazzAnyCstrName, ClazzNamePointCstrSignature);
         }
     }
@@ -193,22 +193,22 @@ LRESULT CALLBACK DummyWndProc( HWND   hWnd, UINT   uMsg, WPARAM wParam, LPARAM l
 }
 
 /*
- * Class:     jogamp_nativewindow_windows_GDI
+ * Class:     jogamp_nativewindow_windows_GDIUtil
  * Method:    getDummyWndProc0
  * Signature: ()J
  */
-JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_windows_GDI_getDummyWndProc0
+JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_windows_GDIUtil_getDummyWndProc0
   (JNIEnv *env, jclass clazz)
 {
     return (jlong) (intptr_t) DummyWndProc;
 }
 
 /*
- * Class:     jogamp_nativewindow_windows_GDI
+ * Class:     jogamp_nativewindow_windows_GDIUtil
  * Method:    GetRelativeLocation0
  * Signature: (JJII)Ljavax/media/nativewindow/util/Point;
  */
-JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_windows_GDI_GetRelativeLocation0
+JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_windows_GDIUtil_GetRelativeLocation0
   (JNIEnv *env, jclass unused, jlong jsrc_win, jlong jdest_win, jint src_x, jint src_y)
 {
     HWND src_win = (HWND) (intptr_t) jsrc_win;
diff --git a/src/nativewindow/native/x11/XineramaHelper.c b/src/nativewindow/native/x11/XineramaHelper.c
index a4d380e..62c02c8 100644
--- a/src/nativewindow/native/x11/XineramaHelper.c
+++ b/src/nativewindow/native/x11/XineramaHelper.c
@@ -39,7 +39,7 @@
 #include <X11/Xlib.h>
 #include <stdio.h>
 
-#ifdef __sun
+#ifdef __sun_obsolete
 
 typedef Status XineramaGetInfoFunc(Display* display, int screen_number,
          XRectangle* framebuffer_rects, unsigned char* framebuffer_hints,
@@ -57,7 +57,7 @@ XineramaGetCenterHintFunc* XineramaSolarisCenterFunc = NULL;
 #endif
 
 Bool XineramaEnabled(Display* display) {
-#ifdef __sun
+#ifdef __sun_obsolete
 
 #define MAXFRAMEBUFFERS 16
   char* XinExtName = "XINERAMA";
diff --git a/src/nativewindow/native/x11/Xmisc.c b/src/nativewindow/native/x11/Xmisc.c
index cc0b1a1..d28891c 100644
--- a/src/nativewindow/native/x11/Xmisc.c
+++ b/src/nativewindow/native/x11/Xmisc.c
@@ -43,7 +43,7 @@
 /* Current versions of Solaris don't expose the XF86 extensions,
    although with the recent transition to Xorg this will probably
    happen in an upcoming release */
-#if !defined(__sun) && !defined(_HPUX)
+#if !defined(__sun_obsolete) && !defined(_HPUX)
 #include <X11/extensions/xf86vmode.h>
 #else
 /* Need to provide stubs for these */
@@ -73,7 +73,7 @@ Bool XF86VidModeSetGammaRamp(
     unsigned short *blue_array) {
   return False;
 }
-#endif /* defined(__sun) || defined(_HPUX) */
+#endif /* defined(__sun_obsolete) || defined(_HPUX) */
 
 /* HP-UX doesn't define RTLD_DEFAULT. */
 #if defined(_HPUX) && !defined(RTLD_DEFAULT)
@@ -293,14 +293,16 @@ static void x11IOErrorHandlerEnable(int onoff, JNIEnv * env) {
 }
 
 static int _initialized=0;
+static jboolean _xinitThreadsOK=JNI_FALSE;
 
-JNIEXPORT void JNICALL 
+JNIEXPORT jboolean JNICALL 
 Java_jogamp_nativewindow_x11_X11Util_initialize0(JNIEnv *env, jclass _unused, jboolean firstUIActionOnProcess) {
     if(0==_initialized) {
         if( JNI_TRUE == firstUIActionOnProcess ) {
             if( 0 == XInitThreads() ) {
                 fprintf(stderr, "Warning: XInitThreads() failed\n");
             } else {
+                _xinitThreadsOK=JNI_TRUE;
                 fprintf(stderr, "Info: XInitThreads() called for concurrent Thread support\n");
             }
         } else {
@@ -311,6 +313,12 @@ Java_jogamp_nativewindow_x11_X11Util_initialize0(JNIEnv *env, jclass _unused, jb
         x11IOErrorHandlerEnable(1, env);
         _initialized=1;
     }
+    return _xinitThreadsOK;
+}
+
+JNIEXPORT void JNICALL 
+Java_jogamp_nativewindow_x11_X11Util_shutdown0(JNIEnv *env, jclass _unused) {
+    x11IOErrorHandlerEnable(0, env);
 }
 
 JNIEXPORT void JNICALL 
diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java
index 6a0ebe1..7b6849a 100644
--- a/src/newt/classes/com/jogamp/newt/Display.java
+++ b/src/newt/classes/com/jogamp/newt/Display.java
@@ -30,7 +30,6 @@ package com.jogamp.newt;
 
 import com.jogamp.newt.util.EDTUtil;
 import jogamp.newt.Debug;
-import jogamp.newt.DisplayImpl;
 
 import java.util.*;
 
@@ -130,7 +129,10 @@ public abstract class Display {
     public abstract int getId();
 
     /**
-     * @return this display instance name as defined at creation time
+     * @return This display connection name as defined at creation time. 
+     *         The display connection name is a technical platform specific detail, see {@link AbstractGraphicsDevice#getConnection()}. 
+     *
+     * @see AbstractGraphicsDevice#getConnection()
      */
     public abstract String getName();
 
@@ -198,6 +200,7 @@ public abstract class Display {
     }
 
     /** Returns the global display collection */
+    @SuppressWarnings("unchecked")
     public static Collection<Display> getAllDisplays() {
         ArrayList<Display> list;
         synchronized(displayList) {
diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java
index d3be098..4e6fa1a 100644
--- a/src/newt/classes/com/jogamp/newt/NewtFactory.java
+++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java
@@ -34,14 +34,19 @@
 
 package com.jogamp.newt;
 
-import javax.media.nativewindow.*;
-
-import com.jogamp.common.os.Platform;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.AbstractGraphicsScreen;
+import javax.media.nativewindow.CapabilitiesImmutable;
+import javax.media.nativewindow.NativeWindow;
+import javax.media.nativewindow.NativeWindowFactory;
 
+import jogamp.newt.Debug;
 import jogamp.newt.DisplayImpl;
 import jogamp.newt.ScreenImpl;
 import jogamp.newt.WindowImpl;
-import jogamp.newt.Debug;
+
+import com.jogamp.common.os.Platform;
 
 public class NewtFactory {
     public static final boolean DEBUG_IMPLEMENTATION = Debug.debug("Window");
@@ -49,7 +54,6 @@ public class NewtFactory {
     // Work-around for initialization order problems on Mac OS X
     // between native Newt and (apparently) Fmod
     static {
-        Platform.initSingleton();
         NativeWindowFactory.initSingleton(false); // last resort ..
         WindowImpl.init(NativeWindowFactory.getNativeWindowType(true));
     }
@@ -80,53 +84,124 @@ public class NewtFactory {
     public static boolean useEDT() { return useEDT; }
 
     /**
-     * Create a Display entity, incl native creation
+     * Create a Display entity.
+     * <p>
+     * Native creation is lazily done at usage, ie. {@link Display#addReference()}.
+     * </p>
+     * <p>
+     * An already existing display connection of the same <code>name</code> will be reused.  
+     * </p>
+     * @param name the display connection name which is a technical platform specific detail,
+     *        see {@link AbstractGraphicsDevice#getConnection()}. Use <code>null</code> for default.
+     * @return the new or reused Display instance
      */
     public static Display createDisplay(String name) {
         return createDisplay(name, true);
     }
 
+    /**
+     * Create a Display entity.
+     * <p>
+     * Native creation is lazily done at usage, ie. {@link Display#addReference()}.
+     * </p>
+     * <p>
+     * An already existing display connection of the same <code>name</code> will be reused
+     * <b>if</b> <code>reuse</code> is <code>true</code>, otherwise a new instance is being created.
+     * </p>
+     * @param name the display connection name which is a technical platform specific detail,
+     *        see {@link AbstractGraphicsDevice#getConnection()}. Use <code>null</code> for default.
+     * @param reuse attempt to reuse an existing Display with same <code>name</code> if set true, otherwise create a new instance.
+     * @return the new or reused Display instance
+     */
     public static Display createDisplay(String name, boolean reuse) {
       return DisplayImpl.create(NativeWindowFactory.getNativeWindowType(true), name, 0, reuse);
     }
 
     /**
-     * Create a Display entity using the given implementation type, incl native creation
+     * Create a Display entity.
+     * <p>
+     * Native creation is lazily done at usage, ie. {@link Display#addReference()}.
+     * </p>
+     * <p>
+     * An already existing display connection of the same <code>name</code> will be reused.
+     * </p>
+     * @param type explicit NativeWindow type eg. {@link NativeWindowFactory#TYPE_AWT}
+     * @param name the display connection name which is a technical platform specific detail,
+     *        see {@link AbstractGraphicsDevice#getConnection()}. Use <code>null</code> for default.
+     * @return the new or reused Display instance
      */
     public static Display createDisplay(String type, String name) {
         return createDisplay(type, name, true);
     }
 
+    /**
+     * Create a Display entity.
+     * <p>
+     * Native creation is lazily done at usage, ie. {@link Display#addReference()}.
+     * </p>
+     * <p>
+     * An already existing display connection of the same <code>name</code> will be reused
+     * <b>if</b> <code>reuse</code> is <code>true</code>, otherwise a new instance is being created.
+     * </p>
+     * @param type explicit NativeWindow type eg. {@link NativeWindowFactory#TYPE_AWT}
+     * @param name the display connection name which is a technical platform specific detail,
+     *        see {@link AbstractGraphicsDevice#getConnection()}. Use <code>null</code> for default.
+     * @param reuse attempt to reuse an existing Display with same <code>name</code> if set true, otherwise create a new instance.
+     * @return the new or reused Display instance
+     */
     public static Display createDisplay(String type, String name, boolean reuse) {
       return DisplayImpl.create(type, name, 0, reuse);
     }
 
     /**
-     * Create a Screen entity, incl native creation
+     * Create a Screen entity.
+     * <p>
+     * Native creation is lazily done at usage, ie. {@link Screen#addReference()}.
+     * </p>
+     * <p>
+     * The lifecycle of this Screen's Display is handled via {@link Display#addReference()}
+     * and {@link Display#removeReference()}.
+     * </p>
      */
     public static Screen createScreen(Display display, int index) {
       return ScreenImpl.create(display, index);
     }
 
     /**
-     * Create a top level Window entity, incl native creation.<br>
-     * The Display/Screen is created and owned, ie destructed atomatically.<br>
-     * A new Display is only created if no preexisting one could be found via {@link Display#getLastDisplayOf(java.lang.String, java.lang.String, int)}.
+     * Create a top level Window entity on the default Display and default Screen.
+     * <p>
+     * Native creation is lazily done at usage, ie. {@link Window#setVisible(boolean)}.
+     * </p>
+     * <p>
+     * An already existing default Display will be reused.
+     * </p>
+     * <p>
+     * The lifecycle of this Window's Screen and Display is handled via {@link Screen#addReference()}
+     * and {@link Screen#removeReference()}.
+     * </p>
      */
     public static Window createWindow(CapabilitiesImmutable caps) {
         return createWindowImpl(NativeWindowFactory.getNativeWindowType(true), caps);
     }
 
     /**
-     * Create a top level Window entity, incl native creation
+     * Create a top level Window entity.
+     * <p>
+     * Native creation is lazily done at usage, ie. {@link Window#setVisible(boolean)}.
+     * </p>
+     * <p>
+     * The lifecycle of this Window's Screen and Display is handled via {@link Screen#addReference()}
+     * and {@link Screen#removeReference()}.
+     * </p>
      */
     public static Window createWindow(Screen screen, CapabilitiesImmutable caps) {
         return createWindowImpl(screen, caps);
     }
 
     /**
-     * Create a child Window entity attached to the given parent, incl native creation.<br>
-     * The Screen and Display information is regenerated utilizing the parents information.<br>
+     * Create a child Window entity attached to the given parent.<br>
+     * The Screen and Display information is regenerated utilizing the parents information,
+     * while reusing an existing Display.<br>
      * <p>
      * In case <code>parentWindowObject</code> is a {@link com.jogamp.newt.Window} instance,<br>
      * the new window is added to it's list of children.<br>
@@ -138,38 +213,41 @@ public class NewtFactory {
      * In case <code>parentWindowObject</code> is a different {@link javax.media.nativewindow.NativeWindow} implementation,<br>
      * you have to handle all events appropriate.<br></p>
      * <p>
+     * <p>
+     * The lifecycle of this Window's Screen and Display is handled via {@link Screen#addReference()}
+     * and {@link Screen#removeReference()}.
+     * </p>
      *
      * @param parentWindowObject either a NativeWindow instance
      */
-    public static Window createWindow(NativeWindow nParentWindow, CapabilitiesImmutable caps) {
+    public static Window createWindow(NativeWindow parentWindow, CapabilitiesImmutable caps) {
         final String type = NativeWindowFactory.getNativeWindowType(true);
-
         Screen screen  = null;
-        Window parentWindow = null;
+        Window newtParentWindow = null;
 
-        if ( nParentWindow instanceof Window ) {
+        if ( parentWindow instanceof Window ) {
             // use parent NEWT Windows Display/Screen
-            parentWindow = (Window) nParentWindow ;
-            screen = parentWindow.getScreen();
+            newtParentWindow = (Window) parentWindow ;
+            screen = newtParentWindow.getScreen();
         } else {
             // create a Display/Screen compatible to the NativeWindow
-            AbstractGraphicsConfiguration nParentConfig = nParentWindow.getGraphicsConfiguration();
-            if(null!=nParentConfig) {
-                AbstractGraphicsScreen nParentScreen = nParentConfig.getScreen();
-                AbstractGraphicsDevice nParentDevice = nParentScreen.getDevice();
-                Display display = NewtFactory.createDisplay(type, nParentDevice.getHandle(), true);
-                screen  = NewtFactory.createScreen(display, nParentScreen.getIndex());
+            AbstractGraphicsConfiguration parentConfig = parentWindow.getGraphicsConfiguration();
+            if(null!=parentConfig) {
+                AbstractGraphicsScreen parentScreen = parentConfig.getScreen();
+                AbstractGraphicsDevice parentDevice = parentScreen.getDevice();
+                Display display = NewtFactory.createDisplay(type, parentDevice.getHandle(), true);
+                screen  = NewtFactory.createScreen(display, parentScreen.getIndex());
             } else {
                 Display display = NewtFactory.createDisplay(type, null, true); // local display
                 screen  = NewtFactory.createScreen(display, 0); // screen 0
             }
         }
-        final Window win = createWindowImpl(nParentWindow, screen, caps);
+        final Window win = createWindowImpl(parentWindow, screen, caps);
 
-        win.setSize(nParentWindow.getWidth(), nParentWindow.getHeight());
-        if ( null != parentWindow ) {
-            parentWindow.addChild(win);
-            win.setVisible(parentWindow.isVisible());
+        win.setSize(parentWindow.getWidth(), parentWindow.getHeight());
+        if ( null != newtParentWindow ) {
+            newtParentWindow.addChild(win);
+            win.setVisible(newtParentWindow.isVisible());
         }
         return win;
     }
diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java
index c6943ff..d25d3e7 100644
--- a/src/newt/classes/com/jogamp/newt/Screen.java
+++ b/src/newt/classes/com/jogamp/newt/Screen.java
@@ -151,24 +151,28 @@ public abstract class Screen {
     public abstract void removeScreenModeListener(ScreenModeListener sml);
 
     /** 
-     * Return a list of available {@link com.jogamp.newt.ScreenMode}s.
-     * @return a shallow copy of the internal immutable {@link com.jogamp.newt.ScreenMode}s,
-     * or null if not implemented for this native type {@link com.jogamp.newt.Display#getType()}.
+     * Return a list of available {@link com.jogamp.newt.ScreenMode ScreenMode}s.
+     * <p>
+     * If {@link com.jogamp.newt.ScreenMode ScreenMode}s are not supported for this 
+     * native type {@link com.jogamp.newt.Display#getType()}, it returns a list of size one with the current screen size.</p>
+     * 
+     * @return a shallow copy of the internal immutable {@link com.jogamp.newt.ScreenMode ScreenMode}s.
      */
     public abstract List<ScreenMode> getScreenModes();
 
     /**
      * Return the original {@link com.jogamp.newt.ScreenMode}, as used at NEWT initialization.
-     * @return null if functionality not implemented,
-     * otherwise the original ScreenMode which is element of the list {@link #getScreenModes()}.
-     *
+     * @return original ScreenMode which is element of the list {@link #getScreenModes()}.
      */
     public abstract ScreenMode getOriginalScreenMode();
 
     /**
      * Return the current {@link com.jogamp.newt.ScreenMode}.
-     * @return null if functionality not implemented,
-     * otherwise the current ScreenMode which is element of the list {@link #getScreenModes()}.
+     * <p>
+     * If {@link com.jogamp.newt.ScreenMode ScreenMode}s are not supported for this 
+     * native type {@link com.jogamp.newt.Display#getType()}, it returns one with the current screen size. </p>
+     * 
+     * @return current ScreenMode which is element of the list {@link #getScreenModes()}.
      */
     public abstract ScreenMode getCurrentScreenMode();
 
diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java
index 24555bf..32024a4 100644
--- a/src/newt/classes/com/jogamp/newt/Window.java
+++ b/src/newt/classes/com/jogamp/newt/Window.java
@@ -30,12 +30,13 @@ package com.jogamp.newt;
 
 import com.jogamp.newt.event.WindowListener;
 import com.jogamp.newt.event.KeyListener;
+import com.jogamp.newt.event.KeyEvent;
+import com.jogamp.newt.event.InputEvent;
 import com.jogamp.newt.event.MouseListener;
 import jogamp.newt.Debug;
 import javax.media.nativewindow.CapabilitiesChooser;
 import javax.media.nativewindow.CapabilitiesImmutable;
 import javax.media.nativewindow.NativeWindow;
-import javax.media.nativewindow.SurfaceUpdatedListener;
 import javax.media.nativewindow.WindowClosingProtocol;
 
 /**
@@ -133,6 +134,11 @@ public interface Window extends NativeWindow, WindowClosingProtocol {
 
     boolean isVisible();
 
+    /** 
+     * If the implementation uses delegation, return the delegated {@link Window} instance, 
+     * otherwise return <code>this</code> instance. */
+    Window getDelegatedWindow();
+    
     //
     // Child Window Management
     // 
@@ -225,6 +231,44 @@ public interface Window extends NativeWindow, WindowClosingProtocol {
 
     String getTitle();
 
+    boolean isPointerVisible();
+    
+    /**
+     * Makes the pointer visible or invisible.
+     * 
+     * @param pointerVisible defaults to <code>true</code> for platforms w/ visible pointer,
+     *                       otherwise defaults to <code>true</code>, eg. Android.
+     * @see #confinePointer(boolean)
+     */
+    void setPointerVisible(boolean pointerVisible);
+
+    boolean isPointerConfined();
+    
+    /**
+     * Confine the pointer to this window, ie. pointer jail.
+     * <p>
+     * Before jailing the mouse pointer, 
+     * the window request the focus and the pointer is centered in the window.
+     * </p>
+     * <p>
+     * In combination w/ {@link #warpPointer(int, int)} 
+     * and maybe {@link #setPointerVisible(boolean)} a simple mouse
+     * navigation can be realized.</p>
+     *  
+     * @param confine defaults to <code>false</code>.
+     */
+    void confinePointer(boolean confine);
+    
+    /**
+     * Moves the pointer to x/y relative to this window's origin.
+     * 
+     * @param x relative pointer x position within this window
+     * @param y relative pointer y position within this window
+     * 
+     * @see #confinePointer(boolean)
+     */
+    void warpPointer(int x, int y);
+    
     /** Defining ids for the reparenting strategy */
     public interface ReparentAction {
         /** No native reparenting valid */
@@ -272,16 +316,46 @@ public interface Window extends NativeWindow, WindowClosingProtocol {
     }
 
     /**
-     * May set to a {@link FocusRunnable}, {@link FocusRunnable#run()} before Newt requests the native focus.
+     * Sets a {@link FocusRunnable}, 
+     * which {@link FocusRunnable#run()} method is executed before the native focus is requested.
+     * <p>
      * This allows notifying a covered window toolkit like AWT that the focus is requested,
      * hence focus traversal can be made transparent.
+     * </p>
      */
     void setFocusAction(FocusRunnable focusAction);
+    
+    /**
+     * Sets a {@link KeyListener} allowing focus traversal with a covered window toolkit like AWT.
+     * <p>
+     * The {@link KeyListener} methods are invoked prior to all other {@link KeyListener}'s
+     * allowing to suppress the {@link KeyEvent} via the {@link InputEvent#consumedTag}.
+     * </p>
+     * @param l
+     */
+    void setKeyboardFocusHandler(KeyListener l);
 
+    /** 
+     * Request focus for this native window
+     * <p>
+     * The request is handled on this Window EDT and blocked until finished.
+     * </p>
+     * 
+     * @see #requestFocus(boolean)
+     */
     void requestFocus();
 
-    boolean hasFocus();
-
+    /** 
+     * Request focus for this native window
+     * <p>
+     * The request is handled on this Window EDT. 
+     * </p>
+     * 
+     * @param wait true if waiting until the request is executed, otherwise false
+     * @see #requestFocus()
+     */
+    void requestFocus(boolean wait);
+    
     void windowRepaint(int x, int y, int width, int height);
 
     void enqueueEvent(boolean wait, com.jogamp.newt.event.NEWTEvent event);
@@ -290,38 +364,6 @@ public interface Window extends NativeWindow, WindowClosingProtocol {
 
 
     //
-    // SurfaceUpdateListener
-    //
-
-    /**
-     * Appends the given {@link com.jogamp.newt.event.SurfaceUpdatedListener} to the end of
-     * the list.
-     */
-    void addSurfaceUpdatedListener(SurfaceUpdatedListener l);
-
-    /**
-     *
-     * Inserts the given {@link com.jogamp.newt.event.SurfaceUpdatedListener} at the
-     * specified position in the list.<br>
-     *
-     * @param index Position where the listener will be inserted.
-     * Should be within (0 <= index && index <= size()).
-     * An index value of -1 is interpreted as the end of the list, size().
-     * @param l The listener object to be inserted
-     * @throws IndexOutOfBoundsException If the index is not within (0 <= index && index <= size()), or -1
-     */
-    void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException;
-
-    void removeAllSurfaceUpdatedListener();
-
-    void removeSurfaceUpdatedListener(SurfaceUpdatedListener l);
-
-    SurfaceUpdatedListener getSurfaceUpdatedListener(int index);
-
-    SurfaceUpdatedListener[] getSurfaceUpdatedListeners();
-
-
-    //
     // WindowListener
     //
 
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index 929980d..a71c610 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -29,41 +29,56 @@
 
 package com.jogamp.newt.awt;
 
-import com.jogamp.newt.Display;
-import java.lang.reflect.*;
-import java.security.*;
-
+import java.awt.AWTKeyStroke;
 import java.awt.Canvas;
-import java.awt.EventQueue;
 import java.awt.Graphics;
+import java.awt.GraphicsConfiguration;
 import java.awt.KeyboardFocusManager;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Set;
 
 import javax.media.nativewindow.NativeWindow;
-import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.OffscreenLayerOption;
 import javax.media.nativewindow.WindowClosingProtocol;
 import javax.media.nativewindow.awt.AWTWindowClosingProtocol;
+import javax.swing.MenuSelectionManager;
+
 import jogamp.nativewindow.awt.AWTMisc;
+import jogamp.nativewindow.jawt.JAWTWindow;
+import jogamp.newt.Debug;
+import jogamp.newt.awt.NewtFactoryAWT;
+import jogamp.newt.awt.event.AWTParentWindowAdapter;
+import jogamp.newt.driver.DriverClearFocus;
 
-import com.jogamp.newt.event.awt.AWTAdapter;
-import com.jogamp.newt.event.WindowEvent;
+import com.jogamp.newt.Display;
 import com.jogamp.newt.Window;
+import com.jogamp.newt.event.InputEvent;
+import com.jogamp.newt.event.KeyEvent;
+import com.jogamp.newt.event.KeyListener;
 import com.jogamp.newt.event.WindowAdapter;
+import com.jogamp.newt.event.WindowEvent;
 import com.jogamp.newt.event.WindowListener;
-import jogamp.newt.Debug;
-import jogamp.newt.awt.event.AWTParentWindowAdapter;
-import jogamp.newt.awt.event.NewtFactoryAWT;
-
-import javax.swing.MenuSelectionManager;
+import com.jogamp.newt.event.awt.AWTAdapter;
+import com.jogamp.newt.event.awt.AWTKeyAdapter;
+import com.jogamp.newt.event.awt.AWTMouseAdapter;
 
 @SuppressWarnings("serial")
-public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProtocol {
+public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProtocol, OffscreenLayerOption {
     public static final boolean DEBUG = Debug.debug("Window");
 
-    NativeWindow nativeWindow = null;
-    Window newtChild = null;
-    int newtChildCloseOp;
-    AWTAdapter awtAdapter = null;
-
+    private JAWTWindow jawtWindow = null;
+    private boolean shallUseOffscreenLayer = false;
+    private Window newtChild = null;
+    private boolean isOnscreen = true;
+    private int newtChildCloseOp;
+    private AWTAdapter awtAdapter = null;
+    private AWTAdapter awtMouseAdapter = null;
+    private AWTAdapter awtKeyAdapter = null;
+    
     private AWTWindowClosingProtocol awtWindowClosingProtocol =
           new AWTWindowClosingProtocol(this, new Runnable() {
                 public void run() {
@@ -79,6 +94,13 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
     }
 
     /**
+     * Instantiates a NewtCanvas without a NEWT child.<br>
+     */
+    public NewtCanvasAWT(GraphicsConfiguration gc) {
+        super(gc);
+    }
+
+    /**
      * Instantiates a NewtCanvas with a NEWT child.
      */
     public NewtCanvasAWT(Window child) {
@@ -86,54 +108,144 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
         setNEWTChild(child);
     }
 
+    /**
+     * Instantiates a NewtCanvas with a NEWT child.
+     */
+    public NewtCanvasAWT(GraphicsConfiguration gc, Window child) {
+        super(gc);
+        setNEWTChild(child);
+    }
+    
+    public void setShallUseOffscreenLayer(boolean v) {
+        shallUseOffscreenLayer = v;
+    }
+    
+    public final boolean getShallUseOffscreenLayer() {
+        return shallUseOffscreenLayer;        
+    }
+    
+    public final boolean isOffscreenLayerSurfaceEnabled() { 
+        return jawtWindow.isOffscreenLayerSurfaceEnabled();
+    }
+      
+    /** 
+     * Returns true if the AWT component is parented to an {@link java.applet.Applet}, 
+     * otherwise false. This information is valid only after {@link #addNotify()} is issued, 
+     * ie. before adding the component to the AWT tree and make it visible. 
+     */
+    public boolean isApplet() {
+        return jawtWindow.isApplet();
+    }
+    
     class FocusAction implements Window.FocusRunnable {
         public boolean run() {
-            if ( EventQueue.isDispatchThread() ) {
-                focusActionImpl.run();
-            } else {
-                try {
-                    EventQueue.invokeAndWait(focusActionImpl);
-                } catch (Exception e) {
-                    throw new NativeWindowException(e);
-                }
-                /**
-                // wait for AWT focus !
-                for(long sleep = Window.TIMEOUT_NATIVEWINDOW; 0<sleep && !isFocusOwner(); sleep-=10 ) {
-                    try { Thread.sleep(10); } catch (InterruptedException e) { }
-                } */
+            if(DEBUG) {
+                System.err.println("NewtCanvasAWT.FocusAction: "+Display.getThreadName()+", isOnscreen "+isOnscreen+", hasFocus "+hasFocus());
             }
-            return focusActionImpl.result;
-        }
-
-        class FocusActionImpl implements Runnable {
-            public final boolean result = false; // NEWT shall always proceed requesting the native focus
-            public void run() {
-                if(DEBUG) {
-                    System.err.println("FocusActionImpl.run() "+Display.getThreadName());
-                }
-                NewtCanvasAWT.this.requestFocusAWTParent();
-                KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
-                kfm.clearGlobalFocusOwner();
+            // Newt-EDT -> AWT-EDT may freeze Window's native peer requestFocus.
+            if(!hasFocus()) {
+                // Acquire the AWT focus 1st for proper AWT traversal
+                NewtCanvasAWT.super.requestFocus();
+            }
+            if(isOnscreen) {
+                // Remove the AWT focus in favor of the native NEWT focus
+                KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
             }
+            return false; // NEWT shall proceed requesting the native focus
         }
-        FocusActionImpl focusActionImpl = new FocusActionImpl();
     }
-    FocusAction focusAction = new FocusAction();
+    private FocusAction focusAction = new FocusAction();
     
     WindowListener clearAWTMenusOnNewtFocus = new WindowAdapter() {
           @Override
           public void windowGainedFocus(WindowEvent arg0) {
-                  MenuSelectionManager.defaultManager().clearSelectedPath();
+              MenuSelectionManager.defaultManager().clearSelectedPath();
           }
     };
 
-    /** sets a new NEWT child, provoking reparenting on the NEWT level. */
-    /*package */ NewtCanvasAWT setNEWTChild(Window child) {
+    class FocusTraversalKeyListener implements KeyListener {
+         boolean suppress = false;
+         
+         public void keyPressed(KeyEvent e) {
+             handleKey(e, false);
+         }
+         public void keyReleased(KeyEvent e) {
+             handleKey(e, true);
+         }
+         public void keyTyped(KeyEvent e) {
+             if(suppress) {
+                 e.setAttachment(InputEvent.consumedTag);
+                 suppress = false; // reset
+             }             
+         }
+         
+         void handleKey(KeyEvent evt, boolean onRelease) {   
+             if(null == keyboardFocusManager) {
+                 throw new InternalError("XXX");
+             }
+             final AWTKeyStroke ks = AWTKeyStroke.getAWTKeyStroke(evt.getKeyCode(), evt.getModifiers(), onRelease);
+             if(null != ks) {
+                 final Set<AWTKeyStroke> fwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); 
+                 final Set<AWTKeyStroke> bwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);         
+                 if(fwdKeys.contains(ks)) {
+                     if(DEBUG) {
+                         System.err.println("NewtCanvasAWT.focusKey (fwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner());
+                     }
+                     // Newt-EDT -> AWT-EDT may freeze Window's native peer requestFocus.
+                     NewtCanvasAWT.this.transferFocus();
+                     suppress = true;
+                 } else if(bwdKeys.contains(ks)) {
+                     if(DEBUG) {
+                         System.err.println("NewtCanvasAWT.focusKey (bwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner());
+                     }
+                     // Newt-EDT -> AWT-EDT may freeze Window's native peer requestFocus.
+                     NewtCanvasAWT.this.transferFocusBackward();
+                     suppress = true;
+                 }
+             }
+             if(suppress) {
+                 evt.setAttachment(InputEvent.consumedTag);                 
+             }
+             if(DEBUG) {
+                 System.err.println("NewtCanvasAWT.focusKey: XXX: "+ks);
+             }
+         }
+    }
+    private final FocusTraversalKeyListener newtFocusTraversalKeyListener = new FocusTraversalKeyListener(); 
+
+    class FocusPropertyChangeListener implements PropertyChangeListener {
+        public void propertyChange(PropertyChangeEvent evt) {
+            final Object oldF = evt.getOldValue();
+            final Object newF = evt.getNewValue();
+            if(DEBUG) {
+                System.err.println("NewtCanvasAWT.FocusProperty: "+evt.getPropertyName()+", src "+evt.getSource()+", "+oldF+" -> "+newF);
+            }
+            if(oldF == NewtCanvasAWT.this && newF == null) {
+                // focus traversal to NEWT - NOP
+                if(DEBUG) {                    
+                    System.err.println("NewtCanvasAWT.FocusProperty: NEWT focus traversal");
+                }
+            } else if(null != newF && newF != NewtCanvasAWT.this) {
+                // focus traversal to another AWT component
+                if(DEBUG) {                    
+                    System.err.println("NewtCanvasAWT.FocusProperty: lost focus - clear focus");
+                }
+                if(newtChild.getDelegatedWindow() instanceof DriverClearFocus) {
+                    ((DriverClearFocus)newtChild.getDelegatedWindow()).clearFocus();
+                }
+            }
+        }        
+    }
+    private final FocusPropertyChangeListener focusPropertyChangeListener = new FocusPropertyChangeListener();
+    private volatile KeyboardFocusManager keyboardFocusManager = null;
+
+    /** sets a new NEWT child, provoking reparenting. */
+    private NewtCanvasAWT setNEWTChild(Window child) {
         if(newtChild!=child) {
             newtChild = child;
-            if(null!=nativeWindow) {
-                java.awt.Container cont = AWTMisc.getContainer(this);
+            if(isDisplayable()) {
                 // reparent right away, addNotify has been called already
+                final java.awt.Container cont = AWTMisc.getContainer(this);
                 reparentWindow( (null!=child) ? true : false, cont );
             }
         }
@@ -147,8 +259,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
 
     /** @return this AWT Canvas NativeWindow representation, may be null in case {@link #removeNotify()} has been called,
      * or {@link #addNotify()} hasn't been called yet.*/
-    public NativeWindow getNativeWindow() { return nativeWindow; }
-
+    public NativeWindow getNativeWindow() { return jawtWindow; }
+    
     public int getDefaultCloseOperation() {
         return awtWindowClosingProtocol.getDefaultCloseOperation();
     }
@@ -162,13 +274,41 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
           awtAdapter.removeFrom(this);
           awtAdapter=null;
         }
+        if(null!=awtMouseAdapter) {
+            awtMouseAdapter.removeFrom(this);
+            awtMouseAdapter = null;
+        }
+        if(null!=awtKeyAdapter) {
+            awtKeyAdapter.removeFrom(this);
+            awtKeyAdapter = null;
+        }
+        newtChild.setKeyboardFocusHandler(null);
+        if(null != keyboardFocusManager) {
+            keyboardFocusManager.removePropertyChangeListener("focusOwner", focusPropertyChangeListener);
+            keyboardFocusManager = null;
+        }
+        
         if( null != newtChild ) {
             if(attach) {
+                if(null == jawtWindow.getGraphicsConfiguration()) {
+                    throw new InternalError("XXX");
+                }                
+                isOnscreen = jawtWindow.getGraphicsConfiguration().getChosenCapabilities().isOnscreen();
                 awtAdapter = new AWTParentWindowAdapter(newtChild).addTo(this);
                 newtChild.addWindowListener(clearAWTMenusOnNewtFocus);
                 newtChild.setFocusAction(focusAction); // enable AWT focus traversal
                 newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingProtocol.DO_NOTHING_ON_CLOSE);
                 awtWindowClosingProtocol.addClosingListenerOneShot();
+                keyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
+                keyboardFocusManager.addPropertyChangeListener("focusOwner", focusPropertyChangeListener);
+                if(isOnscreen) {
+                    // onscreen newt child needs to fwd AWT focus
+                    newtChild.setKeyboardFocusHandler(newtFocusTraversalKeyListener);
+                } else {
+                    // offscreen newt child requires AWT to fwd AWT key/mouse event
+                    awtMouseAdapter = new AWTMouseAdapter(newtChild).addTo(this);
+                    awtKeyAdapter = new AWTKeyAdapter(newtChild).addTo(this);
+                }
             } else {
                 newtChild.removeWindowListener(clearAWTMenusOnNewtFocus);
                 newtChild.setFocusAction(null);
@@ -217,26 +357,47 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
 
       newtChild.setFocusAction(null); // no AWT focus traversal ..
       if(add) {
-          nativeWindow = NewtFactoryAWT.getNativeWindow(this, newtChild.getRequestedCapabilities());
-          if(null!=nativeWindow) {
-              if(DEBUG) {
-                System.err.println("NewtCanvasAWT.reparentWindow: "+newtChild);
-              }
-              final int w = cont.getWidth();
-              final int h = cont.getHeight();
-              setSize(w, h);
-              newtChild.setSize(w, h);
-              newtChild.reparentWindow(nativeWindow);
-              newtChild.setVisible(true);
-              configureNewtChild(true);
-              newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener
-              newtChild.windowRepaint(0, 0, w, h);
+          jawtWindow = NewtFactoryAWT.getNativeWindow(this, newtChild.getRequestedCapabilities());          
+          jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer);
+          if(DEBUG) {
+            System.err.println("NewtCanvasAWT.reparentWindow: newtChild: "+newtChild);
+          }
+          final int w;
+          final int h;
+          if(isPreferredSizeSet()) {
+             java.awt.Dimension d = getPreferredSize();
+             w = d.width;
+             h = d.height;
+          } else {
+             final java.awt.Dimension min;
+             if(this.isMinimumSizeSet()) {
+                 min = getMinimumSize();
+             } else {
+                 min = new java.awt.Dimension(0, 0);
+             }
+             java.awt.Insets ins = cont.getInsets();
+             w = Math.max(min.width, cont.getWidth() - ins.left - ins.right);
+             h = Math.max(min.height, cont.getHeight() - ins.top - ins.bottom);
           }
+          setSize(w, h);
+          newtChild.setSize(w, h);
+          newtChild.reparentWindow(jawtWindow);
+          newtChild.setVisible(true);
+          configureNewtChild(true);
+          newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener
+          newtChild.windowRepaint(0, 0, w, h);
+          
+          // force this AWT Canvas to be focus-able, 
+          // since this it is completely covered by the newtChild (z-order).
+          setFocusable(true);        
       } else {
-          configureNewtChild(false);
-          nativeWindow = null;
+          configureNewtChild(false);          
           newtChild.setVisible(false);
           newtChild.reparentWindow(null);
+          if(null != jawtWindow) {
+              NewtFactoryAWT.destroyNativeWindow(jawtWindow);
+              jawtWindow=null;
+          }
       }
     }
 
@@ -258,7 +419,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
                 System.err.println("NewtCanvasAWT.destroy(): "+newtChild+", from "+cont);
             }
             configureNewtChild(false);
-            nativeWindow = null;
+            if(null!=jawtWindow) {
+                NewtFactoryAWT.destroyNativeWindow(jawtWindow);
+                jawtWindow=null;
+            }
             newtChild.setVisible(false);
             newtChild.reparentWindow(null);
             newtChild.destroy();
@@ -267,7 +431,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
                 cont.remove(this);
             }
         }
-    }
+    }    
 
     @Override
     public void paint(Graphics g) {
@@ -284,13 +448,12 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
         }
     }
 
-    final void requestFocusAWTParent() {
-        super.requestFocusInWindow();
-    }
-
-    final void requestFocusNEWTChild() {
+    private final void requestFocusNEWTChild() {
         if(null!=newtChild) {
             newtChild.setFocusAction(null);
+            if(isOnscreen) {                    
+                KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
+            }
             newtChild.requestFocus();
             newtChild.setFocusAction(focusAction);
         }
diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java
index 38a3d95..a052f6f 100755
--- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java
+++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java
@@ -1,16 +1,48 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ *    1. Redistributions of source code must retain the above copyright notice, this list of
+ *       conditions and the following disclaimer.
+ *
+ *    2. Redistributions in binary form must reproduce the above copyright notice, this list
+ *       of conditions and the following disclaimer in the documentation and/or other materials
+ *       provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
 package com.jogamp.newt.awt.applet;
 
-import java.applet.*;
+import java.applet.Applet;
+import java.awt.BorderLayout;
+import java.awt.Button;
+import java.awt.Component;
 import java.awt.Container;
+import java.awt.event.KeyListener;
 import java.awt.event.MouseListener;
 import java.awt.event.MouseMotionListener;
-import java.awt.event.KeyListener;
 
-import javax.media.opengl.*;
+import javax.media.opengl.FPSCounter;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
 
 import com.jogamp.newt.awt.NewtCanvasAWT;
 import com.jogamp.newt.opengl.GLWindow;
-import java.awt.BorderLayout;
 
 /** 
  * Simple GLEventListener deployment as an applet using JOGL. This demo must be
@@ -58,6 +90,8 @@ import java.awt.BorderLayout;
  */
 @SuppressWarnings("serial")
 public class JOGLNewtApplet1Run extends Applet {
+    public static final boolean DEBUG = JOGLNewtAppletBase.DEBUG;
+    
     GLWindow glWindow;
     NewtCanvasAWT newtCanvasAWT;
     JOGLNewtAppletBase base;
@@ -66,10 +100,13 @@ public class JOGLNewtApplet1Run extends Applet {
     boolean glStandalone = false;
 
     public void init() {
+        if(DEBUG) {
+            System.err.println("JOGLNewtApplet1Run.init() START");
+        }
         if(!(this instanceof Container)) {
             throw new RuntimeException("This Applet is not a AWT Container");
         }
-        Container container = (Container) this; // have to think about that, we may use a Container
+        Container container = (Container) this;
 
         String glEventListenerClazzName=null;
         String glProfileName=null;
@@ -82,6 +119,7 @@ public class JOGLNewtApplet1Run extends Applet {
         int glAlphaBits=0;
         int glNumMultisampleBuffer=0;
         boolean glNoDefaultKeyListener = false;
+        boolean appletDebugTestBorder = false;
         try {
             glEventListenerClazzName = getParameter("gl_event_listener_class");
             glProfileName = getParameter("gl_profile");
@@ -98,6 +136,7 @@ public class JOGLNewtApplet1Run extends Applet {
             glWidth = JOGLNewtAppletBase.str2Int(getParameter("gl_width"), glWidth);
             glHeight = JOGLNewtAppletBase.str2Int(getParameter("gl_height"), glHeight);
             glNoDefaultKeyListener = JOGLNewtAppletBase.str2Bool(getParameter("gl_nodefaultkeyListener"), glNoDefaultKeyListener);
+            appletDebugTestBorder = JOGLNewtAppletBase.str2Bool(getParameter("appletDebugTestBorder"), appletDebugTestBorder);
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -105,6 +144,24 @@ public class JOGLNewtApplet1Run extends Applet {
             throw new RuntimeException("No applet parameter 'gl_event_listener_class'");
         }
         glStandalone = Integer.MAX_VALUE>glXd && Integer.MAX_VALUE>glYd && Integer.MAX_VALUE>glWidth && Integer.MAX_VALUE>glHeight;
+        if(DEBUG) {
+            System.err.println("JOGLNewtApplet1Run Configuration:");
+            System.err.println("glStandalone: "+glStandalone);
+            if(glStandalone) {
+                System.err.println("pos-size: "+glXd+"/"+glYd+" "+glWidth+"x"+glHeight);
+            }
+            System.err.println("glEventListenerClazzName: "+glEventListenerClazzName);
+            System.err.println("glProfileName: "+glProfileName);
+            System.err.println("glSwapInterval: "+glSwapInterval);
+            System.err.println("glDebug: "+glDebug);
+            System.err.println("glTrace: "+glTrace);
+            System.err.println("glUndecorated: "+glUndecorated);
+            System.err.println("glAlwaysOnTop: "+glAlwaysOnTop);
+            System.err.println("glOpaque: "+glOpaque);
+            System.err.println("glAlphaBits: "+glAlphaBits);
+            System.err.println("glNumMultisampleBuffer: "+glNumMultisampleBuffer);
+            System.err.println("glNoDefaultKeyListener: "+glNoDefaultKeyListener);
+        }
         
         base = new JOGLNewtAppletBase(glEventListenerClazzName, 
                                       glSwapInterval,
@@ -113,7 +170,6 @@ public class JOGLNewtApplet1Run extends Applet {
                                       glTrace);
 
         try {
-            GLProfile.initSingleton(false);
             GLCapabilities caps = new GLCapabilities(GLProfile.get(glProfileName));
             caps.setAlphaBits(glAlphaBits);
             if(0<glNumMultisampleBuffer) {
@@ -125,12 +181,12 @@ public class JOGLNewtApplet1Run extends Applet {
             glWindow.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err);
             glWindow.setUndecorated(glUndecorated);
             glWindow.setAlwaysOnTop(glAlwaysOnTop);
-            if(glStandalone) {
-                newtCanvasAWT = null;
-            } else {
-                newtCanvasAWT = new NewtCanvasAWT(glWindow);
-                container.setLayout(new BorderLayout());
-                container.add(newtCanvasAWT, BorderLayout.CENTER);
+            container.setLayout(new BorderLayout());
+            if(appletDebugTestBorder) {
+                container.add(new Button("North"), BorderLayout.NORTH);
+                container.add(new Button("South"), BorderLayout.SOUTH);
+                container.add(new Button("East"), BorderLayout.EAST);
+                container.add(new Button("West"), BorderLayout.WEST);
             }
             base.init(glWindow);
             if(base.isValid()) {
@@ -146,25 +202,67 @@ public class JOGLNewtApplet1Run extends Applet {
                     addKeyListener((KeyListener)glEventListener);
                 }
             }
+            if(glStandalone) {
+                newtCanvasAWT = null;
+            } else {
+                newtCanvasAWT = new NewtCanvasAWT(glWindow);
+                container.add(newtCanvasAWT, BorderLayout.CENTER);
+                container.validate();
+            }
         } catch (Throwable t) {
             throw new RuntimeException(t);
         }
+        if(DEBUG) {
+            System.err.println("JOGLNewtApplet1Run.init() END");
+        }
     }
 
     public void start() {
+        if(DEBUG) {
+            System.err.println("JOGLNewtApplet1Run.start() START");
+        }
+        this.validate();
+        this.setVisible(true);
+        
+        final java.awt.Point p0 = this.getLocationOnScreen();
         if(glStandalone) {
             glWindow.setSize(glWidth, glHeight);
-            final java.awt.Point p0 = this.getLocationOnScreen();
             glWindow.setPosition(p0.x+glXd, p0.y+glYd);
         }
+        if(DEBUG) {
+            Component topC = this;
+            while (null != topC.getParent()) {
+                topC = topC.getParent();
+            }
+            System.err.println("JOGLNewtApplet1Run start:");
+            System.err.println("TopComponent: "+topC.getLocation()+" rel, "+topC.getLocationOnScreen()+" screen, visible "+topC.isVisible()+", "+topC);
+            System.err.println("Applet Pos: "+this.getLocation()+" rel, "+p0+" screen, visible "+this.isVisible()+", "+this);
+            if(null != newtCanvasAWT) {
+                System.err.println("NewtCanvasAWT Pos: "+newtCanvasAWT.getLocation()+" rel, "+newtCanvasAWT.getLocationOnScreen()+" screen, visible "+newtCanvasAWT.isVisible()+", "+newtCanvasAWT);
+            }
+            System.err.println("GLWindow Pos: "+glWindow.getX()+"/"+glWindow.getY()+" rel, "+glWindow.getLocationOnScreen(null)+" screen");
+            System.err.println("GLWindow: "+glWindow);
+        }
         base.start();
+        if(DEBUG) {
+            System.err.println("JOGLNewtApplet1Run.start() END");
+        }
     }
 
     public void stop() {
+        if(DEBUG) {
+            System.err.println("JOGLNewtApplet1Run.stop() START");
+        }
         base.stop();
+        if(DEBUG) {
+            System.err.println("JOGLNewtApplet1Run.stop() END");
+        }
     }
 
     public void destroy() {
+        if(DEBUG) {
+            System.err.println("JOGLNewtApplet1Run.destroy() START");
+        }
         glWindow.setVisible(false); // hide 1st
         if(!glStandalone) {
             glWindow.reparentWindow(null); // get out of newtCanvasAWT
@@ -172,6 +270,9 @@ public class JOGLNewtApplet1Run extends Applet {
         }
         base.destroy(); // destroy glWindow unrecoverable
         base=null;
+        if(DEBUG) {
+            System.err.println("JOGLNewtApplet1Run.destroy() END");
+        }
     }
 }
 
diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java
index c6240d1..67da502 100755
--- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java
+++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java
@@ -1,21 +1,60 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ *    1. Redistributions of source code must retain the above copyright notice, this list of
+ *       conditions and the following disclaimer.
+ *
+ *    2. Redistributions in binary form must reproduce the above copyright notice, this list
+ *       of conditions and the following disclaimer in the documentation and/or other materials
+ *       provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
 package com.jogamp.newt.awt.applet;
 
-import java.lang.reflect.*;
+import java.lang.reflect.Field;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
 import javax.media.nativewindow.NativeWindow;
-import javax.media.opengl.*;
-
-import com.jogamp.opengl.util.*;
-
-import com.jogamp.newt.event.*;
+import javax.media.opengl.FPSCounter;
+import javax.media.opengl.GL;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLPipelineFactory;
+
+import jogamp.newt.Debug;
+
+import com.jogamp.newt.event.KeyEvent;
+import com.jogamp.newt.event.KeyListener;
+import com.jogamp.newt.event.MouseListener;
+import com.jogamp.newt.event.WindowEvent;
+import com.jogamp.newt.event.WindowListener;
 import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.util.Animator;
+
 
 /** Shows how to deploy an applet using JOGL. This demo must be
     referenced from a web page via an <applet> tag. */
 
 public class JOGLNewtAppletBase implements KeyListener, GLEventListener {
+    public static final boolean DEBUG = Debug.debug("Applet");
+    
     String glEventListenerClazzName;
     int glSwapInterval;
     boolean noDefaultKeyListener;
@@ -161,6 +200,7 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener {
     public void start() {
         if(isValid) {
             glWindow.setVisible(true);
+            glWindow.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
             glAnimator.start();
             awtParent = glWindow.getParent();
         }
diff --git a/src/newt/classes/com/jogamp/newt/event/InputEvent.java b/src/newt/classes/com/jogamp/newt/event/InputEvent.java
index 40a5c84..d8a9235 100644
--- a/src/newt/classes/com/jogamp/newt/event/InputEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/InputEvent.java
@@ -34,17 +34,25 @@
 
 package com.jogamp.newt.event;
 
+ at SuppressWarnings("serial")
 public abstract class InputEvent extends NEWTEvent
 {
- public static final int  SHIFT_MASK     = 1 << 0;
- public static final int  CTRL_MASK      = 1 << 1;
- public static final int  META_MASK      = 1 << 2;
- public static final int  ALT_MASK       = 1 << 3;
- public static final int  ALT_GRAPH_MASK = 1 << 5;
- public static final int  BUTTON1_MASK   = 1 << 6;
- public static final int  BUTTON2_MASK   = 1 << 7;
- public static final int  BUTTON3_MASK   = 1 << 8;
+ public static final int  SHIFT_MASK     = 1 <<  0;
+ public static final int  CTRL_MASK      = 1 <<  1;
+ public static final int  META_MASK      = 1 <<  2;
+ public static final int  ALT_MASK       = 1 <<  3;
+ public static final int  ALT_GRAPH_MASK = 1 <<  5;
+ public static final int  BUTTON1_MASK   = 1 <<  6;
+ public static final int  BUTTON2_MASK   = 1 <<  7;
+ public static final int  BUTTON3_MASK   = 1 <<  8;
+ public static final int  CONFINED_MASK  = 1 << 16;
+ public static final int  INVISIBLE_MASK = 1 << 17;
 
+ /** Object when attached via {@link #setAttachment(Object)} marks the event consumed,
+  * ie. stops propagating the event any further to the event listener. 
+  */
+ public static final Object consumedTag = new Object();
+ 
  protected InputEvent(int eventType, Object source, long when, int modifiers) {
     super(eventType, source, when);
     this.modifiers=modifiers;
@@ -68,6 +76,12 @@ public abstract class InputEvent extends NEWTEvent
  public boolean isShiftDown()  {
     return (modifiers&SHIFT_MASK)!=0;
  }
+ public boolean isConfined()  {
+    return (modifiers&CONFINED_MASK)!=0;
+ }
+ public boolean isInvisible()  {
+    return (modifiers&INVISIBLE_MASK)!=0;
+ }
 
  /**
   * @return Array of pressed mouse buttons  [{@link MouseEvent#BUTTON1} ..]. 
@@ -100,7 +114,7 @@ public abstract class InputEvent extends NEWTEvent
  }
 
  public String toString() {
-     return "InputEvent[modifiers:"+modifiers+", "+super.toString()+"]";
+     return "InputEvent[modifiers: 0x"+Integer.toHexString(modifiers)+", "+super.toString()+"]";
  }
 
  private final int modifiers;
diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
index 9e4fe37..44fcea4 100644
--- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
@@ -34,6 +34,7 @@
 
 package com.jogamp.newt.event;
 
+ at SuppressWarnings("serial")
 public class KeyEvent extends InputEvent
 {
  public KeyEvent(int eventType, Object source, long when, int modifiers, int keyCode, char keyChar) {
@@ -42,9 +43,12 @@ public class KeyEvent extends InputEvent
      this.keyChar=keyChar;
  }
 
+ /** Only valid if delivered via {@link KeyListener#keyPressed(KeyEvent)} */
  public char getKeyChar() {
     return keyChar;
  }
+ 
+ /** Always valid. */
  public int getKeyCode() {
     return keyCode;
  }
diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
index 2c12049..9bc3be1 100644
--- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
@@ -34,6 +34,7 @@
 
 package com.jogamp.newt.event;
 
+ at SuppressWarnings("serial")
 public class MouseEvent extends InputEvent
 {
     public static final int BUTTON1 = 1;
@@ -138,6 +139,20 @@ public class MouseEvent extends InputEvent
         return pressure[index];
     }
     
+    /**
+     * <i>Usually</i> a wheel rotation of <b>> 0 is up</b>,
+     * and  <b>< 0 is down</b>.<br>
+     * <i>However</i>, on some OS this might be flipped due to the OS <i>default</i> behavior.
+     * The latter is true for OS X 10.7 (Lion) for example.
+     * <p>
+     * The events will be send usually in steps of one, ie. <i>-1</i> and <i>1</i>.
+     * Higher values may result due to fast scrolling.
+     * </p>
+     * <p>
+     * The button number refers to the wheel number.
+     * </p> 
+     * @return
+     */
     public int getWheelRotation() {
         return wheelRotation;
     }
diff --git a/src/newt/classes/com/jogamp/newt/event/MouseListener.java b/src/newt/classes/com/jogamp/newt/event/MouseListener.java
index 5ec086b..7668b75 100644
--- a/src/newt/classes/com/jogamp/newt/event/MouseListener.java
+++ b/src/newt/classes/com/jogamp/newt/event/MouseListener.java
@@ -43,6 +43,8 @@ public interface MouseListener extends NEWTEventListener
  public void mouseReleased(MouseEvent e);
  public void mouseMoved(MouseEvent e);
  public void mouseDragged(MouseEvent e);
+ 
+ /** See {@link MouseEvent#getWheelRotation() } */
  public void mouseWheelMoved(MouseEvent e);
 }
 
diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java
index 50aed2c..3f3817b 100644
--- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java
@@ -46,6 +46,7 @@ package com.jogamp.newt.event;
  *   <li> KeyEvent    <code>300..30x</code></li>
  * </ul><br>
  */
+ at SuppressWarnings("serial")
 public class NEWTEvent extends java.util.EventObject {
     private final boolean isSystemEvent;
     private final int eventType;
diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
index ae7474c..69b0d04 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
@@ -107,6 +107,9 @@ public class AWTWindowAdapter
 
     public void componentResized(java.awt.event.ComponentEvent e) {
         com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
+        if(DEBUG_IMPLEMENTATION) {
+            System.err.println("AWT: componentResized: "+event);
+        }
         if(null!=newtListener) {
             ((com.jogamp.newt.event.WindowListener)newtListener).windowResized(event);
         } else {
@@ -116,6 +119,9 @@ public class AWTWindowAdapter
 
     public void componentMoved(java.awt.event.ComponentEvent e) {
         com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
+        if(DEBUG_IMPLEMENTATION) {
+            System.err.println("AWT: componentMoved: "+event);
+        }
         if(null!=newtListener) {
             ((com.jogamp.newt.event.WindowListener)newtListener).windowMoved(event);
         } else {
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index 7712b46..d03a475 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -41,6 +41,7 @@ import com.jogamp.common.GlueGenVersion;
 import com.jogamp.common.util.VersionUtil;
 import com.jogamp.newt.*;
 import com.jogamp.newt.event.*;
+
 import jogamp.newt.WindowImpl;
 
 import javax.media.nativewindow.*;
@@ -51,10 +52,11 @@ import javax.media.opengl.*;
 import jogamp.opengl.FPSCounterImpl;
 import jogamp.opengl.GLDrawableHelper;
 import com.jogamp.opengl.JoglVersion;
+import com.jogamp.opengl.util.Animator;
 
 /**
- * An implementation of {@link javax.media.opengl.GLAutoDrawable} interface,
- * using an aggregation of a {@link com.jogamp.newt.Window} implementation.
+ * An implementation of {@link GLAutoDrawable} and {@link Window} interface,
+ * using a delegated {@link Window} instance, which may be an aggregation (lifecycle: created and destroyed).
  * <P>
  * This implementation does not make the OpenGL context current<br>
  * before calling the various input EventListener callbacks, ie {@link com.jogamp.newt.event.MouseListener} etc.<br>
@@ -78,7 +80,7 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
         window.addWindowListener(new WindowAdapter() {
                 @Override
                 public void windowRepaint(WindowUpdateEvent e) {
-                    if( !GLWindow.this.window.isWindowLockedByOtherThread() && !GLWindow.this.helper.isExternalAnimatorAnimating() ) {
+                    if( !GLWindow.this.window.isWindowLockedByOtherThread() && !GLWindow.this.helper.isAnimatorAnimating() ) {
                         display();
                     }
                 }
@@ -86,7 +88,7 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
                 @Override
                 public void windowResized(WindowEvent e) {
                     sendReshape = true;
-                    if( !GLWindow.this.window.isWindowLockedByOtherThread() && !GLWindow.this.helper.isExternalAnimatorAnimating() ) {
+                    if( !GLWindow.this.window.isWindowLockedByOtherThread() && !GLWindow.this.helper.isAnimatorAnimating() ) {
                         display();
                     }
                 }
@@ -120,12 +122,13 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
     }
 
     /**
-     * Creates a new GLWindow attaching a new Window referencing a new Screen
-     * with the given GLCapabilities.
-     * <P>
-     * The resulting GLWindow owns the Window, Screen and Device, ie it will be destructed.
-     * <P>
-     * The default display connection will be used and reused if already in process.  
+     * Creates a new GLWindow attaching a new Window referencing a 
+     * new default Screen and default Display with the given GLCapabilities.
+     * <p>
+     * The lifecycle of this Window's Screen and Display is handled via {@link Screen#addReference()}
+     * and {@link Screen#removeReference()}.
+     * </p>
+     * The default Display will be reused if already instantiated.  
      */
     public static GLWindow create(GLCapabilitiesImmutable caps) {
         return new GLWindow(NewtFactory.createWindow(caps));
@@ -134,8 +137,10 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
     /**
      * Creates a new GLWindow attaching a new Window referencing the given Screen
      * with the given GLCapabilities.
-     * <P>
-     * The resulting GLWindow owns the Window, ie it will be destructed.
+     * <p>
+     * The lifecycle of this Window's Screen and Display is handled via {@link Screen#addReference()}
+     * and {@link Screen#removeReference()}.
+     * </p>
      */
     public static GLWindow create(Screen screen, GLCapabilitiesImmutable caps) {
         return new GLWindow(NewtFactory.createWindow(screen, caps));
@@ -143,8 +148,10 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
 
     /** 
      * Creates a new GLWindow attaching the given window.
-     * <P>
-     * The resulting GLWindow does not own the given Window, ie it will not be destructed. 
+     * <p>
+     * The lifecycle of this Window's Screen and Display is handled via {@link Screen#addReference()}
+     * and {@link Screen#removeReference()}.
+     * </p>
      */
     public static GLWindow create(Window window) {
         return new GLWindow(window);
@@ -153,11 +160,15 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
     /** 
      * Creates a new GLWindow attaching a new child Window 
      * of the given <code>parentNativeWindow</code> with the given GLCapabilities.
-     * <P>
+     * <p>
      * The Display/Screen will be compatible with the <code>parentNativeWindow</code>,
      * or even identical in case it's a Newt Window.
-     * <P>
-     * The resulting GLWindow owns the Window, ie it will be destructed. 
+     * An already instantiated compatible Display will be reused.  
+     * </p>
+     * <p>
+     * The lifecycle of this Window's Screen and Display is handled via {@link Screen#addReference()}
+     * and {@link Screen#removeReference()}.
+     * </p>
      */
     public static GLWindow create(NativeWindow parentNativeWindow, GLCapabilitiesImmutable caps) {
         return new GLWindow(NewtFactory.createWindow(parentNativeWindow, caps));
@@ -194,8 +205,8 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
         return window.getRequestedCapabilities();
     }
 
-    public final Window getWindow() {
-        return window;
+    public final Window getDelegatedWindow() {
+        return window.getDelegatedWindow();
     }
 
     public final NativeWindow getParent() {
@@ -214,10 +225,29 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
         return window.getTitle();
     }
 
+    public final boolean isPointerVisible() {
+        return window.isPointerVisible();
+    }
+    
+    public final void setPointerVisible(boolean mouseVisible) {
+        window.setPointerVisible(mouseVisible);        
+    }
+    
+    public final boolean isPointerConfined() {
+        return window.isPointerConfined();
+    }
+    
+    public final void confinePointer(boolean grab) {
+        window.confinePointer(grab);
+    }
+    
     public final void setUndecorated(boolean value) {
         window.setUndecorated(value);
     }
 
+    public final void warpPointer(int x, int y) {
+        window.warpPointer(x, y);
+    }
     public final boolean isUndecorated() {
         return window.isUndecorated();
     }
@@ -234,10 +264,18 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
         window.setFocusAction(focusAction);
     }
     
+    public void setKeyboardFocusHandler(KeyListener l) {
+        window.setKeyboardFocusHandler(l);
+    }
+    
     public final void requestFocus() {
         window.requestFocus();
     }
 
+    public final void requestFocus(boolean wait) {
+        window.requestFocus(wait);        
+    }
+    
     public boolean hasFocus() {
         return window.hasFocus();
     }
@@ -379,11 +417,11 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
             if (null == context && visible && 0 != window.getWindowHandle() && 0<getWidth()*getHeight()) {
                 NativeWindow nw;
                 if (window.getWrappedWindow() != null) {
-                    nw = NativeWindowFactory.getNativeWindow(window.getWrappedWindow(), window.getGraphicsConfiguration());
+                    nw = NativeWindowFactory.getNativeWindow(window.getWrappedWindow(), window.getPrivateGraphicsConfiguration());
                 } else {
                     nw = window;
                 }
-                GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) nw.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+                GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) nw.getGraphicsConfiguration().getChosenCapabilities();
                 if(null==factory) {
                     factory = GLDrawableFactory.getFactory(glCaps.getGLProfile());
                 }
@@ -539,14 +577,12 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
         }
     }
     
-    /** This implementation uses a static value */
-    public void setAutoSwapBufferMode(boolean onOrOff) {
+    public void setAutoSwapBufferMode(boolean enable) {
         if(null!=helper) {
-            helper.setAutoSwapBufferMode(onOrOff);
+            helper.setAutoSwapBufferMode(enable);
         }
     }
 
-    /** This implementation uses a static value */
     public boolean getAutoSwapBufferMode() {
         if(null!=helper) {
             return helper.getAutoSwapBufferMode();
@@ -554,6 +590,28 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
         return false;
     }
     
+    /**
+     * @param t the thread for which context release shall be skipped, usually the animation thread,
+     *          ie. {@link Animator#getThread()}.
+     * @deprecated this is an experimental feature, 
+     *             intended for measuring performance in regards to GL context switch
+     */
+    public void setSkipContextReleaseThread(Thread t) {
+        if(null!=helper) {
+            helper.setSkipContextReleaseThread(t);
+        }
+    }
+
+    /**
+     * @deprecated see {@link #setSkipContextReleaseThread(Thread)} 
+     */
+    public Thread getSkipContextReleaseThread() {
+        if(null!=helper) {
+            return helper.getSkipContextReleaseThread();
+        }
+        return null;
+    }
+    
     public void swapBuffers() {
         if(drawable!=null && context != null) {
             drawable.swapBuffers();
@@ -713,18 +771,6 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
         window.runOnEDTIfAvail(wait, task);
     }
 
-    public final SurfaceUpdatedListener getSurfaceUpdatedListener(int index) {
-        return window.getSurfaceUpdatedListener(index);
-    }
-
-    public final SurfaceUpdatedListener[] getSurfaceUpdatedListeners() {
-        return window.getSurfaceUpdatedListeners();
-    }
-
-    public final void removeAllSurfaceUpdatedListener() {
-        window.removeAllSurfaceUpdatedListener();
-    }
-
     public final void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
         window.removeSurfaceUpdatedListener(l);
     }
diff --git a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java
index d1a11a7..4493e27 100644
--- a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java
+++ b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java
@@ -49,9 +49,19 @@ package com.jogamp.newt.util;
  */
 public interface EDTUtil {
 
-    public static final long defaultEDTPollGranularity = 10; // 10ms, 1/100s
+    public static final long defaultEDTPollPeriod = 10; // 10ms, 1/100s
 
     /**
+     * @return poll period in milliseconds
+     */
+    public long getPollPeriod();
+
+    /**
+     * @param ms poll period in milliseconds
+     */
+    public void setPollPeriod(long ms);
+    
+    /**
      * Create a new EDT. One should invoke <code>reset()</code><br>
      * after <code>invokeStop(..)</code> in case another <code>start()</code> or <code>invoke(..)</code>
      * is expected.
diff --git a/src/newt/classes/com/jogamp/newt/util/MainThread.java b/src/newt/classes/com/jogamp/newt/util/MainThread.java
index 8de7742..e71ef75 100644
--- a/src/newt/classes/com/jogamp/newt/util/MainThread.java
+++ b/src/newt/classes/com/jogamp/newt/util/MainThread.java
@@ -93,17 +93,21 @@ import jogamp.newt.NEWTJNILibLoader;
  */
 public class MainThread {
     private static final String MACOSXDisplayClassName = "jogamp.newt.driver.macosx.MacDisplay";
+    private static final Platform.OSType osType;
+    private static final boolean isMacOSX;
+        
     
     /** if true, use the main thread EDT, otherwise AWT's EDT */
     public static final boolean  HINT_USE_MAIN_THREAD;
     
     static {
         final AccessControlContext localACC = AccessController.getContext();
-        Platform.initSingleton();
         NativeWindowFactory.initSingleton(true);
         NEWTJNILibLoader.loadNEWT();
         HINT_USE_MAIN_THREAD = !NativeWindowFactory.isAWTAvailable() || 
-                                Debug.getBooleanProperty("newt.MainThread.force", true, localACC);        
+                                Debug.getBooleanProperty("newt.MainThread.force", true, localACC);
+        osType = Platform.getOSType();
+        isMacOSX = osType == Platform.OSType.MACOS;                
     }
     
     public static boolean useMainThread = false;
@@ -112,25 +116,27 @@ public class MainThread {
 
     private static final MainThread singletonMainThread = new MainThread(); // one singleton MainThread
 
-    static class MainAction extends Thread {
+    static class UserApp extends Thread {
         private String mainClassName;
         private String[] mainClassArgs;
 
         private Method mainClassMain;
 
-        public MainAction(String mainClassName, String[] mainClassArgs) {
+        public UserApp(String mainClassName, String[] mainClassArgs) {
             this.mainClassName=mainClassName;
             this.mainClassArgs=mainClassArgs;
         }
 
         @Override
         public void run() {
+            setName(getName()+"-UserApp");
+            
             if(DEBUG) System.err.println("MainAction.run(): "+Thread.currentThread().getName()+" start");
             // start user app ..
             try {
                 Class<?> mainClass = ReflectionUtil.getClass(mainClassName, true, getClass().getClassLoader());
                 if(null==mainClass) {
-                    throw new RuntimeException(new ClassNotFoundException("MainThread couldn't find main class "+mainClassName));
+                    throw new RuntimeException(new ClassNotFoundException("MainAction couldn't find main class "+mainClassName));
                 }
                 try {
                     mainClassMain = mainClass.getDeclaredMethod("main", new Class[] { String[].class });
@@ -149,22 +155,36 @@ public class MainThread {
             if(DEBUG) System.err.println("MainAction.run(): "+Thread.currentThread().getName()+" user app fin");
 
             if ( useMainThread ) {
-                if(DEBUG) System.err.println("MainAction.run(): "+Thread.currentThread().getName()+" MainThread fin - stop");
-                System.exit(0);
+                if(isMacOSX) {
+                    try {
+                        if(DEBUG) {
+                            System.err.println("MainAction.main(): "+Thread.currentThread()+" MainAction fin - stopNSApp.0"); 
+                        }
+                        ReflectionUtil.callStaticMethod(MACOSXDisplayClassName, "stopNSApplication", 
+                            null, null, MainThread.class.getClassLoader());
+                        if(DEBUG) {
+                            System.err.println("MainAction.main(): "+Thread.currentThread()+" MainAction fin - stopNSApp.X"); 
+                        }
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                } else {
+                    if(DEBUG) System.err.println("MainAction.run(): "+Thread.currentThread().getName()+" MainAction fin - System.exit(0)");
+                    System.exit(0);                
+                }   
             }
         }
     }
-    private static MainAction mainAction;
+    private static UserApp mainAction;
 
     /** Your new java application main entry, which pipelines your application */
     public static void main(String[] args) {
+        final Thread cur = Thread.currentThread();
+        
         useMainThread = HINT_USE_MAIN_THREAD;
 
-        final Platform.OSType osType = Platform.getOSType();
-        final boolean isMacOSX = osType == Platform.OSType.MACOS;
-        
         if(DEBUG) {
-            System.err.println("MainThread.main(): "+Thread.currentThread().getName()+
+            System.err.println("MainThread.main(): "+cur.getName()+
                 ", useMainThread "+ useMainThread +
                 ", HINT_USE_MAIN_THREAD "+ HINT_USE_MAIN_THREAD +
                 ", isAWTAvailable " + NativeWindowFactory.isAWTAvailable() + ", ostype "+osType+", isMacOSX "+isMacOSX);
@@ -184,7 +204,7 @@ public class MainThread {
             System.arraycopy(args, 1, mainClassArgs, 0, args.length-1);
         }
 
-        mainAction = new MainAction(mainClassName, mainClassArgs);
+        mainAction = new UserApp(mainClassName, mainClassArgs);
 
         if(isMacOSX) {
             ReflectionUtil.callStaticMethod(MACOSXDisplayClassName, "initSingleton", 
@@ -192,13 +212,17 @@ public class MainThread {
         }
 
         if ( useMainThread ) {
+            try {
+                cur.setName(cur.getName()+"-MainThread");
+            } catch (Exception e) {}
+            
             // dispatch user's main thread ..
             mainAction.start();
             
             if(isMacOSX) {
                 try {
                     if(DEBUG) {
-                        System.err.println("MainThread.main(): "+Thread.currentThread().getName()+"- runNSApp"); 
+                        System.err.println("MainThread.main(): "+cur.getName()+"- runNSApp"); 
                     }
                     ReflectionUtil.callStaticMethod(MACOSXDisplayClassName, "runNSApplication", 
                         null, null, MainThread.class.getClassLoader());
diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java
index 0bcd332..fd757fb 100644
--- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java
+++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java
@@ -55,6 +55,7 @@ public class DefaultEDTUtil implements EDTUtil {
     private String name;
     int start_iter=0;
     private Runnable dispatchMessages;
+    private static long pollPeriod = EDTUtil.defaultEDTPollPeriod;
 
     public DefaultEDTUtil(ThreadGroup tg, String name, Runnable dispatchMessages) {
         this.threadGroup = tg;
@@ -64,6 +65,14 @@ public class DefaultEDTUtil implements EDTUtil {
         this.edt.setDaemon(true); // don't stop JVM from shutdown ..
     }
 
+    final public long getPollPeriod() {
+        return pollPeriod;
+    }
+
+    final public void setPollPeriod(long ms) {
+        pollPeriod = ms;
+    }
+    
     public final void reset() {
         synchronized(edtLock) { 
             waitUntilStopped();
@@ -271,7 +280,7 @@ public class DefaultEDTUtil implements EDTUtil {
                         // wait for tasks
                         if(!shouldStop && tasks.size()==0) {
                             try {
-                                tasks.wait(defaultEDTPollGranularity);
+                                tasks.wait(pollPeriod);
                             } catch (InterruptedException e) {
                                 e.printStackTrace();
                             }
diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java
index 2d25161..908a44e 100644
--- a/src/newt/classes/jogamp/newt/DisplayImpl.java
+++ b/src/newt/classes/jogamp/newt/DisplayImpl.java
@@ -438,15 +438,15 @@ public abstract class DisplayImpl extends Display {
         }
     }
 
-    public interface DisplayRunnable {
-        Object run(long dpy);
+    public interface DisplayRunnable<T> {
+        T run(long dpy);
     }    
-    public final Object runWithLockedDisplayHandle(DisplayRunnable action) {
+    public final <T> T runWithLockedDisplayHandle(DisplayRunnable<T> action) {
         final AbstractGraphicsDevice aDevice = getGraphicsDevice();
         if(null == aDevice) {
             throw new RuntimeException("null device - not initialized: "+this);
         }
-        Object res;
+        T res;
         aDevice.lock();
         try {
             res = action.run(aDevice.getHandle());
diff --git a/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java b/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java
index 1f5d5dd..78707e7 100644
--- a/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java
+++ b/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java
@@ -43,6 +43,7 @@ import java.security.AccessController;
 import java.security.PrivilegedAction;
 
 import com.jogamp.common.jvm.JNILibLoaderBase;
+import com.jogamp.common.os.Platform;
 import com.jogamp.common.util.cache.TempJarCache;
 
 public class NEWTJNILibLoader extends JNILibLoaderBase {
@@ -50,9 +51,10 @@ public class NEWTJNILibLoader extends JNILibLoaderBase {
   public static void loadNEWT() {
     AccessController.doPrivileged(new PrivilegedAction<Object>() {
       public Object run() {
+        Platform.initSingleton();
         final String libName = "newt";
         if(TempJarCache.isInitialized() && null == TempJarCache.findLibrary(libName)) {
-            addNativeJarLibs(NEWTJNILibLoader.class, "jogl.all", "jogl-all", new String[] { "nativewindow", "newt" } );
+            addNativeJarLibs(NEWTJNILibLoader.class, "jogl-all", new String[] { "nativewindow", "newt" } );
         }
         loadLibrary(libName, false);
         return null;
diff --git a/src/newt/classes/jogamp/newt/OffscreenWindow.java b/src/newt/classes/jogamp/newt/OffscreenWindow.java
index fa7bafe..050e24b 100644
--- a/src/newt/classes/jogamp/newt/OffscreenWindow.java
+++ b/src/newt/classes/jogamp/newt/OffscreenWindow.java
@@ -48,18 +48,16 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable {
     static long nextWindowHandle = 0x100; // start here - a marker
 
     protected void createNativeImpl() {
-        if(0!=getParentWindowHandle()) {
-            throw new NativeWindowException("OffscreenWindow does not support window parenting");
-        }
         if(capsRequested.isOnscreen()) {
             throw new NativeWindowException("Capabilities is onscreen");
         }
-        AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen();
-        config = GraphicsConfigurationFactory.getFactory(aScreen.getDevice()).chooseGraphicsConfiguration(
-                capsRequested, capsRequested, capabilitiesChooser, aScreen);
-        if (config == null) {
+        final AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen();
+        final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(aScreen.getDevice()).chooseGraphicsConfiguration(
+                                                         capsRequested, capsRequested, capabilitiesChooser, aScreen);
+        if (null == cfg) {
             throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
         }
+        setGraphicsConfiguration(cfg);
 
         synchronized(OffscreenWindow.class) {
             setWindowHandle(nextWindowHandle++);
@@ -70,6 +68,10 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable {
         // nop
     }
 
+    public void surfaceSizeChanged(int width, int height) {
+         sizeChanged(false, width, height, false);
+    }
+    
     @Override
     public synchronized void destroy() {
         super.destroy();
@@ -89,29 +91,30 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable {
     }
 
     @Override
-    public void setSize(int width, int height) {
-        if(!isVisible()) {
-            sizeChanged(false, width, height, false);
-        }
-    }
-    @Override
     public void setPosition(int x, int y) {
         // nop
     }
+    
     @Override
     public boolean setFullscreen(boolean fullscreen) {
         // nop
         return false;
     }
-    
+
     protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) {
         if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) {
             sizeChanged(false, width, height, false);
-            visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags));            
+            visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags));
         } else {
-            shouldNotCallThis();
+            /**
+             * silently ignore:
+                FLAG_CHANGE_PARENTING
+                FLAG_CHANGE_DECORATION
+                FLAG_CHANGE_FULLSCREEN
+                FLAG_CHANGE_ALWAYSONTOP
+             */
         }
-        return false;
+        return true;
     }
 
     @Override
diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java
index 749bba1..6ea9aff 100644
--- a/src/newt/classes/jogamp/newt/ScreenImpl.java
+++ b/src/newt/classes/jogamp/newt/ScreenImpl.java
@@ -68,7 +68,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
     long t0; // creationTime
 
     static {
-        AccessController.doPrivileged(new PrivilegedAction() {
+        AccessController.doPrivileged(new PrivilegedAction<Object>() {
             public Object run() {
                 registerShutdownHook();
                 return null;
@@ -76,6 +76,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
         });
     }
     
+    @SuppressWarnings("unchecked")
     private static Class<? extends Screen> getScreenClass(String type) throws ClassNotFoundException 
     {
         Class<?> screenClass = NewtFactory.getCustomClass(type, "Screen");
@@ -207,6 +208,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
     public synchronized final int addReference() throws NativeWindowException {
         if(DEBUG) {
             System.err.println("Screen.addReference() ("+DisplayImpl.getThreadName()+"): "+refCount+" -> "+(refCount+1));
+            // Thread.dumpStack();
         }
         if ( 0 == refCount ) {
             createNative();
@@ -219,10 +221,8 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
 
     public synchronized final int removeReference() {
         if(DEBUG) {
-            String msg = "Screen.removeReference() ("+DisplayImpl.getThreadName()+"): "+refCount+" -> "+(refCount-1);
-            // Throwable t = new Throwable(msg);
-            // t.printStackTrace();
-            System.err.println(msg);
+            System.err.println("Screen.removeReference() ("+DisplayImpl.getThreadName()+"): "+refCount+" -> "+(refCount-1));
+            // Thread.dumpStack();
         }
         refCount--; // could become < 0, in case of manual destruction without actual creation/addReference
         if(0>=refCount) {
@@ -307,22 +307,23 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
     public ScreenMode getCurrentScreenMode() {
         ScreenMode smU = null;
         ScreenModeStatus sms = ScreenModeStatus.getScreenModeStatus(this.getFQName());
-        if(null != sms) {
-            ScreenMode sm0 = ( DEBUG_TEST_SCREENMODE_DISABLED ) ? null : getCurrentScreenModeImpl();
-            if(null == sm0) {
-                return null;
-            }
-            sms.lock();
-            try {
-                smU = sms.getScreenModes().getOrAdd(sm0); // unified instance, maybe new
+        if(null == sms) {
+            throw new InternalError("ScreenModeStatus.getScreenModeStatus("+this.getFQName()+") == null");            
+        }
+        ScreenMode sm0 = getCurrentScreenModeIntern();
+        if(null == sm0) {
+            throw new InternalError("getCurrentScreenModeImpl() == null");
+        }
+        sms.lock();
+        try {
+            smU = sms.getScreenModes().getOrAdd(sm0); // unified instance, maybe new
 
-                // if mode has changed somehow, update it ..
-                if( sms.getCurrentScreenMode().hashCode() != smU.hashCode() ) {
-                    sms.fireScreenModeChanged(smU, true);
-                }
-            } finally {
-                sms.unlock();
+            // if mode has changed somehow, update it ..
+            if( sms.getCurrentScreenMode().hashCode() != smU.hashCode() ) {
+                sms.fireScreenModeChanged(smU, true);
             }
+        } finally {
+            sms.unlock();
         }
         return smU;
     }
@@ -337,46 +338,46 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
             return true;
         }
         ScreenModeStatus sms = ScreenModeStatus.getScreenModeStatus(this.getFQName());
-        if(null!=sms) {
-            sms.lock();
-            try {
-                long t0=0, t1=0;
-                if(DEBUG) {
-                    System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): 0.0 "+screenMode);
-                    t0 = System.currentTimeMillis();
-                }                
-
-                sms.fireScreenModeChangeNotify(smU);
+        if(null == sms) {
+            throw new InternalError("ScreenModeStatus.getScreenModeStatus("+this.getFQName()+") == null");            
+        }
+        boolean success;
+        sms.lock();
+        try {
+            long t0=0, t1=0;
+            if(DEBUG) {
+                System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): 0.0 "+smU);
+                t0 = System.currentTimeMillis();
+            }                
 
-                if(DEBUG) {
-                    System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): 0.1 "+screenMode);
-                    t1 = System.currentTimeMillis();
-                }
+            sms.fireScreenModeChangeNotify(smU);
 
-                boolean success = setCurrentScreenModeImpl(smU);                    
-                if(success) {
-                    setScreenSize(screenMode.getRotatedWidth(), screenMode.getRotatedHeight());
-                }
-                
-                if(DEBUG) {
-                    t1 = System.currentTimeMillis() - t1;
-                    System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): X.0 "+screenMode+", success: "+success);
-                }
+            if(DEBUG) {
+                System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): 0.1 "+smU);
+                t1 = System.currentTimeMillis();
+            }
 
-                sms.fireScreenModeChanged(smU, success);
-                                
-                if(DEBUG) {
-                    t0 = System.currentTimeMillis() - t0;
-                    System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): X.X "+screenMode+", success: "+success+
-                                       " - dt0 "+t0+"ms, dt1 "+t1+"ms");
-                }
+            success = setCurrentScreenModeImpl(smU);                    
+            if(success) {
+                setScreenSize(smU.getRotatedWidth(), smU.getRotatedHeight());
+            }
+            
+            if(DEBUG) {
+                t1 = System.currentTimeMillis() - t1;
+                System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): X.0 "+smU+", success: "+success);
+            }
 
-                return success;
-            } finally {
-                sms.unlock();
+            sms.fireScreenModeChanged(smU, success);
+                            
+            if(DEBUG) {
+                t0 = System.currentTimeMillis() - t0;
+                System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): X.X "+smU+", success: "+success+
+                                   " - dt0 "+t0+"ms, dt1 "+t1+"ms");
             }
+        } finally {
+            sms.unlock();
         }
-        return false;
+        return success;
     }
 
     public void screenModeChangeNotify(ScreenMode sm) {
@@ -455,6 +456,29 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
     protected ScreenMode getCurrentScreenModeImpl() {
         return null;
     }
+    
+    /**
+     * Utilizes {@link #getCurrentScreenModeImpl()}, if the latter returns null it uses
+     * the current screen size and dummy values.
+     */
+    protected ScreenMode getCurrentScreenModeIntern() {
+        ScreenMode res = getCurrentScreenModeImpl();
+        if(null == res) {
+            int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL];
+            int i = 0;
+            props[i++] = 0; // set later for verification of iterator
+            props[i++] = getWidth();  // width
+            props[i++] = getHeight(); // height
+            props[i++] = 32;   // bpp
+            props[i++] = 519;  // widthmm
+            props[i++] = 324;  // heightmm
+            props[i++] = 60;   // rate
+            props[i++] = 0;    // rot
+            props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i; // count
+            res = ScreenModeUtil.streamIn(props, 0);
+        }
+        return res;
+    }
 
     /**
      * To be implemented by the native specification.<br>
@@ -471,30 +495,25 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
             sms = ScreenModeStatus.getScreenModeStatus(this.getFQName());
             if(null==sms) {                
                 IntIntHashMap screenModesIdx2NativeIdx = new IntIntHashMap();
+                final ScreenMode currentSM = getCurrentScreenModeIntern();
+                if(null == currentSM) {
+                    throw new InternalError("getCurrentScreenModeImpl() == null");
+                }
 
                 ArrayHashSet<ScreenMode> screenModes = collectNativeScreenModes(screenModesIdx2NativeIdx);
                 if(screenModes.size()==0) {
-                    ScreenMode sm0 = ( DEBUG_TEST_SCREENMODE_DISABLED ) ? null : getCurrentScreenModeImpl();
-                    if(null != sm0) {
-                        if(DEBUG) {
-                            System.err.println("ScreenImpl.initScreenModeStatus: added current (last resort, collect failed): "+sm0);
-                        }
-                        screenModes.getOrAdd(sm0);
-                    } else if(DEBUG) {
-                        System.err.println("ScreenImpl.initScreenModeStatus: Warning: No screen modes added!");
+                    if(DEBUG) {
+                        System.err.println("ScreenImpl.initScreenModeStatus: added current (last resort, collect failed): "+currentSM);
                     }
+                    screenModes.getOrAdd(currentSM);
                 }
+                
                 sms = new ScreenModeStatus(screenModes, screenModesIdx2NativeIdx);
-                if(screenModes.size()>0) {
-                    ScreenMode originalScreenMode = ( DEBUG_TEST_SCREENMODE_DISABLED ) ? null : getCurrentScreenModeImpl();
-                    if(null != originalScreenMode) {
-                        ScreenMode originalScreenMode0 = screenModes.get(originalScreenMode); // unify via value hash
-                        if(null == originalScreenMode0) {
-                            throw new RuntimeException(originalScreenMode+" could not be hashed from ScreenMode list");
-                        }
-                        sms.setOriginalScreenMode(originalScreenMode0);
-                    }
+                ScreenMode originalScreenMode0 = screenModes.get(currentSM); // unify via value hash
+                if(null == originalScreenMode0) {
+                    throw new RuntimeException(currentSM+" could not be hashed from ScreenMode list");
                 }
+                sms.setOriginalScreenMode(originalScreenMode0);
                 ScreenModeStatus.mapScreenModeStatus(this.getFQName(), sms);
             }
         } finally {
@@ -557,8 +576,14 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
                 sms.lock();
                 try {
                     if(0 == sms.removeListener(this)) {
-                        if(!sms.isOriginalMode()) {
-                            setCurrentScreenMode(sms.getOriginalScreenMode());
+                        if(sms.isOriginalModeChangedByOwner()) {
+                            System.err.println("Screen.destroy(): "+sms.getCurrentScreenMode()+" -> "+sms.getOriginalScreenMode());
+                            try {
+                                setCurrentScreenMode(sms.getOriginalScreenMode());
+                            } catch (Throwable t) {
+                                // be verbose but continue
+                                t.printStackTrace();
+                            }
                         }
                         ScreenModeStatus.unmapScreenModeStatus(getFQName());
                     }
@@ -574,8 +599,9 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
     private final void shutdown() {
         ScreenModeStatus sms = ScreenModeStatus.getScreenModeStatusUnlocked(getFQName());
         if(null != sms) {
-            if(!sms.isOriginalMode()) {
+            if(sms.isOriginalModeChangedByOwner()) {
                 try {
+                    System.err.println("Screen.shutdown(): "+sms.getCurrentScreenMode()+" -> "+sms.getOriginalScreenMode());
                     setCurrentScreenModeImpl(sms.getOriginalScreenMode());
                 } catch (Throwable t) {
                     // be quiet .. shutdown
@@ -596,7 +622,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
                 ScreenImpl.shutdownAll();
             }
         });
-        AccessController.doPrivileged(new PrivilegedAction() {
+        AccessController.doPrivileged(new PrivilegedAction<Object>() {
             public Object run() {
                 Runtime.getRuntime().addShutdownHook(shutdownHook);
                 return null;
diff --git a/src/newt/classes/jogamp/newt/ScreenModeStatus.java b/src/newt/classes/jogamp/newt/ScreenModeStatus.java
index be87ce0..4075fb1 100644
--- a/src/newt/classes/jogamp/newt/ScreenModeStatus.java
+++ b/src/newt/classes/jogamp/newt/ScreenModeStatus.java
@@ -47,6 +47,7 @@ public class ScreenModeStatus {
     private IntIntHashMap screenModesIdx2NativeIdx;
     private ScreenMode currentScreenMode;
     private ScreenMode originalScreenMode;
+    private boolean screenModeChangedByOwner; 
     private ArrayList<ScreenModeListener> listener = new ArrayList<ScreenModeListener>();
 
     private static HashMap<String, ScreenModeStatus> screenFQN2ScreenModeStatus = new HashMap<String, ScreenModeStatus>();
@@ -111,6 +112,7 @@ public class ScreenModeStatus {
                             IntIntHashMap screenModesIdx2NativeIdx) {
         this.screenModes = screenModes;
         this.screenModesIdx2NativeIdx = screenModesIdx2NativeIdx;
+        this.screenModeChangedByOwner = false;
     }
 
     protected final void setOriginalScreenMode(ScreenMode originalScreenMode) {
@@ -131,18 +133,32 @@ public class ScreenModeStatus {
         }
     }
 
-    public final boolean isOriginalMode() {
+    /**
+     * We cannot guarantee that we won't interfere w/ another running
+     * application's screen mode change.
+     * <p>
+     * At least we only return <code>true</true> if the owner, ie. the Screen,
+     * has changed the screen mode and if the original screen mode 
+     * is not current the current one.
+     * </p>
+     * @return
+     */
+    public final boolean isOriginalModeChangedByOwner() {
         lock();
         try {
-            if(null != currentScreenMode && null != originalScreenMode) {
-                return currentScreenMode.hashCode() == originalScreenMode.hashCode();
-            }
-            return true;
+            return screenModeChangedByOwner && !isCurrentModeOriginalMode();
         } finally {
             unlock();
         }
     }
 
+    protected final boolean isCurrentModeOriginalMode() {
+        if(null != currentScreenMode && null != originalScreenMode) {
+            return currentScreenMode.hashCode() == originalScreenMode.hashCode();
+        }
+        return true;
+    }
+    
     protected final ArrayHashSet<ScreenMode> getScreenModes() {
         return screenModes;
     }
@@ -195,6 +211,7 @@ public class ScreenModeStatus {
         try {
             if(success) {
                 this.currentScreenMode = currentScreenMode;
+                this.screenModeChangedByOwner = !isCurrentModeOriginalMode();
             }
             for(int i=0; i<listener.size(); i++) {
                 listener.get(i).screenModeChanged(currentScreenMode, success);
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 0091144..a8e93d4 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -45,6 +45,7 @@ import com.jogamp.newt.Window;
 import com.jogamp.common.util.locks.LockFactory;
 import com.jogamp.common.util.locks.RecursiveLock;
 import com.jogamp.newt.ScreenMode;
+import com.jogamp.newt.event.InputEvent;
 import com.jogamp.newt.event.KeyEvent;
 import com.jogamp.newt.event.KeyListener;
 import com.jogamp.newt.event.MouseEvent;
@@ -71,6 +72,8 @@ import javax.media.nativewindow.util.InsetsImmutable;
 import javax.media.nativewindow.util.Point;
 import javax.media.nativewindow.util.Rectangle;
 
+import jogamp.nativewindow.SurfaceUpdatedHelper;
+
 public abstract class WindowImpl implements Window, NEWTEventConsumer
 {
     public static final boolean DEBUG_TEST_REPARENT_INCOMPATIBLE = Debug.isPropertyDefined("newt.test.Window.reparent.incompatible", true);
@@ -84,7 +87,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
     private boolean screenReferenceAdded = false;
     private NativeWindow parentWindow = null;
     private long parentWindowHandle = 0;
-    protected AbstractGraphicsConfiguration config = null;
+    private AbstractGraphicsConfiguration config = null; // control access due to delegation
     protected CapabilitiesImmutable capsRequested = null;
     protected CapabilitiesChooser capabilitiesChooser = null; // default null -> default
     protected boolean fullscreen = false, hasFocus = false;    
@@ -96,6 +99,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
     protected String title = "Newt Window";
     protected boolean undecorated = false;
     protected boolean alwaysOnTop = false;
+    private boolean pointerVisible = true;
+    private boolean pointerConfined = false;
     private LifecycleHook lifecycleHook = null;
 
     private DestroyAction destroyAction = new DestroyAction();
@@ -105,10 +110,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
 
     private RequestFocusAction requestFocusAction = new RequestFocusAction();
     private FocusRunnable focusAction = null;
+    private KeyListener keyboardFocusHandler = null;
 
-    private Object surfaceUpdatedListenersLock = new Object();
-    private ArrayList<SurfaceUpdatedListener> surfaceUpdatedListeners = new ArrayList<SurfaceUpdatedListener>();
-
+    private SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper();
+    
     private Object childWindowsLock = new Object();
     private ArrayList<NativeWindow> childWindows = new ArrayList<NativeWindow>();
 
@@ -116,6 +121,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
     private int  mouseButtonPressed = 0;  // current pressed mouse button number
     private long lastMousePressed = 0;    // last time when a mouse button was pressed
     private int  lastMouseClickCount = 0; // last mouse button click count
+    protected boolean mouseInWindow = false;// mouse entered window - is inside the window (may be synthetic)
+    protected Point lastMousePosition = new Point();
 
     private ArrayList<KeyListener> keyListeners = new ArrayList<KeyListener>();
 
@@ -208,6 +215,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
         }
     }
 
+    protected final void setGraphicsConfiguration(AbstractGraphicsConfiguration cfg) {
+        config = cfg;
+    }
+    
     public static interface LifecycleHook {
         /**
          * Reset of internal state counter, ie totalFrames, etc.
@@ -280,6 +291,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
                     createNativeImpl();
                     screen.addScreenModeListener(screenModeListenerImpl);
                     setTitleImpl(title);
+                    setPointerVisibleImpl(pointerVisible);
+                    confinePointerImpl(pointerConfined);
                     if(waitForVisible(true, false)) {
                         if(isFullscreen()) {
                             fullscreen = false;
@@ -522,6 +535,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
      */
     protected abstract void updateInsetsImpl(Insets insets);
 
+    protected boolean setPointerVisibleImpl(boolean pointerVisible) { return false; }
+    protected boolean confinePointerImpl(boolean confine) { return false; }
+    protected void warpPointerImpl(int x, int y) { }
+    
     //----------------------------------------------------------------------
     // NativeSurface
     //
@@ -534,7 +551,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
         if ( LOCK_SURFACE_NOT_READY == res ) {
             try {
                 if( isNativeValid() ) {
-                    final AbstractGraphicsDevice adevice = config.getScreen().getDevice();
+                    final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice();
                     adevice.lock();
                     try {
                         res = lockSurfaceImpl();
@@ -559,7 +576,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
         windowLock.validateLocked();
 
         if (surfaceLock.getHoldCount() == 1) {
-            final AbstractGraphicsDevice adevice = config.getScreen().getDevice();
+            final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice();
             try {
                 unlockSurfaceImpl();
             } finally {
@@ -602,8 +619,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
         return false;
     }
 
-    public AbstractGraphicsConfiguration getGraphicsConfiguration() {
-        return config;
+    public final AbstractGraphicsConfiguration getGraphicsConfiguration() {
+        return config.getNativeGraphicsConfiguration();
     }
 
     public final long getDisplayHandle() {
@@ -671,6 +688,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
         return screen;
     }
 
+    protected final void setVisibleImpl(boolean visible, int x, int y, int width, int height) {
+        reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_VISIBILITY, visible));           
+    }    
     final void setVisibleActionImpl(boolean visible) {
         boolean nativeWindowCreated = false;
         boolean madeVisible = false;
@@ -729,8 +749,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
         if( nativeWindowCreated || madeVisible ) {
             sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout and repaint to listener
         }        
-    }
-    
+    }    
     private class VisibleAction implements Runnable {
         boolean visible;
 
@@ -741,8 +760,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
         public final void run() {
             setVisibleActionImpl(visible);
         }
-    }
-
+    }    
     public void setVisible(boolean visible) {
         if(DEBUG_IMPLEMENTATION) {
             System.err.println("Window setVisible: START ("+getThreadName()+") "+x+"/"+y+" "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+this.visible+" -> "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+(null!=parentWindow));
@@ -751,59 +769,67 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
         runOnEDTIfAvail(true, new VisibleAction(visible));
     }
     
-    protected final void setVisibleImpl(boolean visible, int x, int y, int width, int height) {
-        reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_VISIBILITY, visible));           
+    final void setSizeActionImpl(int width, int height) {
+        boolean recreate = false;
+        windowLock.lock();
+        try {
+            int visibleAction = 0; // 1 invisible, 2 visible (create)
+            if ( !fullscreen && ( width != WindowImpl.this.width || WindowImpl.this.height != height ) ) {
+                recreate = isNativeValid() && !getGraphicsConfiguration().getChosenCapabilities().isOnscreen();
+                if(DEBUG_IMPLEMENTATION) {
+                    System.err.println("Window setSize: START "+WindowImpl.this.width+"x"+WindowImpl.this.height+" -> "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible "+visible+", recreate "+recreate);
+                }
+                if(recreate) {
+                    // will trigger visibleAction:=2 -> create if wasVisible
+                    final boolean wasVisible = WindowImpl.this.visible;
+                    screen.addReference(); // retain screen            
+                    destroyAction.run();
+                    WindowImpl.this.visible = wasVisible;
+                }                
+                if ( isNativeValid() && 0>=width*height && visible ) {
+                    visibleAction=1; // invisible
+                    WindowImpl.this.width = 0;
+                    WindowImpl.this.height = 0;
+                } else if ( !isNativeValid() && 0<width*height && visible ) {
+                    visibleAction = 2; // visible (create)
+                    WindowImpl.this.width = width;
+                    WindowImpl.this.height = height;
+                } else if ( isNativeValid() ) {
+                    // this width/height will be set by windowChanged, called by the native implementation
+                    reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(0, isVisible()));
+                } else {
+                    WindowImpl.this.width = width;
+                    WindowImpl.this.height = height;
+                }
+                if(DEBUG_IMPLEMENTATION) {
+                    System.err.println("Window setSize: END "+WindowImpl.this.width+"x"+WindowImpl.this.height+", visibleAction "+visibleAction);
+                }                    
+                switch(visibleAction) {
+                    case 1: setVisibleActionImpl(false); break;
+                    case 2: setVisibleActionImpl(true); break;
+                }
+            }
+        } finally {
+            if(recreate) {
+                screen.removeReference(); // bring back ref-count
+            }
+            windowLock.unlock();
+        }        
     }
-    
-    private class SetSizeActionImpl implements Runnable {
+    private class SetSizeAction implements Runnable {
         int width, height;
 
-        private SetSizeActionImpl(int w, int h) {
+        private SetSizeAction(int w, int h) {
             width = w;
             height = h;
         }
         public final void run() {
-            windowLock.lock();
-            try {
-                int visibleAction = 0; // 1 invisible, 2 visible (create)
-                if ( !fullscreen && ( width != WindowImpl.this.width || WindowImpl.this.height != height ) ) {
-                    if(DEBUG_IMPLEMENTATION) {
-                        String msg = "Window setSize: START "+WindowImpl.this.width+"x"+WindowImpl.this.height+" -> "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible "+visible;
-                        System.err.println(msg);
-                    }
-                    if ( isNativeValid() && 0>=width*height && visible ) {
-                        visibleAction=1; // invisible
-                        WindowImpl.this.width = 0;
-                        WindowImpl.this.height = 0;
-                    } else if ( !isNativeValid() && 0<width*height && visible ) {
-                        visibleAction = 2; // visible (create)
-                        WindowImpl.this.width = width;
-                        WindowImpl.this.height = height;
-                    } else if ( isNativeValid() ) {
-                        // this width/height will be set by windowChanged, called by the native implementation
-                        reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(0, isVisible()));
-                    } else {
-                        WindowImpl.this.width = width;
-                        WindowImpl.this.height = height;
-                    }
-                    if(DEBUG_IMPLEMENTATION) {
-                        System.err.println("Window setSize: END "+WindowImpl.this.width+"x"+WindowImpl.this.height+", visibleAction "+visibleAction);
-                    }                    
-                    switch(visibleAction) {
-                        case 1: setVisibleActionImpl(false); break;
-                        case 2: setVisibleActionImpl(true); break;
-                    }
-                }
-            } finally {
-                windowLock.unlock();
-            }
+            setSizeActionImpl(width, height);
         }
-    }
-
+    }    
     public void setSize(int width, int height) {
-        runOnEDTIfAvail(true, new SetSizeActionImpl(width, height));
-    }
-    
+        runOnEDTIfAvail(true, new SetSizeAction(width, height));
+    }    
     public void setTopLevelSize(int width, int height) {
         setSize(width - getInsets().getTotalWidth(), height - getInsets().getTotalHeight());
     }
@@ -900,6 +926,22 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
         runOnEDTIfAvail(true, destroyAction);
     }
 
+    /**
+     * @param cWin child window, must not be null
+     * @param pWin parent window, may be null
+     * @return true if at least one of both window's configurations is offscreen 
+     */
+    protected static boolean isOffscreenInstance(NativeWindow cWin, NativeWindow pWin) {
+        boolean ofs = false;
+        if( null != cWin.getGraphicsConfiguration() ) {
+            ofs = !cWin.getGraphicsConfiguration().getChosenCapabilities().isOnscreen();
+        }
+        if( !ofs && null != pWin && null != pWin.getGraphicsConfiguration() ) {
+            ofs |= !pWin.getGraphicsConfiguration().getChosenCapabilities().isOnscreen();
+        }
+        return ofs;
+    }
+    
     private class ReparentActionImpl implements Runnable, ReparentAction {
         NativeWindow newParentWindow;
         boolean forceDestroyCreate;
@@ -907,7 +949,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
 
         private ReparentActionImpl(NativeWindow newParentWindow, boolean forceDestroyCreate) {
             this.newParentWindow = newParentWindow;
-            this.forceDestroyCreate = forceDestroyCreate;
+            this.forceDestroyCreate = forceDestroyCreate | DEBUG_TEST_REPARENT_INCOMPATIBLE;
             this.reparentAction = -1; // ensure it's set
         }
 
@@ -916,10 +958,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
         }
 
         private void setScreen(ScreenImpl newScreen) { // never null !
-            WindowImpl.this.removeScreenReference();
+            removeScreenReference();
             screen = newScreen;
         }
-
+        
         public final void run() {
             boolean animatorPaused = false;
             if(null!=lifecycleHook) {
@@ -941,6 +983,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
 
             windowLock.lock();
             try {
+                if(isNativeValid()) {
+                    // force recreation if offscreen, since it may become onscreen
+                    forceDestroyCreate |= isOffscreenInstance(WindowImpl.this, newParentWindow);
+                }
+                                
                 wasVisible = isVisible();
 
                 Window newParentWindowNEWT = null;
@@ -951,7 +998,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
                 long newParentWindowHandle = 0 ;
 
                 if(DEBUG_IMPLEMENTATION) {
-                    System.err.println("Window.reparent: START ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)+", visible "+wasVisible+", old parentWindow: "+Display.hashCodeNullSafe(parentWindow)+", new parentWindow: "+Display.hashCodeNullSafe(newParentWindow)+", forceDestroyCreate "+forceDestroyCreate+", DEBUG_TEST_REPARENT_INCOMPATIBLE "+DEBUG_TEST_REPARENT_INCOMPATIBLE+" "+x+"/"+y+" "+width+"x"+height);
+                    System.err.println("Window.reparent: START ("+getThreadName()+") valid "+isNativeValid()+", windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)+", visible "+wasVisible+", old parentWindow: "+Display.hashCodeNullSafe(parentWindow)+", new parentWindow: "+Display.hashCodeNullSafe(newParentWindow)+", forceDestroyCreate "+forceDestroyCreate+", "+x+"/"+y+" "+width+"x"+height);
                 }
 
                 if(null!=lifecycleHook) {
@@ -1002,8 +1049,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
                             } else {
                                 reparentAction = ACTION_NATIVE_CREATION_PENDING;
                             }
-                        } else if ( DEBUG_TEST_REPARENT_INCOMPATIBLE || forceDestroyCreate ||
-                                    !NewtFactory.isScreenCompatible(newParentWindow, getScreen()) ) {
+                        } else if ( forceDestroyCreate || !NewtFactory.isScreenCompatible(newParentWindow, getScreen()) ) {
                             // Destroy this window, may create a new compatible Screen/Display,
                             // and mark it for creation.
                             destroy();
@@ -1034,7 +1080,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
                     if( 0 == parentWindowHandle ) {
                         // Already Top Window
                         reparentAction = ACTION_UNCHANGED;
-                    } else if( !isNativeValid() || DEBUG_TEST_REPARENT_INCOMPATIBLE || forceDestroyCreate ) {
+                    } else if( !isNativeValid() || forceDestroyCreate ) {
                         // Destroy this window and mark it for [pending] creation.
                         destroy();
                         if( 0<width*height ) {
@@ -1127,7 +1173,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
                                 ok = WindowImpl.this.waitForSize(width, height, false, TIMEOUT_NATIVEWINDOW);
                             }
                             if(ok) {
-                                requestFocusImpl(true);
+                                requestFocusInt(true);
                                 display.dispatchMessagesNative(); // status up2date                                
                             }
                         }
@@ -1197,7 +1243,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
     }
 
     public int reparentWindow(NativeWindow newParent, boolean forceDestroyCreate) {
-        ReparentActionImpl reparentAction = new ReparentActionImpl(newParent, forceDestroyCreate);
+        final ReparentActionImpl reparentAction = new ReparentActionImpl(newParent, forceDestroyCreate);
         runOnEDTIfAvail(true, reparentAction);
         return reparentAction.getStrategy();
     }
@@ -1209,27 +1255,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
     }
 
     public final CapabilitiesImmutable getChosenCapabilities() {
-        return config.getNativeGraphicsConfiguration().getChosenCapabilities();
+        return getGraphicsConfiguration().getChosenCapabilities();
     }
 
     public final CapabilitiesImmutable getRequestedCapabilities() {
         return capsRequested;
     }
 
-    public String getTitle() {
-        return title;
-    }
-
-    public void setTitle(String title) {
-        if (title == null) {
-            title = "";
-        }
-        this.title = title;
-        if(0 != getWindowHandle()) {
-            setTitleImpl(title);
-        }
-    }
-
     private class DecorationActionImpl implements Runnable {
         boolean undecorated;
 
@@ -1328,14 +1360,66 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
         return alwaysOnTop || fullscreen ;
     }
         
-    public void requestFocus() {
-        enqueueRequestFocus(true);
+    public String getTitle() {
+        return title;
     }
-
-    public final boolean hasFocus() {
-        return hasFocus;
+    public void setTitle(String title) {
+        if (title == null) {
+            title = "";
+        }
+        this.title = title;
+        if(0 != getWindowHandle()) {
+            setTitleImpl(title);
+        }
     }
 
+    public boolean isPointerVisible() {
+        return pointerVisible;
+    }
+    public void setPointerVisible(boolean pointerVisible) {
+        if(this.pointerVisible != pointerVisible) {
+            boolean setVal = 0 == getWindowHandle();
+            if(!setVal) {
+                setVal = setPointerVisibleImpl(pointerVisible);
+            }
+            if(setVal) {
+                this.pointerVisible = pointerVisible;                
+            }
+        }
+    }
+    public boolean isPointerConfined() {
+        return pointerConfined;
+    }
+    
+    public void confinePointer(boolean confine) {
+        if(this.pointerConfined != confine) {
+            boolean setVal = 0 == getWindowHandle();
+            if(!setVal) {
+                if(confine) {
+                    requestFocus();
+                    warpPointer(width/2, height/2);
+                }
+                setVal = confinePointerImpl(confine);
+                if(confine) {
+                    // give time to deliver mouse movements w/o confinement,
+                    // this allows user listener to sync previous position value to the new centered position
+                    try {
+                        Thread.sleep(3 * screen.getDisplay().getEDTUtil().getPollPeriod());
+                    } catch (InterruptedException e) { }
+                }
+            }
+            if(setVal) {
+                this.pointerConfined = confine;       
+            }
+        }        
+    }
+    
+    public void warpPointer(int x, int y) {
+        if(0 != getWindowHandle()) {
+            warpPointerImpl(x, y);
+        }
+    }
+    
     public final InsetsImmutable getInsets() {
         if(isUndecorated()) {
             return Insets.getZero();
@@ -1368,7 +1452,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
         return fullscreen;
     }
 
-
     //----------------------------------------------------------------------
     // Window
     //
@@ -1396,7 +1479,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
     public Object getWrappedWindow() {
         return null;
     }
-
+    
+    public final Window getDelegatedWindow() {
+        return this;
+    }
+    
     /**
      * If set to true, the default value, this NEWT Window implementation will
      * handle the destruction (ie {@link #destroy()} call) within {@link #windowDestroyNotify()} implementation.<br>
@@ -1410,6 +1497,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
     // WindowImpl
     //
 
+    /** 
+     * Returns the non delegated {@link AbstractGraphicsConfiguration}, 
+     * see {@link #getGraphicsConfiguration()}. */
+    public final AbstractGraphicsConfiguration getPrivateGraphicsConfiguration() {
+        return config;
+    }
+    
     protected final long getParentWindowHandle() {
         return isFullscreen() ? 0 : parentWindowHandle;
     }
@@ -1431,9 +1525,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
                     "\n, WrappedWindow "+getWrappedWindow()+
                     "\n, ChildWindows "+childWindows.size());
 
-        sb.append(", SurfaceUpdatedListeners num "+surfaceUpdatedListeners.size()+" [");
-        for (int i = 0; i < surfaceUpdatedListeners.size(); i++ ) {
-          sb.append(surfaceUpdatedListeners.get(i)+", ");
+        sb.append(", SurfaceUpdatedListeners num "+surfaceUpdatedHelper.size()+" [");
+        for (int i = 0; i < surfaceUpdatedHelper.size(); i++ ) {
+          sb.append(surfaceUpdatedHelper.get(i)+", ");
         }
         sb.append("], WindowListeners num "+windowListeners.size()+" [");
         for (int i = 0; i < windowListeners.size(); i++ ) {
@@ -1473,21 +1567,32 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
         }
     }
 
-    protected void enqueueRequestFocus(boolean wait) {
-        runOnEDTIfAvail(wait, requestFocusAction);
+    public final boolean hasFocus() {
+        return hasFocus;
     }
 
-    /** 
-     * May set to a {@link FocusRunnable}, {@link FocusRunnable#run()} before Newt requests the native focus.
-     * This allows notifying a covered window toolkit like AWT that the focus is requested,
-     * hence focus traversal can be made transparent.
-     */
+    public void requestFocus() {
+        requestFocus(true);
+    }
+
+    public void requestFocus(boolean wait) {
+        if(isNativeValid() && !focusAction()) {
+            runOnEDTIfAvail(wait, requestFocusAction);
+        }
+    }
+    
+    /** Internal request focus on current thread */
+    private void requestFocusInt(boolean force) {
+        if(!focusAction()) {
+            requestFocusImpl(force);
+        }        
+    }
+    
     public void setFocusAction(FocusRunnable focusAction) {
         this.focusAction = focusAction;
     }
-
-    /** Called by native requestFocusImpl() */
-    protected boolean focusAction() {
+    
+    private boolean focusAction() {
         if(DEBUG_IMPLEMENTATION) {
             System.err.println("Window.focusAction() START - "+getThreadName()+", focusAction: "+focusAction+" - windowHandle "+toHexString(getWindowHandle()));
         }
@@ -1502,7 +1607,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
         }
         return res;
     }
-
+    
+    public void setKeyboardFocusHandler(KeyListener l) {
+        keyboardFocusHandler = l;
+    }
+    
     private class SetPositionActionImpl implements Runnable {
         int x, y;
 
@@ -1624,7 +1733,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
                         display.dispatchMessagesNative(); // status up2date                                                        
                         WindowImpl.this.waitForSize(w, h, false, TIMEOUT_NATIVEWINDOW);
                         display.dispatchMessagesNative(); // status up2date                                                        
-                        requestFocusImpl(true);
+                        requestFocusInt(true);
                         display.dispatchMessagesNative(); // status up2date
                         
                         if(DEBUG_IMPLEMENTATION) {
@@ -1744,8 +1853,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
                 // queue event in case window is locked, ie in operation
                 if( isWindowLocked() ) {
                     if(DEBUG_IMPLEMENTATION) {
-                        // System.err.println("Window.consumeEvent: queued "+e);
-                        // Thread.dumpStack(); // JAU
+                        System.err.println("Window.consumeEvent: queued "+e);
+                        // Thread.dumpStack();
                     }
                     return false;
                 }
@@ -1768,62 +1877,20 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
     //
     // SurfaceUpdatedListener Support
     //
-
     public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
-        addSurfaceUpdatedListener(-1, l);
+        surfaceUpdatedHelper.addSurfaceUpdatedListener(l);
     }
 
-    public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) 
-        throws IndexOutOfBoundsException
-    {
-        if(l == null) {
-            return;
-        }
-        synchronized(surfaceUpdatedListenersLock) {
-            if(0>index) { 
-                index = surfaceUpdatedListeners.size(); 
-            }
-            surfaceUpdatedListeners.add(index, l);
-        }
+    public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException {
+        surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l);
     }
 
     public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
-        if (l == null) {
-            return;
-        }
-        synchronized(surfaceUpdatedListenersLock) {
-            surfaceUpdatedListeners.remove(l);
-        }
-    }
-
-    public void removeAllSurfaceUpdatedListener() {
-        synchronized(surfaceUpdatedListenersLock) {
-            surfaceUpdatedListeners = new ArrayList<SurfaceUpdatedListener>();
-        }
-    }
-
-    public SurfaceUpdatedListener getSurfaceUpdatedListener(int index) {
-        synchronized(surfaceUpdatedListenersLock) {
-            if(0>index) { 
-                index = surfaceUpdatedListeners.size()-1; 
-            }
-            return surfaceUpdatedListeners.get(index);
-        }
-    }
-
-    public SurfaceUpdatedListener[] getSurfaceUpdatedListeners() {
-        synchronized(surfaceUpdatedListenersLock) {
-            return (SurfaceUpdatedListener[]) surfaceUpdatedListeners.toArray();
-        }
+        surfaceUpdatedHelper.removeSurfaceUpdatedListener(l);
     }
 
     public void surfaceUpdated(Object updater, NativeSurface ns, long when) {
-        synchronized(surfaceUpdatedListenersLock) {
-          for(int i = 0; i < surfaceUpdatedListeners.size(); i++ ) {
-            SurfaceUpdatedListener l = surfaceUpdatedListeners.get(i);
-            l.surfaceUpdated(updater, ns, when);
-          }
-        }
+        surfaceUpdatedHelper.surfaceUpdated(updater, ns, when);
     }
 
     //
@@ -1837,22 +1904,59 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
                                   int x, int y, int button, int rotation) {
         doMouseEvent(true, wait, eventType, modifiers, x, y, button, rotation);
     }
-    private void doMouseEvent(boolean enqueue, boolean wait, int eventType, int modifiers,
-                              int x, int y, int button, int rotation) {
+    
+    protected void doMouseEvent(boolean enqueue, boolean wait, int eventType, int modifiers,
+                                int x, int y, int button, int rotation) {
+        if(eventType == MouseEvent.EVENT_MOUSE_ENTERED ||            
+           eventType == MouseEvent.EVENT_MOUSE_EXITED) {
+            if(eventType == MouseEvent.EVENT_MOUSE_EXITED && x==-1 && y==-1) {
+                x = lastMousePosition.getX();
+                y = lastMousePosition.getY();
+            }
+            // clip coordinates to window dimension
+            x = Math.min(Math.max(x,  0), width-1);
+            y = Math.min(Math.max(y,  0), height-1);
+            mouseInWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED;
+        }
         if(x<0||y<0||x>=width||y>=height) {
             return; // .. invalid ..
         }
         if(DEBUG_MOUSE_EVENT) {
-            System.err.println("doMouseEvent: enqueue"+enqueue+", wait "+wait+", "+MouseEvent.getEventTypeString(eventType)+
-                               ", mod "+modifiers+", pos "+x+"/"+y+", button "+button);
+            System.err.println("doMouseEvent: enqueue "+enqueue+", wait "+wait+", "+MouseEvent.getEventTypeString(eventType)+
+                               ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+lastMousePosition);
+        }
+        long when = System.currentTimeMillis();
+        if(eventType == MouseEvent.EVENT_MOUSE_MOVED) {
+            if(!mouseInWindow) {
+                mouseInWindow = true;
+                MouseEvent e = new MouseEvent(MouseEvent.EVENT_MOUSE_ENTERED, this, when,
+                                              modifiers, x, y, lastMouseClickCount, button, 0);
+                if(DEBUG_MOUSE_EVENT) {
+                    System.err.println("doMouseEvent: synthesized MOUSE_ENTERED event: "+e);
+                }
+                doEvent(enqueue, wait, e);
+            } else if(lastMousePosition.getX() == x && lastMousePosition.getY()==y) { 
+                if(DEBUG_MOUSE_EVENT) {
+                    System.err.println("doMouseEvent: skip EVENT_MOUSE_MOVED w/ same position: "+lastMousePosition);
+                }
+                return; // skip same position
+            }
+            lastMousePosition.setX(x);
+            lastMousePosition.setY(y);
         }
         if(button<0||button>MouseEvent.BUTTON_NUMBER) {
             throw new NativeWindowException("Invalid mouse button number" + button);
         }
-        long when = System.currentTimeMillis();
         MouseEvent eClicked = null;
         MouseEvent e = null;
 
+        if(isPointerConfined()) {
+            modifiers |= InputEvent.CONFINED_MASK;
+        }
+        if(!isPointerVisible()) {
+            modifiers |= InputEvent.INVISIBLE_MASK;
+        }
+        
         if(MouseEvent.EVENT_MOUSE_PRESSED==eventType) {
             if(when-lastMousePressed<MouseEvent.getClickTimeout()) {
                 lastMouseClickCount++;
@@ -1890,7 +1994,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
         doEvent(enqueue, wait, e);
         if(null!=eClicked) {
             if(DEBUG_MOUSE_EVENT) {
-                System.err.println("doMouseEvent: synthesized MOUSE_CLICKED event");
+                System.err.println("doMouseEvent: synthesized MOUSE_CLICKED event: "+eClicked);
             }
             doEvent(enqueue, wait, eClicked);
         }
@@ -1934,15 +2038,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
     }
 
     public MouseListener[] getMouseListeners() {
-        return (MouseListener[]) mouseListeners.toArray();
+        return mouseListeners.toArray(new MouseListener[mouseListeners.size()]);
     }
 
     protected void consumeMouseEvent(MouseEvent e) {
         if(DEBUG_MOUSE_EVENT) {
             System.err.println("consumeMouseEvent: event:         "+e);
         }
-
-        for(int i = 0; i < mouseListeners.size(); i++ ) {
+        boolean consumed = false;
+        for(int i = 0; !consumed && i < mouseListeners.size(); i++ ) {
             MouseListener l = mouseListeners.get(i);
             switch(e.getEventType()) {
                 case MouseEvent.EVENT_MOUSE_CLICKED:
@@ -1972,13 +2076,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
                 default:
                     throw new NativeWindowException("Unexpected mouse event type " + e.getEventType());
             }
+            consumed = InputEvent.consumedTag == e.getAttachment();
         }
     }
 
     //
     // KeyListener/Event Support
     //
-
     public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) {
         consumeKeyEvent(new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers, keyCode, keyChar) );
     }
@@ -2024,28 +2128,41 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
     }
 
     public KeyListener[] getKeyListeners() {
-        return (KeyListener[]) keyListeners.toArray();
+        return keyListeners.toArray(new KeyListener[keyListeners.size()]);
     }
 
-    protected void consumeKeyEvent(KeyEvent e) {
-        if(DEBUG_KEY_EVENT) {
-            System.err.println("consumeKeyEvent: "+e);
+    private final boolean propagateKeyEvent(KeyEvent e, KeyListener l) {
+        switch(e.getEventType()) {
+            case KeyEvent.EVENT_KEY_PRESSED:
+                l.keyPressed(e);
+                break;
+            case KeyEvent.EVENT_KEY_RELEASED:
+                l.keyReleased(e);
+                break;
+            case KeyEvent.EVENT_KEY_TYPED:
+                l.keyTyped(e);
+                break;
+            default:
+                throw new NativeWindowException("Unexpected key event type " + e.getEventType());
         }
-        for(int i = 0; i < keyListeners.size(); i++ ) {
-            KeyListener l = keyListeners.get(i);
-            switch(e.getEventType()) {
-                case KeyEvent.EVENT_KEY_PRESSED:
-                    l.keyPressed(e);
-                    break;
-                case KeyEvent.EVENT_KEY_RELEASED:
-                    l.keyReleased(e);
-                    break;
-                case KeyEvent.EVENT_KEY_TYPED:
-                    l.keyTyped(e);
-                    break;
-                default:
-                    throw new NativeWindowException("Unexpected key event type " + e.getEventType());
+        return InputEvent.consumedTag == e.getAttachment();
+    }
+    
+    protected void consumeKeyEvent(KeyEvent e) {
+        boolean consumed;
+        if(null != keyboardFocusHandler) {
+            consumed = propagateKeyEvent(e, keyboardFocusHandler);
+            if(DEBUG_KEY_EVENT) {
+                System.err.println("consumeKeyEvent: "+e+", keyboardFocusHandler consumed: "+consumed);
             }
+        } else {
+            consumed = false;
+            if(DEBUG_KEY_EVENT) {
+                System.err.println("consumeKeyEvent: "+e);
+            }
+        }
+        for(int i = 0; !consumed && i < keyListeners.size(); i++ ) {
+            consumed = propagateKeyEvent(e, keyListeners.get(i));
         }
     }
 
@@ -2099,7 +2216,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
     }
 
     public WindowListener[] getWindowListeners() {
-        return (WindowListener[]) windowListeners.toArray();
+        return windowListeners.toArray(new WindowListener[windowListeners.size()]);
     }
 
     protected void consumeWindowEvent(WindowEvent e) {
@@ -2140,24 +2257,28 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
 
     /** Triggered by implementation's WM events to update the focus state. */
     protected void focusChanged(boolean defer, boolean focusGained) {
-        if(DEBUG_IMPLEMENTATION) {
-            System.err.println("Window.focusChanged: ("+getThreadName()+"): (defer: "+defer+") "+this.hasFocus+" -> "+focusGained+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle));
-        }
-        hasFocus = focusGained;
-        final int evt = focusGained ? WindowEvent.EVENT_WINDOW_GAINED_FOCUS : WindowEvent.EVENT_WINDOW_LOST_FOCUS ; 
-        if(!defer) {
-            sendWindowEvent(evt);
-        } else {
-            enqueueWindowEvent(false, evt);
+        if(hasFocus != focusGained) {
+            if(DEBUG_IMPLEMENTATION) {
+                System.err.println("Window.focusChanged: ("+getThreadName()+"): (defer: "+defer+") "+this.hasFocus+" -> "+focusGained+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle));
+            }
+            hasFocus = focusGained;
+            final int evt = focusGained ? WindowEvent.EVENT_WINDOW_GAINED_FOCUS : WindowEvent.EVENT_WINDOW_LOST_FOCUS ; 
+            if(!defer) {
+                sendWindowEvent(evt);
+            } else {
+                enqueueWindowEvent(false, evt);
+            }
         }
     }
 
     /** Triggered by implementation's WM events to update the visibility state. */
     protected void visibleChanged(boolean defer, boolean visible) {
-        if(DEBUG_IMPLEMENTATION) {
-            System.err.println("Window.visibleChanged ("+getThreadName()+"): (defer: "+defer+") "+this.visible+" -> "+visible+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle));
+        if(this.visible != visible) {
+            if(DEBUG_IMPLEMENTATION) {
+                System.err.println("Window.visibleChanged ("+getThreadName()+"): (defer: "+defer+") "+this.visible+" -> "+visible+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle));
+            }
+            this.visible = visible ;
         }
-        this.visible = visible ;
     }
 
     private boolean waitForVisible(boolean visible, boolean failFast) {
diff --git a/src/newt/classes/jogamp/newt/awt/event/NewtFactoryAWT.java b/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java
similarity index 69%
rename from src/newt/classes/jogamp/newt/awt/event/NewtFactoryAWT.java
rename to src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java
index aa98d3a..2ca3d2c 100644
--- a/src/newt/classes/jogamp/newt/awt/event/NewtFactoryAWT.java
+++ b/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java
@@ -26,15 +26,19 @@
  * or implied, of JogAmp Community.
  */
  
+package jogamp.newt.awt;
 
-package jogamp.newt.awt.event;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.CapabilitiesImmutable;
+import javax.media.nativewindow.NativeWindow;
+import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.nativewindow.awt.AWTGraphicsConfiguration;
 
-
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.awt.*;
+import jogamp.nativewindow.jawt.JAWTWindow;
+import jogamp.newt.Debug;
 
 import com.jogamp.newt.NewtFactory;
-import jogamp.newt.Debug;
 
 public class NewtFactoryAWT extends NewtFactory {
   public static final boolean DEBUG_IMPLEMENTATION = Debug.debug("Window");
@@ -51,7 +55,7 @@ public class NewtFactoryAWT extends NewtFactory {
    *
    * @param awtCompObject must be of type java.awt.Component
    */
-  public static NativeWindow getNativeWindow(Object awtCompObject, CapabilitiesImmutable capsRequested) {
+  public static JAWTWindow getNativeWindow(Object awtCompObject, CapabilitiesImmutable capsRequested) {
       if(null==awtCompObject) {
         throw new NativeWindowException("Null AWT Component");
       }
@@ -61,13 +65,23 @@ public class NewtFactoryAWT extends NewtFactory {
       return getNativeWindow( (java.awt.Component) awtCompObject, capsRequested );
   }
 
-  public static NativeWindow getNativeWindow(java.awt.Component awtComp, CapabilitiesImmutable capsRequested) {
-      DefaultGraphicsConfiguration config = AWTGraphicsConfiguration.create(awtComp, capsRequested, capsRequested);
-      NativeWindow awtNative = NativeWindowFactory.getNativeWindow(awtComp, config); // a JAWTWindow
+  public static JAWTWindow getNativeWindow(java.awt.Component awtComp, CapabilitiesImmutable capsRequested) {
+      AWTGraphicsConfiguration config = AWTGraphicsConfiguration.create(awtComp, null, capsRequested);
+      NativeWindow nw = NativeWindowFactory.getNativeWindow(awtComp, config); // a JAWTWindow
+      if(! ( nw instanceof JAWTWindow ) ) {
+          throw new NativeWindowException("Not an AWT NativeWindow: "+nw);
+      }
       if(DEBUG_IMPLEMENTATION) {
-        System.err.println("NewtFactoryAWT.getNativeWindow: "+awtComp+" -> "+awtNative);
+        System.err.println("NewtFactoryAWT.getNativeWindow: "+awtComp+" -> "+nw);
       }
-      return awtNative;
+      return (JAWTWindow)nw;
+  }
+    
+  public static void destroyNativeWindow(JAWTWindow jawtWindow) {
+      final AbstractGraphicsConfiguration config = jawtWindow.getGraphicsConfiguration();
+      jawtWindow.destroy();
+      config.getScreen().getDevice().close();      
   }
+    
 }
 
diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java
index b9c8d2c..d64cc93 100644
--- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java
+++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java
@@ -29,6 +29,7 @@
 package jogamp.newt.awt.event;
 
 import com.jogamp.common.util.IntIntHashMap;
+import com.jogamp.newt.event.InputEvent;
 
 public class AWTNewtEventFactory {
 
@@ -122,10 +123,19 @@ public class AWTNewtEventFactory {
                 rotation = ((java.awt.event.MouseWheelEvent)event).getWheelRotation();
             }
 
+            int mods = awtModifiers2Newt(event.getModifiers(), true);
+            if(null!=newtSource) {
+                if(newtSource.isPointerConfined()) {
+                    mods |= InputEvent.CONFINED_MASK;
+                }
+                if(!newtSource.isPointerVisible()) {
+                    mods |= InputEvent.INVISIBLE_MASK;
+                }
+            }
+                    
             return new com.jogamp.newt.event.MouseEvent(
                            type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(),
-                           awtModifiers2Newt(event.getModifiers(), true), 
-                           event.getX(), event.getY(), event.getClickCount(), 
+                           mods, event.getX(), event.getY(), event.getClickCount(), 
                            awtButton2Newt(event.getButton()), rotation);
         }
         return null; // no mapping ..
diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java
index 3588645..8e9c028 100644
--- a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java
+++ b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java
@@ -28,6 +28,10 @@
  
 package jogamp.newt.awt.event;
 
+import java.awt.KeyboardFocusManager;
+
+import jogamp.newt.driver.DriverUpdatePosition;
+
 import com.jogamp.newt.event.awt.AWTAdapter;
 import com.jogamp.newt.event.awt.AWTWindowAdapter;
 
@@ -54,9 +58,16 @@ public class AWTParentWindowAdapter
     }
 
     public void focusGained(java.awt.event.FocusEvent e) {
+        // forward focus to NEWT child
+        final com.jogamp.newt.Window newtChild = getNewtWindow();
+        final boolean isOnscreen = newtChild.isNativeValid() && newtChild.getGraphicsConfiguration().getChosenCapabilities().isOnscreen();
         if(DEBUG_IMPLEMENTATION) {
-            System.err.println("AWT: focusGained: "+ e);
+            System.err.println("AWT: focusGained: onscreen "+ isOnscreen+", "+e);
+        }
+        if(isOnscreen) {
+            KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
         }
+        newtChild.requestFocus(false);
     }
 
     public void focusLost(java.awt.event.FocusEvent e) {
@@ -90,7 +101,12 @@ public class AWTParentWindowAdapter
     }
 
     public void componentMoved(java.awt.event.ComponentEvent e) {
-        // no propagation to NEWT child window
+        if(DEBUG_IMPLEMENTATION) {
+            System.err.println("AWT: componentMoved: "+e);            
+        }
+        if(getNewtWindow().getDelegatedWindow() instanceof DriverUpdatePosition) {
+            ((DriverUpdatePosition)getNewtWindow().getDelegatedWindow()).updatePosition();
+        }            
     }
 
     public void windowActivated(java.awt.event.WindowEvent e) {
@@ -104,11 +120,11 @@ public class AWTParentWindowAdapter
     public void hierarchyChanged(java.awt.event.HierarchyEvent e) {
         if( null == getNewtEventListener() ) {
             long bits = e.getChangeFlags();
-            final java.awt.Component changed = e.getChanged();
+            final java.awt.Component changed = e.getChanged();            
             if( 0 != ( java.awt.event.HierarchyEvent.SHOWING_CHANGED & bits ) ) {
                 final boolean showing = changed.isShowing();
                 if(DEBUG_IMPLEMENTATION) {
-                    System.err.println("AWT: hierarchyChanged SHOWING_CHANGED: showing "+showing+", "+changed);
+                    System.err.println("AWT: hierarchyChanged SHOWING_CHANGED: showing "+showing+", "+changed+", source "+e.getComponent());
                 }
                 getNewtWindow().runOnEDTIfAvail(false, new Runnable() {
                     public void run() {
diff --git a/src/newt/classes/jogamp/newt/driver/DriverClearFocus.java b/src/newt/classes/jogamp/newt/driver/DriverClearFocus.java
new file mode 100644
index 0000000..0a824e8
--- /dev/null
+++ b/src/newt/classes/jogamp/newt/driver/DriverClearFocus.java
@@ -0,0 +1,12 @@
+package jogamp.newt.driver;
+
+/** 
+ * Interface tagging driver requirement of clearing the focus.
+ * <p>
+ * Some drivers require a programmatic {@link #clearFocus()} when traversing the focus. 
+ * </p>   
+ */
+public interface DriverClearFocus {
+    /** Programmatic clear the focus */
+    void clearFocus();
+}
diff --git a/src/newt/classes/jogamp/newt/driver/DriverUpdatePosition.java b/src/newt/classes/jogamp/newt/driver/DriverUpdatePosition.java
new file mode 100644
index 0000000..bb846c0
--- /dev/null
+++ b/src/newt/classes/jogamp/newt/driver/DriverUpdatePosition.java
@@ -0,0 +1,9 @@
+package jogamp.newt.driver;
+
+/** 
+ * Interface tagging driver requirement of absolute positioning, ie. depend on parent position.
+ */
+public interface DriverUpdatePosition {
+    /** Programmatic update the position */
+    void updatePosition();
+}
diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java
index cd3cb48..32879b0 100644
--- a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java
@@ -205,7 +205,7 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
     @Override
     protected void createNativeImpl() {
         Log.d(MD.TAG, "createNativeImpl 0 - surfaceHandle 0x"+Long.toHexString(surfaceHandle)+
-                    ", "+x+"/"+y+" "+width+"x"+height+" - "+Thread.currentThread().getName());
+                    ", format "+format+", "+x+"/"+y+" "+width+"x"+height+" - "+Thread.currentThread().getName());
         Thread.dumpStack();
         if(0!=getParentWindowHandle()) {
             throw new NativeWindowException("Window parenting not supported (yet)");
@@ -239,7 +239,7 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
         }
         
         // propagate data ..
-        config = eglConfig;
+        setGraphicsConfiguration(eglConfig);
         setWindowHandle(surfaceHandle);
         Log.d(MD.TAG, "createNativeImpl X");
     }
@@ -331,9 +331,9 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
         Log.d(MD.TAG, "surfaceCreated: "+x+"/"+y+" "+width+"x"+height);
     }
 
-    public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
-        Log.d(MD.TAG, "surfaceChanged: f "+this.format+" -> "+format+", "+width+"x"+height+", current surfaceHandle: 0x"+Long.toHexString(surfaceHandle));
-        if(0!=surfaceHandle && this.format != format) {
+    public void surfaceChanged(SurfaceHolder aHolder, int aFormat, int aWidth, int aHeight) {
+        Log.d(MD.TAG, "surfaceChanged: f "+format+" -> "+aFormat+", "+aWidth+"x"+aHeight+", current surfaceHandle: 0x"+Long.toHexString(surfaceHandle));
+        if(0!=surfaceHandle && format != aFormat) {
             // re-create
             Log.d(MD.TAG, "surfaceChanged (destroy old)");
             windowDestroyNotify();
@@ -352,24 +352,26 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
         }
         
         if(0 == surfaceHandle) {
-            surface = holder.getSurface();
+            surface = aHolder.getSurface();
             surfaceHandle = getSurfaceHandle0(surface);
             acquire0(surfaceHandle);
             format = getSurfaceVisualID0(surfaceHandle);
+            final int nWidth = getWidth0(surfaceHandle);
+            final int nHeight = getHeight0(surfaceHandle);
             capsByFormat = (GLCapabilitiesImmutable) fixCaps(format, getRequestedCapabilities());
-            sizeChanged(false, getWidth0(surfaceHandle), getHeight0(surfaceHandle), false);
+            sizeChanged(false, nWidth, nHeight, false);
     
             Log.d(MD.TAG, "surfaceRealized: isValid: "+surface.isValid()+
                           ", new surfaceHandle 0x"+Long.toHexString(surfaceHandle)+", format: "+format+
-                          ", "+x+"/"+y+" "+width+"x"+height+", visible: "+isVisible());
+                          ", "+x+"/"+y+" "+nWidth+"x"+nHeight+", visible: "+isVisible());
     
             if(isVisible()) {
                setVisible(true); 
             }
         } else {
-            sizeChanged(false, width, height, false);                
+            sizeChanged(false, aWidth, aHeight, false);
         }
-        windowRepaint(0, 0, width, height);
+        windowRepaint(0, 0, aWidth, aHeight);
         Log.d(MD.TAG, "surfaceChanged: X");
     }
     
@@ -382,8 +384,7 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
         Log.d(MD.TAG, "surfaceRedrawNeeded");
         windowRepaint(0, 0, getWidth(), getHeight());
     }
-    
-    
+        
     private MSurfaceView androidView;
     private android.view.Window androidWindow;
     private int format; // stored current PixelFormat
diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java
index 5e5b907..f7c05cd 100644
--- a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java
+++ b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java
@@ -27,10 +27,7 @@
  */
 package jogamp.newt.driver.android;
 
-import javax.media.opengl.GLProfile;
-
 import com.jogamp.newt.Window;
-import com.jogamp.newt.opengl.GLWindow;
 import com.jogamp.opengl.util.Animator;
 
 import jogamp.newt.driver.android.AndroidWindow;
@@ -63,9 +60,7 @@ public class NewtBaseActivity extends Activity {
    }     
    
    public void setContentView(android.view.Window androidWindow, Window newtWindow) {
-       if(newtWindow instanceof GLWindow) {
-           newtWindow = ((GLWindow)newtWindow).getWindow();
-       }
+       newtWindow = newtWindow.getDelegatedWindow();
        if(newtWindow instanceof AndroidWindow) {
            this.newtWindow = (AndroidWindow)newtWindow;
            this.newtWindow.setAndroidWindow(androidWindow);
@@ -81,6 +76,10 @@ public class NewtBaseActivity extends Activity {
    
    public void setAnimator(Animator animator) {
        this.animator = animator;
+       if(!animator.isStarted()) {
+           animator.start();
+       }
+       animator.pause();
    }
       
    @Override
@@ -99,9 +98,6 @@ public class NewtBaseActivity extends Activity {
            jogamp.common.os.android.StaticContext.setContext(extActivity.getApplicationContext());
        }
        extActivity.getWindow();
-
-       // init GLProfile
-       GLProfile.initSingleton(true);       
    }
    
    @Override
@@ -127,7 +123,7 @@ public class NewtBaseActivity extends Activity {
          super.onResume();
      }
      if(null != animator) {
-         animator.start();
+         animator.resume();
      }
    }
 
diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java
index ecf1f72..863bfd3 100644
--- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java
+++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java
@@ -32,6 +32,7 @@ import java.awt.event.MouseEvent;
 
 import com.jogamp.common.util.IntIntHashMap;
 import com.jogamp.newt.Window;
+import com.jogamp.newt.event.InputEvent;
 
 public class AndroidNewtEventFactory {
 
@@ -157,14 +158,22 @@ public class AndroidNewtEventFactory {
                 index++;
             }
 
+            if(null!=newtSource) {
+                if(newtSource.isPointerConfined()) {
+                    modifiers |= InputEvent.CONFINED_MASK;
+                }
+                if(!newtSource.isPointerVisible()) {
+                    modifiers |= InputEvent.INVISIBLE_MASK;
+                }
+            }
+                                
             com.jogamp.newt.event.MouseEvent res[];
 
             com.jogamp.newt.event.MouseEvent me1 = 
                     new com.jogamp.newt.event.MouseEvent(
                            type, 
                            (null==newtSource)?null:(Object)newtSource, event.getEventTime(),
-                                   modifiers , 
-                           x, y, pressure, pointers, clickCount, 
+                           modifiers, x, y, pressure, pointers, clickCount, 
                            pointers.length==1 ? MouseEvent.BUTTON1 : 0, rotation);
             
             if(type == com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED) {
@@ -172,8 +181,7 @@ public class AndroidNewtEventFactory {
                     new com.jogamp.newt.event.MouseEvent(
                            com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED, 
                            (null==newtSource)?null:(Object)newtSource, event.getEventTime(),
-                                   modifiers , 
-                           x, y, pressure, pointers, clickCount, 
+                           modifiers, x, y, pressure, pointers, clickCount, 
                            pointers.length==1 ? MouseEvent.BUTTON1 : 0, rotation);
                 res = new com.jogamp.newt.event.MouseEvent[2];
                 res[0] = me1;
diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java
index 0729f02..b63e433 100644
--- a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java
+++ b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java
@@ -99,7 +99,7 @@ public class AWTCanvas extends Canvas {
     if(null==awtConfig) {
         throw new NativeWindowException("Error: NULL AWTGraphicsConfiguration");
     }
-    chosen = awtConfig.getGraphicsConfiguration();
+    chosen = awtConfig.getAWTGraphicsConfiguration();
 
     // before native peer is valid: X11
     disableBackgroundErase();
@@ -192,7 +192,7 @@ public class AWTCanvas extends Canvas {
          */
         AWTGraphicsConfiguration config = chooseGraphicsConfiguration(
                 awtConfig.getChosenCapabilities(), awtConfig.getRequestedCapabilities(), chooser, gc.getDevice());
-        final GraphicsConfiguration compatible = (null!=config)?config.getGraphicsConfiguration():null;
+        final GraphicsConfiguration compatible = (null!=config)?config.getAWTGraphicsConfiguration():null;
         if(Window.DEBUG_IMPLEMENTATION) {
             Exception e = new Exception("Info: Call Stack: "+Thread.currentThread().getName());
             e.printStackTrace();
@@ -246,7 +246,9 @@ public class AWTCanvas extends Canvas {
                                                                       CapabilitiesImmutable capsRequested,
                                                                       CapabilitiesChooser chooser,
                                                                       GraphicsDevice device) {
-    AbstractGraphicsScreen aScreen = AWTGraphicsScreen.createScreenDevice(device, AbstractGraphicsDevice.DEFAULT_UNIT);
+    final AbstractGraphicsScreen aScreen = null != device ? 
+            AWTGraphicsScreen.createScreenDevice(device, AbstractGraphicsDevice.DEFAULT_UNIT):
+            AWTGraphicsScreen.createDefault();
     AWTGraphicsConfiguration config = (AWTGraphicsConfiguration)
       GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class).chooseGraphicsConfiguration(capsChosen,
                                                                                                    capsRequested,
diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java b/src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java
index 64c7414..f22ec6f 100644
--- a/src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java
+++ b/src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
  * 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -33,7 +34,6 @@
 
 package jogamp.newt.driver.awt;
 
-import javax.media.nativewindow.AbstractGraphicsDevice;
 import javax.media.nativewindow.awt.AWTGraphicsDevice;
 import com.jogamp.newt.NewtFactory;
 import jogamp.newt.DisplayImpl;
@@ -43,7 +43,7 @@ public class AWTDisplay extends DisplayImpl {
     }
 
     protected void createNativeImpl() {
-        aDevice = (AWTGraphicsDevice) AWTGraphicsDevice.createDevice(null, AbstractGraphicsDevice.DEFAULT_UNIT); // default
+        aDevice = AWTGraphicsDevice.createDefault();
     }
 
     protected void setAWTGraphicsDevice(AWTGraphicsDevice d) {
diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java
index cca1e32..6d0b102 100644
--- a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java
+++ b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java
@@ -29,7 +29,6 @@
 package jogamp.newt.driver.awt;
 
 import java.awt.EventQueue;
-import java.lang.reflect.InvocationTargetException;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -49,7 +48,8 @@ public class AWTEDTUtil implements EDTUtil {
     private static TimerTask pumpMessagesTimerTask=null;
     private static final Map<Display, Runnable> pumpMessageDisplayMap = new HashMap<Display, Runnable>();
     private static AWTEDTUtil singletonMainThread = new AWTEDTUtil(); // one singleton MainThread
-
+    private static long pollPeriod = EDTUtil.defaultEDTPollPeriod;
+    
     public static AWTEDTUtil getSingleton() {
         return singletonMainThread;
     }
@@ -58,6 +58,14 @@ public class AWTEDTUtil implements EDTUtil {
         // package private access ..
     }
 
+    final public long getPollPeriod() {
+        return pollPeriod;
+    }
+
+    final public void setPollPeriod(long ms) {
+        pollPeriod = ms;
+    }
+    
     final public void reset() {
         // nop AWT is always running
     }
@@ -132,7 +140,7 @@ public class AWTEDTUtil implements EDTUtil {
                         }
                     }
                 };
-                pumpMessagesTimer.scheduleAtFixedRate(pumpMessagesTimerTask, 0, defaultEDTPollGranularity);
+                pumpMessagesTimer.scheduleAtFixedRate(pumpMessagesTimerTask, 0, pollPeriod);
             }
             pumpMessageDisplayMap.put(dpy, pumpMessage);
         }
diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java b/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java
index 9aaa82f..ca280fa 100644
--- a/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java
@@ -39,7 +39,9 @@ import java.awt.Container;
 import java.awt.DisplayMode;
 import java.awt.Frame;
 import java.awt.Insets;
+
 import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.awt.AWTGraphicsConfiguration;
 import javax.media.nativewindow.awt.AWTGraphicsDevice;
 import javax.media.nativewindow.awt.AWTGraphicsScreen;
 import javax.media.nativewindow.util.Point;
@@ -145,27 +147,24 @@ public class AWTWindow extends WindowImpl {
     public boolean hasDeviceChanged() {
         boolean res = canvas.hasDeviceChanged();
         if(res) {
-            config = canvas.getAWTGraphicsConfiguration();
-            if (config == null) {
+            final AWTGraphicsConfiguration cfg = canvas.getAWTGraphicsConfiguration();
+            if (null == cfg) {
                 throw new NativeWindowException("Error Device change null GraphicsConfiguration: "+this);
             }
-            updateDeviceData();
+            setGraphicsConfiguration(cfg);
+            
+            // propagate new info ..
+            ((AWTScreen)getScreen()).setAWTGraphicsScreen((AWTGraphicsScreen)cfg.getScreen());
+            ((AWTDisplay)getScreen().getDisplay()).setAWTGraphicsDevice((AWTGraphicsDevice)cfg.getScreen().getDevice());
+    
+            final DisplayMode mode = ((AWTGraphicsDevice)cfg.getScreen().getDevice()).getGraphicsDevice().getDisplayMode();
+            if(null != mode) {
+                ((AWTScreen)getScreen()).setScreenSize(mode.getWidth(), mode.getHeight());
+            }
         }
         return res;
     }
 
-    private void updateDeviceData() {
-        // propagate new info ..
-        ((AWTScreen)getScreen()).setAWTGraphicsScreen((AWTGraphicsScreen)config.getScreen());
-        ((AWTDisplay)getScreen().getDisplay()).setAWTGraphicsDevice((AWTGraphicsDevice)config.getScreen().getDevice());
-
-        final DisplayMode mode = ((AWTGraphicsDevice)config.getScreen().getDevice()).getGraphicsDevice().getDisplayMode();
-        if(null != mode) {
-            ((AWTScreen)getScreen()).setScreenSize(mode.getWidth(), mode.getHeight());
-        }
-        
-    }
-
     protected void updateInsetsImpl(javax.media.nativewindow.util.Insets insets) {
         Insets contInsets = container.getInsets();
         insets.setLeftWidth(contInsets.left);
@@ -202,11 +201,12 @@ public class AWTWindow extends WindowImpl {
         if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) {
             if( 0 != ( FLAG_IS_VISIBLE & flags ) ) {
                 if( !hasDeviceChanged() ) {
-                    // oops ??
-                    config = canvas.getAWTGraphicsConfiguration();
-                    if(null == config) {
+                    // oops ??                   
+                    final AWTGraphicsConfiguration cfg = canvas.getAWTGraphicsConfiguration();
+                    if(null == cfg) {
                         throw new NativeWindowException("Error: !hasDeviceChanged && null == GraphicsConfiguration: "+this);
                     }
+                    setGraphicsConfiguration(cfg);
                 }
             }
             visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags));
diff --git a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java
index 7df293c..6f66eed 100644
--- a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java
+++ b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java
@@ -35,6 +35,7 @@ package jogamp.newt.driver.broadcom.egl;
 
 import jogamp.opengl.egl.*;
 import javax.media.nativewindow.*;
+import javax.media.nativewindow.awt.AWTGraphicsConfiguration;
 import javax.media.nativewindow.util.Insets;
 import javax.media.nativewindow.util.Point;
 import javax.media.opengl.GLCapabilitiesImmutable;
@@ -51,13 +52,14 @@ public class Window extends jogamp.newt.WindowImpl {
         if(0!=getParentWindowHandle()) {
             throw new RuntimeException("Window parenting not supported (yet)");
         }
-        // query a good configuration .. even thought we drop this one 
-        // and reuse the EGLUtil choosen one later.
-        config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(
+        // query a good configuration, however chose the final one by the native queried egl-cfg-id  
+        // after creation at {@link #windowCreated(int, int, int)}.
+        final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(
                 capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen());
-        if (config == null) {
+        if (null == cfg) {
             throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
         }
+        setGraphicsConfiguration(cfg);
         setSizeImpl(getScreen().getWidth(), getScreen().getHeight());
 
         setWindowHandle(realizeWindow(true, width, height));
@@ -139,7 +141,7 @@ public class Window extends jogamp.newt.WindowImpl {
 
     private long realizeWindow(boolean chromaKey, int width, int height) {
         if(DEBUG_IMPLEMENTATION) {
-            System.err.println("BCEGL Window.realizeWindow() with: chroma "+chromaKey+", "+width+"x"+height+", "+config);
+            System.err.println("BCEGL Window.realizeWindow() with: chroma "+chromaKey+", "+width+"x"+height+", "+getGraphicsConfiguration());
         }
         long handle = CreateWindow(getDisplayHandle(), chromaKey, width, height);
         if (0 == handle) {
@@ -152,13 +154,14 @@ public class Window extends jogamp.newt.WindowImpl {
     private void windowCreated(int cfgID, int width, int height) {
         this.width = width;
         this.height = height;
-        GLCapabilitiesImmutable capsReq = (GLCapabilitiesImmutable) config.getRequestedCapabilities();
-        config = EGLGraphicsConfiguration.create(capsReq, getScreen().getGraphicsScreen(), cfgID);
-        if (config == null) {
+        GLCapabilitiesImmutable capsReq = (GLCapabilitiesImmutable) getGraphicsConfiguration().getRequestedCapabilities();
+        final AbstractGraphicsConfiguration cfg = EGLGraphicsConfiguration.create(capsReq, getScreen().getGraphicsScreen(), cfgID);
+        if (null == cfg) {
             throw new NativeWindowException("Error creating EGLGraphicsConfiguration from id: "+cfgID+", "+this);
         }
+        setGraphicsConfiguration(cfg);
         if(DEBUG_IMPLEMENTATION) {
-            System.err.println("BCEGL Window.windowCreated(): "+toHexString(cfgID)+", "+width+"x"+height+", "+config);
+            System.err.println("BCEGL Window.windowCreated(): "+toHexString(cfgID)+", "+width+"x"+height+", "+cfg);
         }
     }
 
diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java
index ab3e95e..6fc76a1 100644
--- a/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java
+++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java
@@ -51,14 +51,15 @@ public class Window extends jogamp.newt.WindowImpl {
         if(0!=getParentWindowHandle()) {
             throw new NativeWindowException("GDL Window does not support window parenting");
         }
-        AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen();
-        AbstractGraphicsDevice aDevice = getScreen().getDisplay().getGraphicsDevice();
+        final AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen();
+        final AbstractGraphicsDevice aDevice = getScreen().getDisplay().getGraphicsDevice();
 
-        config = GraphicsConfigurationFactory.getFactory(aDevice).chooseGraphicsConfiguration(
+        final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(aDevice).chooseGraphicsConfiguration(
                 capsRequested, capsRequested, capabilitiesChooser, aScreen);
-        if (config == null) {
+        if (null == cfg) {
             throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
         }
+        setGraphicsConfiguration(cfg);
 
         synchronized(Window.class) {
             setWindowHandle(nextWindowHandle++); // just a marker
diff --git a/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java b/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java
index 10a75a0..0c720e5 100644
--- a/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java
@@ -55,18 +55,19 @@ public class KDWindow extends WindowImpl {
         if(0!=getParentWindowHandle()) {
             throw new RuntimeException("Window parenting not supported (yet)");
         }
-        config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(
+        final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(
                 capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen());
-        if (config == null) {
+        if (null == cfg) {
             throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
         }
+        setGraphicsConfiguration(cfg);
 
-        GLCapabilitiesImmutable eglCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
+        GLCapabilitiesImmutable eglCaps = (GLCapabilitiesImmutable) cfg.getChosenCapabilities();
         int[] eglAttribs = EGLGraphicsConfiguration.GLCapabilities2AttribList(eglCaps);
 
         eglWindowHandle = CreateWindow(getDisplayHandle(), eglAttribs);
         if (eglWindowHandle == 0) {
-            throw new NativeWindowException("Error creating egl window: "+config);
+            throw new NativeWindowException("Error creating egl window: "+cfg);
         }
         setVisible0(eglWindowHandle, false);
         setWindowHandle(RealizeWindow(eglWindowHandle));
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacDisplay.java b/src/newt/classes/jogamp/newt/driver/macosx/MacDisplay.java
index 527fdac..2ac98f2 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/MacDisplay.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/MacDisplay.java
@@ -72,8 +72,12 @@ public class MacDisplay extends DisplayImpl {
     public static void runNSApplication() {
         runNSApplication0();
     }
+    public static void stopNSApplication() {
+        stopNSApplication0();
+    }
 
     private static native boolean initNSApplication0();
     private static native void runNSApplication0();
+    private static native void stopNSApplication0();
 }
 
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java b/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java
new file mode 100644
index 0000000..46625f7
--- /dev/null
+++ b/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java
@@ -0,0 +1,262 @@
+package jogamp.newt.driver.macosx;
+
+import com.jogamp.newt.event.KeyEvent;
+
+public class MacKeyUtil {
+      
+    // KeyCodes (independent)
+    private static final int kVK_Return                    = 0x24;
+    private static final int kVK_Tab                       = 0x30;
+    private static final int kVK_Space                     = 0x31;
+    private static final int kVK_Delete                    = 0x33;
+    private static final int kVK_Escape                    = 0x35;
+    private static final int kVK_Command                   = 0x37;
+    private static final int kVK_Shift                     = 0x38;
+    private static final int kVK_CapsLock                  = 0x39;
+    private static final int kVK_Option                    = 0x3A;
+    private static final int kVK_Control                   = 0x3B;
+    private static final int kVK_RightShift                = 0x3C;
+    private static final int kVK_RightOption               = 0x3D;
+    private static final int kVK_RightControl              = 0x3E;
+    private static final int kVK_Function                  = 0x3F;
+    private static final int kVK_F17                       = 0x40;
+    private static final int kVK_VolumeUp                  = 0x48;
+    private static final int kVK_VolumeDown                = 0x49;
+    private static final int kVK_Mute                      = 0x4A;
+    private static final int kVK_F18                       = 0x4F;
+    private static final int kVK_F19                       = 0x50;
+    private static final int kVK_F20                       = 0x5A;
+    private static final int kVK_F5                        = 0x60;
+    private static final int kVK_F6                        = 0x61;
+    private static final int kVK_F7                        = 0x62;
+    private static final int kVK_F3                        = 0x63;
+    private static final int kVK_F8                        = 0x64;
+    private static final int kVK_F9                        = 0x65;
+    private static final int kVK_F11                       = 0x67;
+    private static final int kVK_F13                       = 0x69;
+    private static final int kVK_F16                       = 0x6A;
+    private static final int kVK_F14                       = 0x6B;
+    private static final int kVK_F10                       = 0x6D;
+    private static final int kVK_F12                       = 0x6F;
+    private static final int kVK_F15                       = 0x71;
+    private static final int kVK_Help                      = 0x72;
+    private static final int kVK_Home                      = 0x73;
+    private static final int kVK_PageUp                    = 0x74;
+    private static final int kVK_ForwardDelete             = 0x75;
+    private static final int kVK_F4                        = 0x76;
+    private static final int kVK_End                       = 0x77;
+    private static final int kVK_F2                        = 0x78;
+    private static final int kVK_PageDown                  = 0x79;
+    private static final int kVK_F1                        = 0x7A;
+    private static final int kVK_LeftArrow                 = 0x7B;
+    private static final int kVK_RightArrow                = 0x7C;
+    private static final int kVK_DownArrow                 = 0x7D;
+    private static final int kVK_UpArrow                   = 0x7E;
+  
+    // Key constants handled differently on Mac OS X than other platforms
+    private static final char NSUpArrowFunctionKey        = 0xF700;
+    private static final char NSDownArrowFunctionKey      = 0xF701;
+    private static final char NSLeftArrowFunctionKey      = 0xF702;
+    private static final char NSRightArrowFunctionKey     = 0xF703;
+    private static final char NSF1FunctionKey             = 0xF704;
+    private static final char NSF2FunctionKey             = 0xF705;
+    private static final char NSF3FunctionKey             = 0xF706;
+    private static final char NSF4FunctionKey             = 0xF707;
+    private static final char NSF5FunctionKey             = 0xF708;
+    private static final char NSF6FunctionKey             = 0xF709;
+    private static final char NSF7FunctionKey             = 0xF70A;
+    private static final char NSF8FunctionKey             = 0xF70B;
+    private static final char NSF9FunctionKey             = 0xF70C;
+    private static final char NSF10FunctionKey            = 0xF70D;
+    private static final char NSF11FunctionKey            = 0xF70E;
+    private static final char NSF12FunctionKey            = 0xF70F;
+    private static final char NSF13FunctionKey            = 0xF710;
+    private static final char NSF14FunctionKey            = 0xF711;
+    private static final char NSF15FunctionKey            = 0xF712;
+    private static final char NSF16FunctionKey            = 0xF713;
+    private static final char NSF17FunctionKey            = 0xF714;
+    private static final char NSF18FunctionKey            = 0xF715;
+    private static final char NSF19FunctionKey            = 0xF716;
+    private static final char NSF20FunctionKey            = 0xF717;
+    private static final char NSF21FunctionKey            = 0xF718;
+    private static final char NSF22FunctionKey            = 0xF719;
+    private static final char NSF23FunctionKey            = 0xF71A;
+    private static final char NSF24FunctionKey            = 0xF71B;
+    private static final char NSF25FunctionKey            = 0xF71C;
+    private static final char NSF26FunctionKey            = 0xF71D;
+    private static final char NSF27FunctionKey            = 0xF71E;
+    private static final char NSF28FunctionKey            = 0xF71F;
+    private static final char NSF29FunctionKey            = 0xF720;
+    private static final char NSF30FunctionKey            = 0xF721;
+    private static final char NSF31FunctionKey            = 0xF722;
+    private static final char NSF32FunctionKey            = 0xF723;
+    private static final char NSF33FunctionKey            = 0xF724;
+    private static final char NSF34FunctionKey            = 0xF725;
+    private static final char NSF35FunctionKey            = 0xF726;
+    private static final char NSInsertFunctionKey         = 0xF727;
+    private static final char NSDeleteFunctionKey         = 0xF728;
+    private static final char NSHomeFunctionKey           = 0xF729;
+    private static final char NSBeginFunctionKey          = 0xF72A;
+    private static final char NSEndFunctionKey            = 0xF72B;
+    private static final char NSPageUpFunctionKey         = 0xF72C;
+    private static final char NSPageDownFunctionKey       = 0xF72D;
+    private static final char NSPrintScreenFunctionKey    = 0xF72E;
+    private static final char NSScrollLockFunctionKey     = 0xF72F;
+    private static final char NSPauseFunctionKey          = 0xF730;
+    private static final char NSSysReqFunctionKey         = 0xF731;
+    private static final char NSBreakFunctionKey          = 0xF732;
+    private static final char NSResetFunctionKey          = 0xF733;
+    private static final char NSStopFunctionKey           = 0xF734;
+    private static final char NSMenuFunctionKey           = 0xF735;
+    private static final char NSUserFunctionKey           = 0xF736;
+    private static final char NSSystemFunctionKey         = 0xF737;
+    private static final char NSPrintFunctionKey          = 0xF738;
+    private static final char NSClearLineFunctionKey      = 0xF739;
+    private static final char NSClearDisplayFunctionKey   = 0xF73A;
+    private static final char NSInsertLineFunctionKey     = 0xF73B;
+    private static final char NSDeleteLineFunctionKey     = 0xF73C;
+    private static final char NSInsertCharFunctionKey     = 0xF73D;
+    private static final char NSDeleteCharFunctionKey     = 0xF73E;
+    private static final char NSPrevFunctionKey           = 0xF73F;
+    private static final char NSNextFunctionKey           = 0xF740;
+    private static final char NSSelectFunctionKey         = 0xF741;
+    private static final char NSExecuteFunctionKey        = 0xF742;
+    private static final char NSUndoFunctionKey           = 0xF743;
+    private static final char NSRedoFunctionKey           = 0xF744;
+    private static final char NSFindFunctionKey           = 0xF745;
+    private static final char NSHelpFunctionKey           = 0xF746;
+    private static final char NSModeSwitchFunctionKey     = 0xF747;
+    
+    static int validateKeyCode(int keyCode, char keyChar) {        
+        // OS X Virtual Keycodes
+        switch(keyCode) {
+            case kVK_Return:               return KeyEvent.VK_ENTER;
+            case kVK_Tab:                  return KeyEvent.VK_TAB;
+            case kVK_Space:                return KeyEvent.VK_SPACE;
+            case kVK_Delete:               return KeyEvent.VK_BACK_SPACE;
+            case kVK_Escape:               return KeyEvent.VK_ESCAPE;
+            case kVK_Command:              return KeyEvent.VK_ALT;
+            case kVK_Shift:                return KeyEvent.VK_SHIFT;
+            case kVK_CapsLock:             return KeyEvent.VK_CAPS_LOCK;
+            case kVK_Option:               return KeyEvent.VK_WINDOWS;
+            case kVK_Control:              return KeyEvent.VK_CONTROL;
+            case kVK_RightShift:           return KeyEvent.VK_SHIFT;
+            case kVK_RightOption:          return KeyEvent.VK_WINDOWS;
+            case kVK_RightControl:         return KeyEvent.VK_CONTROL;
+            // case kVK_Function:             return KeyEvent.VK_F;
+            case kVK_F17:                  return KeyEvent.VK_F17;
+            // case kVK_VolumeUp:        
+            // case kVK_VolumeDown:
+            // case kVK_Mute:
+            case kVK_F18:                  return KeyEvent.VK_F18;
+            case kVK_F19:                  return KeyEvent.VK_F19;
+            case kVK_F20:                  return KeyEvent.VK_F20;
+            case kVK_F5:                   return KeyEvent.VK_F5;
+            case kVK_F6:                   return KeyEvent.VK_F6;
+            case kVK_F7:                   return KeyEvent.VK_F7;
+            case kVK_F3:                   return KeyEvent.VK_F3;
+            case kVK_F8:                   return KeyEvent.VK_F8;
+            case kVK_F9:                   return KeyEvent.VK_F9;
+            case kVK_F11:                  return KeyEvent.VK_F11;
+            case kVK_F13:                  return KeyEvent.VK_F13;
+            case kVK_F16:                  return KeyEvent.VK_F16;
+            case kVK_F14:                  return KeyEvent.VK_F14;
+            case kVK_F10:                  return KeyEvent.VK_F10;
+            case kVK_F12:                  return KeyEvent.VK_F12;
+            case kVK_F15:                  return KeyEvent.VK_F15;
+            case kVK_Help:                 return KeyEvent.VK_HELP;
+            case kVK_Home:                 return KeyEvent.VK_HOME;
+            case kVK_PageUp:               return KeyEvent.VK_PAGE_UP;
+            case kVK_ForwardDelete:        return KeyEvent.VK_DELETE;
+            case kVK_F4:                   return KeyEvent.VK_F4;
+            case kVK_End:                  return KeyEvent.VK_END;
+            case kVK_F2:                   return KeyEvent.VK_F2;
+            case kVK_PageDown:             return KeyEvent.VK_PAGE_DOWN;
+            case kVK_F1:                   return KeyEvent.VK_F1;
+            case kVK_LeftArrow:            return KeyEvent.VK_LEFT;
+            case kVK_RightArrow:           return KeyEvent.VK_RIGHT;
+            case kVK_DownArrow:            return KeyEvent.VK_DOWN;
+            case kVK_UpArrow:              return KeyEvent.VK_UP;
+        }
+        
+        if (keyChar == '\r') {
+            // Turn these into \n
+            return KeyEvent.VK_ENTER;
+        }
+
+        if (keyChar >= NSUpArrowFunctionKey && keyChar <= NSModeSwitchFunctionKey) {
+            switch (keyChar) {
+                case NSUpArrowFunctionKey:     return KeyEvent.VK_UP;
+                case NSDownArrowFunctionKey:   return KeyEvent.VK_DOWN;
+                case NSLeftArrowFunctionKey:   return KeyEvent.VK_LEFT;
+                case NSRightArrowFunctionKey:  return KeyEvent.VK_RIGHT;
+                case NSF1FunctionKey:          return KeyEvent.VK_F1;
+                case NSF2FunctionKey:          return KeyEvent.VK_F2;
+                case NSF3FunctionKey:          return KeyEvent.VK_F3;
+                case NSF4FunctionKey:          return KeyEvent.VK_F4;
+                case NSF5FunctionKey:          return KeyEvent.VK_F5;
+                case NSF6FunctionKey:          return KeyEvent.VK_F6;
+                case NSF7FunctionKey:          return KeyEvent.VK_F7;
+                case NSF8FunctionKey:          return KeyEvent.VK_F8;
+                case NSF9FunctionKey:          return KeyEvent.VK_F9;
+                case NSF10FunctionKey:         return KeyEvent.VK_F10;
+                case NSF11FunctionKey:         return KeyEvent.VK_F11;
+                case NSF12FunctionKey:         return KeyEvent.VK_F12;
+                case NSF13FunctionKey:         return KeyEvent.VK_F13;
+                case NSF14FunctionKey:         return KeyEvent.VK_F14;
+                case NSF15FunctionKey:         return KeyEvent.VK_F15;
+                case NSF16FunctionKey:         return KeyEvent.VK_F16;
+                case NSF17FunctionKey:         return KeyEvent.VK_F17;
+                case NSF18FunctionKey:         return KeyEvent.VK_F18;
+                case NSF19FunctionKey:         return KeyEvent.VK_F19;
+                case NSF20FunctionKey:         return KeyEvent.VK_F20;
+                case NSF21FunctionKey:         return KeyEvent.VK_F21;
+                case NSF22FunctionKey:         return KeyEvent.VK_F22;
+                case NSF23FunctionKey:         return KeyEvent.VK_F23;
+                case NSF24FunctionKey:         return KeyEvent.VK_F24;
+                case NSInsertFunctionKey:      return KeyEvent.VK_INSERT;
+                case NSDeleteFunctionKey:      return KeyEvent.VK_DELETE;
+                case NSHomeFunctionKey:        return KeyEvent.VK_HOME;
+                case NSBeginFunctionKey:       return KeyEvent.VK_BEGIN;
+                case NSEndFunctionKey:         return KeyEvent.VK_END;
+                case NSPageUpFunctionKey:      return KeyEvent.VK_PAGE_UP;
+                case NSPageDownFunctionKey:    return KeyEvent.VK_PAGE_DOWN;
+                case NSPrintScreenFunctionKey: return KeyEvent.VK_PRINTSCREEN;
+                case NSScrollLockFunctionKey:  return KeyEvent.VK_SCROLL_LOCK;
+                case NSPauseFunctionKey:       return KeyEvent.VK_PAUSE;
+                // Not handled:
+                // NSSysReqFunctionKey
+                // NSBreakFunctionKey
+                // NSResetFunctionKey
+                case NSStopFunctionKey:        return KeyEvent.VK_STOP;
+                // Not handled:
+                // NSMenuFunctionKey
+                // NSUserFunctionKey
+                // NSSystemFunctionKey
+                // NSPrintFunctionKey
+                // NSClearLineFunctionKey
+                // NSClearDisplayFunctionKey
+                // NSInsertLineFunctionKey
+                // NSDeleteLineFunctionKey
+                // NSInsertCharFunctionKey
+                // NSDeleteCharFunctionKey
+                // NSPrevFunctionKey
+                // NSNextFunctionKey
+                // NSSelectFunctionKey
+                // NSExecuteFunctionKey
+                // NSUndoFunctionKey
+                // NSRedoFunctionKey
+                // NSFindFunctionKey
+                // NSHelpFunctionKey
+                // NSModeSwitchFunctionKey
+                default: break;
+            }
+        }
+
+        if ('a' <= keyChar && keyChar <= 'z') {
+            return KeyEvent.VK_A + ( keyChar - 'a' ) ;
+        }
+
+        return (int) keyChar; // let's hope for the best (compatibility of keyChar/keyCode's)
+    }   
+}
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java
index b34f9a2..47c599a 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java
@@ -34,107 +34,24 @@
 
 package jogamp.newt.driver.macosx;
 
-import javax.media.nativewindow.*;
-
-import com.jogamp.newt.event.*;
-
-import jogamp.nativewindow.macosx.OSXUtil;
-import jogamp.newt.*;
-
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.GraphicsConfigurationFactory;
+import javax.media.nativewindow.NativeWindow;
+import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.SurfaceChangeable;
 import javax.media.nativewindow.util.Insets;
 import javax.media.nativewindow.util.InsetsImmutable;
 import javax.media.nativewindow.util.Point;
+import javax.media.nativewindow.util.PointImmutable;
 
-public class MacWindow extends WindowImpl {
-    
-    // Window styles
-    private static final int NSBorderlessWindowMask     = 0;
-    private static final int NSTitledWindowMask         = 1 << 0;
-    private static final int NSClosableWindowMask       = 1 << 1;
-    private static final int NSMiniaturizableWindowMask = 1 << 2;
-    private static final int NSResizableWindowMask      = 1 << 3;
-
-    // Window backing store types
-    private static final int NSBackingStoreRetained     = 0;
-    private static final int NSBackingStoreNonretained  = 1;
-    private static final int NSBackingStoreBuffered     = 2;
-
-    // Key constants handled differently on Mac OS X than other platforms
-    private static final int NSUpArrowFunctionKey        = 0xF700;
-    private static final int NSDownArrowFunctionKey      = 0xF701;
-    private static final int NSLeftArrowFunctionKey      = 0xF702;
-    private static final int NSRightArrowFunctionKey     = 0xF703;
-    private static final int NSF1FunctionKey             = 0xF704;
-    private static final int NSF2FunctionKey             = 0xF705;
-    private static final int NSF3FunctionKey             = 0xF706;
-    private static final int NSF4FunctionKey             = 0xF707;
-    private static final int NSF5FunctionKey             = 0xF708;
-    private static final int NSF6FunctionKey             = 0xF709;
-    private static final int NSF7FunctionKey             = 0xF70A;
-    private static final int NSF8FunctionKey             = 0xF70B;
-    private static final int NSF9FunctionKey             = 0xF70C;
-    private static final int NSF10FunctionKey            = 0xF70D;
-    private static final int NSF11FunctionKey            = 0xF70E;
-    private static final int NSF12FunctionKey            = 0xF70F;
-    private static final int NSF13FunctionKey            = 0xF710;
-    private static final int NSF14FunctionKey            = 0xF711;
-    private static final int NSF15FunctionKey            = 0xF712;
-    private static final int NSF16FunctionKey            = 0xF713;
-    private static final int NSF17FunctionKey            = 0xF714;
-    private static final int NSF18FunctionKey            = 0xF715;
-    private static final int NSF19FunctionKey            = 0xF716;
-    private static final int NSF20FunctionKey            = 0xF717;
-    private static final int NSF21FunctionKey            = 0xF718;
-    private static final int NSF22FunctionKey            = 0xF719;
-    private static final int NSF23FunctionKey            = 0xF71A;
-    private static final int NSF24FunctionKey            = 0xF71B;
-    private static final int NSF25FunctionKey            = 0xF71C;
-    private static final int NSF26FunctionKey            = 0xF71D;
-    private static final int NSF27FunctionKey            = 0xF71E;
-    private static final int NSF28FunctionKey            = 0xF71F;
-    private static final int NSF29FunctionKey            = 0xF720;
-    private static final int NSF30FunctionKey            = 0xF721;
-    private static final int NSF31FunctionKey            = 0xF722;
-    private static final int NSF32FunctionKey            = 0xF723;
-    private static final int NSF33FunctionKey            = 0xF724;
-    private static final int NSF34FunctionKey            = 0xF725;
-    private static final int NSF35FunctionKey            = 0xF726;
-    private static final int NSInsertFunctionKey         = 0xF727;
-    private static final int NSDeleteFunctionKey         = 0xF728;
-    private static final int NSHomeFunctionKey           = 0xF729;
-    private static final int NSBeginFunctionKey          = 0xF72A;
-    private static final int NSEndFunctionKey            = 0xF72B;
-    private static final int NSPageUpFunctionKey         = 0xF72C;
-    private static final int NSPageDownFunctionKey       = 0xF72D;
-    private static final int NSPrintScreenFunctionKey    = 0xF72E;
-    private static final int NSScrollLockFunctionKey     = 0xF72F;
-    private static final int NSPauseFunctionKey          = 0xF730;
-    private static final int NSSysReqFunctionKey         = 0xF731;
-    private static final int NSBreakFunctionKey          = 0xF732;
-    private static final int NSResetFunctionKey          = 0xF733;
-    private static final int NSStopFunctionKey           = 0xF734;
-    private static final int NSMenuFunctionKey           = 0xF735;
-    private static final int NSUserFunctionKey           = 0xF736;
-    private static final int NSSystemFunctionKey         = 0xF737;
-    private static final int NSPrintFunctionKey          = 0xF738;
-    private static final int NSClearLineFunctionKey      = 0xF739;
-    private static final int NSClearDisplayFunctionKey   = 0xF73A;
-    private static final int NSInsertLineFunctionKey     = 0xF73B;
-    private static final int NSDeleteLineFunctionKey     = 0xF73C;
-    private static final int NSInsertCharFunctionKey     = 0xF73D;
-    private static final int NSDeleteCharFunctionKey     = 0xF73E;
-    private static final int NSPrevFunctionKey           = 0xF73F;
-    private static final int NSNextFunctionKey           = 0xF740;
-    private static final int NSSelectFunctionKey         = 0xF741;
-    private static final int NSExecuteFunctionKey        = 0xF742;
-    private static final int NSUndoFunctionKey           = 0xF743;
-    private static final int NSRedoFunctionKey           = 0xF744;
-    private static final int NSFindFunctionKey           = 0xF745;
-    private static final int NSHelpFunctionKey           = 0xF746;
-    private static final int NSModeSwitchFunctionKey     = 0xF747;
+import jogamp.newt.WindowImpl;
+import jogamp.newt.driver.DriverClearFocus;
+import jogamp.newt.driver.DriverUpdatePosition;
 
-    private volatile long surfaceHandle;
+import com.jogamp.newt.event.KeyEvent;
 
+public class MacWindow extends WindowImpl implements SurfaceChangeable, DriverClearFocus, DriverUpdatePosition {
+    
     static {
         MacDisplay.initSingleton();
     }
@@ -142,23 +59,25 @@ public class MacWindow extends WindowImpl {
     public MacWindow() {
     }
     
+    @Override
     protected void createNativeImpl() {
-        config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(
+        final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(
                 capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen());
-        if (config == null) {
+        if (null == cfg) {
             throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
         }
+        setGraphicsConfiguration(cfg);
         reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_VISIBILITY, true));        
         if (0 == getWindowHandle()) {
             throw new NativeWindowException("Error creating window");
         }
     }
 
+    @Override
     protected void closeNativeImpl() {
         try {
             if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.CloseAction "+Thread.currentThread().getName()); }
             if (getWindowHandle() != 0) {
-                orderOut0(getWindowHandle());
                 close0(getWindowHandle());
             }
         } catch (Throwable t) {
@@ -172,216 +91,237 @@ public class MacWindow extends WindowImpl {
     }
     
     @Override
+    protected int lockSurfaceImpl() {
+        if(!isOffscreenInstance) {
+            return lockSurface0(getWindowHandle()) ? LOCK_SUCCESS : LOCK_SURFACE_NOT_READY;
+        }
+        return LOCK_SUCCESS;
+    }
+
+    @Override
+    protected void unlockSurfaceImpl() {
+        if(!isOffscreenInstance) {
+            unlockSurface0(getWindowHandle());
+        }
+    }
+    
+    @Override
     public final long getSurfaceHandle() {
-        return surfaceHandle;
+        return 0 != sscSurfaceHandle ? sscSurfaceHandle : surfaceHandle;
     }
 
+    public void setSurfaceHandle(long surfaceHandle) {
+        if(DEBUG_IMPLEMENTATION) {
+            System.err.println("MacWindow.setSurfaceHandle(): 0x"+Long.toHexString(surfaceHandle));
+        }
+        sscSurfaceHandle = surfaceHandle;
+        if (isNativeValid()) {
+            if (0 != sscSurfaceHandle) {
+                orderOut0( 0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() );
+            } /** this is done by recreation! 
+              else if (isVisible()){
+                orderFront0( 0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() );
+            } */
+        }        
+    }
+
+    public void surfaceSizeChanged(int width, int height) {
+        sizeChanged(false, width, height, false);
+    }
+    
     @Override
     protected void setTitleImpl(final String title) {
         setTitle0(getWindowHandle(), title);
     }
 
-    protected void requestFocusImpl(boolean reparented) {
-        makeKeyAndOrderFront0(getWindowHandle());            
+    protected void requestFocusImpl(boolean force) {
+        if(!isOffscreenInstance) {
+            requestFocus0(getWindowHandle(), force);
+        } else {
+            focusChanged(false, true);
+        }
     }
-    
-    protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) {
-        int _x = x, _y = y;
-        if(0 == ( FLAG_IS_UNDECORATED & flags) && 0<=_x && 0<=_y) {
-            final InsetsImmutable i = getInsets();         
-            
-            // client position -> top-level window position
-            _x -= i.getLeftWidth() ;
-            _y -= i.getTopHeight() ;
-            if( 0 > _x ) { _x = 0; }
-            if( 0 > _y ) { _y = 0; }
-            if(DEBUG_IMPLEMENTATION) {
-                System.err.println("MacWindow reconfig (insets: "+i+"): "+x+"/"+y+" -> "+_x+"/"+_y);
-            }
+        
+    public final void clearFocus() {
+        if(DEBUG_IMPLEMENTATION) {
+            System.err.println("MacWindow: clearFocus() - requestFocusParent, isOffscreenInstance "+isOffscreenInstance);
         }
-        {
-            // On MacOSX the absolute position is required to position 
-            // a window - even for a child window!
-            final NativeWindow parent = getParent();
-            if( null != parent && 0 != parent.getWindowHandle() ) {
-                final Point p = parent.getLocationOnScreen(null);
-                _x += p.getX();
-                _y += p.getY();
-                if(DEBUG_IMPLEMENTATION) {
-                    System.err.println("MacWindow reconfig (parent abs pos: "+p+"): "+x+"/"+y+" -> "+_x+"/"+_y);
-                }
-            }
+        if(!isOffscreenInstance) {
+            requestFocusParent0(getWindowHandle());
+        } else {
+            focusChanged(false, false);
         }
+    }
+    
+    public void updatePosition() {
+        final Point pS = getTopLevelLocationOnScreen(getX(), getY());
+        if(DEBUG_IMPLEMENTATION) {
+            System.err.println("MacWindow: updatePosition() - isOffscreenInstance "+isOffscreenInstance+", new abs pos: pS "+pS);
+        }
+        if( !isOffscreenInstance ) {                
+            setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), pS.getX(), pS.getY());
+        } // else no offscreen position
+        // no native event (fullscreen, some reparenting)
+        super.positionChanged(true, getX(), getY());
+    }
+    
+    
+    protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) {
+        final Point pS = getTopLevelLocationOnScreen(x, y);
+        isOffscreenInstance = 0 != sscSurfaceHandle || isOffscreenInstance(this, this.getParent());
         
         if(DEBUG_IMPLEMENTATION) {
-            System.err.println("MacWindow reconfig: "+x+"/"+y+" -> "+_x+"/"+_y+" - "+width+"x"+height+", "+
-                               getReconfigureFlagsAsString(null, flags));
+            System.err.println("MacWindow reconfig: "+x+"/"+y+" -> "+pS+" - "+width+"x"+height+
+                               ", offscreenInstance "+isOffscreenInstance+
+                               ", "+getReconfigureFlagsAsString(null, flags));
         }
         
-        if( getWindowHandle() == 0 ) {
-            if( 0 != ( FLAG_IS_VISIBLE & flags) ) {
-                // FIXME: for some reason we do not need (or can use) 
-                // the absolute position at creation time .. need to determine the reason/mechanics.
-                createWindow(false, x, y, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags));
-                this.x = x;
-                this.y = y;
-                visibleChanged(false, true); // no native event ..
-            } /* else { ?? } */
-        } else {
-            if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) {
-                if( 0 != ( FLAG_IS_VISIBLE & flags) ) {
-                    makeKeyAndOrderFront0(getWindowHandle());
-                    visibleChanged(false, true); // no native event ..
-                    enqueueWindowEvent(false, WindowEvent.EVENT_WINDOW_GAINED_FOCUS);
-                } else {
-                    orderOut0(getWindowHandle());
-                    visibleChanged(false, false); // no native event ..
-                    enqueueWindowEvent(false, WindowEvent.EVENT_WINDOW_LOST_FOCUS);
-                }
-            } else if( 0 != ( FLAG_CHANGE_DECORATION & flags) ||
-                       0 != ( FLAG_CHANGE_PARENTING & flags) ||
-                       0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) {
-                // FIXME: for some reason we do not need (or can use) 
-                // the absolute position at creation time .. need to determine the reason/mechanics.
-                createWindow(true, x, y, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags));
-            }
-            if(x>=0 && y>=0) {
-                setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), _x, _y);
-                this.x = x;
-                this.y = y;
-                enqueueWindowEvent(false, WindowEvent.EVENT_WINDOW_MOVED);
+        if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 == ( FLAG_IS_VISIBLE & flags) ) {
+            if ( !isOffscreenInstance ) {
+                orderOut0(getWindowHandle());
             }
-            if(width>0 && height>0) {
+            // no native event ..
+            visibleChanged(true, false); 
+        }
+        if( 0 == getWindowHandle() && 0 != ( FLAG_IS_VISIBLE & flags) ||
+            0 != ( FLAG_CHANGE_DECORATION & flags) ||
+            0 != ( FLAG_CHANGE_PARENTING & flags) ||
+            0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) {
+            createWindow(isOffscreenInstance, 0 != getWindowHandle(), pS, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags));
+            if(isVisible()) { flags |= FLAG_CHANGE_VISIBILITY; } 
+        }
+        if(x>=0 && y>=0) {
+            if( !isOffscreenInstance ) {                
+                setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), pS.getX(), pS.getY());
+            } // else no offscreen position
+            // no native event (fullscreen, some reparenting)
+            super.positionChanged(true,  x, y);
+        }
+        if(width>0 && height>0) {
+            if( !isOffscreenInstance ) {                
                 setContentSize0(getWindowHandle(), width, height);
-                this.width = width;
-                this.height = height;
-                enqueueWindowEvent(false, WindowEvent.EVENT_WINDOW_RESIZED);
+            } // else offscreen size is realized via recreation
+            // no native event (fullscreen, some reparenting)
+            sizeChanged(true, width, height, false); // incl. validation (incl. repositioning)
+        }
+        if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 != ( FLAG_IS_VISIBLE & flags) ) {
+            if( !isOffscreenInstance ) {                
+                orderFront0(getWindowHandle());
             }
+            // no native event ..
+            visibleChanged(true, true);
+        } 
+        if( !isOffscreenInstance ) {                
             setAlwaysOnTop0(getWindowHandle(), 0 != ( FLAG_IS_ALWAYSONTOP & flags));
         }
         return true;
     }
 
     protected Point getLocationOnScreenImpl(int x, int y) {
-        return OSXUtil.GetLocationOnScreen(getWindowHandle(), x, y);
+        Point p = new Point(x, y);
+        // min val is 0
+        p.setX(Math.max(p.getX(), 0));
+        p.setY(Math.max(p.getY(), 0));
+        
+        final NativeWindow parent = getParent();
+        if( null != parent && 0 != parent.getWindowHandle() ) {
+            p.translate(parent.getLocationOnScreen(null));
+        }
+        return p;        
+    }
+    
+    private Point getTopLevelLocationOnScreen(int x, int y) {
+        final InsetsImmutable _insets = getInsets(); // zero if undecorated
+        // client position -> top-level window position
+        x -= _insets.getLeftWidth() ;
+        y -= _insets.getTopHeight() ;
+        return getLocationOnScreenImpl(x, y);
     }
     
     protected void updateInsetsImpl(Insets insets) {
         // nop - using event driven insetsChange(..)
     }
         
-    private char convertKeyChar(char keyChar) {
-        if (keyChar == '\r') {
-            // Turn these into \n
-            return '\n';
+    @Override
+    protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) {
+        if(width != newWidth || height != newHeight) {
+            final Point p0S = getTopLevelLocationOnScreen(x, y);            
+            setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), p0S.getX(), p0S.getY());               
         }
-
-        if (keyChar >= NSUpArrowFunctionKey && keyChar <= NSModeSwitchFunctionKey) {
-            switch (keyChar) {
-                case NSUpArrowFunctionKey:     return KeyEvent.VK_UP;
-                case NSDownArrowFunctionKey:   return KeyEvent.VK_DOWN;
-                case NSLeftArrowFunctionKey:   return KeyEvent.VK_LEFT;
-                case NSRightArrowFunctionKey:  return KeyEvent.VK_RIGHT;
-                case NSF1FunctionKey:          return KeyEvent.VK_F1;
-                case NSF2FunctionKey:          return KeyEvent.VK_F2;
-                case NSF3FunctionKey:          return KeyEvent.VK_F3;
-                case NSF4FunctionKey:          return KeyEvent.VK_F4;
-                case NSF5FunctionKey:          return KeyEvent.VK_F5;
-                case NSF6FunctionKey:          return KeyEvent.VK_F6;
-                case NSF7FunctionKey:          return KeyEvent.VK_F7;
-                case NSF8FunctionKey:          return KeyEvent.VK_F8;
-                case NSF9FunctionKey:          return KeyEvent.VK_F9;
-                case NSF10FunctionKey:         return KeyEvent.VK_F10;
-                case NSF11FunctionKey:         return KeyEvent.VK_F11;
-                case NSF12FunctionKey:         return KeyEvent.VK_F12;
-                case NSF13FunctionKey:         return KeyEvent.VK_F13;
-                case NSF14FunctionKey:         return KeyEvent.VK_F14;
-                case NSF15FunctionKey:         return KeyEvent.VK_F15;
-                case NSF16FunctionKey:         return KeyEvent.VK_F16;
-                case NSF17FunctionKey:         return KeyEvent.VK_F17;
-                case NSF18FunctionKey:         return KeyEvent.VK_F18;
-                case NSF19FunctionKey:         return KeyEvent.VK_F19;
-                case NSF20FunctionKey:         return KeyEvent.VK_F20;
-                case NSF21FunctionKey:         return KeyEvent.VK_F21;
-                case NSF22FunctionKey:         return KeyEvent.VK_F22;
-                case NSF23FunctionKey:         return KeyEvent.VK_F23;
-                case NSF24FunctionKey:         return KeyEvent.VK_F24;
-                case NSInsertFunctionKey:      return KeyEvent.VK_INSERT;
-                case NSDeleteFunctionKey:      return KeyEvent.VK_DELETE;
-                case NSHomeFunctionKey:        return KeyEvent.VK_HOME;
-                case NSBeginFunctionKey:       return KeyEvent.VK_BEGIN;
-                case NSEndFunctionKey:         return KeyEvent.VK_END;
-                case NSPageUpFunctionKey:      return KeyEvent.VK_PAGE_UP;
-                case NSPageDownFunctionKey:    return KeyEvent.VK_PAGE_DOWN;
-                case NSPrintScreenFunctionKey: return KeyEvent.VK_PRINTSCREEN;
-                case NSScrollLockFunctionKey:  return KeyEvent.VK_SCROLL_LOCK;
-                case NSPauseFunctionKey:       return KeyEvent.VK_PAUSE;
-                // Not handled:
-                // NSSysReqFunctionKey
-                // NSBreakFunctionKey
-                // NSResetFunctionKey
-                case NSStopFunctionKey:        return KeyEvent.VK_STOP;
-                // Not handled:
-                // NSMenuFunctionKey
-                // NSUserFunctionKey
-                // NSSystemFunctionKey
-                // NSPrintFunctionKey
-                // NSClearLineFunctionKey
-                // NSClearDisplayFunctionKey
-                // NSInsertLineFunctionKey
-                // NSDeleteLineFunctionKey
-                // NSInsertCharFunctionKey
-                // NSDeleteCharFunctionKey
-                // NSPrevFunctionKey
-                // NSNextFunctionKey
-                // NSSelectFunctionKey
-                // NSExecuteFunctionKey
-                // NSUndoFunctionKey
-                // NSRedoFunctionKey
-                // NSFindFunctionKey
-                // NSHelpFunctionKey
-                // NSModeSwitchFunctionKey
-                default: break;
+        super.sizeChanged(defer, newWidth, newHeight, force);
+    }
+    
+    @Override
+    protected void positionChanged(boolean defer, int newX, int newY) {        
+        // passed coordinates are in screen position of the client area
+        if(getWindowHandle()!=0) {
+            // screen position -> window position
+            Point absPos = new Point(newX, newY);            
+            final NativeWindow parent = getParent();
+            if(null != parent) {
+                absPos.translate( parent.getLocationOnScreen(null).scale(-1, -1) );
             }
+            super.positionChanged(defer, absPos.getX(), absPos.getY());
         }
-
-        // NSEvent's charactersIgnoringModifiers doesn't ignore the shift key
-        if (keyChar >= 'a' && keyChar <= 'z') {
-            return Character.toUpperCase(keyChar);
-        }
-
-        return keyChar;
+    }
+    
+    @Override
+    protected boolean setPointerVisibleImpl(final boolean pointerVisible) {
+        if( !isOffscreenInstance ) {                
+            return setPointerVisible0(getWindowHandle(), pointerVisible);
+        } // else may need offscreen solution ? FIXME
+        return false;
     }
 
     @Override
+    protected boolean confinePointerImpl(final boolean confine) {
+        if( !isOffscreenInstance ) {                
+            return confinePointer0(getWindowHandle(), confine);
+        } // else may need offscreen solution ? FIXME
+        return false;
+    }
+    
+    @Override
+    protected void warpPointerImpl(final int x, final int y) {
+        if( !isOffscreenInstance ) {                
+            warpPointer0(getWindowHandle(), x, y);
+        } // else may need offscreen solution ? FIXME
+    }
+    
+    @Override
+    public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) {
+        // Note that we send the key char for the key code on this
+        // platform -- we do not get any useful key codes out of the system
+        final int keyCode2 = MacKeyUtil.validateKeyCode(keyCode, keyChar);
+        if(DEBUG_IMPLEMENTATION) System.err.println("MacWindow.sendKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(keyCode)+" -> 0x"+Integer.toHexString(keyCode2));
+        // only deliver keyChar on key Typed events, harmonizing platform behavior
+        keyChar = KeyEvent.EVENT_KEY_TYPED == eventType ? keyChar : (char)-1;
+        super.sendKeyEvent(eventType, modifiers, keyCode2, keyChar);        
+    }
+    
+    @Override
     public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) {
-        int key = convertKeyChar(keyChar);
-        if(DEBUG_IMPLEMENTATION) System.err.println("MacWindow.enqueueKeyEvent "+Thread.currentThread().getName());
         // Note that we send the key char for the key code on this
         // platform -- we do not get any useful key codes out of the system
-        super.enqueueKeyEvent(wait, eventType, modifiers, key, keyChar);
+        final int keyCode2 = MacKeyUtil.validateKeyCode(keyCode, keyChar);
+        if(DEBUG_IMPLEMENTATION) System.err.println("MacWindow.enqueueKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(keyCode)+" -> 0x"+Integer.toHexString(keyCode2));
+        // only deliver keyChar on key Typed events, harmonizing platform behavior
+        keyChar = KeyEvent.EVENT_KEY_TYPED == eventType ? keyChar : (char)-1;
+        super.enqueueKeyEvent(wait, eventType, modifiers, keyCode2, keyChar);
     }
 
-    private void createWindow(final boolean recreate, 
-                              int x, int y, int width, int height, 
+    //----------------------------------------------------------------------
+    // Internals only
+    //    
+    
+    private void createWindow(final boolean offscreenInstance, final boolean recreate, 
+                              final PointImmutable pS, final int width, final int height, 
                               final boolean fullscreen) {
 
         if(0!=getWindowHandle() && !recreate) {
             return;
         }
 
-        x=(x>=0)?x:this.x;
-        y=(x>=0)?y:this.y;
-        width=(width>0)?width:this.width;
-        height=(height>0)?height:this.height;
-        
-        final NativeWindow parent = getParent();
-        if(null != parent) {
-            final Point p = parent.getLocationOnScreen(null);
-            x += p.getX();
-            y += p.getY();
-        }
-        
         try {
             if(0!=getWindowHandle()) {
                 // save the view .. close the window
@@ -396,44 +336,40 @@ public class MacWindow extends WindowImpl {
                 surfaceHandle = 0;
             }
             setWindowHandle(createWindow0(getParentWindowHandle(),
-                                         x, y, width, height,
-                                         config.getChosenCapabilities().isBackgroundOpaque(),
-                                         fullscreen,
-                                         (isUndecorated() ?
-                                         NSBorderlessWindowMask :
-                                         NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask),
-                                         NSBackingStoreBuffered, 
-                                         getScreen().getIndex(), surfaceHandle));
+                                 pS.getX(), pS.getY(), width, height,
+                                 (getGraphicsConfiguration().getChosenCapabilities().isBackgroundOpaque() && !offscreenInstance),
+                                 fullscreen,
+                                 ((isUndecorated() || offscreenInstance) ?
+                                   NSBorderlessWindowMask :
+                                   NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask),
+                                 NSBackingStoreBuffered, 
+                                 getScreen().getIndex(), surfaceHandle));
             if (getWindowHandle() == 0) {
                 throw new NativeWindowException("Could create native window "+Thread.currentThread().getName()+" "+this);
             }
             surfaceHandle = contentView0(getWindowHandle());
-            setTitle0(getWindowHandle(), getTitle());
-            makeKeyAndOrderFront0(getWindowHandle());
+            if( offscreenInstance ) {
+                orderOut0(0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle());
+            } else {
+                setTitle0(getWindowHandle(), getTitle());
+            }
         } catch (Exception ie) {
             ie.printStackTrace();
         }
     }
     
-    @Override
-    protected void positionChanged(boolean defer, int newX, int newY) {
-        final NativeWindow parent = getParent();
-        if(null != parent) {
-            final Point p = parent.getLocationOnScreen(null);
-            newX -= p.getX();
-            newY -= p.getY();
-        }
-        super.positionChanged(defer, newX, newY);
-    }
-    
     protected static native boolean initIDs0();
     private native long createWindow0(long parentWindowHandle, int x, int y, int w, int h,
                                      boolean opaque, boolean fullscreen, int windowStyle,
                                      int backingStoreType,
                                      int screen_idx, long view);
-    private native void makeKeyAndOrderFront0(long window);
-    private native void makeKey0(long window);
+    private native boolean lockSurface0(long window);
+    private native void unlockSurface0(long window);
+    private native void requestFocus0(long window, boolean force);
+    private native void requestFocusParent0(long window);
+    /** in case of a child window, it actually only issues orderBack(..) */
     private native void orderOut0(long window);
+    private native void orderFront0(long window);
     private native void close0(long window);
     private native void setTitle0(long window, String title);
     private native long contentView0(long window);
@@ -441,4 +377,25 @@ public class MacWindow extends WindowImpl {
     private native void setContentSize0(long window, int w, int h);
     private native void setFrameTopLeftPoint0(long parentWindowHandle, long window, int x, int y);
     private native void setAlwaysOnTop0(long window, boolean atop);
+    private static native Object getLocationOnScreen0(long windowHandle, int src_x, int src_y);
+    private static native boolean setPointerVisible0(long windowHandle, boolean visible);
+    private static native boolean confinePointer0(long windowHandle, boolean confine);
+    private static native void warpPointer0(long windowHandle, int x, int y);
+    
+    // Window styles
+    private static final int NSBorderlessWindowMask     = 0;
+    private static final int NSTitledWindowMask         = 1 << 0;
+    private static final int NSClosableWindowMask       = 1 << 1;
+    private static final int NSMiniaturizableWindowMask = 1 << 2;
+    private static final int NSResizableWindowMask      = 1 << 3;
+
+    // Window backing store types
+    private static final int NSBackingStoreRetained     = 0;
+    private static final int NSBackingStoreNonretained  = 1;
+    private static final int NSBackingStoreBuffered     = 2;
+
+    private volatile long surfaceHandle;
+    private long sscSurfaceHandle;
+    private boolean isOffscreenInstance;
+    
 }
diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java
index f2e457a..6566d72 100644
--- a/src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java
+++ b/src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java
@@ -32,13 +32,8 @@
  */
 package jogamp.newt.driver.windows;
 
-import com.jogamp.common.util.ArrayHashSet;
-import java.util.ArrayList;
-
-import com.jogamp.newt.*;
 import jogamp.newt.ScreenImpl;
 import com.jogamp.newt.ScreenMode;
-import jogamp.newt.ScreenModeStatus;
 import com.jogamp.newt.util.ScreenModeUtil;
 
 import javax.media.nativewindow.*;
diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java
index ee057fb..23206c2 100644
--- a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java
@@ -35,13 +35,20 @@
 package jogamp.newt.driver.windows;
 
 import jogamp.nativewindow.windows.GDI;
+import jogamp.nativewindow.windows.GDIUtil;
 import jogamp.newt.WindowImpl;
+
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
 import javax.media.nativewindow.GraphicsConfigurationFactory;
 import javax.media.nativewindow.NativeWindowException;
 import javax.media.nativewindow.util.Insets;
 import javax.media.nativewindow.util.InsetsImmutable;
 import javax.media.nativewindow.util.Point;
 
+import com.jogamp.newt.event.KeyEvent;
+import com.jogamp.newt.event.MouseAdapter;
+import com.jogamp.newt.event.MouseEvent;
+
 public class WindowsWindow extends WindowImpl {
 
     private long hmon;
@@ -97,13 +104,14 @@ public class WindowsWindow extends WindowImpl {
     }
 
     protected void createNativeImpl() {
-        WindowsScreen  screen = (WindowsScreen) getScreen();
-        WindowsDisplay display = (WindowsDisplay) screen.getDisplay();
-        config = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration(
+        final WindowsScreen  screen = (WindowsScreen) getScreen();
+        final WindowsDisplay display = (WindowsDisplay) screen.getDisplay();
+        final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration(
                 capsRequested, capsRequested, capabilitiesChooser, screen.getGraphicsScreen());
-        if (config == null) {
+        if (null == cfg) {
             throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
         }
+        setGraphicsConfiguration(cfg);
         final int flags = getReconfigureFlags(0, true) & 
                           ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ;
         setWindowHandle(CreateWindow0(display.getHInstance(), display.getWindowClassName(), display.getWindowClassName(),
@@ -112,6 +120,8 @@ public class WindowsWindow extends WindowImpl {
             throw new NativeWindowException("Error creating window");
         }
         windowHandleClose = getWindowHandle();
+        addMouseListener(new MouseTracker());
+        
         if(DEBUG_IMPLEMENTATION) {
             Exception e = new Exception("Info: Window new window handle "+Thread.currentThread().getName()+
                                         " (Parent HWND "+toHexString(getParentWindowHandle())+
@@ -119,6 +129,12 @@ public class WindowsWindow extends WindowImpl {
             e.printStackTrace();
         }
     }
+    
+    class MouseTracker extends MouseAdapter {
+        public void mouseEntered(MouseEvent e) {
+            WindowsWindow.trackPointerLeave0(WindowsWindow.this.getWindowHandle());
+        }
+    }
 
     protected void closeNativeImpl() {
         if (hdc != 0) {
@@ -188,14 +204,81 @@ public class WindowsWindow extends WindowImpl {
         setTitle0(getWindowHandle(), title);
     }
 
+    @Override
+    protected boolean setPointerVisibleImpl(final boolean pointerVisible) {
+        final Boolean[] res = new Boolean[] { Boolean.FALSE };
+        
+        this.runOnEDTIfAvail(true, new Runnable() {
+            public void run() {
+                res[0] = Boolean.valueOf(setPointerVisible0(getWindowHandle(), pointerVisible));
+            }
+        });
+        return res[0].booleanValue();
+    }
+
+    @Override
+    protected boolean confinePointerImpl(final boolean confine) {
+        final Boolean[] res = new Boolean[] { Boolean.FALSE };
+        
+        this.runOnEDTIfAvail(true, new Runnable() {
+            public void run() {
+                final Point p0 = getLocationOnScreenImpl(0, 0);
+                res[0] = Boolean.valueOf(confinePointer0(getWindowHandle(), confine, 
+                        p0.getX(), p0.getY(), p0.getX()+width, p0.getY()+height));
+            }
+        });
+        return res[0].booleanValue();
+    }
+    
+    @Override
+    protected void warpPointerImpl(final int x, final int y) {        
+        this.runOnEDTIfAvail(true, new Runnable() {
+            public void run() {
+                final Point sPos = getLocationOnScreenImpl(x, y);
+                warpPointer0(getWindowHandle(), sPos.getX(), sPos.getY());
+            }
+        });
+        return;
+    }
+        
     protected Point getLocationOnScreenImpl(int x, int y) {
-        return GDI.GetRelativeLocation( getWindowHandle(), 0 /*root win*/, x, y);
+        return GDIUtil.GetRelativeLocation( getWindowHandle(), 0 /*root win*/, x, y);
     }
 
     protected void updateInsetsImpl(Insets insets) {
         // nop - using event driven insetsChange(..)         
     }
     
+    private final int validateKeyCode(int eventType, int keyCode) {
+        switch(eventType) {
+            case KeyEvent.EVENT_KEY_PRESSED:
+                lastPressedKeyCode = keyCode;
+                break;
+            case KeyEvent.EVENT_KEY_TYPED:
+                if(-1==keyCode) {
+                    keyCode = lastPressedKeyCode;
+                }
+                lastPressedKeyCode = -1;
+                break;
+        }
+        return keyCode;
+    }
+    private int lastPressedKeyCode = 0;
+    
+    @Override
+    public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) {
+        // Note that we have to regenerate the keyCode for EVENT_KEY_TYPED on this platform
+        keyCode = validateKeyCode(eventType, keyCode);
+        super.sendKeyEvent(eventType, modifiers, keyCode, keyChar);        
+    }
+    
+    @Override
+    public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) {
+        // Note that we have to regenerate the keyCode for EVENT_KEY_TYPED on this platform
+        keyCode = validateKeyCode(eventType, keyCode);
+        super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar);
+    }
+    
     //----------------------------------------------------------------------
     // Internals only
     //
@@ -211,4 +294,8 @@ public class WindowsWindow extends WindowImpl {
     private static native void setTitle0(long windowHandle, String title);
     private native void requestFocus0(long windowHandle, boolean force);
 
+    private static native boolean setPointerVisible0(long windowHandle, boolean visible);
+    private static native boolean confinePointer0(long windowHandle, boolean grab, int l, int t, int r, int b);
+    private static native void warpPointer0(long windowHandle, int x, int y);    
+    private static native void trackPointerLeave0(long windowHandle);    
 }
diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Display.java b/src/newt/classes/jogamp/newt/driver/x11/X11Display.java
index b9a32c7..b3bc6e4 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/X11Display.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/X11Display.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
  * 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -33,10 +34,14 @@
 
 package jogamp.newt.driver.x11;
 
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.x11.*;
-import jogamp.newt.*;
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.nativewindow.x11.X11GraphicsDevice;
+
 import jogamp.nativewindow.x11.X11Util;
+import jogamp.newt.DisplayImpl;
+import jogamp.newt.NEWTJNILibLoader;
 
 public class X11Display extends DisplayImpl {
 
@@ -64,6 +69,20 @@ public class X11Display extends DisplayImpl {
         return X11Util.validateDisplayName(name, handle);
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * We use a private non-shared X11 Display instance for EDT window operations and one for exposed animation, eg. OpenGL.
+     * <p>
+     * In case {@link X11Util#HAS_XLOCKDISPLAY_BUG} and {@link X11Util#XINITTHREADS_ALWAYS_ENABLED}, 
+     * we use null locking. Even though this seems not to be rational, it gives most stable results on all platforms.
+     * </p>
+     * <p>
+     * Otherwise we use basic locking via the constructor {@link X11GraphicsDevice#X11GraphicsDevice(long, int, boolean)},
+     * since it is possible to share this device via {@link com.jogamp.newt.NewtFactory#createDisplay(String, boolean)}.
+     * </p> 
+     */
+    @SuppressWarnings("unused")
     protected void createNativeImpl() {
         long handle = X11Util.openDisplay(name);
         if( 0 == handle ) {
@@ -85,12 +104,11 @@ public class X11Display extends DisplayImpl {
             throw e;
         }
         
-        if(X11Util.XINITTHREADS_ALWAYS_ENABLED) {
-            // Hack: Force non X11Display locking, even w/ AWT and w/o isFirstUIActionOnProcess() 
-            aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, NativeWindowFactory.getNullToolkitLock());            
+        // see API doc above!
+        if(X11Util.XINITTHREADS_ALWAYS_ENABLED && X11Util.HAS_XLOCKDISPLAY_BUG) {
+            aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, NativeWindowFactory.getNullToolkitLock(), false);            
         } else {
-            // Proper: Use AWT/X11Display locking w/ AWT and X11Display locking only w/o isFirstUIActionOnProcess()
-            aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT);
+            aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, false);
         }
     }
 
diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java b/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java
index a673521..463c62e 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
  * 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -32,6 +33,7 @@
  */
 package jogamp.newt.driver.x11;
 
+import jogamp.nativewindow.x11.X11Util;
 import jogamp.newt.DisplayImpl;
 import jogamp.newt.ScreenImpl;
 import jogamp.newt.DisplayImpl.DisplayRunnable;
@@ -53,8 +55,8 @@ public class X11Screen extends ScreenImpl {
 
     protected void createNativeImpl() {
         // validate screen index
-        Long handle = (Long) display.runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() {
-            public Object run(long dpy) {        
+        Long handle = display.runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<Long>() {
+            public Long run(long dpy) {        
                 long handle = GetScreen0(dpy, screen_idx);
                 if(0 != handle) {
                     setScreenSize(getWidth0(dpy, screen_idx), getHeight0(dpy, screen_idx));
@@ -79,8 +81,8 @@ public class X11Screen extends ScreenImpl {
     private int nmode_number;
 
     protected int[] getScreenModeFirstImpl() {
-        return (int[]) runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() {
-            public Object run(long dpy) {
+        return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<int[]>() {
+            public int[] run(long dpy) {
                 // initialize iterators and static data
                 nrotations = getAvailableScreenModeRotations0(dpy, screen_idx);
                 if(null==nrotations || 0==nrotations.length) {
@@ -108,8 +110,8 @@ public class X11Screen extends ScreenImpl {
 
     protected int[] getScreenModeNextImpl() {
         // assemble: w x h x bpp x f x r        
-        return (int[]) runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() {
-            public Object run(long dpy) {
+        return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<int[]>() {
+            public int[] run(long dpy) {
                 /**
                 System.err.println("******** mode: "+nmode_number);
                 System.err.println("rot  "+nrotation_index);
@@ -172,8 +174,8 @@ public class X11Screen extends ScreenImpl {
     }
 
     protected ScreenMode getCurrentScreenModeImpl() {
-        return (ScreenMode) runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() {
-            public Object run(long dpy) {
+        return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<ScreenMode>() {
+            public ScreenMode run(long dpy) {
                 int resNumber = getNumScreenModeResolutions0(dpy, screen_idx);
                 if(0==resNumber) {
                     return null;
@@ -222,8 +224,8 @@ public class X11Screen extends ScreenImpl {
             throw new RuntimeException("ScreenMode not element of ScreenMode list: "+screenMode);
         }
         final long t0 = System.currentTimeMillis();
-        Boolean done = (Boolean) runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() {
-            public Object run(long dpy) {
+        boolean done = runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<Boolean>() {
+            public Boolean run(long dpy) {
                 boolean done = false;
                 int resNumber = getNumScreenModeResolutions0(dpy, screen_idx);
                 int resIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx);
@@ -243,37 +245,40 @@ public class X11Screen extends ScreenImpl {
                 }
                 return Boolean.valueOf(done);
             }            
-        });
+        }).booleanValue();
         
-        if(!done.booleanValue()) {
+        if(DEBUG || !done) {
             System.err.println("X11Screen.setCurrentScreenModeImpl: TO ("+SCREEN_MODE_CHANGE_TIMEOUT+") reached: "+
-                               (System.currentTimeMillis()-t0)+"ms");
+                               (System.currentTimeMillis()-t0)+"ms; Current: "+getCurrentScreenMode()+"; Desired: "+screenMode);
         }
-        return done.booleanValue();
+        return done;
     }
 
     //----------------------------------------------------------------------
     // Internals only
     //    
-    private final Object runWithLockedDisplayHandle(DisplayRunnable action) {
+    private final <T> T runWithLockedDisplayHandle(DisplayRunnable<T> action) {
         return display.runWithLockedDisplayHandle(action);
         // return runWithTempDisplayHandle(action);
+        // return runWithoutLock(action);
     }
     
-    /** just here for testing some X11 RANDR bugs .. etc ..
-    private final Object runWithTempDisplayHandle(DisplayRunnable action) {
-        long dpy = X11Util.openDisplay(null);
-        if(0 == dpy) {
+    private final <T> T runWithTempDisplayHandle(DisplayRunnable<T> action) {
+        final long displayHandle = X11Util.openDisplay(display.getName());        
+        if(0 == displayHandle) {
             throw new RuntimeException("null device");
         }
-        Object res;
+        T res;
         try {
-            res = action.run(dpy);
+            res = action.run(displayHandle);
         } finally {
-            X11Util.closeDisplay(dpy);
+            X11Util.closeDisplay(displayHandle);
         }
         return res;
-    } */
+    }
+    private final <T> T runWithoutLock(DisplayRunnable<T> action) {
+        return action.run(display.getHandle());
+    }
     
     private static native long GetScreen0(long dpy, int scrn_idx);
 
diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java
index dfb84f6..bfaf53f 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
  * 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -33,7 +34,7 @@
 
 package jogamp.newt.driver.x11;
 
-import jogamp.nativewindow.x11.X11Util;
+import jogamp.nativewindow.x11.X11Lib;
 import jogamp.newt.DisplayImpl;
 import jogamp.newt.DisplayImpl.DisplayRunnable;
 import jogamp.newt.WindowImpl;
@@ -43,9 +44,15 @@ import javax.media.nativewindow.util.Insets;
 import javax.media.nativewindow.util.InsetsImmutable;
 import javax.media.nativewindow.util.Point;
 
+import com.jogamp.newt.event.MouseEvent;
+
 public class X11Window extends WindowImpl {
     private static final String WINDOW_CLASS_NAME = "NewtWindow";
-
+    private static final int X11_WHEEL_ONE_UP_BUTTON = 4;
+    private static final int X11_WHEEL_ONE_DOWN_BUTTON = 5;
+    private static final int X11_WHEEL_TWO_UP_BUTTON = 6;
+    private static final int X11_WHEEL_TWO_DOWN_BUTTON = 7;
+    
     static {
         X11Display.initSingleton();
     }
@@ -57,16 +64,16 @@ public class X11Window extends WindowImpl {
         final X11Screen screen = (X11Screen) getScreen();
         final X11Display display = (X11Display) screen.getDisplay();
         final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice());
-        config = factory.chooseGraphicsConfiguration(
+        final X11GraphicsConfiguration cfg = (X11GraphicsConfiguration) factory.chooseGraphicsConfiguration(
                 capsRequested, capsRequested, capabilitiesChooser, screen.getGraphicsScreen());
         if(DEBUG_IMPLEMENTATION) {
-            System.err.println("X11Window.createNativeImpl() factory: "+factory+", chosen config: "+config);
+            System.err.println("X11Window.createNativeImpl() factory: "+factory+", chosen config: "+cfg);
         }        
-        if (config == null) {
+        if (null == cfg) {
             throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
         }
-        X11GraphicsConfiguration x11config = (X11GraphicsConfiguration) config;
-        final long visualID = x11config.getVisualID();
+        setGraphicsConfiguration(cfg);
+        final long visualID = cfg.getVisualID();
         final int flags = getReconfigureFlags(0, true) & 
                           ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ;        
         setWindowHandle(CreateWindow0(getParentWindowHandle(),
@@ -129,23 +136,93 @@ public class X11Window extends WindowImpl {
 
     @Override
     protected void setTitleImpl(final String title) {
-        runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() {
+        runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<Object>() {
             public Object run(long dpy) {
                 setTitle0(dpy, getWindowHandle(), title);
                 return null;
             }
         });
     }
+    
+    @Override
+    protected boolean setPointerVisibleImpl(final boolean pointerVisible) {
+        return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<Boolean>() {
+            public Boolean run(long dpy) {
+                return Boolean.valueOf(setPointerVisible0(getDisplayEDTHandle(), getWindowHandle(), pointerVisible));
+            }
+        }).booleanValue();
+    }
 
+    @Override
+    protected boolean confinePointerImpl(final boolean confine) {
+        return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<Boolean>() {
+            public Boolean run(long dpy) {
+                return Boolean.valueOf(confinePointer0(getDisplayEDTHandle(), getWindowHandle(), confine));
+            }
+        }).booleanValue();
+    }
+    
+    @Override
+    protected void warpPointerImpl(final int x, final int y) {
+        runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<Object>() {
+            public Object run(long dpy) {
+                warpPointer0(getDisplayEDTHandle(), getWindowHandle(), x, y);
+                return null;
+            }
+        });
+    }
+    
     protected Point getLocationOnScreenImpl(final int x, final int y) {
         // X11Util.GetRelativeLocation: locks display already !
-        return X11Util.GetRelativeLocation( getScreen().getDisplay().getHandle(), getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y);
+        return X11Lib.GetRelativeLocation( getScreen().getDisplay().getHandle(), getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y);
     }
 
     protected void updateInsetsImpl(Insets insets) {
         // nop - using event driven insetsChange(..)         
     }
     
+    protected void doMouseEvent(boolean enqueue, boolean wait, int eventType, int modifiers,
+                                int x, int y, int button, int rotation) {
+        switch(eventType) {
+            case MouseEvent.EVENT_MOUSE_PRESSED:
+                switch(button) {
+                    case X11_WHEEL_ONE_UP_BUTTON:
+                    case X11_WHEEL_ONE_DOWN_BUTTON:
+                    case X11_WHEEL_TWO_UP_BUTTON:
+                    case X11_WHEEL_TWO_DOWN_BUTTON:
+                        // ignore wheel pressed !
+                        return;
+                }
+                break;
+            case MouseEvent.EVENT_MOUSE_RELEASED:
+                switch(button) {
+                    case X11_WHEEL_ONE_UP_BUTTON:
+                        eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED;
+                        button = 1;
+                        rotation = 1;
+                        break;
+                    case X11_WHEEL_ONE_DOWN_BUTTON:
+                        eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED;
+                        button = 1;
+                        rotation = -1;
+                        break;
+                    case X11_WHEEL_TWO_UP_BUTTON:
+                        eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED;
+                        button = 2;
+                        rotation = 1;
+                        break;
+                    case X11_WHEEL_TWO_DOWN_BUTTON:
+                        eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED;
+                        button = 2;
+                        rotation = -1;
+                        break;
+                }                
+                break;
+        }
+        super.doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, rotation);        
+    }
+    
+    
     //----------------------------------------------------------------------
     // Internals only
     //
@@ -153,21 +230,26 @@ public class X11Window extends WindowImpl {
     private final long getDisplayEDTHandle() {
         return ((X11Display) getScreen().getDisplay()).getEDTHandle();
     }
-    private final Object runWithLockedDisplayHandle(DisplayRunnable action) {
+    private final <T> T runWithLockedDisplayHandle(DisplayRunnable<T> action) {
         return ((DisplayImpl) getScreen().getDisplay()).runWithLockedDisplayHandle(action);
         // return runWithTempDisplayHandle(action);
     }
 
     protected static native boolean initIDs0();
+    
     private native long CreateWindow0(long parentWindowHandle, long display, int screen_index, 
                                             long visualID, long javaObjectAtom, long windowDeleteAtom, 
                                             int x, int y, int width, int height, int flags); 
     private native void CloseWindow0(long display, long windowHandle, long javaObjectAtom, long windowDeleteAtom);
     private native void reconfigureWindow0(long display, int screen_index, long parentWindowHandle, long windowHandle,
                                            int x, int y, int width, int height, int flags);    
-    private native void setTitle0(long display, long windowHandle, String title);
     private native void requestFocus0(long display, long windowHandle, boolean force);
-    private native long getParentWindow0(long display, long windowHandle);
-
+    
+    private static native void setTitle0(long display, long windowHandle, String title);
+    private static native long getParentWindow0(long display, long windowHandle);
+    private static native boolean setPointerVisible0(long display, long windowHandle, boolean visible);
+    private static native boolean confinePointer0(long display, long windowHandle, boolean grab);
+    private static native void warpPointer0(long display, long windowHandle, int x, int y);
+    
     private long   windowHandleClose;
 }
diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m
index 335a1fd..e39ff03 100644
--- a/src/newt/native/MacWindow.m
+++ b/src/newt/native/MacWindow.m
@@ -43,6 +43,12 @@
 
 #import <stdio.h>
 
+static const char * const ClazzNamePoint = "javax/media/nativewindow/util/Point";
+static const char * const ClazzAnyCstrName = "<init>";
+static const char * const ClazzNamePointCstrSignature = "(II)V";
+static jclass pointClz = NULL;
+static jmethodID pointCstr = NULL;
+
 static NSString* jstringToNSString(JNIEnv* env, jstring jstr)
 {
     const jchar* jstrChars = (*env)->GetStringChars(env, jstr, NULL);
@@ -51,25 +57,34 @@ static NSString* jstringToNSString(JNIEnv* env, jstring jstr)
     return str;
 }
 
-static void setFrameTopLeftPoint(NSWindow* pWin, NSWindow* mWin, jint x, jint y) {
-    NSScreen* screen = [NSScreen mainScreen];
-    NSRect screenRect = [screen frame];
-
-    DBG_PRINT( "setFrameTopLeftPoint screen %lf/%lf %lfx%lf\n", 
-        screenRect.origin.x,
-        screenRect.origin.y,
-        screenRect.size.width,
-        screenRect.size.height);
+static void setFrameTopLeftPoint(NSWindow* pWin, NewtMacWindow* mWin, jint x, jint y) {
+    NSPoint pS = [mWin newtScreenWinPos2OSXScreenPos: NSMakePoint(x, y)];
+    [mWin setFrameOrigin: pS];
 
-    NSPoint pt = NSMakePoint(screenRect.origin.x + x, screenRect.origin.y + screenRect.size.height - y);
+    NSView* mView = [mWin contentView];
+    [mWin invalidateCursorRectsForView: mView];
+}
 
-    DBG_PRINT( "setFrameTopLeftPoint -> %lf/%lf\n", pt.x, pt.y);
-    [mWin setFrameTopLeftPoint: pt];
+#ifdef VERBOSE_ON
+static int getRetainCount(NSObject * obj) {
+    return ( NULL == obj ) ? -1 : (int)([obj retainCount]) ;
 }
+#endif
 
-static NewtView * changeContentView(JNIEnv *env, jobject javaWindowObject, NSWindow *pwin, NSView *pview, NSWindow *win, NewtView *newView) {
+static void changeContentView(JNIEnv *env, jobject javaWindowObject, NSView *pview, NewtMacWindow *win, NewtView *newView) {
+    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
     NSView* oldNSView = [win contentView];
     NewtView* oldView = NULL;
+#ifdef VERBOSE_ON
+    int dbgIdx = 1;
+#endif
+
+    if( [oldNSView isMemberOfClass:[NewtView class]] ) {
+        oldView = (NewtView *) oldNSView;
+    }
+
+    DBG_PRINT( "changeContentView.%d win %p, view (%p,%d (%d) -> %p,%d), parent view %p\n", 
+        dbgIdx++, win, oldNSView, getRetainCount(oldNSView), NULL!=oldView, newView, getRetainCount(newView), pview);
 
     if(NULL!=oldNSView) {
 NS_DURING
@@ -79,19 +94,20 @@ NS_DURING
         }
 NS_HANDLER
 NS_ENDHANDLER
-        if( [oldNSView isMemberOfClass:[NewtView class]] ) {
-            oldView = (NewtView *) oldNSView;
+        DBG_PRINT( "changeContentView.%d win %p, view (%p,%d (%d) -> %p,%d)\n", 
+            dbgIdx++, win, oldNSView, getRetainCount(oldNSView), NULL!=oldView, newView, getRetainCount(newView));
 
+        if( NULL != oldView ) {
             jobject globJavaWindowObject = [oldView getJavaWindowObject];
             (*env)->DeleteGlobalRef(env, globJavaWindowObject);
             [oldView setJavaWindowObject: NULL];
             [oldView setDestroyNotifySent: false];
         }
-        /** FIXME: Tried child window: auto clip or message reception ..
-        if(NULL!=pwin) {
-            [oldView removeFromSuperview];
-        } */
+        [oldNSView removeFromSuperviewWithoutNeedingDisplay];
     }
+    DBG_PRINT( "changeContentView.%d win %p, view (%p,%d -> %p,%d), isHidden %d, isHiddenOrHasHiddenAncestor: %d\n", 
+        dbgIdx++, win, oldNSView, getRetainCount(oldNSView), newView, getRetainCount(newView), [newView isHidden], [newView isHiddenOrHasHiddenAncestor]);
+
     if(NULL!=newView) {
         jobject globJavaWindowObject = (*env)->NewGlobalRef(env, javaWindowObject);
         [newView setJavaWindowObject: globJavaWindowObject];
@@ -109,18 +125,28 @@ NS_ENDHANDLER
             [newView setJVMVersion: jvmVersion];
         }
 
-        /** FIXME: Tried child window: auto clip or message reception ..
-        if(NULL!=pwin) {
+        DBG_PRINT( "changeContentView.%d win %p, view (%p,%d -> %p,%d)\n", 
+            dbgIdx++, win, oldNSView, getRetainCount(oldNSView), newView, getRetainCount(newView));
+
+        if(NULL!=pview) {
             [pview addSubview: newView positioned: NSWindowAbove relativeTo: nil];
-        } */
+        }
     }
+    DBG_PRINT( "changeContentView.%d win %p, view (%p,%d -> %p,%d), isHidden %d, isHiddenOrHasHiddenAncestor: %d\n", 
+        dbgIdx++, win, oldNSView, getRetainCount(oldNSView), newView, getRetainCount(newView), [newView isHidden], [newView isHiddenOrHasHiddenAncestor]);
+
     [win setContentView: newView];
 
+    DBG_PRINT( "changeContentView.%d win %p, view (%p,%d -> %p,%d), isHidden %d, isHiddenOrHasHiddenAncestor: %d\n", 
+        dbgIdx++, win, oldNSView, getRetainCount(oldNSView), newView, getRetainCount(newView), [newView isHidden], [newView isHiddenOrHasHiddenAncestor]);
+
     // make sure the insets are updated in the java object
-    NewtMacWindow* newtw = (NewtMacWindow*)win;
-    [newtw updateInsets: env];
+    [win updateInsets: env];
+
+    DBG_PRINT( "changeContentView.X win %p, view (%p,%d -> %p,%d)\n", 
+        win, oldNSView, getRetainCount(oldNSView), newView, getRetainCount(newView));
 
-    return oldView;
+    [pool release];
 }
 
 /*
@@ -165,13 +191,50 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacDisplay_initNSAppli
 JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacDisplay_runNSApplication0
   (JNIEnv *env, jclass clazz)
 {
-    // NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
     DBG_PRINT( "\nrunNSApplication0.0\n");
 
     [NSApp run];
 
     DBG_PRINT( "\nrunNSApplication0.X\n");
-    // [pool release];
+    [pool release];
+}
+
+/*
+ * Class:     jogamp_newt_driver_macosx_MacDisplay
+ * Method:    stopNSApplication0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacDisplay_stopNSApplication0
+  (JNIEnv *env, jclass clazz)
+{
+    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+    DBG_PRINT( "\nstopNSApplication0.0 nsApp.running %d\n", (NSApp && [NSApp isRunning]));
+
+    if(NSApp && [NSApp isRunning]) {
+        [NSApp performSelectorOnMainThread:@selector(stop:) withObject:nil waitUntilDone:YES];
+        // [NSApp stop: nil];
+        NSEvent* event = [NSEvent otherEventWithType: NSApplicationDefined
+                                            location: NSMakePoint(0,0)
+                                       modifierFlags: 0
+                                           timestamp: 0.0
+                                        windowNumber: 0
+                                             context: nil
+                                             subtype: 0
+                                               data1: 0
+                                               data2: 0];
+        DBG_PRINT( "\nstopNSApplication0.1\n");
+        [NSApp postEvent: event atStart: true];
+    }
+    /**
+    DBG_PRINT( "\nstopNSApplication0.2\n");
+    if(NSApp && [NSApp isRunning]) {
+        DBG_PRINT( "\nstopNSApplication0.3\n");
+        [NSApp terminate:nil];
+    } */
+
+    DBG_PRINT( "\nstopNSApplication0.X\n");
+    [pool release];
 }
 
 /*
@@ -229,6 +292,22 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_initIDs0
     if(initialized) return JNI_TRUE;
     initialized = 1;
 
+    jclass c;
+    c = (*env)->FindClass(env, ClazzNamePoint);
+    if(NULL==c) {
+        NewtCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't find %s", ClazzNamePoint);
+    }
+    pointClz = (jclass)(*env)->NewGlobalRef(env, c);
+    (*env)->DeleteLocalRef(env, c);
+    if(NULL==pointClz) {
+        NewtCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't use %s", ClazzNamePoint);
+    }
+    pointCstr = (*env)->GetMethodID(env, pointClz, ClazzAnyCstrName, ClazzNamePointCstrSignature);
+    if(NULL==pointCstr) {
+        NewtCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't fetch %s.%s %s",
+            ClazzNamePoint, ClazzAnyCstrName, ClazzNamePointCstrSignature);
+    }
+
     // Need this when debugging, as it is necessary to attach gdb to
     // the running java process -- "gdb java" doesn't work
     //    printf("Going to sleep for 10 seconds\n");
@@ -271,18 +350,21 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_createWindow0
     }
 
     // Allocate the window
-    NSWindow* myWindow = [[[NewtMacWindow alloc] initWithContentRect: rect
+    NewtMacWindow* myWindow = [[NewtMacWindow alloc] initWithContentRect: rect
                                                styleMask: (NSUInteger) styleMask
                                                backing: (NSBackingStoreType) bufferingType
-                                               screen: myScreen] retain];
+                                               defer: NO
+                                               screen: myScreen];
+    [myWindow setReleasedWhenClosed: YES]; // default
+    [myWindow setPreservesContentDuringLiveResize: NO];
 
-    NSObject *nsParentObj = (NSObject*) ((intptr_t) parent);
+    NSObject* nsParentObj = (NSObject*) ((intptr_t) parent);
     NSWindow* parentWindow = NULL;
     NSView* parentView = NULL;
     if( nsParentObj != NULL && [nsParentObj isKindOfClass:[NSWindow class]] ) {
         parentWindow = (NSWindow*) nsParentObj;
         parentView = [parentWindow contentView];
-        DBG_PRINT( "createWindow0 - Parent is NSWindow : %p (view) -> %p (win) \n", parentView, parentWindow);
+        DBG_PRINT( "createWindow0 - Parent is NSWindow : %p (win) -> %p (view) \n", parentWindow, parentView);
     } else if( nsParentObj != NULL && [nsParentObj isKindOfClass:[NSView class]] ) {
         parentView = (NSView*) nsParentObj;
         parentWindow = [parentView window];
@@ -290,13 +372,18 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_createWindow0
     } else {
         DBG_PRINT( "createWindow0 - Parent is neither NSWindow nor NSView : %p\n", nsParentObj);
     }
-    if(NULL!=parentWindow) {
-        [parentWindow addChildWindow: myWindow ordered: NSWindowAbove];
-        [myWindow setParentWindow: parentWindow];
-    }
+    DBG_PRINT( "createWindow0 - is visible.1: %d\n", [myWindow isVisible]);
 
+#ifdef VERBOSE_ON
+    int dbgIdx = 1;
+#endif
     if(opaque) {
         [myWindow setOpaque: YES];
+        DBG_PRINT( "createWindow0.%d\n", dbgIdx++);
+        if (!fullscreen) {
+            [myWindow setShowsResizeIndicator: YES];
+        }
+        DBG_PRINT( "createWindow0.%d\n", dbgIdx++);
     } else {
         [myWindow setOpaque: NO];
         [myWindow setBackgroundColor: [NSColor clearColor]];
@@ -304,19 +391,43 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_createWindow0
 
     // specify we want mouse-moved events
     [myWindow setAcceptsMouseMovedEvents:YES];
+    DBG_PRINT( "createWindow0.%d\n", dbgIdx++);
 
     // Use given NewtView or allocate an NewtView if NULL
     if(NULL == myView) {
         myView = [[NewtView alloc] initWithFrame: rect] ;
-        DBG_PRINT( "createWindow0 - new own view: %p\n", myView);
+        DBG_PRINT( "createWindow0.%d - use new view: %p,%d\n", dbgIdx++, myView, getRetainCount(myView));
+    } else {
+        DBG_PRINT( "createWindow0.%d - use given view: %p,%d\n", dbgIdx++, myView, getRetainCount(myView));
     }
 
+    DBG_PRINT( "createWindow0.%d - %p,%d view %p,%d, isVisible %d\n", 
+        dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]);
+
     // Set the content view
-    (void) changeContentView(env, jthis, parentWindow, parentView, myWindow, myView);
+    changeContentView(env, jthis, parentView, myWindow, myView);
+
+    DBG_PRINT( "createWindow0.%d - %p,%d view %p,%d, isVisible %d\n", 
+        dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]);
+
+    if(NULL!=parentWindow) {
+        [myWindow attachToParent: parentWindow];
+    }
 
     // Immediately re-position the window based on an upper-left coordinate system
     setFrameTopLeftPoint(parentWindow, myWindow, x, y);
 
+    // force surface creation
+    [myView lockFocus];
+    [myView unlockFocus];
+
+    // concurrent view rendering
+    [myWindow setAllowsConcurrentViewDrawing: YES];
+    [myView setCanDrawConcurrently: YES];
+
+    // visible on front
+    [myWindow orderFront: myWindow];
+
 NS_DURING
     // Available >= 10.5 - Makes the menubar disapear
     if(fullscreen) {
@@ -329,104 +440,191 @@ NS_ENDHANDLER
     // right mouse button down events
     [myView setNextResponder: myWindow];
 
-    DBG_PRINT( "createWindow0 - %p (this), %p (parent): new window: %p (END)\n",
-        (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow);
+    DBG_PRINT( "createWindow0 - %p (this), %p (parent): new window: %p, view %p,%d (END)\n",
+        (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView, getRetainCount(myView));
 
     [pool release];
 
     return (jlong) ((intptr_t) myWindow);
 }
+// Footnote: Our view handling produces random 'Assertion failure' even w/o parenting:
+//
+// [NSThemeFrame lockFocus], /SourceCache/AppKit/AppKit-1138.23/AppKit.subproj/NSView.m:6053
+// [NSThemeFrame(0x7fe94bc72c80) lockFocus] failed with window=0x7fe94bc445a0, windowNumber=9425, [self isHiddenOrHasHiddenAncestor]=0
+//                       ..
+// AppKit                0x00007fff89621001 -[NSView lockFocus] + 250
+// AppKit                0x00007fff8961eafa -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 3780
+// AppKit                0x00007fff8961793e -[NSView displayIfNeeded] + 1676
+// AppKit                0x00007fff8961707d _handleWindowNeedsDisplayOrLayoutOrUpdateConstraints + 648
+//                       
+
 
 /*
  * Class:     jogamp_newt_driver_macosx_MacWindow
- * Method:    makeKeyAndOrderFront
+ * Method:    close0
  * Signature: (J)V
  */
-JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_makeKeyAndOrderFront0
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_close0
   (JNIEnv *env, jobject unused, jlong window)
 {
     NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
-    NSWindow* win = (NSWindow*) ((intptr_t) window);
+    NewtMacWindow* mWin = (NewtMacWindow*) ((intptr_t) window);
+    NewtView* mView = (NewtView *)[mWin contentView];
+    NSWindow* pWin = [mWin parentWindow];
+    DBG_PRINT( "windowClose.0 - %p,%d view %p,%d, parent %p\n", 
+        mWin, getRetainCount(mWin), mView, getRetainCount(mView), pWin);
+
+NS_DURING
+    if(NULL!=mView) {
+        // Available >= 10.5 - Makes the menubar disapear
+        if([mView isInFullScreenMode]) {
+            [mView exitFullScreenModeWithOptions: NULL];
+        }
+        [mWin setContentView: nil];
+        [mView release];
+    }
+NS_HANDLER
+NS_ENDHANDLER
 
-    DBG_PRINT( "makeKeyAndOrderFront0 - window: %p (START)\n", win);
+    if(NULL!=pWin) {
+        [mWin detachFromParent: pWin];
+    }
+    [mWin orderOut: mWin];
 
-    // [win performSelectorOnMainThread:@selector(makeKeyAndOrderFront:) withObject:win waitUntilDone:NO];
-    [win makeKeyAndOrderFront: win];
+    DBG_PRINT( "windowClose.1 - %p,%d view %p,%d, parent %p\n", 
+        mWin, getRetainCount(mWin), mView, getRetainCount(mView), pWin);
 
-    DBG_PRINT( "makeKeyAndOrderFront0 - window: %p (END)\n", win);
+    [mWin close]; // performs release!
+
+    DBG_PRINT( "windowClose.X - %p,%d view %p,%d, parent %p\n", 
+        mWin, getRetainCount(mWin), mView, getRetainCount(mView), pWin);
 
     [pool release];
 }
 
 /*
- * Class:     jogamp_newt_driver_macosx_MacWindow
- * Method:    makeKey
+ * Class:     Java_jogamp_newt_driver_macosx_MacWindow
+ * Method:    lockSurface0
+ * Signature: (J)Z
+ */
+JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_lockSurface0
+  (JNIEnv *env, jclass clazz, jlong window)
+{
+    NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window);
+    NewtView * mView = (NewtView *) [mWin contentView];
+    return [mView softLock] == YES ? JNI_TRUE : JNI_FALSE;
+    /** deadlocks, since we render independent of focus
+    return [mView lockFocusIfCanDraw] == YES ? JNI_TRUE : JNI_FALSE; */
+}
+
+/*
+ * Class:     Java_jogamp_newt_driver_macosx_MacWindow
+ * Method:    unlockSurface0
  * Signature: (J)V
  */
-JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_makeKey0
-  (JNIEnv *env, jobject unused, jlong window)
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_unlockSurface0
+  (JNIEnv *env, jclass clazz, jlong window)
+{
+    NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window);
+    NewtView * mView = (NewtView *) [mWin contentView];
+    [mView softUnlock];
+    /** deadlocks, since we render independent of focus
+    [mView unlockFocus]; */
+}
+
+/*
+ * Class:     jogamp_newt_driver_macosx_MacWindow
+ * Method:    requestFocus0
+ * Signature: (JZ)V
+ */
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_requestFocus0
+  (JNIEnv *env, jobject window, jlong w, jboolean force)
 {
     NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
-    NSWindow* win = (NSWindow*) ((intptr_t) window);
+    NSWindow* mWin = (NSWindow*) ((intptr_t) w);
+#ifdef VERBOSE_ON
+    BOOL hasFocus = [mWin isKeyWindow];
+#endif
 
-    DBG_PRINT( "makeKey0 - window: %p (START)\n", win);
+    DBG_PRINT( "requestFocus - window: %p, force %d, hasFocus %d (START)\n", mWin, force, hasFocus);
 
-    // [win performSelectorOnMainThread:@selector(makeKeyWindow:) withObject:nil waitUntilDone:NO];
-    [win makeKeyWindow];
+    [mWin makeFirstResponder: nil];
+    // [mWin performSelectorOnMainThread:@selector(orderFrontRegardless) withObject:nil waitUntilDone:YES];
+    // [mWin performSelectorOnMainThread:@selector(makeKeyWindow) withObject:nil waitUntilDone:YES];
+    [mWin orderFrontRegardless];
+    [mWin makeKeyWindow];
 
-    DBG_PRINT( "makeKey0 - window: %p (END)\n", win);
+    DBG_PRINT( "requestFocus - window: %p, force %d (END)\n", mWin, force);
 
     [pool release];
 }
 
 /*
  * Class:     jogamp_newt_driver_macosx_MacWindow
- * Method:    orderOut
+ * Method:    requestFocusParent0
  * Signature: (J)V
  */
-JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_orderOut0
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_requestFocusParent0
+  (JNIEnv *env, jobject window, jlong w)
+{
+    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+    NSWindow* mWin = (NSWindow*) ((intptr_t) w);
+    NSWindow* pWin = [mWin parentWindow];
+#ifdef VERBOSE_ON
+    BOOL hasFocus = [mWin isKeyWindow];
+#endif
+
+    DBG_PRINT( "requestFocusParent0 - window: %p, parent: %p, hasFocus %d (START)\n", mWin, pWin, hasFocus );
+    if(NULL != pWin) {
+        [pWin makeKeyWindow];
+    }
+    DBG_PRINT( "requestFocusParent0 - window: %p, parent: %p (END)\n", mWin, pWin);
+
+    [pool release];
+}
+
+/*
+ * Class:     jogamp_newt_driver_macosx_MacWindow
+ * Method:    orderFront0
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_orderFront0
   (JNIEnv *env, jobject unused, jlong window)
 {
     NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
     NSWindow* win = (NSWindow*) ((intptr_t) window);
 
-    DBG_PRINT( "orderOut0 - window: %p (START)\n", win);
+    DBG_PRINT( "orderFront0 - window: %p (START)\n", win);
 
-    // [win performSelectorOnMainThread:@selector(orderOut:) withObject:win waitUntilDone:NO];
-    [win orderOut: win];
+    [win orderFrontRegardless];
 
-    DBG_PRINT( "orderOut0 - window: %p (END)\n", win);
+    DBG_PRINT( "orderFront0 - window: %p (END)\n", win);
 
     [pool release];
 }
 
 /*
  * Class:     jogamp_newt_driver_macosx_MacWindow
- * Method:    close0
+ * Method:    orderOut
  * Signature: (J)V
  */
-JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_close0
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_orderOut0
   (JNIEnv *env, jobject unused, jlong window)
 {
     NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
-    NSWindow* win = (NSWindow*) ((intptr_t) window);
-    NSView* view = [win contentView];
-    DBG_PRINT( "*************** windowClose.0: 0x%p\n", (void *)win);
-NS_DURING
-    if(NULL!=view) {
-        // Available >= 10.5 - Makes the menubar disapear
-        if([view isInFullScreenMode]) {
-            [view exitFullScreenModeWithOptions: NULL];
-        }
+    NSWindow* mWin = (NSWindow*) ((intptr_t) window);
+    NSWindow* pWin = [mWin parentWindow];
+
+    DBG_PRINT( "orderOut0 - window: (parent %p) %p (START)\n", pWin, mWin);
+
+    if(NULL == pWin) {
+        [mWin orderOut: mWin];
+    } else {
+        [mWin orderBack: mWin];
     }
-NS_HANDLER
-NS_ENDHANDLER
-    DBG_PRINT( "*************** windowClose.2: 0x%p\n", (void *)win);
 
-    [win performSelectorOnMainThread:@selector(close:) withObject:nil waitUntilDone:NO];
-    // [win close]
+    DBG_PRINT( "orderOut0 - window: (parent %p) %p (END)\n", pWin, mWin);
 
-    DBG_PRINT( "*************** windowClose.X: 0x%p\n", (void *)win);
     [pool release];
 }
 
@@ -445,8 +643,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setTitle0
 
     NSString* str = jstringToNSString(env, title);
     [str autorelease];
-    [win performSelectorOnMainThread:@selector(setTitle:) withObject:str waitUntilDone:NO];
-    // [win setTitle: str];
+    [win setTitle: str];
 
     DBG_PRINT( "setTitle0 - window: %p (END)\n", win);
 
@@ -484,27 +681,33 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_changeContentVi
 {
     NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
 
-    NSWindow* win = (NewtMacWindow*) ((intptr_t) window);
     NewtView* newView = (NewtView *) ((intptr_t) jview);
+    NewtMacWindow* win = (NewtMacWindow*) ((intptr_t) window);
+    NSView* oldNSView = [win contentView];
+    NewtView* oldView = NULL;
+
+    if( [oldNSView isMemberOfClass:[NewtView class]] ) {
+        oldView = (NewtView *) oldNSView;
+    }
 
-    DBG_PRINT( "changeContentView0 - window: %p (START)\n", win);
+    DBG_PRINT( "changeContentView0.0 -  win %p, view (%p,%d (%d) -> %p,%d)\n", 
+        win, oldNSView, getRetainCount(oldNSView), NULL!=oldView, newView, getRetainCount(newView));
 
     NSObject *nsParentObj = (NSObject*) ((intptr_t) parentWindowOrView);
-    NSWindow* pWin = NULL;
     NSView* pView = NULL;
     if( NULL != nsParentObj ) {
         if( [nsParentObj isKindOfClass:[NSWindow class]] ) {
-            pWin = (NSWindow*) nsParentObj;
+            NSWindow * pWin = (NSWindow*) nsParentObj;
             pView = [pWin contentView];
         } else if( [nsParentObj isKindOfClass:[NSView class]] ) {
             pView = (NSView*) nsParentObj;
-            pWin = [pView window];
         }
     }
 
-    NewtView* oldView = changeContentView(env, jthis, pWin, pView, win, newView);
+    changeContentView(env, jthis, pView, win, newView);
 
-    DBG_PRINT( "changeContentView0 - window: %p (END)\n", win);
+    DBG_PRINT( "changeContentView0.X -  win %p, view (%p,%d (%d) -> %p,%d)\n", 
+        win, oldNSView, getRetainCount(oldNSView), NULL!=oldView, newView, getRetainCount(newView));
 
     [pool release];
 
@@ -541,14 +744,22 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setFrameTopLeftP
   (JNIEnv *env, jobject unused, jlong parent, jlong window, jint x, jint y)
 {
     NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
-    NSWindow* pwin = (NSWindow*) ((intptr_t) parent);
-    NSWindow* win = (NSWindow*) ((intptr_t) window);
+    NewtMacWindow* mWin = (NewtMacWindow*) ((intptr_t) window);
 
-    DBG_PRINT( "setFrameTopLeftPoint0 - window: %p (START)\n", win);
+    NSObject *nsParentObj = (NSObject*) ((intptr_t) parent);
+    NSWindow* pWin = NULL;
+    if( nsParentObj != NULL && [nsParentObj isKindOfClass:[NSWindow class]] ) {
+        pWin = (NSWindow*) nsParentObj;
+    } else if( nsParentObj != NULL && [nsParentObj isKindOfClass:[NSView class]] ) {
+        NSView* pView = (NSView*) nsParentObj;
+        pWin = [pView window];
+    }
 
-    setFrameTopLeftPoint(pwin, win, x, y);
+    DBG_PRINT( "setFrameTopLeftPoint0 - window: %p, parent %p (START)\n", mWin, pWin);
 
-    DBG_PRINT( "setFrameTopLeftPoint0 - window: %p (END)\n", win);
+    setFrameTopLeftPoint(pWin, mWin, x, y);
+
+    DBG_PRINT( "setFrameTopLeftPoint0 - window: %p, parent %p (END)\n", mWin, pWin);
 
     [pool release];
 }
@@ -577,3 +788,62 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setAlwaysOnTop0
     [pool release];
 }
 
+/*
+ * Class:     jogamp_newt_driver_macosx_MacWindow
+ * Method:    getLocationOnScreen0
+ * Signature: (JII)Ljavax/media/nativewindow/util/Point;
+ */
+JNIEXPORT jobject JNICALL Java_jogamp_newt_driver_macosx_MacWindow_getLocationOnScreen0
+  (JNIEnv *env, jclass unused, jlong win, jint src_x, jint src_y)
+{
+    NSObject *nsObj = (NSObject*) ((intptr_t) win);
+    NewtMacWindow * mWin = NULL;
+
+    if( [nsObj isKindOfClass:[NewtMacWindow class]] ) {
+        mWin = (NewtMacWindow*) nsObj;
+    } else {
+        NewtCommon_throwNewRuntimeException(env, "not NewtMacWindow %p\n", nsObj);
+    }
+
+    NSPoint p0 = [mWin getLocationOnScreen: NSMakePoint(src_x, src_y)];
+    return (*env)->NewObject(env, pointClz, pointCstr, (jint)p0.x, (jint)p0.y);
+}
+
+/*
+ * Class:     Java_jogamp_newt_driver_macosx_MacWindow
+ * Method:    setPointerVisible0
+ * Signature: (JZ)Z
+ */
+JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setPointerVisible0
+  (JNIEnv *env, jclass clazz, jlong window, jboolean mouseVisible)
+{
+    NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window);
+    [mWin setMouseVisible: ( JNI_TRUE == mouseVisible ) ? YES : NO];
+    return JNI_TRUE;
+}
+
+/*
+ * Class:     Java_jogamp_newt_driver_macosx_MacWindow
+ * Method:    confinePointer0
+ * Signature: (JZ)Z
+ */
+JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_confinePointer0
+  (JNIEnv *env, jclass clazz, jlong window, jboolean confine)
+{
+    NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window);
+    [mWin setMouseConfined: ( JNI_TRUE == confine ) ? YES : NO];
+    return JNI_TRUE;
+}
+
+/*
+ * Class:     Java_jogamp_newt_driver_macosx_MacWindow
+ * Method:    warpPointer0
+ * Signature: (JJII)V
+ */
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_warpPointer0
+  (JNIEnv *env, jclass clazz, jlong window, jint x, jint y)
+{
+    NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window);
+    [mWin setMousePosition: [mWin newtClientWinPos2OSXScreenPos: NSMakePoint(x, y)]];
+}
+
diff --git a/src/newt/native/NewtMacWindow.h b/src/newt/native/NewtMacWindow.h
index 5c465d4..eaece2c 100644
--- a/src/newt/native/NewtMacWindow.h
+++ b/src/newt/native/NewtMacWindow.h
@@ -32,14 +32,16 @@
  */
 
 #import <AppKit/AppKit.h>
+#import <pthread.h>
 #import "jni.h"
 
 #include "NewtCommon.h"
 
-#define VERBOSE_ON 1
+// #define VERBOSE_ON 1
 
 #ifdef VERBOSE_ON
-    #define DBG_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr) 
+    #define DBG_PRINT(...) NSLog(@ __VA_ARGS__)
+    // #define DBG_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr)
 #else
     #define DBG_PRINT(...)
 #endif
@@ -52,9 +54,18 @@
     JavaVM *jvmHandle;
     int jvmVersion;
 
-    BOOL destroyNotifySent;
+    volatile BOOL destroyNotifySent;
+    volatile BOOL softLocked;
+    pthread_mutex_t softLockSync;
+
+    NSTrackingRectTag ptrTrackingTag;
+    NSRect ptrRect;
+    NSCursor * myCursor;
 }
 
+- (id)initWithFrame:(NSRect)frameRect;
+- (void) dealloc;
+
 /* Set during event dispatching cycle */
 - (void) setJVMHandle: (JavaVM*) vm;
 - (JavaVM*) getJVMHandle;
@@ -66,10 +77,23 @@
 - (void) setJavaWindowObject: (jobject) javaWindowObj;
 - (jobject) getJavaWindowObject;
 
+- (void) rightMouseDown: (NSEvent*) theEvent;
+- (void) resetCursorRects;
+- (NSCursor *) cursor;
+
 - (void) setDestroyNotifySent: (BOOL) v;
 - (BOOL) getDestroyNotifySent;
 
-- (void) rightMouseDown: (NSEvent*) theEvent;
+- (BOOL) softLock;
+- (void) softUnlock;
+
+- (BOOL) needsDisplay;
+- (void) displayIfNeeded;
+- (void) display;
+- (void) drawRect:(NSRect)dirtyRect;
+- (void) viewDidHide;
+- (void) viewDidUnhide;
+- (BOOL) acceptsFirstResponder;
 
 @end
 
@@ -79,15 +103,43 @@
 @interface NewtMacWindow : NSWindow 
 #endif
 {
+    BOOL mouseConfined;
+    BOOL mouseVisible;
+    BOOL mouseInside;
+    BOOL cursorIsHidden;
+    NSPoint lastInsideMousePosition;
+ at public
+    int cachedInsets[4]; // l, r, t, b
 }
 
 + (BOOL) initNatives: (JNIEnv*) env forClass: (jobject) clazz;
 
-- (void) updateInsets: (JNIEnv*) env;
-
 - (id) initWithContentRect: (NSRect) contentRect
        styleMask: (NSUInteger) windowStyle
        backing: (NSBackingStoreType) bufferingType
+       defer: (BOOL) deferCreation
        screen:(NSScreen *)screen;
 
+- (void) updateInsets: (JNIEnv*) env;
+- (void) attachToParent: (NSWindow*) parent;
+- (void) detachFromParent: (NSWindow*) parent;
+
+- (NSPoint) newtScreenWinPos2OSXScreenPos: (NSPoint) p;
+- (NSPoint) newtClientWinPos2OSXScreenPos: (NSPoint) p;
+- (NSPoint) getLocationOnScreen: (NSPoint) p;
+- (NSPoint) screenPos2NewtClientWinPos: (NSPoint) p;
+
+- (void) cursorHide:(BOOL)v;
+- (void) setMouseVisible:(BOOL)v;
+- (void) setMouseConfined:(BOOL)v;
+- (void) setMousePosition:(NSPoint)p;
+
+- (BOOL) becomeFirstResponder;
+- (BOOL) resignFirstResponder;
+- (void) becomeKeyWindow;
+- (void) resignKeyWindow;
+- (void) windowDidBecomeKey: (NSNotification *) notification;
+- (void) windowDidResignKey: (NSNotification *) notification;
+- (void) focusChanged: (BOOL) gained;
+
 @end
diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m
index eb1426d..ce41673 100644
--- a/src/newt/native/NewtMacWindow.m
+++ b/src/newt/native/NewtMacWindow.m
@@ -44,15 +44,17 @@ jint GetDeltaY(NSEvent *event, jint javaMods) {
         // mouse pad case
         deltaY =
             CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventPointDeltaAxis1);
+        // fprintf(stderr, "WHEEL/PAD: %lf\n", (double)deltaY);
     } else {
         // traditional mouse wheel case
         deltaY = [event deltaY];
+        // fprintf(stderr, "WHEEL/TRAD: %lf\n", (double)deltaY);
         if (deltaY == 0.0 && (javaMods & EVENT_SHIFT_MASK) != 0) {
             // shift+vertical wheel scroll produces horizontal scroll
             // we convert it to vertical
             deltaY = [event deltaX];
         }
-        if (deltaY < 1.0  && deltaY > -1.0) {
+        if (-1.0 < deltaY && deltaY < 1.0) {
             deltaY *= 10.0;
         } else {
             if (deltaY < 0.0) {
@@ -62,19 +64,15 @@ jint GetDeltaY(NSEvent *event, jint javaMods) {
             }
         }
     }
-
-    if (deltaY > 0) {
-        return (NSInteger)deltaY;
-    } else if (deltaY < 0) {
-        return -(NSInteger)deltaY;
-    }
-
-    return 0;
+    // fprintf(stderr, "WHEEL/res: %d\n", (int)deltaY);
+    return (jint) deltaY;
 }
 
 static jmethodID enqueueMouseEventID = NULL;
+static jmethodID sendMouseEventID = NULL;
 static jmethodID enqueueKeyEventID = NULL;
-static jmethodID enqueueRequestFocusID = NULL;
+static jmethodID sendKeyEventID = NULL;
+static jmethodID requestFocusID = NULL;
 
 static jmethodID insetsChangedID   = NULL;
 static jmethodID sizeChangedID     = NULL;
@@ -82,9 +80,54 @@ static jmethodID visibleChangedID = NULL;
 static jmethodID positionChangedID = NULL;
 static jmethodID focusChangedID    = NULL;
 static jmethodID windowDestroyNotifyID = NULL;
+static jmethodID windowRepaintID = NULL;
+
+// Can't use USE_SENDIO_DIRECT, ie w/o enqueueing to EDT,
+// since we may operate on AWT-AppKit (Main Thread)
+// and direct issuing 'requestFocus()' would deadlock:
+//     AWT-AppKit
+//     AWT-EventQueue-0
+//
+// #define USE_SENDIO_DIRECT 1
 
 @implementation NewtView
 
+- (id)initWithFrame:(NSRect)frameRect
+{
+    javaWindowObject = NULL;
+
+    jvmHandle = NULL;
+    jvmVersion = 0;
+    destroyNotifySent = NO;
+    softLocked = NO;
+
+    pthread_mutexattr_t softLockSyncAttr;
+    pthread_mutexattr_init(&softLockSyncAttr);
+    pthread_mutexattr_settype(&softLockSyncAttr, PTHREAD_MUTEX_RECURSIVE);
+    pthread_mutex_init(&softLockSync, &softLockSyncAttr); // recursive
+
+    ptrTrackingTag = 0;
+
+    /**
+    NSCursor crs = [NSCursor arrowCursor];
+    NSImage crsImg = [crs image];
+    NSPoint crsHot = [crs hotSpot];
+    myCursor = [[NSCursor alloc] initWithImage: crsImg hotSpot:crsHot];
+    */
+    myCursor = NULL;
+
+    return [super initWithFrame:frameRect];
+}
+
+- (void) dealloc
+{
+    if(softLocked) {
+        NSLog(@"NewtView::dealloc: softLock still hold @ dealloc!\n");
+    }
+    pthread_mutex_destroy(&softLockSync);
+    [super dealloc];
+}
+
 - (void) setJVMHandle: (JavaVM*) vm
 {
     jvmHandle = vm;
@@ -114,6 +157,32 @@ static jmethodID windowDestroyNotifyID = NULL;
     return javaWindowObject;
 }
 
+- (void) rightMouseDown: (NSEvent*) theEvent
+{
+    NSResponder* next = [self nextResponder];
+    if (next != nil) {
+        [next rightMouseDown: theEvent];
+    }
+}
+
+- (void) resetCursorRects
+{
+    [super resetCursorRects];
+
+    if(0 != ptrTrackingTag) {
+        // [self removeCursorRect: ptrRect cursor: myCursor];
+        [self removeTrackingRect: ptrTrackingTag];
+    }
+    ptrRect = [self bounds]; 
+    // [self addCursorRect: ptrRect cursor: myCursor];
+    ptrTrackingTag = [self addTrackingRect: ptrRect owner: self userData: nil assumeInside: NO];
+}
+
+- (NSCursor *) cursor
+{
+    return myCursor;
+}
+
 - (void) setDestroyNotifySent: (BOOL) v
 {
     destroyNotifySent = v;
@@ -124,30 +193,79 @@ static jmethodID windowDestroyNotifyID = NULL;
     return destroyNotifySent;
 }
 
-- (void) rightMouseDown: (NSEvent*) theEvent
+- (BOOL) softLock
 {
-    NSResponder* next = [self nextResponder];
-    if (next != nil) {
-        [next rightMouseDown: theEvent];
+    // DBG_PRINT("*************** softLock.0: %p\n", (void*)pthread_self());
+    // NSLog(@"NewtView::softLock: %@",[NSThread callStackSymbols]);
+    pthread_mutex_lock(&softLockSync);
+    softLocked = YES;
+    // DBG_PRINT("*************** softLock.X: %p\n", (void*)pthread_self());
+    return softLocked;
+}
+
+- (void) softUnlock
+{
+    // DBG_PRINT("*************** softUnlock: %p\n", (void*)pthread_self());
+    softLocked = NO;
+    pthread_mutex_unlock(&softLockSync);
+}
+
+- (BOOL) needsDisplay
+{
+    return NO == destroyNotifySent && [super needsDisplay];
+}
+
+- (void) displayIfNeeded
+{
+    if( YES == [self needsDisplay] ) {
+        [self softLock];
+        [super displayIfNeeded];
+        [self softUnlock];
     }
 }
 
-- (void)viewWillDraw
+- (void) display
 {
-    DBG_PRINT("*************** viewWillDraw: 0x%p\n", javaWindowObject);
-    [super viewWillDraw];
+    if( NO == destroyNotifySent ) {
+        [self softLock];
+        [super display];
+        [self softUnlock];
+    }
 }
 
-- (void)viewDidHide
+- (void) drawRect:(NSRect)dirtyRect
 {
+    DBG_PRINT("*************** dirtyRect: %p %lf/%lf %lfx%lf\n", 
+        javaWindowObject, dirtyRect.origin.x, dirtyRect.origin.y, dirtyRect.size.width, dirtyRect.size.height);
+
     int shallBeDetached = 0;
     JNIEnv* env = NewtCommon_GetJNIEnv(jvmHandle, jvmVersion, &shallBeDetached);
     if(NULL==env) {
-        NSLog(@"viewDidHide: null JNIEnv");
+        DBG_PRINT("viewDidHide: null JNIEnv\n");
         return;
     }
 
-    (*env)->CallVoidMethod(env, javaWindowObject, visibleChangedID, JNI_TRUE, JNI_FALSE);
+    NSRect viewFrame = [self frame];
+
+    (*env)->CallVoidMethod(env, javaWindowObject, windowRepaintID, JNI_TRUE, // defer ..
+        dirtyRect.origin.x, viewFrame.size.height - dirtyRect.origin.y, 
+        dirtyRect.size.width, dirtyRect.size.height);
+
+    if (shallBeDetached) {
+        (*jvmHandle)->DetachCurrentThread(jvmHandle);
+    }
+}
+
+- (void) viewDidHide
+{
+    int shallBeDetached = 0;
+    JNIEnv* env = NewtCommon_GetJNIEnv(jvmHandle, jvmVersion, &shallBeDetached);
+    if(NULL==env) {
+        DBG_PRINT("viewDidHide: null JNIEnv\n");
+        return;
+    }
+
+    (*env)->CallVoidMethod(env, javaWindowObject, visibleChangedID, JNI_FALSE, JNI_FALSE);
 
     if (shallBeDetached) {
         (*jvmHandle)->DetachCurrentThread(jvmHandle);
@@ -156,16 +274,16 @@ static jmethodID windowDestroyNotifyID = NULL;
     [super viewDidHide];
 }
 
-- (void)viewDidUnhide
+- (void) viewDidUnhide
 {
     int shallBeDetached = 0;
     JNIEnv* env = NewtCommon_GetJNIEnv(jvmHandle, jvmVersion, &shallBeDetached);
     if(NULL==env) {
-        NSLog(@"viewDidHide: null JNIEnv");
+        DBG_PRINT("viewDidHide: null JNIEnv\n");
         return;
     }
 
-    (*env)->CallVoidMethod(env, javaWindowObject, visibleChangedID, JNI_TRUE, JNI_TRUE);
+    (*env)->CallVoidMethod(env, javaWindowObject, visibleChangedID, JNI_FALSE, JNI_TRUE);
 
     if (shallBeDetached) {
         (*jvmHandle)->DetachCurrentThread(jvmHandle);
@@ -174,6 +292,11 @@ static jmethodID windowDestroyNotifyID = NULL;
     [super viewDidUnhide];
 }
 
+- (BOOL) acceptsFirstResponder 
+{
+    return YES;
+}
+
 @end
 
 @implementation NewtMacWindow
@@ -181,22 +304,50 @@ static jmethodID windowDestroyNotifyID = NULL;
 + (BOOL) initNatives: (JNIEnv*) env forClass: (jclass) clazz
 {
     enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIII)V");
+    sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V");
     enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZIIIC)V");
-    sizeChangedID     = (*env)->GetMethodID(env, clazz, "sizeChanged",     "(ZIIZ)V");
+    sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V");
+    sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged",     "(ZIIZ)V");
     visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V");
-    insetsChangedID     = (*env)->GetMethodID(env, clazz, "insetsChanged", "(ZIIII)V");
+    insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(ZIIII)V");
     positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(ZII)V");
     focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(ZZ)V");
     windowDestroyNotifyID    = (*env)->GetMethodID(env, clazz, "windowDestroyNotify",    "()V");
-    enqueueRequestFocusID = (*env)->GetMethodID(env, clazz, "enqueueRequestFocus", "(Z)V");
-    if (enqueueMouseEventID && enqueueKeyEventID && sizeChangedID && visibleChangedID && insetsChangedID &&
-        positionChangedID && focusChangedID && windowDestroyNotifyID && enqueueRequestFocusID)
+    windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(ZIIII)V");
+    requestFocusID = (*env)->GetMethodID(env, clazz, "requestFocus", "(Z)V");
+    if (enqueueMouseEventID && sendMouseEventID && enqueueKeyEventID && sendKeyEventID && sizeChangedID && visibleChangedID && insetsChangedID &&
+        positionChangedID && focusChangedID && windowDestroyNotifyID && requestFocusID && windowRepaintID)
     {
         return YES;
     }
     return NO;
 }
 
+- (id) initWithContentRect: (NSRect) contentRect
+       styleMask: (NSUInteger) windowStyle
+       backing: (NSBackingStoreType) bufferingType
+       defer: (BOOL) deferCreation
+       screen:(NSScreen *)screen
+{
+    id res = [super initWithContentRect: contentRect
+                    styleMask: windowStyle
+                    backing: bufferingType
+                    defer: deferCreation
+                    screen: screen];
+    // Why is this necessary? Without it we don't get any of the
+    // delegate methods like resizing and window movement.
+    [self setDelegate: self];
+    cachedInsets[0] = 0; // l
+    cachedInsets[1] = 0; // r
+    cachedInsets[2] = 0; // t
+    cachedInsets[3] = 0; // b
+    mouseConfined = NO;
+    mouseVisible = YES;
+    mouseInside = NO;
+    cursorIsHidden = NO;
+    return res;
+}
+
 - (void) updateInsets: (JNIEnv*) env
 {
     NSView* nsview = [self contentView];
@@ -215,30 +366,105 @@ static jmethodID windowDestroyNotifyID = NULL;
     // note: this is a simplistic implementation which doesn't take
     // into account DPI and scaling factor
     CGFloat l = contentRect.origin.x - frameRect.origin.x;
-    jint top = (jint)(frameRect.size.height - contentRect.size.height);
-    jint left = (jint)l;
-    jint bottom = (jint)(contentRect.origin.y - frameRect.origin.y);
-    jint right = (jint)(frameRect.size.width - (contentRect.size.width + l));
+    cachedInsets[0] = (int)l;                                                     // l
+    cachedInsets[1] = (int)(frameRect.size.width - (contentRect.size.width + l)); // r
+    cachedInsets[2] = (jint)(frameRect.size.height - contentRect.size.height);    // t
+    cachedInsets[3] = (jint)(contentRect.origin.y - frameRect.origin.y);          // b
 
-    DBG_PRINT( "updateInsets: [ l %d, r %d, t %d, b %d ]\n", (int)left, (int)right, (int)top, (int)bottom);
+    DBG_PRINT( "updateInsets: [ l %d, r %d, t %d, b %d ]\n", cachedInsets[0], cachedInsets[1], cachedInsets[2], cachedInsets[3]);
 
-    (*env)->CallVoidMethod(env, javaWindowObject, insetsChangedID, JNI_TRUE, left, right, top, bottom);
+    (*env)->CallVoidMethod(env, javaWindowObject, insetsChangedID, JNI_FALSE, cachedInsets[0], cachedInsets[1], cachedInsets[2], cachedInsets[3]);
 }
 
-- (id) initWithContentRect: (NSRect) contentRect
-       styleMask: (NSUInteger) windowStyle
-       backing: (NSBackingStoreType) bufferingType
-       screen:(NSScreen *)screen
+- (void) attachToParent: (NSWindow*) parent
 {
-    id res = [super initWithContentRect: contentRect
-                    styleMask: windowStyle
-                    backing: bufferingType
-                    defer: YES
-                    screen: screen];
-    // Why is this necessary? Without it we don't get any of the
-    // delegate methods like resizing and window movement.
-    [self setDelegate: self];
-    return res;
+    DBG_PRINT( "attachToParent.1\n");
+    [parent addChildWindow: self ordered: NSWindowAbove];
+    DBG_PRINT( "attachToParent.2\n");
+    [self setParentWindow: parent];
+    DBG_PRINT( "attachToParent.X\n");
+}
+
+- (void) detachFromParent: (NSWindow*) parent
+{
+    DBG_PRINT( "detachFromParent.1\n");
+    [self setParentWindow: nil];
+    DBG_PRINT( "detachFromParent.2\n");
+    [parent removeChildWindow: self];
+    DBG_PRINT( "detachFromParent.X\n");
+}
+
+/**
+ * p abs screen position w/ top-left origin
+ * returns: abs screen position w/ bottom-left origin
+ */
+- (NSPoint) newtScreenWinPos2OSXScreenPos: (NSPoint) p
+{
+    NSView* mView = [self contentView];
+    NSRect mViewFrame = [mView frame]; 
+    int totalHeight = mViewFrame.size.height + cachedInsets[2] + cachedInsets[3]; // height + insets[top+bottom]
+
+    NSScreen* screen = [self screen];
+    NSRect screenFrame = [screen frame];
+
+    return NSMakePoint(screenFrame.origin.x + p.x + cachedInsets[0],
+                       screenFrame.origin.y + screenFrame.size.height - p.y - totalHeight);
+}
+
+/**
+ * p rel client window position w/ top-left origin
+ * returns: abs screen position w/ bottom-left origin
+ */
+- (NSPoint) newtClientWinPos2OSXScreenPos: (NSPoint) p
+{
+    NSRect winFrame = [self frame];
+
+    NSView* mView = [self contentView];
+    NSRect mViewFrame = [mView frame]; 
+
+    return NSMakePoint(winFrame.origin.x + p.x,
+                       winFrame.origin.y + ( mViewFrame.size.height - p.y ) ); // y-flip in view
+}
+
+/**
+ * y-flips input / output
+ * p rel client window position w/ top-left origin
+ * returns: location in 0/0 top-left space.
+ */
+- (NSPoint) getLocationOnScreen: (NSPoint) p
+{
+    NSScreen* screen = [self screen];
+    NSRect screenRect = [screen frame];
+
+    NSView* view = [self contentView];
+    NSRect viewFrame = [view frame];
+
+    NSRect r;
+    r.origin.x = p.x;
+    r.origin.y = viewFrame.size.height - p.y; // y-flip
+    r.size.width = 0;
+    r.size.height = 0;
+    // NSRect rS = [win convertRectToScreen: r]; // 10.7
+    NSPoint oS = [self convertBaseToScreen: r.origin];
+    oS.y = screenRect.origin.y + screenRect.size.height - oS.y;
+    return oS;
+}
+
+- (NSPoint) screenPos2NewtClientWinPos: (NSPoint) p
+{
+    NSView* view = [self contentView];
+    NSRect viewFrame = [view frame];
+
+    NSRect r;
+    r.origin.x = p.x;
+    r.origin.y = p.y;
+    r.size.width = 0;
+    r.size.height = 0;
+    // NSRect rS = [win convertRectFromScreen: r]; // 10.7
+    NSPoint oS = [self convertScreenToBase: r.origin];
+    oS.y = viewFrame.size.height - oS.y; // y-flip
+
+    return oS;
 }
 
 - (BOOL) canBecomeKeyWindow
@@ -275,14 +501,14 @@ static jint mods2JavaMods(NSUInteger mods)
     NewtView* view = (NewtView *) nsview;
     jobject javaWindowObject = [view getJavaWindowObject];
     if (javaWindowObject == NULL) {
-        NSLog(@"sendKeyEvent: null javaWindowObject");
+        DBG_PRINT("sendKeyEvent: null javaWindowObject\n");
         return;
     }
     int shallBeDetached = 0;
     JavaVM *jvmHandle = [view getJVMHandle];
     JNIEnv* env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], &shallBeDetached);
     if(NULL==env) {
-        NSLog(@"sendKeyEvent: null JNIEnv");
+        DBG_PRINT("sendKeyEvent: null JNIEnv\n");
         return;
     }
 
@@ -296,8 +522,15 @@ static jint mods2JavaMods(NSUInteger mods)
         // Note: the key code in the NSEvent does not map to anything we can use
         jchar keyChar = (jchar) [chars characterAtIndex: i];
 
+        DBG_PRINT("sendKeyEvent: %d/%d char 0x%X, code 0x%X\n", i, len, (int)keyChar, (int)keyCode);
+
+        #ifdef USE_SENDIO_DIRECT
+        (*env)->CallVoidMethod(env, javaWindowObject, sendKeyEventID,
+                               evType, javaMods, keyCode, keyChar);
+        #else
         (*env)->CallVoidMethod(env, javaWindowObject, enqueueKeyEventID, JNI_FALSE,
                                evType, javaMods, keyCode, keyChar);
+        #endif
     }
 
     if (shallBeDetached) {
@@ -325,27 +558,17 @@ static jint mods2JavaMods(NSUInteger mods)
     NewtView* view = (NewtView *) nsview;
     jobject javaWindowObject = [view getJavaWindowObject];
     if (javaWindowObject == NULL) {
-        NSLog(@"sendMouseEvent: null javaWindowObject");
+        DBG_PRINT("sendMouseEvent: null javaWindowObject\n");
         return;
     }
     int shallBeDetached = 0;
     JavaVM *jvmHandle = [view getJVMHandle];
     JNIEnv* env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], &shallBeDetached);
     if(NULL==env) {
-        NSLog(@"sendMouseEvent: null JNIEnv");
+        DBG_PRINT("sendMouseEvent: null JNIEnv\n");
         return;
     }
-
     jint javaMods = mods2JavaMods([event modifierFlags]);
-    NSRect frameRect = [self frame];
-    NSRect contentRect = [self contentRectForFrameRect: frameRect];
-    // NSPoint location = [event locationInWindow];
-    // The following computation improves the behavior of mouse drag
-    // events when they also affect the location of the window, but it
-    // still isn't perfect
-    NSPoint curLocation = [NSEvent mouseLocation];
-    NSPoint location = NSMakePoint(curLocation.x - frameRect.origin.x,
-                                   curLocation.y - frameRect.origin.y);
 
     // convert to 1-based button number (or use zero if no button is involved)
     // TODO: detect mouse button when mouse wheel scrolled  
@@ -354,6 +577,7 @@ static jint mods2JavaMods(NSUInteger mods)
     switch ([event type]) {
     case NSScrollWheel: {
         scrollDeltaY = GetDeltaY(event, javaMods);
+        javaButtonNum = 1;
         break;
     }
     case NSLeftMouseDown:
@@ -371,9 +595,6 @@ static jint mods2JavaMods(NSUInteger mods)
     case NSOtherMouseDragged:
         javaButtonNum = 2;
         break;
-    default:
-        javaButtonNum = 0;
-        break;
     }
 
     if (evType == EVENT_MOUSE_WHEEL_MOVED && scrollDeltaY == 0) {
@@ -381,31 +602,95 @@ static jint mods2JavaMods(NSUInteger mods)
         return;
     }
     if (evType == EVENT_MOUSE_PRESSED) {
-        (*env)->CallVoidMethod(env, javaWindowObject, enqueueRequestFocusID, JNI_FALSE);
+        (*env)->CallVoidMethod(env, javaWindowObject, requestFocusID, JNI_FALSE);
     }
+
+    NSPoint location = [self screenPos2NewtClientWinPos: [NSEvent mouseLocation]];
+
+    #ifdef USE_SENDIO_DIRECT
+    (*env)->CallVoidMethod(env, javaWindowObject, sendMouseEventID,
+                           evType, javaMods,
+                           (jint) location.x, (jint) location.y,
+                           javaButtonNum, scrollDeltaY);
+    #else
     (*env)->CallVoidMethod(env, javaWindowObject, enqueueMouseEventID, JNI_FALSE,
                            evType, javaMods,
-                           (jint) location.x,
-                           (jint) (contentRect.size.height - location.y),
+                           (jint) location.x, (jint) location.y,
                            javaButtonNum, scrollDeltaY);
+    #endif
 
     if (shallBeDetached) {
         (*jvmHandle)->DetachCurrentThread(jvmHandle);
     }
 }
 
+- (void) setMouseVisible:(BOOL)v
+{
+    mouseVisible = v;
+    DBG_PRINT( "setMouseVisible: confined %d, visible %d\n", mouseConfined, mouseVisible);
+    if(YES == mouseInside) {
+        [self cursorHide: !mouseVisible];
+    }
+}
+
+- (void) cursorHide:(BOOL)v
+{
+    if(v) {
+        if(!cursorIsHidden) {
+            [NSCursor hide];
+            cursorIsHidden = YES;
+        }
+    } else {
+        if(cursorIsHidden) {
+            [NSCursor unhide];
+            cursorIsHidden = NO;
+        }
+    }
+}
+
+- (void) setMouseConfined:(BOOL)v
+{
+    mouseConfined = v;
+    DBG_PRINT( "setMouseConfined: confined %d, visible %d\n", mouseConfined, mouseVisible);
+}
+
+- (void) setMousePosition:(NSPoint)p
+{
+    NSScreen* screen = [self screen];
+    NSRect screenRect = [screen frame];
+
+    CGPoint pt = { p.x, screenRect.size.height - p.y }; // y-flip (CG is top-left origin)
+    CGEventRef ev = CGEventCreateMouseEvent (NULL, kCGEventMouseMoved, pt, kCGMouseButtonLeft);
+    CGEventPost (kCGHIDEventTap, ev);
+    NSPoint l0 = [NSEvent mouseLocation];
+    [self screenPos2NewtClientWinPos: l0];
+}
+
 - (void) mouseEntered: (NSEvent*) theEvent
 {
-    [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_ENTERED];
+    DBG_PRINT( "mouseEntered: confined %d, visible %d\n", mouseConfined, mouseVisible);
+    mouseInside = YES;
+    [self setMouseVisible: mouseVisible];
+    if(NO == mouseConfined) {
+        [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_ENTERED];
+    }
 }
 
 - (void) mouseExited: (NSEvent*) theEvent
 {
-    [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_EXITED];
+    DBG_PRINT( "mouseExited: confined %d, visible %d\n", mouseConfined, mouseVisible);
+    if(NO == mouseConfined) {
+        mouseInside = NO;
+        [self cursorHide: NO];
+        [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_EXITED];
+    } else {
+        [self setMousePosition: lastInsideMousePosition];
+    }
 }
 
 - (void) mouseMoved: (NSEvent*) theEvent
 {
+    lastInsideMousePosition = [NSEvent mouseLocation];
     [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED];
 }
 
@@ -421,6 +706,7 @@ static jint mods2JavaMods(NSUInteger mods)
 
 - (void) mouseDragged: (NSEvent*) theEvent
 {
+    lastInsideMousePosition = [NSEvent mouseLocation];
     // Note use of MOUSE_MOVED event type because mouse dragged events are synthesized by Java
     [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED];
 }
@@ -437,6 +723,7 @@ static jint mods2JavaMods(NSUInteger mods)
 
 - (void) rightMouseDragged: (NSEvent*) theEvent
 {
+    lastInsideMousePosition = [NSEvent mouseLocation];
     // Note use of MOUSE_MOVED event type because mouse dragged events are synthesized by Java
     [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED];
 }
@@ -453,6 +740,7 @@ static jint mods2JavaMods(NSUInteger mods)
 
 - (void) otherMouseDragged: (NSEvent*) theEvent
 {
+    lastInsideMousePosition = [NSEvent mouseLocation];
     // Note use of MOUSE_MOVED event type because mouse dragged events are synthesized by Java
     [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED];
 }
@@ -471,14 +759,14 @@ static jint mods2JavaMods(NSUInteger mods)
     NewtView* view = (NewtView *) nsview;
     jobject javaWindowObject = [view getJavaWindowObject];
     if (javaWindowObject == NULL) {
-        NSLog(@"windowDidResize: null javaWindowObject");
+        DBG_PRINT("windowDidResize: null javaWindowObject\n");
         return;
     }
     int shallBeDetached = 0;
     JavaVM *jvmHandle = [view getJVMHandle];
     JNIEnv* env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], &shallBeDetached);
     if(NULL==env) {
-        NSLog(@"windowDidResize: null JNIEnv");
+        DBG_PRINT("windowDidResize: null JNIEnv\n");
         return;
     }
 
@@ -488,7 +776,7 @@ static jint mods2JavaMods(NSUInteger mods)
     NSRect frameRect = [self frame];
     NSRect contentRect = [self contentRectForFrameRect: frameRect];
 
-    (*env)->CallVoidMethod(env, javaWindowObject, sizeChangedID, JNI_TRUE,
+    (*env)->CallVoidMethod(env, javaWindowObject, sizeChangedID, JNI_FALSE,
                            (jint) contentRect.size.width,
                            (jint) contentRect.size.height, JNI_FALSE);
 
@@ -506,28 +794,20 @@ static jint mods2JavaMods(NSUInteger mods)
     NewtView* view = (NewtView *) nsview;
     jobject javaWindowObject = [view getJavaWindowObject];
     if (javaWindowObject == NULL) {
-        NSLog(@"windowDidMove: null javaWindowObject");
+        DBG_PRINT("windowDidMove: null javaWindowObject\n");
         return;
     }
     int shallBeDetached = 0;
     JavaVM *jvmHandle = [view getJVMHandle];
     JNIEnv* env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], &shallBeDetached);
     if(NULL==env) {
-        NSLog(@"windowDidMove: null JNIEnv");
+        DBG_PRINT("windowDidMove: null JNIEnv\n");
         return;
     }
 
-    NSRect rect = [self frame];
-    NSScreen* screen = NULL;
-    NSRect screenRect;
-    NSPoint pt;
-
-    screen = [self screen];
-    // this allows for better compatibility with awt behavior
-    screenRect = [screen frame];
-    pt = NSMakePoint(rect.origin.x, screenRect.origin.y + screenRect.size.height - rect.origin.y - rect.size.height);
-
-    (*env)->CallVoidMethod(env, javaWindowObject, positionChangedID, JNI_TRUE, (jint) pt.x, (jint) pt.y);
+    NSPoint p0 = { 0, 0 };
+    p0 = [self getLocationOnScreen: p0];
+    (*env)->CallVoidMethod(env, javaWindowObject, positionChangedID, JNI_FALSE, (jint) p0.x, (jint) p0.y);
 
     if (shallBeDetached) {
         (*jvmHandle)->DetachCurrentThread(jvmHandle);
@@ -538,6 +818,8 @@ static jint mods2JavaMods(NSUInteger mods)
 {
     NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
 
+    [self cursorHide: NO];
+
     NSView* nsview = [self contentView];
     if( ! [nsview isMemberOfClass:[NewtView class]] ) {
         return;
@@ -546,16 +828,16 @@ static jint mods2JavaMods(NSUInteger mods)
 
     if( false == [view getDestroyNotifySent] ) {
         jobject javaWindowObject = [view getJavaWindowObject];
-        DBG_PRINT( "*************** windowWillClose.0: 0x%p\n", (void *)(intptr_t)javaWindowObject);
+        DBG_PRINT( "*************** windowWillClose.0: %p\n", (void *)(intptr_t)javaWindowObject);
         if (javaWindowObject == NULL) {
-            NSLog(@"windowWillClose: null javaWindowObject");
+            DBG_PRINT("windowWillClose: null javaWindowObject\n");
             return;
         }
         int shallBeDetached = 0;
         JavaVM *jvmHandle = [view getJVMHandle];
         JNIEnv* env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], &shallBeDetached);
         if(NULL==env) {
-            NSLog(@"windowWillClose: null JNIEnv");
+            DBG_PRINT("windowWillClose: null JNIEnv\n");
             return;
         }
 
@@ -570,42 +852,52 @@ static jint mods2JavaMods(NSUInteger mods)
         if (shallBeDetached) {
             (*jvmHandle)->DetachCurrentThread(jvmHandle);
         }
-        DBG_PRINT( "*************** windowWillClose.X: 0x%p\n", (void *)(intptr_t)javaWindowObject);
+        DBG_PRINT( "*************** windowWillClose.X: %p\n", (void *)(intptr_t)javaWindowObject);
     } else {
         DBG_PRINT( "*************** windowWillClose (skip)\n");
     }
     [pool release];
 }
 
-- (void) windowDidBecomeKey: (NSNotification *) notification
+- (BOOL) becomeFirstResponder
 {
-    NSView* nsview = [self contentView];
-    if( ! [nsview isMemberOfClass:[NewtView class]] ) {
-        return;
-    }
-    NewtView* view = (NewtView *) nsview;
-    jobject javaWindowObject = [view getJavaWindowObject];
-    if (javaWindowObject == NULL) {
-        NSLog(@"windowDidBecomeKey: null javaWindowObject");
-        return;
-    }
-    int shallBeDetached = 0;
-    JavaVM *jvmHandle = [view getJVMHandle];
-    JNIEnv* env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], &shallBeDetached);
-    if(NULL==env) {
-        NSLog(@"windowDidBecomeKey: null JNIEnv");
-        return;
-    }
+    DBG_PRINT( "*************** becomeFirstResponder\n");
+    return [super becomeFirstResponder];
+}
 
-    (*env)->CallVoidMethod(env, javaWindowObject, focusChangedID, JNI_TRUE, JNI_TRUE);
+- (BOOL) resignFirstResponder
+{
+    DBG_PRINT( "*************** resignFirstResponder\n");
+    return [super resignFirstResponder];
+}
 
-    if (shallBeDetached) {
-        (*jvmHandle)->DetachCurrentThread(jvmHandle);
-    }
+- (void) becomeKeyWindow
+{
+    DBG_PRINT( "*************** becomeKeyWindow\n");
+    [super becomeKeyWindow];
+}
+
+- (void) resignKeyWindow
+{
+    DBG_PRINT( "*************** resignKeyWindow\n");
+    [super resignKeyWindow];
+}
+
+- (void) windowDidBecomeKey: (NSNotification *) notification
+{
+    DBG_PRINT( "*************** windowDidBecomeKey\n");
+    [self focusChanged: YES];
 }
 
 - (void) windowDidResignKey: (NSNotification *) notification
 {
+    DBG_PRINT( "*************** windowDidResignKey\n");
+    [self focusChanged: NO];
+}
+
+- (void) focusChanged: (BOOL) gained
+{
+    DBG_PRINT( "focusChanged: gained %d\n", gained);
     NSView* nsview = [self contentView];
     if( ! [nsview isMemberOfClass:[NewtView class]] ) {
         return;
@@ -613,18 +905,18 @@ static jint mods2JavaMods(NSUInteger mods)
     NewtView* view = (NewtView *) nsview;
     jobject javaWindowObject = [view getJavaWindowObject];
     if (javaWindowObject == NULL) {
-        NSLog(@"windowDidResignKey: null javaWindowObject");
+        DBG_PRINT("focusChanged: null javaWindowObject\n");
         return;
     }
     int shallBeDetached = 0;
     JavaVM *jvmHandle = [view getJVMHandle];
     JNIEnv* env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], &shallBeDetached);
     if(NULL==env) {
-        NSLog(@"windowDidResignKey: null JNIEnv");
+        DBG_PRINT("focusChanged: null JNIEnv\n");
         return;
     }
 
-    (*env)->CallVoidMethod(env, javaWindowObject, focusChangedID, JNI_TRUE, JNI_FALSE);
+    (*env)->CallVoidMethod(env, javaWindowObject, focusChangedID, JNI_FALSE, (gained == YES) ? JNI_TRUE : JNI_FALSE);
 
     if (shallBeDetached) {
         (*jvmHandle)->DetachCurrentThread(jvmHandle);
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c
index 307938a..9b97895 100644
--- a/src/newt/native/WindowsWindow.c
+++ b/src/newt/native/WindowsWindow.c
@@ -115,8 +115,7 @@ static jmethodID enqueueMouseEventID = NULL;
 static jmethodID sendMouseEventID = NULL;
 static jmethodID enqueueKeyEventID = NULL;
 static jmethodID sendKeyEventID = NULL;
-static jmethodID focusActionID = NULL;
-static jmethodID enqueueRequestFocusID = NULL;
+static jmethodID requestFocusID = NULL;
 
 static RECT* UpdateInsets(JNIEnv *env, jobject window, HWND hwnd);
 
@@ -600,23 +599,30 @@ static void NewtWindows_requestFocus (JNIEnv *env, jobject window, HWND hwnd, jb
     current = GetFocus();
     DBG_PRINT("*** WindowsWindow: requestFocus.S parent %p, window %p, isCurrent %d\n", 
         (void*) pHwnd, (void*)hwnd, current==hwnd);
+
     if( JNI_TRUE==force || current!=hwnd) {
-        if( JNI_TRUE==force || JNI_FALSE == (*env)->CallBooleanMethod(env, window, focusActionID) ) {
-            UINT flags = SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
-            SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, flags);
-            SetForegroundWindow(hwnd);  // Slightly Higher Priority
-            SetFocus(hwnd);// Sets Keyboard Focus To Window
-            if(NULL!=pHwnd) {
-                SetActiveWindow(hwnd);
-            }
-            DBG_PRINT("*** WindowsWindow: requestFocus.X1\n");
-        } else {
-            DBG_PRINT("*** WindowsWindow: requestFocus.X0\n");
+        UINT flags = SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
+        SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, flags);
+        SetForegroundWindow(hwnd);  // Slightly Higher Priority
+        SetFocus(hwnd);// Sets Keyboard Focus To Window
+        if(NULL!=pHwnd) {
+            SetActiveWindow(hwnd);
         }
+        DBG_PRINT("*** WindowsWindow: requestFocus.X1\n");
     }
     DBG_PRINT("*** WindowsWindow: requestFocus.XX\n");
 }
 
+static void NewtWindows_trackPointerLeave(HWND hwnd) {
+    TRACKMOUSEEVENT tme;
+    memset(&tme, 0, sizeof(TRACKMOUSEEVENT));
+    tme.cbSize = sizeof(TRACKMOUSEEVENT);
+    tme.dwFlags = TME_LEAVE;
+    tme.hwndTrack = hwnd;
+    tme.dwHoverTime = 0; // we don't use TME_HOVER
+    TrackMouseEvent(&tme);
+}
+
 #if 0
 
 static RECT* UpdateInsets(JNIEnv *env, jobject window, HWND hwnd)
@@ -859,7 +865,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
 
     case WM_LBUTTONDOWN:
         DBG_PRINT("*** WindowsWindow: LBUTTONDOWN\n");
-        (*env)->CallVoidMethod(env, window, enqueueRequestFocusID, JNI_FALSE);
+        (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE);
         (*env)->CallVoidMethod(env, window, sendMouseEventID,
                                (jint) EVENT_MOUSE_PRESSED,
                                GetModifiers(),
@@ -879,7 +885,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
 
     case WM_MBUTTONDOWN:
         DBG_PRINT("*** WindowsWindow: MBUTTONDOWN\n");
-        (*env)->CallVoidMethod(env, window, enqueueRequestFocusID, JNI_FALSE);
+        (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE);
         (*env)->CallVoidMethod(env, window, sendMouseEventID,
                                (jint) EVENT_MOUSE_PRESSED,
                                GetModifiers(),
@@ -899,7 +905,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
 
     case WM_RBUTTONDOWN:
         DBG_PRINT("*** WindowsWindow: RBUTTONDOWN\n");
-        (*env)->CallVoidMethod(env, window, enqueueRequestFocusID, JNI_FALSE);
+        (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE);
         (*env)->CallVoidMethod(env, window, sendMouseEventID,
                                (jint) EVENT_MOUSE_PRESSED,
                                GetModifiers(),
@@ -925,6 +931,15 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
                                (jint) 0,  (jint) 0);
         useDefWindowProc = 1;
         break;
+    case WM_MOUSELEAVE:
+        (*env)->CallVoidMethod(env, window, enqueueMouseEventID, JNI_FALSE,
+                               (jint) EVENT_MOUSE_EXITED,
+                               0,
+                               (jint) -1, (jint) -1, // fake
+                               (jint) 0,  (jint) 0);
+        useDefWindowProc = 1;
+        break;
+    // Java synthesizes EVENT_MOUSE_ENTERED
 
     case WM_MOUSEWHEEL: {
         // need to convert the coordinates to component-relative
@@ -938,7 +953,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
                                (jint) EVENT_MOUSE_WHEEL_MOVED,
                                GetModifiers(),
                                (jint) eventPt.x, (jint) eventPt.y,
-                               (jint) 0,  (jint) (GET_WHEEL_DELTA_WPARAM(wParam)/120.0f));
+                               (jint) 1,  (jint) (GET_WHEEL_DELTA_WPARAM(wParam)/120.0f));
         useDefWindowProc = 1;
         break;
     }
@@ -986,7 +1001,6 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
         break;
 
 
-    // FIXME: generate EVENT_MOUSE_ENTERED, EVENT_MOUSE_EXITED
     default:
         useDefWindowProc = 1;
     }
@@ -1251,8 +1265,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_initIDs
     sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V");
     enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZIIIC)V");
     sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V");
-    enqueueRequestFocusID = (*env)->GetMethodID(env, clazz, "enqueueRequestFocus", "(Z)V");
-    focusActionID = (*env)->GetMethodID(env, clazz, "focusAction", "()Z");
+    requestFocusID = (*env)->GetMethodID(env, clazz, "requestFocus", "(Z)V");
 
     if (insetsChangedID == NULL ||
         sizeChangedID == NULL ||
@@ -1265,8 +1278,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_initIDs
         sendMouseEventID == NULL ||
         enqueueKeyEventID == NULL ||
         sendKeyEventID == NULL ||
-        focusActionID == NULL ||
-        enqueueRequestFocusID == NULL) {
+        requestFocusID == NULL) {
         return JNI_FALSE;
     }
     BuildDynamicKeyMapTable();
@@ -1574,4 +1586,93 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_requestFocu
     NewtWindows_requestFocus ( env, obj, (HWND) (intptr_t) window, force) ;
 }
 
+/*
+ * Class:     Java_jogamp_newt_driver_windows_WindowsWindow
+ * Method:    setPointerVisible0
+ * Signature: (JJZ)Z
+ */
+JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_setPointerVisible0
+  (JNIEnv *env, jclass clazz, jlong window, jboolean mouseVisible)
+{
+    HWND hwnd = (HWND) (intptr_t) window;
+    int res, resOld, i;
+    jboolean b;
+
+    if(JNI_TRUE == mouseVisible) {
+        res = ShowCursor(TRUE);
+        if(res < 0) {
+            i=0;
+            do {
+                resOld = res;
+                res = ShowCursor(TRUE);
+            } while(res!=resOld && res<0 && ++i<10);
+        }
+        b = res>=0 ? JNI_TRUE : JNI_FALSE;
+    } else {
+        res = ShowCursor(FALSE);
+        if(res >= 0) {
+            i=0;
+            do {
+                resOld = res;
+                res = ShowCursor(FALSE);
+            } while(res!=resOld && res>=0 && ++i<10);
+        }
+        b = res<0 ? JNI_TRUE : JNI_FALSE;
+    }
+
+    DBG_PRINT( "*** WindowsWindow: setPointerVisible0: %d, res %d/%d\n", mouseVisible, res, b);
+
+    return b;
+}
+
+/*
+ * Class:     Java_jogamp_newt_driver_windows_WindowsWindow
+ * Method:    confinePointer0
+ * Signature: (JJZIIII)Z
+ */
+JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_confinePointer0
+  (JNIEnv *env, jclass clazz, jlong window, jboolean confine, jint l, jint t, jint r, jint b)
+{
+    HWND hwnd = (HWND) (intptr_t) window;
+    jboolean res;
+
+    if(JNI_TRUE == confine) {
+        // SetCapture(hwnd);
+        // res = ( GetCapture() == hwnd ) ? JNI_TRUE : JNI_FALSE;
+        RECT rect = { l, t, r, b };
+        res = ClipCursor(&rect) ? JNI_TRUE : JNI_FALSE;
+    } else {
+        // res = ReleaseCapture() ? JNI_TRUE : JNI_FALSE;
+        res = ClipCursor(NULL) ? JNI_TRUE : JNI_FALSE;
+    }
+    DBG_PRINT( "*** WindowsWindow: confinePointer0: %d, [ l %d t %d r %d b %d ], res %d\n", 
+        confine, l, t, r, b, res);
+
+    return res;
+}
+
+/*
+ * Class:     Java_jogamp_newt_driver_windows_WindowsWindow
+ * Method:    warpPointer0
+ * Signature: (JJII)V
+ */
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_warpPointer0
+  (JNIEnv *env, jclass clazz, jlong window, jint x, jint y)
+{
+    DBG_PRINT( "*** WindowsWindow: warpPointer0: %d/%d\n", x, y);
+    SetCursorPos(x, y);
+}
+
+/*
+ * Class:     Java_jogamp_newt_driver_windows_WindowsWindow
+ * Method:    trackPointerLeave0
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_trackPointerLeave0
+  (JNIEnv *env, jclass clazz, jlong window)
+{
+    HWND hwnd = (HWND) (intptr_t) window;
+    DBG_PRINT( "*** WindowsWindow: trackMouseLeave0\n");
+    NewtWindows_trackPointerLeave(hwnd);
+}
 
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index f2af919..3613f00 100644
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -105,34 +105,91 @@
 static jint X11KeySym2NewtVKey(KeySym keySym) {
     if(IS_WITHIN(keySym,XK_F1,XK_F12)) 
         return (keySym-XK_F1)+J_VK_F1;
+    if(IS_WITHIN(keySym,XK_KP_0,XK_KP_9)) 
+        return (keySym-XK_KP_0)+J_VK_NUMPAD0;
 
     switch(keySym) {
+        case XK_Return:
+        case XK_KP_Enter:
+            return J_VK_ENTER;
+        case XK_BackSpace:
+            return J_VK_BACK_SPACE;
+        case XK_Tab:
+        case XK_KP_Tab:
+        case XK_ISO_Left_Tab:
+            return J_VK_TAB;
+        case XK_Cancel:
+            return J_VK_CANCEL;
+        case XK_Clear:
+            return J_VK_CLEAR;
+        case XK_Shift_L:
+        case XK_Shift_R:
+            return J_VK_SHIFT;
+        case XK_Control_L:
+        case XK_Control_R:
+            return J_VK_CONTROL;
         case XK_Alt_L:
         case XK_Alt_R:
             return J_VK_ALT;
-
+        case XK_Pause:
+            return J_VK_PAUSE;
+        case XK_Caps_Lock:
+            return J_VK_CAPS_LOCK;
+        case XK_Escape:
+            return J_VK_ESCAPE;
+        case XK_space:
+        case XK_KP_Space:
+            return J_VK_SPACE;
+        case XK_Page_Up:
+        case XK_KP_Page_Up:
+            return J_VK_PAGE_UP;
+        case XK_Page_Down:
+        case XK_KP_Page_Down:
+            return J_VK_PAGE_DOWN;
+        case XK_End:
+        case XK_KP_End:
+            return J_VK_END;
+        case XK_Home:
+        case XK_KP_Home:
+            return J_VK_HOME;
         case XK_Left:
+        case XK_KP_Left:
             return J_VK_LEFT;
-        case XK_Right:
-            return J_VK_RIGHT;
         case XK_Up:
+        case XK_KP_Up:
             return J_VK_UP;
+        case XK_Right:
+        case XK_KP_Right:
+            return J_VK_RIGHT;
         case XK_Down:
+        case XK_KP_Down:
             return J_VK_DOWN;
-        case XK_Page_Up:
-            return J_VK_PAGE_UP;
-        case XK_Page_Down:
-            return J_VK_PAGE_DOWN;
-        case XK_Shift_L:
-        case XK_Shift_R:
-            return J_VK_SHIFT;
-        case XK_Control_L:
-        case XK_Control_R:
-            return J_VK_CONTROL;
-        case XK_Escape:
-            return J_VK_ESCAPE;
+        case XK_KP_Multiply:
+            return J_VK_MULTIPLY;
+        case XK_KP_Add:
+            return J_VK_ADD;
+        case XK_KP_Separator:
+            return J_VK_SEPARATOR;
+        case XK_KP_Subtract:
+            return J_VK_SUBTRACT;
+        case XK_KP_Decimal:
+            return J_VK_DECIMAL;
+        case XK_KP_Divide:
+            return J_VK_DIVIDE;
         case XK_Delete:
+        case XK_KP_Delete:
             return J_VK_DELETE;
+        case XK_Num_Lock:
+            return J_VK_NUM_LOCK;
+        case XK_Scroll_Lock:
+            return J_VK_SCROLL_LOCK;
+        case XK_Print:
+            return J_VK_PRINTSCREEN;
+        case XK_Insert:
+        case XK_KP_Insert:
+            return J_VK_INSERT;
+        case XK_Help:
+            return J_VK_HELP;
     }
     return keySym;
 }
@@ -161,6 +218,8 @@ static jint X11InputState2NewtModifiers(unsigned int xstate) {
     return modifiers;
 }
 
+#define X11_MOUSE_EVENT_MASK (ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask)
+
 static const char * const ClazzNameNewtWindow = "com/jogamp/newt/Window";
 
 static jclass    newtWindowClz=NULL;
@@ -177,8 +236,7 @@ static jmethodID enqueueMouseEventID = NULL;
 static jmethodID sendMouseEventID = NULL;
 static jmethodID enqueueKeyEventID = NULL;
 static jmethodID sendKeyEventID = NULL;
-static jmethodID focusActionID = NULL;
-static jmethodID enqueueRequestFocusID = NULL;
+static jmethodID requestFocusID = NULL;
 
 static jmethodID displayCompletedID = NULL;
 
@@ -529,20 +587,18 @@ static void NewtWindows_requestFocus (JNIEnv *env, jobject window, Display *dpy,
     Window focus_return;
     int revert_to_return;
 
-    DBG_PRINT( "X11: requestFocus dpy %p,win %p, force %d\n", dpy, (void*)w, force);
-
     XGetInputFocus(dpy, &focus_return, &revert_to_return);
+    DBG_PRINT( "X11: requestFocus dpy %p,win %p, force %d, hasFocus %d\n", dpy, (void*)w, force, focus_return==w);
+
     if( JNI_TRUE==force || focus_return!=w) {
-        if( JNI_TRUE==force || JNI_FALSE == (*env)->CallBooleanMethod(env, window, focusActionID) ) {
-            DBG_PRINT( "X11: XRaiseWindow dpy %p, win %p\n", dpy, (void*)w);
-            XRaiseWindow(dpy, w);
-            NewtWindows_setCWAbove(dpy, w);
-            // Avoid 'BadMatch' errors from XSetInputFocus, ie if window is not viewable
-            XGetWindowAttributes(dpy, w, &xwa);
-            if(xwa.map_state == IsViewable) {
-                DBG_PRINT( "X11: XSetInputFocus dpy %p,win %pd\n", dpy, (void*)w);
-                XSetInputFocus(dpy, w, RevertToParent, CurrentTime);
-            }
+        DBG_PRINT( "X11: XRaiseWindow dpy %p, win %p\n", dpy, (void*)w);
+        XRaiseWindow(dpy, w);
+        NewtWindows_setCWAbove(dpy, w);
+        // Avoid 'BadMatch' errors from XSetInputFocus, ie if window is not viewable
+        XGetWindowAttributes(dpy, w, &xwa);
+        if(xwa.map_state == IsViewable) {
+            DBG_PRINT( "X11: XSetInputFocus dpy %p,win %pd\n", dpy, (void*)w);
+            XSetInputFocus(dpy, w, RevertToParent, CurrentTime);
         }
     }
     DBG_PRINT( "X11: requestFocus dpy %p,win %p, force %d - FIN\n", dpy, (void*)w, force);
@@ -785,11 +841,12 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Display_DispatchMessages0
                     keyChar=text[0];
                     XConvertCase(keySym, &lower_return, &upper_return);
                     // always return upper case, set modifier masks (SHIFT, ..)
-                    keySym = upper_return;
-                    modifiers = X11InputState2NewtModifiers(evt.xkey.state);
+                    keySym = X11KeySym2NewtVKey(upper_return);
                 } else {
                     keyChar=0;
+                    keySym = X11KeySym2NewtVKey(keySym);
                 }
+                modifiers = X11InputState2NewtModifiers(evt.xkey.state);
                 break;
 
             case ButtonPress:
@@ -804,7 +861,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Display_DispatchMessages0
 
         switch(evt.type) {
             case ButtonPress:
-                (*env)->CallVoidMethod(env, jwindow, enqueueRequestFocusID, JNI_FALSE);
+                (*env)->CallVoidMethod(env, jwindow, requestFocusID, JNI_FALSE);
                 #ifdef USE_SENDIO_DIRECT
                 (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED, 
                                       modifiers,
@@ -837,29 +894,53 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Display_DispatchMessages0
                                       (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0 /*rotation*/); 
                 #endif
                 break;
+            case EnterNotify:
+                DBG_PRINT( "X11: event . EnterNotify call %p %d/%d\n", (void*)evt.xcrossing.window, evt.xcrossing.x, evt.xcrossing.y);
+                #ifdef USE_SENDIO_DIRECT
+                (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_ENTERED, 
+                                      modifiers,
+                                      (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); 
+                #else
+                (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_ENTERED, 
+                                      modifiers,
+                                      (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); 
+                #endif
+                break;
+            case LeaveNotify:
+                DBG_PRINT( "X11: event . LeaveNotify call %p %d/%d\n", (void*)evt.xcrossing.window, evt.xcrossing.x, evt.xcrossing.y);
+                #ifdef USE_SENDIO_DIRECT
+                (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_EXITED, 
+                                      modifiers,
+                                      (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); 
+                #else
+                (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_EXITED, 
+                                      modifiers,
+                                      (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); 
+                #endif
+                break;
             case KeyPress:
                 #ifdef USE_SENDIO_DIRECT
                 (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_PRESSED, 
-                                      modifiers, X11KeySym2NewtVKey(keySym), (jchar) keyChar);
+                                      modifiers, keySym, (jchar) -1);
                 #else
                 (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_PRESSED, 
-                                      modifiers, X11KeySym2NewtVKey(keySym), (jchar) keyChar);
+                                      modifiers, keySym, (jchar) -1);
                 #endif
 
                 break;
             case KeyRelease:
                 #ifdef USE_SENDIO_DIRECT
                 (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_RELEASED, 
-                                      modifiers, X11KeySym2NewtVKey(keySym), (jchar) keyChar);
+                                      modifiers, keySym, (jchar) -1);
 
                 (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_TYPED, 
-                                      modifiers, (jint) -1, (jchar) keyChar);
+                                      modifiers, keySym, (jchar) keyChar);
                 #else
                 (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_RELEASED, 
-                                      modifiers, X11KeySym2NewtVKey(keySym), (jchar) keyChar);
+                                      modifiers, keySym, (jchar) -1);
 
                 (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_TYPED, 
-                                      modifiers, (jint) -1, (jchar) keyChar);
+                                      modifiers, keySym, (jchar) keyChar);
                 #endif
 
                 break;
@@ -1133,6 +1214,8 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getNumScreenModeRes
     int num_sizes;   
     XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions
     
+    DBG_PRINT("getNumScreenModeResolutions0: %d\n", num_sizes);
+
     return num_sizes;
 }
 
@@ -1246,6 +1329,8 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRat
     //free
     XRRFreeScreenConfigInfo(conf);
     
+    DBG_PRINT("getCurrentScreenRate0: %d\n", (int)original_rate);
+
     return (jint) original_rate;
 }
 
@@ -1304,6 +1389,7 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRes
    //free
    XRRFreeScreenConfigInfo(conf);
    
+   DBG_PRINT("getCurrentScreenResolutionIndex0: %d\n", (int)original_size_id);
    return (jint)original_size_id;   
 }
 
@@ -1449,8 +1535,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Window_initIDs0
     sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V");
     enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZIIIC)V");
     sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V");
-    enqueueRequestFocusID = (*env)->GetMethodID(env, clazz, "enqueueRequestFocus", "(Z)V");
-    focusActionID = (*env)->GetMethodID(env, clazz, "focusAction", "()Z");
+    requestFocusID = (*env)->GetMethodID(env, clazz, "requestFocus", "(Z)V");
 
     if (insetsChangedID == NULL ||
         sizeChangedID == NULL ||
@@ -1464,8 +1549,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Window_initIDs0
         sendMouseEventID == NULL ||
         enqueueKeyEventID == NULL ||
         sendKeyEventID == NULL ||
-        focusActionID == NULL ||
-        enqueueRequestFocusID == NULL) {
+        requestFocusID == NULL) {
         return JNI_FALSE;
     }
     return JNI_TRUE;
@@ -1586,7 +1670,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Window_CreateWindow0
     xswa.backing_store=NotUseful;  /* NotUseful, WhenMapped, Always */
     xswa.backing_planes=0;         /* planes to be preserved if possible */
     xswa.backing_pixel=0;          /* value to use in restoring planes */
-    xswa.event_mask  = ButtonPressMask | ButtonReleaseMask | PointerMotionMask ;
+    xswa.event_mask  = X11_MOUSE_EVENT_MASK;
     xswa.event_mask |= KeyPressMask | KeyReleaseMask ;
     xswa.event_mask |= FocusChangeMask | SubstructureNotifyMask | StructureNotifyMask | ExposureMask ;
 
@@ -1847,7 +1931,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_requestFocus0
  * Signature: (JJ)J
  */
 JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Window_getParentWindow0
-  (JNIEnv *env, jobject obj, jlong display, jlong window)
+  (JNIEnv *env, jclass clazz, jlong display, jlong window)
 {
     return (jlong) NewtWindows_getParent ((Display *) (intptr_t) display, (Window)window);
 }
@@ -1903,3 +1987,76 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_setTitle0
 #endif
 }
 
+/*
+ * Class:     Java_jogamp_newt_driver_x11_X11Window
+ * Method:    setPointerVisible0
+ * Signature: (JJZ)Z
+ */
+JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Window_setPointerVisible0
+  (JNIEnv *env, jclass clazz, jlong display, jlong window, jboolean mouseVisible)
+{
+    static char noData[] = { 0,0,0,0,0,0,0,0 };
+    static XColor black = { 0 };
+
+    Display * dpy = (Display *) (intptr_t) display;
+    Window w = (Window)window;
+
+    DBG_PRINT( "X11: setPointerVisible0: %d\n", mouseVisible);
+
+    if(JNI_TRUE == mouseVisible) {
+        XUndefineCursor(dpy, w);
+    } else {
+        Pixmap bitmapNoData;
+        Cursor invisibleCursor;
+
+        bitmapNoData = XCreateBitmapFromData(dpy, w, noData, 8, 8);
+        if(None == bitmapNoData) {
+            return JNI_FALSE;
+        }
+        invisibleCursor = XCreatePixmapCursor(dpy, bitmapNoData, bitmapNoData, &black, &black, 0, 0);
+        XDefineCursor(dpy, w, invisibleCursor);
+        XFreeCursor(dpy, invisibleCursor);
+        XFreePixmap(dpy, bitmapNoData);
+    }
+    return JNI_TRUE;
+}
+
+/*
+ * Class:     Java_jogamp_newt_driver_x11_X11Window
+ * Method:    confinePointer0
+ * Signature: (JJZ)Z
+ */
+JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Window_confinePointer0
+  (JNIEnv *env, jclass clazz, jlong display, jlong window, jboolean confine)
+{
+    Display * dpy = (Display *) (intptr_t) display;
+    Window w = (Window)window;
+
+    DBG_PRINT( "X11: confinePointer0: %d\n", confine);
+
+    if(JNI_TRUE == confine) {
+        return GrabSuccess == XGrabPointer(dpy, w, True, 
+                                           X11_MOUSE_EVENT_MASK,
+                                           GrabModeAsync, GrabModeAsync, w, None, CurrentTime)
+               ? JNI_TRUE : JNI_FALSE ;
+    }
+    XUngrabPointer(dpy, CurrentTime);
+    return JNI_TRUE;
+}
+
+/*
+ * Class:     Java_jogamp_newt_driver_x11_X11Window
+ * Method:    warpPointer0
+ * Signature: (JJII)V
+ */
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_warpPointer0
+  (JNIEnv *env, jclass clazz, jlong display, jlong window, jint x, jint y)
+{
+    Display * dpy = (Display *) (intptr_t) display;
+    Window w = (Window)window;
+
+    DBG_PRINT( "X11: warpPointer0: %d/%d\n", x, y);
+
+    XWarpPointer(dpy, None, w, 0, 0, 0, 0, x, y);
+}
+
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java
index 4424008..74419e5 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java
@@ -52,16 +52,17 @@ public class NEWTElektronActivity extends NewtBaseActivity {
        
        // create GLWindow (-> incl. underlying NEWT Display, Screen & Window)
        GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
-       // caps.setAlphaBits(4);
-       // caps.setNumSamples(4);
-       // caps.setSampleBuffers(true);
+       caps.setRedBits(5);
+       caps.setGreenBits(6);
+       caps.setBlueBits(5);
+       caps.setAlphaBits(0);
        Log.d(TAG, "req caps: "+caps);
        GLWindow glWindow = GLWindow.create(caps);
        glWindow.setFullscreen(true);
        setContentView(getWindow(), glWindow);
        
        glWindow.addGLEventListener(new ElektronenMultiplizierer());
-       glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() {
+       glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
         public void screenModeChangeNotify(ScreenMode sm) { }
         public void screenModeChanged(ScreenMode sm, boolean success) {
             System.err.println("ScreenMode Changed: "+sm);
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java
index bc4e7d3..ba861d0 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java
@@ -52,12 +52,17 @@ public class NEWTGearsES1Activity extends NewtBaseActivity {
        
        // create GLWindow (-> incl. underlying NEWT Display, Screen & Window)
        GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES1));
+       /*
+       caps.setRedBits(5);
+       caps.setGreenBits(6);
+       caps.setBlueBits(5);
+       caps.setAlphaBits(0); */
        Log.d(TAG, "req caps: "+caps);
        GLWindow glWindow = GLWindow.create(caps);
        setContentView(getWindow(), glWindow);
        
        glWindow.addGLEventListener(new GearsES1(1));
-       glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() {
+       glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
         public void screenModeChangeNotify(ScreenMode sm) { }
         public void screenModeChanged(ScreenMode sm, boolean success) {
             System.err.println("ScreenMode Changed: "+sm);
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java
index 939bfa2..89ecf4c 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java
@@ -52,22 +52,32 @@ public class NEWTGearsES2Activity extends NewtBaseActivity {
        
        // create GLWindow (-> incl. underlying NEWT Display, Screen & Window)
        GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
+       /*
+       caps.setRedBits(5);
+       caps.setGreenBits(6);
+       caps.setBlueBits(5);
+       caps.setAlphaBits(0); */
        Log.d(TAG, "req caps: "+caps);
        GLWindow glWindow = GLWindow.create(caps);
        glWindow.setFullscreen(true);
        setContentView(getWindow(), glWindow);
        
-       glWindow.addGLEventListener(new GearsES2(1));
-       glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() {
+       GearsES2 demo = new GearsES2(0);
+       // demo.enableAndroidTrace(true);
+       glWindow.addGLEventListener(demo);
+       glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
         public void screenModeChangeNotify(ScreenMode sm) { }
         public void screenModeChanged(ScreenMode sm, boolean success) {
             System.err.println("ScreenMode Changed: "+sm);
         }
        });
-       glWindow.setVisible(true);
        Animator animator = new Animator(glWindow);
        animator.setUpdateFPSFrames(60, System.err);
+       // animator.setRunAsFastAsPossible(true);
        setAnimator(animator);
+       // glWindow.setSkipContextReleaseThread(animator.getThread());
+       
+       glWindow.setVisible(true);
        
        Log.d(TAG, "onCreate - X");
    }   
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java
index 84ff0a5..d6b7507 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java
@@ -61,16 +61,18 @@ public class NEWTGearsES2TransActivity extends NewtBaseActivity {
        setContentView(getWindow(), glWindow);
        
        glWindow.addGLEventListener(new GearsES2(1));
-       glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() {
+       glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
         public void screenModeChangeNotify(ScreenMode sm) { }
         public void screenModeChanged(ScreenMode sm, boolean success) {
             System.err.println("ScreenMode Changed: "+sm);
         }
        });
-       glWindow.setVisible(true);
        Animator animator = new Animator(glWindow);
        animator.setUpdateFPSFrames(60, System.err);
        setAnimator(animator);
+       // glWindow.setSkipContextReleaseThread(animator.getThread());
+       
+       glWindow.setVisible(true);
        
        Log.d(TAG, "onCreate - X");
    }   
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java
index 83f3587..1efedcd 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java
@@ -61,7 +61,7 @@ public class NEWTGraphUI1pActivity extends NewtBaseActivity {
        setContentView(getWindow(), glWindow);
        
        glWindow.addGLEventListener(new GPUUISceneGLListener0A(0));
-       glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() {
+       glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
         public void screenModeChangeNotify(ScreenMode sm) { }
         public void screenModeChanged(ScreenMode sm, boolean success) {
             System.err.println("ScreenMode Changed: "+sm);
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java
index 17924d4..39fb5e2 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java
@@ -62,7 +62,7 @@ public class NEWTGraphUI2pActivity extends NewtBaseActivity {
        setContentView(getWindow(), glWindow);
        
        glWindow.addGLEventListener(new GPUUISceneGLListener0A(Region.VBAA_RENDERING_BIT));
-       glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() {
+       glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
         public void screenModeChangeNotify(ScreenMode sm) { }
         public void screenModeChanged(ScreenMode sm, boolean success) {
             System.err.println("ScreenMode Changed: "+sm);
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java
index 6fc3a46..99d7fd7 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java
@@ -52,12 +52,16 @@ public class NEWTRedSquareES1Activity extends NewtBaseActivity {
        
        // create GLWindow (-> incl. underlying NEWT Display, Screen & Window)
        GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES1));
+       caps.setRedBits(5);
+       caps.setGreenBits(6);
+       caps.setBlueBits(5);
+       caps.setAlphaBits(0);
        Log.d(TAG, "req caps: "+caps);
        GLWindow glWindow = GLWindow.create(caps);
        setContentView(getWindow(), glWindow);
        
        glWindow.addGLEventListener(new RedSquareES1(1));
-       glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() {
+       glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
         public void screenModeChangeNotify(ScreenMode sm) { }
         public void screenModeChanged(ScreenMode sm, boolean success) {
             System.err.println("ScreenMode Changed: "+sm);
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java
index e9ef981..804e627 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java
@@ -52,22 +52,31 @@ public class NEWTRedSquareES2Activity extends NewtBaseActivity {
        
        // create GLWindow (-> incl. underlying NEWT Display, Screen & Window)
        GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
+       caps.setRedBits(5);
+       caps.setGreenBits(6);
+       caps.setBlueBits(5);
+       caps.setAlphaBits(0);
        Log.d(TAG, "req caps: "+caps);
        GLWindow glWindow = GLWindow.create(caps);
        glWindow.setFullscreen(true);
        setContentView(getWindow(), glWindow);
        
-       glWindow.addGLEventListener(new RedSquareES2(1));
-       glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() {
+       final RedSquareES2 demo = new RedSquareES2(0);
+       // demo.enableAndroidTrace(true);
+       glWindow.addGLEventListener(demo);
+       glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
         public void screenModeChangeNotify(ScreenMode sm) { }
         public void screenModeChanged(ScreenMode sm, boolean success) {
             System.err.println("ScreenMode Changed: "+sm);
         }
        });
-       glWindow.setVisible(true);
        Animator animator = new Animator(glWindow);
        animator.setUpdateFPSFrames(60, System.err);
+       // animator.setRunAsFastAsPossible(true);
        setAnimator(animator);
+       // glWindow.setSkipContextReleaseThread(animator.getThread());
+       glWindow.setVisible(true);
+       
        
        Log.d(TAG, "onCreate - X");
    }   
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java b/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java
index 55d3371..b6c3cc7 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java
@@ -32,11 +32,6 @@ public class TestRegionRendererNEWT01 extends UITestCase {
         org.junit.runner.JUnitCore.main(tstname);
     }    
     
-    @BeforeClass
-    public static void initClass() {
-        GLProfile.initSingleton(true);
-    }
-
     static void destroyWindow(GLWindow window) {
         if(null!=window) {
             window.destroy();
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java
index 9fd0c05..8f03af7 100755
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java
@@ -35,11 +35,6 @@ public class TestTextRendererNEWT01 extends UITestCase {
         org.junit.runner.JUnitCore.main(tstname);
     }    
         
-    @BeforeClass
-    public static void initClass() {
-        GLProfile.initSingleton(true);
-    }
-
     static void destroyWindow(GLWindow window) {
         if(null!=window) {
             window.destroy();
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java
index 5e0c266..160dc0f 100755
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java
@@ -55,7 +55,6 @@ public class GPURegionNewtDemo01 {
     static final boolean TRACE = false;
     
     public static void main(String[] args) {
-        GLProfile.initSingleton(true);
         GLProfile glp = GLProfile.getGL2ES2();
         GLCapabilities caps = new GLCapabilities(glp);
         caps.setAlphaBits(4);
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo02.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo02.java
index f1db1cc..e7b5c73 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo02.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo02.java
@@ -52,7 +52,6 @@ public class GPURegionNewtDemo02 {
     static final boolean TRACE = false;
     
     public static void main(String[] args) {
-        GLProfile.initSingleton(true);
         GLProfile glp = GLProfile.getGL2ES2();
         GLCapabilities caps = new GLCapabilities(glp);
         caps.setAlphaBits(4);               
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java
index bcd60d4..d257f78 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java
@@ -49,7 +49,6 @@ public class GPUTextNewtDemo01 {
     static final boolean TRACE = false;
     
     public static void main(String[] args) {
-        GLProfile.initSingleton(true);
         GLProfile glp = GLProfile.getGL2ES2();
         GLCapabilities caps = new GLCapabilities(glp);
         caps.setAlphaBits(4);
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java
index 5981e79..1b71cd7 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java
@@ -57,7 +57,6 @@ public class GPUTextNewtDemo02 {
     static final boolean TRACE = false;
     
     public static void main(String[] args) {
-        GLProfile.initSingleton(true);
         GLProfile glp = GLProfile.getGL2ES2();
         
         GLCapabilities caps = new GLCapabilities(glp);
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java
index 540aade..5abc181 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java
@@ -360,7 +360,8 @@ public class GPUUISceneGLListener0A implements GLEventListener {
     }
     
     private class MultiTouchListener extends MouseAdapter {
-        int lv = 0;
+        int lx = 0;
+        int ly = 0;
         
         boolean first = false;
         
@@ -378,30 +379,38 @@ public class GPUUISceneGLListener0A implements GLEventListener {
         public void mouseDragged(MouseEvent e) {
             System.err.println("demo:mousedragged "+e);
             if(e.getPointerCount()==2) {
-                // 2 finger zoom ..
+                // 2 pointers zoom ..
                 if(first) {
-                    lv = Math.abs(e.getY(0)-e.getY(1));
+                    lx = Math.abs(e.getY(0)-e.getY(1));
                     first=false;
                     return;
                 }
                 int nv = Math.abs(e.getY(0)-e.getY(1));
-                int dy = nv - lv;
+                int dy = nv - lx;
                 
                 zoom += 2 * Math.signum(dy);
                 
-                lv = nv;
+                lx = nv;
             } else {
-                // 1 finger drag
+                // 1 pointer drag
                 if(first) {
-                    lv = e.getX();
+                    lx = e.getX();
+                    ly = e.getY();
                     first=false;
                     return;
                 }
-                int nv = e.getX();
-                int dx = nv - lv;                
-                xTran += Math.signum(dx);
-                
-                lv = nv;
+                int nx = e.getX();
+                int ny = e.getY();
+                int dx = nx - lx;       
+                int dy = ny - ly;
+                if(Math.abs(dx) > Math.abs(dy)){
+                    xTran += Math.signum(dx);
+                }
+                else {
+                    yTran -= Math.signum(dy);
+                }
+                lx = nx;
+                ly = ny;
             }
         }
     }
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo01.java
index 91f6687..0563ab2 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo01.java
@@ -16,7 +16,6 @@ public class GPUUISceneNewtDemo01 {
     static final boolean TRACE = false;
     
     public static void main(String[] args) {
-        GLProfile.initSingleton(true);
         GLProfile glp = GLProfile.getGL2ES2();
         GLCapabilities caps = new GLCapabilities(glp);
         caps.setAlphaBits(4);
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo02.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo02.java
index a6cd770..4c8da13 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo02.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo02.java
@@ -17,7 +17,6 @@ public class GPUUISceneNewtDemo02 {
     static final boolean TRACE = false;
     
     public static void main(String[] args) {
-        GLProfile.initSingleton(true);
         GLProfile glp = GLProfile.getGL2ES2();
         GLCapabilities caps = new GLCapabilities(glp);
         caps.setAlphaBits(4);
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java
index 27b7ecc..0577c5f 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java
@@ -54,7 +54,6 @@ public class UINewtDemo01 {
     static final boolean TRACE = false;
     
     public static void main(String[] args) {
-        GLProfile.initSingleton(true);
         GLProfile glp = GLProfile.getGL2ES2();
         GLCapabilities caps = new GLCapabilities(glp);
         caps.setAlphaBits(4);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug00NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug00NEWT.java
index a42247b..62e7446 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug00NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug00NEWT.java
@@ -55,11 +55,6 @@ public class TestGLDebug00NEWT extends UITestCase {
     static String dbgTstMsg0 = "Hello World";
     static int dbgTstId0 = 42;
     
-    @BeforeClass
-    public static void initClass() {
-        // GLProfile.initSingleton(true);
-    }
-    
     public class WindowContext {        
         public final Window window;
         public final GLContext context;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java
index 6ab6714..f9b566c 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java
@@ -41,7 +41,6 @@ import javax.media.opengl.GLRunnable;
 
 import org.junit.Assert;
 import org.junit.Test;
-import org.junit.BeforeClass;
 
 import com.jogamp.newt.opengl.GLWindow;
 import com.jogamp.opengl.test.junit.util.UITestCase;
@@ -51,11 +50,6 @@ public class TestGLDebug01NEWT extends UITestCase {
     static String dbgTstMsg0 = "Hello World";
     static int dbgTstId0 = 42;
     
-    @BeforeClass
-    public static void initClass() {
-        GLProfile.initSingleton(true);
-    }
-    
     GLWindow createWindow(GLProfile glp, boolean debugGL) {        
         GLCapabilities caps = new GLCapabilities(glp);
         //
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java
index 5af5263..e4245ef 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java
@@ -42,6 +42,8 @@ import javax.media.opengl.GLContext;
 import javax.media.opengl.GLDrawableFactory;
 import javax.media.opengl.GLProfile;
 
+import jogamp.opengl.GLDrawableFactoryImpl;
+
 import org.junit.Test;
 
 public class TestGLExtensionQueryOffscreen {
@@ -52,9 +54,12 @@ public class TestGLExtensionQueryOffscreen {
         instance.testJogl2ExtensionCheck2();
     }
 
+    /** 
+     * @deprecated This test uses a non public API in jogamp.opengl.* and hence is not recommended
+     */
     @Test
     public void testJogl2ExtensionCheck1() {
-        GLDrawableFactory factory = GLDrawableFactory.getDesktopFactory();
+        GLDrawableFactoryImpl factory = (GLDrawableFactoryImpl) GLDrawableFactory.getDesktopFactory();
         GLContext sharedContext = factory.getOrCreateSharedContext(null);
         sharedContext.makeCurrent();
         String extensions;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java
index 7813482..6a5f76f 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java
@@ -137,17 +137,6 @@ public class TestGLProfile01NEWT extends UITestCase {
         dumpVersion(glp);
     }
     
-    @Test
-    public void test06GLProfileShutdownRecreate() throws InterruptedException {
-        GLProfile.shutdown();
-        GLProfile.initSingleton(true);
-        System.out.println("GLProfile.getDefault(): "+GLProfile.getDefault());
-        System.out.println("GLProfile.getDefaultDesktopDevice(): "+GLProfile.getDefaultDesktopDevice());
-        System.out.println("GLProfile.getDefaultEGLDevice(): "+GLProfile.getDefaultEGLDevice());
-        System.out.println("GLProfile.getDefaultDevice(): "+GLProfile.getDefaultDevice());
-    }
-
-
     protected void dumpVersion(GLProfile glp) throws InterruptedException {
         GLCapabilities caps = new GLCapabilities(glp);
         GLWindow glWindow = GLWindow.create(caps);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrentNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrentNEWT.java
new file mode 100644
index 0000000..fc025d0
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrentNEWT.java
@@ -0,0 +1,230 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ * 
+ *    1. Redistributions of source code must retain the above copyright notice, this list of
+ *       conditions and the following disclaimer.
+ * 
+ *    2. Redistributions in binary form must reproduce the above copyright notice, this list
+ *       of conditions and the following disclaimer in the documentation and/or other materials
+ *       provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+ 
+package com.jogamp.opengl.test.junit.jogl.acore;
+
+import java.io.IOException;
+
+import javax.media.nativewindow.Capabilities;
+import javax.media.nativewindow.util.InsetsImmutable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.jogamp.newt.NewtFactory;
+import com.jogamp.newt.Window;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+public class TestInitConcurrentNEWT extends UITestCase {
+
+    static final int demoSize = 128;
+    
+    static long duration = 300; // ms
+    
+    static InsetsImmutable insets = null;
+    static int scrnHeight, scrnWidth;
+    static int num_x, num_y;
+    
+    @BeforeClass
+    public static void initClass() {
+        Window dummyWindow = NewtFactory.createWindow(new Capabilities());
+        dummyWindow.setSize(demoSize, demoSize);
+        dummyWindow.setVisible(true);
+        Assert.assertEquals(true, dummyWindow.isVisible());
+        Assert.assertEquals(true, dummyWindow.isNativeValid());
+        insets = dummyWindow.getInsets();        
+        scrnHeight = dummyWindow.getScreen().getHeight();
+        scrnWidth = dummyWindow.getScreen().getWidth();        
+        num_x = scrnWidth  / ( demoSize + insets.getTotalWidth() )  - 2;
+        num_y = scrnHeight / ( demoSize + insets.getTotalHeight() ) - 2;
+        dummyWindow.destroy();
+    }
+    
+    public class JOGLTask implements Runnable {
+        private int id;
+        private Object postSync;
+        private boolean done = false;
+        
+        public JOGLTask(Object postSync, int id) {
+            this.postSync = postSync;
+            this.id = id;
+        }
+        public void run() {
+            int x = (  id          % num_x ) * ( demoSize + insets.getTotalHeight() );
+            int y = ( (id / num_x) % num_y ) * ( demoSize + insets.getTotalHeight() );
+            
+            System.err.println("JOGLTask "+id+": START: "+x+"/"+y+" - "+Thread.currentThread().getName());
+            GLWindow glWindow = GLWindow.create(new GLCapabilities(GLProfile.getDefault()));
+            Assert.assertNotNull(glWindow);
+            glWindow.setTitle("Task "+id);
+            glWindow.setPosition(x + insets.getLeftWidth(), y + insets.getTopHeight() );
+    
+            glWindow.addGLEventListener(new GearsES2(0));
+    
+            Animator animator = new Animator(glWindow);
+    
+            glWindow.setSize(demoSize, demoSize);
+            glWindow.setVisible(true);
+            animator.setUpdateFPSFrames(60, null);
+            animator.start();
+            Assert.assertEquals(true, animator.isAnimating());
+            Assert.assertEquals(true, glWindow.isVisible());
+            Assert.assertEquals(true, glWindow.isNativeValid());
+            Assert.assertEquals(true, glWindow.isRealized());
+            System.err.println("JOGLTask "+id+": RUNNING: "+Thread.currentThread().getName());
+    
+            while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
+                try {
+                    Thread.sleep(100);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+            }
+    
+            animator.stop();
+            glWindow.destroy();
+            
+            System.err.println("JOGLTask "+id+": DONE/SYNC: "+Thread.currentThread().getName());
+            synchronized (postSync) {
+                done = true;
+                System.err.println("JOGLTask "+id+": END: "+Thread.currentThread().getName());
+                postSync.notifyAll();
+            }
+        }
+        
+        public boolean done() { return done; }
+    }
+
+    protected static boolean done(JOGLTask[] tasks) {
+        for(int i=tasks.length-1; i>=0; i--) {
+            if(!tasks[i].done()) {
+                return false;
+            }
+        }
+        return true;
+    }
+    protected static String doneDump(JOGLTask[] tasks) {
+        StringBuffer sb = new StringBuffer();
+        sb.append("[");
+        for(int i=0; i<tasks.length; i++) {
+            if(i>0) {
+                sb.append(", ");
+            }
+            sb.append(i).append(": ").append(tasks[i].done());
+        }
+        sb.append("]");
+        return sb.toString();
+    }
+    
+    protected static boolean isDead(Thread[] threads) {
+        for(int i=threads.length-1; i>=0; i--) {
+            if(threads[i].isAlive()) {
+                return false;
+            }
+        }
+        return true;
+    }
+    protected static String isAliveDump(Thread[] threads) {
+        StringBuffer sb = new StringBuffer();
+        sb.append("[");
+        for(int i=0; i<threads.length; i++) {
+            if(i>0) {
+                sb.append(", ");
+            }
+            sb.append(i).append(": ").append(threads[i].isAlive());
+        }
+        sb.append("]");
+        return sb.toString();
+    }
+    
+    protected void runJOGLTasks(int num) throws InterruptedException {
+        final String currentThreadName = Thread.currentThread().getName();
+        final Object sync = new Object();
+        final JOGLTask[] tasks = new JOGLTask[num];
+        final Thread[] threads = new Thread[num];
+        int i;
+        for(i=0; i<num; i++) {
+            tasks[i] = new JOGLTask(sync, i);
+            threads[i] = new Thread(tasks[i], currentThreadName+"-jt"+i);
+        }
+        for(i=0; i<num; i++) {
+            threads[i].start();
+        }
+        synchronized (sync) {
+            while(!done(tasks)) {
+                try {
+                    sync.wait();
+                } catch (InterruptedException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        }
+        Assert.assertTrue("Tasks are incomplete. Complete: "+doneDump(tasks), done(tasks));
+        i=0;
+        while(i<30 && !isDead(threads)) {
+            Thread.sleep(100);
+            i++;
+        }
+        Assert.assertTrue("Threads are still alive after 3s. Alive: "+isAliveDump(threads), isDead(threads));
+    }
+    
+    @Test
+    public void test01OneThread() throws InterruptedException {
+        runJOGLTasks(1);
+    }
+
+    @Test
+    public void test02TwoThreads() throws InterruptedException {
+        runJOGLTasks(2);
+    }
+    
+    @Test
+    public void test16SixteenThreads() throws InterruptedException {
+        runJOGLTasks(16);
+    }
+    
+    public static void main(String args[]) throws IOException {
+        for(int i=0; i<args.length; i++) {
+            if(args[i].equals("-time")) {
+                i++;
+                try {
+                    duration = Integer.parseInt(args[i]);
+                } catch (Exception ex) { ex.printStackTrace(); }
+            }
+        }
+        String tstname = TestInitConcurrentNEWT.class.getName();
+        org.junit.runner.JUnitCore.main(tstname);
+    }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/util/FocusEventCountAdapter.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMainVersionGLCanvasAWT.java
similarity index 71%
copy from src/test/com/jogamp/opengl/test/junit/util/FocusEventCountAdapter.java
copy to src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMainVersionGLCanvasAWT.java
index b555515..5523ce5 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/FocusEventCountAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMainVersionGLCanvasAWT.java
@@ -1,5 +1,5 @@
 /**
- * Copyright 2010 JogAmp Community. All rights reserved.
+ * Copyright 2011 JogAmp Community. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without modification, are
  * permitted provided that the following conditions are met:
@@ -26,9 +26,27 @@
  * or implied, of JogAmp Community.
  */
  
-package com.jogamp.opengl.test.junit.util;
+package com.jogamp.opengl.test.junit.jogl.acore;
 
-public interface FocusEventCountAdapter extends EventCountAdapter {
-    boolean hasFocus();
-}
+import java.io.IOException;
+
+import javax.media.opengl.awt.GLCanvas;
+
+import org.junit.Test;
+
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+public class TestMainVersionGLCanvasAWT extends UITestCase {
 
+    @Test
+    public void testMain() throws InterruptedException {
+        GLCanvas.main(null);
+    }
+
+
+    public static void main(String args[]) throws IOException {
+        String tstname = TestMainVersionGLCanvasAWT.class.getName();
+        org.junit.runner.JUnitCore.main(tstname);
+    }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/util/FocusEventCountAdapter.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMainVersionGLWindowNEWT.java
similarity index 71%
copy from src/test/com/jogamp/opengl/test/junit/util/FocusEventCountAdapter.java
copy to src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMainVersionGLWindowNEWT.java
index b555515..d178e34 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/FocusEventCountAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMainVersionGLWindowNEWT.java
@@ -1,5 +1,5 @@
 /**
- * Copyright 2010 JogAmp Community. All rights reserved.
+ * Copyright 2011 JogAmp Community. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without modification, are
  * permitted provided that the following conditions are met:
@@ -26,9 +26,25 @@
  * or implied, of JogAmp Community.
  */
  
-package com.jogamp.opengl.test.junit.util;
+package com.jogamp.opengl.test.junit.jogl.acore;
 
-public interface FocusEventCountAdapter extends EventCountAdapter {
-    boolean hasFocus();
-}
+import java.io.IOException;
+import org.junit.Test;
+
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+public class TestMainVersionGLWindowNEWT extends UITestCase {
+
+    @Test
+    public void testMain() throws InterruptedException {
+        GLWindow.main(null);
+    }
 
+
+    public static void main(String args[]) throws IOException {
+        String tstname = TestMainVersionGLWindowNEWT.class.getName();
+        org.junit.runner.JUnitCore.main(tstname);
+    }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNVSwapGroupNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNVSwapGroupNEWT.java
index 0f64738..05f122b 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNVSwapGroupNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNVSwapGroupNEWT.java
@@ -52,7 +52,6 @@ public class TestNVSwapGroupNEWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
         glp = GLProfile.getDefault();
         Assert.assertNotNull(glp);
         caps = new GLCapabilities(glp);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java
new file mode 100644
index 0000000..5f04ed6
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java
@@ -0,0 +1,127 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ * 
+ *    1. Redistributions of source code must retain the above copyright notice, this list of
+ *       conditions and the following disclaimer.
+ * 
+ *    2. Redistributions in binary form must reproduce the above copyright notice, this list
+ *       of conditions and the following disclaimer in the documentation and/or other materials
+ *       provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.junit.jogl.acore;
+
+import java.awt.EventQueue;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.media.opengl.DefaultGLCapabilitiesChooser;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLPbuffer;
+import javax.media.opengl.GLProfile;
+
+import jogamp.nativewindow.jawt.JAWTUtil;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.jogamp.common.util.RunnableTask;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+public class TestPBufferDeadlockAWT extends UITestCase {
+  static GLProfile glp;
+  static int width, height;
+
+  @BeforeClass
+  public static void initClass() {
+    glp = GLProfile.getDefault();
+    Assert.assertNotNull( glp );
+    width = 512;
+    height = 512;
+  }
+
+  protected void runTestGL( GLCapabilities caps ) throws InterruptedException, InvocationTargetException {
+    final GLPbuffer pbuffer = GLDrawableFactory.getFactory( GLProfile.get( "GL2" ) ).createGLPbuffer(
+        null,
+        caps, new DefaultGLCapabilitiesChooser(),
+        512, 512,
+        null
+    );
+
+    final boolean[] done = {false};
+    final Runnable pbufferCreationAction = new Runnable() {
+      public void run() {
+        System.err.println("AA.1");
+        pbuffer.display();
+        done[ 0 ] = true;
+        System.err.println("AA.X");
+      }
+    };
+    
+    EventQueue.invokeAndWait(new Runnable() {
+        public void run() {
+            Assert.assertTrue(EventQueue.isDispatchThread());
+            JAWTUtil.lockToolkit();
+            try {
+                final RunnableTask rTask = new RunnableTask(pbufferCreationAction, new Object(), false);                    
+                System.err.println("BB.0: "+rTask.getSyncObject());
+                synchronized (rTask.getSyncObject()) {
+                    System.err.println("BB.1: "+rTask.getSyncObject());
+                    new Thread(rTask, Thread.currentThread().getName()+"-Pbuffer_Creation").start();                
+                    try {
+                        System.err.println("BB.2");
+                        rTask.getSyncObject().wait();
+                        System.err.println("BB.3");
+                    } catch (InterruptedException e) {
+                        throw new RuntimeException(e);
+                    }                    
+                    System.err.println("BB.X");
+                }
+            } finally {
+                JAWTUtil.unlockToolkit();
+            }
+        }        
+    });
+    Assert.assertTrue(done[0]);
+  }
+
+  @Test(timeout = 2000) // 2s timeout
+  public void testDeadlock() throws InterruptedException, InvocationTargetException {
+    GLCapabilities caps = new GLCapabilities( glp );
+    runTestGL( caps );
+  }
+
+  static long duration = 500; // ms
+
+  public static void main( String args[] ) {
+    for ( int i = 0; i < args.length; i++ ) {
+      if ( args[ i ].equals( "-time" ) ) {
+        i++;
+        try {
+          duration = Integer.parseInt( args[ i ] );
+        }
+        catch ( Exception ex ) {
+          ex.printStackTrace();
+        }
+      }
+    }
+    org.junit.runner.JUnitCore.main( TestPBufferDeadlockAWT.class.getName() );
+  }
+} 
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java
index 99e81af..dc08229 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java
@@ -40,7 +40,7 @@ import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
 import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
 
 import java.awt.Frame;
-import javax.swing.SwingUtilities;
+import java.lang.reflect.InvocationTargetException;
 
 import org.junit.Assert;
 import org.junit.Assume;
@@ -78,12 +78,18 @@ public class TestSharedContextListAWT extends UITestCase {
         Assert.assertNotNull(sharedDrawable);
         sharedDrawable.destroy();
     }
-    protected Frame createFrame(int x, int y, boolean useShared) {
-        return new Frame("Shared Gears AWT Test: "+x+"/"+y+" shared "+useShared);
+    
+    protected void setFrameTitle(final Frame f, final boolean useShared) 
+            throws InterruptedException, InvocationTargetException {
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                f.setTitle("Shared Gears AWT Test: "+f.getX()+"/"+f.getY()+" shared "+useShared);
+            }
+        });
     }
 
     protected GLCanvas runTestGL(final Frame frame, final Animator animator, final int x, final int y, final boolean useShared, final boolean vsync)
-            throws InterruptedException
+            throws InterruptedException, InvocationTargetException
     {
         final GLCanvas glCanvas = new GLCanvas(caps, useShared ? sharedDrawable.getContext() : null);        
         Assert.assertNotNull(glCanvas);
@@ -99,26 +105,41 @@ public class TestSharedContextListAWT extends UITestCase {
 
         animator.add(glCanvas);
 
-        frame.setVisible(true);
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame.setVisible(true);
+            } } );
         Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas, true));
 
         return glCanvas;
     }
 
     @Test
-    public void test01() throws InterruptedException {
+    public void test01() throws InterruptedException, InvocationTargetException {
         initShared();
-
-        final Frame f1 = createFrame(0, 0, true);
-        final Frame f2 = createFrame(width, 0, true);
-        final Frame f3 = createFrame(0, height, false);
-
+        final Frame f1 = new Frame();
+        final Frame f2 = new Frame();
+        final Frame f3 = new Frame();
         Animator animator = new Animator();
 
         final GLCanvas glc1 = runTestGL(f1, animator, 0,     0,      true, false);
-        final GLCanvas glc2 = runTestGL(f2, animator, width, 0,      true, false);
-        final GLCanvas glc3 = runTestGL(f3, animator, 0,     height, false, true);
-
+        int x0 = f1.getX();
+        int y0 = f1.getY();
+        
+        final GLCanvas glc2 = runTestGL(f2, animator, 
+                                        x0+width,
+                                        y0+0,      
+                                        true, false);
+        
+        final GLCanvas glc3 = runTestGL(f3, animator, 
+                                        x0+0,     
+                                        y0+height, 
+                                        false, true);
+
+        setFrameTitle(f1, true);
+        setFrameTitle(f2, true);
+        setFrameTitle(f3, false);
+        
         animator.setUpdateFPSFrames(1, null);        
         animator.start();
         while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java
index a37b4cc..3080947 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java
@@ -39,6 +39,7 @@ import javax.media.opengl.GLPbuffer;
 import javax.media.opengl.GLProfile;
 import com.jogamp.opengl.util.Animator;
 
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
 import com.jogamp.opengl.test.junit.util.UITestCase;
 import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
 
@@ -55,7 +56,6 @@ public class TestSharedContextListNEWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
         glp = GLProfile.getDefault();
         Assert.assertNotNull(glp);
         caps = new GLCapabilities(glp);
@@ -77,9 +77,10 @@ public class TestSharedContextListNEWT extends UITestCase {
     private void releaseShared() {
         Assert.assertNotNull(sharedDrawable);
         sharedDrawable.destroy();
+        sharedDrawable = null;
     }
 
-    protected GLWindow runTestGL(Animator animator, int x, int y, boolean useShared, boolean vsync) {
+    protected GLWindow runTestGL(Animator animator, int x, int y, boolean useShared, boolean vsync) throws InterruptedException {
         GLWindow glWindow = GLWindow.create(caps);
         Assert.assertNotNull(glWindow);
         glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared);
@@ -98,9 +99,9 @@ public class TestSharedContextListNEWT extends UITestCase {
         animator.add(glWindow);
 
         glWindow.setVisible(true);
-
-        /** insets (if supported) are available only if window is set visible and hence is created */
-        glWindow.setTopLevelPosition(x, y);
+        Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true));
+        Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true));
+        glWindow.setPosition(x, y);
 
         return glWindow;
     }
@@ -111,8 +112,10 @@ public class TestSharedContextListNEWT extends UITestCase {
         Animator animator = new Animator();
         GLWindow f1 = runTestGL(animator, 0, 0, true, false);
         InsetsImmutable insets = f1.getInsets();
-        GLWindow f2 = runTestGL(animator, width+insets.getTotalWidth(), 0, true, false);
-        GLWindow f3 = runTestGL(animator, 0, height+insets.getTotalHeight(), false, true);
+        GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(), 
+                                          f1.getY()+0, true, false);
+        GLWindow f3 = runTestGL(animator, f1.getX()+0, 
+                                          f1.getY()+height+insets.getTotalHeight(), false, true);
         animator.setUpdateFPSFrames(1, null);        
         animator.start();
         while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
@@ -121,7 +124,7 @@ public class TestSharedContextListNEWT extends UITestCase {
         animator.stop();
 
         // here we go again: On AMD/X11 the create/destroy sequence must be the same
-        // even though this is agains the chicken/egg logic here ..
+        // even though this is against the chicken/egg logic here ..
         releaseShared();
 
         f1.destroy();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java
similarity index 78%
copy from src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java
copy to src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java
index a37b4cc..4281572 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java
@@ -34,29 +34,27 @@ import com.jogamp.newt.opengl.GLWindow;
 
 import javax.media.nativewindow.util.InsetsImmutable;
 import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLDrawableFactory;
-import javax.media.opengl.GLPbuffer;
 import javax.media.opengl.GLProfile;
 import com.jogamp.opengl.util.Animator;
 
-import com.jogamp.opengl.test.junit.util.UITestCase;
 import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.UITestCase;
 
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-public class TestSharedContextListNEWT extends UITestCase {
+public class TestSharedContextListNEWT2 extends UITestCase {
     static GLProfile glp;
     static GLCapabilities caps;
     static int width, height;
-    GLPbuffer sharedDrawable;
+    GLWindow sharedDrawable;
     Gears sharedGears;
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
-        glp = GLProfile.getDefault();
+        glp = GLProfile.get(GLProfile.GL2);
         Assert.assertNotNull(glp);
         caps = new GLCapabilities(glp);
         Assert.assertNotNull(caps);
@@ -65,11 +63,13 @@ public class TestSharedContextListNEWT extends UITestCase {
     }
 
     private void initShared() {
-        sharedDrawable = GLDrawableFactory.getFactory(glp).createGLPbuffer(null, caps, null, width, height, null);
+    	sharedDrawable = GLWindow.create(caps);
         Assert.assertNotNull(sharedDrawable);
-        sharedGears = new Gears();
+        sharedGears = new Gears(0);
         Assert.assertNotNull(sharedGears);
         sharedDrawable.addGLEventListener(sharedGears);
+        sharedDrawable.setSize(width, height);
+        sharedDrawable.setVisible(true);
         // init and render one frame, which will setup the Gears display lists
         sharedDrawable.display();
     }
@@ -77,10 +77,12 @@ public class TestSharedContextListNEWT extends UITestCase {
     private void releaseShared() {
         Assert.assertNotNull(sharedDrawable);
         sharedDrawable.destroy();
+        sharedDrawable = null;
     }
 
-    protected GLWindow runTestGL(Animator animator, int x, int y, boolean useShared, boolean vsync) {
+    protected GLWindow runTestGL(Animator animator, int x, int y, boolean useShared, boolean vsync) throws InterruptedException {
         GLWindow glWindow = GLWindow.create(caps);
+        
         Assert.assertNotNull(glWindow);
         glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared);
         if(useShared) {
@@ -96,32 +98,34 @@ public class TestSharedContextListNEWT extends UITestCase {
         glWindow.addGLEventListener(gears);
 
         animator.add(glWindow);
-
+        animator.start();
         glWindow.setVisible(true);
 
-        /** insets (if supported) are available only if window is set visible and hence is created */
-        glWindow.setTopLevelPosition(x, y);
-
+        Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true));
+        Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true));
+        glWindow.setPosition(x, y);
+        
         return glWindow;
     }
 
     @Test
     public void test01() throws InterruptedException {
         initShared();
-        Animator animator = new Animator();
-        GLWindow f1 = runTestGL(animator, 0, 0, true, false);
+        GLWindow f1 = runTestGL(new Animator(), 0, 0, true, false);
         InsetsImmutable insets = f1.getInsets();
-        GLWindow f2 = runTestGL(animator, width+insets.getTotalWidth(), 0, true, false);
-        GLWindow f3 = runTestGL(animator, 0, height+insets.getTotalHeight(), false, true);
-        animator.setUpdateFPSFrames(1, null);        
-        animator.start();
-        while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
-            Thread.sleep(100);
-        }
-        animator.stop();
+        GLWindow f2 = runTestGL(new Animator(), f1.getX()+width+insets.getTotalWidth(), 
+                                f1.getY()+0, true, false);
+        GLWindow f3 = runTestGL(new Animator(), f1.getX()+0, 
+                                f1.getY()+height+insets.getTotalHeight(), true, false);
+
+        try {
+			Thread.sleep(duration);
+		} catch(Exception e) {
+			e.printStackTrace();
+		}
 
         // here we go again: On AMD/X11 the create/destroy sequence must be the same
-        // even though this is agains the chicken/egg logic here ..
+        // even though this is against the chicken/egg logic here ..
         releaseShared();
 
         f1.destroy();
@@ -132,7 +136,7 @@ public class TestSharedContextListNEWT extends UITestCase {
         // releaseShared();
     }
 
-    static long duration = 500; // ms
+    static long duration = 2000; // ms
 
     public static void main(String args[]) throws IOException {
         for(int i=0; i<args.length; i++) {
@@ -147,6 +151,6 @@ public class TestSharedContextListNEWT extends UITestCase {
         BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
         System.err.println("Press enter to continue");
         System.err.println(stdin.readLine()); */         
-        org.junit.runner.JUnitCore.main(TestSharedContextListNEWT.class.getName());
+        org.junit.runner.JUnitCore.main(TestSharedContextListNEWT2.class.getName());
     }
 }
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextNewtAWTBug523.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextNewtAWTBug523.java
new file mode 100644
index 0000000..60f46fe
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextNewtAWTBug523.java
@@ -0,0 +1,778 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ * 
+ *    1. Redistributions of source code must retain the above copyright notice, this list of
+ *       conditions and the following disclaimer.
+ * 
+ *    2. Redistributions in binary form must reproduce the above copyright notice, this list
+ *       of conditions and the following disclaimer in the documentation and/or other materials
+ *       provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+ 
+package com.jogamp.opengl.test.junit.jogl.acore;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
+import javax.media.opengl.GL2;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLPbuffer;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.awt.GLCanvas;
+import javax.media.opengl.glu.GLU;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JSlider;
+import javax.swing.SwingUtilities;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.jogamp.common.nio.Buffers;
+import com.jogamp.newt.awt.NewtCanvasAWT;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.GLBuffers;
+
+
+/**
+ * TestSharedContextNewtAWTBug523
+ * 
+ * Opens a single JFrame with two OpenGL windows and sliders to adjust the view orientation.
+ *
+ * Each window renders a red triangle and a blue triangle.
+ * The red triangle is rendered using glBegin / glVertex / glEnd.
+ * The blue triangle is rendered using vertex buffer objects bound to a vertex array object.
+ *
+ * If static useNewt is true, then those windows are GLWindow objects in a NewtCanvasAWT.
+ * If static useNewt is false, then those windows are GLCanvas objects.
+ *
+ * If shareContext is true, then the two OpenGL windows are initialized with a shared context,
+ * so that they share the vertex buffer and array objects and display lists.
+ * If shareContext is false, then the two OpenGL windows each have their own context, and the blue
+ * triangle fails to render in one of the windows.
+ * 
+ * The four test cases run through the four combinations of useNewt and shareContext.
+ * 
+ * Similar test cases are {@link TestSharedContextListNEWT}, {@link TestSharedContextListAWT}, 
+ * {@link TestSharedContextVBOES2NEWT} and {@link TestSharedContextVBOES1NEWT}.
+ * 
+ */
+public class TestSharedContextNewtAWTBug523 extends UITestCase {
+
+    static long durationPerTest = 1000;
+    
+    // counters for instances of event listener TwoTriangles
+    // private static int instanceCounter;
+    private static int initializationCounter;
+
+    // This semaphore is released once each time a GLEventListener destroy method is called.
+    // The main thread waits twice on this semaphore to ensure both canvases have finished cleaning up.
+    private static Semaphore disposalCompleteSemaphore = new Semaphore(0);
+
+    // Buffer objects can be shared across shared OpenGL context. 
+    // If we run with sharedContext, then the tests will use these shared buffer objects,
+    // otherwise each event listener allocates its own buffer objects.
+    private static int [] sharedVertexBufferObjects = {0};
+    private static int [] sharedIndexBufferObjects = {0};
+    private static FloatBuffer sharedVertexBuffer;
+    private static IntBuffer sharedIndexBuffer;
+
+    static private GLPbuffer initShared(GLCapabilities caps) {
+        GLPbuffer sharedDrawable = GLDrawableFactory.getFactory(caps.getGLProfile()).createGLPbuffer(null, caps, null, 64, 64, null);
+        Assert.assertNotNull(sharedDrawable);
+        // init and render one frame, which will setup the Gears display lists
+        sharedDrawable.display();
+        return sharedDrawable;
+    }
+
+    static private void releaseShared(GLPbuffer sharedDrawable) {
+        if(null != sharedDrawable) {
+            sharedDrawable.destroy();
+        }
+    }
+    
+    // inner class that implements the event listener
+    static class TwoTriangles implements GLEventListener {
+
+        boolean useShared;
+        int canvasWidth;
+        int canvasHeight;
+        private float boundsRadius = 2f;
+        private float viewDistance;
+        private float viewDistanceFactor = 1.0f;
+        private float xAxisRotation;
+        private float yAxisRotation;
+        private float viewFovDegrees = 15f;
+
+        // vertex array objects cannot be shared across open gl canvases;
+        //
+        // However, display lists can be shared across GLCanvas instances (if those canvases are initialized with the same GLContext),
+        // including a display list created in one context that uses a VAO. 
+        private int [] vertexArrayObjects = {0};
+
+        // Buffer objects can be shared across canvas instances, if those canvases are initialized with the same GLContext.
+        // If we run with sharedBufferObjects true, then the tests will use these shared buffer objects.
+        // If we run with sharedBufferObjects false, then each event listener allocates its own buffer objects.
+        private int [] privateVertexBufferObjects = {0};
+        private int [] privateIndexBufferObjects = {0};
+        private FloatBuffer privateVertexBuffer;
+        private IntBuffer privateIndexBuffer;
+        
+        TwoTriangles (int canvasWidth, int canvasHeight, boolean useShared) {
+            // instanceNum = instanceCounter++;
+            this.canvasWidth = canvasWidth;
+            this.canvasHeight = canvasHeight;
+            this.useShared = useShared;
+        }
+
+        public void setXAxisRotation(float xRot) {
+            xAxisRotation = xRot;
+        }
+
+        public void setYAxisRotation(float yRot) {
+            yAxisRotation = yRot;
+        }
+
+        public void setViewDistanceFactor(float factor) {
+            viewDistanceFactor = factor;
+        }
+
+
+        public void init(GLAutoDrawable drawable) {
+            GL2 gl2 = drawable.getGL().getGL2();
+
+            System.err.println("INIT GL IS: " + gl2.getClass().getName());
+
+            // Disable VSync
+            gl2.setSwapInterval(0);
+
+            // Setup the drawing area and shading mode
+            gl2.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+            // the first instance of TwoTriangles initializes the shared buffer objects;
+            // synchronizing to deal with potential liveness issues if the data is intialized from one thread and used on another
+            synchronized (this) {
+                gl2.glGenVertexArrays(1, vertexArrayObjects, 0);
+
+                gl2.glBindVertexArray(vertexArrayObjects[0]);
+
+                // use either the shared or private vertex buffers, as 
+                int [] vertexBufferObjects;
+                int [] indexBufferObjects;
+                FloatBuffer vertexBuffer;
+                IntBuffer indexBuffer;
+                //
+                if (useShared) {
+                    vertexBufferObjects = sharedVertexBufferObjects;
+                    indexBufferObjects = sharedIndexBufferObjects;
+                    vertexBuffer = sharedVertexBuffer;
+                    indexBuffer = sharedIndexBuffer;
+                } else {
+                    vertexBufferObjects = privateVertexBufferObjects;
+                    indexBufferObjects = privateIndexBufferObjects;
+                    vertexBuffer = privateVertexBuffer;
+                    indexBuffer = privateIndexBuffer;
+                }
+                
+                // if buffer sharing is enabled, then the first of the two event listeners to be
+                // initialized will allocate the buffers, and the other will re-use the allocated one
+                if (vertexBufferObjects[0] == 0) {
+                    vertexBuffer = GLBuffers.newDirectFloatBuffer(18);
+                    vertexBuffer.put(new float[]{
+                            1.0f, -0.5f, 0f,    // vertex 1
+                            0f, 0f, 1f,         // normal 1
+                            1.5f, -0.5f, 0f,    // vertex 2
+                            0f, 0f, 1f,         // normal 2
+                            1.0f, 0.5f, 0f,     // vertex 3
+                            0f, 0f, 1f          // normal 3
+                    });
+                    vertexBuffer.position(0);
+
+                    gl2.glGenBuffers(1, vertexBufferObjects, 0);
+                    gl2.glBindBuffer(GL2.GL_ARRAY_BUFFER, vertexBufferObjects[0]);
+                    gl2.glBufferData(GL2.GL_ARRAY_BUFFER, vertexBuffer.capacity() * Buffers.SIZEOF_FLOAT, vertexBuffer, GL2.GL_STATIC_DRAW);
+                }
+                
+                // A check in the case that buffer sharing is enabled but context sharing is not enabled -- in that
+                // case, the buffer objects are not shareable, and the blue triangle cannot be rendereds.
+                // Furthermore, although the calls to bind and draw elements do not cause an error from glGetError
+                // when this check is removed, true blue triangle is not rendered anyways, and more importantly,
+                // I found that with my system glDrawElements causes a runtime exception 50% of the time. Executing the binds
+                // to unshareable buffers sets up glDrawElements for unpredictable crashes -- sometimes it does, sometimes not.
+                if (gl2.glIsBuffer(vertexBufferObjects[0])) {
+                    gl2.glBindBuffer(GL2.GL_ARRAY_BUFFER, vertexBufferObjects[0]);
+                    //
+                    gl2.glEnableClientState(GL2.GL_VERTEX_ARRAY);
+                    gl2.glVertexPointer(3, GL2.GL_FLOAT, 6 * GLBuffers.SIZEOF_FLOAT, 0);
+                    //
+                    gl2.glEnableClientState(GL2.GL_NORMAL_ARRAY);
+                    gl2.glNormalPointer(GL2.GL_FLOAT, 6 * GLBuffers.SIZEOF_FLOAT, 3 * GLBuffers.SIZEOF_FLOAT);
+                }
+
+                if (indexBufferObjects[0] == 0) {
+                    indexBuffer = GLBuffers.newDirectIntBuffer(3);
+                    indexBuffer.put(new int[]{0, 1, 2});
+                    indexBuffer.position(0);
+
+                    gl2.glGenBuffers(1, indexBufferObjects, 0);
+                    gl2.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, indexBufferObjects[0]);
+                    gl2.glBufferData(GL2.GL_ELEMENT_ARRAY_BUFFER, indexBuffer.capacity() * Buffers.SIZEOF_INT, indexBuffer, GL2.GL_STATIC_DRAW);
+                }
+
+                // again, a check in the case that buffer sharing is enabled but context sharing is not enabled 
+                if (gl2.glIsBuffer(indexBufferObjects[0])) {
+                    gl2.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, indexBufferObjects[0]);
+                }
+
+                gl2.glBindVertexArray(0);
+                gl2.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, 0);
+                gl2.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0);
+                gl2.glDisableClientState(GL2.GL_VERTEX_ARRAY);
+                gl2.glDisableClientState(GL2.GL_NORMAL_ARRAY);
+
+                initializationCounter++;
+            } // synchronized (this)
+
+
+            viewDistance = setupViewFrustum(gl2, canvasWidth, canvasHeight, boundsRadius, 1.0f, viewFovDegrees);
+
+        }
+
+        public void dispose(GLAutoDrawable drawable) {
+
+            synchronized (this) {
+                initializationCounter--;
+
+                GL2 gl2 = drawable.getGL().getGL2();
+
+                gl2.glDeleteVertexArrays(1, vertexArrayObjects, 0);
+                vertexArrayObjects[0] = 0;
+                logAnyErrorCodes(gl2, "display");
+
+                // release shared resources 
+                if (initializationCounter == 0 || !useShared) {
+                    // use either the shared or private vertex buffers, as 
+                    int [] vertexBufferObjects;
+                    int [] indexBufferObjects;
+                    if (useShared) {
+                        vertexBufferObjects = sharedVertexBufferObjects;
+                        indexBufferObjects = sharedIndexBufferObjects;
+                    } else {
+                        vertexBufferObjects = privateVertexBufferObjects;
+                        indexBufferObjects = privateIndexBufferObjects;
+                    }
+
+                    gl2.glDeleteBuffers(1, vertexBufferObjects, 0);
+                    gl2.glDeleteBuffers(1, indexBufferObjects, 0);
+                    vertexBufferObjects[0] = 0;
+                    indexBufferObjects[0] = 0;
+                    logAnyErrorCodes(gl2, "display");
+                }
+
+                // release the main thread once for each disposal
+                disposalCompleteSemaphore.release();
+            } // synchronized (this)
+        }
+
+        public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+        }
+
+        public void display(GLAutoDrawable drawable) {
+
+            // wait until all instances are initialized before attempting to draw using the
+            // vertex array object, because the buffers are allocated in init and when the
+            // buffers are shared, we need to ensure that they are allocated before trying to use thems
+            synchronized (this) {
+                if (initializationCounter != 2) {
+                    return;
+                }
+            }
+
+            GL2 gl2 = drawable.getGL().getGL2();
+            GLU glu = new GLU();
+
+            // Clear the drawing area
+            gl2.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
+
+            gl2.glViewport(0, 0, canvasWidth, canvasHeight);
+            gl2.glMatrixMode(GL2.GL_PROJECTION);
+            gl2.glLoadIdentity();
+            glu.gluPerspective(viewFovDegrees, (float)canvasWidth/(float)canvasHeight,
+                               viewDistance*viewDistanceFactor-boundsRadius, viewDistance*viewDistanceFactor+boundsRadius);
+
+            // Reset the current matrix to the "identity"
+            gl2.glMatrixMode(GL2.GL_MODELVIEW);
+            gl2.glLoadIdentity();
+
+            // draw the scene
+            gl2.glPushAttrib(GL2.GL_ALL_ATTRIB_BITS);
+            gl2.glPushMatrix();
+
+            glu.gluLookAt(0, 0, 0 + viewDistance*viewDistanceFactor, 0, 0, 0, 0, 1, 0);
+            gl2.glRotatef(xAxisRotation, 1, 0, 0);
+            gl2.glRotatef(yAxisRotation, 0, 1, 0);
+
+            gl2.glDisable(GL2.GL_CULL_FACE);
+            gl2.glEnable(GL2.GL_DEPTH_TEST);
+
+            // draw the triangles
+            drawTwoTriangles(gl2);
+
+            gl2.glPopMatrix();
+            gl2.glPopAttrib();
+
+            // Flush all drawing operations to the graphics card
+            gl2.glFlush();
+
+            logAnyErrorCodes(gl2, "display");
+        }
+
+        public void drawTwoTriangles(GL2 gl2) {
+
+            // draw a red triangle the old fashioned way
+            gl2.glColor3f(1f, 0f, 0f);
+            gl2.glBegin(GL2.GL_TRIANGLES);
+            gl2.glVertex3d(-1.5, -0.5, 0);
+            gl2.glNormal3d(0, 0, 1);
+            gl2.glVertex3d(-0.5, -0.5, 0);
+            gl2.glNormal3d(0, 0, 1);
+            gl2.glVertex3d(-0.75, 0.5, 0);
+            gl2.glNormal3d(0, 0, 1);
+            gl2.glEnd();
+
+            // draw the blue triangle using a vertex array object, sharing the vertex and index buffer objects across
+            // contexts; if context sharing is not initialized, then one window will simply have to live without a blue triangle
+            //
+            // synchronizing to deal with potential liveness issues if the data is intialized from one
+            // thread and used on another
+            boolean vaoBound = false;
+            // use either the shared or private vertex buffers, as 
+            int [] vertexBufferObjects;
+            int [] indexBufferObjects;
+            synchronized (this) {
+                if (useShared) {
+                    vertexBufferObjects = sharedVertexBufferObjects;
+                    indexBufferObjects = sharedIndexBufferObjects;
+                } else {
+                    vertexBufferObjects = privateVertexBufferObjects;
+                    indexBufferObjects = privateIndexBufferObjects;
+                }
+            } // synchronized (this)
+                
+            // A check in the case that buffer sharing is enabled but context sharing is not enabled -- in that
+            // case, the buffer objects are not shareable, and the blue triangle cannot be rendereds.
+            // Furthermore, although the calls to bind and draw elements do not cause an error from glGetError
+            // when this check is removed, true blue triangle is not rendered anyways, and more importantly,
+            // I found that with my system glDrawElements causes a runtime exception 50% of the time. Executing the binds
+            // to unshareable buffers sets up glDrawElements for unpredictable crashes -- sometimes it does, sometimes not.
+            if (gl2.glIsVertexArray(vertexArrayObjects[0]) && 
+                    gl2.glIsBuffer(indexBufferObjects[0]) && gl2.glIsBuffer(vertexBufferObjects[0])) {
+                gl2.glBindVertexArray(vertexArrayObjects[0]);
+                gl2.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, indexBufferObjects[0]);
+                vaoBound = true;
+            }
+        
+            logAnyErrorCodes(gl2, "drawTwoTriangles");
+
+            if (vaoBound) {
+                gl2.glColor3f(0f, 0f, 1f);
+                gl2.glDrawElements(GL2.GL_TRIANGLES, 3, GL2.GL_UNSIGNED_INT, 0);
+                gl2.glBindVertexArray(0);
+                gl2.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, 0);
+            } 
+        }
+
+        public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
+        }
+        
+    } // inner class TwoTriangles
+
+    public static void logAnyErrorCodes(GL2 gl2, String prefix) {
+        int glError = gl2.glGetError();
+        while (glError != GL2.GL_NO_ERROR) {
+            System.err.println(prefix + ", OpenGL error: 0x" + Integer.toHexString(glError));
+            glError = gl2.glGetError();
+        }
+        int status = gl2.glCheckFramebufferStatus(GL2.GL_FRAMEBUFFER);
+        if (status != GL2.GL_FRAMEBUFFER_COMPLETE) {
+            System.err.println(prefix + ", glCheckFramebufferStatus: 0x" + Integer.toHexString(status));
+        }
+    }
+
+    /**
+     * Sets the OpenGL projection matrix and front and back clipping planes for
+     * a viewport and returns the distance the camera should be placed from
+     * the center of the scene's bounding sphere such that the geometry is
+     * centered in the view frustum.
+     *
+     * @param gl2 current OpenGL context
+     * @param width width of GLDrawable
+     * @param height height of GLDrawable
+     * @param boundsRadius radius of a minimal bounding sphere of objects to be
+     *            rendered in the viewport
+     * @param zoomFactor affects how far away the camera is placed from the scene; changing the
+     *            zoom from 1.0 to 0.5 would make the scene appear half the size
+     * @param viewFovDegrees the desired field of vision for the viewport,
+     *            higher is more fish-eye
+     * @return the distance the camera should be from the center of the scenes
+     *         bounding sphere
+     */
+    public static float setupViewFrustum(GL2 gl2, int width, int height, float boundsRadius, float zoomFactor, float viewFovDegrees) {
+    	assert boundsRadius > 0.0f;
+    	assert zoomFactor > 0.0f;
+    	assert viewFovDegrees > 0.0f;
+
+        GLU glu = new GLU();
+
+        final float aspectRatio = (float) width / (float) height;
+        final float boundRadiusAdjusted = boundsRadius / zoomFactor;
+        final float lowestFov = aspectRatio > 1.0f ? viewFovDegrees : aspectRatio * viewFovDegrees;
+        final float viewDist = (float) (boundRadiusAdjusted / Math.sin( (lowestFov / 2.0) * (Math.PI / 180.0) ));
+
+        gl2.glMatrixMode(GL2.GL_PROJECTION);
+        gl2.glLoadIdentity();
+        glu.gluPerspective(viewFovDegrees, aspectRatio,	0.1*viewDist, viewDist + boundRadiusAdjusted);
+
+        return viewDist;
+    }
+
+    @Test
+    public void testContextSharingCreateVisibleDestroy1() throws InterruptedException, InvocationTargetException {
+        testContextSharingCreateVisibleDestroy(false, false);
+    }
+
+    @Test
+    public void testContextSharingCreateVisibleDestroy2() throws InterruptedException, InvocationTargetException {
+        testContextSharingCreateVisibleDestroy(false, true);
+    }
+
+    @Test
+    public void testContextSharingCreateVisibleDestroy3() throws InterruptedException, InvocationTargetException {
+        testContextSharingCreateVisibleDestroy(true, false);
+    }
+
+    @Test
+    public void testContextSharingCreateVisibleDestroy4() throws InterruptedException, InvocationTargetException {
+        testContextSharingCreateVisibleDestroy(true, true);
+    }
+
+    /**
+     * Assemble the user interface and start the animator.
+     * It waits until the window is closed an then attempts orderly shutdown and resource deallocation.
+     */
+    public void testContextSharingCreateVisibleDestroy(final boolean useNewt, final boolean shareContext) throws InterruptedException, InvocationTargetException {
+        final JFrame frame = new JFrame("Simple JOGL App for testing context sharing");
+        //
+        // GLDrawableFactory factory = GLDrawableFactory.getFactory(GLProfile.get(GLProfile.GL2));
+        // GLContext sharedContext = factory.getOrCreateSharedContext(factory.getDefaultDevice());
+        //
+        GLCapabilities glCapabilities = new GLCapabilities(GLProfile.get(GLProfile.GL2));
+        glCapabilities.setSampleBuffers(true);
+        glCapabilities.setNumSamples(4);
+
+        final GLPbuffer sharedDrawable;
+        final GLContext sharedContext; 
+        if(shareContext) {
+            sharedDrawable = initShared(glCapabilities);
+            sharedContext = sharedDrawable.getContext();
+        } else {
+            sharedDrawable = null;
+            sharedContext = null;
+        }
+        
+        final TwoTriangles eventListener1 = new TwoTriangles(640, 480, shareContext);
+        final TwoTriangles eventListener2 = new TwoTriangles(320, 480, shareContext);
+
+        final Component openGLComponent1;
+        final Component openGLComponent2;
+        final GLAutoDrawable openGLAutoDrawable1;
+        final GLAutoDrawable openGLAutoDrawable2;
+
+        if (useNewt) {
+            GLWindow glWindow1 = GLWindow.create(glCapabilities);
+            glWindow1.setSharedContext(sharedContext);
+            NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1);
+            newtCanvasAWT1.setPreferredSize(new Dimension(eventListener1.canvasWidth, eventListener1.canvasHeight));
+            glWindow1.addGLEventListener(eventListener1);
+            //
+            GLWindow glWindow2 = GLWindow.create(glCapabilities);
+            NewtCanvasAWT newtCanvasAWT2 = new NewtCanvasAWT(glWindow2);
+            newtCanvasAWT2.setPreferredSize(new Dimension(eventListener2.canvasWidth, eventListener2.canvasHeight));
+            glWindow2.addGLEventListener(eventListener2);
+
+            openGLComponent1 = newtCanvasAWT1;
+            openGLComponent2 = newtCanvasAWT2;
+            openGLAutoDrawable1 = glWindow1;
+            openGLAutoDrawable2 = glWindow2;
+        } else {
+            // Implementation using two GLCanvas instances; for GLCanvas context sharing to work, you must pass it in
+            // through the constructor; if you set it after it has no effect -- it does no harm if you initialized the ctor
+            // with the shared context, but if you didn't, it also doesn't trigger sharing
+            final GLCanvas canvas1;
+            final GLCanvas canvas2;
+
+            if (shareContext) {
+                canvas1 = new GLCanvas(glCapabilities, sharedContext);
+                canvas2 = new GLCanvas(glCapabilities, sharedContext);
+            } else {
+                canvas1 = new GLCanvas(glCapabilities);
+                canvas2 = new GLCanvas(glCapabilities);
+            }
+
+            canvas1.setSize(eventListener1.canvasWidth, eventListener1.canvasHeight);
+            canvas1.addGLEventListener(eventListener1);
+            //
+            canvas2.setSize(eventListener2.canvasWidth, eventListener2.canvasHeight);
+            canvas2.addGLEventListener(eventListener2);
+
+            openGLComponent1 = canvas1;
+            openGLComponent2 = canvas2;
+            openGLAutoDrawable1 = canvas1;
+            openGLAutoDrawable2 = canvas2;
+        }
+
+        // Create slider for x rotation.
+        // The vertically oriented slider rotates around the x axis
+        final JSlider xAxisRotationSlider = new JSlider(JSlider.VERTICAL, -180, 180, 1);
+        xAxisRotationSlider.setPaintTicks(false);
+        xAxisRotationSlider.setPaintLabels(false);
+        xAxisRotationSlider.setSnapToTicks(false);
+        xAxisRotationSlider.addChangeListener(new ChangeListener() {
+
+            public void stateChanged(ChangeEvent e) {
+                eventListener1.setXAxisRotation(xAxisRotationSlider.getValue());
+                eventListener2.setXAxisRotation(xAxisRotationSlider.getValue());
+            }
+        });
+        JLabel xAxisRotationLabel = new JLabel("X-Axis Rotation");
+
+        // Create slider for y rotation.
+        // The horizontally oriented slider rotates around the y axis
+        final JSlider yAxisRotationSlider = new JSlider(JSlider.HORIZONTAL, -180, 180, 1);
+        yAxisRotationSlider.setPaintTicks(false);
+        yAxisRotationSlider.setPaintLabels(false);
+        yAxisRotationSlider.setSnapToTicks(false);
+        yAxisRotationSlider.addChangeListener(new ChangeListener() {
+
+            public void stateChanged(ChangeEvent e) {
+                eventListener1.setYAxisRotation(yAxisRotationSlider.getValue());
+                eventListener2.setYAxisRotation(yAxisRotationSlider.getValue());
+            }
+        });
+        JLabel yAxisRotationLabel = new JLabel("Y-Axis Rotation");
+
+        // Create slider for view distance factor.
+        // We want a range of 0.0 to 10.0 with 0.1 increments (so we can scale down using 0.0 to 1.0).
+        // So, set JSlider to 0 to 100 and divide by 10.0 in stateChanged
+        final JSlider viewDistanceFactorSlider = new JSlider(JSlider.HORIZONTAL, 0, 100, 10);
+        viewDistanceFactorSlider.setPaintTicks(false);
+        viewDistanceFactorSlider.setPaintLabels(false);
+        viewDistanceFactorSlider.setSnapToTicks(false);
+        viewDistanceFactorSlider.addChangeListener(new ChangeListener() {
+
+            public void stateChanged(ChangeEvent e) {
+                eventListener1.setViewDistanceFactor((float) viewDistanceFactorSlider.getValue() / 10.0f);
+                eventListener2.setViewDistanceFactor((float) viewDistanceFactorSlider.getValue() / 10.0f);
+            }
+        });
+        JLabel viewDistanceFactorLabel = new JLabel("View Distance Factor");
+
+        // group the view distance and label into a vertical panel
+        JPanel viewDistancePanel = new JPanel();
+        viewDistancePanel.setLayout(new BoxLayout(viewDistancePanel, BoxLayout.PAGE_AXIS));
+        viewDistancePanel.add(Box.createVerticalGlue());
+        viewDistancePanel.add(viewDistanceFactorSlider);
+        viewDistancePanel.add(viewDistanceFactorLabel);
+        viewDistancePanel.add(Box.createVerticalGlue());
+
+        // group both OpenGL canvases / windows into a horizontal panel
+        JPanel openGLPanel = new JPanel();
+        openGLPanel.setLayout(new BoxLayout(openGLPanel, BoxLayout.LINE_AXIS));
+        openGLPanel.add(openGLComponent1);
+        openGLPanel.add(Box.createHorizontalStrut(5));
+        openGLPanel.add(openGLComponent2);
+
+        // group the open GL panel and the y-axis rotation slider into a vertical panel.
+        JPanel canvasAndYAxisPanel = new JPanel();
+        canvasAndYAxisPanel.setLayout(new BoxLayout(canvasAndYAxisPanel, BoxLayout.PAGE_AXIS));
+        canvasAndYAxisPanel.add(openGLPanel);
+        canvasAndYAxisPanel.add(Box.createVerticalGlue());
+        canvasAndYAxisPanel.add(yAxisRotationSlider);
+        canvasAndYAxisPanel.add(yAxisRotationLabel);
+
+        // group the X-axis rotation slider and label into a horizontal panel.
+        JPanel xAxisPanel = new JPanel();
+        xAxisPanel.setLayout(new BoxLayout(xAxisPanel, BoxLayout.LINE_AXIS));
+        xAxisPanel.add(xAxisRotationSlider);
+        xAxisPanel.add(xAxisRotationLabel);
+
+        JPanel mainPanel = (JPanel) frame.getContentPane();
+        mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.LINE_AXIS));
+        mainPanel.add(viewDistancePanel);
+        mainPanel.add(Box.createHorizontalGlue());
+        mainPanel.add(canvasAndYAxisPanel);
+        mainPanel.add(Box.createHorizontalGlue());
+        mainPanel.add(xAxisPanel);
+
+        final Animator animator = new Animator(Thread.currentThread().getThreadGroup());
+        animator.setUpdateFPSFrames(1, null);
+        animator.add(openGLAutoDrawable1);
+        animator.add(openGLAutoDrawable2);
+
+        final Semaphore windowOpenSemaphore = new Semaphore(0);
+        final Semaphore closingSemaphore = new Semaphore(0);
+
+        // signal the main thread when the frame is closed
+        frame.addWindowListener(new WindowAdapter() {
+
+            @Override
+            public void windowClosing(WindowEvent e) {
+                closingSemaphore.release();
+            }
+        });
+
+        // make the window visible using the EDT
+        SwingUtilities.invokeLater( new Runnable() {
+            public void run() {
+                frame.pack();
+                frame.setVisible(true);
+                windowOpenSemaphore.release();
+            }
+        });
+
+        // wait for the window to be visible and start the animation
+        try {
+            boolean windowOpened = windowOpenSemaphore.tryAcquire(5000, TimeUnit.MILLISECONDS);
+            Assert.assertEquals(true, windowOpened);
+        } catch (InterruptedException e) {
+            System.err.println("Closing wait interrupted: " + e.getMessage());
+        }
+        animator.start();
+
+        // sleep for test duration, then request the window to close, wait for the window to close,s and stop the animation
+        try {
+            while(animator.isAnimating() && animator.getTotalFPSDuration() < durationPerTest) {
+                Thread.sleep(100);
+            }
+            AWTRobotUtil.closeWindow(frame, true);
+            boolean windowClosed = closingSemaphore.tryAcquire(5000, TimeUnit.MILLISECONDS);
+            Assert.assertEquals(true, windowClosed);
+        } catch (InterruptedException e) {
+            System.err.println("Closing wait interrupted: " + e.getMessage());
+        }
+        animator.stop();
+
+        // ask the EDT to dispose of the frame;
+        // if using newt, explicitly dispose of the canvases because otherwise it seems our destroy methods are not called
+        SwingUtilities.invokeLater( new Runnable() {
+            public void run() {
+                frame.setVisible(false);
+                frame.dispose();
+                if (useNewt) {
+                    ((NewtCanvasAWT)openGLComponent1).destroy();
+                    ((NewtCanvasAWT)openGLComponent2).destroy();
+                }
+                closingSemaphore.release();
+            }
+        });
+
+        // wait for orderly destruction; it seems that if we share a GLContext across newt windows, bad things happen;
+        // I must be doing something wrong but I haven't figured it out yet
+        try {
+            boolean windowsDisposed = closingSemaphore.tryAcquire(5000, TimeUnit.MILLISECONDS);
+            Assert.assertEquals(true, windowsDisposed);
+        } catch (InterruptedException e) {
+            System.err.println("Closing wait interrupted: " + e.getMessage());
+        }
+
+        // ensure that the two OpenGL canvas' destroy methods completed successfully and released resources before we move on
+        int disposalSuccesses = 0;
+        try {
+            boolean acquired;
+            acquired = disposalCompleteSemaphore.tryAcquire(5000, TimeUnit.MILLISECONDS);
+            if (acquired){
+                disposalSuccesses++;
+            }
+            acquired = disposalCompleteSemaphore.tryAcquire(5000, TimeUnit.MILLISECONDS);
+            if (acquired){
+                disposalSuccesses++;
+            }
+        } catch (InterruptedException e) {
+            System.err.println("Clean exit interrupted: " + e.getMessage());
+        }
+
+        Assert.assertEquals(true, disposalSuccesses == 2);
+        
+        releaseShared(sharedDrawable);
+    }
+
+    static int atoi(String a) {
+        int i=0;
+        try {
+            i = Integer.parseInt(a);
+        } catch (Exception ex) { ex.printStackTrace(); }
+        return i;
+    }
+
+    public static void main(String[] args) throws IOException {
+        for(int i=0; i<args.length; i++) {
+            if(args[i].equals("-time")) {
+                if (++i < args.length) {
+                    durationPerTest = atoi(args[i]);
+                }
+            } 
+        }
+        
+        String testname = TestSharedContextNewtAWTBug523.class.getName();
+        org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] {
+            testname,
+            "filtertrace=true",
+            "haltOnError=false",
+            "haltOnFailure=false",
+            "showoutput=true",
+            "outputtoformatters=true",
+            "logfailedtests=true",
+            "logtestlistenerevents=true",
+            "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter",
+            "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+testname+".xml" } );
+    }
+
+}
+
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java
index e78efb3..6e48e44 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java
@@ -37,6 +37,7 @@ import javax.media.opengl.GLPbuffer;
 import javax.media.opengl.GLProfile;
 import com.jogamp.opengl.util.Animator;
 
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
 import com.jogamp.opengl.test.junit.util.UITestCase;
 import com.jogamp.opengl.test.junit.jogl.demos.es1.GearsES1;
 
@@ -53,7 +54,6 @@ public class TestSharedContextVBOES1NEWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
         glp = GLProfile.getDefault();
         Assert.assertNotNull(glp);
         caps = new GLCapabilities(glp);
@@ -77,7 +77,7 @@ public class TestSharedContextVBOES1NEWT extends UITestCase {
         sharedDrawable.destroy();
     }
 
-    protected GLWindow runTestGL(Animator animator, int x, int y, boolean useShared, boolean vsync) {
+    protected GLWindow runTestGL(Animator animator, int x, int y, boolean useShared, boolean vsync) throws InterruptedException {
         GLWindow glWindow = GLWindow.create(caps);
         Assert.assertNotNull(glWindow);
         glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared);
@@ -96,9 +96,10 @@ public class TestSharedContextVBOES1NEWT extends UITestCase {
         animator.add(glWindow);
 
         glWindow.setVisible(true);
+        Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true));
+        Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true));
 
-        /** insets (if supported) are available only if window is set visible and hence is created */
-        glWindow.setTopLevelPosition(x, y);
+        glWindow.setPosition(x, y);
         
         return glWindow;
     }
@@ -109,8 +110,10 @@ public class TestSharedContextVBOES1NEWT extends UITestCase {
         Animator animator = new Animator();
         GLWindow f1 = runTestGL(animator, 0, 0, true, false);
         InsetsImmutable insets = f1.getInsets();
-        GLWindow f2 = runTestGL(animator, width+insets.getTotalWidth(), 0, true, false);
-        GLWindow f3 = runTestGL(animator, 0, height+insets.getTotalHeight(), false, true);
+        GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(), 
+                                          f1.getY()+0, true, false);
+        GLWindow f3 = runTestGL(animator, f1.getX()+0, 
+                                          f1.getY()+height+insets.getTotalHeight(), false, true);        
         animator.setUpdateFPSFrames(1, null);        
         animator.start();
         while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT.java
index a37c43c..022ef21 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT.java
@@ -37,6 +37,7 @@ import javax.media.opengl.GLPbuffer;
 import javax.media.opengl.GLProfile;
 import com.jogamp.opengl.util.Animator;
 
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
 import com.jogamp.opengl.test.junit.util.UITestCase;
 import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
 
@@ -53,7 +54,6 @@ public class TestSharedContextVBOES2NEWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
         glp = GLProfile.getDefault();
         Assert.assertNotNull(glp);
         caps = new GLCapabilities(glp);
@@ -77,7 +77,7 @@ public class TestSharedContextVBOES2NEWT extends UITestCase {
         sharedDrawable.destroy();
     }
 
-    protected GLWindow runTestGL(Animator animator, int x, int y, boolean useShared, boolean vsync) {
+    protected GLWindow runTestGL(Animator animator, int x, int y, boolean useShared, boolean vsync) throws InterruptedException {
         GLWindow glWindow = GLWindow.create(caps);
         Assert.assertNotNull(glWindow);
         glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared);
@@ -96,9 +96,10 @@ public class TestSharedContextVBOES2NEWT extends UITestCase {
         animator.add(glWindow);
 
         glWindow.setVisible(true);
+        Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true));
+        Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true));
         
-        /** insets (if supported) are available only if window is set visible and hence is created */
-        glWindow.setTopLevelPosition(x, y);
+        glWindow.setPosition(x, y);
 
         return glWindow;
     }
@@ -109,8 +110,10 @@ public class TestSharedContextVBOES2NEWT extends UITestCase {
         Animator animator = new Animator();
         GLWindow f1 = runTestGL(animator, 0, 0, true, false);
         InsetsImmutable insets = f1.getInsets();
-        GLWindow f2 = runTestGL(animator, width+insets.getTotalWidth(), 0, true, false);
-        GLWindow f3 = runTestGL(animator, 0, height+insets.getTotalHeight(), false, true);
+        GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(), 
+                                          f1.getY()+0, true, false);
+        GLWindow f3 = runTestGL(animator, f1.getX()+0, 
+                                          f1.getY()+height+insets.getTotalHeight(), false, true);
         animator.setUpdateFPSFrames(1, null);        
         animator.start();
         while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java
similarity index 74%
copy from src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java
copy to src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java
index a37b4cc..5b2cb25 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java
@@ -34,29 +34,27 @@ import com.jogamp.newt.opengl.GLWindow;
 
 import javax.media.nativewindow.util.InsetsImmutable;
 import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLDrawableFactory;
-import javax.media.opengl.GLPbuffer;
 import javax.media.opengl.GLProfile;
 import com.jogamp.opengl.util.Animator;
 
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
 import com.jogamp.opengl.test.junit.util.UITestCase;
-import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
 
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-public class TestSharedContextListNEWT extends UITestCase {
+public class TestSharedContextVBOES2NEWT2 extends UITestCase {
     static GLProfile glp;
     static GLCapabilities caps;
     static int width, height;
-    GLPbuffer sharedDrawable;
-    Gears sharedGears;
+    GLWindow sharedDrawable;
+    GearsES2 sharedGears;
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
-        glp = GLProfile.getDefault();
+        glp = GLProfile.get(GLProfile.GL2);
         Assert.assertNotNull(glp);
         caps = new GLCapabilities(glp);
         Assert.assertNotNull(caps);
@@ -65,11 +63,14 @@ public class TestSharedContextListNEWT extends UITestCase {
     }
 
     private void initShared() {
-        sharedDrawable = GLDrawableFactory.getFactory(glp).createGLPbuffer(null, caps, null, width, height, null);
+    	sharedDrawable = GLWindow.create(caps);
         Assert.assertNotNull(sharedDrawable);
-        sharedGears = new Gears();
+        // sharedGears = new Gears(0);
+        sharedGears = new GearsES2(0);
         Assert.assertNotNull(sharedGears);
         sharedDrawable.addGLEventListener(sharedGears);
+        sharedDrawable.setSize(width, height);
+        sharedDrawable.setVisible(true);
         // init and render one frame, which will setup the Gears display lists
         sharedDrawable.display();
     }
@@ -77,10 +78,12 @@ public class TestSharedContextListNEWT extends UITestCase {
     private void releaseShared() {
         Assert.assertNotNull(sharedDrawable);
         sharedDrawable.destroy();
+        sharedDrawable = null;
     }
 
-    protected GLWindow runTestGL(Animator animator, int x, int y, boolean useShared, boolean vsync) {
+    protected GLWindow runTestGL(Animator animator, int x, int y, boolean useShared, boolean vsync) throws InterruptedException {
         GLWindow glWindow = GLWindow.create(caps);
+        
         Assert.assertNotNull(glWindow);
         glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared);
         if(useShared) {
@@ -89,39 +92,41 @@ public class TestSharedContextListNEWT extends UITestCase {
 
         glWindow.setSize(width, height);
 
-        Gears gears = new Gears(vsync ? 1 : 0);
+        GearsES2 gears = new GearsES2(vsync ? 1 : 0);
         if(useShared) {
             gears.setGears(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3());
         }
         glWindow.addGLEventListener(gears);
 
         animator.add(glWindow);
-
+        animator.start();
         glWindow.setVisible(true);
 
-        /** insets (if supported) are available only if window is set visible and hence is created */
-        glWindow.setTopLevelPosition(x, y);
-
+        Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true));
+        Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true));
+        glWindow.setPosition(x, y);
+        
         return glWindow;
     }
 
     @Test
     public void test01() throws InterruptedException {
         initShared();
-        Animator animator = new Animator();
-        GLWindow f1 = runTestGL(animator, 0, 0, true, false);
+        GLWindow f1 = runTestGL(new Animator(), 0, 0, true, false);
         InsetsImmutable insets = f1.getInsets();
-        GLWindow f2 = runTestGL(animator, width+insets.getTotalWidth(), 0, true, false);
-        GLWindow f3 = runTestGL(animator, 0, height+insets.getTotalHeight(), false, true);
-        animator.setUpdateFPSFrames(1, null);        
-        animator.start();
-        while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
-            Thread.sleep(100);
-        }
-        animator.stop();
+        GLWindow f2 = runTestGL(new Animator(), f1.getX()+width+insets.getTotalWidth(), 
+                                f1.getY()+0, true, false);
+        GLWindow f3 = runTestGL(new Animator(), f1.getX()+0, 
+                                f1.getY()+height+insets.getTotalHeight(), true, false);
+
+        try {
+			Thread.sleep(duration);
+		} catch(Exception e) {
+			e.printStackTrace();
+		}
 
         // here we go again: On AMD/X11 the create/destroy sequence must be the same
-        // even though this is agains the chicken/egg logic here ..
+        // even though this is against the chicken/egg logic here ..
         releaseShared();
 
         f1.destroy();
@@ -132,7 +137,7 @@ public class TestSharedContextListNEWT extends UITestCase {
         // releaseShared();
     }
 
-    static long duration = 500; // ms
+    static long duration = 2000; // ms
 
     public static void main(String args[]) throws IOException {
         for(int i=0; i<args.length; i++) {
@@ -147,6 +152,6 @@ public class TestSharedContextListNEWT extends UITestCase {
         BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
         System.err.println("Press enter to continue");
         System.err.println(stdin.readLine()); */         
-        org.junit.runner.JUnitCore.main(TestSharedContextListNEWT.class.getName());
+        org.junit.runner.JUnitCore.main(TestSharedContextVBOES2NEWT2.class.getName());
     }
 }
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteAWT.java
new file mode 100644
index 0000000..322ce36
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteAWT.java
@@ -0,0 +1,125 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ * 
+ *    1. Redistributions of source code must retain the above copyright notice, this list of
+ *       conditions and the following disclaimer.
+ * 
+ *    2. Redistributions in binary form must reproduce the above copyright notice, this list
+ *       of conditions and the following disclaimer in the documentation and/or other materials
+ *       provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+ 
+package com.jogamp.opengl.test.junit.jogl.acore;
+
+import java.awt.Frame;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.awt.GLCanvas;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+public class TestShutdownCompleteAWT extends UITestCase {
+
+    static long duration = 300; // ms
+    
+    protected void runTestGL() throws InterruptedException, InvocationTargetException {
+        final Frame frame = new Frame("Gears AWT Test");
+        Assert.assertNotNull(frame);
+
+        final GLCanvas glCanvas = new GLCanvas(new GLCapabilities(GLProfile.getDefault()));
+        Assert.assertNotNull(glCanvas);
+        frame.add(glCanvas);
+        frame.setSize(256, 256);
+
+        glCanvas.addGLEventListener(new Gears(1));
+
+        Animator animator = new Animator(glCanvas);
+
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame.setVisible(true);
+            }});
+        
+        animator.setUpdateFPSFrames(60, System.err);        
+        animator.start();
+        Assert.assertEquals(true, animator.isAnimating());
+        Assert.assertEquals(true, glCanvas.isVisible());
+        Assert.assertEquals(true, glCanvas.isDisplayable());
+
+        while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
+            Thread.sleep(100);
+        }
+        Assert.assertEquals(true, glCanvas.isRealized());
+
+        animator.stop();
+        Assert.assertEquals(false, animator.isAnimating());
+        frame.setVisible(false);
+        Assert.assertEquals(false, frame.isVisible());
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame.remove(glCanvas);
+                frame.dispose();
+            }});
+    }
+
+    protected void oneLife() throws InterruptedException, InvocationTargetException {
+        long t0 = System.nanoTime();
+        GLProfile.initSingleton();
+        long t1 = System.nanoTime();
+        runTestGL();        
+        long t2 = System.nanoTime();
+        GLProfile.shutdown(GLProfile.ShutdownType.COMPLETE);        
+        long t3 = System.nanoTime();
+        System.err.println("Total:                          "+ (t3-t0)/1e6 +"ms"); 
+        System.err.println("  GLProfile.initSingleton():    "+ (t1-t0)/1e6 +"ms"); 
+        System.err.println("  Demo Code:                    "+ (t2-t1)/1e6 +"ms"); 
+        System.err.println("  GLProfile.shutdown(COMPLETE): "+ (t3-t2)/1e6 +"ms"); 
+    }
+    
+    @Test
+    public void test01OneLife() throws InterruptedException, InvocationTargetException {
+        oneLife();
+    }
+
+    @Test
+    public void test01AnotherLife() throws InterruptedException, InvocationTargetException {
+        oneLife();
+    }
+    
+    @Test
+    public void test01TwoLifes() throws InterruptedException, InvocationTargetException {
+        oneLife();
+        oneLife();
+    }
+    
+    public static void main(String args[]) throws IOException {
+        String tstname = TestShutdownCompleteAWT.class.getName();
+        org.junit.runner.JUnitCore.main(tstname);
+    }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteNEWT.java
new file mode 100644
index 0000000..1abac10
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteNEWT.java
@@ -0,0 +1,144 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ * 
+ *    1. Redistributions of source code must retain the above copyright notice, this list of
+ *       conditions and the following disclaimer.
+ * 
+ *    2. Redistributions in binary form must reproduce the above copyright notice, this list
+ *       of conditions and the following disclaimer in the documentation and/or other materials
+ *       provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+ 
+package com.jogamp.opengl.test.junit.jogl.acore;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+public class TestShutdownCompleteNEWT extends UITestCase {
+
+    static long duration = 300; // ms
+    
+    protected void runTestGL() throws InterruptedException {
+        GLWindow glWindow = GLWindow.create(new GLCapabilities(GLProfile.getDefault()));
+        Assert.assertNotNull(glWindow);
+        glWindow.setTitle("Gears NEWT Test");
+
+        glWindow.addGLEventListener(new Gears());
+
+        Animator animator = new Animator(glWindow);
+
+        glWindow.setSize(256, 256);
+        glWindow.setVisible(true);
+        animator.setUpdateFPSFrames(60, System.err);
+        animator.start();
+        Assert.assertEquals(true, animator.isAnimating());
+        Assert.assertEquals(true, glWindow.isVisible());
+        Assert.assertEquals(true, glWindow.isNativeValid());
+        Assert.assertEquals(true, glWindow.isRealized());
+
+        while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
+            Thread.sleep(100);
+        }
+
+        animator.stop();
+        glWindow.destroy();
+    }
+
+    protected void oneLife() throws InterruptedException {
+        if(waitForEach) {
+            waitForEnter();
+        }
+        long t0 = System.nanoTime();
+        GLProfile.initSingleton();
+        long t1 = System.nanoTime();
+        if(!initOnly) {
+            runTestGL();
+        }
+        long t2 = System.nanoTime();
+        GLProfile.shutdown(GLProfile.ShutdownType.COMPLETE);        
+        long t3 = System.nanoTime();
+        System.err.println("Total:                          "+ (t3-t0)/1e6 +"ms"); 
+        System.err.println("  GLProfile.initSingleton():    "+ (t1-t0)/1e6 +"ms"); 
+        System.err.println("  Demo Code:                    "+ (t2-t1)/1e6 +"ms"); 
+        System.err.println("  GLProfile.shutdown(COMPLETE): "+ (t3-t2)/1e6 +"ms"); 
+    }
+    
+    @Test
+    public void test01OneLife() throws InterruptedException {
+        oneLife();
+    }
+
+    @Test
+    public void test01AnotherLife() throws InterruptedException {
+        oneLife();
+    }
+    
+    @Test
+    public void test01TwoLifes() throws InterruptedException {
+        oneLife();
+        oneLife();
+    }
+    
+    static boolean initOnly = false;
+    static boolean waitForEach = false;
+    
+    static void waitForEnter() {
+        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+        System.err.println("Press enter to continue");
+        try {
+            System.err.println(stdin.readLine());
+        } catch (IOException e) { }        
+    }
+    
+    public static void main(String args[]) throws IOException {
+        boolean waitForKey = false;
+        
+        for(int i=0; i<args.length; i++) {
+            if(args[i].equals("-wait")) {
+                waitForKey = true;
+            } else if(args[i].equals("-waitForEach")) {
+                waitForEach = true;
+                waitForKey = true;
+            } else if(args[i].equals("-initOnly")) {
+                initOnly = true;
+            }
+        }
+        
+        if(waitForKey) {
+            waitForEnter();
+        }
+        
+        String tstname = TestShutdownCompleteNEWT.class.getName();
+        org.junit.runner.JUnitCore.main(tstname);
+    }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownSharedAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownSharedAWT.java
new file mode 100644
index 0000000..a12ef23
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownSharedAWT.java
@@ -0,0 +1,124 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ * 
+ *    1. Redistributions of source code must retain the above copyright notice, this list of
+ *       conditions and the following disclaimer.
+ * 
+ *    2. Redistributions in binary form must reproduce the above copyright notice, this list
+ *       of conditions and the following disclaimer in the documentation and/or other materials
+ *       provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+ 
+package com.jogamp.opengl.test.junit.jogl.acore;
+
+import java.awt.Frame;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.awt.GLCanvas;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+public class TestShutdownSharedAWT extends UITestCase {
+
+    static long duration = 300; // ms
+    
+    protected void runTestGL() throws InterruptedException, InvocationTargetException {
+        final Frame frame = new Frame("Gears AWT Test");
+        Assert.assertNotNull(frame);
+
+        final GLCanvas glCanvas = new GLCanvas(new GLCapabilities(GLProfile.getDefault()));
+        Assert.assertNotNull(glCanvas);
+        frame.add(glCanvas);
+        frame.setSize(256, 256);
+
+        glCanvas.addGLEventListener(new Gears(1));
+
+        Animator animator = new Animator(glCanvas);
+
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame.setVisible(true);
+            }});
+        animator.setUpdateFPSFrames(60, System.err);        
+        animator.start();
+        Assert.assertEquals(true, animator.isAnimating());
+        Assert.assertEquals(true, glCanvas.isVisible());
+        Assert.assertEquals(true, glCanvas.isDisplayable());
+
+        while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
+            Thread.sleep(100);
+        }
+        Assert.assertEquals(true, glCanvas.isRealized());
+
+        animator.stop();
+        Assert.assertEquals(false, animator.isAnimating());
+        frame.setVisible(false);
+        Assert.assertEquals(false, frame.isVisible());
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame.remove(glCanvas);
+                frame.dispose();
+            }});
+    }
+
+    protected void oneLife() throws InterruptedException, InvocationTargetException {
+        long t0 = System.nanoTime();
+        GLProfile.initSingleton();
+        long t1 = System.nanoTime();
+        runTestGL();        
+        long t2 = System.nanoTime();
+        GLProfile.shutdown(GLProfile.ShutdownType.SHARED_ONLY);        
+        long t3 = System.nanoTime();
+        System.err.println("Total:                          "+ (t3-t0)/1e6 +"ms"); 
+        System.err.println("  GLProfile.initSingleton():    "+ (t1-t0)/1e6 +"ms"); 
+        System.err.println("  Demo Code:                    "+ (t2-t1)/1e6 +"ms"); 
+        System.err.println("  GLProfile.shutdown(SHARED):   "+ (t3-t2)/1e6 +"ms"); 
+    }
+    
+    @Test
+    public void test01OneLife() throws InterruptedException, InvocationTargetException {
+        oneLife();
+    }
+
+    @Test
+    public void test01AnotherLife() throws InterruptedException, InvocationTargetException {
+        oneLife();
+    }
+    
+    @Test
+    public void test01TwoLifes() throws InterruptedException, InvocationTargetException {
+        oneLife();
+        oneLife();
+    }
+    
+    public static void main(String args[]) throws IOException {
+        String tstname = TestShutdownSharedAWT.class.getName();
+        org.junit.runner.JUnitCore.main(tstname);
+    }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownSharedNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownSharedNEWT.java
new file mode 100644
index 0000000..99b5a6c
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownSharedNEWT.java
@@ -0,0 +1,127 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ * 
+ *    1. Redistributions of source code must retain the above copyright notice, this list of
+ *       conditions and the following disclaimer.
+ * 
+ *    2. Redistributions in binary form must reproduce the above copyright notice, this list
+ *       of conditions and the following disclaimer in the documentation and/or other materials
+ *       provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+ 
+package com.jogamp.opengl.test.junit.jogl.acore;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+public class TestShutdownSharedNEWT extends UITestCase {
+
+    static long duration = 300; // ms
+    
+    protected void runTestGL() throws InterruptedException {
+        GLWindow glWindow = GLWindow.create(new GLCapabilities(GLProfile.getDefault()));
+        Assert.assertNotNull(glWindow);
+        glWindow.setTitle("Gears NEWT Test");
+
+        glWindow.addGLEventListener(new Gears());
+
+        Animator animator = new Animator(glWindow);
+
+        glWindow.setSize(256, 256);
+        glWindow.setVisible(true);
+        animator.setUpdateFPSFrames(60, System.err);
+        animator.start();
+        Assert.assertEquals(true, animator.isAnimating());
+        Assert.assertEquals(true, glWindow.isVisible());
+        Assert.assertEquals(true, glWindow.isNativeValid());
+        Assert.assertEquals(true, glWindow.isRealized());
+
+        while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
+            Thread.sleep(100);
+        }
+
+        animator.stop();
+        glWindow.destroy();
+    }
+
+    protected void oneLife() throws InterruptedException {
+        long t0 = System.nanoTime();
+        GLProfile.initSingleton();
+        long t1 = System.nanoTime();
+        runTestGL();        
+        long t2 = System.nanoTime();
+        GLProfile.shutdown(GLProfile.ShutdownType.SHARED_ONLY);        
+        long t3 = System.nanoTime();
+        System.err.println("Total:                          "+ (t3-t0)/1e6 +"ms"); 
+        System.err.println("  GLProfile.initSingleton():    "+ (t1-t0)/1e6 +"ms"); 
+        System.err.println("  Demo Code:                    "+ (t2-t1)/1e6 +"ms"); 
+        System.err.println("  GLProfile.shutdown(SHARED):   "+ (t3-t2)/1e6 +"ms"); 
+    }
+    
+    @Test
+    public void test01OneLife() throws InterruptedException {
+        oneLife();
+    }
+
+    @Test
+    public void test01AnotherLife() throws InterruptedException {
+        oneLife();
+    }
+    
+    @Test
+    public void test01TwoLifes() throws InterruptedException {
+        oneLife();
+        oneLife();
+    }
+    
+    public static void main(String args[]) throws IOException {
+        boolean waitForKey = false;
+        
+        for(int i=0; i<args.length; i++) {
+            if(args[i].equals("-wait")) {
+                waitForKey = true;
+            }
+        }
+        
+        if(waitForKey) {
+            BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+            System.err.println("Press enter to continue");
+            try {
+                System.err.println(stdin.readLine());
+            } catch (IOException e) { }
+        }
+        
+        String tstname = TestShutdownSharedNEWT.class.getName();
+        org.junit.runner.JUnitCore.main(tstname);
+    }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461OffscreenSupersamplingSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461OffscreenSupersamplingSwingAWT.java
index 55c9c68..284122b 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461OffscreenSupersamplingSwingAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461OffscreenSupersamplingSwingAWT.java
@@ -30,35 +30,9 @@ package com.jogamp.opengl.test.junit.jogl.awt;
 
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
-/**
- * Copyright 2011 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- * 
- *    1. Redistributions of source code must retain the above copyright notice, this list of
- *       conditions and the following disclaimer.
- * 
- *    2. Redistributions in binary form must reproduce the above copyright notice, this list
- *       of conditions and the following disclaimer in the documentation and/or other materials
- *       provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
  
 import java.awt.image.BufferedImage;
+import java.lang.reflect.InvocationTargetException;
 
 import javax.media.opengl.GL;
 import javax.media.opengl.GL2;
@@ -123,12 +97,19 @@ public class TestBug461OffscreenSupersamplingSwingAWT extends UITestCase impleme
 
     /* @Override */
     public void dispose(GLAutoDrawable drawable) {  
-        jframe.setVisible(false);
-        jframe.dispose();
+        try {
+            javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+                public void run() {
+                    jframe.setVisible(false);
+                    jframe.dispose();
+                }});
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 
     @Test
-    public void testOffscreenSupersampling() {
+    public void testOffscreenSupersampling() throws InterruptedException, InvocationTargetException {
         jframe = new JFrame("Offscreen Supersampling");
         Assert.assertNotNull(jframe);
         jframe.setSize( 300, 300);
@@ -163,7 +144,10 @@ public class TestBug461OffscreenSupersamplingSwingAWT extends UITestCase impleme
         Assert.assertNotNull(offScreenBuffer);
         offScreenBuffer.addGLEventListener(this);        
         offScreenBuffer.display();
-        jframe.setVisible( true );
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                jframe.setVisible(true);
+            }});
     }
 
     public static void main(String args[]) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/MultisampleDemo01.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/MultisampleDemo01.java
index b41501a..ab0171c 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/MultisampleDemo01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/MultisampleDemo01.java
@@ -63,7 +63,7 @@ class MultisampleDemo01 implements GLEventListener {
     }
 
     public void init(GLAutoDrawable drawable) {
-        AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+        AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration();
         System.err.println();
         System.err.println("Info: " + config);
         System.err.println();
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyAWT.java
similarity index 51%
copy from src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java
copy to src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyAWT.java
index 2ce6223..8e72096 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyAWT.java
@@ -26,37 +26,39 @@
  * or implied, of JogAmp Community.
  */
  
-package com.jogamp.opengl.test.junit.newt.parenting;
-
-import java.lang.reflect.*;
-
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+package com.jogamp.opengl.test.junit.jogl.caps;
 
 import java.awt.BorderLayout;
+import java.awt.Color;
 import java.awt.Container;
 import java.awt.Dimension;
 import java.awt.Frame;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
 import java.awt.Label;
+import java.awt.Transparency;
+import java.awt.image.ColorModel;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 
-import javax.media.opengl.*;
-
-import com.jogamp.opengl.util.Animator;
-import com.jogamp.newt.*;
-import com.jogamp.newt.event.*;
-import com.jogamp.newt.opengl.*;
-import com.jogamp.newt.awt.NewtCanvasAWT;
+import javax.media.opengl.GLAnimatorControl;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.awt.GLCanvas;
 
-import java.io.IOException;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
-import com.jogamp.opengl.test.junit.util.*;
+import com.jogamp.common.util.ReflectionUtil;
 import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
 
-public class TestParenting03AWT extends UITestCase {
+public class TestTranslucencyAWT extends UITestCase {
     static Dimension size;
     static long durationPerTest = 400;
-    static long waitAdd2nd = 200;
     static GLCapabilities glCaps;
 
     @BeforeClass
@@ -67,62 +69,73 @@ public class TestParenting03AWT extends UITestCase {
         glCaps.setBackgroundOpaque(false);
     }
 
-    @Test
-    public void testWindowParenting1AWTOneNewtChild01() throws InterruptedException, InvocationTargetException {
-        testWindowParenting1AWTOneNewtChild();
+    static Frame getTranslucentFrame() {
+        GraphicsConfiguration gc=null;
+        GraphicsDevice[] devices= GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
+        for (int i = 0; i < devices.length ; i++)
+        {
+            GraphicsConfiguration[] configs = devices[i].getConfigurations();
+            for (int j = 0; j < configs.length ; j++) {
+                GraphicsConfiguration config = configs[j];
+                ColorModel tcm = config.getColorModel(Transparency.TRANSLUCENT);
+                boolean capable1 = ( null != tcm ) ? tcm.getTransparency() == Transparency.TRANSLUCENT : false;
+                boolean capable2 = false;
+                try {
+                    capable2 = ((Boolean)ReflectionUtil.callStaticMethod(
+                                                "com.sun.awt.AWTUtilities", "isTranslucencyCapable", 
+                                                new Class<?>[] { GraphicsConfiguration.class }, 
+                                                new Object[] { config } , 
+                                                GraphicsConfiguration.class.getClassLoader())).booleanValue();
+                    System.err.println("com.sun.awt.AWTUtilities.isTranslucencyCapable(config) passed: "+capable2);
+                } catch (RuntimeException re) {
+                    System.err.println("com.sun.awt.AWTUtilities.isTranslucencyCapable(config) failed: "+re.getMessage());
+                }
+                System.err.println(i+":"+j+" "+config+", "+tcm+", capable "+capable1+"/"+capable2);
+                if(capable1&&capable2) {
+                    gc=configs[j];
+                    System.err.println("Chosen "+i+":"+j+" "+config+", "+tcm+", capable "+capable1+"/"+capable2);
+                    break;
+                }
+            }
+        }
+        final Frame frame = new Frame(gc);
+        if(null!=gc) {
+            frame.setUndecorated(true);
+            frame.setBackground(new Color(0, 0, 0, 0));
+        }
+        frame.setTitle("AWT Parent Frame (opaque: "+(null==gc)+")");
+        return frame;
     }
-
-    public void testWindowParenting1AWTOneNewtChild() throws InterruptedException, InvocationTargetException {
-        GLWindow glWindow1 = GLWindow.create(glCaps);
-        glWindow1.setUpdateFPSFrames(1, null);
-        glWindow1.setUndecorated(true);
-        NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1);
-        newtCanvasAWT1.setPreferredSize(size);
+    
+    @Test
+    public void test() throws InterruptedException, InvocationTargetException {
+        final Frame frame1 = getTranslucentFrame();
+        final GLCanvas glCanvas= new GLCanvas(glCaps);
+        
+        glCanvas.setPreferredSize(size);
 
         GLEventListener demo1 = new GearsES2(1);
-        setDemoFields(demo1, glWindow1, false);
-        glWindow1.addGLEventListener(demo1);
-        final NewtCanvasAWT f_newtCanvasAWT1 = newtCanvasAWT1;
-        final GLWindow f_glWindow1 = glWindow1;
-        glWindow1.addKeyListener(new KeyAdapter() {
-            public void keyTyped(KeyEvent e) {
-                if(e.getKeyChar()=='d') {
-                    f_glWindow1.setUndecorated(!f_glWindow1.isUndecorated());
-                } else if(e.getKeyChar()=='f') {
-                    f_glWindow1.setFullscreen(!f_glWindow1.isFullscreen());
-                } else if(e.getKeyChar()=='r') {
-                    if(f_glWindow1.getParent()==null) {
-                        System.err.println("XXX glWin1 to home");
-                        f_glWindow1.reparentWindow(f_newtCanvasAWT1.getNativeWindow());
-                    } else {
-                        System.err.println("XXX glWin1 to TOP");
-                        f_glWindow1.reparentWindow(null);
-                    }
-                }
-            }
-        });
-        GLAnimatorControl animator1 = new Animator(glWindow1);
+        // setDemoFields(demo1, glCanvas, false);
+        glCanvas.addGLEventListener(demo1);
+        GLAnimatorControl animator1 = new Animator(glCanvas);
         animator1.start();
 
         Container cont1 = new Container();
         cont1.setLayout(new BorderLayout());
-        cont1.add(newtCanvasAWT1, BorderLayout.CENTER);
+        cont1.add(glCanvas, BorderLayout.CENTER);
         cont1.setVisible(true);
 
-        Frame frame1 = new Frame("AWT Parent Frame");
         frame1.setLayout(new BorderLayout());
         frame1.add(cont1, BorderLayout.EAST);
         frame1.add(new Label("center"), BorderLayout.CENTER);
         frame1.setLocation(0, 0);
         frame1.setSize((int)size.getWidth(), (int)size.getHeight());
-        final Frame f_frame1 = frame1;
         javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
-                f_frame1.pack();
-                f_frame1.setVisible(true);
+                frame1.pack();
+                frame1.setVisible(true);
             }});
 
-        Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent());
         Assert.assertEquals(true, animator1.isAnimating());
         Assert.assertEquals(false, animator1.isPaused());
         Assert.assertNotNull(animator1.getThread());
@@ -135,20 +148,6 @@ public class TestParenting03AWT extends UITestCase {
         Assert.assertEquals(null, animator1.getThread());
 
         frame1.dispose();
-        glWindow1.destroy();
-    }
-
-    public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
-        Assert.assertNotNull(demo);
-        Assert.assertNotNull(glWindow);
-        Window window = glWindow.getWindow();
-        if(debug) {
-            MiscUtils.setFieldIfExists(demo, "glDebug", true);
-            MiscUtils.setFieldIfExists(demo, "glTrace", true);
-        }
-        if(!MiscUtils.setFieldIfExists(demo, "window", window)) {
-            MiscUtils.setFieldIfExists(demo, "glWindow", glWindow);
-        }
     }
 
     static int atoi(String a) {
@@ -163,23 +162,9 @@ public class TestParenting03AWT extends UITestCase {
         for(int i=0; i<args.length; i++) {
             if(args[i].equals("-time")) {
                 durationPerTest = atoi(args[++i]);
-            } else if(args[i].equals("-wait")) {
-                waitAdd2nd = atoi(args[++i]);
             }
         }
-        String tstname = TestParenting03AWT.class.getName();
-        /*
-        org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] {
-            tstname,
-            "filtertrace=true",
-            "haltOnError=false",
-            "haltOnFailure=false",
-            "showoutput=true",
-            "outputtoformatters=true",
-            "logfailedtests=true",
-            "logtestlistenerevents=true",
-            "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter",
-            "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } ); */
+        String tstname = TestTranslucencyAWT.class.getName();
         org.junit.runner.JUnitCore.main(tstname);
     }
 
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyNEWT.java
index a01cb59..67e8524 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyNEWT.java
@@ -52,7 +52,6 @@ public class TestTranslucencyNEWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
         /*if(GLProfile.isAvailable(GLProfile.getDefaultEGLDevice(), GLProfile.GLES2)) {
             // exact match
             glp = GLProfile.get(GLProfile.getDefaultEGLDevice(), GLProfile.GLES2);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
index 8d579ce..b5a729e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
@@ -21,6 +21,7 @@
 
 package com.jogamp.opengl.test.junit.jogl.demos.es1;
 
+import javax.media.nativewindow.NativeWindow;
 import javax.media.opengl.GL;
 import javax.media.opengl.GL2ES1;
 import javax.media.opengl.GLAutoDrawable;
@@ -181,8 +182,18 @@ public class GearsES1 implements GLEventListener {
     // Get the GL corresponding to the drawable we are animating
     GL2ES1 gl = drawable.getGL().getGL2ES1();
 
-    gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
-
+    final boolean hasFocus;
+    if(drawable.getNativeSurface() instanceof NativeWindow) {
+      hasFocus = ((NativeWindow)drawable.getNativeSurface()).hasFocus();
+    } else {
+      hasFocus = true;
+    }
+    if(hasFocus) {
+      gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+    } else {
+      gl.glClearColor(0.2f, 0.2f, 0.2f, 0.0f);
+    }
+    
     // Special handling for the case where the GLJPanel is translucent
     // and wants to be composited with other Java 2D content
     if (GLProfile.isAWTAvailable() && 
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java
index 86f63cb..8b41141 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java
@@ -52,7 +52,6 @@ public class TestGearsES1NEWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
         /* if(GLProfile.isAvailable(GLProfile.getDefaultEGLDevice(), GLProfile.GLES1)) {
             // exact match
             glp = GLProfile.get(GLProfile.getDefaultEGLDevice(), GLProfile.GLES1);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java
index e73be50..13aafe4 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java
@@ -52,7 +52,6 @@ public class TestRedSquareES1NEWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
         /* if(GLProfile.isAvailable(GLProfile.getDefaultEGLDevice(), GLProfile.GLES1)) {
             // exact match
             glp = GLProfile.get(GLProfile.getDefaultEGLDevice(), GLProfile.GLES1);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
index 9bff38f..51bc7d1 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
@@ -34,6 +34,8 @@ import com.jogamp.opengl.util.glsl.ShaderCode;
 import com.jogamp.opengl.util.glsl.ShaderProgram;
 import com.jogamp.opengl.util.glsl.ShaderState;
 import java.nio.FloatBuffer;
+
+import javax.media.nativewindow.NativeWindow;
 import javax.media.opengl.GL;
 import javax.media.opengl.GL2ES2;
 import javax.media.opengl.GLAutoDrawable;
@@ -56,6 +58,7 @@ public class GearsES2 implements GLEventListener {
     private GearsObjectES2 gear1=null, gear2=null, gear3=null;
     private float angle = 0.0f;
     private int swapInterval = 0;
+    private boolean pmvUseBackingArray = true; // the default for PMVMatrix now, since it's faster
     // private MouseListener gearsMouse = new TraceMouseAdapter(new GearsMouseAdapter());
     private MouseListener gearsMouse = new GearsMouseAdapter();    
     private KeyListener gearsKeys = new GearsKeyAdapter();
@@ -70,6 +73,10 @@ public class GearsES2 implements GLEventListener {
         this.swapInterval = 1;
     }
 
+    public void setPMVUseBackingArray(boolean pmvUseBackingArray) {
+        this.pmvUseBackingArray = pmvUseBackingArray;
+    }
+    
     public void setGears(GearsObjectES2 g1, GearsObjectES2 g2, GearsObjectES2 g3) {
         gear1 = g1;
         gear2 = g2;
@@ -106,7 +113,7 @@ public class GearsES2 implements GLEventListener {
         gl.glEnable(GL.GL_DEPTH_TEST);
         
         st = new ShaderState();
-        st.setVerbose(true);
+        // st.setVerbose(true);
         final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, this.getClass(),
                 "shader", "shader/bin", "gears");
         final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, this.getClass(),
@@ -119,7 +126,7 @@ public class GearsES2 implements GLEventListener {
         // Use debug pipeline
         // drawable.setGL(new DebugGL(drawable.getGL()));
 
-        pmvMatrix = new PMVMatrix();
+        pmvMatrix = new PMVMatrix(pmvUseBackingArray);
         st.attachObject("pmvMatrix", pmvMatrix);
         pmvMatrixUniform = new GLUniformData("pmvMatrix", 4, 4, pmvMatrix.glGetPMvMvitMatrixf()); // P, Mv, Mvi and Mvit
         st.ownUniform(pmvMatrixUniform);
@@ -173,6 +180,10 @@ public class GearsES2 implements GLEventListener {
         System.err.println(Thread.currentThread()+" GearsES2.init FIN");
     }
 
+    public void enableAndroidTrace(boolean v) {
+        useAndroidDebug = v;
+    }
+    
     public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
         System.err.println(Thread.currentThread()+" GearsES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval);
         GL2ES2 gl = drawable.getGL().getGL2ES2();
@@ -189,10 +200,24 @@ public class GearsES2 implements GLEventListener {
         st.uniform(gl, pmvMatrixUniform);
         st.useProgram(gl, false);
         
+        if(useAndroidDebug) {
+            try {
+                android.os.Debug.startMethodTracing("GearsES2.trace");
+                // android.os.Debug.startAllocCounting();
+                useAndroidDebug = true;
+            } catch (NoClassDefFoundError e) { useAndroidDebug=false; }
+        }
+        
         System.err.println(Thread.currentThread()+" GearsES2.reshape FIN");
     }
+    private boolean useAndroidDebug = false;
 
     public void dispose(GLAutoDrawable drawable) {
+        if(useAndroidDebug) {
+            // android.os.Debug.stopAllocCounting();
+            android.os.Debug.stopMethodTracing();
+        }
+        
         System.err.println(Thread.currentThread()+" GearsES2.dispose ... ");
         if (drawable instanceof Window) {
             Window window = (Window) drawable;
@@ -221,8 +246,18 @@ public class GearsES2 implements GLEventListener {
         // Get the GL corresponding to the drawable we are animating
         GL2ES2 gl = drawable.getGL().getGL2ES2();
 
-        gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
-
+        final boolean hasFocus;
+        if(drawable.getNativeSurface() instanceof NativeWindow) {
+          hasFocus = ((NativeWindow)drawable.getNativeSurface()).hasFocus();
+        } else {
+          hasFocus = true;
+        }
+        if(hasFocus) {
+          gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+        } else {
+          gl.glClearColor(0.2f, 0.2f, 0.2f, 0.0f);
+        }
+        
         // Special handling for the case where the GLJPanel is translucent
         // and wants to be composited with other Java 2D content
         if (GLProfile.isAWTAvailable() && 
@@ -244,9 +279,15 @@ public class GearsES2 implements GLEventListener {
         gear2.draw(gl,  3.1f, -2.0f, -2f * angle -  9.0f, GearsObject.green);
         gear3.draw(gl, -3.1f,  4.2f, -2f * angle - 25.0f, GearsObject.blue);    
         pmvMatrix.glPopMatrix();
-        st.useProgram(gl, false);
+        st.useProgram(gl, false);        
     }
-
+    
+    boolean confinedFixedCenter = false;
+    
+    public void setConfinedFixedCenter(boolean v) {
+        confinedFixedCenter = v;
+    }
+    
     class GearsKeyAdapter extends KeyAdapter {      
         public void keyPressed(KeyEvent e) {
             int kc = e.getKeyCode();
@@ -271,13 +312,30 @@ public class GearsES2 implements GLEventListener {
         public void mouseReleased(MouseEvent e) {
         }
 
+        public void mouseMoved(MouseEvent e) {          
+            if(e.isConfined()) {
+                navigate(e);                                    
+            } else {
+                // track prev. position so we don't have 'jumps'
+                // in case we move to confined navigation.
+                prevMouseX = e.getX();
+                prevMouseY = e.getY();
+            }
+        }
+        
         public void mouseDragged(MouseEvent e) {
+            navigate(e);
+        }
+        
+        private void navigate(MouseEvent e) {
             int x = e.getX();
             int y = e.getY();
-            int width=0, height=0;
+            
+            int width, height;
             Object source = e.getSource();
+            Window window = null;
             if(source instanceof Window) {
-                Window window = (Window) source;
+                window = (Window) source;
                 width=window.getWidth();
                 height=window.getHeight();
             } else if (GLProfile.isAWTAvailable() && source instanceof java.awt.Component) {
@@ -286,15 +344,18 @@ public class GearsES2 implements GLEventListener {
                 height=comp.getHeight();
             } else {
                 throw new RuntimeException("Event source neither Window nor Component: "+source);
+            }           
+            final float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)width);
+            final float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)height);
+            view_rotx += thetaX;
+            view_roty += thetaY;
+            if(e.isConfined() && confinedFixedCenter && null!=window) {                
+                x=window.getWidth()/2;
+                y=window.getHeight()/2;
+                window.warpPointer(x, y);
             }
-            float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)width);
-            float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)height);
-
             prevMouseX = x;
             prevMouseY = y;
-
-            view_rotx += thetaX;
-            view_roty += thetaY;
         }
     }
 }
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
index d06c6da..d645fb9 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
@@ -131,21 +131,6 @@ public class RedSquareES2 implements GLEventListener {
         System.err.println(Thread.currentThread()+" RedSquareES2.init FIN");
     }
 
-    public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) {
-        System.err.println(Thread.currentThread()+" RedSquareES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval);        
-        GL2ES2 gl = glad.getGL().getGL2ES2();
-        
-        st.useProgram(gl, true);
-        // Set location in front of camera
-        pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION);
-        pmvMatrix.glLoadIdentity();
-        pmvMatrix.gluPerspective(45.0F, (float) width / (float) height, 1.0F, 100.0F);
-        //pmvMatrix.glOrthof(-4.0f, 4.0f, -4.0f, 4.0f, 1.0f, 100.0f);
-        st.uniform(gl, pmvMatrixUniform);
-        st.useProgram(gl, false);
-        System.err.println(Thread.currentThread()+" RedSquareES2.reshape FIN");
-    }
-
     public void display(GLAutoDrawable glad) {
         long t1 = System.currentTimeMillis();
 
@@ -170,7 +155,40 @@ public class RedSquareES2 implements GLEventListener {
         st.useProgram(gl, false);
     }
 
+    public void enableAndroidTrace(boolean v) {
+        useAndroidDebug = v;
+    }
+    
+    public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) {
+        System.err.println(Thread.currentThread()+" RedSquareES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval);        
+        GL2ES2 gl = glad.getGL().getGL2ES2();
+        
+        st.useProgram(gl, true);
+        // Set location in front of camera
+        pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION);
+        pmvMatrix.glLoadIdentity();
+        pmvMatrix.gluPerspective(45.0F, (float) width / (float) height, 1.0F, 100.0F);
+        //pmvMatrix.glOrthof(-4.0f, 4.0f, -4.0f, 4.0f, 1.0f, 100.0f);
+        st.uniform(gl, pmvMatrixUniform);
+        st.useProgram(gl, false);
+        
+        if(useAndroidDebug) {
+            try {
+                android.os.Debug.startMethodTracing("RedSquareES2.trace");
+                // android.os.Debug.startAllocCounting();
+                useAndroidDebug = true;
+            } catch (NoClassDefFoundError e) { useAndroidDebug=false; }
+        }
+        
+        System.err.println(Thread.currentThread()+" RedSquareES2.reshape FIN");
+    }
+    private boolean useAndroidDebug = false;
+
     public void dispose(GLAutoDrawable glad) {
+        if(useAndroidDebug) {
+            // android.os.Debug.stopAllocCounting();
+            android.os.Debug.stopMethodTracing();
+        }
         System.err.println(Thread.currentThread()+" RedSquareES2.dispose ... ");
         if (null != glWindow) {
             glWindow.removeMouseListener(myMouse);
@@ -187,7 +205,7 @@ public class RedSquareES2 implements GLEventListener {
     class MyMouseAdapter extends MouseAdapter {
         public void mouseClicked(MouseEvent e) {
             System.err.println(e);
-            if(null != glWindow && e.getSource() == glWindow.getWindow()) {
+            if(null != glWindow && e.getSource() == glWindow.getDelegatedWindow()) {
                 if(e.getX() < glWindow.getWidth()/2) {
                     glWindow.setFullscreen(!glWindow.isFullscreen());
                     System.err.println("setFullscreen: "+glWindow.isFullscreen());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java
index d9cee4f..fb63590 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java
@@ -65,11 +65,6 @@ public class TestElektronenMultipliziererNEWT extends UITestCase {
     static int startFrame = 1700;
     static long duration = 5000; // ms
     
-    @BeforeClass
-    public static void initClass() {
-        GLProfile.initSingleton(true);
-    }
-
     @AfterClass
     public static void releaseClass() {
     }
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
index df86b83..e57b26f 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
@@ -28,6 +28,10 @@
  
 package com.jogamp.opengl.test.junit.jogl.demos.es2.newt;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
 import com.jogamp.newt.event.KeyAdapter;
 import com.jogamp.newt.event.KeyEvent;
 import com.jogamp.newt.opengl.GLWindow;
@@ -38,7 +42,10 @@ import com.jogamp.opengl.util.Animator;
 
 import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
 
+import javax.media.opengl.GLAnimatorControl;
+import javax.media.opengl.GLAutoDrawable;
 import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLEventListener;
 import javax.media.opengl.GLProfile;
 
 import org.junit.Assert;
@@ -52,7 +59,6 @@ public class TestGearsES2NEWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
         /*if(GLProfile.isAvailable(GLProfile.getDefaultEGLDevice(), GLProfile.GLES2)) {
             // exact match
             glp = GLProfile.get(GLProfile.getDefaultEGLDevice(), GLProfile.GLES2);
@@ -61,8 +67,10 @@ public class TestGearsES2NEWT extends UITestCase {
             glp = GLProfile.getGL2ES2(); 
         }
         Assert.assertNotNull(glp);
-        width  = 512;
-        height = 512;
+        // width  = 512;
+        // height = 512;
+        width  = 200;
+        height = 200;
     }
 
     @AfterClass
@@ -71,14 +79,40 @@ public class TestGearsES2NEWT extends UITestCase {
 
     protected void runTestGL(GLCapabilities caps, boolean undecorated) throws InterruptedException {
         System.err.println("requested: "+caps);
-        GLWindow glWindow = GLWindow.create(caps);
+        final GLWindow glWindow = GLWindow.create(caps);
         Assert.assertNotNull(glWindow);
         glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+")");
         glWindow.setSize(width, height);
+        glWindow.setPosition(100, 100);
         glWindow.setUndecorated(undecorated);
         glWindow.setAlwaysOnTop(alwaysOnTop);
         glWindow.setFullscreen(fullscreen);
-        glWindow.addGLEventListener(new GearsES2());
+        glWindow.setPointerVisible(mouseVisible);
+        glWindow.confinePointer(mouseConfined);
+
+        final GearsES2 demo = new GearsES2(vsync ? 1 : 0);
+        demo.setPMVUseBackingArray(pmvUseBackingArray);
+        glWindow.addGLEventListener(demo);
+        if(waitForKey) {
+            glWindow.addGLEventListener(new GLEventListener() {
+                public void init(GLAutoDrawable drawable) { }
+                public void dispose(GLAutoDrawable drawable) { }
+                public void display(GLAutoDrawable drawable) {
+                    GLAnimatorControl  actrl = drawable.getAnimator();
+                    if(waitForKey && actrl.getTotalFPSFrames() == 60*3) {
+                        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+                        System.err.println("Press enter to continue");
+                        try {
+                            System.err.println(stdin.readLine());
+                        } catch (IOException e) { }
+                        actrl.resetFPSCounter();
+                        waitForKey = false;
+                    }
+                }
+                public void reshape(GLAutoDrawable drawable, int x, int y,
+                        int width, int height) { }
+            });
+        }
 
         Animator animator = new Animator(glWindow);
         QuitAdapter quitAdapter = new QuitAdapter();
@@ -88,49 +122,81 @@ public class TestGearsES2NEWT extends UITestCase {
         glWindow.addKeyListener(quitAdapter);
         glWindow.addWindowListener(quitAdapter);
 
-        final GLWindow f_glWindow = glWindow;
         glWindow.addKeyListener(new KeyAdapter() {
             public void keyTyped(KeyEvent e) {
                 if(e.getKeyChar()=='f') {
                     new Thread() {
                         public void run() {
-                            System.err.println("[set fullscreen  pre]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", f "+f_glWindow.isFullscreen()+", "+f_glWindow.getInsets());
-                            f_glWindow.setFullscreen(!f_glWindow.isFullscreen());
-                            System.err.println("[set fullscreen post]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", f "+f_glWindow.isFullscreen()+", "+f_glWindow.getInsets());
+                            System.err.println("[set fullscreen  pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", "+glWindow.getInsets());
+                            glWindow.setFullscreen(!glWindow.isFullscreen());
+                            System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", "+glWindow.getInsets());
                     } }.start();
                 } else if(e.getKeyChar()=='a') {
                     new Thread() {
                         public void run() {
-                            System.err.println("[set alwaysontop pre]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", a "+f_glWindow.isAlwaysOnTop()+", "+f_glWindow.getInsets());
-                            f_glWindow.setAlwaysOnTop(!f_glWindow.isAlwaysOnTop());
-                            System.err.println("[set alwaysontop post]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", a "+f_glWindow.isAlwaysOnTop()+", "+f_glWindow.getInsets());
+                            System.err.println("[set alwaysontop pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
+                            glWindow.setAlwaysOnTop(!glWindow.isAlwaysOnTop());
+                            System.err.println("[set alwaysontop post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets());
                     } }.start();
                 } else if(e.getKeyChar()=='d') {
                     new Thread() {
                         public void run() {
-                            System.err.println("[set undecorated  pre]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", d "+f_glWindow.isUndecorated()+", "+f_glWindow.getInsets());
-                            f_glWindow.setUndecorated(!f_glWindow.isUndecorated());
-                            System.err.println("[set undecorated post]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", d "+f_glWindow.isUndecorated()+", "+f_glWindow.getInsets());
+                            System.err.println("[set undecorated  pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", d "+glWindow.isUndecorated()+", "+glWindow.getInsets());
+                            glWindow.setUndecorated(!glWindow.isUndecorated());
+                            System.err.println("[set undecorated post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", d "+glWindow.isUndecorated()+", "+glWindow.getInsets());
                     } }.start();
                 } else if(e.getKeyChar()=='s') {
                     new Thread() {
                         public void run() {
-                            System.err.println("[set position  pre]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", "+f_glWindow.getInsets());
-                            f_glWindow.setPosition(100, 100);
-                            System.err.println("[set position post]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", "+f_glWindow.getInsets());
+                            System.err.println("[set position  pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets());
+                            glWindow.setPosition(100, 100);
+                            System.err.println("[set position post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets());
+                    } }.start();
+                } else if(e.getKeyChar()=='i') {
+                    new Thread() {
+                        public void run() {
+                            System.err.println("[set mouse visible pre]: "+glWindow.isPointerVisible());
+                            glWindow.setPointerVisible(!glWindow.isPointerVisible());
+                            System.err.println("[set mouse visible post]: "+glWindow.isPointerVisible());
+                    } }.start();
+                } else if(e.getKeyChar()=='j') {
+                    new Thread() {
+                        public void run() {
+                            System.err.println("[set mouse confined pre]: "+glWindow.isPointerConfined());
+                            glWindow.confinePointer(!glWindow.isPointerConfined());
+                            System.err.println("[set mouse confined post]: "+glWindow.isPointerConfined());
+                            if(!glWindow.isPointerConfined()) {
+                                demo.setConfinedFixedCenter(false);
+                            }
+                    } }.start();
+                } else if(e.getKeyChar()=='J') {
+                    new Thread() {
+                        public void run() {
+                            System.err.println("[set mouse confined pre]: "+glWindow.isPointerConfined());
+                            glWindow.confinePointer(!glWindow.isPointerConfined());
+                            System.err.println("[set mouse confined post]: "+glWindow.isPointerConfined());
+                            demo.setConfinedFixedCenter(glWindow.isPointerConfined());
+                    } }.start();
+                } else if(e.getKeyChar()=='w') {
+                    new Thread() {
+                        public void run() {
+                            System.err.println("[set mouse pos pre]");
+                            glWindow.warpPointer(glWindow.getWidth()/2, glWindow.getHeight()/2);
+                            System.err.println("[set mouse pos post]");
                     } }.start();
                 }
             }
         });
 
+        animator.setUpdateFPSFrames(60, System.err);
+        animator.start();
+        // glWindow.setSkipContextReleaseThread(animator.getThread());
+
         glWindow.setVisible(true);
         
-        System.err.println("size/pos: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", "+f_glWindow.getInsets());
+        System.err.println("size/pos: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets());
         System.err.println("chosen: "+glWindow.getChosenCapabilities());
         
-        animator.setUpdateFPSFrames(1, null);
-        animator.start();
-
         while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
             Thread.sleep(100);
         }
@@ -151,8 +217,14 @@ public class TestGearsES2NEWT extends UITestCase {
     static boolean undecorated = false;
     static boolean alwaysOnTop = false;
     static boolean fullscreen = false;
+    static boolean pmvUseBackingArray = true;
+    static boolean vsync = false;
+    static boolean waitForKey = false;
+    static boolean mouseVisible = true;
+    static boolean mouseConfined = false;
 
-    public static void main(String args[]) {
+    public static void main(String args[]) throws IOException {
+        
         for(int i=0; i<args.length; i++) {
             if(args[i].equals("-time")) {
                 i++;
@@ -167,8 +239,34 @@ public class TestGearsES2NEWT extends UITestCase {
                 alwaysOnTop = true;
             } else if(args[i].equals("-fullscreen")) {
                 fullscreen = true;
+            } else if(args[i].equals("-pmvDirect")) {
+                pmvUseBackingArray = false;
+            } else if(args[i].equals("-vsync")) {
+                vsync = true;
+            } else if(args[i].equals("-wait")) {
+                waitForKey = true;
+            } else if(args[i].equals("-mouseInvisible")) {
+                mouseVisible = false;
+            } else if(args[i].equals("-mouseConfine")) {
+                mouseConfined = true;
             }
         }
+        System.err.println("translucent "+(!opaque));
+        System.err.println("undecorated "+undecorated);
+        System.err.println("atop "+alwaysOnTop);
+        System.err.println("fullscreen "+fullscreen);
+        System.err.println("pmvDirect "+(!pmvUseBackingArray));
+        System.err.println("vsync "+vsync);
+        System.err.println("mouseVisible "+mouseVisible);
+        System.err.println("mouseConfined "+mouseConfined);
+
+        if(waitForKey) {
+            BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+            System.err.println("Press enter to continue");
+            try {
+                System.err.println(stdin.readLine());
+            } catch (IOException e) { }
+        }
         org.junit.runner.JUnitCore.main(TestGearsES2NEWT.class.getName());
     }
 }
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java
index 63ec215..f3bad28 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java
@@ -52,7 +52,6 @@ public class TestRedSquareES2NEWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
         /* if(GLProfile.isAvailable(GLProfile.getDefaultEGLDevice(), GLProfile.GLES1)) {
             // exact match
             glp = GLProfile.get(GLProfile.getDefaultEGLDevice(), GLProfile.GLES1);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/elektronenmultiplizierer_development.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/elektronenmultiplizierer_development.fp
index 6c9e048..22fb65e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/elektronenmultiplizierer_development.fp
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/elektronenmultiplizierer_development.fp
@@ -40,7 +40,9 @@ vec2 oglFragCoord;
 
 //const pre-calc
 const float phi = 1.618;
-const float _IKVNORM_ = 1.0 / sqrt(pow(phi * (1.0 + phi), 2.0) + pow(phi * phi - 1.0, 2.0) + pow(1.0 + phi, 2.0));
+// Using math functions in initializers fails on MacOSX
+// const float _IKVNORM_ = 1.0 / sqrt(pow(phi * (1.0 + phi), 2.0) + pow(phi * phi - 1.0, 2.0) + pow(1.0 + phi, 2.0));
+const float _IKVNORM_ = 0.190989113930771;
 const float _C1_ = phi * (1.0 + phi) * _IKVNORM_;
 const float _C2_ = (phi * phi - 1.0) * _IKVNORM_;
 const float _1C_ = (1.0 + phi) * _IKVNORM_;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.fp
index e8feef2..f41adda 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.fp
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.fp
@@ -23,17 +23,16 @@ const vec4 matSpecular = vec4(0.8, 0.8, 0.8, 1.0);
 const float matShininess = 0.5;
 
 void main()
-{ 
-    float lambertTerm = dot(normal, lightDir);       
- 
+{  
     vec4 ambient = color * matAmbient;
-    vec4 diffuse = color * lambertTerm *  attenuation * matDiffuse;
     vec4 specular = vec4(0.0);
+    
+    float lambertTerm = dot(normal, lightDir);       
+    vec4 diffuse = color * lambertTerm *  attenuation * matDiffuse;
     if (lambertTerm > 0.0) {
         float NdotHV;
         /*
-        vec3 halfDir;        
-        halfDir  = normalize (lightDir + cameraDir); 
+        vec3 halfDir = normalize (lightDir + cameraDir); 
         NdotHV   = max(0.0, dot(normal, halfDir));
         */      
         vec3 E = normalize(-position.xyz);  
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java
index 8ab6412..f032696 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java
@@ -41,6 +41,7 @@ import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
 import com.jogamp.opengl.test.junit.util.UITestCase;
 import com.jogamp.opengl.test.junit.util.QuitAdapter;
 import java.awt.Frame;
+import java.lang.reflect.InvocationTargetException;
 
 import org.junit.Assert;
 import org.junit.BeforeClass;
@@ -50,6 +51,7 @@ import org.junit.Test;
 public class TestGearsAWT extends UITestCase {
     static GLProfile glp;
     static int width, height;
+    static boolean firstUIActionOnProcess = false;
 
     @BeforeClass
     public static void initClass() {
@@ -63,16 +65,16 @@ public class TestGearsAWT extends UITestCase {
     public static void releaseClass() {
     }
 
-    protected void runTestGL(GLCapabilities caps) throws InterruptedException {
-        Frame frame = new Frame("Gears AWT Test");
+    protected void runTestGL(GLCapabilities caps) throws InterruptedException, InvocationTargetException {
+        final Frame frame = new Frame("Gears AWT Test");
         Assert.assertNotNull(frame);
 
-        GLCanvas glCanvas = new GLCanvas(caps);
+        final GLCanvas glCanvas = new GLCanvas(caps);
         Assert.assertNotNull(glCanvas);
         frame.add(glCanvas);
         frame.setSize(512, 512);
 
-        glCanvas.addGLEventListener(new Gears());
+        glCanvas.addGLEventListener(new Gears(1));
 
         Animator animator = new Animator(glCanvas);
         QuitAdapter quitAdapter = new QuitAdapter();
@@ -80,8 +82,11 @@ public class TestGearsAWT extends UITestCase {
         new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glCanvas);
         new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame);
 
-        frame.setVisible(true);
-        animator.setUpdateFPSFrames(1, null);        
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame.setVisible(true);
+            }});
+        animator.setUpdateFPSFrames(60, System.err);        
         animator.start();
 
         while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
@@ -96,14 +101,15 @@ public class TestGearsAWT extends UITestCase {
         Assert.assertEquals(false, animator.isAnimating());
         frame.setVisible(false);
         Assert.assertEquals(false, frame.isVisible());
-        frame.remove(glCanvas);
-        frame.dispose();
-        frame=null;
-        glCanvas=null;
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame.remove(glCanvas);
+                frame.dispose();
+            }});
     }
 
     @Test
-    public void test01() throws InterruptedException {
+    public void test01() throws InterruptedException, InvocationTargetException {
         GLCapabilities caps = new GLCapabilities(glp);
         runTestGL(caps);
     }
@@ -117,6 +123,8 @@ public class TestGearsAWT extends UITestCase {
                 try {
                     duration = Integer.parseInt(args[i]);
                 } catch (Exception ex) { ex.printStackTrace(); }
+            } else if(args[i].equals("-firstUIAction")) {
+                firstUIActionOnProcess = true;
             }
         }
         org.junit.runner.JUnitCore.main(TestGearsAWT.class.getName());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWTAnalyzeBug455.java
similarity index 57%
copy from src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java
copy to src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWTAnalyzeBug455.java
index 8ab6412..4b670f0 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWTAnalyzeBug455.java
@@ -41,13 +41,21 @@ import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
 import com.jogamp.opengl.test.junit.util.UITestCase;
 import com.jogamp.opengl.test.junit.util.QuitAdapter;
 import java.awt.Frame;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.lang.reflect.InvocationTargetException;
 
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.AfterClass;
 import org.junit.Test;
 
-public class TestGearsAWT extends UITestCase {
+public class TestGearsAWTAnalyzeBug455 extends UITestCase {
+    static long duration = 500; // ms
+    static boolean waitForKey = false; // for manual profiling
+    static boolean altSwap = true;     // using alternate GL swap method (copy pixel) no [auto-]swap
+
     static GLProfile glp;
     static int width, height;
 
@@ -63,16 +71,40 @@ public class TestGearsAWT extends UITestCase {
     public static void releaseClass() {
     }
 
-    protected void runTestGL(GLCapabilities caps) throws InterruptedException {
-        Frame frame = new Frame("Gears AWT Test");
+    static class Swapper implements GLEventListener {
+        public void init(GLAutoDrawable drawable) {
+            System.err.println("auto-swap: "+drawable.getAutoSwapBufferMode());
+        }
+        public void dispose(GLAutoDrawable drawable) {
+        }
+        public void display(GLAutoDrawable drawable) {
+            if(!drawable.getAutoSwapBufferMode()) {
+                GL2 gl = drawable.getGL().getGL2();
+                // copy the colored content of the back buffer into the front buffer
+                // gl.glPushAttrib(GL.GL_COLOR_BUFFER_BIT);
+                gl.glReadBuffer(GL.GL_BACK);  // def. in dbl buff mode: GL_BACK
+                gl.glDrawBuffer(GL.GL_FRONT); // def. in dbl buff mode: GL_BACK
+                gl.glCopyPixels(0, 0, drawable.getWidth(), drawable.getHeight(), GL2.GL_COLOR);
+                // gl.glPopAttrib();
+                gl.glDrawBuffer(GL.GL_BACK); // def. in dbl buff mode: GL_BACK
+            }            
+        }
+        public void reshape(GLAutoDrawable drawable, int x, int y, int width,
+                int height) {
+        }        
+    }
+    protected void runTestGL(GLCapabilities caps) throws InterruptedException, InvocationTargetException {
+        final Frame frame = new Frame("Gears AWT Test");
         Assert.assertNotNull(frame);
 
-        GLCanvas glCanvas = new GLCanvas(caps);
+        final GLCanvas glCanvas = new GLCanvas(caps);
         Assert.assertNotNull(glCanvas);
+        glCanvas.setAutoSwapBufferMode(!altSwap);
         frame.add(glCanvas);
         frame.setSize(512, 512);
 
-        glCanvas.addGLEventListener(new Gears());
+        glCanvas.addGLEventListener(new Gears(0));
+        glCanvas.addGLEventListener(new Swapper());
 
         Animator animator = new Animator(glCanvas);
         QuitAdapter quitAdapter = new QuitAdapter();
@@ -80,8 +112,11 @@ public class TestGearsAWT extends UITestCase {
         new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glCanvas);
         new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame);
 
-        frame.setVisible(true);
-        animator.setUpdateFPSFrames(1, null);        
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame.setVisible(true);
+            }});
+        animator.setUpdateFPSFrames(60, System.err);        
         animator.start();
 
         while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
@@ -96,20 +131,20 @@ public class TestGearsAWT extends UITestCase {
         Assert.assertEquals(false, animator.isAnimating());
         frame.setVisible(false);
         Assert.assertEquals(false, frame.isVisible());
-        frame.remove(glCanvas);
-        frame.dispose();
-        frame=null;
-        glCanvas=null;
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame.remove(glCanvas);
+                frame.dispose();
+            }});
     }
 
     @Test
-    public void test01() throws InterruptedException {
+    public void test01() throws InterruptedException, InvocationTargetException {
         GLCapabilities caps = new GLCapabilities(glp);
+        caps.setDoubleBuffered(true); // code assumes dbl buffer setup
         runTestGL(caps);
     }
 
-    static long duration = 500; // ms
-
     public static void main(String args[]) {
         for(int i=0; i<args.length; i++) {
             if(args[i].equals("-time")) {
@@ -117,8 +152,20 @@ public class TestGearsAWT extends UITestCase {
                 try {
                     duration = Integer.parseInt(args[i]);
                 } catch (Exception ex) { ex.printStackTrace(); }
+            } else if(args[i].equals("-wait")) {
+                waitForKey = true;
+            } else if(args[i].equals("-autoswap")) {
+                altSwap = false;
             }
         }
-        org.junit.runner.JUnitCore.main(TestGearsAWT.class.getName());
+        System.err.println("altSwap "+altSwap);
+        if(waitForKey) {
+            BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+            System.err.println("Press enter to continue");
+            try {
+                System.err.println(stdin.readLine());
+            } catch (IOException e) { }
+        }
+        org.junit.runner.JUnitCore.main(TestGearsAWTAnalyzeBug455.class.getName());
     }
 }
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNEWT.java
index 4b6f799..f410baf 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNEWT.java
@@ -55,7 +55,6 @@ public class TestGearsNEWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
         glp = GLProfile.getDefault();
         Assert.assertNotNull(glp);
         width  = 512;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/drawable/TestDrawable01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/drawable/TestDrawable01NEWT.java
index 5568b42..731f7c8 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/drawable/TestDrawable01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/drawable/TestDrawable01NEWT.java
@@ -52,7 +52,6 @@ public class TestDrawable01NEWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
         glp = GLProfile.getDefault();
         Assert.assertNotNull(glp);
         factory = GLDrawableFactory.getFactory(glp);
@@ -99,7 +98,7 @@ public class TestDrawable01NEWT extends UITestCase {
         // Create native OpenGL resources .. XGL/WGL/CGL .. 
         // equivalent to GLAutoDrawable methods: setVisible(true)
         // 
-        GLCapabilities glCaps = (GLCapabilities) window.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+        GLCapabilities glCaps = (GLCapabilities) window.getGraphicsConfiguration().getChosenCapabilities();
         Assert.assertNotNull(glCaps);
         Assert.assertTrue(glCaps.getGreenBits()>5);
         Assert.assertTrue(glCaps.getBlueBits()>5);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java
index ae08b64..297cbbb 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java
@@ -37,8 +37,8 @@ import javax.media.opengl.GLDrawable;
 import org.junit.Assert;
 
 public class GLSLMiscHelper {
-    public static final int frames_perftest =  10000; // frames
-    public static final int frames_warmup   =    500; // frames
+    public static final int frames_perftest = 600; // frames
+    public static final int frames_warmup   = 100; // frames
     
     public static void validateGLArrayDataServerState(GL2ES2 gl, GLArrayDataServer data) {
         final ShaderState st = ShaderState.getShaderState(gl);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestFBOMRTNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestFBOMRTNEWT01.java
index 9dd9200..aca1e66 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestFBOMRTNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestFBOMRTNEWT01.java
@@ -27,6 +27,7 @@
  */
 package com.jogamp.opengl.test.junit.jogl.glsl;
 
+import com.jogamp.common.os.Platform;
 import com.jogamp.opengl.util.FBObject;
 import com.jogamp.opengl.util.GLArrayDataServer;
 import com.jogamp.opengl.util.PMVMatrix;
@@ -44,6 +45,7 @@ import javax.media.opengl.GL;
 import javax.media.opengl.GL2ES2;
 import javax.media.opengl.GL2GL3;
 import javax.media.opengl.GLDrawable;
+import javax.media.opengl.GLPipelineFactory;
 import javax.media.opengl.GLProfile;
 import javax.media.opengl.GLUniformData;
 
@@ -54,17 +56,14 @@ import org.junit.BeforeClass;
 public class TestFBOMRTNEWT01 extends UITestCase {
     static long durationPerTest = 10; // ms
 
-    @BeforeClass
-    public static void initClass() {
-        GLProfile.initSingleton(true);
-    }
-    
     @Test
     public void test01() throws InterruptedException {
         // preset ..
-        final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(GLProfile.getGL2ES2(), 640, 480, true);
+        final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(GLProfile.getGL2ES2(), 640, 480, true);        
         final GLDrawable drawable = winctx.context.getGLDrawable();
-        final GL _gl = winctx.context.getGL();
+        GL _gl = winctx.context.getGL();
+        Assert.assertTrue(_gl.isGL2GL3());
+        _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", null, _gl, null) );
         Assert.assertTrue(_gl.isGL2GL3());
         final GL2GL3 gl = _gl.getGL2GL3();
         System.err.println(winctx.context);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java
index 6729383..ea29069 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java
@@ -54,15 +54,11 @@ import org.junit.BeforeClass;
  */
 public class TestGLSLShaderState01NEWT extends UITestCase {
     static long durationPerTest = 10; // ms
+    static boolean firstUIActionOnProcess = false;
 
     static final int vertices0_loc = 0; // FIXME: AMD needs this to be location 0 ? hu ?
     static final int colors0_loc = 1;
     
-    @BeforeClass
-    public static void initClass() {
-        GLProfile.initSingleton(true);
-    }
-    
     @Test
     public void testShaderState01Validation() throws InterruptedException {
         // preset ..
@@ -181,11 +177,11 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
         NEWTGLContext.destroyWindow(winctx);
     }
 
-    @Test(timeout=120000)
+    @Test(timeout=240000)
     public void testShaderState00PerformanceSingleKeepEnabled() throws InterruptedException {
         testShaderState00PerformanceSingle(false);
     }
-    @Test(timeout=120000)
+    @Test(timeout=240000)
     public void testShaderState00PerformanceSingleToggleEnable() throws InterruptedException {
         testShaderState00PerformanceSingle(true);
     }
@@ -278,7 +274,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
         NEWTGLContext.destroyWindow(winctx);        
     }
     
-    @Test(timeout=120000)
+    @Test(timeout=240000)
     public void testShaderState01PerformanceDouble() throws InterruptedException {
         // preset ..
         final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(GLProfile.getGL2ES2(), 480, 480, false);
@@ -386,9 +382,10 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
         for(int i=0; i<args.length; i++) {
             if(args[i].equals("-time")) {
                 durationPerTest = MiscUtils.atoi(args[++i], (int)durationPerTest);
-            }
-            if(args[i].equals("-wait")) {
+            } else if(args[i].equals("-wait")) {
                 wait = true;
+            } else if(args[i].equals("-firstUIAction")) {
+                firstUIActionOnProcess = true;
             }
         }
         if(wait) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java
index 2bb8256..fb52ff0 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java
@@ -58,11 +58,6 @@ public class TestGLSLShaderState02NEWT extends UITestCase {
     static final int vertices0_loc = 0; // FIXME: AMD needs this to be location 0 ? hu ?
     static final int colors0_loc = 5;
     
-    @BeforeClass
-    public static void initClass() {
-        GLProfile.initSingleton(true);
-    }
-    
     @Test
     public void testShaderState01ValidationSP1Linked() throws InterruptedException {
         testShaderState01Validation(true);
@@ -236,7 +231,7 @@ public class TestGLSLShaderState02NEWT extends UITestCase {
         NEWTGLContext.destroyWindow(winctx);
     }
 
-    @Test(timeout=120000)    
+    @Test(timeout=240000)    
     public void testShaderState01PerformanceDouble() throws InterruptedException {
         // preset ..
         final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(GLProfile.getGL2ES2(), 480, 480, false);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java
index b683cb2..6721939 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java
@@ -54,19 +54,6 @@ import org.junit.AfterClass;
 public class TestGLSLSimple01NEWT extends UITestCase {
     static long durationPerTest = 100; // ms
 
-    @BeforeClass
-    public static void initClass() {
-        System.err.println("class init");
-        GLProfile.initSingleton(true);
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        System.err.println("class tear down ..");
-        GLProfile.shutdown();
-        System.err.println("class tear down end");
-    }
-
     @Test(timeout=60000)
     public void testGLSLCompilation01() {
         GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java
index cc97efb..13780a7 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java
@@ -28,6 +28,7 @@
 package com.jogamp.opengl.test.junit.jogl.glsl;
 
 import com.jogamp.common.nio.Buffers;
+import com.jogamp.newt.ScreenMode;
 import com.jogamp.newt.util.MonitorMode;
 import com.jogamp.opengl.util.GLArrayDataServer;
 import com.jogamp.opengl.util.PMVMatrix;
@@ -56,13 +57,11 @@ import org.junit.BeforeClass;
 public class TestRulerNEWT01 extends UITestCase {
     static long durationPerTest = 10; // ms
 
-    @BeforeClass
-    public static void initClass() {
-        GLProfile.initSingleton(true);
-    }
-    
     @Test
     public void test01() throws InterruptedException {
+        long t0 = System.nanoTime();
+        GLProfile.initSingleton();
+        long t1 = System.nanoTime();
         // preset ..
         final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(GLProfile.getGL2ES2(), 640, 480, true);
         final GLDrawable drawable = winctx.context.getGLDrawable();
@@ -105,7 +104,13 @@ public class TestRulerNEWT01 extends UITestCase {
         st.uniform(gl, rulerColor);        
         Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
         
-        final MonitorMode mmode = winctx.window.getScreen().getCurrentScreenMode().getMonitorMode();
+        Assert.assertNotNull(winctx);
+        Assert.assertNotNull(winctx.window);
+        Assert.assertNotNull(winctx.window.getScreen());
+        ScreenMode sm = winctx.window.getScreen().getCurrentScreenMode();
+        Assert.assertNotNull(sm);
+        System.err.println(sm);
+        final MonitorMode mmode = sm.getMonitorMode();
         final DimensionImmutable sdim = mmode.getScreenSizeMM();
         final DimensionImmutable spix = mmode.getSurfaceSize().getResolution();   
         final GLUniformData rulerPixFreq = new GLUniformData("gcu_RulerPixFreq", 2, Buffers.newDirectFloatBuffer(2));
@@ -154,7 +159,15 @@ public class TestRulerNEWT01 extends UITestCase {
             Thread.sleep(durationPerTest/10);
         }
         
+        long t2 = System.nanoTime();
+        
         NEWTGLContext.destroyWindow(winctx);
+        
+        long t3 = System.nanoTime();
+        
+        System.err.println("t1-t0: "+ (t1-t0)/1e6 +"ms"); 
+        System.err.println("t3-t0: "+ (t3-t0)/1e6 +"ms"); 
+        System.err.println("t3-t2: "+ (t3-t2)/1e6 +"ms"); 
     }
     
     public static void main(String args[]) throws IOException {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestTransformFeedbackVaryingsBug407NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestTransformFeedbackVaryingsBug407NEWT.java
index a6d04cf..a3059ba 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestTransformFeedbackVaryingsBug407NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestTransformFeedbackVaryingsBug407NEWT.java
@@ -29,16 +29,6 @@ public class TestTransformFeedbackVaryingsBug407NEWT extends UITestCase {
 
     private String VERTEX_SHADER_TEXT;
 
-    @BeforeClass
-    public static void initClass() {
-        GLProfile.initSingleton(true);
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        GLProfile.shutdown();
-    }
-
     class MyShader {
         int shaderProgram;
         int vertShader;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java b/src/test/com/jogamp/opengl/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java
index 2809a13..213d3ad 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java
@@ -112,9 +112,6 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase {
     public static void setup() throws InterruptedException, InvocationTargetException, AWTException {
         System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.setup(): Start Pre-JOGL-Swing");
 
-        // GLProfile.initSingleton(false);
-        // GLProfile.initSingleton(true);
-
         // simulate AWT usage before JOGL's initialization of X11 threading
         windowClosing=false;
         border = BorderFactory.createLineBorder (Color.yellow, 2);
@@ -166,8 +163,7 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase {
         System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.setup(): Before JOGL init");
 
         // just to trigger JOGL initialization at a well defined point ..
-        // ofc it's not the first UI command
-        GLProfile.initSingleton(false);
+        GLProfile.initSingleton();
 
         System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.setup(): End Pre-JOGL-Swing");
     }
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java
index 5618194..3f1fd14 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java
@@ -56,7 +56,6 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
         glpDefault = GLProfile.getDefault();
         Assert.assertNotNull(glpDefault);
         glDrawableFactory = GLDrawableFactory.getFactory(glpDefault);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java
index 1b43940..e2ce78b 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java
@@ -61,7 +61,6 @@ public class TestOffscreen02BitmapNEWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
         glpDefault = GLProfile.getDefault();
         Assert.assertNotNull(glpDefault);
         glDrawableFactory = GLDrawableFactory.getFactory(glpDefault);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java
index 199b094..1d1ee1e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java
@@ -103,7 +103,7 @@ public class WindowUtilNEWT {
         while ( windowOffScreen.getTotalFPSFrames() < frames) {
             windowOffScreen.display();
         }
-        windowOffScreen.removeAllSurfaceUpdatedListener();
+        windowOffScreen.removeSurfaceUpdatedListener(ul);
 
     }
 
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT01GLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT01GLn.java
index e6d937d..d302c39 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT01GLn.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT01GLn.java
@@ -73,7 +73,6 @@ public class TestSWT01GLn extends UITestCase {
 
     @BeforeClass
     public static void startup() {
-        GLProfile.initSingleton(true);
         System.out.println( "GLProfile " + GLProfile.glAvailabilityToString() );
     }
 
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java
index 1ee3748..b8e45df 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java
@@ -77,20 +77,31 @@ public class TestSWT02GLn extends UITestCase {
 
     @BeforeClass
     public static void startup() {
-        GLProfile.initSingleton( true );
         System.out.println( "GLProfile " + GLProfile.glAvailabilityToString() );
     }
 
     @Before
     public void init() {
-        display = new Display();
-        Assert.assertNotNull( display );
-        shell = new Shell( display );
+        final Display[] r = new Display[1];
+        final Shell[] s = new Shell[1];
+        SWTAccessor.invoke(true, new Runnable() {
+           public void run() {
+               r[0] = new Display();
+               s[0] = new Shell();
+           }
+        });
+        display = r[0];
+        shell = s[0];        
+        Assert.assertNotNull( display );        
         Assert.assertNotNull( shell );
-        shell.setLayout( new FillLayout() );
-        composite = new Composite( shell, SWT.NONE );
-        composite.setLayout( new FillLayout() );
-        Assert.assertNotNull( composite );
+        
+        SWTAccessor.invoke(true, new Runnable() {
+           public void run() {
+            shell.setLayout( new FillLayout() );
+            composite = new Composite( shell, SWT.NONE );
+            Assert.assertNotNull( composite );
+            composite.setLayout( new FillLayout() );
+           }});
     }
 
     @After
@@ -99,9 +110,12 @@ public class TestSWT02GLn extends UITestCase {
         Assert.assertNotNull( shell );
         Assert.assertNotNull( composite );
         try {
-            composite.dispose();
-            shell.dispose();
-            display.dispose();
+            SWTAccessor.invoke(true, new Runnable() {
+               public void run() {
+                composite.dispose();
+                shell.dispose();
+                display.dispose();
+               }});
         }
         catch( Throwable throwable ) {
             throwable.printStackTrace();
@@ -111,14 +125,25 @@ public class TestSWT02GLn extends UITestCase {
         shell = null;
         composite = null;
     }
-
+    
+    class CanvasCStr implements Runnable {
+           Canvas canvas;
+           
+           public void run() {
+               canvas = new Canvas( composite, SWT.NO_BACKGROUND);
+           }        
+    }
+    
     protected void runTestAGL( GLProfile glprofile ) throws InterruptedException {
         GLCapabilities caps = new GLCapabilities(glprofile);
         GLDrawableFactory factory = GLDrawableFactory.getFactory(glprofile);
         
         // need SWT.NO_BACKGROUND to prevent SWT from clearing the window
         // at the wrong times (we use glClear for this instead)
-        final Canvas canvas = new Canvas( composite, SWT.NO_BACKGROUND);
+        CanvasCStr canvasCstr = new CanvasCStr();
+        
+        SWTAccessor.invoke(true, canvasCstr);
+        final Canvas canvas = canvasCstr.canvas;        
         Assert.assertNotNull( canvas );
         
         SWTAccessor.setRealized(canvas, true);
@@ -129,7 +154,7 @@ public class TestSWT02GLn extends UITestCase {
         
         ProxySurface proxySurface = factory.createProxySurface(device, nativeWindowHandle, caps, null);
         Assert.assertNotNull( proxySurface );        
-        proxySurface.setSize( 640, 480 );
+        proxySurface.surfaceSizeChanged( 640, 480 );
         System.err.println("*** ProxySurface: " + proxySurface);
         final GLDrawable drawable = factory.createGLDrawable(proxySurface);
         Assert.assertNotNull( drawable );
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAWT01GLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAWT01GLn.java
index 595e6fb..6139d81 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAWT01GLn.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAWT01GLn.java
@@ -29,6 +29,7 @@
 package com.jogamp.opengl.test.junit.jogl.swt;
 
 import java.awt.Frame;
+import java.lang.reflect.InvocationTargetException;
 
 import javax.media.opengl.GL2;
 import javax.media.opengl.GLAutoDrawable;
@@ -37,6 +38,8 @@ import javax.media.opengl.GLEventListener;
 import javax.media.opengl.GLProfile;
 import javax.media.opengl.awt.GLCanvas;
 
+import jogamp.nativewindow.swt.SWTAccessor;
+
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.awt.SWT_AWT;
 import org.eclipse.swt.graphics.Rectangle;
@@ -76,46 +79,47 @@ public class TestSWTAWT01GLn extends UITestCase {
     }
 
     @Before
-    public void init() {
-        display = new Display();
-        Assert.assertNotNull( display );
-        shell = new Shell( display );
-        Assert.assertNotNull( shell );
-        shell.setLayout( new FillLayout() );
-        composite = new Composite( shell, SWT.EMBEDDED | SWT.NO_BACKGROUND );
-        composite.setLayout( new FillLayout() );
-        Assert.assertNotNull( composite );
-        frame = SWT_AWT.new_Frame( composite );
-        Assert.assertNotNull( frame );
+    public void init() throws InterruptedException, InvocationTargetException {
+        SWTAccessor.invoke(true, new Runnable() {
+            public void run() {        
+                display = new Display();
+                Assert.assertNotNull( display );
+                shell = new Shell( display );
+                Assert.assertNotNull( shell );
+                shell.setLayout( new FillLayout() );
+                composite = new Composite( shell, SWT.EMBEDDED | SWT.NO_BACKGROUND );
+                composite.setLayout( new FillLayout() );
+                Assert.assertNotNull( composite );
+                frame = SWT_AWT.new_Frame( composite );
+                Assert.assertNotNull( frame );
+            }});
     }
 
     @After
-    public void release() {
+    public void release() throws InterruptedException, InvocationTargetException {
         Assert.assertNotNull( display );
         Assert.assertNotNull( shell );
         Assert.assertNotNull( composite );
         Assert.assertNotNull( glcanvas );
-        try {
-            javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
-                public void run() {
-                    frame.setVisible(false);
-                    frame.remove(glcanvas);
-                    frame.dispose();
-                }});
-            composite.dispose();
-            shell.close();
-            shell.dispose();
-            display.dispose();
-        }
-        catch( Throwable throwable ) {
-            throwable.printStackTrace();
-            Assume.assumeNoException( throwable );
-        }
-        display = null;
-        shell = null;
-        composite = null;
-        frame = null;
-        glcanvas = null;
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame.setVisible(false);
+                frame.remove(glcanvas);
+                frame.dispose();
+                frame = null;
+                glcanvas = null;
+            }});
+        
+        SWTAccessor.invoke(true, new Runnable() {
+            public void run() {
+                composite.dispose();
+                shell.close();
+                shell.dispose();
+                display.dispose();
+                display = null;
+                shell = null;
+                composite = null;
+            }});
     }
 
     protected void runTestGL( GLProfile glprofile ) throws InterruptedException {
@@ -148,18 +152,26 @@ public class TestSWTAWT01GLn extends UITestCase {
             }
         });
 
-        shell.setText( getClass().getName() );
-        shell.setSize( 640, 480 );
-        shell.open();
+        SWTAccessor.invoke(true, new Runnable() {
+            public void run() {
+                shell.setText( getClass().getName() );
+                shell.setSize( 640, 480 );
+                shell.open();
+            }});
 
         long lStartTime = System.currentTimeMillis();
         long lEndTime = lStartTime + duration;
         try {
             while( (System.currentTimeMillis() < lEndTime) && !composite.isDisposed() ) {
-                if( !display.readAndDispatch() ) {
-                    // blocks on linux .. display.sleep();
-                    Thread.sleep(10);
-                }
+                SWTAccessor.invoke(true, new Runnable() {
+                    public void run() {
+                        if( !display.readAndDispatch() ) {
+                            // blocks on linux .. display.sleep();
+                            try {
+                                Thread.sleep(10);
+                            } catch (InterruptedException e) { }
+                        }
+                    }});
             }
         }
         catch( Throwable throwable ) {
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestCloseNewtAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestCloseNewtAWT.java
index 69f9da0..4ebb7dd 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestCloseNewtAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestCloseNewtAWT.java
@@ -39,10 +39,9 @@ import javax.media.nativewindow.NativeWindow;
 import javax.media.nativewindow.util.Point;
 import javax.media.opengl.GLCapabilities;
 import javax.media.opengl.GLProfile;
+
 import com.jogamp.newt.Window;
 import com.jogamp.newt.awt.NewtCanvasAWT;
-import com.jogamp.newt.event.WindowAdapter;
-import com.jogamp.newt.event.WindowEvent;
 import com.jogamp.newt.opengl.GLWindow;
 import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
 import com.jogamp.opengl.test.junit.util.UITestCase;
@@ -53,6 +52,7 @@ public class TestCloseNewtAWT extends UITestCase {
     NewtCanvasAWT newtCanvas = null;
     JFrame frame = null;
 
+    @SuppressWarnings("serial")
     class MyCanvas extends NewtCanvasAWT {
          public MyCanvas(Window window) {
             super(window);
@@ -78,7 +78,7 @@ public class TestCloseNewtAWT extends UITestCase {
                     NativeWindow nw = MyCanvas.this.getNativeWindow();
                     if(null != nw) {
                         Point p = nw.getLocationOnScreen(null);
-                        System.err.println("MyCanvas On NEWT-EDT: position: "+p);
+                        System.err.println("MyCanvas On NEWT-EDT: position: "+p);                        
                     } else {
                         System.err.println("MyCanvas On NEWT-EDT: position n/a, null NativeWindow");
                     }
@@ -97,7 +97,7 @@ public class TestCloseNewtAWT extends UITestCase {
         newtWindow = GLWindow.create(new GLCapabilities(GLProfile.getDefault()));
         newtCanvas = new MyCanvas(newtWindow);
 
-        SwingUtilities.invokeLater(new Runnable() {
+        SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 frame = new JFrame("NEWT Close Test");
                 frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
@@ -107,11 +107,9 @@ public class TestCloseNewtAWT extends UITestCase {
                 frame.setVisible(true);
             }
         });
-        Thread.sleep(1000);
+        Thread.sleep(500);
 
         Assert.assertEquals(true,  AWTRobotUtil.closeWindow(frame, true));
-
-        GLProfile.shutdown();
     }
 
     public static void main(String[] args) {
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java
index d027460..c9450c2 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java
@@ -51,7 +51,6 @@ public class TestDisplayLifecycle01NEWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
         width  = 640;
         height = 480;
         glp = GLProfile.getDefault();
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java
index 4b3c5d5..bf50912 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java
@@ -51,7 +51,6 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
         width  = 640;
         height = 480;
         glp = GLProfile.getDefault();
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestEventSourceNotAWTBug.java b/src/test/com/jogamp/opengl/test/junit/newt/TestEventSourceNotAWTBug.java
index e6f3f0a..7956e22 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestEventSourceNotAWTBug.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestEventSourceNotAWTBug.java
@@ -32,6 +32,7 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 
 import javax.media.opengl.GLCapabilities;
 import javax.media.opengl.GLProfile;
@@ -54,7 +55,7 @@ public class TestEventSourceNotAWTBug extends UITestCase {
     }
 
     @Test
-    public void testEventSourceNotNewtBug() throws InterruptedException {
+    public void testEventSourceNotNewtBug() throws InterruptedException, InvocationTargetException {
         JFrame jf = new JFrame();
 
         jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
@@ -69,7 +70,7 @@ public class TestEventSourceNotAWTBug extends UITestCase {
 
         final JFrame f_jf = jf;
 
-        SwingUtilities.invokeLater(new Runnable() {
+        SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 f_jf.setSize(800, 600);
                 f_jf.setVisible(true);
@@ -78,7 +79,7 @@ public class TestEventSourceNotAWTBug extends UITestCase {
 
         Thread.sleep(500);
 
-        SwingUtilities.invokeLater(new Runnable() {
+        SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 f_jf.dispose();
             }
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java
index 173cae1..fe7fef0 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java
@@ -35,6 +35,7 @@ import org.junit.Assume;
 import java.awt.AWTException;
 import java.awt.BorderLayout;
 import java.awt.Button;
+import java.awt.Color;
 import java.awt.Robot;
 import java.lang.reflect.InvocationTargetException;
 
@@ -43,9 +44,7 @@ import javax.media.opengl.GLEventListener;
 import javax.swing.JFrame;
 
 import java.util.ArrayList;
-import java.io.BufferedReader;
 import java.io.IOException;
-import java.io.InputStreamReader;
 
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -59,7 +58,7 @@ import com.jogamp.opengl.test.junit.util.*;
 
 public class TestFocus01SwingAWTRobot extends UITestCase {
     static int width, height;
-    static long durationPerTest = 800;
+    static long durationPerTest = 10;
     static long awtWaitTimeout = 1000;
 
     static GLCapabilities glCaps;
@@ -98,7 +97,6 @@ public class TestFocus01SwingAWTRobot extends UITestCase {
         TestListenerCom01AWT.setDemoFields(demo1, glWindow1, false);
         glWindow1.addGLEventListener(demo1);
         NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1");
-        eventCountAdapters.add(glWindow1FA);
         glWindow1.addWindowListener(glWindow1FA);
 
         // Monitor NEWT focus and keyboard events.
@@ -115,7 +113,6 @@ public class TestFocus01SwingAWTRobot extends UITestCase {
         eventCountAdapters.add(newtCanvasAWTKA);
         AWTFocusAdapter newtCanvasAWTFA = new AWTFocusAdapter("NewtCanvasAWT");
         newtCanvasAWT.addFocusListener(newtCanvasAWTFA);
-        eventCountAdapters.add(newtCanvasAWTFA);
 
         // Add the canvas to a frame, and make it all visible.
         final JFrame frame1 = new JFrame("Swing AWT Parent Frame: "
@@ -123,18 +120,22 @@ public class TestFocus01SwingAWTRobot extends UITestCase {
         AWTFocusAdapter frame1FA = new AWTFocusAdapter("frame1");
         frame1.addFocusListener(frame1FA);
         frame1.getContentPane().add(newtCanvasAWT, BorderLayout.CENTER);
-        Button button = new Button("Click me ..");
+        final Button button = new Button("Click me ..");
         AWTFocusAdapter buttonFA = new AWTFocusAdapter("Button");
         button.addFocusListener(buttonFA);
-        eventCountAdapters.add(buttonFA);
         AWTKeyAdapter buttonKA = new AWTKeyAdapter("Button");
         button.addKeyListener(buttonKA);
         eventCountAdapters.add(buttonKA);
         frame1.getContentPane().add(button, BorderLayout.NORTH);
         frame1.setSize(width, height);
-        frame1.setVisible(true);
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame1.setVisible(true);
+            } } );
         Assert.assertTrue(AWTRobotUtil.toFront(robot, frame1));
 
+        Thread.sleep(durationPerTest); // manual testing
+        
         int wait=0;
         while(wait<awtWaitTimeout/100 && glWindow1.getTotalFPSFrames()<1) { Thread.sleep(awtWaitTimeout/10); wait++; }
         System.err.println("Frames for initial setVisible(true): "+glWindow1.getTotalFPSFrames());
@@ -151,10 +152,12 @@ public class TestFocus01SwingAWTRobot extends UITestCase {
         
         System.err.println("FOCUS AWT  Button request");
         EventCountAdapterUtil.reset(eventCountAdapters);
-        AWTRobotUtil.assertRequestFocusAndWait(robot, button, button, buttonFA, null);
-        Assert.assertEquals(true, buttonFA.hasFocus());
-        Assert.assertEquals(false, glWindow1FA.hasFocus());
-        Assert.assertEquals(false, newtCanvasAWTFA.hasFocus());
+        AWTRobotUtil.assertRequestFocusAndWait(robot, button, button, buttonFA, frame1FA);
+        Assert.assertEquals(true,  buttonFA.focusGained());
+        Assert.assertEquals(false, frame1FA.focusGained());
+        Assert.assertEquals(true,  frame1FA.focusLost());
+        Assert.assertEquals(false, glWindow1FA.focusGained());
+        Assert.assertEquals(false, newtCanvasAWTFA.focusGained());
         System.err.println("FOCUS AWT  Button sync");
         AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, button, buttonKA);
 
@@ -163,10 +166,10 @@ public class TestFocus01SwingAWTRobot extends UITestCase {
         System.err.println("FOCUS NEWT Canvas/GLWindow request");
         EventCountAdapterUtil.reset(eventCountAdapters);
         AWTRobotUtil.assertRequestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonFA);
-        Assert.assertTrue(AWTRobotUtil.waitForFocusCount(false, newtCanvasAWTFA));
-        Assert.assertEquals(true, glWindow1FA.hasFocus());
-        Assert.assertEquals(false, newtCanvasAWTFA.hasFocus());
-        Assert.assertEquals(false, buttonFA.hasFocus());
+        Assert.assertEquals(true,  glWindow1FA.focusGained());
+        Assert.assertEquals(false, buttonFA.focusGained());
+        Assert.assertEquals(true,  buttonFA.focusLost());
+        Assert.assertEquals(false, newtCanvasAWTFA.focusGained());
         System.err.println("FOCUS NEWT Canvas/GLWindow sync");
         AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA);
         Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount());
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java
index 78f2f45..b9eb748 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java
@@ -58,6 +58,7 @@ import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
 
 public class TestFocus02SwingAWTRobot extends UITestCase {
     static int width, height;
+    static long durationPerTest = 10;
     static long awtWaitTimeout = 1000;
     static GLCapabilities glCaps;
 
@@ -93,7 +94,6 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
         glWindow1.addGLEventListener(demo1);
         NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1");
         glWindow1.addWindowListener(glWindow1FA);
-        eventCountAdapters.add(glWindow1FA);
         NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1");
         glWindow1.addKeyListener(glWindow1KA);
         eventCountAdapters.add(glWindow1KA);
@@ -104,7 +104,6 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
         NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
         AWTFocusAdapter newtCanvasAWTFA = new AWTFocusAdapter("NewtCanvasAWT");
         newtCanvasAWT.addFocusListener(newtCanvasAWTFA);
-        eventCountAdapters.add(newtCanvasAWTFA);
         AWTKeyAdapter newtCanvasAWTKA = new AWTKeyAdapter("NewtCanvasAWT");
         newtCanvasAWT.addKeyListener(newtCanvasAWTKA);
         eventCountAdapters.add(newtCanvasAWTKA);
@@ -115,7 +114,6 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
         Button buttonNorthInner = new Button("north");
         AWTFocusAdapter buttonNorthInnerFA = new AWTFocusAdapter("ButtonNorthInner");
         buttonNorthInner.addFocusListener(buttonNorthInnerFA);
-        eventCountAdapters.add(buttonNorthInnerFA);
         AWTKeyAdapter buttonNorthInnerKA = new AWTKeyAdapter("ButtonNorthInner");
         buttonNorthInner.addKeyListener(buttonNorthInnerKA);
         eventCountAdapters.add(buttonNorthInnerKA);
@@ -133,7 +131,6 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
         Button buttonNorthOuter = new Button("north");
         AWTFocusAdapter buttonNorthOuterFA = new AWTFocusAdapter("ButtonNorthOuter");
         buttonNorthOuter.addFocusListener(buttonNorthOuterFA);
-        eventCountAdapters.add(buttonNorthOuterFA);
         AWTKeyAdapter buttonNorthOuterKA = new AWTKeyAdapter("ButtonNorthOuter");
         buttonNorthOuter.addKeyListener(buttonNorthOuterKA);
         eventCountAdapters.add(buttonNorthOuterKA);
@@ -148,14 +145,17 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
         jPanel1.add(new Button("west"), BorderLayout.WEST);
         jPanel1.add(container1, BorderLayout.CENTER);
 
-        JFrame jFrame1 = new JFrame("Swing Parent JFrame");
+        final JFrame jFrame1 = new JFrame("Swing Parent JFrame");
         AWTFocusAdapter jFrame1FA = new AWTFocusAdapter("JFrame1");
         jFrame1.addFocusListener(jFrame1FA);
         // jFrame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         jFrame1.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // equivalent to Frame, use windowClosing event!
         jFrame1.setContentPane(jPanel1);
         jFrame1.setSize(width, height);
-        jFrame1.setVisible(true); // from here on, we need to run modifications on EDT
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                jFrame1.setVisible(true);
+            } } );
         Assert.assertTrue(AWTRobotUtil.toFront(robot, jFrame1));
 
         int wait=0;
@@ -169,34 +169,39 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
         animator1.start();
         AWTRobotUtil.assertRequestFocusAndWait(robot, jFrame1, jFrame1, jFrame1FA, null);
 
+        Thread.sleep(durationPerTest); // manual testing
+        
         // Button Outer Focus
         Thread.sleep(100); // allow event sync
         System.err.println("FOCUS AWT  Button Outer request");
         EventCountAdapterUtil.reset(eventCountAdapters);
-        AWTRobotUtil.assertRequestFocusAndWait(robot, buttonNorthOuter, buttonNorthOuter, buttonNorthOuterFA, null);
-        Assert.assertEquals(true, buttonNorthOuterFA.hasFocus());
-        Assert.assertEquals(false, glWindow1FA.hasFocus());
-        Assert.assertEquals(false, newtCanvasAWTFA.hasFocus());
-        Assert.assertEquals(false, buttonNorthInnerFA.hasFocus());
-        Assert.assertEquals(false, jFrame1FA.hasFocus());
+        AWTRobotUtil.assertRequestFocusAndWait(robot, buttonNorthOuter, buttonNorthOuter, buttonNorthOuterFA, jFrame1FA);
+        Assert.assertEquals(true,  buttonNorthOuterFA.focusGained());
+        Assert.assertEquals(false, jFrame1FA.focusGained());
+        Assert.assertEquals(true,  jFrame1FA.focusLost());
+        Assert.assertEquals(false, glWindow1FA.focusGained());
+        Assert.assertEquals(false, newtCanvasAWTFA.focusGained());
+        Assert.assertEquals(false, buttonNorthInnerFA.focusGained());
+        Assert.assertEquals(false, jFrame1FA.focusGained());
         System.err.println("FOCUS AWT  Button Outer sync");
         AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, buttonNorthOuter, buttonNorthOuterKA);
         AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1, 
                                       buttonNorthOuter, buttonNorthOuterMA);
         AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2, 
-                                      buttonNorthOuter, buttonNorthOuterMA);
+                                      buttonNorthOuter, buttonNorthOuterMA);                                     
 
         // NEWT Focus
         Thread.sleep(100); // allow event sync
         System.err.println("FOCUS NEWT Canvas/GLWindow request");
         EventCountAdapterUtil.reset(eventCountAdapters);
         AWTRobotUtil.assertRequestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonNorthOuterFA);
-        Assert.assertTrue(AWTRobotUtil.waitForFocusCount(false, newtCanvasAWTFA));
-        Assert.assertEquals(true, glWindow1FA.hasFocus());
-        Assert.assertEquals(false, newtCanvasAWTFA.hasFocus());
-        Assert.assertEquals(false, buttonNorthInnerFA.hasFocus());
-        Assert.assertEquals(false, buttonNorthOuterFA.hasFocus());
-        Assert.assertEquals(false, jFrame1FA.hasFocus());
+        Assert.assertEquals(true,  glWindow1FA.focusGained());
+        Assert.assertEquals(false, buttonNorthOuterFA.focusGained());
+        Assert.assertEquals(true,  buttonNorthOuterFA.focusLost());        
+        Assert.assertEquals(false, newtCanvasAWTFA.focusGained());
+        Assert.assertEquals(false, buttonNorthInnerFA.focusGained());
+        Assert.assertEquals(false, buttonNorthOuterFA.focusGained());
+        Assert.assertEquals(false, jFrame1FA.focusGained());
         System.err.println("FOCUS NEWT Canvas/GLWindow sync");
         AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA);
         Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount());
@@ -211,11 +216,12 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
         System.err.println("FOCUS AWT  Button request");
         EventCountAdapterUtil.reset(eventCountAdapters);
         AWTRobotUtil.assertRequestFocusAndWait(robot, buttonNorthInner, buttonNorthInner, buttonNorthInnerFA, glWindow1FA);
-        Assert.assertEquals(true, buttonNorthInnerFA.hasFocus());
-        Assert.assertEquals(false, glWindow1FA.hasFocus());
-        Assert.assertEquals(false, newtCanvasAWTFA.hasFocus());
-        Assert.assertEquals(false, buttonNorthOuterFA.hasFocus());
-        Assert.assertEquals(false, jFrame1FA.hasFocus());
+        Assert.assertEquals(true,  buttonNorthInnerFA.focusGained());
+        Assert.assertEquals(false, glWindow1FA.focusGained());
+        Assert.assertEquals(true,  glWindow1FA.focusLost());        
+        Assert.assertEquals(false, newtCanvasAWTFA.focusGained());
+        Assert.assertEquals(false, buttonNorthOuterFA.focusGained());
+        Assert.assertEquals(false, jFrame1FA.focusGained());
         System.err.println("FOCUS AWT  Button sync");
         AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, buttonNorthInner, buttonNorthInnerKA);
         AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1, 
@@ -229,11 +235,12 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
         EventCountAdapterUtil.reset(eventCountAdapters);
         AWTRobotUtil.assertRequestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonNorthInnerFA);
         Assert.assertTrue(AWTRobotUtil.waitForFocusCount(false, newtCanvasAWTFA));
-        Assert.assertEquals(true, glWindow1FA.hasFocus());
-        Assert.assertEquals(false, newtCanvasAWTFA.hasFocus());
-        Assert.assertEquals(false, buttonNorthInnerFA.hasFocus());
-        Assert.assertEquals(false, buttonNorthOuterFA.hasFocus());
-        Assert.assertEquals(false, jFrame1FA.hasFocus());
+        Assert.assertEquals(true,  glWindow1FA.focusGained());
+        Assert.assertEquals(false, buttonNorthInnerFA.focusGained());
+        Assert.assertEquals(true,  buttonNorthInnerFA.focusLost());
+        Assert.assertEquals(false, newtCanvasAWTFA.focusGained());
+        Assert.assertEquals(false, buttonNorthOuterFA.focusGained());
+        Assert.assertEquals(false, jFrame1FA.focusGained());
         System.err.println("FOCUS NEWT Canvas/GLWindow sync");
         AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA);
         Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount());
@@ -283,6 +290,11 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
     public static void main(String args[]) 
         throws IOException, AWTException, InterruptedException, InvocationTargetException 
     {
+        for(int i=0; i<args.length; i++) {
+            if(args[i].equals("-time")) {
+                durationPerTest = atoi(args[++i]);
+            }
+        }
         if(true) {
             String tstname = TestFocus02SwingAWTRobot.class.getName();
             org.junit.runner.JUnitCore.main(tstname);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows00NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows00NEWT.java
index 5c42f2b..309d7c7 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows00NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows00NEWT.java
@@ -50,8 +50,6 @@ public class TestGLWindows00NEWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
-        // GLProfile.initSingleton(false);
         width  = 640;
         height = 480;
         glp = GLProfile.getDefault();
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows01NEWT.java
index 45a0b0b..0c6f60b 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows01NEWT.java
@@ -50,8 +50,6 @@ public class TestGLWindows01NEWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
-        // GLProfile.initSingleton(false);
         width  = 640;
         height = 480;
         glp = GLProfile.getDefault();
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java b/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java
index 3176d59..6f4ced5 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java
@@ -52,7 +52,6 @@ public class TestGLWindows02NEWTAnimated extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
         width  = 640;
         height = 480;
         glp = GLProfile.getDefault();
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java
index 15151fa..fa7f0f9 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java
@@ -42,6 +42,7 @@ import com.jogamp.newt.opengl.*;
 import com.jogamp.newt.awt.NewtCanvasAWT;
 
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 
 import com.jogamp.opengl.test.junit.util.*;
 import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
@@ -58,7 +59,7 @@ public class TestListenerCom01AWT extends UITestCase {
     }
 
     @Test
-    public void testListenerStringPassingAndOrder() throws InterruptedException {
+    public void testListenerStringPassingAndOrder() throws InterruptedException, InvocationTargetException {
         // setup NEWT GLWindow ..
         GLWindow glWindow = GLWindow.create(new GLCapabilities(null));
         Assert.assertNotNull(glWindow);
@@ -88,10 +89,13 @@ public class TestListenerCom01AWT extends UITestCase {
 
         // attach NEWT GLWindow to AWT Canvas
         NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow);
-        Frame frame = new Frame("AWT Parent Frame");
+        final Frame frame = new Frame("AWT Parent Frame");
         frame.add(newtCanvasAWT);
         frame.setSize(width, height);
-        frame.setVisible(true);
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame.setVisible(true);
+            }});
 
         Animator animator1 = new Animator(glWindow);
         animator1.setUpdateFPSFrames(1, null);        
@@ -104,14 +108,17 @@ public class TestListenerCom01AWT extends UITestCase {
         animator1.stop();
         Assert.assertEquals(false, animator1.isAnimating());
 
-        frame.dispose();
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame.dispose();
+            }});
         glWindow.destroy();
     }
 
     public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
         Assert.assertNotNull(demo);
         Assert.assertNotNull(glWindow);
-        Window window = glWindow.getWindow();
+        Window window = glWindow.getDelegatedWindow();
         if(debug) {
             MiscUtils.setFieldIfExists(demo, "glDebug", true);
             MiscUtils.setFieldIfExists(demo, "glTrace", true);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestRemoteGLWindows01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestRemoteGLWindows01NEWT.java
index 578aa55..35e2440 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestRemoteGLWindows01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestRemoteGLWindows01NEWT.java
@@ -42,25 +42,15 @@ import com.jogamp.newt.opengl.*;
 import java.io.IOException;
 
 import com.jogamp.opengl.test.junit.util.UITestCase;
-import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.jogl.demos.es1.GearsES1;
 
 import javax.media.nativewindow.AbstractGraphicsDevice;
 import javax.media.nativewindow.NativeWindowException;
 
 public class TestRemoteGLWindows01NEWT extends UITestCase {
-    static GLProfile glp;
-    static int width, height;
+    static int width = 640, height = 480;
     static long durationPerTest = 100; // ms
-    static String remoteDisplay = "nowhere:0.0";
-
-    @BeforeClass
-    public static void initClass() {
-        GLProfile.initSingleton(true);
-        // GLProfile.initSingleton(false);
-        width  = 640;
-        height = 480;
-        glp = GLProfile.getDefault();
-    }
+    static String remoteDisplay = "localhost:0.0";
 
     static GLWindow createWindow(Screen screen, GLCapabilities caps, GLEventListener demo)
         throws InterruptedException
@@ -98,54 +88,67 @@ public class TestRemoteGLWindows01NEWT extends UITestCase {
     @Test
     public void testRemoteWindow01() throws InterruptedException {
         Animator animator = new Animator();
-        GLCapabilities caps = new GLCapabilities(glp);
-        Assert.assertNotNull(caps);
-        GLWindow window1 = createWindow(null, caps, new GearsES2(1)); // local with vsync
-        Assert.assertEquals(true,window1.isNativeValid());
-        Assert.assertEquals(true,window1.isVisible());
-        AbstractGraphicsDevice device1 = window1.getScreen().getDisplay().getGraphicsDevice();
+        GLProfile glpLocal = GLProfile.getGL2ES1();
+        Assert.assertNotNull(glpLocal);
+        GLCapabilities capsLocal = new GLCapabilities(glpLocal);
+        Assert.assertNotNull(capsLocal);
+        GearsES1 demoLocal = new GearsES1(1);
+        GLWindow windowLocal = createWindow(null, capsLocal, demoLocal); // local with vsync
+        Assert.assertEquals(true,windowLocal.isNativeValid());
+        Assert.assertEquals(true,windowLocal.isVisible());
+        AbstractGraphicsDevice device1 = windowLocal.getScreen().getDisplay().getGraphicsDevice();
 
         System.err.println("GLProfiles window1: "+device1.getConnection()+": "+GLProfile.glAvailabilityToString(device1));
 
-        animator.add(window1);
+        animator.add(windowLocal);
 
         // Remote Display/Device/Screen/Window ..
         // Eager initialization of NEWT Display -> AbstractGraphicsDevice -> GLProfile (device)
-        Display display2; // remote display
-        AbstractGraphicsDevice device2;
-        Screen screen2;
-        GLWindow window2;
+        Display displayRemote; // remote display
+        AbstractGraphicsDevice deviceRemote;
+        Screen screenRemote;
+        GLWindow windowRemote;
+        GearsES1 demoRemote = null;
         try {
-            display2 = NewtFactory.createDisplay(remoteDisplay); // remote display
-            display2.createNative();
-            System.err.println(display2);
-            device2 = display2.getGraphicsDevice();
-            System.err.println(device2);
-            GLProfile.initProfiles(device2); // just to make sure
-            System.err.println("");
-            System.err.println("GLProfiles window2: "+device2.getConnection()+": "+GLProfile.glAvailabilityToString(device2));
-            screen2  = NewtFactory.createScreen(display2, 0); // screen 0
-            window2 = createWindow(screen2, caps, new GearsES2(0)); // remote, no vsync
+            displayRemote = NewtFactory.createDisplay(remoteDisplay); // remote display
+            displayRemote.createNative();
+            System.err.println(displayRemote);
+            deviceRemote = displayRemote.getGraphicsDevice();
+            System.err.println(deviceRemote);
+            GLProfile.initProfiles(deviceRemote); // just to make sure
+            System.err.println();
+            System.err.println("GLProfiles window2: "+deviceRemote.getConnection()+": "+GLProfile.glAvailabilityToString(deviceRemote));
+            GLProfile glpRemote = GLProfile.get(deviceRemote, GLProfile.GL2ES1);
+            Assert.assertNotNull(glpRemote);
+            GLCapabilities capsRemote = new GLCapabilities(glpRemote);
+            Assert.assertNotNull(capsRemote);
+            screenRemote  = NewtFactory.createScreen(displayRemote, 0); // screen 0
+            demoRemote = new GearsES1(0);
+            windowRemote = createWindow(screenRemote, capsRemote, demoRemote); // remote, no vsync
         } catch (NativeWindowException nwe) {
             System.err.println(nwe);
             Assume.assumeNoException(nwe);
-            destroyWindow(window1);
+            destroyWindow(windowLocal);
             return;
         }
 
-        Assert.assertEquals(true,window2.isNativeValid());
-        Assert.assertEquals(true,window2.isVisible());
+        Assert.assertEquals(true,windowRemote.isNativeValid());
+        Assert.assertEquals(true,windowRemote.isVisible());
 
-        animator.add(window2);
+        animator.add(windowRemote);
         animator.setUpdateFPSFrames(1, null);        
         animator.start();
 
         while(animator.getTotalFPSDuration()<durationPerTest) {
             Thread.sleep(100);
         }
+        if(null!=demoRemote) {
+            System.err.println("demoLocal VBO: "+demoLocal.getGear1().backFace.isVBO());
+            System.err.println("demoRemote VBO: "+demoRemote.getGear1().backFace.isVBO());
+        }
 
-        destroyWindow(window1);
-        destroyWindow(window2);
+        destroyWindow(windowLocal);
+        destroyWindow(windowRemote);
     }
 
     static int atoi(String a) {
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestRemoteWindow01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestRemoteWindow01NEWT.java
index 9c44545..eb65258 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestRemoteWindow01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestRemoteWindow01NEWT.java
@@ -43,7 +43,7 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
 
 public class TestRemoteWindow01NEWT extends UITestCase {
     static int width, height;
-    static String remoteDisplay = "nowhere:0.0";
+    static String remoteDisplay = "localhost:0.0";
 
     @BeforeClass
     public static void initClass() {
@@ -77,7 +77,7 @@ public class TestRemoteWindow01NEWT extends UITestCase {
         // Create native OpenGL resources .. XGL/WGL/CGL .. 
         // equivalent to GLAutoDrawable methods: setVisible(true)
         // 
-        CapabilitiesImmutable chosenCapabilities = window.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+        CapabilitiesImmutable chosenCapabilities = window.getGraphicsConfiguration().getChosenCapabilities();
         Assert.assertNotNull(chosenCapabilities);
         Assert.assertTrue(chosenCapabilities.getGreenBits()>5);
         Assert.assertTrue(chosenCapabilities.getBlueBits()>5);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java
index cfb8c77..985affa 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java
@@ -103,26 +103,21 @@ public class TestScreenMode00NEWT extends UITestCase {
         Screen screen = window.getScreen();
 
         List<ScreenMode> screenModes = screen.getScreenModes();
-        if(null != screenModes) {
-            Assert.assertTrue(screenModes.size()>0);
-            int i=0;
-            for(Iterator<ScreenMode> iter=screenModes.iterator(); iter.hasNext(); i++) {
-                System.err.println(i+": "+iter.next());
-            }
-            ScreenMode sm_o = screen.getOriginalScreenMode();
-            Assert.assertNotNull(sm_o);            
-            ScreenMode sm_c = screen.getCurrentScreenMode();
-            Assert.assertNotNull(sm_c);
-            System.err.println("orig SM: "+sm_o);
-            System.err.println("curr SM: "+sm_c);
-            System.err.println("curr sz: "+screen.getWidth()+"x"+screen.getHeight());
-            Assert.assertEquals(sm_o, sm_c);
-            Assert.assertEquals(sm_c.getRotatedWidth(), screen.getWidth());
-            Assert.assertEquals(sm_c.getRotatedHeight(), screen.getHeight());
-        } else {
-            // no support ..
-            System.err.println("Your platform has no ScreenMode change support, sorry");
+        Assert.assertTrue(screenModes.size()>0);
+        int i=0;
+        for(Iterator<ScreenMode> iter=screenModes.iterator(); iter.hasNext(); i++) {
+            System.err.println(i+": "+iter.next());
         }
+        ScreenMode sm_o = screen.getOriginalScreenMode();
+        Assert.assertNotNull(sm_o);            
+        ScreenMode sm_c = screen.getCurrentScreenMode();
+        Assert.assertNotNull(sm_c);
+        System.err.println("orig SM: "+sm_o);
+        System.err.println("curr SM: "+sm_c);
+        System.err.println("curr sz: "+screen.getWidth()+"x"+screen.getHeight());
+        Assert.assertEquals(sm_o, sm_c);
+        Assert.assertEquals(sm_c.getRotatedWidth(), screen.getWidth());
+        Assert.assertEquals(sm_c.getRotatedHeight(), screen.getHeight());
 
         window.destroy();
 
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java
index 15b3740..e9e66da 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java
@@ -82,30 +82,25 @@ public class TestScreenMode00bNEWT extends UITestCase {
         Assert.assertEquals(true,display.isNativeValid());
         
         List<ScreenMode> screenModes = screen.getScreenModes();
-        if(null != screenModes) {
-            Assert.assertTrue(screenModes.size()>0);
-            int i=0;
-            for(Iterator<ScreenMode> iter=screenModes.iterator(); iter.hasNext(); i++) {
-                System.err.println(i+": "+iter.next());
-            }
-            ScreenMode sm_o = screen.getOriginalScreenMode();
-            
-            Assert.assertNotNull(sm_o);            
-            ScreenMode sm_c = screen.getCurrentScreenMode();
+        Assert.assertTrue(screenModes.size()>0);
+        int i=0;
+        for(Iterator<ScreenMode> iter=screenModes.iterator(); iter.hasNext(); i++) {
+            System.err.println(i+": "+iter.next());
+        }
+        ScreenMode sm_o = screen.getOriginalScreenMode();
+        
+        Assert.assertNotNull(sm_o);            
+        ScreenMode sm_c = screen.getCurrentScreenMode();
+        Assert.assertNotNull(sm_c);
+        System.err.println("orig: "+sm_o);
+        System.err.println("curr: "+sm_c);
+        
+        for(i=0; i<50; i++) {
+            sm_c = screen.getCurrentScreenMode();
             Assert.assertNotNull(sm_c);
-            System.err.println("orig: "+sm_o);
-            System.err.println("curr: "+sm_c);
-            
-            for(i=0; i<100; i++) {
-                sm_c = screen.getCurrentScreenMode();
-                Assert.assertNotNull(sm_c);
-                System.err.print(".");
-            }
-            System.err.println("!");
-        } else {
-            // no support ..
-            System.err.println("Your platform has no ScreenMode change support, sorry");
+            System.err.print("."+i);
         }
+        System.err.println("!");
         
         // screen.removeReference();
         anim.stop();
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java
index c53c9a1..b05b5ad 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java
@@ -68,7 +68,6 @@ public class TestScreenMode01NEWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
         width  = 640;
         height = 480;
         glp = GLProfile.getDefault();
@@ -112,8 +111,8 @@ public class TestScreenMode01NEWT extends UITestCase {
      */
     @After
     public void cleanupGL() throws InterruptedException {
-        GLProfile.shutdown();
-        GLProfile.initSingleton(true);
+        GLProfile.shutdown(GLProfile.ShutdownType.COMPLETE);
+        GLProfile.initSingleton();
     }
     
     static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) {
@@ -184,7 +183,7 @@ public class TestScreenMode01NEWT extends UITestCase {
         Assert.assertNotNull(window);
 
         List<ScreenMode> screenModes = screen.getScreenModes();
-        if(null==screenModes) {
+        if(screenModes.size()==1) {
             // no support ..
             System.err.println("Your platform has no ScreenMode change support, sorry");
             destroyWindow(window);
@@ -293,7 +292,7 @@ public class TestScreenMode01NEWT extends UITestCase {
         Assert.assertEquals(smCurrent.getRotatedHeight(), screen.getHeight());
         
         List<ScreenMode> screenModes = screen.getScreenModes();
-        if(null==screenModes) {
+        if(screenModes.size()==1) {
             // no support ..
             destroyWindow(window);
             return;
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java
index 6c505d5..38612fa 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java
@@ -65,7 +65,6 @@ public class TestScreenMode01bNEWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
         width  = 100;
         height = 100;
         glp = GLProfile.getDefault();
@@ -110,7 +109,7 @@ public class TestScreenMode01bNEWT extends UITestCase {
         Assert.assertNotNull(window0);        
 
         List<ScreenMode> screenModes = screen.getScreenModes();
-        if(null==screenModes) {
+        if(screenModes.size()==1) {
             // no support ..
             System.err.println("Your platform has no ScreenMode change support, sorry");
             destroyWindow(window0);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java
index c5c1168..1c9cb91 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java
@@ -60,7 +60,6 @@ public class TestScreenMode02NEWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
         width  = 640;
         height = 480;
         glp = GLProfile.getDefault();
@@ -104,7 +103,7 @@ public class TestScreenMode02NEWT extends UITestCase {
         Assert.assertNotNull(window);
 
         List<ScreenMode> screenModes = screen.getScreenModes();
-        if(null==screenModes) {
+        if(screenModes.size()==1) {
             // no support ..
             System.err.println("Your platform has no ScreenMode change support, sorry");
             destroyWindow(window);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol01AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol01AWT.java
index 7106817..be824c2 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol01AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol01AWT.java
@@ -57,7 +57,7 @@ public class TestWindowClosingProtocol01AWT extends UITestCase {
         GLCapabilities caps = new GLCapabilities(glp);
         final GLCanvas glCanvas = new GLCanvas(caps);
         glCanvas.addGLEventListener(new GearsES2());
-        SwingUtilities.invokeLater(new Runnable() {
+        SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 frame.add(glCanvas);
                 frame.pack();
@@ -94,7 +94,7 @@ public class TestWindowClosingProtocol01AWT extends UITestCase {
         Assert.assertEquals(true,  frame.isVisible());
         Assert.assertEquals(false, glCanvas.isRealized());
 
-        SwingUtilities.invokeLater(new Runnable() {
+        SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 frame.dispose();
             } });
@@ -112,7 +112,7 @@ public class TestWindowClosingProtocol01AWT extends UITestCase {
         frame.pack();
         frame.setSize(512, 512);
         frame.validate();
-        SwingUtilities.invokeLater(new Runnable() {
+        SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 frame.setVisible(true);
             } });
@@ -132,7 +132,7 @@ public class TestWindowClosingProtocol01AWT extends UITestCase {
         Assert.assertEquals(true,  glCanvas.isValid());
         Assert.assertEquals(true,  glCanvas.isDisplayable());
 
-        SwingUtilities.invokeLater(new Runnable() {
+        SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 frame.setVisible(true);
             } });
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol03NewtAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol03NewtAWT.java
index c14c461..19b2bbb 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol03NewtAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol03NewtAWT.java
@@ -62,7 +62,7 @@ public class TestWindowClosingProtocol03NewtAWT extends UITestCase {
 
         final NewtCanvasAWT newtCanvas = new NewtCanvasAWT(glWindow);
 
-        SwingUtilities.invokeLater(new Runnable() {
+        SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 frame.getContentPane().add(newtCanvas);
                 frame.pack();
@@ -94,7 +94,7 @@ public class TestWindowClosingProtocol03NewtAWT extends UITestCase {
         Assert.assertEquals(true,  windowClosingListener.isWindowClosing());
         windowClosingListener.reset();
 
-        SwingUtilities.invokeLater(new Runnable() {
+        SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 frame.setVisible(true);
             } });
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java
index 827dd09..a99edfa 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java
@@ -90,7 +90,7 @@ public class TestWindows01NEWT extends UITestCase {
             Assert.assertEquals(y, window.getY());
         } */
 
-        CapabilitiesImmutable chosenCapabilities = window.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+        CapabilitiesImmutable chosenCapabilities = window.getGraphicsConfiguration().getChosenCapabilities();
         Assert.assertNotNull(chosenCapabilities);
         Assert.assertTrue(chosenCapabilities.getGreenBits()>=5);
         Assert.assertTrue(chosenCapabilities.getBlueBits()>=5);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java
index 46748cb..473f2f5 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java
@@ -51,7 +51,11 @@ class NewtAWTReparentingKeyAdapter extends KeyAdapter {
         if(e.getKeyChar()=='d') {
             glWindow.setUndecorated(!glWindow.isUndecorated());
         } else if(e.getKeyChar()=='f') {
-            glWindow.setFullscreen(!glWindow.isFullscreen());                
+            glWindow.setFullscreen(!glWindow.isFullscreen());
+        } else if(e.getKeyChar()=='l') {
+            javax.media.nativewindow.util.Point p0 = newtCanvasAWT.getNativeWindow().getLocationOnScreen(null);
+            javax.media.nativewindow.util.Point p1 = glWindow.getLocationOnScreen(null);
+            System.err.println("NewtCanvasAWT position: "+p0+", "+p1);                                    
         } else if(e.getKeyChar()=='p') {
             new Thread() {
                 public void run() {
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java
index 7f97be6..256868c 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java
@@ -53,7 +53,6 @@ public class TestParenting01NEWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
         width  = 640;
         height = 480;
         glCaps = new GLCapabilities(null);
@@ -654,7 +653,7 @@ public class TestParenting01NEWT extends UITestCase {
             MiscUtils.setFieldIfExists(demo, "glDebug", true);
             MiscUtils.setFieldIfExists(demo, "glTrace", true);
         }
-        if(!MiscUtils.setFieldIfExists(demo, "window", glWindow.getWindow())) {
+        if(!MiscUtils.setFieldIfExists(demo, "window", glWindow.getDelegatedWindow())) {
             MiscUtils.setFieldIfExists(demo, "glWindow", glWindow);
         }
     }
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java
index 2da3188..2040fb9 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java
@@ -38,12 +38,14 @@ import java.awt.Container;
 import java.awt.Frame;
 
 import javax.media.opengl.*;
+import javax.swing.SwingUtilities;
 
 import com.jogamp.opengl.util.Animator;
 import com.jogamp.newt.opengl.*;
 import com.jogamp.newt.awt.NewtCanvasAWT;
 
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 
 import com.jogamp.opengl.test.junit.util.*;
 import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
@@ -63,8 +65,8 @@ public class TestParenting01aAWT extends UITestCase {
     }
 
     @Test
-    public void testWindowParenting01CreateVisibleDestroy1() throws InterruptedException {
-        GLWindow glWindow1 = GLWindow.create(glCaps);
+    public void testWindowParenting01CreateVisibleDestroy1() throws InterruptedException, InvocationTargetException {
+        final GLWindow glWindow1 = GLWindow.create(glCaps);
         Assert.assertNotNull(glWindow1);
         Assert.assertEquals(false, glWindow1.isVisible());
         Assert.assertEquals(false, glWindow1.isNativeValid());
@@ -74,20 +76,20 @@ public class TestParenting01aAWT extends UITestCase {
         setDemoFields(demo1, glWindow1, false);
         glWindow1.addGLEventListener(demo1);
 
-        NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
+        final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
         Assert.assertNotNull(newtCanvasAWT);
         Assert.assertEquals(false, glWindow1.isVisible());
         Assert.assertEquals(false, glWindow1.isNativeValid());
         Assert.assertNull(glWindow1.getParent());
 
-        Frame frame1 = new Frame("AWT Parent Frame");
+        final Frame frame1 = new Frame("AWT Parent Frame");
         frame1.setLayout(new BorderLayout());
         frame1.add(new Button("North"), BorderLayout.NORTH);
         frame1.add(new Button("South"), BorderLayout.SOUTH);
         frame1.add(new Button("East"), BorderLayout.EAST);
         frame1.add(new Button("West"), BorderLayout.WEST);
 
-        Container container1 = new Container();
+        final Container container1 = new Container();
         container1.setLayout(new BorderLayout());
         container1.add(new Button("north"), BorderLayout.NORTH);
         container1.add(new Button("south"), BorderLayout.SOUTH);
@@ -99,29 +101,48 @@ public class TestParenting01aAWT extends UITestCase {
         frame1.setSize(width, height);
 
         // visible test
-        frame1.setVisible(true);
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame1.setVisible(true);
+           }
+        });
         Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent());
 
-        Animator animator1 = new Animator(glWindow1);
+        final Animator animator1 = new Animator(glWindow1);
         animator1.setUpdateFPSFrames(1, null);        
         animator1.start();
+        Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow1, true));
+        Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow1, true));
+        
         while(animator1.isAnimating() && animator1.getTotalFPSDuration()<durationPerTest) {
             Thread.sleep(100);
         }
         animator1.stop();
         Assert.assertEquals(false, animator1.isAnimating());
 
-        frame1.setVisible(false);
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame1.setVisible(false);
+           } } );        
         Assert.assertEquals(true, glWindow1.isNativeValid());
 
-        frame1.setVisible(true);
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame1.setVisible(true);
+           } } );        
         Assert.assertEquals(true, glWindow1.isNativeValid());
 
-        frame1.remove(newtCanvasAWT);
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame1.remove(newtCanvasAWT);
+           } } );
         // Assert.assertNull(glWindow1.getParent());
         Assert.assertEquals(true, glWindow1.isNativeValid());
 
-        frame1.dispose();
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame1.dispose();
+           } } );
         Assert.assertEquals(true, glWindow1.isNativeValid());
 
         glWindow1.destroy();
@@ -129,8 +150,8 @@ public class TestParenting01aAWT extends UITestCase {
     }
 
     @Test
-    public void testWindowParenting02CreateVisibleDestroy2Defered() throws InterruptedException {
-        GLWindow glWindow1 = GLWindow.create(glCaps);
+    public void testWindowParenting02CreateVisibleDestroy2Defered() throws InterruptedException, InvocationTargetException {
+        final GLWindow glWindow1 = GLWindow.create(glCaps);
         Assert.assertNotNull(glWindow1);
         Assert.assertEquals(false, glWindow1.isVisible());
         Assert.assertEquals(false, glWindow1.isNativeValid());
@@ -139,20 +160,29 @@ public class TestParenting01aAWT extends UITestCase {
         setDemoFields(demo1, glWindow1, false);
         glWindow1.addGLEventListener(demo1);
 
-        NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
+        final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
         Assert.assertNotNull(newtCanvasAWT);
         Assert.assertEquals(false, glWindow1.isVisible());
         Assert.assertEquals(false, glWindow1.isNativeValid());
         Assert.assertNull(glWindow1.getParent());
 
-        Frame frame = new Frame("AWT Parent Frame");
+        final Frame frame = new Frame("AWT Parent Frame");
         Assert.assertNotNull(frame);
         frame.setSize(width, height);
 
         // visible test
-        frame.setVisible(true);
-
-        frame.add(newtCanvasAWT);
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame.setVisible(true);
+           }
+        });
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame.add(newtCanvasAWT);
+               frame.validate();
+           }
+        });
         Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent());
 
         Animator animator1 = new Animator(glWindow1);
@@ -164,27 +194,39 @@ public class TestParenting01aAWT extends UITestCase {
         animator1.stop();
         Assert.assertEquals(false, animator1.isAnimating());
 
-        frame.dispose();
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame.dispose();
+           } } );
         glWindow1.destroy();
     }
 
     @Test
-    public void testWindowParenting02CreateVisibleDestroy3Odd() throws InterruptedException {
+    public void testWindowParenting02CreateVisibleDestroy3Odd() throws InterruptedException, InvocationTargetException {
         GLWindow glWindow1 = GLWindow.create(glCaps);
         GLEventListener demo1 = new RedSquareES2();
         setDemoFields(demo1, glWindow1, false);
         glWindow1.addGLEventListener(demo1);
 
-        NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
+        final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
 
-        Frame frame = new Frame("AWT Parent Frame");
+        final Frame frame = new Frame("AWT Parent Frame");
         Assert.assertNotNull(frame);
         frame.setSize(width, height);
 
         // visible test
-        frame.setVisible(true);
-
-        frame.add(newtCanvasAWT);
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame.setVisible(true);
+           }
+        });
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame.add(newtCanvasAWT);
+               frame.validate();
+           }
+        });
 
         Animator animator1 = new Animator(glWindow1);
         animator1.setUpdateFPSFrames(1, null);
@@ -197,25 +239,38 @@ public class TestParenting01aAWT extends UITestCase {
 
         Assert.assertEquals(true, animator1.isAnimating()); // !!!
 
-        frame.dispose();
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame.dispose();
+           } } );
         glWindow1.destroy();
     }
 
     @Test
-    public void testWindowParenting03ReparentNewtWin2Top() throws InterruptedException {
+    public void testWindowParenting03ReparentNewtWin2Top() throws InterruptedException, InvocationTargetException {
         GLWindow glWindow1 = GLWindow.create(glCaps);
         GLEventListener demo1 = new RedSquareES2();
         setDemoFields(demo1, glWindow1, false);
         glWindow1.addGLEventListener(demo1);
 
-        NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
+        final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
 
-        Frame frame = new Frame("AWT Parent Frame");
+        final Frame frame = new Frame("AWT Parent Frame");
         frame.setSize(width, height);
         frame.setLocation(640, 480);
-        frame.setVisible(true);
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame.setVisible(true);
+           }
+        });
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame.add(newtCanvasAWT);
+               frame.validate();
+           }
+        });
 
-        frame.add(newtCanvasAWT);
         Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent());
 
         Animator animator1 = new Animator(glWindow1);
@@ -243,20 +298,23 @@ public class TestParenting01aAWT extends UITestCase {
         animator1.stop();
         Assert.assertEquals(false, animator1.isAnimating());
 
-        frame.dispose();
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame.dispose();
+           } } );
         glWindow1.destroy();
     }
 
     @Test
-    public void testWindowParenting04ReparentNewtWin2TopLayouted() throws InterruptedException {
+    public void testWindowParenting04ReparentNewtWin2TopLayouted() throws InterruptedException, InvocationTargetException {
         GLWindow glWindow1 = GLWindow.create(glCaps);
         GLEventListener demo1 = new RedSquareES2();
         setDemoFields(demo1, glWindow1, false);
         glWindow1.addGLEventListener(demo1);
 
-        NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
+        final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
 
-        Frame frame = new Frame("AWT Parent Frame");
+        final Frame frame = new Frame("AWT Parent Frame");
         frame.setLayout(new BorderLayout());
         frame.add(new Button("North"), BorderLayout.NORTH);
         frame.add(new Button("South"), BorderLayout.SOUTH);
@@ -264,9 +322,20 @@ public class TestParenting01aAWT extends UITestCase {
         frame.add(new Button("West"), BorderLayout.WEST);
         frame.setSize(width, height);
         frame.setLocation(640, 480);
-        frame.setVisible(true);
-
-        frame.add(newtCanvasAWT, BorderLayout.CENTER);
+        
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame.setVisible(true);
+           }
+        });
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame.add(newtCanvasAWT, BorderLayout.CENTER);
+               frame.validate();
+           }
+        });
+        
         Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent());
 
         Animator animator1 = new Animator(glWindow1);
@@ -294,21 +363,24 @@ public class TestParenting01aAWT extends UITestCase {
         animator1.stop();
         Assert.assertEquals(false, animator1.isAnimating());
 
-        frame.dispose();
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame.dispose();
+           } } );
         glWindow1.destroy();
     }
 
     @Test
-    public void testWindowParenting05ReparentAWTWinHopFrame2Frame() throws InterruptedException {
+    public void testWindowParenting05ReparentAWTWinHopFrame2Frame() throws InterruptedException, InvocationTargetException {
         GLWindow glWindow1 = GLWindow.create(glCaps);
         glWindow1.setUndecorated(true);
         GLEventListener demo1 = new RedSquareES2();
         setDemoFields(demo1, glWindow1, false);
         glWindow1.addGLEventListener(demo1);
 
-        NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
+        final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
 
-        Frame frame1 = new Frame("AWT Parent Frame");
+        final Frame frame1 = new Frame("AWT Parent Frame");
         frame1.setLayout(new BorderLayout());
         frame1.add(new Button("North"), BorderLayout.NORTH);
         frame1.add(new Button("South"), BorderLayout.SOUTH);
@@ -316,9 +388,13 @@ public class TestParenting01aAWT extends UITestCase {
         frame1.add(new Button("West"), BorderLayout.WEST);
         frame1.setSize(width, height);
         frame1.setLocation(0, 0);
-        frame1.setVisible(true);
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame1.setVisible(true);
+           }
+        });
 
-        Frame frame2 = new Frame("AWT Parent Frame");
+        final Frame frame2 = new Frame("AWT Parent Frame");
         frame2.setLayout(new BorderLayout());
         frame2.add(new Button("North"), BorderLayout.NORTH);
         frame2.add(new Button("South"), BorderLayout.SOUTH);
@@ -326,9 +402,19 @@ public class TestParenting01aAWT extends UITestCase {
         frame2.add(new Button("West"), BorderLayout.WEST);
         frame2.setSize(width, height);
         frame2.setLocation(640, 480);
-        frame2.setVisible(true);
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame2.setVisible(true);
+           }
+        });
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame1.add(newtCanvasAWT, BorderLayout.CENTER);
+               frame1.validate();
+           }
+        });
 
-        frame1.add(newtCanvasAWT, BorderLayout.CENTER);
         Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent());
 
         Animator animator1 = new Animator(glWindow1);
@@ -340,12 +426,24 @@ public class TestParenting01aAWT extends UITestCase {
             Thread.sleep(durationPerTest);
             switch(state) {
                 case 0:
-                    frame1.remove(newtCanvasAWT);
-                    frame2.add(newtCanvasAWT, BorderLayout.CENTER);
+                    SwingUtilities.invokeAndWait(new Runnable() {
+                        public void run() {
+                            frame1.remove(newtCanvasAWT);
+                            frame2.add(newtCanvasAWT, BorderLayout.CENTER);
+                            frame1.validate();
+                            frame2.validate();
+                        }
+                    });                    
                     break;
                 case 1:
-                    frame2.remove(newtCanvasAWT);
-                    frame1.add(newtCanvasAWT, BorderLayout.CENTER);
+                    SwingUtilities.invokeAndWait(new Runnable() {
+                        public void run() {
+                            frame2.remove(newtCanvasAWT);
+                            frame1.add(newtCanvasAWT, BorderLayout.CENTER);
+                            frame2.validate();
+                            frame1.validate();
+                        }
+                    });                    
                     break;
             }
             state++;
@@ -354,8 +452,11 @@ public class TestParenting01aAWT extends UITestCase {
         animator1.stop();
         Assert.assertEquals(false, animator1.isAnimating());
 
-        frame1.dispose();
-        frame2.dispose();
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame1.dispose();
+                frame2.dispose();
+            } } );
         glWindow1.destroy();
     }
 
@@ -366,7 +467,7 @@ public class TestParenting01aAWT extends UITestCase {
             MiscUtils.setFieldIfExists(demo, "glDebug", true);
             MiscUtils.setFieldIfExists(demo, "glTrace", true);
         }
-        if(!MiscUtils.setFieldIfExists(demo, "window", glWindow.getWindow())) {
+        if(!MiscUtils.setFieldIfExists(demo, "window", glWindow.getDelegatedWindow())) {
             MiscUtils.setFieldIfExists(demo, "glWindow", glWindow);
         }
     }
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java
index fb93ad9..d98a540 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java
@@ -46,6 +46,7 @@ import com.jogamp.newt.opengl.*;
 import com.jogamp.newt.awt.NewtCanvasAWT;
 
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 
 import com.jogamp.opengl.test.junit.util.*;
 import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
@@ -64,16 +65,16 @@ public class TestParenting01bAWT extends UITestCase {
     }
 
     @Test
-    public void testWindowParenting05ReparentAWTWinHopFrame2FrameFPS25Animator() throws InterruptedException {
+    public void testWindowParenting05ReparentAWTWinHopFrame2FrameFPS25Animator() throws InterruptedException, InvocationTargetException {
         testWindowParenting05ReparentAWTWinHopFrame2FrameImpl(25);
     }
 
     @Test
-    public void testWindowParenting05ReparentAWTWinHopFrame2FrameStdAnimator() throws InterruptedException {
+    public void testWindowParenting05ReparentAWTWinHopFrame2FrameStdAnimator() throws InterruptedException, InvocationTargetException {
         testWindowParenting05ReparentAWTWinHopFrame2FrameImpl(0);
     }
 
-    public void testWindowParenting05ReparentAWTWinHopFrame2FrameImpl(int fps) throws InterruptedException {
+    public void testWindowParenting05ReparentAWTWinHopFrame2FrameImpl(int fps) throws InterruptedException, InvocationTargetException {
         GLWindow glWindow1 = GLWindow.create(glCaps);
         glWindow1.setUndecorated(true);
         GLEventListener demo1 = new RedSquareES2();
@@ -81,7 +82,7 @@ public class TestParenting01bAWT extends UITestCase {
         glWindow1.addGLEventListener(demo1);
 
         final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
-
+        
         final Frame frame1 = new Frame("AWT Parent Frame");
         frame1.setLayout(new BorderLayout());
         frame1.add(new Button("North"), BorderLayout.NORTH);
@@ -90,7 +91,11 @@ public class TestParenting01bAWT extends UITestCase {
         frame1.add(new Button("West"), BorderLayout.WEST);
         frame1.setSize(width, height);
         frame1.setLocation(0, 0);
-        frame1.setVisible(true);
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame1.setVisible(true);               
+           }
+        });
 
         final Frame frame2 = new Frame("AWT Parent Frame");
         frame2.setLayout(new BorderLayout());
@@ -100,9 +105,18 @@ public class TestParenting01bAWT extends UITestCase {
         frame2.add(new Button("West"), BorderLayout.WEST);
         frame2.setSize(width, height);
         frame2.setLocation(640, 480);
-        frame2.setVisible(true);
-
-        frame1.add(newtCanvasAWT, BorderLayout.CENTER);
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame2.setVisible(true);               
+           }
+        });
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame1.add(newtCanvasAWT, BorderLayout.CENTER);
+               frame1.validate();
+           }
+        });
         Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent());
 
         GLAnimatorControl animator1;
@@ -118,7 +132,7 @@ public class TestParenting01bAWT extends UITestCase {
             Thread.sleep(durationPerTest);
             switch(state) {
                 case 0:
-                    SwingUtilities.invokeLater(new Runnable() {
+                    SwingUtilities.invokeAndWait(new Runnable() {
                         public void run() {
                             frame1.remove(newtCanvasAWT);
                             frame2.add(newtCanvasAWT, BorderLayout.CENTER);
@@ -128,7 +142,7 @@ public class TestParenting01bAWT extends UITestCase {
                     });                    
                     break;
                 case 1:
-                    SwingUtilities.invokeLater(new Runnable() {
+                    SwingUtilities.invokeAndWait(new Runnable() {
                         public void run() {
                             frame2.remove(newtCanvasAWT);
                             frame1.add(newtCanvasAWT, BorderLayout.CENTER);
@@ -148,15 +162,18 @@ public class TestParenting01bAWT extends UITestCase {
         Assert.assertEquals(false, animator1.isPaused());
         Assert.assertEquals(null, animator1.getThread());
 
-        frame1.dispose();
-        frame2.dispose();
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame1.dispose();
+                frame2.dispose();
+            } } );
         glWindow1.destroy();
     }
 
     public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
         Assert.assertNotNull(demo);
         Assert.assertNotNull(glWindow);
-        Window window = glWindow.getWindow();
+        Window window = glWindow.getDelegatedWindow();
         if(debug) {
             MiscUtils.setFieldIfExists(demo, "glDebug", true);
             MiscUtils.setFieldIfExists(demo, "glTrace", true);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java
index 4477c3f..dfd0787 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java
@@ -38,12 +38,14 @@ import java.awt.Container;
 import java.awt.Frame;
 
 import javax.media.opengl.*;
+import javax.swing.SwingUtilities;
 
 import com.jogamp.newt.*;
 import com.jogamp.newt.opengl.*;
 import com.jogamp.newt.awt.NewtCanvasAWT;
 
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 
 import com.jogamp.opengl.test.junit.util.*;
 import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
@@ -61,7 +63,7 @@ public class TestParenting01cAWT extends UITestCase {
     }
 
     @Test
-    public void testWindowParenting01CreateVisibleDestroy1() throws InterruptedException {
+    public void testWindowParenting01CreateVisibleDestroy1() throws InterruptedException, InvocationTargetException {
         int i;
 
         GLWindow glWindow1 = GLWindow.create(glCaps);
@@ -74,13 +76,13 @@ public class TestParenting01cAWT extends UITestCase {
         setDemoFields(demo1, glWindow1, false);
         glWindow1.addGLEventListener(demo1);
 
-        NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
+        final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
         Assert.assertNotNull(newtCanvasAWT);
         Assert.assertEquals(false, glWindow1.isVisible());
         Assert.assertEquals(false, glWindow1.isNativeValid());
         Assert.assertNull(glWindow1.getParent());
 
-        Frame frame1 = new Frame("AWT Parent Frame");
+        final Frame frame1 = new Frame("AWT Parent Frame");
         frame1.setLayout(new BorderLayout());
         frame1.add(new Button("North"), BorderLayout.NORTH);
         frame1.add(new Button("South"), BorderLayout.SOUTH);
@@ -99,24 +101,43 @@ public class TestParenting01cAWT extends UITestCase {
         frame1.setSize(width, height);
 
         // visible test
-        frame1.setVisible(true);
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame1.setVisible(true);
+           }
+        });
         Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent());
 
         for(i=0; i*100<durationPerTest; i++) {
             Thread.sleep(100);
         }
 
-        frame1.setVisible(false);
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame1.setVisible(false);
+           }
+        });
         Assert.assertEquals(true, glWindow1.isNativeValid());
 
-        frame1.setVisible(true);
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame1.setVisible(true);
+           }
+        });
         Assert.assertEquals(true, glWindow1.isNativeValid());
 
-        frame1.remove(newtCanvasAWT);
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame1.remove(newtCanvasAWT);
+           }
+        });
         // Assert.assertNull(glWindow1.getParent());
         Assert.assertEquals(true, glWindow1.isNativeValid());
 
-        frame1.dispose();
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame1.dispose();
+           } } );
         Assert.assertEquals(true, glWindow1.isNativeValid());
 
         glWindow1.destroy();
@@ -124,16 +145,16 @@ public class TestParenting01cAWT extends UITestCase {
     }
 
     @Test
-    public void testWindowParenting05ReparentAWTWinHopFrame2Frame() throws InterruptedException {
+    public void testWindowParenting05ReparentAWTWinHopFrame2Frame() throws InterruptedException, InvocationTargetException {
         GLWindow glWindow1 = GLWindow.create(glCaps);
         glWindow1.setUndecorated(true);
         GLEventListener demo1 = new RedSquareES2();
         setDemoFields(demo1, glWindow1, false);
         glWindow1.addGLEventListener(demo1);
 
-        NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
+        final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
 
-        Frame frame1 = new Frame("AWT Parent Frame");
+        final Frame frame1 = new Frame("AWT Parent Frame");
         frame1.setLayout(new BorderLayout());
         frame1.add(new Button("North"), BorderLayout.NORTH);
         frame1.add(new Button("South"), BorderLayout.SOUTH);
@@ -141,9 +162,13 @@ public class TestParenting01cAWT extends UITestCase {
         frame1.add(new Button("West"), BorderLayout.WEST);
         frame1.setSize(width, height);
         frame1.setLocation(0, 0);
-        frame1.setVisible(true);
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame1.setVisible(true);
+           }
+        });
 
-        Frame frame2 = new Frame("AWT Parent Frame");
+        final Frame frame2 = new Frame("AWT Parent Frame");
         frame2.setLayout(new BorderLayout());
         frame2.add(new Button("North"), BorderLayout.NORTH);
         frame2.add(new Button("South"), BorderLayout.SOUTH);
@@ -151,9 +176,18 @@ public class TestParenting01cAWT extends UITestCase {
         frame2.add(new Button("West"), BorderLayout.WEST);
         frame2.setSize(width, height);
         frame2.setLocation(640, 480);
-        frame2.setVisible(true);
-
-        frame1.add(newtCanvasAWT, BorderLayout.CENTER);
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame2.setVisible(true);
+           }
+        });
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               frame1.add(newtCanvasAWT, BorderLayout.CENTER);
+               frame1.validate();
+           }
+        });
         Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent());
 
         int state;
@@ -161,25 +195,40 @@ public class TestParenting01cAWT extends UITestCase {
             Thread.sleep(durationPerTest);
             switch(state) {
                 case 0:
-                    frame1.remove(newtCanvasAWT);
-                    frame2.add(newtCanvasAWT, BorderLayout.CENTER);
+                    SwingUtilities.invokeAndWait(new Runnable() {
+                       public void run() {
+                           frame1.remove(newtCanvasAWT);
+                           frame2.add(newtCanvasAWT, BorderLayout.CENTER);
+                           frame1.validate();
+                           frame2.validate();
+                       }
+                    });
                     break;
                 case 1:
-                    frame2.remove(newtCanvasAWT);
-                    frame1.add(newtCanvasAWT, BorderLayout.CENTER);
+                    SwingUtilities.invokeAndWait(new Runnable() {
+                       public void run() {
+                           frame2.remove(newtCanvasAWT);
+                           frame1.add(newtCanvasAWT, BorderLayout.CENTER);
+                           frame1.validate();
+                           frame2.validate();
+                       }
+                    });
                     break;
             }
         }
 
-        frame1.dispose();
-        frame2.dispose();
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+                frame1.dispose();
+                frame2.dispose();
+           } } );
         glWindow1.destroy();
     }
 
     public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
         Assert.assertNotNull(demo);
         Assert.assertNotNull(glWindow);
-        Window window = glWindow.getWindow();
+        Window window = glWindow.getDelegatedWindow();
         if(debug) {
             MiscUtils.setFieldIfExists(demo, "glDebug", true);
             MiscUtils.setFieldIfExists(demo, "glTrace", true);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java
index 478e000..22ed7c6 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java
@@ -129,7 +129,13 @@ public class TestParenting01cSwingAWT extends UITestCase {
         jFrame1.setContentPane(jPanel1);
         jFrame1.setSize(width, height);
         System.out.println("Demos: 1 - Visible");
-        jFrame1.setVisible(true); // from here on, we need to run modifications on EDT
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               jFrame1.setVisible(true);
+           }
+        });
+        Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true));
+        Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glWindow1, true));
 
         // visible test
         Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent());
@@ -143,25 +149,24 @@ public class TestParenting01cSwingAWT extends UITestCase {
 
         SwingUtilities.invokeAndWait(new Runnable() {
                 public void run() {
-            System.out.println("Demos: 3 - !Visible");
+                    System.out.println("Demos: 3 - !Visible");
                     jFrame1.setVisible(false);
                 } });
-        Assert.assertEquals(true, glWindow1.isNativeValid());
+        Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glWindow1, false));
 
         SwingUtilities.invokeAndWait(new Runnable() {
                 public void run() {
-            System.out.println("Demos: 4 - Visible");
+                    System.out.println("Demos: 4 - Visible");
                     jFrame1.setVisible(true);
                 } });
-        Assert.assertEquals(true, glWindow1.isNativeValid());
+        Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glWindow1, true));
 
         SwingUtilities.invokeAndWait(new Runnable() {
                 public void run() {
-            System.out.println("Demos: 5 - X Container");
+                    System.out.println("Demos: 5 - X Container");
                     jPanel1.remove(container1);
                     jFrame1.validate();
                 } });
-        // Assert.assertNull(glWindow1.getParent());
         Assert.assertEquals(true, glWindow1.isNativeValid());
 
         SwingUtilities.invokeAndWait(new Runnable() {
@@ -236,7 +241,11 @@ public class TestParenting01cSwingAWT extends UITestCase {
         jFrame1.setContentPane(jPanel1);
         jFrame1.setLocation(0, 0);
         jFrame1.setSize(width, height);
-        jFrame1.setVisible(true); // from here on, we need to run modifications on EDT
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               jFrame1.setVisible(true);
+           }
+        });
 
         final JPanel jPanel2 = new JPanel();
         jPanel2.setLayout(new BorderLayout());
@@ -251,7 +260,11 @@ public class TestParenting01cSwingAWT extends UITestCase {
         jFrame2.setContentPane(jPanel2);
         jFrame2.setLocation(640, 480);
         jFrame2.setSize(width, height);
-        jFrame2.setVisible(true); // from here on, we need to run modifications on EDT
+        SwingUtilities.invokeAndWait(new Runnable() {
+           public void run() {
+               jFrame2.setVisible(true);
+           }
+        });
 
         // visible test
         Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent());
@@ -306,7 +319,7 @@ public class TestParenting01cSwingAWT extends UITestCase {
     public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
         Assert.assertNotNull(demo);
         Assert.assertNotNull(glWindow);
-        Window window = glWindow.getWindow();
+        Window window = glWindow.getDelegatedWindow();
         if(debug) {
             MiscUtils.setFieldIfExists(demo, "glDebug", true);
             MiscUtils.setFieldIfExists(demo, "glTrace", true);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java
index 3ce1f50..da689ce 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java
@@ -118,7 +118,8 @@ public class TestParenting02AWT extends UITestCase {
             }
         }
 
-        frame.setSize(width, height);
+        // frame.setSize(width, height);
+        frame.setBounds(100, 100, width, height);
 
         javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
@@ -221,15 +222,19 @@ public class TestParenting02AWT extends UITestCase {
             javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
                 public void run() {
                     frame.remove(newtCanvasAWT);
+                    frame.validate();
                 }});
         }
-        frame.dispose();
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame.dispose();
+            } } );
     }
 
     public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
         Assert.assertNotNull(demo);
         Assert.assertNotNull(glWindow);
-        Window window = glWindow.getWindow();
+        Window window = glWindow.getDelegatedWindow();
         if(debug) {
             MiscUtils.setFieldIfExists(demo, "glDebug", true);
             MiscUtils.setFieldIfExists(demo, "glTrace", true);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java
index 13aad0c..bc39883 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java
@@ -54,7 +54,6 @@ public class TestParenting02NEWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        GLProfile.initSingleton(true);
         width  = 640;
         height = 480;
     }
@@ -120,7 +119,7 @@ public class TestParenting02NEWT extends UITestCase {
         // glWindow1.addGLEventListener(demo1);
 
         glWindow1.setVisible(true);
-        CapabilitiesImmutable capsChosen = glWindow1.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+        CapabilitiesImmutable capsChosen = glWindow1.getGraphicsConfiguration().getChosenCapabilities();
         Assert.assertNotNull(capsChosen);
         Assert.assertTrue(capsChosen.isOnscreen()==true);
 
@@ -142,7 +141,7 @@ public class TestParenting02NEWT extends UITestCase {
         // glWindow2.addGLEventListener(demo2);
 
         glWindow2.setVisible(true);
-        capsChosen = glWindow2.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+        capsChosen = glWindow2.getGraphicsConfiguration().getChosenCapabilities();
         Assert.assertNotNull(capsChosen);
         Assert.assertTrue(capsChosen.isOnscreen()==true);
 
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java
index 2ce6223..b33a40f 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java
@@ -35,16 +35,15 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 
 import java.awt.BorderLayout;
+import java.awt.Button;
 import java.awt.Container;
 import java.awt.Dimension;
 import java.awt.Frame;
-import java.awt.Label;
 
 import javax.media.opengl.*;
 
 import com.jogamp.opengl.util.Animator;
 import com.jogamp.newt.*;
-import com.jogamp.newt.event.*;
 import com.jogamp.newt.opengl.*;
 import com.jogamp.newt.awt.NewtCanvasAWT;
 
@@ -54,79 +53,117 @@ import com.jogamp.opengl.test.junit.util.*;
 import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
 
 public class TestParenting03AWT extends UITestCase {
-    static Dimension size;
-    static long durationPerTest = 400;
-    static long waitAdd2nd = 200;
+    static Dimension glSize, fSize;
+    static long durationPerTest = 1100;
+    static long waitAdd2nd = 500;
     static GLCapabilities glCaps;
 
     @BeforeClass
     public static void initClass() {
-        size = new Dimension(400,200);
+        glSize = new Dimension(400,200);
+        fSize = new Dimension(3*400,2*200);
         glCaps = new GLCapabilities(null);
-        glCaps.setAlphaBits(8);
-        glCaps.setBackgroundOpaque(false);
     }
 
     @Test
-    public void testWindowParenting1AWTOneNewtChild01() throws InterruptedException, InvocationTargetException {
-        testWindowParenting1AWTOneNewtChild();
+    public void testWindowParenting1AWTOneNewtChilds01() throws InterruptedException, InvocationTargetException {
+        testWindowParenting1AWT(false);
     }
 
-    public void testWindowParenting1AWTOneNewtChild() throws InterruptedException, InvocationTargetException {
+    @Test
+    public void testWindowParenting1AWTTwoNewtChilds01() throws InterruptedException, InvocationTargetException {
+        testWindowParenting1AWT(true);
+    }
+    
+    public void testWindowParenting1AWT(boolean use2nd) throws InterruptedException, InvocationTargetException {
+        final Frame frame1 = new Frame("AWT Parent Frame");
         GLWindow glWindow1 = GLWindow.create(glCaps);
         glWindow1.setUpdateFPSFrames(1, null);
-        glWindow1.setUndecorated(true);
-        NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1);
-        newtCanvasAWT1.setPreferredSize(size);
+        final NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1);
+        newtCanvasAWT1.setPreferredSize(glSize);
 
         GLEventListener demo1 = new GearsES2(1);
         setDemoFields(demo1, glWindow1, false);
         glWindow1.addGLEventListener(demo1);
-        final NewtCanvasAWT f_newtCanvasAWT1 = newtCanvasAWT1;
-        final GLWindow f_glWindow1 = glWindow1;
-        glWindow1.addKeyListener(new KeyAdapter() {
-            public void keyTyped(KeyEvent e) {
-                if(e.getKeyChar()=='d') {
-                    f_glWindow1.setUndecorated(!f_glWindow1.isUndecorated());
-                } else if(e.getKeyChar()=='f') {
-                    f_glWindow1.setFullscreen(!f_glWindow1.isFullscreen());
-                } else if(e.getKeyChar()=='r') {
-                    if(f_glWindow1.getParent()==null) {
-                        System.err.println("XXX glWin1 to home");
-                        f_glWindow1.reparentWindow(f_newtCanvasAWT1.getNativeWindow());
-                    } else {
-                        System.err.println("XXX glWin1 to TOP");
-                        f_glWindow1.reparentWindow(null);
-                    }
-                }
-            }
-        });
+        glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1));
         GLAnimatorControl animator1 = new Animator(glWindow1);
         animator1.start();
 
-        Container cont1 = new Container();
+        GLWindow glWindow2 = null;
+        NewtCanvasAWT newtCanvasAWT2 = null;
+        GLAnimatorControl animator2 = null;
+        if(use2nd) {
+            glWindow2 = GLWindow.create(glCaps);
+            glWindow2.setUpdateFPSFrames(1, null);
+            newtCanvasAWT2 = new NewtCanvasAWT(glWindow2);
+            newtCanvasAWT2.setPreferredSize(glSize);
+    
+            GLEventListener demo2 = new GearsES2(1);
+            setDemoFields(demo2, glWindow2, false);
+            glWindow2.addGLEventListener(demo2);
+            glWindow2.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT2, glWindow2));
+            animator2 = new Animator(glWindow2);
+            animator2.start();
+        }
+
+        final Container cont1 = new Container();
         cont1.setLayout(new BorderLayout());
+        cont1.add(new Button("NORTH"), BorderLayout.NORTH);
+        cont1.add(new Button("SOUTH"), BorderLayout.SOUTH);
+        cont1.add(new Button("EAST"), BorderLayout.EAST);
+        cont1.add(new Button("WEST"), BorderLayout.WEST);
         cont1.add(newtCanvasAWT1, BorderLayout.CENTER);
+        System.err.println("******* Cont1 setVisible");
         cont1.setVisible(true);
 
-        Frame frame1 = new Frame("AWT Parent Frame");
+        final Container cont2 = new Container();
+        cont2.setLayout(new BorderLayout());
+        if(use2nd) {
+            cont2.add(new Button("north"), BorderLayout.NORTH);
+            cont2.add(new Button("sourth"), BorderLayout.SOUTH);
+            cont2.add(new Button("east"), BorderLayout.EAST);
+            cont2.add(new Button("west"), BorderLayout.WEST);
+            cont2.add(newtCanvasAWT2, BorderLayout.CENTER);
+        }
+        System.err.println("******* Cont2 setVisible");
+        cont2.setVisible(true);
+
         frame1.setLayout(new BorderLayout());
+        frame1.add(new Button("NORTH"), BorderLayout.NORTH);
+        frame1.add(new Button("CENTER"), BorderLayout.CENTER);
+        frame1.add(new Button("SOUTH"), BorderLayout.SOUTH);
         frame1.add(cont1, BorderLayout.EAST);
-        frame1.add(new Label("center"), BorderLayout.CENTER);
         frame1.setLocation(0, 0);
-        frame1.setSize((int)size.getWidth(), (int)size.getHeight());
-        final Frame f_frame1 = frame1;
+        frame1.setSize(fSize);
         javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
-                f_frame1.pack();
-                f_frame1.setVisible(true);
+                System.err.println("******* Frame setVisible");
+                frame1.validate();                
+                frame1.setVisible(true);
             }});
 
         Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent());
+        
         Assert.assertEquals(true, animator1.isAnimating());
         Assert.assertEquals(false, animator1.isPaused());
         Assert.assertNotNull(animator1.getThread());
 
+        if(use2nd) {
+            Assert.assertEquals(true, animator2.isAnimating());
+            Assert.assertEquals(false, animator2.isPaused());
+            Assert.assertNotNull(animator2.getThread());
+
+            Thread.sleep(waitAdd2nd);
+    
+            javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+                public void run() {
+                    frame1.add(cont2, BorderLayout.WEST);
+                    frame1.validate();
+                }});
+            Assert.assertEquals(newtCanvasAWT2.getNativeWindow(),glWindow2.getParent());
+        }
+
+
         Thread.sleep(durationPerTest);
 
         animator1.stop();
@@ -134,14 +171,27 @@ public class TestParenting03AWT extends UITestCase {
         Assert.assertEquals(false, animator1.isPaused());
         Assert.assertEquals(null, animator1.getThread());
 
-        frame1.dispose();
+        if(use2nd) {
+            animator2.stop();
+            Assert.assertEquals(false, animator2.isAnimating());
+            Assert.assertEquals(false, animator2.isPaused());
+            Assert.assertEquals(null, animator2.getThread());
+        }
+
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame1.dispose();
+            } } );
         glWindow1.destroy();
+        if(use2nd) {
+            glWindow2.destroy();
+        }
     }
 
     public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
         Assert.assertNotNull(demo);
         Assert.assertNotNull(glWindow);
-        Window window = glWindow.getWindow();
+        Window window = glWindow.getDelegatedWindow();
         if(debug) {
             MiscUtils.setFieldIfExists(demo, "glDebug", true);
             MiscUtils.setFieldIfExists(demo, "glTrace", true);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java
new file mode 100644
index 0000000..b23c170
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java
@@ -0,0 +1,334 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ * 
+ *    1. Redistributions of source code must retain the above copyright notice, this list of
+ *       conditions and the following disclaimer.
+ * 
+ *    2. Redistributions in binary form must reproduce the above copyright notice, this list
+ *       of conditions and the following disclaimer in the documentation and/or other materials
+ *       provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+ 
+package com.jogamp.opengl.test.junit.newt.parenting;
+
+import java.lang.reflect.*;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.awt.AWTException;
+import java.awt.AWTKeyStroke;
+import java.awt.BorderLayout;
+import java.awt.Button;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.KeyboardFocusManager;
+import java.awt.Robot;
+
+import javax.media.opengl.*;
+
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.newt.*;
+import com.jogamp.newt.opengl.*;
+import com.jogamp.newt.awt.NewtCanvasAWT;
+import com.jogamp.newt.event.KeyAdapter;
+import com.jogamp.newt.event.KeyEvent;
+
+import java.io.IOException;
+
+import jogamp.newt.driver.DriverClearFocus;
+
+import com.jogamp.opengl.test.junit.util.*;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+
+public class TestParentingFocusTraversal01AWT extends UITestCase {
+    static Dimension glSize, fSize;
+    static int numFocus = 8;
+    static long durationPerTest = numFocus * 100;
+    static GLCapabilities glCaps;
+    static boolean manual = false;
+
+    @BeforeClass
+    public static void initClass() {
+        glSize = new Dimension(200,200);
+        fSize = new Dimension(300,300);
+        glCaps = new GLCapabilities(null);
+    }
+
+    @Test
+    public void testWindowParentingAWTFocusTraversal01Onscreen() throws InterruptedException, InvocationTargetException, AWTException {
+        testWindowParentingAWTFocusTraversal(true);
+    }
+
+    @Test
+    public void testWindowParentingAWTFocusTraversal02Offscreen() throws InterruptedException, InvocationTargetException, AWTException {
+        testWindowParentingAWTFocusTraversal(false);
+    }
+
+    public void testWindowParentingAWTFocusTraversal(boolean onscreen) throws InterruptedException, InvocationTargetException, AWTException {
+        Robot robot = new Robot();
+        
+        // Bug 4908075 - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4908075
+        // Bug 6463168 - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6463168
+        {
+            final KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
+            final Set<AWTKeyStroke> bwdKeys = kfm.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);         
+            final AWTKeyStroke newBack = AWTKeyStroke.getAWTKeyStroke(java.awt.event.KeyEvent.VK_BACK_SPACE, 0, false);
+            Assert.assertNotNull(newBack);
+            final Set<AWTKeyStroke> bwdKeys2 = new HashSet<AWTKeyStroke>(bwdKeys); 
+            bwdKeys2.add(newBack);
+            kfm.setDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, bwdKeys2);
+        }
+        {
+            final KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
+            final Set<AWTKeyStroke> fwdKeys = kfm.getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);             
+            final Set<AWTKeyStroke> bwdKeys = kfm.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);         
+            Iterator<AWTKeyStroke> iter;
+            for(iter = fwdKeys.iterator(); iter.hasNext(); ) {
+                System.err.println("FTKL.fwd-keys: "+iter.next());
+            }
+            for(iter = bwdKeys.iterator(); iter.hasNext(); ) {
+                System.err.println("FTKL.bwd-keys: "+iter.next());
+            }
+        }
+        
+        final Frame frame1 = new Frame("AWT Parent Frame");
+        final Button cWest = new Button("WEST");
+        final Button cEast = new Button("EAST");
+        final GLWindow glWindow1 = GLWindow.create(glCaps);
+        glWindow1.setUpdateFPSFrames(1, null);
+        final NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1);
+        newtCanvasAWT1.setPreferredSize(glSize);
+        newtCanvasAWT1.setShallUseOffscreenLayer(!onscreen);
+        newtCanvasAWT1.setFocusable(true);
+
+        // Test FocusAdapter
+        NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1");
+        glWindow1.addWindowListener(glWindow1FA);
+        AWTFocusAdapter bWestFA = new AWTFocusAdapter("WEST");
+        cWest.addFocusListener(bWestFA);
+        AWTFocusAdapter bEastFA = new AWTFocusAdapter("EAST");
+        cEast.addFocusListener(bEastFA);
+        
+        // Test KeyAdapter
+        NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1");
+        glWindow1.addKeyListener(glWindow1KA);
+        AWTKeyAdapter bWestKA = new AWTKeyAdapter("West");
+        cWest.addKeyListener(bWestKA);
+        AWTKeyAdapter bEastKA = new AWTKeyAdapter("East");
+        cEast.addKeyListener(bEastKA);
+        
+        // demo ..
+        GLEventListener demo1 = new GearsES2(1);
+        setDemoFields(demo1, glWindow1, false);
+        glWindow1.addGLEventListener(demo1);
+        glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1));
+        glWindow1.addKeyListener(new KeyAdapter() {
+            public void keyTyped(KeyEvent e) {
+                if(e.getKeyChar()=='c') {                    
+                    System.err.println("Focus Clear");
+                    if(glWindow1.getDelegatedWindow() instanceof DriverClearFocus) {
+                         ((DriverClearFocus)glWindow1.getDelegatedWindow()).clearFocus();
+                    }
+                } else if(e.getKeyChar()=='e') {                    
+                    System.err.println("Focus East");
+                    try {
+                        java.awt.EventQueue.invokeLater(new Runnable() {
+                           public void run() {
+                               cEast.requestFocusInWindow();
+                           }                         
+                        });
+                    } catch (Exception ex) { ex.printStackTrace(); }
+                } else if(e.getKeyChar()=='w') {                    
+                    System.err.println("Focus West");
+                    try {
+                        java.awt.EventQueue.invokeLater(new Runnable() {
+                           public void run() {
+                               cWest.requestFocusInWindow();
+                           }                         
+                        });
+                    } catch (Exception ex) { ex.printStackTrace(); }
+                }
+            }            
+        });
+        GLAnimatorControl animator1 = new Animator(glWindow1);
+        animator1.start();
+
+        // make frame
+        frame1.setLayout(new BorderLayout());
+        frame1.setLayout(new BorderLayout());
+        frame1.add(cWest, BorderLayout.WEST);
+        frame1.add(newtCanvasAWT1, BorderLayout.CENTER);
+        frame1.add(cEast, BorderLayout.EAST);
+
+        frame1.setLocation(0, 0);
+        frame1.setSize(fSize);
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame1.validate();                
+                frame1.setVisible(true);
+            }});
+        Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glWindow1, true));
+        Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent());
+                        
+        Assert.assertEquals(true, animator1.isAnimating());
+        Assert.assertEquals(false, animator1.isPaused());
+        Assert.assertNotNull(animator1.getThread());
+          
+        if(manual) {
+            Thread.sleep(durationPerTest);            
+        } else {
+            //
+            // initial focus on bWest
+            //        
+            AWTRobotUtil.assertRequestFocusAndWait(robot, cWest, cWest, bWestFA, null);
+            Assert.assertEquals(true,  bWestFA.focusGained());
+            Thread.sleep(durationPerTest/numFocus);
+                    
+            //
+            // forth
+            //
+            
+            // bWest -> glWin
+            AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_TAB, cWest, null);
+            Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA)); 
+            Assert.assertEquals(true,  glWindow1FA.focusGained());
+            Assert.assertEquals(true,  bWestFA.focusLost());
+            Thread.sleep(durationPerTest/numFocus);
+            
+            // glWin -> bEast
+            AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_TAB, glWindow1, null);
+            Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(cEast, bEastFA, glWindow1FA)); 
+            Assert.assertEquals(true,  bEastFA.focusGained());
+            Assert.assertEquals(true,  glWindow1FA.focusLost());
+            Thread.sleep(durationPerTest/numFocus);
+    
+            //
+            // back (using custom back traversal key 'backspace')
+            //
+            // bEast -> glWin
+            AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_BACK_SPACE, cEast, null);
+            Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bEastFA)); 
+            Assert.assertEquals(true,  glWindow1FA.focusGained());
+            Assert.assertEquals(true,  bEastFA.focusLost());
+            Thread.sleep(durationPerTest/numFocus);
+    
+            AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_BACK_SPACE, glWindow1, null);
+            Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(cWest, bWestFA, glWindow1FA)); 
+            Assert.assertEquals(true,  bWestFA.focusGained());
+            Assert.assertEquals(true,  glWindow1FA.focusLost());
+            Thread.sleep(durationPerTest/numFocus);  
+            
+            // direct AWT request focus
+            try {
+                java.awt.EventQueue.invokeAndWait(new Runnable() {
+                   public void run() {
+                       newtCanvasAWT1.requestFocus();
+                   }                         
+                });
+            } catch (Exception ex) { ex.printStackTrace(); }            
+            Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA)); 
+            Assert.assertEquals(true,  glWindow1FA.focusGained());
+            Assert.assertEquals(true,  bWestFA.focusLost());
+            Thread.sleep(durationPerTest/numFocus);
+            
+            // direct AWT request focus
+            try {
+                java.awt.EventQueue.invokeAndWait(new Runnable() {
+                   public void run() {
+                       cWest.requestFocus();
+                   }                         
+                });
+            } catch (Exception ex) { ex.printStackTrace(); }            
+            Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(cWest, bWestFA, glWindow1FA)); 
+            Assert.assertEquals(true,  bWestFA.focusGained());
+            Assert.assertEquals(true,  glWindow1FA.focusLost());
+            Thread.sleep(durationPerTest/numFocus);
+            
+            // direct NEWT request focus
+            glWindow1.requestFocus();
+            Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA)); 
+            Assert.assertEquals(true,  glWindow1FA.focusGained());
+            Assert.assertEquals(true,  bWestFA.focusLost());
+            Thread.sleep(durationPerTest/numFocus);            
+        }
+        
+        animator1.stop();
+        Assert.assertEquals(false, animator1.isAnimating());
+        Assert.assertEquals(false, animator1.isPaused());
+        Assert.assertEquals(null, animator1.getThread());
+
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame1.dispose();
+            } } );
+        glWindow1.destroy();
+    }
+
+    public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
+        Assert.assertNotNull(demo);
+        Assert.assertNotNull(glWindow);
+        Window window = glWindow.getDelegatedWindow();
+        if(debug) {
+            MiscUtils.setFieldIfExists(demo, "glDebug", true);
+            MiscUtils.setFieldIfExists(demo, "glTrace", true);
+        }
+        if(!MiscUtils.setFieldIfExists(demo, "window", window)) {
+            MiscUtils.setFieldIfExists(demo, "glWindow", glWindow);
+        }
+    }
+
+    static int atoi(String a) {
+        int i=0;
+        try {
+            i = Integer.parseInt(a);
+        } catch (Exception ex) { ex.printStackTrace(); }
+        return i;
+    }
+
+    public static void main(String args[]) throws IOException {
+        for(int i=0; i<args.length; i++) {
+            if(args[i].equals("-time")) {
+                durationPerTest = atoi(args[++i]);
+            } else if(args[i].equals("-manual")) {
+                manual = true;
+            }
+        }
+        String tstname = TestParentingFocusTraversal01AWT.class.getName();
+        /*
+        org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] {
+            tstname,
+            "filtertrace=true",
+            "haltOnError=false",
+            "haltOnFailure=false",
+            "showoutput=true",
+            "outputtoformatters=true",
+            "logfailedtests=true",
+            "logtestlistenerevents=true",
+            "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter",
+            "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } ); */
+        org.junit.runner.JUnitCore.main(tstname);
+    }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer01GLCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer01GLCanvasAWT.java
new file mode 100644
index 0000000..1367a27
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer01GLCanvasAWT.java
@@ -0,0 +1,205 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ * 
+ *    1. Redistributions of source code must retain the above copyright notice, this list of
+ *       conditions and the following disclaimer.
+ * 
+ *    2. Redistributions in binary form must reproduce the above copyright notice, this list
+ *       of conditions and the following disclaimer in the documentation and/or other materials
+ *       provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+ 
+package com.jogamp.opengl.test.junit.newt.parenting;
+
+import java.awt.BorderLayout;
+import java.awt.Button;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.media.opengl.GLAnimatorControl;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.awt.GLCanvas;
+
+import jogamp.nativewindow.jawt.JAWTUtil;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.jogamp.newt.Window;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+public class TestParentingOffscreenLayer01GLCanvasAWT extends UITestCase {
+    static Dimension frameSize0;
+    static Dimension frameSize1;
+    static Dimension preferredGLSize;
+    static Dimension minGLSize;
+    static long durationPerTest = 1000;
+
+    @BeforeClass
+    public static void initClass() {
+        frameSize0 = new Dimension(500,300);
+        frameSize1 = new Dimension(800,600);
+        preferredGLSize = new Dimension(400,200);
+        minGLSize = new Dimension(200,100);
+    }
+
+    private void setupFrameAndShow(final Frame f, java.awt.Component comp) throws InterruptedException, InvocationTargetException {
+        
+        Container c = new Container();
+        c.setLayout(new BorderLayout());
+        c.add(new Button("north"), BorderLayout.NORTH);
+        c.add(new Button("south"), BorderLayout.SOUTH);
+        c.add(new Button("east"), BorderLayout.EAST);
+        c.add(new Button("west"), BorderLayout.WEST);
+        c.add(comp, BorderLayout.CENTER);
+        
+        f.setLayout(new BorderLayout());
+        f.add(new Button("NORTH"), BorderLayout.NORTH);
+        f.add(new Button("SOUTH"), BorderLayout.SOUTH);
+        f.add(new Button("EAST"), BorderLayout.EAST);
+        f.add(new Button("WEST"), BorderLayout.WEST);
+        f.add(c, BorderLayout.CENTER);
+        
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                f.validate();
+                f.setVisible(true);
+            }});        
+    }
+    private void end(GLAnimatorControl actrl, final Frame f, Window w) throws InterruptedException, InvocationTargetException {
+        actrl.stop();
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                f.dispose();
+            } } );
+        if(null != w) {
+            w.destroy();
+        }
+    }
+    
+    @Test
+    public void testOnscreenLayerGLCanvas_Onscreen() throws InterruptedException, InvocationTargetException {
+        testOffscreenLayerGLCanvas_Impl(false, false);
+    }
+    
+    /** We have no GLCanvas OffscreenWindow as we have for NEWT .. test disabled.
+    @Test
+    public void testOffscreenLayerGLCanvas_OffscreenLayerWithOffscreenClass() throws InterruptedException, InvocationTargetException {
+        testOffscreenLayerGLCanvas_Impl(true, true);
+    } */
+    
+    @Test
+    public void testOffscreenLayerGLCanvas_OffscreenLayerWithOnscreenClass() throws InterruptedException, InvocationTargetException {
+        testOffscreenLayerGLCanvas_Impl(true, false);
+    }
+    
+    private void testOffscreenLayerGLCanvas_Impl(boolean offscreenLayer, boolean offscreenClass) throws InterruptedException, InvocationTargetException {
+        final Frame frame1 = new Frame("AWT Parent Frame");
+        
+        GLCapabilities glCaps = new GLCapabilities(null);
+        if(offscreenClass) {
+            glCaps.setOnscreen(false);
+            glCaps.setPBuffer(true);
+        }
+
+        final GLCanvas glc = new GLCanvas(glCaps);
+        glc.setShallUseOffscreenLayer(offscreenLayer); // trigger offscreen layer - if supported
+        glc.setPreferredSize(preferredGLSize);
+        glc.setMinimumSize(minGLSize);
+        
+        GLEventListener demo1 = new GearsES2(1);
+        glc.addGLEventListener(demo1);
+        
+        frame1.setSize(frameSize0);
+        setupFrameAndShow(frame1, glc);
+        Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glc, true));
+        Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glc, true));
+        Assert.assertEquals(JAWTUtil.isOffscreenLayerSupported() && offscreenLayer,
+                            glc.isOffscreenLayerSurfaceEnabled());
+        
+        GLAnimatorControl animator1 = new Animator(glc);
+        animator1.start();
+
+        Thread.sleep(durationPerTest/2);
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame1.setSize(frameSize1);
+                frame1.validate();
+            }});        
+        
+        Thread.sleep(durationPerTest/2);
+        
+        end(animator1, frame1, null);        
+    }
+    
+    public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
+        Assert.assertNotNull(demo);
+        Assert.assertNotNull(glWindow);
+        Window window = glWindow.getDelegatedWindow();
+        if(debug) {
+            MiscUtils.setFieldIfExists(demo, "glDebug", true);
+            MiscUtils.setFieldIfExists(demo, "glTrace", true);
+        }
+        if(!MiscUtils.setFieldIfExists(demo, "window", window)) {
+            MiscUtils.setFieldIfExists(demo, "glWindow", glWindow);
+        }
+    }
+
+    static int atoi(String a) {
+        int i=0;
+        try {
+            i = Integer.parseInt(a);
+        } catch (Exception ex) { ex.printStackTrace(); }
+        return i;
+    }
+
+    public static void main(String args[]) throws IOException {
+        for(int i=0; i<args.length; i++) {
+            if(args[i].equals("-time")) {
+                durationPerTest = atoi(args[++i]);
+            }
+        }
+        String tstname = TestParentingOffscreenLayer01GLCanvasAWT.class.getName();
+        /*
+        org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] {
+            tstname,
+            "filtertrace=true",
+            "haltOnError=false",
+            "haltOnFailure=false",
+            "showoutput=true",
+            "outputtoformatters=true",
+            "logfailedtests=true",
+            "logtestlistenerevents=true",
+            "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter",
+            "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } ); */
+        org.junit.runner.JUnitCore.main(tstname);
+    }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer02NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer02NewtCanvasAWT.java
new file mode 100644
index 0000000..bc59c73
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer02NewtCanvasAWT.java
@@ -0,0 +1,209 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ * 
+ *    1. Redistributions of source code must retain the above copyright notice, this list of
+ *       conditions and the following disclaimer.
+ * 
+ *    2. Redistributions in binary form must reproduce the above copyright notice, this list
+ *       of conditions and the following disclaimer in the documentation and/or other materials
+ *       provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+ 
+package com.jogamp.opengl.test.junit.newt.parenting;
+
+import java.awt.BorderLayout;
+import java.awt.Button;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.media.opengl.GLAnimatorControl;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLEventListener;
+
+import jogamp.nativewindow.jawt.JAWTUtil;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.jogamp.newt.Window;
+import com.jogamp.newt.awt.NewtCanvasAWT;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+public class TestParentingOffscreenLayer02NewtCanvasAWT extends UITestCase {
+    static Dimension frameSize0;
+    static Dimension frameSize1;
+    static Dimension preferredGLSize;
+    static Dimension minGLSize;
+    static long durationPerTest = 1000;
+
+    @BeforeClass
+    public static void initClass() {
+        frameSize0 = new Dimension(500,300);
+        frameSize1 = new Dimension(800,600);
+        preferredGLSize = new Dimension(400,200);
+        minGLSize = new Dimension(200,100);
+    }
+
+    private void setupFrameAndShow(final Frame f, java.awt.Component comp) throws InterruptedException, InvocationTargetException {
+        
+        Container c = new Container();
+        c.setLayout(new BorderLayout());
+        c.add(new Button("north"), BorderLayout.NORTH);
+        c.add(new Button("south"), BorderLayout.SOUTH);
+        c.add(new Button("east"), BorderLayout.EAST);
+        c.add(new Button("west"), BorderLayout.WEST);
+        c.add(comp, BorderLayout.CENTER);
+        
+        f.setLayout(new BorderLayout());
+        f.add(new Button("NORTH"), BorderLayout.NORTH);
+        f.add(new Button("SOUTH"), BorderLayout.SOUTH);
+        f.add(new Button("EAST"), BorderLayout.EAST);
+        f.add(new Button("WEST"), BorderLayout.WEST);
+        f.add(c, BorderLayout.CENTER);
+        
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                f.validate();
+                f.setVisible(true);
+            }});        
+    }
+    private void end(GLAnimatorControl actrl, final Frame f, Window w) throws InterruptedException, InvocationTargetException {
+        actrl.stop();
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                f.dispose();
+            } } );
+        if(null != w) {
+            w.destroy();
+        }
+    }
+    
+    @Test
+    public void testOnscreenLayerNewtCanvas_Onscreen() throws InterruptedException, InvocationTargetException {
+        testOffscreenLayerNewtCanvas_Impl(false, false);
+    }
+    
+    @Test
+    public void testOffscreenLayerNewtCanvas_OffscreenLayerWithOffscreenClass() throws InterruptedException, InvocationTargetException {
+        testOffscreenLayerNewtCanvas_Impl(true, true);
+    }
+    
+    @Test
+    public void testOffscreenLayerNewtCanvas_OffscreenLayerWithOnscreenClass() throws InterruptedException, InvocationTargetException {
+        testOffscreenLayerNewtCanvas_Impl(true, false);
+    }
+    
+    private void testOffscreenLayerNewtCanvas_Impl(boolean offscreenLayer, boolean offscreenClass) throws InterruptedException, InvocationTargetException {
+        final Frame frame1 = new Frame("AWT Parent Frame");
+        
+        GLCapabilities glCaps = new GLCapabilities(null);
+        if(offscreenClass) {
+            glCaps.setOnscreen(false);
+            glCaps.setPBuffer(true);
+        }
+
+        GLWindow glWindow1 = GLWindow.create(glCaps);
+        
+        final NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1);
+        newtCanvasAWT1.setShallUseOffscreenLayer(offscreenLayer); // trigger offscreen layer - if supported
+        newtCanvasAWT1.setPreferredSize(preferredGLSize);
+        newtCanvasAWT1.setMinimumSize(minGLSize);
+        
+        GLEventListener demo1 = new GearsES2(1);
+        setDemoFields(demo1, glWindow1, false);
+        glWindow1.addGLEventListener(demo1);
+        glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1));
+        
+        frame1.setSize(frameSize0);
+        setupFrameAndShow(frame1, newtCanvasAWT1);
+        Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true));
+        Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glWindow1, true));
+        Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent());
+        Assert.assertEquals(JAWTUtil.isOffscreenLayerSupported() && offscreenLayer, 
+                            newtCanvasAWT1.isOffscreenLayerSurfaceEnabled());
+
+        GLAnimatorControl animator1 = new Animator(glWindow1);
+        animator1.start();
+
+        Thread.sleep(durationPerTest/2);
+        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame1.setSize(frameSize1);
+                frame1.validate();
+            }});        
+        
+        Thread.sleep(durationPerTest/2);
+        
+        end(animator1, frame1, glWindow1);
+    }
+
+    public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
+        Assert.assertNotNull(demo);
+        Assert.assertNotNull(glWindow);
+        Window window = glWindow.getDelegatedWindow();
+        if(debug) {
+            MiscUtils.setFieldIfExists(demo, "glDebug", true);
+            MiscUtils.setFieldIfExists(demo, "glTrace", true);
+        }
+        if(!MiscUtils.setFieldIfExists(demo, "window", window)) {
+            MiscUtils.setFieldIfExists(demo, "glWindow", glWindow);
+        }
+    }
+
+    static int atoi(String a) {
+        int i=0;
+        try {
+            i = Integer.parseInt(a);
+        } catch (Exception ex) { ex.printStackTrace(); }
+        return i;
+    }
+
+    public static void main(String args[]) throws IOException {
+        for(int i=0; i<args.length; i++) {
+            if(args[i].equals("-time")) {
+                durationPerTest = atoi(args[++i]);
+            }
+        }
+        String tstname = TestParentingOffscreenLayer02NewtCanvasAWT.class.getName();
+        /*
+        org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] {
+            tstname,
+            "filtertrace=true",
+            "haltOnError=false",
+            "haltOnFailure=false",
+            "showoutput=true",
+            "outputtoformatters=true",
+            "logfailedtests=true",
+            "logtestlistenerevents=true",
+            "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter",
+            "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } ); */
+        org.junit.runner.JUnitCore.main(tstname);
+    }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03bAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestTranslucentParentingAWT.java
similarity index 57%
rename from src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03bAWT.java
rename to src/test/com/jogamp/opengl/test/junit/newt/parenting/TestTranslucentParentingAWT.java
index 46a63dc..57b8517 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03bAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestTranslucentParentingAWT.java
@@ -28,120 +28,129 @@
  
 package com.jogamp.opengl.test.junit.newt.parenting;
 
-import java.lang.reflect.*;
-
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
 import java.awt.BorderLayout;
+import java.awt.Color;
 import java.awt.Container;
 import java.awt.Dimension;
 import java.awt.Frame;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
 import java.awt.Label;
+import java.awt.Transparency;
+import java.awt.image.ColorModel;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 
-import javax.media.opengl.*;
+import javax.media.opengl.GLAnimatorControl;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLEventListener;
 
-import com.jogamp.opengl.util.Animator;
-import com.jogamp.newt.*;
-import com.jogamp.newt.opengl.*;
-import com.jogamp.newt.awt.NewtCanvasAWT;
-
-import java.io.IOException;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
-import com.jogamp.opengl.test.junit.util.*;
+import com.jogamp.common.util.ReflectionUtil;
+import com.jogamp.newt.Window;
+import com.jogamp.newt.awt.NewtCanvasAWT;
+import com.jogamp.newt.opengl.GLWindow;
 import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
 
-public class TestParenting03bAWT extends UITestCase {
+public class TestTranslucentParentingAWT extends UITestCase {
     static Dimension size;
-    static long durationPerTest = 800;
-    static long waitAdd2nd = 500;
+    static long durationPerTest = 400;
+    static long waitAdd2nd = 200;
     static GLCapabilities glCaps;
 
     @BeforeClass
     public static void initClass() {
         size = new Dimension(400,200);
         glCaps = new GLCapabilities(null);
+        glCaps.setAlphaBits(8);
+        glCaps.setBackgroundOpaque(false);
     }
 
     @Test
-    public void testWindowParenting1AWTTwoNewtChilds01() throws InterruptedException, InvocationTargetException {
-        testWindowParenting1AWTTwoNewtChilds();
+    public void testWindowParenting1AWTOneNewtChild01() throws InterruptedException, InvocationTargetException {
+        testWindowParenting1AWTOneNewtChild();
     }
 
-    public void testWindowParenting1AWTTwoNewtChilds() throws InterruptedException, InvocationTargetException {
-        Frame frame1 = new Frame("AWT Parent Frame");
-        GLWindow glWindow1 = GLWindow.create(glCaps);
+    static Frame getTranslucentFrame() {
+        GraphicsConfiguration gc=null;
+        GraphicsDevice[] devices= GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
+        for (int i = 0; i < devices.length ; i++)
+        {
+            GraphicsConfiguration[] configs = devices[i].getConfigurations();
+            for (int j = 0; j < configs.length ; j++) {
+                GraphicsConfiguration config = configs[j];
+                ColorModel tcm = config.getColorModel(Transparency.TRANSLUCENT);
+                boolean capable1 = ( null != tcm ) ? tcm.getTransparency() == Transparency.TRANSLUCENT : false;
+                boolean capable2 = false;
+                try {
+                    capable2 = ((Boolean)ReflectionUtil.callStaticMethod(
+                                                "com.sun.awt.AWTUtilities", "isTranslucencyCapable", 
+                                                new Class<?>[] { GraphicsConfiguration.class }, 
+                                                new Object[] { config } , 
+                                                GraphicsConfiguration.class.getClassLoader())).booleanValue();
+                    System.err.println("com.sun.awt.AWTUtilities.isTranslucencyCapable(config) passed: "+capable2);
+                } catch (RuntimeException re) {
+                    System.err.println("com.sun.awt.AWTUtilities.isTranslucencyCapable(config) failed: "+re.getMessage());
+                }
+                System.err.println(i+":"+j+" "+config+", "+tcm+", capable "+capable1+"/"+capable2);
+                if(capable1&&capable2) {
+                    gc=configs[j];
+                    System.err.println("Chosen "+i+":"+j+" "+config+", "+tcm+", capable "+capable1+"/"+capable2);
+                    break;
+                }
+            }
+        }
+        final Frame frame = new Frame(gc);
+        if(null!=gc) {
+            frame.setUndecorated(true);
+            frame.setBackground(new Color(0, 0, 0, 0));
+        }
+        frame.setTitle("AWT Parent Frame (opaque: "+(null==gc)+")");
+        return frame;
+    }
+    
+    public void testWindowParenting1AWTOneNewtChild() throws InterruptedException, InvocationTargetException {
+        final Frame frame1 = getTranslucentFrame();
+        final GLWindow glWindow1 = GLWindow.create(glCaps);
         glWindow1.setUpdateFPSFrames(1, null);
-        NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1);
+        glWindow1.setUndecorated(true);
+        final NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(frame1.getGraphicsConfiguration(), glWindow1);
         newtCanvasAWT1.setPreferredSize(size);
 
         GLEventListener demo1 = new GearsES2(1);
         setDemoFields(demo1, glWindow1, false);
         glWindow1.addGLEventListener(demo1);
-        glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1));
         GLAnimatorControl animator1 = new Animator(glWindow1);
         animator1.start();
 
-        GLWindow glWindow2 = GLWindow.create(glCaps);
-        glWindow2.setUpdateFPSFrames(1, null);
-        NewtCanvasAWT newtCanvasAWT2 = new NewtCanvasAWT(glWindow2);
-        newtCanvasAWT2.setPreferredSize(size);
-
-        GLEventListener demo2 = new GearsES2(1);
-        setDemoFields(demo2, glWindow2, false);
-        glWindow2.addGLEventListener(demo2);
-        glWindow2.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT2, glWindow2));
-        GLAnimatorControl animator2 = new Animator(glWindow2);
-        animator2.start();
-
         Container cont1 = new Container();
         cont1.setLayout(new BorderLayout());
         cont1.add(newtCanvasAWT1, BorderLayout.CENTER);
-        System.err.println("******* Cont1 setVisible");
         cont1.setVisible(true);
 
-        Container cont2 = new Container();
-        cont2.setLayout(new BorderLayout());
-        cont2.add(newtCanvasAWT2, BorderLayout.CENTER);
-        System.err.println("******* Cont2 setVisible");
-        cont2.setVisible(true);
-        final Container f_cont2 = cont2;
-
         frame1.setLayout(new BorderLayout());
-        frame1.add(new Label("NORTH"), BorderLayout.NORTH);
-        frame1.add(new Label("CENTER"), BorderLayout.CENTER);
-        frame1.add(new Label("SOUTH"), BorderLayout.SOUTH);
         frame1.add(cont1, BorderLayout.EAST);
+        frame1.add(new Label("center"), BorderLayout.CENTER);
         frame1.setLocation(0, 0);
-        frame1.setSize((int)size.getWidth()*2, (int)size.getHeight()*2);
-        final Frame f_frame1 = frame1;
+        frame1.setSize((int)size.getWidth(), (int)size.getHeight());
         javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
-                f_frame1.pack();
-                System.err.println("******* Frame setVisible");
-                f_frame1.setVisible(true);
+                frame1.pack();
+                frame1.setVisible(true);
             }});
 
         Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent());
-        Assert.assertEquals(newtCanvasAWT2.getNativeWindow(),glWindow2.getParent());
-
         Assert.assertEquals(true, animator1.isAnimating());
         Assert.assertEquals(false, animator1.isPaused());
         Assert.assertNotNull(animator1.getThread());
 
-        Assert.assertEquals(true, animator2.isAnimating());
-        Assert.assertEquals(false, animator2.isPaused());
-        Assert.assertNotNull(animator2.getThread());
-
-        Thread.sleep(waitAdd2nd);
-
-        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
-            public void run() {
-                f_frame1.add(f_cont2, BorderLayout.WEST);
-                f_frame1.pack();
-            }});
-
         Thread.sleep(durationPerTest);
 
         animator1.stop();
@@ -149,20 +158,14 @@ public class TestParenting03bAWT extends UITestCase {
         Assert.assertEquals(false, animator1.isPaused());
         Assert.assertEquals(null, animator1.getThread());
 
-        animator2.stop();
-        Assert.assertEquals(false, animator2.isAnimating());
-        Assert.assertEquals(false, animator2.isPaused());
-        Assert.assertEquals(null, animator2.getThread());
-
         frame1.dispose();
         glWindow1.destroy();
-        glWindow2.destroy();
     }
 
     public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
         Assert.assertNotNull(demo);
         Assert.assertNotNull(glWindow);
-        Window window = glWindow.getWindow();
+        Window window = glWindow.getDelegatedWindow();
         if(debug) {
             MiscUtils.setFieldIfExists(demo, "glDebug", true);
             MiscUtils.setFieldIfExists(demo, "glTrace", true);
@@ -188,7 +191,7 @@ public class TestParenting03bAWT extends UITestCase {
                 waitAdd2nd = atoi(args[++i]);
             }
         }
-        String tstname = TestParenting03bAWT.class.getName();
+        String tstname = TestTranslucentParentingAWT.class.getName();
         /*
         org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] {
             tstname,
diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTFocusAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/AWTFocusAdapter.java
index d0fbf07..fe0f2ac 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/AWTFocusAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/AWTFocusAdapter.java
@@ -34,7 +34,7 @@ import java.awt.event.FocusListener;
 public class AWTFocusAdapter implements FocusEventCountAdapter, FocusListener {
 
     String prefix;
-    boolean focusGained;
+    int focusCount;
     boolean wasTemporary;
 
     public AWTFocusAdapter(String prefix) {
@@ -42,12 +42,16 @@ public class AWTFocusAdapter implements FocusEventCountAdapter, FocusListener {
         reset();
     }
 
-    public boolean hasFocus() {
-        return focusGained;
+    public boolean focusLost() {
+        return focusCount<0;        
     }
     
+    public boolean focusGained() {
+        return focusCount>0;
+    }
+        
     public void reset() {
-        focusGained = false;
+        focusCount = 0;
         wasTemporary = false;
     }
 
@@ -58,17 +62,19 @@ public class AWTFocusAdapter implements FocusEventCountAdapter, FocusListener {
 
     /* @Override */
     public void focusGained(FocusEvent e) {
-        focusGained = true;
+        if(focusCount<0) { focusCount=0; }
+        focusCount++;
         wasTemporary = e.isTemporary();
-        System.err.println("FOCUS AWT  GAINED "+(wasTemporary?"TEMP":"PERM")+" ["+focusGained+"]: "+prefix+", "+e);
+        System.err.println("FOCUS AWT  GAINED "+(wasTemporary?"TEMP":"PERM")+" [fc "+focusCount+"]: "+prefix+", "+e);
     }
 
     /* @Override */
     public void focusLost(FocusEvent e) {
-        focusGained = false;
+        if(focusCount>0) { focusCount=0; }
+        focusCount--;
         wasTemporary = e.isTemporary();
-        System.err.println("FOCUS AWT  LOST   "+(wasTemporary?"TEMP":"PERM")+" ["+focusGained+"]: "+prefix+", "+e);
+        System.err.println("FOCUS AWT  LOST   "+(wasTemporary?"TEMP":"PERM")+" [fc "+focusCount+"]: "+prefix+", "+e);
     }
     
-    public String toString() { return prefix+"[gained "+focusGained +", temp "+wasTemporary+"]"; }    
+    public String toString() { return prefix+"[focusCount "+focusCount +", temp "+wasTemporary+"]"; }    
 }
diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
index 661d58b..a27bdd7 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java
@@ -32,16 +32,12 @@ import jogamp.newt.WindowImplAccess;
 import java.lang.reflect.InvocationTargetException;
 import java.awt.AWTException;
 import java.awt.Component;
-import java.awt.Container;
 import java.awt.EventQueue;
 import java.awt.KeyboardFocusManager;
-import java.awt.Point;
-import java.awt.Rectangle;
 import java.awt.Robot;
 import java.awt.Toolkit;
 
 import javax.media.opengl.awt.GLCanvas;
-import javax.swing.JFrame;
 
 import org.junit.Assert;
 
@@ -51,12 +47,12 @@ public class AWTRobotUtil {
     
     public static final int RETRY_NUMBER  =   5;
     public static final int ROBOT_DELAY   = 100; // ms
-    public static final int TIME_OUT     = 1000; // 1s
+    public static final int TIME_OUT     = 2000; // 2s
     public static final int POLL_DIVIDER   = 20; // TO/20
     public static final int TIME_SLICE   = TIME_OUT / POLL_DIVIDER ;
     public static Integer AWT_CLICK_TO = null; 
     
-    public static Point getCenterLocation(Object obj) 
+    public static java.awt.Point getCenterLocation(Object obj, boolean onTitleBarIfWindow) 
         throws InterruptedException, InvocationTargetException {
         Component comp = null;
         com.jogamp.newt.Window win = null;
@@ -71,28 +67,29 @@ public class AWTRobotUtil {
 
         int x0, y0;
         if(null!=comp) {
-            Point p0 = comp.getLocationOnScreen();
-            Rectangle r0 = comp.getBounds();
-            if( comp instanceof JFrame ) {
-                JFrame jFrame = (JFrame) comp;
-                Container cont = jFrame.getContentPane();
-                Point p1 = cont.getLocationOnScreen();
-                int dx = (int) ( r0.getWidth() / 2.0 + .5 );
-                int dy = (int) ( ( p1.getY() - p0.getY() ) / 2.0 + .5 );
-                x0 = (int) ( p0.getX() + dx + .5 ) ;
-                y0 = (int) ( p0.getY() + dy + .5 ) ;
+            java.awt.Point p0 = comp.getLocationOnScreen();            
+            java.awt.Rectangle r0 = comp.getBounds();
+            if( onTitleBarIfWindow && comp instanceof java.awt.Window) {
+                java.awt.Window window = (java.awt.Window) comp;
+                java.awt.Insets insets = window.getInsets();
+                y0 = (int) ( p0.getY() +    insets.top / 2.0 + .5 ) ;            
             } else {
-                x0 = (int) ( p0.getX() + r0.getWidth()  / 2.0 + .5 ) ;
                 y0 = (int) ( p0.getY() + r0.getHeight() / 2.0 + .5 ) ;
             }
+            x0 = (int) ( p0.getX() + r0.getWidth() / 2.0 + .5 ) ;
         } else {
-            javax.media.nativewindow.util.Point p0 = win.getLocationOnScreen(null);
-            p0.translate(win.getWidth()/2, win.getHeight()/2);
+            javax.media.nativewindow.util.Point p0 = win.getLocationOnScreen(null);            
+            if( onTitleBarIfWindow ) {
+                javax.media.nativewindow.util.InsetsImmutable insets = win.getInsets();
+                p0.translate(win.getWidth()/2, insets.getTopHeight()/2);                
+            } else {
+                p0.translate(win.getWidth()/2, win.getHeight()/2);
+            }
             x0 = p0.getX();
             y0 = p0.getY();
         }
 
-        return new Point(x0, y0);
+        return new java.awt.Point(x0, y0);
     }
 
     /**
@@ -105,11 +102,14 @@ public class AWTRobotUtil {
     public static boolean toFront(Robot robot, final java.awt.Window window)
         throws AWTException, InterruptedException, InvocationTargetException {
 
+        AWTWindowFocusAdapter winFA = new AWTWindowFocusAdapter("window");
+        window.addWindowFocusListener(winFA);
+        
         if(null == robot) {
             robot = new Robot();
             robot.setAutoWaitForIdle(true);
         }
-        Point p0 = getCenterLocation(window);
+        java.awt.Point p0 = getCenterLocation(window, false);
         System.err.println("robot pos: "+p0);
         robot.mouseMove( (int) p0.getX(), (int) p0.getY() );
         robot.delay(ROBOT_DELAY);
@@ -122,18 +122,19 @@ public class AWTRobotUtil {
             }});
         robot.delay(ROBOT_DELAY);
 
-        KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
         int wait;
-        for (wait=0; wait<POLL_DIVIDER && window != kfm.getFocusedWindow(); wait++) {
+        for (wait=0; wait<POLL_DIVIDER && !winFA.focusGained(); wait++) {
             Thread.sleep(TIME_SLICE);
         }
+        window.removeWindowFocusListener(winFA);
         return wait<POLL_DIVIDER;
     }
 
     /**
      * centerMouse
+     * @param onTitleBarIfWindow TODO
      */
-    public static void centerMouse(Robot robot, Object obj) 
+    public static void centerMouse(Robot robot, Object obj, boolean onTitleBarIfWindow) 
         throws AWTException, InterruptedException, InvocationTargetException {
 
         if(null == robot) {
@@ -141,7 +142,7 @@ public class AWTRobotUtil {
             robot.setAutoWaitForIdle(true);
         }
 
-        Point p0 = getCenterLocation(obj);
+        java.awt.Point p0 = getCenterLocation(obj, onTitleBarIfWindow);
         System.err.println("robot pos: "+p0);
 
         robot.mouseMove( (int) p0.getX(), (int) p0.getY() );
@@ -174,8 +175,6 @@ public class AWTRobotUtil {
         final Component comp;
         final com.jogamp.newt.Window win;
 
-        KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
-        
         if(obj instanceof com.jogamp.newt.Window) {
             win = (com.jogamp.newt.Window) obj;
             comp = null;
@@ -186,13 +185,23 @@ public class AWTRobotUtil {
             throw new RuntimeException("Neither AWT nor NEWT: "+obj);
         }
         
-        if(null!=comp) {
-            javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
-                public void run() {
-                    comp.requestFocus();
-                }});
+        if(null == robot) {        
+            if(null!=comp) {
+                javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+                    public void run() {
+                        comp.requestFocus();
+                    }});
+            } else {
+                win.requestFocus();
+            }
         } else {
-            win.requestFocus();
+            final int mouseButton = java.awt.event.InputEvent.BUTTON1_MASK;    
+            centerMouse(robot, obj, true);
+    
+            robot.waitForIdle();
+            robot.mousePress(mouseButton);
+            robot.mouseRelease(mouseButton);
+            robot.delay( getClickTimeout(obj) + 1 );                
         }
     }
 
@@ -246,7 +255,7 @@ public class AWTRobotUtil {
         
         int wait;
         for (wait=0; wait<POLL_DIVIDER; wait++) {
-            if( ( null == lost || !lost.hasFocus() ) && gain.hasFocus() ) {
+            if( ( null == lost || lost.focusLost() ) && gain.focusGained() ) {
                 return true;
             }
             Thread.sleep(TIME_SLICE);
@@ -265,11 +274,17 @@ public class AWTRobotUtil {
             requestFocus(robot, requestFocus);
             hasFocus = waitForFocus(waitForFocus, gain, lost);
         }
+        if(!hasFocus) {
+            System.err.println("requestFocus: "+requestFocus);
+            System.err.println("waitForFocus: "+waitForFocus);
+            System.err.println("gain: "+gain);
+            System.err.println("lost: "+lost);
+        }
         Assert.assertTrue("Did not gain focus", hasFocus);
     }
 
-    static int keyType(int i, Robot robot, int keyCode,
-                       Object obj, InputEventCountAdapter counter) throws InterruptedException, AWTException, InvocationTargetException 
+    public static int keyType(int i, Robot robot, int keyCode,
+                              Object obj, InputEventCountAdapter counter) throws InterruptedException, AWTException, InvocationTargetException 
     {
         int tc = 0;
         int j;
@@ -281,13 +296,13 @@ public class AWTRobotUtil {
                 if(DEBUG) { System.err.println(i+":"+j+" KC1.0: "+counter+" - regain focus"); }
                 requestFocus(null, obj);
             }
-            final int c0 = counter.getCount();
+            final int c0 = null!=counter ? counter.getCount() : 0;
             if(DEBUG) { System.err.println(i+":"+j+" KC1.1: "+counter); }
             robot.waitForIdle();
             robot.keyPress(keyCode);
             robot.keyRelease(keyCode);
             if(DEBUG) { System.err.println(i+":"+j+" KC1.2: "+counter); }
-            tc = counter.getCount() - c0;
+            tc = ( null!=counter ? counter.getCount() : 1 ) - c0;
             for (int wait=0; wait<POLL_DIVIDER && 1 > tc; wait++) {
                 robot.delay(TIME_SLICE);
                 tc = counter.getCount() - c0;
@@ -311,7 +326,7 @@ public class AWTRobotUtil {
             robot.setAutoWaitForIdle(true);
         }
 
-        centerMouse(robot, obj);
+        centerMouse(robot, obj, false);
 
         Assert.assertEquals("Key already pressed", false, counter.isPressed());
         
@@ -343,13 +358,13 @@ public class AWTRobotUtil {
                 if(DEBUG) { System.err.println(i+":"+j+" MC1.0: "+counter+" - regain focus"); }
                 requestFocus(null, obj);
             }
-            final int c0 = counter.getCount();
+            final int c0 = null != counter ? counter.getCount() : 0;
             if(DEBUG) { System.err.println(i+":"+j+" MC1.1: "+counter); }
             robot.waitForIdle();
             robot.mousePress(mouseButton);
             robot.mouseRelease(mouseButton);
             if(DEBUG) { System.err.println(i+":"+j+" MC1.2: "+counter); }
-            tc = counter.getCount() - c0;
+            tc = ( null != counter ? counter.getCount() : 1 ) - c0;
             for (int wait=0; wait<POLL_DIVIDER && 1 > tc; wait++) {
                 robot.delay(TIME_SLICE);
                 tc = counter.getCount() - c0;
@@ -375,7 +390,7 @@ public class AWTRobotUtil {
 
         final int clickTO = getClickTimeout(obj);
 
-        centerMouse(robot, obj);
+        centerMouse(robot, obj, false);
 
         Assert.assertEquals("Mouse already pressed", false, counter.isPressed());
         
@@ -402,7 +417,7 @@ public class AWTRobotUtil {
      */
     public static boolean waitForFocusCount(boolean desired, FocusEventCountAdapter eca) throws InterruptedException {
         for (int wait=0; wait<POLL_DIVIDER; wait++) {
-            if( eca.hasFocus() == desired ) {
+            if( desired && eca.focusGained() || !desired && eca.focusLost() ) {
                 return true;
             }
             Thread.sleep(TIME_SLICE);
diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTFocusAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/AWTWindowFocusAdapter.java
similarity index 66%
copy from src/test/com/jogamp/opengl/test/junit/util/NEWTFocusAdapter.java
copy to src/test/com/jogamp/opengl/test/junit/util/AWTWindowFocusAdapter.java
index 9f710c4..16aacd2 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/NEWTFocusAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/AWTWindowFocusAdapter.java
@@ -28,44 +28,44 @@
  
 package com.jogamp.opengl.test.junit.util;
 
-import com.jogamp.newt.event.WindowEvent;
-import com.jogamp.newt.event.WindowListener;
-import com.jogamp.newt.event.WindowUpdateEvent;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowFocusListener;
 
-public class NEWTFocusAdapter implements WindowListener, FocusEventCountAdapter {
+public class AWTWindowFocusAdapter implements FocusEventCountAdapter, WindowFocusListener {
 
     String prefix;
-    boolean focusGained;
+    int focusCount;
 
-    public NEWTFocusAdapter(String prefix) {
+    public AWTWindowFocusAdapter(String prefix) {
         this.prefix = prefix;
         reset();
     }
 
-    public boolean hasFocus() {
-        return focusGained;
+    public boolean focusLost() {
+        return focusCount<0;        
     }
     
+    public boolean focusGained() {
+        return focusCount>0;
+    }
+        
     public void reset() {
-        focusGained = false;
+        focusCount = 0;
     }
 
+    /* @Override */
     public void windowGainedFocus(WindowEvent e) {
-        focusGained = true;
-        System.err.println("FOCUS NEWT GAINED ["+focusGained+"]: "+prefix+", "+e);
+        if(focusCount<0) { focusCount=0; }
+        focusCount++;
+        System.err.println("FOCUS AWT  GAINED (Window) [fc "+focusCount+"]: "+prefix+", "+e);
     }
 
+    /* @Override */
     public void windowLostFocus(WindowEvent e) {
-        focusGained = false;
-        System.err.println("FOCUS NEWT LOST   ["+focusGained+"]: "+prefix+", "+e);
+        if(focusCount>0) { focusCount=0; }
+        focusCount--;
+        System.err.println("FOCUS AWT  LOST   (Window) [fc "+focusCount+"]: "+prefix+", "+e);
     }
-
-    public void windowResized(WindowEvent e) { }
-    public void windowMoved(WindowEvent e) { }
-    public void windowDestroyNotify(WindowEvent e) { }
-    public void windowDestroyed(WindowEvent e) { }
-    public void windowRepaint(WindowUpdateEvent e) { }
     
-    public String toString() { return prefix+"[gained "+focusGained+"]"; }        
+    public String toString() { return prefix+"[focusCount "+focusCount +"]"; }
 }
-
diff --git a/src/test/com/jogamp/opengl/test/junit/util/FocusEventCountAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/FocusEventCountAdapter.java
index b555515..461c726 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/FocusEventCountAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/FocusEventCountAdapter.java
@@ -29,6 +29,7 @@
 package com.jogamp.opengl.test.junit.util;
 
 public interface FocusEventCountAdapter extends EventCountAdapter {
-    boolean hasFocus();
+    boolean focusLost();
+    boolean focusGained();
 }
 
diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTFocusAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTFocusAdapter.java
index 9f710c4..27d4abd 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/NEWTFocusAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTFocusAdapter.java
@@ -35,29 +35,35 @@ import com.jogamp.newt.event.WindowUpdateEvent;
 public class NEWTFocusAdapter implements WindowListener, FocusEventCountAdapter {
 
     String prefix;
-    boolean focusGained;
+    int focusCount;
 
     public NEWTFocusAdapter(String prefix) {
         this.prefix = prefix;
         reset();
     }
 
-    public boolean hasFocus() {
-        return focusGained;
+    public boolean focusLost() {
+        return focusCount<0;        
+    }
+    
+    public boolean focusGained() {
+        return focusCount>0;
     }
     
     public void reset() {
-        focusGained = false;
+        focusCount = 0;
     }
 
     public void windowGainedFocus(WindowEvent e) {
-        focusGained = true;
-        System.err.println("FOCUS NEWT GAINED ["+focusGained+"]: "+prefix+", "+e);
+        if(focusCount<0) { focusCount=0; }
+        focusCount++;
+        System.err.println("FOCUS NEWT GAINED [fc "+focusCount+"]: "+prefix+", "+e);
     }
 
     public void windowLostFocus(WindowEvent e) {
-        focusGained = false;
-        System.err.println("FOCUS NEWT LOST   ["+focusGained+"]: "+prefix+", "+e);
+        if(focusCount>0) { focusCount=0; }
+        focusCount--;
+        System.err.println("FOCUS NEWT LOST   [fc "+focusCount+"]: "+prefix+", "+e);
     }
 
     public void windowResized(WindowEvent e) { }
@@ -66,6 +72,6 @@ public class NEWTFocusAdapter implements WindowListener, FocusEventCountAdapter
     public void windowDestroyed(WindowEvent e) { }
     public void windowRepaint(WindowUpdateEvent e) { }
     
-    public String toString() { return prefix+"[gained "+focusGained+"]"; }        
+    public String toString() { return prefix+"[focusCount "+focusCount+"]"; }        
 }
 
diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java
index 814a9fc..c74d2ea 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java
@@ -78,6 +78,7 @@ public class NEWTGLContext {
         Assert.assertNotNull(drawable);
         
         drawable.setRealized(true);
+        Assert.assertTrue(drawable.isRealized());
         
         GLContext context = drawable.createContext(null);
         Assert.assertNotNull(context);
@@ -105,14 +106,15 @@ public class NEWTGLContext {
         Assert.assertNotNull(window);
         window.setSize(width, height);
         window.setVisible(true);
-        AWTRobotUtil.waitForVisible(window, true);
-        AWTRobotUtil.waitForRealized(window, true);
+        Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true));
+        Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true));
             
         GLDrawableFactory factory = GLDrawableFactory.getFactory(glp);
         GLDrawable drawable = factory.createGLDrawable(window);
         Assert.assertNotNull(drawable);
         
         drawable.setRealized(true);
+        Assert.assertTrue(drawable.isRealized());
         
         GLContext context = drawable.createContext(null);
         Assert.assertNotNull(context);
diff --git a/src/test/jogamp/newt/WindowImplAccess.java b/src/test/jogamp/newt/WindowImplAccess.java
index 76d0dc0..e8be5f6 100644
--- a/src/test/jogamp/newt/WindowImplAccess.java
+++ b/src/test/jogamp/newt/WindowImplAccess.java
@@ -29,26 +29,16 @@
 package jogamp.newt;
 
 import com.jogamp.newt.Window;
-import com.jogamp.newt.opengl.GLWindow;
 
 /**
  * Allows access to protected methods of WindowImpl
  */
 public class WindowImplAccess {
     public static final void windowDestroyNotify(Window win) {
-        WindowImpl winImpl = null;
-        if(win instanceof GLWindow) {
-            GLWindow glwin = (GLWindow) win;
-            winImpl = (WindowImpl) glwin.getWindow();
-        } else if(win instanceof WindowImpl) {
-            winImpl = (WindowImpl) win;
-        } else {
-            throw new RuntimeException("Given Window not a GLWindow, not WindowImpl, but "+win.getClass());
-        }
-        final WindowImpl winImplF = winImpl;
-        winImplF.runOnEDTIfAvail(true, new Runnable() {
+        final WindowImpl winImpl = (WindowImpl) win.getDelegatedWindow();
+        winImpl.runOnEDTIfAvail(true, new Runnable() {
             public void run() {
-                winImplF.windowDestroyNotify();
+                winImpl.windowDestroyNotify();
             }
         });        
     }
diff --git a/src/test/native/displayMultiple02.c b/src/test/native/displayMultiple02.c
index 1bfe95b..df6666a 100644
--- a/src/test/native/displayMultiple02.c
+++ b/src/test/native/displayMultiple02.c
@@ -11,7 +11,21 @@
 
 static void testOrder(int reverseDestroyOrder, const char * msg);
 
+static int useXLockDisplay = 0;
+
 int main(int nargs, char **vargs) {
+    int arg=1;
+    while(arg<nargs) {
+       if(0 == strcmp(vargs[arg], "-xlock")) {
+          useXLockDisplay = 1;
+       }
+       arg++;
+    }
+    fprintf(stderr, "-xlock    (XLockDisplay): %d\n", useXLockDisplay);
+
+    if( useXLockDisplay ) {
+      XInitThreads();
+    }
     testOrder(0, "Normal order");
     testOrder(1, "Reverse order");
     return 0;
@@ -20,6 +34,17 @@ int main(int nargs, char **vargs) {
 static void createGLWin(Display *dpy, int width, int height, Window *rWin, GLXContext *rCtx);
 static void useGL(Display *dpy, Window win, GLXContext ctx, int width, int height);
 
+static void XLOCKDISPLAY(Display *dpy) {
+    if( useXLockDisplay ) {
+        XLockDisplay(dpy);
+    }
+}
+static void XUNLOCKDISPLAY(Display *dpy) {
+    if( useXLockDisplay ) {
+        XUnlockDisplay(dpy);
+    }
+}
+
 void testOrder(int reverseDestroyOrder, const char * msg) {
     int major, minor;
     Display *disp1;
@@ -32,35 +57,58 @@ void testOrder(int reverseDestroyOrder, const char * msg) {
 
     fprintf(stderr, "%s: Create #1\n", msg);
     disp1 = XOpenDisplay(NULL);
-    createGLWin(disp1, 200, 200, &win1, &ctx1);
-    useGL(disp1, win1, ctx1, 200, 200);
+    XLOCKDISPLAY(disp1);
+      createGLWin(disp1, 200, 200, &win1, &ctx1);
+      useGL(disp1, win1, ctx1, 200, 200);
+    XUNLOCKDISPLAY(disp1);
 
     fprintf(stderr, "%s: Create #2\n", msg);
     disp2 = XOpenDisplay(NULL);
-    createGLWin(disp2, 300, 300, &win2, &ctx2);
-    useGL(disp2, win2, ctx2, 300, 300);
+    XLOCKDISPLAY(disp2);
+      createGLWin(disp2, 300, 300, &win2, &ctx2);
+      useGL(disp2, win2, ctx2, 300, 300);
+    XUNLOCKDISPLAY(disp2);
 
     if(reverseDestroyOrder) {
-        fprintf(stderr, "%s: Destroy #2\n", msg);
-        glXMakeCurrent(disp2, 0, 0);
-        glXDestroyContext(disp2, ctx2);
+        fprintf(stderr, "%s: Destroy #2.0\n", msg);
+        XLOCKDISPLAY(disp2);
+          glXMakeCurrent(disp2, 0, 0);
+          glXDestroyContext(disp2, ctx2);
+        XUNLOCKDISPLAY(disp2);
         XCloseDisplay(disp2);
-
-        fprintf(stderr, "%s: Destroy #1\n", msg);
-        glXMakeCurrent(disp1, 0, 0);
-        glXDestroyContext(disp1, ctx1);
+        fprintf(stderr, "%s: Destroy #2.X\n", msg);
+
+        fprintf(stderr, "%s: Destroy #1.0\n", msg);
+        XLOCKDISPLAY(disp1);
+        fprintf(stderr, "%s: Destroy #1.1\n", msg);
+          glXMakeCurrent(disp1, 0, 0);
+          fprintf(stderr, "%s: Destroy #1.2\n", msg);
+          glXDestroyContext(disp1, ctx1);
+          fprintf(stderr, "%s: Destroy #1.3\n", msg);
+        XUNLOCKDISPLAY(disp1);
+        fprintf(stderr, "%s: Destroy #1.4\n", msg);
         XCloseDisplay(disp1);
+        fprintf(stderr, "%s: Destroy #1.X\n", msg);
     } else {
-        fprintf(stderr, "%s: Destroy #1\n", msg);
-        glXMakeCurrent(disp1, 0, 0);
-        glXDestroyContext(disp1, ctx1);
+        fprintf(stderr, "%s: Destroy #1.0\n", msg);
+        XLOCKDISPLAY(disp1);
+          glXMakeCurrent(disp1, 0, 0);
+          glXDestroyContext(disp1, ctx1);
+        XUNLOCKDISPLAY(disp1);
         XCloseDisplay(disp1);
-
-        fprintf(stderr, "%s: Destroy #2\n", msg);
-        glXMakeCurrent(disp2, 0, 0);
-        glXDestroyContext(disp2, ctx2);
+        fprintf(stderr, "%s: Destroy #1.X\n", msg);
+
+        fprintf(stderr, "%s: Destroy #2.0\n", msg);
+        XLOCKDISPLAY(disp2);
+        fprintf(stderr, "%s: Destroy #2.1\n", msg);
+          glXMakeCurrent(disp2, 0, 0);
+          fprintf(stderr, "%s: Destroy #2.2\n", msg);
+          glXDestroyContext(disp2, ctx2);
+          fprintf(stderr, "%s: Destroy #2.3\n", msg);
+        XUNLOCKDISPLAY(disp2);
+        fprintf(stderr, "%s: Destroy #2.4\n", msg);
         XCloseDisplay(disp2);
-
+        fprintf(stderr, "%s: Destroy #2.X\n", msg);
     }
 
     fprintf(stderr, "%s: Success - no bug\n", msg);
diff --git a/tools/jackpotc/.gitignore b/tools/jackpotc/.gitignore
new file mode 100644
index 0000000..a65b417
--- /dev/null
+++ b/tools/jackpotc/.gitignore
@@ -0,0 +1 @@
+lib
diff --git a/tools/jackpotc/test/oldgears/.gitignore b/tools/jackpotc/test/oldgears/.gitignore
new file mode 100644
index 0000000..563e9d6
--- /dev/null
+++ b/tools/jackpotc/test/oldgears/.gitignore
@@ -0,0 +1,4 @@
+build
+gensrc
+dist
+nbproject/private
diff --git a/www/index.html b/www/index.html
index 475bb87..202e4de 100644
--- a/www/index.html
+++ b/www/index.html
@@ -28,7 +28,8 @@
                 <div id="sidebar">
                     <h3>Useful Links</h3>
                     <ul>
-                        <li><a href="../../deployment/jogamp-next/javadoc/jogl/javadoc/">JOGL JavaDoc</a></li>
+                        <li><a href="../../">Builds / Downloads</a></li>
+                        <li><a href="../../deployment/jogamp-next/javadoc/jogl/javadoc/">JavaDoc</a></li>
                         <li><a href="../../wiki/index.php/Jogl_Overview">Project Overview</a></li>
                         <li><a href="../doc/HowToBuild.html">Building JOGL</a></li>
                         <li><a href="../doc/deployment/JOGL-DEPLOYMENT.html">Deploying JOGL</a></li>
@@ -45,8 +46,14 @@
                     </ul>
                     <h3>Presentations</h3>
                     <ul>
+                        <li><a href="../../doc/gpunurbs2011/graphicon2011-slides.pdf">NURBS @ GPU</a></li>
+                        <li><a href="../../doc/siggraph2011/jogamp-siggraph2011.pdf">Siggraph 2011</a></li>
                         <li><a href="../../doc/siggraph2010/jogamp-siggraph2010.pdf">Siggraph 2010</a></li>
                     </ul>
+                    <h3>Papers</h3>
+                    <ul>
+                        <li><a href="../../doc/gpunurbs2011/p70-santina.pdf">NURBS @ GPU</a></li>
+                    </ul>
                     <h3>Archive</h3>
                     <ul>
                         <li><a href="BOF-3908-JOGL-slides.pdf"> JavaOne 2007 BOF Slides</a></li>
@@ -69,11 +76,11 @@
                         as well as nearly all vendor extensions.
                         <a href="../doc/Overview-OpenGL-Evolution-And-JOGL.html">OpenGL Evolution & JOGL</a>
                         (<a href="../doc/bouml/html-svg/fig128069.svg">UML</a>) gives you a brief overview of OpenGL, 
-                        it's profiles and how we map them to JOGL.
+                        its profiles and how we map them to JOGL.
                     </p>
                     <p>
                         JOGL integrates with the AWT and Swing widget sets, as well with custom windowing toolkits using the NativeWindow API.
-                        <a href="../doc/NEWT-Overview.html">JOGL also provides it's own native windowing toolkit, NEWT</a>.
+                        <a href="../doc/NEWT-Overview.html">JOGL also provides its own native windowing toolkit, NEWT</a>.
                     </p>
                     <p>
                     Quick Version Info: Current [ <a href="../../deployment/jogamp-current/jogl-applet-version.html">Applet</a>, 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libjogl2-java.git



More information about the pkg-java-commits mailing list