diff options
author | Sven Gothel <[email protected]> | 2010-10-06 16:04:06 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-10-06 16:04:06 +0200 |
commit | 018c7e8660dc0af68bd129be9af5094d04d0b431 (patch) | |
tree | ac17156a48167f4a28e129adfc78b7c746aa6744 /src | |
parent | 03416ffe040d50b96573930104a78933605ae40d (diff) |
NativeWindow/NativeSurface Refactoring ; Added mouseClick NEWT/AWT unit test
NativeWindow/NativeSurface Refactoring
- Using NativeSurface interface
- NativeWindow extends NativeSurface, adds getLocationOnScreen(Point)
- NativeWindow add: getParent()
- NativeWindow/Surface: Removed 'invalidate()', use 'destroy()' if you must.
- NullWindow -> ProxySurface impl NativeSurface
- JOGL: Uses NativeSurface only.
- GLDrawable.getNativeWindow() -> GLDrawable.getNativeSurface()
Added mouseClick NEWT/AWT unit test
JOGL:
- GLAnimatorControl add: resetCounter()
-
NEWT:
- GLWindow counters: return GLWindow counters always
- WindowImpl
- requestFocus() wait until done
- reparent: readded requestFocusImpl(true),
native impl skips java focusAction if reparented
- X11Window: Add XRaiseWindow() in requestFocus()
Diffstat (limited to 'src')
89 files changed, 1100 insertions, 699 deletions
diff --git a/src/jogl/classes/com/jogamp/audio/windows/waveout/TestSpatialization.java b/src/jogl/classes/com/jogamp/audio/windows/waveout/TestSpatialization.java index 78fb3493f..3d6de2b29 100644 --- a/src/jogl/classes/com/jogamp/audio/windows/waveout/TestSpatialization.java +++ b/src/jogl/classes/com/jogamp/audio/windows/waveout/TestSpatialization.java @@ -33,7 +33,7 @@ package com.jogamp.audio.windows.waveout; import java.io.*; -import javax.media.nativewindow.NativeWindow; +import javax.media.nativewindow.NativeSurface; import javax.media.opengl.GLDrawableFactory; public class TestSpatialization { @@ -46,7 +46,7 @@ public class TestSpatialization { try { // FIXME: this is a hack to get the native library loaded try { - GLDrawableFactory.getFactory(NativeWindow.class); + GLDrawableFactory.getFactory(NativeSurface.class); } catch (Exception e) {} // Initialize the audio subsystem Audio audio = Audio.getInstance(); diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java index c19871560..219d9f4dd 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -204,7 +205,7 @@ public abstract class GLContextImpl extends GLContext { if (contextHandle != 0) { int lockRes = drawable.lockSurface(); - if (NativeWindow.LOCK_SURFACE_NOT_READY == lockRes) { + if (NativeSurface.LOCK_SURFACE_NOT_READY == lockRes) { // this would be odd .. throw new GLException("Surface not ready to lock: "+drawable); } @@ -231,7 +232,7 @@ public abstract class GLContextImpl extends GLContext { } int lockRes = drawable.lockSurface(); - if (NativeWindow.LOCK_SURFACE_NOT_READY == lockRes) { + if (NativeSurface.LOCK_SURFACE_NOT_READY == lockRes) { // this would be odd .. throw new GLException("Surface not ready to lock"); } @@ -351,11 +352,11 @@ public abstract class GLContextImpl extends GLContext { boolean exceptionOccurred = false; int lockRes = drawable.lockSurface(); try { - if (NativeWindow.LOCK_SURFACE_NOT_READY == lockRes) { + if (NativeSurface.LOCK_SURFACE_NOT_READY == lockRes) { return CONTEXT_NOT_CURRENT; } try { - if (NativeWindow.LOCK_SURFACE_CHANGED == lockRes) { + if (NativeSurface.LOCK_SURFACE_CHANGED == lockRes) { drawable.updateHandle(); } if (0 == drawable.getHandle()) { @@ -452,7 +453,7 @@ public abstract class GLContextImpl extends GLContext { protected final long createContextARB(long share, boolean direct, int major[], int minor[], int ctp[]) { - AbstractGraphicsConfiguration config = drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); GLCapabilities glCaps = (GLCapabilities) config.getChosenCapabilities(); GLProfile glp = glCaps.getGLProfile(); diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java index cd1422652..6cf326949 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -60,9 +61,9 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { public abstract GLDynamicLookupHelper getGLDynamicLookupHelper(int profile); //--------------------------------------------------------------------------- - // Dispatching GLDrawable construction in respect to the NativeWindow Capabilities + // Dispatching GLDrawable construction in respect to the NativeSurface Capabilities // - public GLDrawable createGLDrawable(NativeWindow target) { + public GLDrawable createGLDrawable(NativeSurface target) { if (target == null) { throw new IllegalArgumentException("Null target"); } @@ -76,7 +77,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { result = createOnscreenDrawable(target); } else { if( ! ( target instanceof SurfaceChangeable ) ) { - throw new IllegalArgumentException("Passed NativeWindow must implement SurfaceChangeable for offscreen: "+target); + throw new IllegalArgumentException("Passed NativeSurface must implement SurfaceChangeable for offscreen: "+target); } if(caps.isPBuffer()) { if(DEBUG) { @@ -102,7 +103,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { // Onscreen GLDrawable construction // - protected abstract GLDrawableImpl createOnscreenDrawable(NativeWindow target); + protected abstract GLDrawableImpl createOnscreenDrawable(NativeSurface target); //--------------------------------------------------------------------------- // @@ -110,9 +111,9 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { // /** Target must implement SurfaceChangeable */ - protected abstract GLDrawableImpl createGLPbufferDrawableImpl(NativeWindow target); + protected abstract GLDrawableImpl createGLPbufferDrawableImpl(NativeSurface target); - protected GLDrawableImpl createGLPbufferDrawable(NativeWindow target) { + protected GLDrawableImpl createGLPbufferDrawable(NativeSurface target) { if (!canCreateGLPbuffer(target.getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice())) { throw new GLException("Pbuffer support not available with current graphics card"); } @@ -130,7 +131,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { capabilities.setDoubleBuffered(false); // FIXME DBLBUFOFFSCRN capabilities.setOnscreen(false); capabilities.setPBuffer(true); - return createGLPbufferDrawable( createOffscreenWindow(capabilities, chooser, height, height) ); + return createGLPbufferDrawable( createOffscreenSurface(capabilities, chooser, height, height) ); } public GLPbuffer createGLPbuffer(GLCapabilities capabilities, @@ -148,7 +149,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { // Offscreen GLDrawable construction // - protected abstract GLDrawableImpl createOffscreenDrawable(NativeWindow target) ; + protected abstract GLDrawableImpl createOffscreenDrawable(NativeSurface target) ; public GLDrawable createOffscreenDrawable(GLCapabilities capabilities, GLCapabilitiesChooser chooser, @@ -161,14 +162,14 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { capabilities.setDoubleBuffered(false); // FIXME DBLBUFOFFSCRN capabilities.setOnscreen(false); capabilities.setPBuffer(false); - return createOffscreenDrawable( createOffscreenWindow(capabilities, chooser, width, height) ); + return createOffscreenDrawable( createOffscreenSurface(capabilities, chooser, width, height) ); } /** - * creates an offscreen NativeWindow, which must implement SurfaceChangeable as well, + * creates an offscreen NativeSurface, which must implement SurfaceChangeable as well, * so the windowing system related implementation is able to set the surface handle. */ - protected abstract NativeWindow createOffscreenWindow(GLCapabilities capabilities, GLCapabilitiesChooser chooser, + protected abstract NativeSurface createOffscreenSurface(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height); protected abstract GLDrawableImpl getSharedDrawable(); diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java index 1270a4545..19e637cab 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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,12 +47,12 @@ public abstract class GLDrawableImpl implements GLDrawable { protected static final boolean DEBUG = Debug.debug("GLDrawable"); protected GLDrawableImpl(GLDrawableFactory factory, - NativeWindow comp, + NativeSurface comp, boolean realized) { this.factory = factory; - this.component = comp; + this.surface = comp; this.realized = realized; - this.requestedCapabilities = (GLCapabilities)component.getGraphicsConfiguration().getNativeGraphicsConfiguration().getRequestedCapabilities(); // a copy .. + this.requestedCapabilities = (GLCapabilities)surface.getGraphicsConfiguration().getNativeGraphicsConfiguration().getRequestedCapabilities(); // a copy .. } /** @@ -70,16 +71,16 @@ public abstract class GLDrawableImpl implements GLDrawable { } public final void swapBuffers() throws GLException { - GLCapabilities caps = (GLCapabilities)component.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); + GLCapabilities caps = (GLCapabilities)surface.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); if ( caps.getDoubleBuffered() ) { - if(!component.surfaceSwap()) { + if(!surface.surfaceSwap()) { int lockRes = lockSurface(); // it's recursive, so it's ok within [makeCurrent .. release] - if (NativeWindow.LOCK_SURFACE_NOT_READY == lockRes) { + if (NativeSurface.LOCK_SURFACE_NOT_READY == lockRes) { return; } try { - AbstractGraphicsDevice aDevice = getNativeWindow().getGraphicsConfiguration().getScreen().getDevice(); - if (NativeWindow.LOCK_SURFACE_CHANGED == lockRes) { + AbstractGraphicsDevice aDevice = getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); + if (NativeSurface.LOCK_SURFACE_CHANGED == lockRes) { updateHandle(); } swapBuffersImpl(); @@ -93,7 +94,7 @@ public abstract class GLDrawableImpl implements GLDrawable { ctx.getGL().glFinish(); } } - component.surfaceUpdated(this, component, System.currentTimeMillis()); + surface.surfaceUpdated(this, surface, System.currentTimeMillis()); } protected abstract void swapBuffersImpl(); @@ -106,22 +107,22 @@ public abstract class GLDrawableImpl implements GLDrawable { } public GLCapabilities getChosenGLCapabilities() { - return (GLCapabilities)component.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); // a copy + return (GLCapabilities)surface.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); // a copy } public GLCapabilities getRequestedGLCapabilities() { return requestedCapabilities; } - public NativeWindow getNativeWindow() { - return component; + public NativeSurface getNativeSurface() { + return surface; } protected void destroyHandle() {} protected void updateHandle() {} public long getHandle() { - return component.getSurfaceHandle(); + return surface.getSurfaceHandle(); } public GLDrawableFactory getFactory() { @@ -134,11 +135,11 @@ public abstract class GLDrawableImpl implements GLDrawable { System.err.println("setRealized: "+getClass().getName()+" "+this.realized+" -> "+realized); } this.realized = realized; - if(realized && NativeWindow.LOCK_SURFACE_NOT_READY == lockSurface()) { + if(realized && NativeSurface.LOCK_SURFACE_NOT_READY == lockSurface()) { throw new GLException("X11GLXDrawable.setRealized(true): lockSurface - surface not ready"); } try { - AbstractGraphicsDevice aDevice = getNativeWindow().getGraphicsConfiguration().getScreen().getDevice(); + AbstractGraphicsDevice aDevice = getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); if(!realized) { destroyHandle(); } @@ -161,39 +162,38 @@ public abstract class GLDrawableImpl implements GLDrawable { } public int getWidth() { - return component.getWidth(); + return surface.getWidth(); } - - /** Returns the current height of this GLDrawable. */ + public int getHeight() { - return component.getHeight(); + return surface.getHeight(); } public int lockSurface() throws GLException { - return component.lockSurface(); + return surface.lockSurface(); } public void unlockSurface() { - component.unlockSurface(); + surface.unlockSurface(); } public boolean isSurfaceLocked() { - return component.isSurfaceLocked(); + return surface.isSurfaceLocked(); } public String toString() { return getClass().getName()+"[Realized "+isRealized()+ ",\n\tFactory "+getFactory()+ ",\n\thandle "+toHexString(getHandle())+ - ",\n\tWindow "+getNativeWindow()+"]"; + ",\n\tWindow "+getNativeSurface()+"]"; } protected GLDrawableFactory factory; - protected NativeWindow component; + protected NativeSurface surface; protected GLCapabilities requestedCapabilities; - // Indicates whether the component (if an onscreen context) has been - // realized. Plausibly, before the component is realized the JAWT + // Indicates whether the surface (if an onscreen context) has been + // realized. Plausibly, before the surface is realized the JAWT // should return an error or NULL object from some of its // operations; this appears to be the case on Win32 but is not true // at least with Sun's current X11 implementation (1.4.x), which @@ -201,7 +201,7 @@ public abstract class GLDrawableImpl implements GLDrawable { // fetched from a locked DrawingSurface during the validation as a // result of calling show() on the main thread. To work around this // we prevent any JAWT or OpenGL operations from being done until - // addNotify() is called on the component. + // addNotify() is called on the surface. protected boolean realized; } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java index dcfb2e3f5..9f113f337 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -64,7 +65,7 @@ public class GLPbufferImpl implements GLPbuffer { public GLPbufferImpl(GLDrawableImpl pbufferDrawable, GLContext parentContext) { GLCapabilities caps = (GLCapabilities) - pbufferDrawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); + pbufferDrawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); if(caps.isOnscreen()) { if(caps.isPBuffer()) { throw new IllegalArgumentException("Error: Given drawable is Onscreen and Pbuffer: "+pbufferDrawable); @@ -96,8 +97,8 @@ public class GLPbufferImpl implements GLPbuffer { throw new GLException("Not yet implemented"); } - public NativeWindow getNativeWindow() { - return pbufferDrawable.getNativeWindow(); + public NativeSurface getNativeSurface() { + return pbufferDrawable.getNativeSurface(); } public long getHandle() { @@ -219,7 +220,7 @@ public class GLPbufferImpl implements GLPbuffer { public int lockSurface() throws GLException { recurLock.lock(); - return NativeWindow.LOCK_SUCCESS; + return NativeSurface.LOCK_SUCCESS; } public void unlockSurface() { diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java index 7eeb19141..f9fcdb29c 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.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 @@ -50,7 +51,7 @@ public abstract class EGLDrawable extends GLDrawableImpl { protected long eglSurface; protected EGLDrawable(EGLDrawableFactory factory, - NativeWindow component) throws GLException { + NativeSurface component) throws GLException { super(factory, component, false); eglSurface=EGL.EGL_NO_SURFACE; eglDisplay=0; @@ -86,19 +87,19 @@ public abstract class EGLDrawable extends GLDrawableImpl { System.err.println("createSurface using eglDisplay 0x"+Long.toHexString(eglDisplay)+", "+eglConfig); } - eglSurface = createSurface(eglDisplay, eglConfig.getNativeConfig(), component.getSurfaceHandle()); + eglSurface = createSurface(eglDisplay, eglConfig.getNativeConfig(), surface.getSurfaceHandle()); if (EGL.EGL_NO_SURFACE==eglSurface) { throw new GLException("Creation of window surface failed: "+eglConfig+", error 0x"+Integer.toHexString(EGL.eglGetError())); } if(DEBUG) { - System.err.println("setSurface using component: handle 0x"+Long.toHexString(component.getSurfaceHandle())+" -> 0x"+Long.toHexString(eglSurface)); + System.err.println("setSurface using component: handle 0x"+Long.toHexString(surface.getSurfaceHandle())+" -> 0x"+Long.toHexString(eglSurface)); } } protected void setRealizedImpl() { if (realized) { - AbstractGraphicsConfiguration aConfig = component.getGraphicsConfiguration().getNativeGraphicsConfiguration(); + AbstractGraphicsConfiguration aConfig = surface.getGraphicsConfiguration().getNativeGraphicsConfiguration(); AbstractGraphicsDevice aDevice = aConfig.getScreen().getDevice(); if(aDevice instanceof EGLGraphicsDevice) { if(DEBUG) { @@ -116,10 +117,10 @@ public abstract class EGLDrawable extends GLDrawableImpl { } int[] tmp = new int[1]; - if ( 0 != component.getSurfaceHandle() && - EGL.eglQuerySurface(eglDisplay, component.getSurfaceHandle(), EGL.EGL_CONFIG_ID, tmp, 0) ) { - // component holds static EGLSurface - eglSurface = component.getSurfaceHandle(); + if ( 0 != surface.getSurfaceHandle() && + EGL.eglQuerySurface(eglDisplay, surface.getSurfaceHandle(), EGL.EGL_CONFIG_ID, tmp, 0) ) { + // surface holds static EGLSurface + eglSurface = surface.getSurfaceHandle(); if(DEBUG) { System.err.println("setSurface re-using component's EGLSurface: handle 0x"+Long.toHexString(eglSurface)); } @@ -145,7 +146,7 @@ public abstract class EGLDrawable extends GLDrawableImpl { long nDisplay=0; if( NativeWindowFactory.TYPE_WINDOWS.equals(NativeWindowFactory.getNativeWindowType(false)) ) { - nDisplay = component.getSurfaceHandle(); // don't even ask .. + nDisplay = surface.getSurfaceHandle(); // don't even ask .. } else { nDisplay = aDevice.getHandle(); // 0 == EGL.EGL_DEFAULT_DISPLAY } @@ -219,7 +220,7 @@ public abstract class EGLDrawable extends GLDrawableImpl { public String toString() { return getClass().getName()+"[realized "+isRealized()+ ",\n\tfactory "+getFactory()+ - ",\n\twindow "+getNativeWindow()+ + ",\n\tsurface "+getNativeSurface()+ ",\n\teglSurface 0x"+Long.toHexString(eglSurface)+ ",\n\teglConfig "+eglConfig+ ",\n\trequested "+getRequestedGLCapabilities()+ diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java index 72498a7af..b1084dd8f 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.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 @@ -40,7 +41,7 @@ import javax.media.opengl.*; import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.util.*; import com.jogamp.opengl.impl.*; -import com.jogamp.nativewindow.impl.NullWindow; +import com.jogamp.nativewindow.impl.ProxySurface; public class EGLDrawableFactory extends GLDrawableFactoryImpl { @@ -114,14 +115,14 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { protected final GLDrawableImpl getSharedDrawable() { return null; } protected final GLContextImpl getSharedContext() { return null; } - public GLDrawableImpl createOnscreenDrawable(NativeWindow target) { + public GLDrawableImpl createOnscreenDrawable(NativeSurface target) { if (target == null) { throw new IllegalArgumentException("Null target"); } return new EGLOnscreenDrawable(this, target); } - protected GLDrawableImpl createOffscreenDrawable(NativeWindow target) { + protected GLDrawableImpl createOffscreenDrawable(NativeSurface target) { throw new GLException("Not yet implemented"); } @@ -129,14 +130,14 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { return true; } - protected GLDrawableImpl createGLPbufferDrawableImpl(NativeWindow target) { + protected GLDrawableImpl createGLPbufferDrawableImpl(NativeSurface target) { return new EGLPbufferDrawable(this, target); } - protected NativeWindow createOffscreenWindow(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) { - NullWindow nw = new NullWindow(EGLGraphicsConfigurationFactory.createOffscreenGraphicsConfiguration(capabilities, chooser)); - nw.setSize(width, height); - return nw; + protected NativeSurface createOffscreenSurface(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) { + ProxySurface ns = new ProxySurface(EGLGraphicsConfigurationFactory.createOffscreenGraphicsConfiguration(capabilities, chooser)); + ns.setSize(width, height); + return ns; } public GLContext createExternalGLContext() { diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLOnscreenDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLOnscreenDrawable.java index 551a21ed6..820ac04e9 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLOnscreenDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLOnscreenDrawable.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -41,12 +42,9 @@ package com.jogamp.opengl.impl.egl; import javax.media.opengl.*; import javax.media.nativewindow.*; -import javax.media.nativewindow.egl.*; -import com.jogamp.opengl.impl.*; -import com.jogamp.nativewindow.impl.NullWindow; public class EGLOnscreenDrawable extends EGLDrawable { - protected EGLOnscreenDrawable(EGLDrawableFactory factory, NativeWindow component) throws GLException { + protected EGLOnscreenDrawable(EGLDrawableFactory factory, NativeSurface component) throws GLException { super(factory, component); } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLPbufferDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLPbufferDrawable.java index 03b02b77e..5b7509c43 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLPbufferDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLPbufferDrawable.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -48,12 +49,12 @@ public class EGLPbufferDrawable extends EGLDrawable { private int texFormat; protected static final boolean useTexture = false; // No yet .. - protected EGLPbufferDrawable(EGLDrawableFactory factory, NativeWindow target) { + protected EGLPbufferDrawable(EGLDrawableFactory factory, NativeSurface target) { super(factory, target); ownEGLDisplay = true; // get choosen ones .. - GLCapabilities caps = (GLCapabilities) getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); + GLCapabilities caps = (GLCapabilities) getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); if(useTexture) { this.texFormat = caps.getAlphaBits() > 0 ? EGL.EGL_TEXTURE_RGBA : EGL.EGL_TEXTURE_RGB ; @@ -62,7 +63,7 @@ public class EGLPbufferDrawable extends EGLDrawable { } if (DEBUG) { - System.out.println("Pbuffer config: " + getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration()); + System.out.println("Pbuffer config: " + getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration()); } setRealized(true); @@ -74,7 +75,7 @@ public class EGLPbufferDrawable extends EGLDrawable { } protected long createSurface(long eglDpy, long eglNativeCfg, long surfaceHandle) { - NativeWindow nw = getNativeWindow(); + NativeSurface nw = getNativeSurface(); int[] attrs = EGLGraphicsConfiguration.CreatePBufferSurfaceAttribList(nw.getWidth(), nw.getHeight(), texFormat); long surf = EGL.eglCreatePbufferSurface(eglDpy, eglNativeCfg, attrs, 0); if (EGL.EGL_NO_SURFACE==surf) { diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java index 46b86a557..1bb07cf9c 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -114,7 +115,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl throw new GLException("GLContextShareSet returned a NULL OpenGL context"); } } - MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); GLCapabilities capabilitiesRequested = (GLCapabilities)config.getRequestedCapabilities(); GLProfile glProfile = capabilitiesRequested.getGLProfile(); if(glProfile.isGL3()) { @@ -242,7 +243,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl } protected void swapBuffers() { - DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); GLCapabilities caps = (GLCapabilities)config.getChosenCapabilities(); if(caps.isOnscreen()) { if(isNSContext) { diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java index 23fdcbf6d..1eeaa55e1 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -77,7 +78,7 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { public static final int NSOPENGL_MODE = 1; public static final int CGL_MODE = 2; - public MacOSXCGLDrawable(GLDrawableFactory factory, NativeWindow comp, boolean realized) { + public MacOSXCGLDrawable(GLDrawableFactory factory, NativeSurface comp, boolean realized) { super(factory, comp, realized); } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java index 9694e5607..396d6aefc 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -45,7 +46,7 @@ import javax.media.opengl.*; import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.util.*; import com.jogamp.opengl.impl.*; -import com.jogamp.nativewindow.impl.NullWindow; +import com.jogamp.nativewindow.impl.ProxySurface; public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { private static final DesktopGLDynamicLookupHelper macOSXCGLDynamicLookupHelper; @@ -87,14 +88,14 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { protected final GLDrawableImpl getSharedDrawable() { return null; } protected final GLContextImpl getSharedContext() { return null; } - public GLDrawableImpl createOnscreenDrawable(NativeWindow target) { + public GLDrawableImpl createOnscreenDrawable(NativeSurface target) { if (target == null) { throw new IllegalArgumentException("Null target"); } return new MacOSXOnscreenCGLDrawable(this, target); } - protected GLDrawableImpl createOffscreenDrawable(NativeWindow target) { + protected GLDrawableImpl createOffscreenDrawable(NativeSurface target) { return new MacOSXOffscreenCGLDrawable(this, target); } @@ -102,7 +103,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { return true; } - protected GLDrawableImpl createGLPbufferDrawableImpl(final NativeWindow target) { + protected GLDrawableImpl createGLPbufferDrawableImpl(final NativeSurface target) { /** * FIXME: Think about this .. * should not be necessary ? .. @@ -119,11 +120,11 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { return new MacOSXPbufferCGLDrawable(this, target); } - protected NativeWindow createOffscreenWindow(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) { + protected NativeSurface createOffscreenSurface(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) { AbstractGraphicsScreen screen = DefaultGraphicsScreen.createDefault(); - NullWindow nw = new NullWindow(MacOSXCGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capabilities, chooser, screen, true)); - nw.setSize(width, height); - return nw; + ProxySurface ns = new ProxySurface(MacOSXCGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capabilities, chooser, screen, true)); + ns.setSize(width, height); + return ns; } public GLContext createExternalGLContext() { diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java index 889d1c333..d2be9d0de 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfiguration.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 @@ -148,7 +149,7 @@ public class MacOSXCGLGraphicsConfiguration extends DefaultGraphicsConfiguration // On this platform the pixel format is associated with the // context and not the drawable. However it's a reasonable // approximation to just store the chosen pixel format up in the - // NativeWindow's AbstractGraphicsConfiguration, + // NativeSurface's AbstractGraphicsConfiguration, // since the public API doesn't provide for a different GLCapabilities per context. // Note: These restrictions of the platform's API might be considered as a bug anyways. diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java index e8518925a..973c67127 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.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 @@ -43,7 +44,7 @@ import javax.media.opengl.*; import com.jogamp.opengl.impl.*; import javax.media.nativewindow.*; -import com.jogamp.nativewindow.impl.NullWindow; +import com.jogamp.nativewindow.impl.ProxySurface; public class MacOSXExternalCGLContext extends MacOSXCGLContext { private boolean firstMakeCurrent = true; @@ -99,9 +100,9 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext { AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault(); MacOSXCGLGraphicsConfiguration cfg = new MacOSXCGLGraphicsConfiguration(aScreen, caps, caps, pixelFormat); - NullWindow nw = new NullWindow(cfg); - nw.setSurfaceHandle(currentDrawable); - return new MacOSXExternalCGLContext(new Drawable(factory, nw), isNSContext, contextHandle); + ProxySurface ns = new ProxySurface(cfg); + ns.setSurfaceHandle(currentDrawable); + return new MacOSXExternalCGLContext(new Drawable(factory, ns), isNSContext, contextHandle); } protected boolean createImpl() throws GLException { @@ -150,7 +151,7 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext { static class Drawable extends MacOSXCGLDrawable { MacOSXExternalCGLContext extCtx; - Drawable(GLDrawableFactory factory, NativeWindow comp) { + Drawable(GLDrawableFactory factory, NativeSurface comp) { super(factory, comp, true); } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOffscreenCGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOffscreenCGLDrawable.java index adaa48f34..f87c89f2d 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOffscreenCGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOffscreenCGLDrawable.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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,7 +47,7 @@ import com.jogamp.opengl.impl.*; public class MacOSXOffscreenCGLDrawable extends MacOSXPbufferCGLDrawable { public MacOSXOffscreenCGLDrawable(GLDrawableFactory factory, - NativeWindow target) { + NativeSurface target) { super(factory, target); } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java index 6ee023867..798e39ef4 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -51,7 +52,7 @@ public class MacOSXOnscreenCGLDrawable extends MacOSXCGLDrawable { private List/*<WeakReference<GLContext>>*/ createdContexts = new ArrayList(); - protected MacOSXOnscreenCGLDrawable(GLDrawableFactory factory, NativeWindow component) { + protected MacOSXOnscreenCGLDrawable(GLDrawableFactory factory, NativeSurface component) { super(factory, component, false); } @@ -70,14 +71,6 @@ public class MacOSXOnscreenCGLDrawable extends MacOSXCGLDrawable { return context; } - public int getWidth() { - return component.getWidth(); - } - - public int getHeight() { - return component.getHeight(); - } - protected void swapBuffersImpl() { for (Iterator iter = createdContexts.iterator(); iter.hasNext(); ) { WeakReference ref = (WeakReference) iter.next(); diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java index 3964c9771..5cf8c6eb9 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java @@ -1,3 +1,36 @@ +/* + * Copyright (c) 2003 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 + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution 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. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ + package com.jogamp.opengl.impl.macosx.cgl; import com.jogamp.common.nio.PointerBuffer; @@ -53,7 +86,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext { if (newCreated) { // Initialize render-to-texture support if requested - DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities(); GL gl = getGL(); boolean rect = gl.isGL2GL3() && capabilities.getPbufferRenderToTextureRectangle(); @@ -102,7 +135,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext { } protected boolean createImpl() throws GLException { - DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities(); if (capabilities.getPbufferFloatingPointBuffers() && !isTigerOrLater) { @@ -190,7 +223,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext { class NSOpenGLImpl implements Impl { public boolean isNSContext() { return true; } public long create() { - DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities(); if (capabilities.getPbufferFloatingPointBuffers() && !isTigerOrLater) { @@ -254,7 +287,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext { int[] attrs = new int[256]; int i = 0; attrs[i++] = CGL.kCGLPFAPBuffer; - DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities(); if (capabilities.getPbufferFloatingPointBuffers()) attrs[i++] = CGL.kCGLPFAColorFloat; diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java index 64d646cfb..bc470383f 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -53,15 +54,15 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { // 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 NativeWindow because the + // Note that we can not store this in the NativeSurface because the // semantic is that contains an NSView protected long pBuffer; - public MacOSXPbufferCGLDrawable(GLDrawableFactory factory, NativeWindow target) { + public MacOSXPbufferCGLDrawable(GLDrawableFactory factory, NativeSurface target) { super(factory, target, true); if (DEBUG) { - System.out.println("Pbuffer config: " + getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration()); + System.out.println("Pbuffer config: " + getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration()); } initOpenGLImpl(); @@ -86,10 +87,10 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { public void destroy() { if (this.pBuffer != 0) { - NativeWindow nw = getNativeWindow(); + NativeSurface ns = getNativeSurface(); impl.destroy(pBuffer); this.pBuffer = 0; - ((SurfaceChangeable)nw).setSurfaceHandle(0); + ((SurfaceChangeable)ns).setSurfaceHandle(0); if (DEBUG) { System.err.println("Destroyed pbuffer: " + pBuffer); } @@ -107,8 +108,8 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { } private void createPbuffer() { - NativeWindow nw = getNativeWindow(); - DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) nw.getGraphicsConfiguration().getNativeGraphicsConfiguration(); + NativeSurface ns = getNativeSurface(); + DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) ns.getGraphicsConfiguration().getNativeGraphicsConfiguration(); GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities(); GLProfile glProfile = capabilities.getGLProfile(); int renderTarget; @@ -117,7 +118,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { } else { int w = getNextPowerOf2(getWidth()); int h = getNextPowerOf2(getHeight()); - ((SurfaceChangeable)nw).setSize(w, h); + ((SurfaceChangeable)ns).setSize(w, h); renderTarget = GL.GL_TEXTURE_2D; } @@ -148,7 +149,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { throw new GLException("pbuffer creation error: CGL.createPBuffer() failed"); } - ((SurfaceChangeable)nw).setSurfaceHandle(pBuffer); + ((SurfaceChangeable)ns).setSurfaceHandle(pBuffer); } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java index 5e3d55b04..299adec50 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -41,22 +42,22 @@ package com.jogamp.opengl.impl.windows.wgl; import javax.media.opengl.*; import com.jogamp.opengl.impl.*; -import com.jogamp.nativewindow.impl.NullWindow; +import com.jogamp.nativewindow.impl.ProxySurface; public class WindowsDummyWGLDrawable extends WindowsWGLDrawable { private long hwnd, hdc; public WindowsDummyWGLDrawable(GLDrawableFactory factory, GLProfile glp) { - super(factory, new NullWindow(WindowsWGLGraphicsConfigurationFactory.createDefaultGraphicsConfiguration(glp, null, true, true)), true); + super(factory, new ProxySurface(WindowsWGLGraphicsConfigurationFactory.createDefaultGraphicsConfiguration(glp, null, true, true)), true); // All entries to CreateDummyWindow must synchronize on one object // to avoid accidentally registering the dummy window class twice synchronized (WindowsDummyWGLDrawable.class) { hwnd = GDI.CreateDummyWindow(0, 0, 1, 1); } hdc = GDI.GetDC(hwnd); - NullWindow nw = (NullWindow) getNativeWindow(); - nw.setSurfaceHandle(hdc); - WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)nw.getGraphicsConfiguration().getNativeGraphicsConfiguration(); + ProxySurface ns = (ProxySurface) getNativeSurface(); + ns.setSurfaceHandle(hdc); + WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration().getNativeGraphicsConfiguration(); // Choose a (hopefully hardware-accelerated) OpenGL pixel format for this device context GLCapabilities caps = (GLCapabilities) config.getChosenCapabilities(); caps.setDepthBits(16); diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java index 1f1fb0d40..9917ea901 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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,7 @@ package com.jogamp.opengl.impl.windows.wgl; import javax.media.opengl.*; import javax.media.nativewindow.*; import com.jogamp.opengl.impl.*; -import com.jogamp.nativewindow.impl.NullWindow; +import com.jogamp.nativewindow.impl.ProxySurface; public class WindowsExternalWGLContext extends WindowsWGLContext { private boolean firstMakeCurrent = true; @@ -77,10 +78,10 @@ public class WindowsExternalWGLContext extends WindowsWGLContext { AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault(); WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.create(hdc, pfdID, glp, aScreen, true, true); - NullWindow nw = new NullWindow(cfg); - nw.setSurfaceHandle(hdc); + ProxySurface ns = new ProxySurface(cfg); + ns.setSurfaceHandle(hdc); - return new WindowsExternalWGLContext(new Drawable(factory, nw), ctx, cfg); + return new WindowsExternalWGLContext(new Drawable(factory, ns), ctx, cfg); } public int makeCurrent() throws GLException { @@ -114,7 +115,7 @@ public class WindowsExternalWGLContext extends WindowsWGLContext { // Need to provide the display connection to extension querying APIs static class Drawable extends WindowsWGLDrawable { - Drawable(GLDrawableFactory factory, NativeWindow comp) { + Drawable(GLDrawableFactory factory, NativeSurface comp) { super(factory, comp, true); } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java index 41e469224..19fe8f03c 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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,11 +43,11 @@ package com.jogamp.opengl.impl.windows.wgl; import javax.media.nativewindow.*; import javax.media.opengl.*; import com.jogamp.opengl.impl.*; -import com.jogamp.nativewindow.impl.NullWindow; +import com.jogamp.nativewindow.impl.ProxySurface; public class WindowsExternalWGLDrawable extends WindowsWGLDrawable { - private WindowsExternalWGLDrawable(GLDrawableFactory factory, NativeWindow component) { + private WindowsExternalWGLDrawable(GLDrawableFactory factory, NativeSurface component) { super(factory, component, true); } @@ -63,12 +64,12 @@ public class WindowsExternalWGLDrawable extends WindowsWGLDrawable { AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault(); WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.create(hdc, pfdID, glp, aScreen, true, true); - NullWindow nw = new NullWindow(cfg); - nw.setSurfaceHandle(hdc); + ProxySurface ns = new ProxySurface(cfg); + ns.setSurfaceHandle(hdc); - cfg.updateGraphicsConfiguration(factory, nw); + cfg.updateGraphicsConfiguration(factory, ns); - return new WindowsExternalWGLDrawable(factory, nw); + return new WindowsExternalWGLDrawable(factory, ns); } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java index 8079cd42a..ea02a4919 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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,13 +43,12 @@ package com.jogamp.opengl.impl.windows.wgl; import javax.media.opengl.*; import javax.media.nativewindow.*; import com.jogamp.opengl.impl.*; -import com.jogamp.nativewindow.impl.NullWindow; public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable { private long origbitmap; private long hbitmap; - public WindowsOffscreenWGLDrawable(GLDrawableFactory factory, NativeWindow target) { + public WindowsOffscreenWGLDrawable(GLDrawableFactory factory, NativeSurface target) { super(factory, target, true); create(); } @@ -66,8 +66,8 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable { } private void create() { - NativeWindow nw = getNativeWindow(); - WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)nw.getGraphicsConfiguration().getNativeGraphicsConfiguration(); + NativeSurface ns = getNativeSurface(); + WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration().getNativeGraphicsConfiguration(); GLCapabilities capabilities = (GLCapabilities)config.getRequestedCapabilities(); int width = getWidth(); int height = getHeight(); @@ -97,7 +97,7 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable { System.out.println("LastError: " + GDI.GetLastError()); throw new GLException("Error creating device context for offscreen OpenGL context"); } - ((SurfaceChangeable)nw).setSurfaceHandle(hdc); + ((SurfaceChangeable)ns).setSurfaceHandle(hdc); hbitmap = GDI.CreateDIBSection(hdc, info, GDI.DIB_RGB_COLORS, null, 0, 0); if (hbitmap == 0) { @@ -114,19 +114,19 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable { throw new GLException("Error selecting bitmap into new device context"); } - config.updateGraphicsConfiguration(getFactory(), nw); + config.updateGraphicsConfiguration(getFactory(), ns); } public void destroy() { - NativeWindow nw = getNativeWindow(); - if (nw.getSurfaceHandle() != 0) { + NativeSurface ns = getNativeSurface(); + if (ns.getSurfaceHandle() != 0) { // Must destroy bitmap and device context - GDI.SelectObject(nw.getSurfaceHandle(), origbitmap); + GDI.SelectObject(ns.getSurfaceHandle(), origbitmap); GDI.DeleteObject(hbitmap); - GDI.DeleteDC(nw.getSurfaceHandle()); + GDI.DeleteDC(ns.getSurfaceHandle()); origbitmap = 0; hbitmap = 0; - ((SurfaceChangeable)nw).setSurfaceHandle(0); + ((SurfaceChangeable)ns).setSurfaceHandle(0); } } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java index 401b8c3c6..b0d62a4e1 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -44,7 +45,7 @@ import javax.media.opengl.*; import com.jogamp.opengl.impl.*; public class WindowsOnscreenWGLDrawable extends WindowsWGLDrawable { - protected WindowsOnscreenWGLDrawable(GLDrawableFactory factory, NativeWindow component) { + protected WindowsOnscreenWGLDrawable(GLDrawableFactory factory, NativeSurface component) { super(factory, component, false); } @@ -52,12 +53,4 @@ public class WindowsOnscreenWGLDrawable extends WindowsWGLDrawable { return new WindowsOnscreenWGLContext(this, shareWith); } - public int getWidth() { - return component.getWidth(); - } - - public int getHeight() { - return component.getHeight(); - } - } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java index c8c62914a..5708aa6bb 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -51,16 +52,16 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { private int floatMode; - public WindowsPbufferWGLDrawable(GLDrawableFactory factory, NativeWindow target, + public WindowsPbufferWGLDrawable(GLDrawableFactory factory, NativeSurface target, WindowsWGLDrawable dummyDrawable, WGLExt wglExt) { super(factory, target, true); if (DEBUG) { - System.out.println("Pbuffer config: " + getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration()); + System.out.println("Pbuffer config: " + getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration()); } - createPbuffer(dummyDrawable.getNativeWindow().getSurfaceHandle(), wglExt); + createPbuffer(dummyDrawable.getNativeSurface().getSurfaceHandle(), wglExt); if (DEBUG) { System.err.println("Created pbuffer " + this); @@ -80,18 +81,18 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { } public void destroy() { - NativeWindow nw = getNativeWindow(); + NativeSurface ns = getNativeSurface(); if(0!=buffer) { WGLExt wglExt = cachedWGLExt; - if (nw.getSurfaceHandle() != 0) { + if (ns.getSurfaceHandle() != 0) { // Must release DC and pbuffer // NOTE that since the context is not current, glGetError() can // not be called here, so we skip the use of any composable // pipelines (see WindowsOnscreenWGLContext.makeCurrentImpl) - if (wglExt.wglReleasePbufferDCARB(buffer, nw.getSurfaceHandle()) == 0) { + if (wglExt.wglReleasePbufferDCARB(buffer, ns.getSurfaceHandle()) == 0) { throw new GLException("Error releasing pbuffer device context: error code " + GDI.GetLastError()); } - ((SurfaceChangeable)nw).setSurfaceHandle(0); + ((SurfaceChangeable)ns).setSurfaceHandle(0); } if (!wglExt.wglDestroyPbufferARB(buffer)) { throw new GLException("Error destroying pbuffer: error code " + GDI.GetLastError()); @@ -102,7 +103,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { public long getPbufferHandle() { // The actual to-be-used handle for makeCurrent etc, - // is the derived DC, set in the NativeWindow surfaceHandle + // is the derived DC, set in the NativeSurface surfaceHandle // returned by getHandle(). return buffer; } @@ -124,7 +125,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { int niattribs = 0; int width, height; - WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); GLCapabilities capabilities = (GLCapabilities)config.getRequestedCapabilities(); GLProfile glProfile = capabilities.getGLProfile(); @@ -265,10 +266,10 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { throw new GLException("pbuffer creation error: wglGetPbufferDC() failed"); } - NativeWindow nw = getNativeWindow(); + NativeSurface ns = getNativeSurface(); // Set up instance variables buffer = tmpBuffer; - ((SurfaceChangeable)nw).setSurfaceHandle(tmpHdc); + ((SurfaceChangeable)ns).setSurfaceHandle(tmpHdc); cachedWGLExt = wglExt; cachedParentHdc = parentHdc; @@ -324,7 +325,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { width = tmp[0]; wglExt.wglQueryPbufferARB( buffer, WGLExt.WGL_PBUFFER_HEIGHT_ARB, tmp, 0 ); height = tmp[0]; - ((SurfaceChangeable)nw).setSize(width, height); + ((SurfaceChangeable)ns).setSize(width, height); } private static String wglGetLastError() { diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java index 33f1bc829..c80e46cc2 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -306,7 +307,7 @@ public class WindowsWGLContext extends GLContextImpl { if (newCreated) { WindowsWGLGraphicsConfiguration config = - (WindowsWGLGraphicsConfiguration)drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + (WindowsWGLGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); config.updateCapabilitiesByWGL(this); } } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawable.java index b1bc9b5ce..9fef457db 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawable.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -55,7 +56,7 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl { private long profilingSwapBuffersTime; - public WindowsWGLDrawable(GLDrawableFactory factory, NativeWindow comp, boolean realized) { + public WindowsWGLDrawable(GLDrawableFactory factory, NativeSurface comp, boolean realized) { super(factory, comp, realized); } @@ -64,9 +65,9 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl { return; // nothing todo .. } - NativeWindow nativeWindow = getNativeWindow(); - WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)nativeWindow.getGraphicsConfiguration().getNativeGraphicsConfiguration(); - config.updateGraphicsConfiguration(getFactory(), nativeWindow); + NativeSurface ns = getNativeSurface(); + WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration().getNativeGraphicsConfiguration(); + config.updateGraphicsConfiguration(getFactory(), ns); if (DEBUG) { System.err.println("!!! WindowsWGLDrawable.setRealized(true): "+config); } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java index 85444b61c..08cee4dab 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -47,7 +48,7 @@ import javax.media.opengl.*; import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.util.*; import com.jogamp.opengl.impl.*; -import com.jogamp.nativewindow.impl.NullWindow; +import com.jogamp.nativewindow.impl.ProxySurface; public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { private static final boolean VERBOSE = Debug.verbose(); @@ -134,14 +135,14 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { } } - public GLDrawableImpl createOnscreenDrawable(NativeWindow target) { + public GLDrawableImpl createOnscreenDrawable(NativeSurface target) { if (target == null) { throw new IllegalArgumentException("Null target"); } return new WindowsOnscreenWGLDrawable(this, target); } - protected GLDrawableImpl createOffscreenDrawable(NativeWindow target) { + protected GLDrawableImpl createOffscreenDrawable(NativeSurface target) { if (target == null) { throw new IllegalArgumentException("Null target"); } @@ -152,7 +153,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { return canCreateGLPbuffer; } - protected GLDrawableImpl createGLPbufferDrawableImpl(final NativeWindow target) { + protected GLDrawableImpl createGLPbufferDrawableImpl(final NativeSurface target) { if (target == null) { throw new IllegalArgumentException("Null target"); } @@ -185,12 +186,12 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { return (GLDrawableImpl) returnList.get(0); } - protected NativeWindow createOffscreenWindow(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) { + protected NativeSurface createOffscreenSurface(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) { AbstractGraphicsScreen screen = DefaultGraphicsScreen.createDefault(); - NullWindow nw = new NullWindow(WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( - capabilities, chooser, screen) ); - nw.setSize(width, height); - return nw; + ProxySurface ns = new ProxySurface(WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( + capabilities, chooser, screen) ); + ns.setSize(width, height); + return ns; } public GLContext createExternalGLContext() { diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java index eb5719566..8744b7a37 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.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 @@ -86,8 +87,8 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio } /** Update config - before having a valid context */ - protected void updateGraphicsConfiguration(GLDrawableFactory factory, NativeWindow nativeWindow) { - WindowsWGLGraphicsConfigurationFactory.updateGraphicsConfiguration(chooser, factory, nativeWindow); + protected void updateGraphicsConfiguration(GLDrawableFactory factory, NativeSurface ns) { + WindowsWGLGraphicsConfigurationFactory.updateGraphicsConfiguration(chooser, factory, ns); } /** Update config - after having a valid and current context */ @@ -101,8 +102,8 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio WGLExt wglExt = (WGLExt) context.getPlatformGLExtensions(); GLDrawable drawable = context.getGLDrawable(); - NativeWindow nativeWindow = drawable.getNativeWindow(); - long hdc = nativeWindow.getSurfaceHandle(); + NativeSurface ns = drawable.getNativeSurface(); + long hdc = ns.getSurfaceHandle(); GLCapabilities[] caps = HDC2GLCapabilities(wglExt, hdc, getPixelFormatID(), glp, true, onscreen, usePBuffer); if(null!=caps && null!=caps[0]) { diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java index e76e63f23..fd5a174c8 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.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 @@ -87,10 +88,10 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio } protected static void updateGraphicsConfiguration(CapabilitiesChooser chooser, - GLDrawableFactory _factory, NativeWindow nativeWindow) { + GLDrawableFactory _factory, NativeSurface ns) { WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory) _factory; - if (nativeWindow == null) { - throw new IllegalArgumentException("NativeWindow is null"); + if (ns == null) { + throw new IllegalArgumentException("NativeSurface is null"); } if (chooser != null && @@ -99,17 +100,17 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio } boolean choosenBywGLPixelFormat = false; - WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) nativeWindow.getGraphicsConfiguration().getNativeGraphicsConfiguration(); + WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) ns.getGraphicsConfiguration().getNativeGraphicsConfiguration(); GLCapabilities capabilities = (GLCapabilities) config.getRequestedCapabilities(); boolean onscreen = capabilities.isOnscreen(); boolean usePBuffer = capabilities.isPBuffer(); GLProfile glProfile = capabilities.getGLProfile(); - long hdc = nativeWindow.getSurfaceHandle(); + long hdc = ns.getSurfaceHandle(); if (DEBUG) { Exception ex = new Exception("WindowsWGLGraphicsConfigurationFactory got HDC "+toHexString(hdc)); ex.printStackTrace(); - System.err.println("WindowsWGLGraphicsConfigurationFactory got NW "+nativeWindow); + System.err.println("WindowsWGLGraphicsConfigurationFactory got NW "+ns); } PIXELFORMATDESCRIPTOR pfd = null; diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java index 475f413ba..690bc4b52 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java @@ -45,12 +45,12 @@ public class X11DummyGLXDrawable extends X11OnscreenGLXDrawable { */ public X11DummyGLXDrawable(X11GraphicsScreen screen, GLDrawableFactory factory, GLProfile glp) { super(factory, - new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( + new ProxySurface(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( new GLCapabilities(glp), null, screen))); this.realized = true; - NullWindow nw = (NullWindow) getNativeWindow(); - X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)nw.getGraphicsConfiguration().getNativeGraphicsConfiguration(); + ProxySurface ns = (ProxySurface) getNativeSurface(); + X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)ns.getGraphicsConfiguration().getNativeGraphicsConfiguration(); X11GraphicsDevice device = (X11GraphicsDevice) screen.getDevice(); long dpy = device.getHandle(); @@ -58,7 +58,7 @@ public class X11DummyGLXDrawable extends X11OnscreenGLXDrawable { long visualID = config.getVisualID(); dummyWindow = X11Lib.CreateDummyWindow(dpy, scrn, visualID); - nw.setSurfaceHandle( dummyWindow ); + ns.setSurfaceHandle( dummyWindow ); updateHandle(); } @@ -77,7 +77,7 @@ public class X11DummyGLXDrawable extends X11OnscreenGLXDrawable { public void destroy() { if(0!=dummyWindow) { destroyHandle(); - X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); X11Lib.DestroyDummyWindow(config.getScreen().getDevice().getHandle(), dummyWindow); } } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXContext.java index 550bde761..76f7f6591 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXContext.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -43,7 +44,7 @@ import javax.media.nativewindow.*; import javax.media.nativewindow.x11.*; import javax.media.opengl.*; import com.jogamp.opengl.impl.*; -import com.jogamp.nativewindow.impl.NullWindow; +import com.jogamp.nativewindow.impl.ProxySurface; public class X11ExternalGLXContext extends X11GLXContext { private boolean firstMakeCurrent = true; @@ -77,9 +78,9 @@ public class X11ExternalGLXContext extends X11GLXContext { GLX.glXQueryContext(display, ctx, GLX.GLX_FBCONFIG_ID, val, 0); X11GLXGraphicsConfiguration cfg = X11GLXGraphicsConfiguration.create(glp, x11Screen, val[0]); - NullWindow nw = new NullWindow(cfg); - nw.setSurfaceHandle(drawable); - return new X11ExternalGLXContext(new Drawable(factory, nw), ctx); + ProxySurface ns = new ProxySurface(cfg); + ns.setSurfaceHandle(drawable); + return new X11ExternalGLXContext(new Drawable(factory, ns), ctx); } protected boolean createImpl() { @@ -117,7 +118,7 @@ public class X11ExternalGLXContext extends X11GLXContext { // Need to provide the display connection to extension querying APIs static class Drawable extends X11GLXDrawable { - Drawable(GLDrawableFactory factory, NativeWindow comp) { + Drawable(GLDrawableFactory factory, NativeSurface comp) { super(factory, comp, true); } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXDrawable.java index d930179df..b83703ef1 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXDrawable.java @@ -42,13 +42,13 @@ package com.jogamp.opengl.impl.x11.glx; import javax.media.nativewindow.*; import javax.media.nativewindow.x11.*; import javax.media.opengl.*; -import com.jogamp.nativewindow.impl.NullWindow; +import com.jogamp.nativewindow.impl.ProxySurface; public class X11ExternalGLXDrawable extends X11GLXDrawable { - private X11ExternalGLXDrawable(GLDrawableFactory factory, NativeWindow component) { - super(factory, component, true); + private X11ExternalGLXDrawable(GLDrawableFactory factory, NativeSurface surface) { + super(factory, surface, true); } protected static X11ExternalGLXDrawable create(GLDrawableFactory factory, GLProfile glp) { @@ -83,10 +83,10 @@ public class X11ExternalGLXDrawable extends X11GLXDrawable { System.err.println("X11ExternalGLXDrawable: WARNING: forcing GLX_RGBA_TYPE for newly created contexts (current 0x"+Integer.toHexString(val[0])+")"); } } - NullWindow nw = new NullWindow(cfg); - nw.setSurfaceHandle(drawable); - nw.setSize(w, h); - return new X11ExternalGLXDrawable(factory, nw); + ProxySurface ns = new ProxySurface(cfg); + ns.setSurfaceHandle(drawable); + ns.setSize(w, h); + return new X11ExternalGLXDrawable(factory, ns); } public GLContext createContext(GLContext shareWith) { @@ -97,14 +97,6 @@ public class X11ExternalGLXDrawable extends X11GLXDrawable { throw new GLException("Should not call this"); } - public int getWidth() { - return getNativeWindow().getWidth(); - } - - public int getHeight() { - return getNativeWindow().getHeight(); - } - class Context extends X11GLXContext { Context(X11GLXDrawable drawable, GLContext shareWith) { super(drawable, shareWith); diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java index 90650bde9..494860c5b 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -130,7 +131,7 @@ public abstract class X11GLXContext extends GLContextImpl { } protected void destroyContextARBImpl(long ctx) { - X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); long display = config.getScreen().getDevice().getHandle(); glXMakeContextCurrent(display, 0, 0, 0); @@ -139,7 +140,7 @@ public abstract class X11GLXContext extends GLContextImpl { protected long createContextARBImpl(long share, boolean direct, int ctp, int major, int minor) { X11GLXDrawableFactory factory = (X11GLXDrawableFactory)drawable.getFactoryImpl(); - X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); long display = config.getScreen().getDevice().getHandle(); GLXExt glXExt; @@ -215,7 +216,7 @@ public abstract class X11GLXContext extends GLContextImpl { protected boolean createContext(boolean direct) { isDirect = false; // default X11GLXDrawableFactory factory = (X11GLXDrawableFactory)drawable.getFactoryImpl(); - X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); long display = config.getScreen().getDevice().getHandle(); X11GLXContext other = (X11GLXContext) GLContextShareSet.getShareContext(this); @@ -328,7 +329,7 @@ public abstract class X11GLXContext extends GLContextImpl { } protected void makeCurrentImpl(boolean newCreated) throws GLException { - long dpy = drawable.getNativeWindow().getDisplayHandle(); + long dpy = drawable.getNativeSurface().getDisplayHandle(); if (GLX.glXGetCurrentContext() != contextHandle) { if (!glXMakeContextCurrent(dpy, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { @@ -345,14 +346,14 @@ public abstract class X11GLXContext extends GLContextImpl { } protected void releaseImpl() throws GLException { - long display = drawable.getNativeWindow().getDisplayHandle(); + long display = drawable.getNativeSurface().getDisplayHandle(); if (!glXMakeContextCurrent(display, 0, 0, 0)) { throw new GLException("Error freeing OpenGL context"); } } protected void destroyImpl() throws GLException { - long display = drawable.getNativeWindow().getDisplayHandle(); + long display = drawable.getNativeSurface().getDisplayHandle(); if (DEBUG) { System.err.println("glXDestroyContext(dpy " + toHexString(display)+ @@ -368,7 +369,7 @@ public abstract class X11GLXContext extends GLContextImpl { protected void copyImpl(GLContext source, int mask) throws GLException { long dst = getHandle(); long src = source.getHandle(); - long display = drawable.getNativeWindow().getDisplayHandle(); + long display = drawable.getNativeSurface().getDisplayHandle(); if (0 == display) { throw new GLException("Connection to X display not yet set up"); } @@ -399,8 +400,8 @@ public abstract class X11GLXContext extends GLContextImpl { glXQueryExtensionsStringInitialized = true; } if (glXQueryExtensionsStringAvailable) { - NativeWindow nw = drawable.getNativeWindow(); - String ret = GLX.glXQueryExtensionsString(nw.getDisplayHandle(), nw.getScreenIndex()); + NativeSurface ns = drawable.getNativeSurface(); + String ret = GLX.glXQueryExtensionsString(ns.getDisplayHandle(), ns.getScreenIndex()); if (DEBUG) { System.err.println("!!! GLX extensions: " + ret); } @@ -414,7 +415,7 @@ public abstract class X11GLXContext extends GLContextImpl { if (glExtensionName.equals("GL_ARB_pbuffer") || glExtensionName.equals("GL_ARB_pixel_format")) { return getGLDrawable().getFactory().canCreateGLPbuffer( - drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice() ); + drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice() ); } return super.isExtensionAvailable(glExtensionName); } @@ -423,7 +424,7 @@ public abstract class X11GLXContext extends GLContextImpl { private int hasSwapIntervalSGI = 0; protected void setSwapIntervalImpl(int interval) { - X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); GLCapabilities glCaps = (GLCapabilities) config.getChosenCapabilities(); if(!glCaps.isOnscreen()) return; diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawable.java index 8547471fb..9c3737d3d 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawable.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -44,7 +45,7 @@ import javax.media.opengl.*; import com.jogamp.opengl.impl.*; public abstract class X11GLXDrawable extends GLDrawableImpl { - protected X11GLXDrawable(GLDrawableFactory factory, NativeWindow comp, boolean realized) { + protected X11GLXDrawable(GLDrawableFactory factory, NativeSurface comp, boolean realized) { super(factory, comp, realized); } @@ -54,7 +55,7 @@ public abstract class X11GLXDrawable extends GLDrawableImpl { protected void setRealizedImpl() { if(realized) { - X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); config.updateGraphicsConfiguration(); if (DEBUG) { @@ -64,7 +65,7 @@ public abstract class X11GLXDrawable extends GLDrawableImpl { } protected void swapBuffersImpl() { - GLX.glXSwapBuffers(getNativeWindow().getDisplayHandle(), getHandle()); + GLX.glXSwapBuffers(getNativeSurface().getDisplayHandle(), getHandle()); } //--------------------------------------------------------------------------- diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java index 98be19263..2ae53fb9d 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -44,7 +45,7 @@ import javax.media.opengl.*; import com.jogamp.opengl.impl.*; import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.util.*; -import com.jogamp.nativewindow.impl.NullWindow; +import com.jogamp.nativewindow.impl.ProxySurface; import com.jogamp.nativewindow.impl.x11.*; public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { @@ -164,14 +165,14 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { X11Util.shutdown( false, DEBUG ); } - public GLDrawableImpl createOnscreenDrawable(NativeWindow target) { + public GLDrawableImpl createOnscreenDrawable(NativeSurface target) { if (target == null) { throw new IllegalArgumentException("Null target"); } return new X11OnscreenGLXDrawable(this, target); } - protected GLDrawableImpl createOffscreenDrawable(NativeWindow target) { + protected GLDrawableImpl createOffscreenDrawable(NativeSurface target) { if (target == null) { throw new IllegalArgumentException("Null target"); } @@ -209,7 +210,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { return ( glxVersionMajor > majorReq ) || ( glxVersionMajor == majorReq && glxVersionMinor >= minorReq ) ; } - protected GLDrawableImpl createGLPbufferDrawableImpl(final NativeWindow target) { + protected GLDrawableImpl createGLPbufferDrawableImpl(final NativeSurface target) { if (target == null) { throw new IllegalArgumentException("Null target"); } @@ -238,12 +239,12 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { } - protected NativeWindow createOffscreenWindow(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) { - NullWindow nw = new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capabilities, chooser, sharedScreen)); - if(nw != null) { - nw.setSize(width, height); + protected NativeSurface createOffscreenSurface(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) { + ProxySurface ns = new ProxySurface(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capabilities, chooser, sharedScreen)); + if(ns != null) { + ns.setSize(width, height); } - return nw; + return ns; } public GLContext createExternalGLContext() { diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXContext.java index 6f24d5a60..bde65f3bb 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXContext.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -54,7 +55,7 @@ public class X11OffscreenGLXContext extends X11GLXContext { } public int getOffscreenContextReadBuffer() { - GLCapabilities caps = (GLCapabilities)drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); + GLCapabilities caps = (GLCapabilities)drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); if (caps.getDoubleBuffered()) { return GL.GL_BACK; } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java index 230387c1c..3be34eb6a 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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,7 +47,7 @@ import com.jogamp.nativewindow.impl.x11.*; public class X11OffscreenGLXDrawable extends X11GLXDrawable { private long pixmap; - protected X11OffscreenGLXDrawable(GLDrawableFactory factory, NativeWindow target) { + protected X11OffscreenGLXDrawable(GLDrawableFactory factory, NativeSurface target) { super(factory, target, true); create(); } @@ -64,8 +65,8 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable { } private void create() { - NativeWindow nw = getNativeWindow(); - X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration) nw.getGraphicsConfiguration().getNativeGraphicsConfiguration(); + NativeSurface ns = getNativeSurface(); + X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration) ns.getGraphicsConfiguration().getNativeGraphicsConfiguration(); XVisualInfo vis = config.getXVisualInfo(); int bitsPerPixel = vis.getDepth(); AbstractGraphicsScreen aScreen = config.getScreen(); @@ -74,7 +75,7 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable { int screen = aScreen.getIndex(); pixmap = X11Lib.XCreatePixmap(dpy, X11Lib.RootWindow(dpy, screen), - component.getWidth(), component.getHeight(), bitsPerPixel); + surface.getWidth(), surface.getHeight(), bitsPerPixel); if (pixmap == 0) { throw new GLException("XCreatePixmap failed"); } @@ -84,7 +85,7 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable { pixmap = 0; throw new GLException("glXCreateGLXPixmap failed"); } - ((SurfaceChangeable)nw).setSurfaceHandle(drawable); + ((SurfaceChangeable)ns).setSurfaceHandle(drawable); if (DEBUG) { System.err.println("Created pixmap " + toHexString(pixmap) + ", GLXPixmap " + toHexString(drawable) + @@ -95,10 +96,10 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable { public void destroy() { if (pixmap == 0) return; - NativeWindow nw = getNativeWindow(); - long display = nw.getDisplayHandle(); + NativeSurface ns = getNativeSurface(); + long display = ns.getDisplayHandle(); - long drawable = nw.getSurfaceHandle(); + long drawable = ns.getSurfaceHandle(); if (DEBUG) { System.err.println("Destroying pixmap " + toHexString(pixmap) + ", GLXPixmap " + toHexString(drawable) + @@ -124,7 +125,7 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable { X11Lib.XFreePixmap(display, pixmap); drawable = 0; pixmap = 0; - ((SurfaceChangeable)nw).setSurfaceHandle(0); + ((SurfaceChangeable)ns).setSurfaceHandle(0); display = 0; } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java index 3a8bbfecc..5243e8c46 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -48,7 +49,7 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable { long glXWindow; // GLXWindow, a GLXDrawable representation boolean useGLXWindow; - protected X11OnscreenGLXDrawable(GLDrawableFactory factory, NativeWindow component) { + protected X11OnscreenGLXDrawable(GLDrawableFactory factory, NativeSurface component) { super(factory, component, false); glXWindow=0; useGLXWindow=false; @@ -58,12 +59,12 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable { if(useGLXWindow) { return glXWindow; } - return getNativeWindow().getSurfaceHandle(); + return getNativeSurface().getSurfaceHandle(); } protected void destroyHandle() { if(0!=glXWindow) { - GLX.glXDestroyWindow(getNativeWindow().getDisplayHandle(), glXWindow); + GLX.glXDestroyWindow(getNativeSurface().getDisplayHandle(), glXWindow); glXWindow = 0; useGLXWindow=false; } @@ -72,16 +73,16 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable { /** must be locked already */ protected void updateHandle() { if(USE_GLXWINDOW) { - X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); if(config.getFBConfig()>=0) { useGLXWindow=true; - long dpy = getNativeWindow().getDisplayHandle(); + long dpy = getNativeSurface().getDisplayHandle(); if(0!=glXWindow) { GLX.glXDestroyWindow(dpy, glXWindow); } - glXWindow = GLX.glXCreateWindow(dpy, config.getFBConfig(), getNativeWindow().getSurfaceHandle(), null, 0); + glXWindow = GLX.glXCreateWindow(dpy, config.getFBConfig(), getNativeSurface().getSurfaceHandle(), null, 0); if (DEBUG) { - System.err.println("!!! X11OnscreenGLXDrawable.setRealized(true): glXWindow: "+toHexString(getNativeWindow().getSurfaceHandle())+" -> "+toHexString(glXWindow)); + System.err.println("!!! X11OnscreenGLXDrawable.setRealized(true): glXWindow: "+toHexString(getNativeSurface().getSurfaceHandle())+" -> "+toHexString(glXWindow)); } if(0==glXWindow) { throw new GLException("X11OnscreenGLXDrawable.setRealized(true): GLX.glXCreateWindow() failed: "+this); @@ -93,12 +94,4 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable { public GLContext createContext(GLContext shareWith) { return new X11OnscreenGLXContext(this, shareWith); } - - public int getWidth() { - return component.getWidth(); - } - - public int getHeight() { - return component.getHeight(); - } } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXDrawable.java index c00f9909e..ce9e6d75d 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXDrawable.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -43,14 +44,14 @@ import javax.media.opengl.*; import javax.media.nativewindow.*; public class X11PbufferGLXDrawable extends X11GLXDrawable { - protected X11PbufferGLXDrawable(GLDrawableFactory factory, NativeWindow target) { + protected X11PbufferGLXDrawable(GLDrawableFactory factory, NativeSurface target) { /* GLCapabilities caps, GLCapabilitiesChooser chooser, int width, int height */ super(factory, target, true); if (DEBUG) { - System.out.println("Pbuffer config: " + getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration()); + System.out.println("Pbuffer config: " + getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration()); } createPbuffer(); @@ -73,15 +74,15 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { } public void destroy() { - NativeWindow nw = getNativeWindow(); - if (nw.getSurfaceHandle() != 0) { - GLX.glXDestroyPbuffer(nw.getDisplayHandle(), nw.getSurfaceHandle()); + NativeSurface ns = getNativeSurface(); + if (ns.getSurfaceHandle() != 0) { + GLX.glXDestroyPbuffer(ns.getDisplayHandle(), ns.getSurfaceHandle()); } - ((SurfaceChangeable)nw).setSurfaceHandle(0); + ((SurfaceChangeable)ns).setSurfaceHandle(0); } private void createPbuffer() { - X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration) getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration) getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); AbstractGraphicsScreen aScreen = config.getScreen(); AbstractGraphicsDevice aDevice = aScreen.getDevice(); long display = aDevice.getHandle(); @@ -91,7 +92,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { throw new GLException("Null display"); } - NativeWindow nw = getNativeWindow(); + NativeSurface ns = getNativeSurface(); GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities(); @@ -108,9 +109,9 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { int[] iattributes = new int[5]; iattributes[niattribs++] = GLX.GLX_PBUFFER_WIDTH; - iattributes[niattribs++] = nw.getWidth(); + iattributes[niattribs++] = ns.getWidth(); iattributes[niattribs++] = GLX.GLX_PBUFFER_HEIGHT; - iattributes[niattribs++] = nw.getHeight(); + iattributes[niattribs++] = ns.getHeight(); iattributes[niattribs++] = 0; long pbuffer = GLX.glXCreatePbuffer(display, config.getFBConfig(), iattributes, 0); @@ -120,7 +121,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { } // Set up instance variables - ((SurfaceChangeable)nw).setSurfaceHandle(pbuffer); + ((SurfaceChangeable)ns).setSurfaceHandle(pbuffer); // Determine the actual width and height we were able to create. int[] tmp = new int[1]; @@ -128,7 +129,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { int width = tmp[0]; GLX.glXQueryDrawable(display, pbuffer, GLX.GLX_HEIGHT, tmp, 0); int height = tmp[0]; - ((SurfaceChangeable)nw).setSize(width, height); + ((SurfaceChangeable)ns).setSize(width, height); } public int getFloatingPointMode() { diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java index 5d48405e2..2b8876a91 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java @@ -197,6 +197,7 @@ public class Animator extends AnimatorBase { if (runnable == null) { runnable = new MainLoop(); } + resetCounter(); int id; String threadName = Thread.currentThread().getName()+"-"+baseName; if(null==threadGroup) { @@ -272,6 +273,7 @@ public class Animator extends AnimatorBase { } } } + resetCounter(); } protected final boolean getShouldPause() { diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java index 279fe33ef..a54f6be57 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java @@ -49,9 +49,9 @@ public abstract class AnimatorBase implements GLAnimatorControl { protected Thread thread; protected boolean ignoreExceptions; protected boolean printExceptions; - protected long startTime = 0; - protected long curTime = 0; - protected int totalFrames = 0; + protected long startTime; + protected long curTime; + protected int totalFrames; /** Creates a new, empty Animator. */ public AnimatorBase() { @@ -69,6 +69,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { animatorCount++; baseName = baseName.concat("-"+animatorCount); } + resetCounter(); } protected abstract String getBaseName(String prefix); @@ -112,10 +113,6 @@ public abstract class AnimatorBase implements GLAnimatorControl { return curTime - startTime; } - protected abstract boolean getShouldPause(); - - protected abstract boolean getShouldStop(); - public long getStartTime() { return startTime; } @@ -124,6 +121,12 @@ public abstract class AnimatorBase implements GLAnimatorControl { return totalFrames; } + public synchronized void resetCounter() { + startTime = System.currentTimeMillis(); // overwrite startTime to real init one + curTime = startTime; + totalFrames = 0; + } + public final synchronized Thread getThread() { return thread; } @@ -142,4 +145,12 @@ public abstract class AnimatorBase implements GLAnimatorControl { public void setPrintExceptions(boolean printExceptions) { this.printExceptions = printExceptions; } + + public String toString() { + return getClass().getName()+"[started "+isStarted()+", animating "+isAnimating()+", paused "+isPaused()+", frames "+getTotalFrames()+"]"; + } + + protected abstract boolean getShouldPause(); + + protected abstract boolean getShouldStop(); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java index d098cf1a3..8542000c6 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java @@ -88,11 +88,6 @@ public class FPSAnimator extends AnimatorBase { this.scheduleAtFixedRate = scheduleAtFixedRate; } - public long getStartTime() { return startTime; } - public long getCurrentTime() { return curTime; } - public long getDuration() { return curTime-startTime; } - public int getTotalFrames() { return totalFrames; } - public final synchronized boolean isStarted() { return (timer != null); } @@ -116,9 +111,7 @@ public class FPSAnimator extends AnimatorBase { } }; - startTime = System.currentTimeMillis(); - curTime = startTime; - totalFrames = 0; + resetCounter(); shouldRun = true; if (scheduleAtFixedRate) { diff --git a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java index ee41c9161..dc6daa645 100644 --- a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java +++ b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003-2009 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 diff --git a/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java b/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java index 13788fe53..3aba634a0 100644 --- a/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java +++ b/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java @@ -66,10 +66,7 @@ public interface GLAnimatorControl { /** - * @return Number of frames issued to all registered GLAutoDrawables registered - */ - /** - * @return Number of frame cycles displayed by all registered {@link javax.media.opengl.GLAutoDrawable} + * @return Number of frame cycles displayed * since the first display call, ie <code>getStartTime()</code>. * This value is reset if started or resumed. * @@ -78,6 +75,9 @@ public interface GLAnimatorControl { */ int getTotalFrames(); + /** Reset all performance counter (startTime, currentTime, frame number) */ + public void resetCounter(); + /** * Indicates whether this animator is currently running, ie started. * diff --git a/src/jogl/classes/javax/media/opengl/GLArrayData.java b/src/jogl/classes/javax/media/opengl/GLArrayData.java index 088c71bd8..6c8122f27 100644 --- a/src/jogl/classes/javax/media/opengl/GLArrayData.java +++ b/src/jogl/classes/javax/media/opengl/GLArrayData.java @@ -1,3 +1,30 @@ +/** + * 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 javax.media.opengl; diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java index bc2f633ce..12ded8736 100644 --- a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java @@ -56,7 +56,7 @@ import java.security.*; based rendering mechanism as well by end users directly.<P> The implementation shall initialize itself as soon as possible, - ie if the attached {@link javax.media.nativewindow.NativeWindow NativeWindow} is become visible. + ie if the attached {@link javax.media.nativewindow.NativeSurface NativeSurface} becomes visible/realized. The following protocol shall be satisfied: <ul> <li> Create the {@link GLDrawable} with the requested {@link GLCapabilities}</li> @@ -70,12 +70,12 @@ import java.security.*; Another implementation detail is the drawable reconfiguration. One use case is where a window is being dragged to another screen with a different pixel configuration, ie {@link GLCapabilities}. The implementation - shall be able to detect such cases in conjunction with the associated {@link javax.media.nativewindow.NativeWindow NativeWindow}.<br> + shall be able to detect such cases in conjunction with the associated {@link javax.media.nativewindow.NativeSurface NativeSurface}.<br> For example, AWT's {@link java.awt.Canvas} 's {@link java.awt.Canvas#getGraphicsConfiguration getGraphicsConfiguration()} is capable to determine a display device change. This is demonstrated within {@link javax.media.opengl.awt.GLCanvas}'s and NEWT's <code>AWTCanvas</code> {@link javax.media.opengl.awt.GLCanvas#getGraphicsConfiguration getGraphicsConfiguration()} specialization. Another demonstration is NEWT's {@link javax.media.nativewindow.NativeWindow NativeWindow} - implementation on the the Windows platform, which utilizes the native platform's <i>MonitorFromWindow(HWND)</i> function.<br> + implementation on the Windows platform, which utilizes the native platform's <i>MonitorFromWindow(HWND)</i> function.<br> All OpenGL resources shall be regenerated, while the drawable's {@link GLCapabilities} has to be choosen again. The following protocol shall be satisfied. <ul> diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java index 5ba410a61..90b320ed3 100644 --- a/src/jogl/classes/javax/media/opengl/GLBase.java +++ b/src/jogl/classes/javax/media/opengl/GLBase.java @@ -1,5 +1,30 @@ -/* +/** * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. + * 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 javax.media.opengl; diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilities.java b/src/jogl/classes/javax/media/opengl/GLCapabilities.java index 530078ec0..11d353e61 100644 --- a/src/jogl/classes/javax/media/opengl/GLCapabilities.java +++ b/src/jogl/classes/javax/media/opengl/GLCapabilities.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003-2009 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 diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/GLCapabilitiesChooser.java index 38cda8cdf..73a77de27 100644 --- a/src/jogl/classes/javax/media/opengl/GLCapabilitiesChooser.java +++ b/src/jogl/classes/javax/media/opengl/GLCapabilitiesChooser.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003-2009 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 diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index b11374f9d..0cc63fb1a 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 diff --git a/src/jogl/classes/javax/media/opengl/GLDrawable.java b/src/jogl/classes/javax/media/opengl/GLDrawable.java index 46296ca52..e4861edd2 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawable.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -103,13 +104,13 @@ public interface GLDrawable { * * With an argument of <code>true</code>, * the minimum implementation shall call - * {@link NativeWindow#lockSurface() NativeWindow's lockSurface()} and if successfull: + * {@link NativeSurface#lockSurface() NativeSurface's lockSurface()} and if successfull: * <ul> * <li> Update the {@link GLCapabilities}, which are associated with - * the attached {@link NativeWindow}'s {@link AbstractGraphicsConfiguration}.</li> - * <li> Release the lock with {@link NativeWindow#unlockSurface() NativeWindow's unlockSurface()}.</li> + * the attached {@link NativeSurface}'s {@link AbstractGraphicsConfiguration}.</li> + * <li> Release the lock with {@link NativeSurface#unlockSurface() NativeSurface's unlockSurface()}.</li> * </ul><br> - * This is important since {@link NativeWindow#lockSurface() NativeWindow's lockSurface()} + * This is important since {@link NativeSurface#lockSurface() NativeSurface's lockSurface()} * ensures resolving the window/surface handles, and the drawable's {@link GLCapabilities} * might have changed. * @@ -143,7 +144,7 @@ public interface GLDrawable { On some platforms, the pixel format is not directly associated with the drawable; a best attempt is made to return a reasonable value in this case. <br> - This object shall be directly associated to the attached {@link NativeWindow}'s + This object shall be directly associated to the attached {@link NativeSurface}'s {@link AbstractGraphicsConfiguration}, and if changes are necessary, they should reflect those as well. @return A copy of the queried object. @@ -155,11 +156,11 @@ public interface GLDrawable { */ public GLProfile getGLProfile(); - public NativeWindow getNativeWindow(); + public NativeSurface getNativeSurface(); /** * This is the GL/Windowing drawable handle.<br> - * It is usually the {@link javax.media.nativewindow.NativeWindow#getSurfaceHandle()}, + * It is usually the {@link javax.media.nativewindow.NativeSurface#getSurfaceHandle()}, * ie the native surface handle of the underlying windowing toolkit.<br> * However, on X11/GLX this reflects a GLXDrawable, which represents a GLXWindow, GLXPixmap, or GLXPbuffer.<br> * On EGL, this represents the EGLSurface.<br> diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index 86e3def38..a85993c8e 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -177,7 +178,7 @@ public abstract class GLDrawableFactory { * which determines pixel format, on- and offscreen incl. PBuffer type. * <p> * The native platform's chosen Capabilties are referenced within the target - * NativeWindow's AbstractGraphicsConfiguration.<p> + * NativeSurface's AbstractGraphicsConfiguration.<p> * * In case {@link javax.media.nativewindow.Capabilities#isOnscreen()} is true,<br> * an onscreen GLDrawable will be realized. @@ -193,7 +194,7 @@ public abstract class GLDrawableFactory { * * @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen) */ - public abstract GLDrawable createGLDrawable(NativeWindow target) + public abstract GLDrawable createGLDrawable(NativeSurface target) throws IllegalArgumentException, GLException; /** diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index 3b40dbe69..287e7a5a9 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 4e63a8048..60ed731f1 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -567,8 +567,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable { return (GLCapabilities)awtConfig.getRequestedCapabilities(); } - public NativeWindow getNativeWindow() { - return drawable.getNativeWindow(); + public NativeSurface getNativeSurface() { + return drawable.getNativeSurface(); } public long getHandle() { diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 72b782f9a..e4a295ba3 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -488,7 +488,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable { return glProfile; } - public NativeWindow getNativeWindow() { + public NativeSurface getNativeSurface() { throw new GLException("FIXME"); } @@ -1541,7 +1541,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable { } } if (joglContext == null) { - AbstractGraphicsDevice device = j2dContext.getGLDrawable().getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice(); + AbstractGraphicsDevice device = j2dContext.getGLDrawable().getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice(); if (factory.canCreateExternalGLDrawable(device)) { joglDrawable = factory.createExternalGLDrawable(); // FIXME: Need to share with j2d context, due to FBO resource .. diff --git a/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java b/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java index 2bb14dee0..243c9e8a7 100644 --- a/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java +++ b/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java @@ -120,7 +120,7 @@ public class TestDrawable01NEWT extends UITestCase { // Assert.assertEquals(width,drawable.getWidth()); // Assert.assertEquals(height,drawable.getHeight()); // Assert.assertEquals(glCaps,drawable.getChosenGLCapabilities()); - Assert.assertEquals(window,drawable.getNativeWindow()); + Assert.assertEquals(window,drawable.getNativeSurface()); // System.out.println("Post: "+drawable); context = drawable.createContext(null); diff --git a/src/junit/com/jogamp/test/junit/jogl/offscreen/Surface2File.java b/src/junit/com/jogamp/test/junit/jogl/offscreen/Surface2File.java index cc4686159..c5d770bb8 100644 --- a/src/junit/com/jogamp/test/junit/jogl/offscreen/Surface2File.java +++ b/src/junit/com/jogamp/test/junit/jogl/offscreen/Surface2File.java @@ -46,7 +46,7 @@ public class Surface2File implements SurfaceUpdatedListener { readBufferUtil.dispose(); } - public void surfaceUpdated(Object updater, NativeWindow window, long when) { + public void surfaceUpdated(Object updater, NativeSurface ns, long when) { if (updater instanceof GLDrawable) { GLDrawable drawable = (GLDrawable) updater; GLContext ctx = GLContext.getCurrent(); diff --git a/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle01NEWT.java index 263f5da1a..7f70d1f8b 100644 --- a/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle01NEWT.java +++ b/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle01NEWT.java @@ -158,7 +158,7 @@ public class TestDisplayLifecycle01NEWT extends UITestCase { Assert.assertEquals(false,window.isVisible()); // just make the Window visible again - window.resetPerfCounter(); + window.resetCounter(); Assert.assertEquals(0, window.getTotalFrames()); window.setVisible(true); wait=0; @@ -186,7 +186,7 @@ public class TestDisplayLifecycle01NEWT extends UITestCase { Assert.assertEquals(true,screen.isNativeValid()); Assert.assertEquals(false,window.isNativeValid()); Assert.assertEquals(false,window.isVisible()); - window.resetPerfCounter(); + window.resetCounter(); Assert.assertEquals(0, window.getTotalFrames()); // a display call shall not change a thing diff --git a/src/junit/com/jogamp/test/junit/newt/TestFocus02SwingAWTRobot.java b/src/junit/com/jogamp/test/junit/newt/TestFocus02SwingAWTRobot.java index 145b32a5f..dfca6c10b 100644 --- a/src/junit/com/jogamp/test/junit/newt/TestFocus02SwingAWTRobot.java +++ b/src/junit/com/jogamp/test/junit/newt/TestFocus02SwingAWTRobot.java @@ -29,39 +29,24 @@ package com.jogamp.test.junit.newt; import java.lang.reflect.*; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; import org.junit.Assert; -import org.junit.Before; import org.junit.BeforeClass; -import org.junit.After; import org.junit.AfterClass; import org.junit.Test; import java.awt.AWTException; import java.awt.Button; import java.awt.BorderLayout; -import java.awt.Canvas; import java.awt.Container; -import java.awt.Frame; -import java.awt.Dimension; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; import java.awt.Robot; -import java.awt.Point; -import java.awt.Rectangle; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; import javax.media.opengl.*; -import javax.media.nativewindow.*; 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; @@ -252,7 +237,7 @@ public class TestFocus02SwingAWTRobot extends UITestCase { glWindow1.destroy(true); } - @Test +// @Test public void testFocus01ProgrFocus() throws AWTException, InterruptedException, InvocationTargetException { testFocus01ProgrFocusImpl(null); } diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01NEWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01NEWT.java index 3ac830c89..c07601eb6 100644 --- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01NEWT.java +++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01NEWT.java @@ -86,7 +86,7 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertNotNull(glWindow1); Assert.assertEquals(false, glWindow1.isVisible()); Assert.assertEquals(false, glWindow1.isNativeValid()); - Assert.assertNull(glWindow1.getParentNativeWindow()); + Assert.assertNull(glWindow1.getParent()); screen = glWindow1.getScreen(); display = screen.getDisplay(); Assert.assertEquals(true,display.getDestroyWhenUnused()); @@ -108,7 +108,7 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertNotNull(glWindow2); Assert.assertEquals(false, glWindow2.isVisible()); Assert.assertEquals(false, glWindow2.isNativeValid()); - Assert.assertSame(glWindow1,glWindow2.getParentNativeWindow()); + Assert.assertSame(glWindow1,glWindow2.getParent()); Assert.assertSame(screen,glWindow2.getScreen()); Assert.assertSame(display,glWindow2.getScreen().getDisplay()); glWindow2.setSize(320, 240); @@ -156,8 +156,8 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertEquals(true, glWindow2.isNativeValid()); Assert.assertEquals(0, glWindow1.getTotalFrames()); - glWindow1.resetPerfCounter(); - glWindow2.resetPerfCounter(); + glWindow1.resetCounter(); + glWindow2.resetCounter(); Assert.assertEquals(0, glWindow1.getTotalFrames()); Assert.assertEquals(0, glWindow2.getTotalFrames()); glWindow1.setVisible(true); @@ -173,8 +173,8 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); - glWindow1.resetPerfCounter(); - glWindow2.resetPerfCounter(); + glWindow1.resetCounter(); + glWindow2.resetCounter(); Animator animator1 = new Animator(glWindow1); animator1.start(); Assert.assertEquals(true, animator1.isAnimating()); @@ -201,8 +201,8 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertEquals(true, animator2.isPaused()); Assert.assertNotNull(animator2.getThread()); - glWindow1.resetPerfCounter(); - glWindow2.resetPerfCounter(); + glWindow1.resetCounter(); + glWindow2.resetCounter(); animator1.resume(); Assert.assertEquals(true, animator1.isAnimating()); Assert.assertEquals(false, animator1.isPaused()); @@ -268,8 +268,8 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertEquals(1,Display.getActiveDisplayNumber()); // recreation .. - glWindow1.resetPerfCounter(); - glWindow2.resetPerfCounter(); + glWindow1.resetCounter(); + glWindow2.resetCounter(); Assert.assertEquals(0, glWindow1.getTotalFrames()); Assert.assertEquals(0, glWindow2.getTotalFrames()); glWindow1.setVisible(true); @@ -434,14 +434,16 @@ public class TestParenting01NEWT extends UITestCase { case 0: // glWindow2 -- child --> glWindow1: compatible Assert.assertEquals(true, glWindow2.isVisible()); + System.err.println("Frames(1) "+glWindow2.getTotalFrames()); reparentAction = glWindow2.reparentWindow(glWindow1, reparentRecreate); + System.err.println("Frames(2) "+glWindow2.getTotalFrames()); Assert.assertTrue(Window.ReparentAction.ACTION_INVALID < reparentAction); for(wait=0; wait<10 && glWindow2.getTotalFrames()<1; wait++) { Thread.sleep(100); } System.err.println("Frames for reparentWindow(parent, "+reparentRecreate+"): "+reparentAction+", B2: "+glWindow2.getTotalFrames()); Assert.assertTrue(0 < glWindow2.getTotalFrames()); Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); - Assert.assertSame(glWindow1,glWindow2.getParentNativeWindow()); + Assert.assertSame(glWindow1,glWindow2.getParent()); Assert.assertEquals(1,display1.getReferenceCount()); Assert.assertEquals(true,display1.isNativeValid()); @@ -484,7 +486,7 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertTrue(0 < glWindow2.getTotalFrames()); Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); - Assert.assertNull(glWindow2.getParentNativeWindow()); + Assert.assertNull(glWindow2.getParent()); Assert.assertEquals(1,display1.getReferenceCount()); Assert.assertEquals(true,display1.isNativeValid()); @@ -674,7 +676,7 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertEquals(true,display1.getEDTUtil().isRunning()); Assert.assertEquals(2,screen1.getReferenceCount()); Assert.assertEquals(true,screen1.isNativeValid()); - Assert.assertSame(glWindow1,glWindow2.getParentNativeWindow()); + Assert.assertSame(glWindow1,glWindow2.getParent()); Assert.assertSame(screen1,glWindow2.getScreen()); Assert.assertEquals(1,Display.getActiveDisplayNumber()); @@ -697,7 +699,7 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertTrue(0 < glWindow2.getTotalFrames()); Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); - Assert.assertNull(glWindow2.getParentNativeWindow()); + Assert.assertNull(glWindow2.getParent()); Assert.assertSame(screen1,glWindow2.getScreen()); Assert.assertSame(display1,glWindow2.getScreen().getDisplay()); Assert.assertEquals(1,Display.getActiveDisplayNumber()); @@ -711,7 +713,7 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertTrue(0 < glWindow2.getTotalFrames()); Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); - Assert.assertSame(glWindow1,glWindow2.getParentNativeWindow()); + Assert.assertSame(glWindow1,glWindow2.getParent()); Assert.assertSame(screen1,glWindow2.getScreen()); Assert.assertSame(display1,glWindow2.getScreen().getDisplay()); Assert.assertEquals(1,Display.getActiveDisplayNumber()); @@ -735,7 +737,7 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertEquals(true,display1.getEDTUtil().isRunning()); Assert.assertEquals(2,screen1.getReferenceCount()); Assert.assertEquals(true,screen1.isNativeValid()); - Assert.assertSame(glWindow1,glWindow2.getParentNativeWindow()); + Assert.assertSame(glWindow1,glWindow2.getParent()); Assert.assertSame(screen1,glWindow2.getScreen()); Assert.assertEquals(1,Display.getActiveDisplayNumber()); diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01aAWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01aAWT.java index 34c1bc1f3..3d3f5234d 100644 --- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01aAWT.java +++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01aAWT.java @@ -90,7 +90,7 @@ public class TestParenting01aAWT extends UITestCase { Assert.assertNotNull(glWindow1); Assert.assertEquals(false, glWindow1.isVisible()); Assert.assertEquals(false, glWindow1.isNativeValid()); - Assert.assertNull(glWindow1.getParentNativeWindow()); + Assert.assertNull(glWindow1.getParent()); glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); GLEventListener demo1 = new RedSquare(); setDemoFields(demo1, glWindow1, false); @@ -100,7 +100,7 @@ public class TestParenting01aAWT extends UITestCase { Assert.assertNotNull(newtCanvasAWT); Assert.assertEquals(false, glWindow1.isVisible()); Assert.assertEquals(false, glWindow1.isNativeValid()); - Assert.assertNull(glWindow1.getParentNativeWindow()); + Assert.assertNull(glWindow1.getParent()); Frame frame1 = new Frame("AWT Parent Frame"); frame1.setLayout(new BorderLayout()); @@ -122,7 +122,7 @@ public class TestParenting01aAWT extends UITestCase { // visible test frame1.setVisible(true); - Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParentNativeWindow()); + Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); Animator animator1 = new Animator(glWindow1); animator1.start(); @@ -139,7 +139,7 @@ public class TestParenting01aAWT extends UITestCase { Assert.assertEquals(true, glWindow1.isValid()); frame1.remove(newtCanvasAWT); - // Assert.assertNull(glWindow1.getParentNativeWindow()); + // Assert.assertNull(glWindow1.getParent()); Assert.assertEquals(true, glWindow1.isValid()); frame1.dispose(); @@ -160,7 +160,7 @@ public class TestParenting01aAWT extends UITestCase { Assert.assertNotNull(glWindow1); Assert.assertEquals(false, glWindow1.isVisible()); Assert.assertEquals(false, glWindow1.isNativeValid()); - Assert.assertNull(glWindow1.getParentNativeWindow()); + Assert.assertNull(glWindow1.getParent()); GLEventListener demo1 = new RedSquare(); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); @@ -169,7 +169,7 @@ public class TestParenting01aAWT extends UITestCase { Assert.assertNotNull(newtCanvasAWT); Assert.assertEquals(false, glWindow1.isVisible()); Assert.assertEquals(false, glWindow1.isNativeValid()); - Assert.assertNull(glWindow1.getParentNativeWindow()); + Assert.assertNull(glWindow1.getParent()); Frame frame = new Frame("AWT Parent Frame"); Assert.assertNotNull(frame); @@ -179,7 +179,7 @@ public class TestParenting01aAWT extends UITestCase { frame.setVisible(true); frame.add(newtCanvasAWT); - Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParentNativeWindow()); + Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); Animator animator1 = new Animator(glWindow1); animator1.start(); @@ -248,7 +248,7 @@ public class TestParenting01aAWT extends UITestCase { frame.setVisible(true); frame.add(newtCanvasAWT); - Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParentNativeWindow()); + Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); Animator animator1 = new Animator(glWindow1); animator1.start(); @@ -260,12 +260,12 @@ public class TestParenting01aAWT extends UITestCase { case 0: glWindow1.reparentWindow(null); Assert.assertEquals(true, glWindow1.isNativeValid()); - Assert.assertNull(glWindow1.getParentNativeWindow()); + Assert.assertNull(glWindow1.getParent()); break; case 1: glWindow1.reparentWindow(newtCanvasAWT.getNativeWindow()); Assert.assertEquals(true, glWindow1.isNativeValid()); - Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParentNativeWindow()); + Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); break; } state++; @@ -303,7 +303,7 @@ public class TestParenting01aAWT extends UITestCase { frame.setVisible(true); frame.add(newtCanvasAWT, BorderLayout.CENTER); - Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParentNativeWindow()); + Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); Animator animator1 = new Animator(glWindow1); animator1.start(); @@ -315,12 +315,12 @@ public class TestParenting01aAWT extends UITestCase { case 0: glWindow1.reparentWindow(null); Assert.assertEquals(true, glWindow1.isNativeValid()); - Assert.assertNull(glWindow1.getParentNativeWindow()); + Assert.assertNull(glWindow1.getParent()); break; case 1: glWindow1.reparentWindow(newtCanvasAWT.getNativeWindow()); Assert.assertEquals(true, glWindow1.isNativeValid()); - Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParentNativeWindow()); + Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); break; } state++; @@ -369,7 +369,7 @@ public class TestParenting01aAWT extends UITestCase { frame2.setVisible(true); frame1.add(newtCanvasAWT, BorderLayout.CENTER); - Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParentNativeWindow()); + Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); Animator animator1 = new Animator(glWindow1); animator1.start(); diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01bAWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01bAWT.java index f9a19fe73..11d25822a 100644 --- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01bAWT.java +++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01bAWT.java @@ -124,7 +124,7 @@ public class TestParenting01bAWT extends UITestCase { frame2.setVisible(true); frame1.add(newtCanvasAWT, BorderLayout.CENTER); - Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParentNativeWindow()); + Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); GLAnimatorControl animator1; if(fps>0) { diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cAWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cAWT.java index 9919666fd..24ee30bc0 100644 --- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cAWT.java +++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cAWT.java @@ -89,7 +89,7 @@ public class TestParenting01cAWT extends UITestCase { Assert.assertNotNull(glWindow1); Assert.assertEquals(false, glWindow1.isVisible()); Assert.assertEquals(false, glWindow1.isNativeValid()); - Assert.assertNull(glWindow1.getParentNativeWindow()); + Assert.assertNull(glWindow1.getParent()); glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); GLEventListener demo1 = new RedSquare(); setDemoFields(demo1, glWindow1, false); @@ -99,7 +99,7 @@ public class TestParenting01cAWT extends UITestCase { Assert.assertNotNull(newtCanvasAWT); Assert.assertEquals(false, glWindow1.isVisible()); Assert.assertEquals(false, glWindow1.isNativeValid()); - Assert.assertNull(glWindow1.getParentNativeWindow()); + Assert.assertNull(glWindow1.getParent()); Frame frame1 = new Frame("AWT Parent Frame"); frame1.setLayout(new BorderLayout()); @@ -121,7 +121,7 @@ public class TestParenting01cAWT extends UITestCase { // visible test frame1.setVisible(true); - Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParentNativeWindow()); + Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); for(i=0; i*100<durationPerTest; i++) { Thread.sleep(100); @@ -134,7 +134,7 @@ public class TestParenting01cAWT extends UITestCase { Assert.assertEquals(true, glWindow1.isValid()); frame1.remove(newtCanvasAWT); - // Assert.assertNull(glWindow1.getParentNativeWindow()); + // Assert.assertNull(glWindow1.getParent()); Assert.assertEquals(true, glWindow1.isValid()); frame1.dispose(); @@ -180,7 +180,7 @@ public class TestParenting01cAWT extends UITestCase { frame2.setVisible(true); frame1.add(newtCanvasAWT, BorderLayout.CENTER); - Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParentNativeWindow()); + Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); int state; for(state=0; state<3; state++) { diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cSwingAWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cSwingAWT.java index 6e35f024e..ece99c0be 100644 --- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cSwingAWT.java +++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cSwingAWT.java @@ -96,7 +96,7 @@ public class TestParenting01cSwingAWT extends UITestCase { Assert.assertNotNull(glWindow1); Assert.assertEquals(false, glWindow1.isVisible()); Assert.assertEquals(false, glWindow1.isNativeValid()); - Assert.assertNull(glWindow1.getParentNativeWindow()); + Assert.assertNull(glWindow1.getParent()); glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); GLEventListener demo1 = new RedSquare(); setDemoFields(demo1, glWindow1, false); @@ -124,7 +124,7 @@ public class TestParenting01cSwingAWT extends UITestCase { Assert.assertNotNull(newtCanvasAWT); Assert.assertEquals(false, glWindow1.isVisible()); Assert.assertEquals(false, glWindow1.isNativeValid()); - Assert.assertNull(glWindow1.getParentNativeWindow()); + Assert.assertNull(glWindow1.getParent()); Container container1 = new Container(); container1.setLayout(new BorderLayout()); @@ -155,7 +155,7 @@ public class TestParenting01cSwingAWT extends UITestCase { final Container _container1 = container1; // visible test - Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParentNativeWindow()); + Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); while(animator1.isAnimating() && animator1.getDuration()<durationPerTest) { Thread.sleep(100); @@ -183,7 +183,7 @@ public class TestParenting01cSwingAWT extends UITestCase { System.out.println("Demos: 5 - X Container"); _jPanel1.remove(_container1); } }); - // Assert.assertNull(glWindow1.getParentNativeWindow()); + // Assert.assertNull(glWindow1.getParent()); Assert.assertEquals(true, glWindow1.isValid()); SwingUtilities.invokeAndWait(new Runnable() { @@ -210,7 +210,7 @@ public class TestParenting01cSwingAWT extends UITestCase { Assert.assertNotNull(glWindow1); Assert.assertEquals(false, glWindow1.isVisible()); Assert.assertEquals(false, glWindow1.isNativeValid()); - Assert.assertNull(glWindow1.getParentNativeWindow()); + Assert.assertNull(glWindow1.getParent()); glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); GLEventListener demo1 = new RedSquare(); setDemoFields(demo1, glWindow1, false); @@ -237,7 +237,7 @@ public class TestParenting01cSwingAWT extends UITestCase { Assert.assertNotNull(newtCanvasAWT); Assert.assertEquals(false, glWindow1.isVisible()); Assert.assertEquals(false, glWindow1.isNativeValid()); - Assert.assertNull(glWindow1.getParentNativeWindow()); + Assert.assertNull(glWindow1.getParent()); Container container1 = new Container(); container1.setLayout(new BorderLayout()); @@ -286,7 +286,7 @@ public class TestParenting01cSwingAWT extends UITestCase { final JPanel _jPanel2 = jPanel2; // visible test - Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParentNativeWindow()); + Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); int state = 0; while(animator1.isAnimating() && animator1.getDuration()<3*durationPerTest) { diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02AWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02AWT.java index 7920e7cd4..a4b8c183d 100644 --- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02AWT.java +++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02AWT.java @@ -114,7 +114,7 @@ public class TestParenting02AWT extends UITestCase { Assert.assertNotNull(newtCanvasAWT); Assert.assertEquals(false, glWindow.isVisible()); Assert.assertEquals(false, glWindow.isNativeValid()); - Assert.assertNull(glWindow.getParentNativeWindow()); + Assert.assertNull(glWindow.getParent()); Frame frame = new Frame("AWT Parent Frame"); Assert.assertNotNull(frame); @@ -157,7 +157,7 @@ public class TestParenting02AWT extends UITestCase { } while(!glWindow.isNativeValid()) ; Assert.assertEquals(true, glWindow.isNativeValid()); - Assert.assertNotNull(glWindow.getParentNativeWindow()); + Assert.assertNotNull(glWindow.getParent()); if(verbose) { System.out.println("+++++++++++++++++++ 1st ADDED"); } @@ -168,7 +168,7 @@ public class TestParenting02AWT extends UITestCase { frame.remove(newtCanvasAWT); Assert.assertEquals(false, glWindow.isVisible()); Assert.assertEquals(true, glWindow.isNativeValid()); - Assert.assertNull(glWindow.getParentNativeWindow()); + Assert.assertNull(glWindow.getParent()); if(verbose) { System.out.println("+++++++++++++++++++ REMOVED!"); } @@ -179,7 +179,7 @@ public class TestParenting02AWT extends UITestCase { glWindow.display(); Assert.assertEquals(true, glWindow.isVisible()); Assert.assertEquals(true, glWindow.isNativeValid()); - Assert.assertNotNull(glWindow.getParentNativeWindow()); + Assert.assertNotNull(glWindow.getParent()); if(verbose) { System.out.println("+++++++++++++++++++ 2nd ADDED"); } @@ -216,7 +216,7 @@ public class TestParenting02AWT extends UITestCase { } Thread.sleep(waitReparent); - glWindow.destroy(); + glWindow.destroy(true); if(useLayout) { frame.remove(newtCanvasAWT); } diff --git a/src/junit/com/jogamp/test/junit/util/AWTRobotUtil.java b/src/junit/com/jogamp/test/junit/util/AWTRobotUtil.java index 38998e854..a167766f5 100644 --- a/src/junit/com/jogamp/test/junit/util/AWTRobotUtil.java +++ b/src/junit/com/jogamp/test/junit/util/AWTRobotUtil.java @@ -74,8 +74,10 @@ public class AWTRobotUtil { y0 = (int) ( p0.getY() + r0.getHeight() / 2.0 + .5 ) ; } } else { - x0 = win.getX() + win.getWidth() / 2 ; - y0 = win.getY() + win.getHeight() / 2 ; + javax.media.nativewindow.util.Point p0 = win.getLocationOnScreen(null); + p0.translate(win.getWidth()/2, win.getHeight()/2); + x0 = p0.getX(); + y0 = p0.getY(); } return new Point(x0, y0); diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/NullWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/ProxySurface.java index fc6242968..5e6487ae8 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/NullWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/ProxySurface.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -36,16 +37,19 @@ package com.jogamp.nativewindow.impl; -import javax.media.nativewindow.*; -import com.jogamp.nativewindow.impl.RecursiveToolkitLock; +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindow; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.SurfaceChangeable; -public class NullWindow implements NativeWindow, SurfaceChangeable { +public class ProxySurface implements NativeSurface, SurfaceChangeable { private RecursiveToolkitLock recurLock = new RecursiveToolkitLock(); protected int width, height, scrnIndex; protected long surfaceHandle, displayHandle; protected AbstractGraphicsConfiguration config; - public NullWindow(AbstractGraphicsConfiguration cfg) { + public ProxySurface(AbstractGraphicsConfiguration cfg) { invalidate(); config = cfg; displayHandle=cfg.getScreen().getDevice().getHandle(); @@ -58,6 +62,10 @@ public class NullWindow implements NativeWindow, SurfaceChangeable { protected void initNative() throws NativeWindowException { } + public NativeWindow getParent() { + return null; + } + public void destroy() { invalidate(); } @@ -97,7 +105,23 @@ public class NullWindow implements NativeWindow, SurfaceChangeable { return false; } - public void surfaceUpdated(Object updater, NativeWindow window, long when) { } + public long getSurfaceHandle() { + return surfaceHandle; + } + + public int getWidth() { + return width; + } + + public int getHeight() { + return height; + } + + public AbstractGraphicsConfiguration getGraphicsConfiguration() { + return config; + } + + public void surfaceUpdated(Object updater, NativeSurface ns, long when) { } public long getDisplayHandle() { return displayHandle; @@ -105,36 +129,16 @@ public class NullWindow implements NativeWindow, SurfaceChangeable { public int getScreenIndex() { return scrnIndex; } - public long getWindowHandle() { - return 0; - } - public long getSurfaceHandle() { - return surfaceHandle; - } + public void setSurfaceHandle(long surfaceHandle) { this.surfaceHandle=surfaceHandle; } - public AbstractGraphicsConfiguration getGraphicsConfiguration() { - return config; - } - - public final boolean isTerminalObject() { - return true; - } public void setSize(int width, int height) { this.width=width; this.height=height; } - public int getWidth() { - return width; - } - - public int getHeight() { - return height; - } - public String toString() { return "NullWindow[config "+config+ ", displayHandle 0x"+Long.toHexString(getDisplayHandle())+ diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java index 1cd63235d..0cb861453 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -36,14 +37,14 @@ package com.jogamp.nativewindow.impl.jawt; -import com.jogamp.nativewindow.impl.*; -import com.jogamp.nativewindow.util.Rectangle; import java.awt.Component; import java.awt.Window; import java.awt.GraphicsEnvironment; import javax.media.nativewindow.*; import com.jogamp.nativewindow.impl.*; +import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.Rectangle; public abstract class JAWTWindow implements NativeWindow { protected static final boolean DEBUG = Debug.debug("JAWT"); @@ -79,21 +80,12 @@ public abstract class JAWTWindow implements NativeWindow { protected abstract void initNative() throws NativeWindowException; - public synchronized void invalidate() { + protected synchronized void invalidate() { component = null; drawable= 0; bounds = new Rectangle(); } - public synchronized void destroy() { - if(null!=component) { - if(component instanceof Window) { - ((Window)component).dispose(); - } - } - invalidate(); - } - protected void updateBounds(JAWT_Rectangle jawtBounds) { bounds.setX(jawtBounds.getX()); bounds.setY(jawtBounds.getY()); @@ -101,6 +93,25 @@ public abstract class JAWTWindow implements NativeWindow { bounds.setHeight(jawtBounds.getHeight()); } + /** @return the JAWT_DrawingSurfaceInfo's (JAWT_Rectangle) bounds, updated with lock */ + public Rectangle getBounds() { return bounds; } + + public Component getAWTComponent() { + return component; + } + + // + // SurfaceUpdateListener + // + + public void surfaceUpdated(Object updater, NativeSurface ns, long when) { + // nop + } + + // + // NativeSurface + // + private RecursiveToolkitLock recurLock = new RecursiveToolkitLock(); protected abstract int lockSurfaceImpl() throws NativeWindowException; @@ -148,15 +159,6 @@ public abstract class JAWTWindow implements NativeWindow { public void surfaceUpdated(Object updater, NativeWindow window, long when) { } - public long getDisplayHandle() { - return config.getScreen().getDevice().getHandle(); - } - public int getScreenIndex() { - return config.getScreen().getIndex(); - } - public long getWindowHandle() { - return drawable; - } public long getSurfaceHandle() { return drawable; } @@ -164,8 +166,12 @@ public abstract class JAWTWindow implements NativeWindow { return config; } - public Object getWrappedWindow() { - return component; + public long getDisplayHandle() { + return config.getScreen().getDevice().getHandle(); + } + + public int getScreenIndex() { + return config.getScreen().getIndex(); } public void setSize(int width, int height) { @@ -180,8 +186,44 @@ public abstract class JAWTWindow implements NativeWindow { return component.getHeight(); } - /** @return the JAWT_DrawingSurfaceInfo's (JAWT_Rectangle) bounds, updated with lock */ - public Rectangle getBounds() { return bounds; } + // + // NativeWindow + // + + public synchronized void destroy() { + if(null!=component) { + if(component instanceof Window) { + ((Window)component).dispose(); + } + } + invalidate(); + } + + public NativeWindow getParent() { + return null; + } + + public long getWindowHandle() { + return drawable; + } + + public int getX() { + return component.getX(); + } + + public int getY() { + return component.getY(); + } + + public Point getLocationOnScreen(Point point) { + java.awt.Point awtLOS = component.getLocationOnScreen(); + int dx = (int) ( awtLOS.getX() + .5 ) ; + int dy = (int) ( awtLOS.getY() + .5 ) ; + if(null!=point) { + return point.translate(dx, dy); + } + return new Point(dx, dy); + } public String toString() { StringBuffer sb = new StringBuffer(); @@ -191,14 +233,14 @@ public abstract class JAWTWindow implements NativeWindow { ", surfaceHandle 0x"+Long.toHexString(getSurfaceHandle())+ ", bounds "+bounds); if(null!=component) { - sb.append(", pos "+component.getX()+"/"+component.getY()+", size "+getWidth()+"x"+getHeight()+ + sb.append(", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+ ", visible "+component.isVisible()); } else { sb.append(", component NULL"); } sb.append(", lockedExt "+isSurfaceLockedByOtherThread()+ ",\n\tconfig "+config+ - ",\n\twrappedWindow "+getWrappedWindow()+"]"); + ",\n\tawtComponent "+getAWTComponent()+"]"); return sb.toString(); } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java index c3b3682fd..b6da7166d 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -56,7 +57,7 @@ public class WindowsJAWTWindow extends JAWTWindow { protected void initNative() throws NativeWindowException { } - public synchronized void invalidate() { + protected synchronized void invalidate() { super.invalidate(); windowHandle = 0; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java new file mode 100644 index 000000000..3648a9a32 --- /dev/null +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java @@ -0,0 +1,166 @@ +/** + * Copyright 2010 JogAmp Community. 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 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 javax.media.nativewindow; + +/** Provides low-level information required for + hardware-accelerated rendering using a surface in a platform-independent manner.<P> + + A NativeSurface created for a particular on- or offscreen component is + expected to have the same lifetime as that component. As long as + the component is alive and realized/visible, NativeSurface must be able + provide information such as the surface handle while it is locked.<P> +*/ +public interface NativeSurface extends SurfaceUpdatedListener { + /** Unlocked state */ + public static final int LOCK_SURFACE_UNLOCKED = 0; + + /** Returned by {@link #lockSurface()} if the surface is not ready to be locked. */ + public static final int LOCK_SURFACE_NOT_READY = 1; + + /** Returned by {@link #lockSurface()} if the surface is locked, but has changed. */ + public static final int LOCK_SURFACE_CHANGED = 2; + + /** Returned by {@link #lockSurface()} if the surface is locked, and is unchanged. */ + public static final int LOCK_SUCCESS = 3; + + /** + * Lock the surface of this native window<P> + * + * The surface handle, see {@link #lockSurface()}, <br> + * shall be valid after a successfull call, + * ie return a value other than {@link #LOCK_SURFACE_NOT_READY}.<P> + * + * This call is blocking until the surface has been locked + * or a timeout is reached. The latter will throw a runtime exception. <P> + * + * This call allows recursion from the same thread.<P> + * + * The implementation may want to aquire the + * application level {@link com.jogamp.nativewindow.impl.RecursiveToolkitLock} + * first before proceeding with a native surface lock. <P> + * + * @return {@link #LOCK_SUCCESS}, {@link #LOCK_SURFACE_CHANGED} or {@link #LOCK_SURFACE_NOT_READY}. + * + * @throws RuntimeException after timeout when waiting for the surface lock + * + * @see com.jogamp.nativewindow.impl.RecursiveToolkitLock + */ + public int lockSurface(); + + /** + * Unlock the surface of this native window + * + * Shall not modify the surface handle, see {@link #lockSurface()} <P> + * + * @throws RuntimeException if surface is not locked + * + * @see #lockSurface + * @see com.jogamp.nativewindow.impl.RecursiveToolkitLock + */ + public void unlockSurface() throws NativeWindowException ; + + /** + * Return if surface is locked by another thread, ie not the current one + */ + public boolean isSurfaceLockedByOtherThread(); + + /** + * Return if surface is locked + */ + public boolean isSurfaceLocked(); + + /** + * Return the locking owner's Thread, or null if not locked. + */ + public Thread getSurfaceLockOwner(); + + /** + * Return the lock-exception, or null if not locked. + * + * The lock-exception is created at {@link #lockSurface()} + * and hence holds the locker's call stack. + */ + public Exception getSurfaceLockStack(); + + /** + * Provide a mechanism to utilize custom (pre-) swap surface + * code. This method is called before the render toolkit (e.g. JOGL) + * swaps the buffer/surface. The implementation may itself apply the swapping, + * in which case true shall be returned. + * + * @return true if this method completed swapping the surface, + * otherwise false, in which case eg the GLDrawable + * implementation has to swap the code. + */ + public boolean surfaceSwap(); + + /** + * Returns the handle to the surface for this NativeSurface. <P> + * + * The surface handle should be set/update by {@link #lockSurface()}, + * where {@link #unlockSurface()} is not allowed to modify it. + * After {@link #unlockSurface()} it is no more guaranteed + * that the surface handle is still valid. + * + * The surface handle shall reflect the platform one + * for all drawable surface operations, e.g. opengl, swap-buffer. <P> + * + * On X11 this returns an entity of type Window, + * since there is no differentiation of surface and window there. <BR> + * On Microsoft Windows this returns an entity of type HDC. + */ + public long getSurfaceHandle(); + + /** Returns the current width of this surface. */ + public int getWidth(); + + /** Returns the current height of this surface. */ + public int getHeight(); + + /** + * Returns the graphics configuration corresponding to this window. + * @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen) + */ + public AbstractGraphicsConfiguration getGraphicsConfiguration(); + + /** + * Convenience: Get display handle from + * AbstractGraphicsConfiguration . AbstractGraphicsScreen . AbstractGraphicsDevice + */ + public long getDisplayHandle(); + + /** + * Convenience: Get display handle from + * AbstractGraphicsConfiguration . AbstractGraphicsScreen + */ + public int getScreenIndex(); + +} + diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java index 2187f6054..d65cc8c18 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 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 @@ -39,111 +40,18 @@ package javax.media.nativewindow; -/** Provides the low-level information required for - hardware-accelerated rendering in a platform-independent manner. A - window toolkit such as the AWT may either implement this interface +import javax.media.nativewindow.util.Point; + +/** Extend the {@link NativeSurface} interface with windowing + information such as window handle and position.<P> + + A window toolkit such as the AWT may either implement this interface directly with one of its components, or provide and register an implementation of {@link NativeWindowFactory NativeWindowFactory} which can create NativeWindow objects for its components. <P> - - A NativeWindow created for a particular on-screen component is - expected to have the same lifetime as that component. As long as - the component is alive, the NativeWindow must be able to control - it, and any time it is visible and locked, provide information - such as the window handle. */ -public interface NativeWindow extends SurfaceUpdatedListener { - /** Unlocked state */ - public static final int LOCK_SURFACE_UNLOCKED = 0; - - /** Returned by {@link #lockSurface()} if the surface is not ready to be locked. */ - public static final int LOCK_SURFACE_NOT_READY = 1; - - /** Returned by {@link #lockSurface()} if the surface is locked, but has changed. */ - public static final int LOCK_SURFACE_CHANGED = 2; - - /** Returned by {@link #lockSurface()} if the surface is locked, and is unchanged. */ - public static final int LOCK_SUCCESS = 3; - - /** - * Lock the surface of this native window<P> - * - * The surface handle, see {@link #lockSurface()}, <br> - * shall be valid after a successfull call, - * ie return a value other than {@link #LOCK_SURFACE_NOT_READY}.<P> - * - * This call is blocking until the surface has been locked - * or a timeout is reached. The latter will throw a runtime exception. <P> - * - * This call allows recursion from the same thread.<P> - * - * The implementation may want to aquire the - * application level {@link com.jogamp.nativewindow.impl.RecursiveToolkitLock} - * first before proceeding with a native surface lock. <P> - * - * @return {@link #LOCK_SUCCESS}, {@link #LOCK_SURFACE_CHANGED} or {@link #LOCK_SURFACE_NOT_READY}. - * - * @throws RuntimeException after timeout when waiting for the surface lock - * - * @see com.jogamp.nativewindow.impl.RecursiveToolkitLock - */ - public int lockSurface(); - - /** - * Unlock the surface of this native window - * - * Shall not modify the surface handle, see {@link #lockSurface()} <P> - * - * @throws RuntimeException if surface is not locked - * - * @see #lockSurface - * @see com.jogamp.nativewindow.impl.RecursiveToolkitLock - */ - public void unlockSurface() throws NativeWindowException ; - - /** - * Return if surface is locked by another thread, ie not the current one - */ - public boolean isSurfaceLockedByOtherThread(); - - /** - * Return if surface is locked - */ - public boolean isSurfaceLocked(); - - /** - * Return the locking owner's Thread, or null if not locked. - */ - public Thread getSurfaceLockOwner(); - - /** - * Return the lock-exception, or null if not locked. - * - * The lock-exception is created at {@link #lockSurface()} - * and hence holds the locker's call stack. - */ - public Exception getSurfaceLockStack(); - - /** - * Provide a mechanism to utilize custom (pre-) swap surface - * code. This method is called before the render toolkit (e.g. JOGL) - * swaps the buffer/surface. The implementation may itself apply the swapping, - * in which case true shall be returned. - * - * @return true if this method completed swapping the surface, - * otherwise false, in which case eg the GLDrawable - * implementation has to swap the code. - */ - public boolean surfaceSwap(); - - /** - * render all native window information invalid, - * as if the native window was destroyed - * - * @see #destroy - */ - public void invalidate(); - +public interface NativeWindow extends NativeSurface { + /** * destroys the window and releases * windowing related resources. @@ -151,6 +59,11 @@ public interface NativeWindow extends SurfaceUpdatedListener { public void destroy(); /** + * @return The parent NativeWindow, or null if this NativeWindow is top level. + */ + public NativeWindow getParent(); + + /** * Returns the window handle for this NativeWindow. <P> * * The window handle shall reflect the platform one @@ -161,45 +74,20 @@ public interface NativeWindow extends SurfaceUpdatedListener { */ public long getWindowHandle(); - /** - * Returns the handle to the surface for this NativeWindow. <P> - * - * The surface handle should be set/update by {@link #lockSurface()}, - * where {@link #unlockSurface()} is not allowed to modify it. - * After {@link #unlockSurface()} it is no more guaranteed - * that the surface handle is still valid. - * - * The surface handle shall reflect the platform one - * for all drawable surface operations, e.g. opengl, swap-buffer. <P> - * - * On X11 this returns an entity of type Window, - * since there is no differentiation of surface and window there. <BR> - * On Microsoft Windows this returns an entity of type HDC. - */ - public long getSurfaceHandle(); - - /** Returns the current width of this window. */ - public int getWidth(); + /** Returns the current x position of this window, relative to it's parent. */ + public int getX(); - /** Returns the current height of this window. */ - public int getHeight(); + /** Returns the current y position of this window, relative to it's parent. */ + public int getY(); - /** - * Returns the graphics configuration corresponding to this window. - * @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen) - */ - public AbstractGraphicsConfiguration getGraphicsConfiguration(); - - /** - * Convenience: Get display handle from - * AbstractGraphicsConfiguration . AbstractGraphicsScreen . AbstractGraphicsDevice - */ - public long getDisplayHandle(); - - /** - * Convenience: Get display handle from - * AbstractGraphicsConfiguration . AbstractGraphicsScreen + /** + * Returns the current absolute location of this window. + * @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. + * @return either the passed non null translated point by the screen location of this NativeWindow, + * or a new instance with the screen location of this NativeWindow. */ - public int getScreenIndex(); - + public Point getLocationOnScreen(Point point); + } diff --git a/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java b/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java index 7be15408c..88e805d14 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java +++ b/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.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 @@ -38,9 +39,9 @@ public interface SurfaceUpdatedListener { * * @param updater is the caller object who updated the surface, * e.g. a JOGL GLDrawable. - * @param window the NativeWindow, which surface is updated + * @param ns the updated NativeSurface * @param when the time in ms, when the surface was updated */ - public void surfaceUpdated(Object updater, NativeWindow window, long when) ; + public void surfaceUpdated(Object updater, NativeSurface ns, long when) ; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/package.html b/src/nativewindow/classes/javax/media/nativewindow/package.html index fa422b2ab..1eb1cef08 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/package.html +++ b/src/nativewindow/classes/javax/media/nativewindow/package.html @@ -39,8 +39,9 @@ <br> shall be registered with {@link javax.media.nativewindow.GraphicsConfigurationFactory#registerFactory GraphicsConfigurationFactory.registerFactory(..)}.</li><br> </ul><br> - This protocol <i>does not</i> describe how to <i>create</i> native windows, but how to <i>bind</i> a native window to an implementation of - {@link javax.media.nativewindow.NativeWindow NativeWindow}.<br> + This protocol <i>does not</i> describe how to <i>create</i> native windows, but how to <i>bind</i> a native surface to an implementation of + and window to an implementation of {@link javax.media.nativewindow.NativeSurface NativeSurface}.<br> + {@link javax.media.nativewindow.NativeWindow NativeWindow} specializes the NativeSurface.<br> However, an implementation of this protocol (e.g. {@link com.jogamp.newt}) may support the creation.<br> <h3>Dependencies</h3> diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java new file mode 100644 index 000000000..19ec1e259 --- /dev/null +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java @@ -0,0 +1,94 @@ +/** + * Copyright 2010 JogAmp Community. 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 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 javax.media.nativewindow.util; + +public class Dimension { + int width; + int height; + + public Dimension() { + this(0, 0); + } + + public Dimension(int width, int height) { + this.width=width; + this.height=height; + } + public int getWidth() { return width; } + public int getHeight() { return height; } + public void setWidth(int width) { this.width = width; } + public void setHeight(int height) { this.height = height; } + + public Dimension scale(int s) { + width *= s; + height *= s; + return this; + } + + public Dimension add(Dimension pd) { + width += pd.width ; + height += pd.height ; + return this; + } + + public String toString() { + return new String("Dimension["+width+"x"+height+"]"); + } + + /** + * Checks whether two dimensions objects are equal. Two instances + * of <code>Dimension</code> are equal if the four integer values + * of the fields <code>height</code> and <code>width</code> + * are equal. + * @return <code>true</code> if the two dimensions are equal; + * otherwise <code>false</code>. + */ + public boolean equals(Object obj) { + if (obj instanceof Dimension) { + Dimension p = (Dimension)obj; + return (height == p.height) && (width == p.width) && + (height == p.height) && (width == p.width); + } + return false; + } + + /** + * Returns the hash code for this Dimension. + * + * @return a hash code for this Dimension. + */ + public int hashCode() { + int sum1 = width + height; + return sum1 * (sum1 + 1)/2 + width; + } + +} + diff --git a/src/newt/classes/com/jogamp/newt/util/Insets.java b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java index 068cc1dfb..4162e1099 100644 --- a/src/newt/classes/com/jogamp/newt/util/Insets.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2009 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 @@ -30,7 +31,7 @@ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * */ -package com.jogamp.newt.util; +package javax.media.nativewindow.util; /** * Simple class representing insets. diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java new file mode 100644 index 000000000..a541b3cfd --- /dev/null +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java @@ -0,0 +1,93 @@ +/** + * Copyright 2010 JogAmp Community. 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 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 javax.media.nativewindow.util; + +public class Point { + int x; + int y; + + public Point() { + this(0, 0); + } + + public Point(int x, int y) { + this.x=x; + this.y=y; + } + public int getX() { return x; } + public int getY() { return y; } + public void setX(int x) { this.x = x; } + public void setY(int y) { this.y = y; } + + public Point translate(Point pd) { + x += pd.x ; + y += pd.y ; + return this; + } + + public Point translate(int dx, int dy) { + x += dx ; + y += dy ; + return this; + } + + public String toString() { + return new String("Point["+x+"/"+y+"]"); + } + + /** + * Checks whether two points objects are equal. Two instances + * of <code>Point</code> are equal if the four integer values + * of the fields <code>y</code> and <code>x</code> + * are equal. + * @return <code>true</code> if the two points are equal; + * otherwise <code>false</code>. + */ + public boolean equals(Object obj) { + if (obj instanceof Point) { + Point p = (Point)obj; + return (y == p.y) && (x == p.x); + } + return false; + } + + /** + * Returns the hash code for this Point. + * + * @return a hash code for this Point. + */ + public int hashCode() { + int sum1 = x + y; + return sum1 * (sum1 + 1)/2 + x; + } + +} + diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/util/Rectangle.java b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java index 9f7711443..84e970b9f 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/util/Rectangle.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java @@ -27,7 +27,7 @@ */ -package com.jogamp.nativewindow.util; +package javax.media.nativewindow.util; public class Rectangle { int x; @@ -54,6 +54,37 @@ public class Rectangle { public void setWidth(int width) { this.width = width; } public void setHeight(int height) { this.height = height; } + /** + * Checks whether two rect objects are equal. Two instances + * of <code>Rectangle</code> are equal if the four integer values + * of the fields <code>y</code>, <code>x</code>, + * <code>height</code>, and <code>width</code> are all equal. + * @return <code>true</code> if the two rectangles are equal; + * otherwise <code>false</code>. + */ + public boolean equals(Object obj) { + if (obj instanceof Rectangle) { + Rectangle rect = (Rectangle)obj; + return (y == rect.y) && (x == rect.x) && + (height == rect.height) && (width == rect.width); + } + return false; + } + + /** + * Returns the hash code for this Rectangle. + * + * @return a hash code for this Rectangle. + */ + public int hashCode() { + int sum1 = x + height; + int sum2 = width + y; + int val1 = sum1 * (sum1 + 1)/2 + x; + int val2 = sum2 * (sum2 + 1)/2 + y; + int sum3 = val1 + val2; + return sum3 * (sum3 + 1)/2 + val2; + } + public String toString() { return new String("Rect["+x+"/"+y+" "+width+"x"+height+"]"); } diff --git a/src/nativewindow/native/x11/Xmisc.c b/src/nativewindow/native/x11/Xmisc.c index 2b4e730d1..2c61a71ef 100644 --- a/src/nativewindow/native/x11/Xmisc.c +++ b/src/nativewindow/native/x11/Xmisc.c @@ -124,8 +124,7 @@ static void _FatalError(JNIEnv *env, const char* msg, ...) vsnprintf(buffer, sizeof(buffer), msg, ap); va_end(ap); - fprintf(stderr, buffer); - fprintf(stderr, "\n"); + fprintf(stderr, "%s\n", buffer); (*env)->FatalError(env, buffer); } diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 17a562d61..4bdcd67a4 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -28,15 +28,15 @@ package com.jogamp.newt; -import com.jogamp.newt.util.Insets; import com.jogamp.newt.event.WindowListener; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.event.MouseListener; -import com.jogamp.newt.event.NEWTEventConsumer; import com.jogamp.newt.impl.Debug; import javax.media.nativewindow.Capabilities; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.SurfaceUpdatedListener; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.Point; /** * Specifying the public Window functionality for the @@ -76,12 +76,6 @@ public interface Window extends NativeWindow { Screen getScreen(); /** - * @return The NativeWindow representation of the parent Window, - * or null if this Window is top level - */ - NativeWindow getParentNativeWindow(); - - /** * @return The requested capabilities */ Capabilities getRequestedCapabilities(); @@ -239,7 +233,7 @@ public interface Window extends NativeWindow { * @param y coord of the top left corner */ void setPosition(int x, int y); - + int getX(); int getY(); diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 01593b2d9..223b4193a 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -49,7 +49,7 @@ import com.jogamp.newt.impl.Debug; public class NewtCanvasAWT extends java.awt.Canvas { public static final boolean DEBUG = Debug.debug("Window"); - NativeWindow parent = null; + NativeWindow nativeWindow = null; Window newtChild = null; AWTAdapter awtAdapter = null; @@ -101,7 +101,7 @@ public class NewtCanvasAWT extends java.awt.Canvas { public NewtCanvasAWT setNEWTChild(Window child) { if(newtChild!=child) { newtChild = child; - if(null!=parent) { + if(null!=nativeWindow) { java.awt.Container cont = getContainer(this); // reparent right away, addNotify has been called already reparentWindow( (null!=newtChild) ? true : false, cont ); @@ -117,7 +117,7 @@ public class NewtCanvasAWT extends java.awt.Canvas { /** @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 parent; } + public NativeWindow getNativeWindow() { return nativeWindow; } void setWindowAdapter(boolean attach) { if(null!=awtAdapter) { @@ -168,14 +168,14 @@ public class NewtCanvasAWT extends java.awt.Canvas { newtChild.setFocusAction(null); // no AWT focus traversal .. if(add) { - parent = NewtFactoryAWT.getNativeWindow(this, newtChild.getRequestedCapabilities()); - if(null!=parent) { + nativeWindow = NewtFactoryAWT.getNativeWindow(this, newtChild.getRequestedCapabilities()); + if(null!=nativeWindow) { if(DEBUG) { System.err.println("NewtCanvasAWT.reparentWindow: "+newtChild); } setSize(cont.getWidth(), cont.getHeight()); newtChild.setSize(cont.getWidth(), cont.getHeight()); - newtChild.reparentWindow(parent); + newtChild.reparentWindow(nativeWindow); newtChild.setVisible(true); setWindowAdapter(true); newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener @@ -184,7 +184,7 @@ public class NewtCanvasAWT extends java.awt.Canvas { } } else { setWindowAdapter(false); - parent = null; + nativeWindow = null; newtChild.setVisible(false); newtChild.reparentWindow(null); } @@ -215,7 +215,7 @@ public class NewtCanvasAWT extends java.awt.Canvas { if(DEBUG) { System.err.println("NewtCanvasAWT.destroy("+unrecoverable+"): "+newtChild+", from "+cont); } - parent = null; + nativeWindow = null; newtChild.setVisible(false); newtChild.reparentWindow(null); newtChild.destroy(unrecoverable); diff --git a/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java b/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java index 829ffe9c0..7cd6ee370 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java @@ -28,8 +28,7 @@ package com.jogamp.newt.event; -import com.jogamp.newt.*; -import com.jogamp.nativewindow.util.Rectangle; +import javax.media.nativewindow.util.Rectangle; public class WindowUpdateEvent extends WindowEvent { Rectangle bounds; diff --git a/src/newt/classes/com/jogamp/newt/impl/OffscreenWindow.java b/src/newt/classes/com/jogamp/newt/impl/OffscreenWindow.java index 217d9d293..95c326ce4 100644 --- a/src/newt/classes/com/jogamp/newt/impl/OffscreenWindow.java +++ b/src/newt/classes/com/jogamp/newt/impl/OffscreenWindow.java @@ -35,6 +35,7 @@ package com.jogamp.newt.impl; import javax.media.nativewindow.*; +import javax.media.nativewindow.util.Point; public class OffscreenWindow extends WindowImpl implements SurfaceChangeable { @@ -115,5 +116,14 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable { protected void reconfigureWindowImpl(int x, int y, int width, int height) { shouldNotCallThis(); } + + public Point getLocationOnScreen(Point storage) { + if(null!=storage) { + storage.setX(0); + storage.setY(0); + return storage; + } + return new Point(0,0); + } } diff --git a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java index c10d9a491..0e9114145 100644 --- a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java +++ b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java @@ -39,17 +39,17 @@ import com.jogamp.newt.Display; import com.jogamp.newt.Screen; import com.jogamp.newt.Window; import com.jogamp.newt.event.*; -import com.jogamp.newt.util.*; import com.jogamp.common.util.*; import javax.media.nativewindow.*; -import com.jogamp.nativewindow.util.Rectangle; import com.jogamp.nativewindow.impl.RecursiveToolkitLock; -import com.jogamp.newt.impl.OffscreenWindow; import java.util.ArrayList; import java.util.Iterator; import java.lang.reflect.Method; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.Rectangle; public abstract class WindowImpl implements Window, NEWTEventConsumer { @@ -263,7 +263,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer //---------------------------------------------------------------------- - // NativeWindow: Native implementation + // NativeSurface: Native implementation // protected int lockSurfaceImpl() { return LOCK_SUCCESS; } @@ -291,7 +291,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected void setTitleImpl(String title) {} //---------------------------------------------------------------------- - // NativeWindow + // NativeSurface // public final int lockSurface() { @@ -336,6 +336,18 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return windowLock.getLockedStack(); } + public long getSurfaceHandle() { + return windowHandle; // default: return window handle + } + + public boolean surfaceSwap() { + return false; + } + + public AbstractGraphicsConfiguration getGraphicsConfiguration() { + return config; + } + public final long getDisplayHandle() { return getScreen().getDisplay().getHandle(); } @@ -344,20 +356,32 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return getScreen().getIndex(); } - public AbstractGraphicsConfiguration getGraphicsConfiguration() { - return config; + //---------------------------------------------------------------------- + // NativeWindow + // + + public final void destroy() { + destroy(false); } - public final long getWindowHandle() { - return windowHandle; + public final NativeWindow getParent() { + return parentWindow; } - public long getSurfaceHandle() { - return windowHandle; // default: return window handle + public final long getWindowHandle() { + return windowHandle; } - public boolean surfaceSwap() { - return false; + public Point getLocationOnScreen(Point storage) { + if(null!=storage) { + storage.translate(getX(),getY()); + } else { + storage = new Point(getX(),getY()); + } + if(null!=parentWindow) { + parentWindow.getLocationOnScreen(storage); + } + return storage; } //---------------------------------------------------------------------- @@ -372,10 +396,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return null != getScreen() ; } - public final NativeWindow getParentNativeWindow() { - return parentWindow; - } - public final Screen getScreen() { return screen; } @@ -508,10 +528,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } - public final void destroy() { - destroy(false); - } - public void destroy(boolean unrecoverable) { if( isValid() ) { if(DEBUG_IMPLEMENTATION) { @@ -689,7 +705,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer setScreen( (ScreenImpl) newParentWindowNEWT.getScreen() ); displayChanged = true; reparentAction = ACTION_NATIVE_CREATION_PENDING; - } else if(newParentWindow != getParentNativeWindow()) { + } else if(newParentWindow != getParent()) { // Case: Parent's native window realized and changed if( !isNativeValid() ) { // May create a new compatible Screen/Display and @@ -812,6 +828,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer visible = true; setVisibleImpl(true); display.dispatchMessages(); // status up2date + requestFocusImpl(true); + display.dispatchMessages(); // status up2date } } else { // native reparent failed -> try creation @@ -921,7 +939,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } public void requestFocus() { - enqueueRequestFocus(false); // FIXME: or shall we wait ? + // enqueueRequestFocus(false); // FIXME: or shall we wait ? + enqueueRequestFocus(true); } public boolean hasFocus() { @@ -1114,6 +1133,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } public boolean setFullscreen(boolean fullscreen) { + boolean action = false; windowLock.lock(); try{ if(0!=windowHandle && this.fullscreen!=fullscreen) { @@ -1138,11 +1158,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } this.fullscreen = fullscreen; reconfigureWindowImpl(x, y, w, h); - requestFocus(); + action = true; } } finally { windowLock.unlock(); } + if(action) { + requestFocus(); + } if( isVisible() ) { sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout and repaint to listener } @@ -1297,11 +1320,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } - public void surfaceUpdated(Object updater, NativeWindow window, long when) { + public void surfaceUpdated(Object updater, NativeSurface ns, long when) { synchronized(surfaceUpdatedListenersLock) { for(Iterator i = surfaceUpdatedListeners.iterator(); i.hasNext(); ) { SurfaceUpdatedListener l = (SurfaceUpdatedListener) i.next(); - l.surfaceUpdated(updater, window, when); + l.surfaceUpdated(updater, ns, when); } } } diff --git a/src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java b/src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java index e4452d2c8..1f481e28b 100644 --- a/src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java +++ b/src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.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 @@ -37,19 +38,10 @@ import com.jogamp.newt.event.awt.*; import com.jogamp.newt.util.EDTUtil; import java.awt.BorderLayout; -import java.awt.Canvas; import java.awt.Container; import java.awt.DisplayMode; import java.awt.EventQueue; import java.awt.Frame; -import java.awt.GraphicsDevice; -import java.awt.GraphicsEnvironment; -import java.lang.reflect.Method; -import java.lang.reflect.InvocationTargetException; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.*; -import com.jogamp.newt.Window; import com.jogamp.newt.impl.WindowImpl; import java.awt.Insets; import javax.media.nativewindow.*; @@ -224,7 +216,7 @@ public class AWTWindow extends WindowImpl { } } - public com.jogamp.newt.util.Insets getInsets() { + public javax.media.nativewindow.util.Insets getInsets() { final int insets[] = new int[] { 0, 0, 0, 0 }; runOnEDT(true, new Runnable() { public void run() { @@ -235,8 +227,7 @@ public class AWTWindow extends WindowImpl { insets[3] = contInsets.right; } }); - return new com.jogamp.newt.util. - Insets(insets[0],insets[1],insets[2],insets[3]); + return new javax.media.nativewindow.util.Insets(insets[0],insets[1],insets[2],insets[3]); } protected void setPositionImpl(final int x, final int y) { diff --git a/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java b/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java index 5043be918..a114417f0 100644 --- a/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java +++ b/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.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 @@ -36,10 +37,9 @@ package com.jogamp.newt.impl.macosx; import javax.media.nativewindow.*; import com.jogamp.nativewindow.impl.RecursiveToolkitLock; -import com.jogamp.newt.*; import com.jogamp.newt.event.*; import com.jogamp.newt.impl.*; -import com.jogamp.newt.util.*; +import javax.media.nativewindow.util.Insets; public class MacWindow extends WindowImpl { diff --git a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java index ee3c8e197..3c922b9e7 100644 --- a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java +++ b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.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 @@ -34,9 +35,8 @@ package com.jogamp.newt.impl.windows; import javax.media.nativewindow.*; -import com.jogamp.newt.*; -import com.jogamp.newt.util.*; import com.jogamp.newt.impl.WindowImpl; +import javax.media.nativewindow.util.Insets; public class WindowsWindow extends WindowImpl { diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 028f809f0..a7104bf1a 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -36,11 +36,12 @@ package com.jogamp.newt.opengl; import com.jogamp.newt.*; import com.jogamp.newt.event.*; -import com.jogamp.newt.util.Insets; import com.jogamp.newt.impl.WindowImpl; import javax.media.nativewindow.*; +import javax.media.nativewindow.util.Point; import javax.media.opengl.*; import com.jogamp.opengl.impl.GLDrawableHelper; +import javax.media.nativewindow.util.Insets; /** * An implementation of {@link javax.media.opengl.GLAutoDrawable} interface, @@ -62,7 +63,7 @@ public class GLWindow implements GLAutoDrawable, Window { * Constructor. Do not call this directly -- use {@link #create()} instead. */ protected GLWindow(Window window) { - resetPerfCounter(); + resetCounter(); this.window = (WindowImpl) window; ((WindowImpl)this.window).setHandleDestroyNotify(false); window.addWindowListener(new WindowAdapter() { @@ -152,8 +153,8 @@ public class GLWindow implements GLAutoDrawable, Window { return window; } - public final NativeWindow getParentNativeWindow() { - return window.getParentNativeWindow(); + public final NativeWindow getParent() { + return window.getParent(); } public final Screen getScreen() { @@ -253,6 +254,10 @@ public class GLWindow implements GLAutoDrawable, Window { return window.isNativeValid(); } + public Point getLocationOnScreen(Point storage) { + return window.getLocationOnScreen(storage); + } + // Hide methods here .. protected class GLLifecycleHook implements WindowImpl.LifecycleHook { @@ -326,9 +331,9 @@ public class GLWindow implements GLAutoDrawable, Window { } drawable.setRealized(true); context = drawable.createContext(null); - resetPerfCounter(); + resetCounter(); } else if(!visible) { - resetPerfCounter(); + resetCounter(); } if(Window.DEBUG_WINDOW_EVENT || Window.DEBUG_IMPLEMENTATION) { String msg = new String("GLWindow.setVisibleAction("+visible+", "+nativeWindowCreated+") "+Thread.currentThread()+", fin"); @@ -349,7 +354,7 @@ public class GLWindow implements GLAutoDrawable, Window { } public synchronized void reparentActionPost(int reparentActionType) { - resetPerfCounter(); + resetCounter(); GLAnimatorControl ctrl = GLWindow.this.getAnimator(); if ( null!=ctrl && animatorPaused ) { animatorPaused = false; @@ -372,14 +377,6 @@ public class GLWindow implements GLAutoDrawable, Window { private long startTime, curTime, lastCheck; private int totalFrames, lastFrames; - /** Reset all performance counter (startTime, currentTime, frame number) */ - public void resetPerfCounter() { - startTime = System.currentTimeMillis(); // overwrite startTime to real init one - curTime = startTime; - lastCheck = startTime; - totalFrames = 0; lastFrames = 0; - } - public GLDrawableFactory getFactory() { return factory; } @@ -450,7 +447,7 @@ public class GLWindow implements GLAutoDrawable, Window { return; } - if( null == context && window.isVisible() ) { + if( null == context && isVisible() ) { // retry native window and drawable/context creation setVisible(true); } @@ -494,7 +491,7 @@ public class GLWindow implements GLAutoDrawable, Window { public void run() { // Lock: Locked Surface/Window by MakeCurrent/Release helper.init(GLWindow.this); - resetPerfCounter(); + resetCounter(); } } private InitAction initAction = new InitAction(); @@ -531,37 +528,17 @@ public class GLWindow implements GLAutoDrawable, Window { /** * @return Time of the first display call in milliseconds. * This value is reset if becoming visible again or reparenting. - * In case an animator is used, - * the corresponding {@link javax.media.opengl.GLAnimatorControl} value is returned. - * - * @see javax.media.opengl.GLAnimatorControl#getStartTime() */ public final long getStartTime() { - GLAnimatorControl animator = getAnimator(); - if ( null == animator || null == animator.getThread() ) { - // no animator, or not started -> use local time - return startTime; - } else { - return animator.getStartTime(); - } + return startTime; } /** * @return Time of the last display call in milliseconds. * This value is reset if becoming visible again or reparenting. - * In case an animator is used, - * the corresponding {@link javax.media.opengl.GLAnimatorControl} value is returned. - * - * @see javax.media.opengl.GLAnimatorControl#getCurrentTime() */ public final long getCurrentTime() { - GLAnimatorControl animator = getAnimator(); - if ( null == animator || null == animator.getThread() ) { - // no animator, or not started -> use local time - return curTime; - } else { - return animator.getCurrentTime(); - } + return curTime; } /** @@ -577,19 +554,17 @@ public class GLWindow implements GLAutoDrawable, Window { /** * @return Number of frames displayed since the first display call, ie <code>getStartTime()</code>. * This value is reset if becoming visible again or reparenting. - * In case an animator is used, - * the corresponding {@link javax.media.opengl.GLAnimatorControl} value is returned. - * - * @see javax.media.opengl.GLAnimatorControl#getTotalFrames() */ - public final int getTotalFrames() { - GLAnimatorControl animator = getAnimator(); - if ( null == animator || null == animator.getThread() ) { - // no animator, or not started -> use local value - return totalFrames; - } else { - return animator.getTotalFrames(); - } + public final int getTotalFrames() { + return totalFrames; + } + + /** Reset all counter (startTime, currentTime, frame number) */ + public synchronized void resetCounter() { + startTime = System.currentTimeMillis(); // overwrite startTime to real init one + curTime = startTime; + lastCheck = startTime; + totalFrames = 0; lastFrames = 0; } class SwapBuffersAction implements Runnable { @@ -603,8 +578,8 @@ public class GLWindow implements GLAutoDrawable, Window { // GLDrawable methods // - public final NativeWindow getNativeWindow() { - return null!=drawable ? drawable.getNativeWindow() : null; + public final NativeSurface getNativeSurface() { + return null!=drawable ? drawable.getNativeSurface() : null; } public final long getHandle() { @@ -824,7 +799,7 @@ public class GLWindow implements GLAutoDrawable, Window { return window.getScreenIndex(); } - public final void surfaceUpdated(Object updater, NativeWindow window, long when) { - window.surfaceUpdated(updater, window, when); + public final void surfaceUpdated(Object updater, NativeSurface ns, long when) { + window.surfaceUpdated(updater, ns, when); } } diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 4bf2545ab..e1250811c 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -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 @@ -606,7 +607,7 @@ static void NewtWindows_requestFocus (JNIEnv *env, jobject window, HWND hwnd, BO DBG_PRINT("*** WindowsWindow: requestFocus.S parent %p, window %p, isCurrent %d, reparented %d\n", (void*) pHwnd, (void*)hwnd, current==hwnd, (int) reparented); if(reparented || current!=hwnd) { - if( JNI_FALSE == (*env)->CallBooleanMethod(env, window, focusActionID) ) { + if( reparented || JNI_FALSE == (*env)->CallBooleanMethod(env, window, focusActionID) ) { UINT flags = SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE; if(reparented) { flags |= SWP_FRAMECHANGED; diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index 350a0a704..8a07067b7 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -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 @@ -399,11 +400,12 @@ static void NewtWindows_requestFocus (JNIEnv *env, jobject window, Display *dpy, Window focus_return; int revert_to_return; - XGetWindowAttributes(dpy, w, &xwa); XGetInputFocus(dpy, &focus_return, &revert_to_return); if(reparented || focus_return!=w) { - // Avoid 'BadMatch' errors from XSetInputFocus, ie if window is not viewable - if( JNI_FALSE == (*env)->CallBooleanMethod(env, window, focusActionID) ) { + if( reparented || JNI_FALSE == (*env)->CallBooleanMethod(env, window, focusActionID) ) { + XRaiseWindow(dpy, w); + // Avoid 'BadMatch' errors from XSetInputFocus, ie if window is not viewable + XGetWindowAttributes(dpy, w, &xwa); if(xwa.map_state == IsViewable) { XSetInputFocus(dpy, w, RevertToParent, CurrentTime); } |