summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-11-15 04:43:09 +0100
committerSven Gothel <[email protected]>2010-11-15 04:43:09 +0100
commite6280cb0c673d87faddbfec5224c3ca56bc7d4e9 (patch)
tree9bd47bd64936fb3e8f8e11db3c9efa9a9d418138
parent35d1c40fe89311f88c7303930e172adcc5d6853a (diff)
NEWT: Cleanup reparent (window resize/display) ; AWT Focus Tests: Bring back AWT wait period.
-rw-r--r--make/scripts/tests.sh2
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWTRobot.java18
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestFocus02SwingAWTRobot.java5
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/WindowImpl.java27
4 files changed, 24 insertions, 28 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 3b7f46f82..93deeab83 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -26,7 +26,7 @@ function jrun() {
#D_ARGS="-Djogl.debug.GLProfile"
# D_ARGS="-Djogamp.debug.TraceLock"
# D_ARGS="-Dnewt.debug.EDT -Dnativewindow.debug.ToolkitLock.TraceLock -Dnativewindow.debug.NativeWindow"
- D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT"
+ #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT"
# D_ARGS="-Dnewt.debug.EDT -Dnativewindow.debug.ToolkitLock.TraceLock -Dnativewindow.debug.X11Util.TraceDisplayLifecycle=true"
#D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock"
# D_ARGS="-Dnewt.debug.Window -Dnewt.debug.EDT -Dnewt.debug.Display "
diff --git a/src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWTRobot.java b/src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWTRobot.java
index 49591aab8..762e906fc 100644
--- a/src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWTRobot.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWTRobot.java
@@ -29,18 +29,12 @@
package com.jogamp.test.junit.newt;
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.BorderLayout;
import java.awt.Button;
import java.awt.Robot;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
import java.lang.reflect.InvocationTargetException;
import javax.media.opengl.GLCapabilities;
@@ -49,18 +43,12 @@ import javax.media.opengl.GLProfile;
import javax.swing.JFrame;
import java.util.ArrayList;
-import java.util.List;
-import java.util.Iterator;
import java.io.IOException;
import org.junit.BeforeClass;
import org.junit.Test;
import com.jogamp.newt.awt.NewtCanvasAWT;
-import com.jogamp.newt.event.KeyAdapter;
-import com.jogamp.newt.event.KeyEvent;
-import com.jogamp.newt.event.WindowAdapter;
-import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.util.Animator;
import com.jogamp.test.junit.jogl.demos.es1.RedSquare;
@@ -69,8 +57,8 @@ import com.jogamp.test.junit.util.*;
public class TestFocus01SwingAWTRobot extends UITestCase {
static int width, height;
-
static long durationPerTest = 800;
+ static long awtWaitTimeout = 1000;
static GLCapabilities glCaps;
@@ -144,8 +132,10 @@ public class TestFocus01SwingAWTRobot extends UITestCase {
frame1.setVisible(true);
Assert.assertTrue(AWTRobotUtil.toFront(robot, frame1));
+ int wait=0;
+ while(wait<awtWaitTimeout/100 && glWindow1.getTotalFrames()<1) { Thread.sleep(awtWaitTimeout/10); wait++; }
+ System.err.println("Frames for initial setVisible(true): "+glWindow1.getTotalFrames());
Assert.assertTrue(glWindow1.isVisible());
- System.out.println("Frames for initial setVisible(true): "+glWindow1.getTotalFrames());
Assert.assertTrue(0 < glWindow1.getTotalFrames());
// Continuous animation ..
diff --git a/src/junit/com/jogamp/test/junit/newt/TestFocus02SwingAWTRobot.java b/src/junit/com/jogamp/test/junit/newt/TestFocus02SwingAWTRobot.java
index af959a2eb..3ce6080a9 100644
--- a/src/junit/com/jogamp/test/junit/newt/TestFocus02SwingAWTRobot.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestFocus02SwingAWTRobot.java
@@ -59,6 +59,7 @@ import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears;
public class TestFocus02SwingAWTRobot extends UITestCase {
static int width, height;
static long durationPerTest = 800;
+ static long awtWaitTimeout = 1000;
static long waitReparent = 0;
static GLCapabilities glCaps;
@@ -162,8 +163,10 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
jFrame1.setVisible(true); // from here on, we need to run modifications on EDT
Assert.assertTrue(AWTRobotUtil.toFront(robot, jFrame1));
+ int wait=0;
+ while(wait<awtWaitTimeout/100 && glWindow1.getTotalFrames()<1) { Thread.sleep(awtWaitTimeout/10); wait++; }
+ System.err.println("Frames for initial setVisible(true): "+glWindow1.getTotalFrames());
Assert.assertTrue(glWindow1.isVisible());
- System.out.println("Frames for initial setVisible(true): "+glWindow1.getTotalFrames());
Assert.assertTrue(0 < glWindow1.getTotalFrames());
// Continuous animation ..
diff --git a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
index 73b13e326..c34081ebf 100644
--- a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
+++ b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
@@ -800,7 +800,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
public void run() {
boolean wasVisible;
- boolean displayChanged = false;
// mirror pos/size so native change notification can get overwritten
int x = WindowImpl.this.x;
@@ -851,7 +850,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
// It may be created properly when the parent is made visible.
destroy(false);
setScreen( (ScreenImpl) newParentWindowNEWT.getScreen() );
- displayChanged = true;
reparentAction = ACTION_NATIVE_CREATION_PENDING;
} else if(newParentWindow != getParent()) {
// Case: Parent's native window realized and changed
@@ -866,7 +864,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
// auto destroy on-the-fly created Screen/Display
newScreen.setDestroyWhenUnused(true);
setScreen( (ScreenImpl) newScreen );
- displayChanged = true;
}
}
if( 0<width*height ) {
@@ -886,7 +883,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
setScreen( (ScreenImpl) NewtFactory.createCompatibleScreen(newParentWindow, getScreen()) );
screen.setDestroyWhenUnused(true);
}
- displayChanged = true;
reparentAction = ACTION_NATIVE_CREATION;
} else {
// Mark it for native reparenting
@@ -1003,6 +999,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
// reset pos/size .. due to some native impl flakyness
reconfigureWindowImpl(x, y, width, height, false, 0, 0);
display.dispatchMessagesNative(); // status up2date
+ WindowImpl.this.waitForVisible(true, false);
+ display.dispatchMessagesNative(); // status up2date
}
}
}
@@ -1036,14 +1034,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
windowLock.unlock();
}
- if( ACTION_NATIVE_REPARENTING == reparentAction ) {
- sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout and repaint to listener
- }
-
- if( ACTION_NATIVE_CREATION == reparentAction && wasVisible ) {
- // This may run on the Display/Screen connection,
- // hence a new EDT task
- runOnEDTIfAvail(true, reparentActionRecreate);
+ if(wasVisible) {
+ switch (reparentAction) {
+ case ACTION_NATIVE_REPARENTING:
+ // trigger a resize/relayout and repaint to listener
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
+ break;
+
+ case ACTION_NATIVE_CREATION:
+ // This may run on the Display/Screen connection,
+ // hence a new EDT task
+ runOnEDTIfAvail(true, reparentActionRecreate);
+ break;
+ }
}
}
}