Jogamp
NEWT Cleanup: AWT driver fix, WindowImpl createNative .., minor edits
authorSven Gothel <sgothel@jausoft.com>
Fri, 16 Sep 2011 10:40:46 +0000 (12:40 +0200)
committerSven Gothel <sgothel@jausoft.com>
Fri, 16 Sep 2011 10:40:46 +0000 (12:40 +0200)
AWT driver fix
  - setVisible at creation, using reconfigureWindow impl (fixed

WindowImpl createNative ..,
  - no double visibility check on creation
  - visible:=true anyway for later creation, if failed or not available yet

src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
src/newt/classes/jogamp/newt/WindowImpl.java
src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java
src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java
src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java

index ee6d44d..b7f2077 100644 (file)
@@ -198,7 +198,7 @@ public abstract class NativeWindowFactory {
                 ReflectionUtil.isClassAvailable(AWTComponentClassName, cl) &&
                 ReflectionUtil.isClassAvailable("javax.media.nativewindow.awt.AWTGraphicsDevice", cl) ) {
 
-                AccessController.doPrivileged(new PrivilegedAction() {
+                AccessController.doPrivileged(new PrivilegedAction<Object>() {
                     public Object run() {
                         try {
                             jawtUtilClass = Class.forName(JAWTUtilClassName, false, NativeWindowFactory.class.getClassLoader());
index dd87526..420e9d1 100644 (file)
@@ -294,7 +294,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
                 }
                 // always flag visible, 
                 // allowing to retry if visible && !isNativeValid()
-                setVisibleImpl(true, x, y, width, height);
+                visible = true;
             }
         } finally {
             if(null!=parentWindow) {
@@ -693,10 +693,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
             if(!isNativeValid() && visible) {
                 if( 0<width*height ) {
                     nativeWindowCreated = createNative();
-                    if(nativeWindowCreated) {
-                        WindowImpl.this.waitForVisible(visible, true);
-                        madeVisible = visible;
-                    }
+                    madeVisible = nativeWindowCreated;
                 }
             } else if(WindowImpl.this.visible != visible) {
                 if(isNativeValid()) {
index 531b8d2..d71015d 100644 (file)
@@ -120,10 +120,9 @@ public class AWTWindow extends WindowImpl {
         container.setLocation(x, y);
         new AWTWindowAdapter(this).addTo(container); // fwd all AWT Window events to here
 
-        if(null!=frame) {
-            frame.setUndecorated(isUndecorated());
-        }
-
+        reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_VISIBILITY | FLAG_CHANGE_DECORATION, true));
+        // throws exception if failed ..
+        
         setWindowHandle(1); // just a marker ..
     }
 
@@ -175,11 +174,7 @@ public class AWTWindow extends WindowImpl {
         insets.setBottomHeight(contInsets.bottom);
     }
 
-    protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) {        
-        if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) {
-            container.setVisible(0 != ( FLAG_IS_VISIBLE & flags));
-        }
-        
+    protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) {
         if(0 != ( FLAG_CHANGE_DECORATION & flags) && null!=frame) {
             if(!container.isDisplayable()) {
                 frame.setUndecorated(isUndecorated());
@@ -189,6 +184,11 @@ public class AWTWindow extends WindowImpl {
                 }
             }
         }
+        
+        if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) {
+            container.setVisible(0 != ( FLAG_IS_VISIBLE & flags));
+        }
+        
         x=(x>=0)?x:AWTWindow.this.x;
         y=(x>=0)?y:AWTWindow.this.y;
         width=(width>0)?width:AWTWindow.this.width;
@@ -199,14 +199,16 @@ public class AWTWindow extends WindowImpl {
         container.setSize(width + insets.left + insets.right,
                           height + insets.top + insets.bottom);
 
-        if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) {        
-            config = canvas.getAWTGraphicsConfiguration();
-
-            if (config == null) {
-                throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
+        if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) {
+            if( 0 != ( FLAG_IS_VISIBLE & flags ) ) {
+                if( !hasDeviceChanged() ) {
+                    // oops ??
+                    config = canvas.getAWTGraphicsConfiguration();
+                    if(null == config) {
+                        throw new NativeWindowException("Error: !hasDeviceChanged && null == GraphicsConfiguration: "+this);
+                    }
+                }
             }
-
-            updateDeviceData();
             visibleChanged(0 != ( FLAG_IS_VISIBLE & flags));
         }
         
index dd18271..78f2f45 100644 (file)
@@ -58,9 +58,7 @@ import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
 
 public class TestFocus02SwingAWTRobot extends UITestCase {
     static int width, height;
-    static long durationPerTest = 800;
     static long awtWaitTimeout = 1000;
-    static long waitReparent = 0;
     static GLCapabilities glCaps;
 
     @BeforeClass
@@ -161,7 +159,7 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
         Assert.assertTrue(AWTRobotUtil.toFront(robot, jFrame1));
 
         int wait=0;
-        while(wait<awtWaitTimeout/100 && glWindow1.getTotalFPSFrames()<1) { Thread.sleep(awtWaitTimeout/10); wait++; }
+        while(wait<awtWaitTimeout/10 && glWindow1.getTotalFPSFrames()<1) { Thread.sleep(awtWaitTimeout/100); wait++; }
         System.err.println("Frames for initial setVisible(true): "+glWindow1.getTotalFPSFrames());
         Assert.assertTrue(glWindow1.isVisible());
         Assert.assertTrue(0 < glWindow1.getTotalFPSFrames());
@@ -285,15 +283,6 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
     public static void main(String args[]) 
         throws IOException, AWTException, InterruptedException, InvocationTargetException 
     {
-        for(int i=0; i<args.length; i++) {
-            if(args[i].equals("-time")) {
-                durationPerTest = atoi(args[++i]);
-            } else if(args[i].equals("-wait")) {
-                waitReparent = atoi(args[++i]);
-            }
-        }
-        System.err.println("durationPerTest "+durationPerTest);
-        System.err.println("waitReparent "+waitReparent);
         if(true) {
             String tstname = TestFocus02SwingAWTRobot.class.getName();
             org.junit.runner.JUnitCore.main(tstname);
index af3c771..661d58b 100644 (file)
@@ -39,7 +39,6 @@ import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.Robot;
 import java.awt.Toolkit;
-import java.awt.event.InputEvent;
 
 import javax.media.opengl.awt.GLCanvas;
 import javax.swing.JFrame;
http://JogAmp.org git info: FAQ, tutorial and man pages.