summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-09-26 04:19:11 +0200
committerSven Gothel <[email protected]>2010-09-26 04:19:11 +0200
commit609e30836d4fcc5d2da945bf1c7d1d9a9c349b2a (patch)
tree70216c951469fb5389596f3e994f4348d399cbeb
parent0d073c5ea4426b0139409b20a3879b6003f795b0 (diff)
NEWT: Add Window.hasFocus() ; Test cleanup ..
- Window add focus tracking and query via hasFocus() - TestTransformFeedbackVeryingsBug407NEWT allow fail if no GL3 is available - TestFocus01SwingAWT check on NEWTChild focus
-rw-r--r--make/scripts/tests.bat3
-rwxr-xr-xmake/scripts/tests.sh2
-rw-r--r--src/junit/com/jogamp/test/junit/jogl/glsl/TestTransformFeedbackVeryingsBug407NEWT.java9
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWT.java4
-rw-r--r--src/newt/classes/com/jogamp/newt/Window.java2
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/WindowImpl.java8
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java4
7 files changed, 27 insertions, 5 deletions
diff --git a/make/scripts/tests.bat b/make/scripts/tests.bat
index 7be498837..82dba1c9b 100644
--- a/make/scripts/tests.bat
+++ b/make/scripts/tests.bat
@@ -11,4 +11,5 @@ REM # ./scripts/java-run-all.sh ../build-x86_64 com.jogamp.test.junit.newt.paren
REM # ./scripts/java-run-all.sh ../build-x86_64 com.jogamp.test.junit.newt.TestGLWindows01NEWT
REM # ./scripts/java-run-all.sh ../build-x86_64 com.jogamp.test.junit.newt.TestGLWindows02NEWTAnimated
-scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.parenting.TestParenting01NEWT
+REM scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.parenting.TestParenting01NEWT
+scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.TestFocus01SwingAWT
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index f935a13cb..1234bd348 100755
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -28,5 +28,7 @@ spath=`dirname $0`
# $spath/java-run-all.sh ../build-x86_64 com.jogamp.test.junit.jogl.awt.TestSwingAWTUsageBeforeJOGLInitBug411 $*
$spath/java-run-all.sh ../build-x86_64 com.jogamp.test.junit.newt.TestFocus01SwingAWT $*
+# $spath/java-run-all.sh ../build-x86_64 com.jogamp.test.junit.jogl.offscreen.TestOffscreen01NEWT $*
+
$spath/count-edt-start.sh java-run.log
diff --git a/src/junit/com/jogamp/test/junit/jogl/glsl/TestTransformFeedbackVeryingsBug407NEWT.java b/src/junit/com/jogamp/test/junit/jogl/glsl/TestTransformFeedbackVeryingsBug407NEWT.java
index 361d16613..2e092a5b7 100644
--- a/src/junit/com/jogamp/test/junit/jogl/glsl/TestTransformFeedbackVeryingsBug407NEWT.java
+++ b/src/junit/com/jogamp/test/junit/jogl/glsl/TestTransformFeedbackVeryingsBug407NEWT.java
@@ -12,6 +12,7 @@ import javax.media.opengl.GLProfile;
import org.junit.After;
import org.junit.Assert;
+import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
@@ -51,7 +52,13 @@ public class TestTransformFeedbackVeryingsBug407NEWT {
Window window;
GLDrawable drawable;
- GLProfile glp = GLProfile.get(GLProfile.GL3);
+ GLProfile glp = null;
+ try {
+ glp = GLProfile.get(GLProfile.GL3);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ Assume.assumeNoException(t);
+ }
caps = new GLCapabilities(glp);
caps.setOnscreen(true);
diff --git a/src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWT.java b/src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWT.java
index 42a58e2b1..1dac6edad 100644
--- a/src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWT.java
@@ -2,6 +2,7 @@ package com.jogamp.test.junit.newt;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import java.awt.AWTException;
import java.awt.BorderLayout;
@@ -94,8 +95,7 @@ public class TestFocus01SwingAWT {
// Verify focus status.
assertFalse("AWT parent canvas has focus", newtCanvasAWT.hasFocus());
- // TODO No test for NEWT hasFocus.
- // assertTrue(newtCanvasAWT.getNEWTChild().hasFocus());
+ assertTrue(newtCanvasAWT.getNEWTChild().hasFocus());
// Type two keys, which should be directed to the focused window.
Robot robot = new Robot();
diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java
index ef3e5e69c..17a562d61 100644
--- a/src/newt/classes/com/jogamp/newt/Window.java
+++ b/src/newt/classes/com/jogamp/newt/Window.java
@@ -277,6 +277,8 @@ public interface Window extends NativeWindow {
void requestFocus();
+ boolean hasFocus();
+
void windowRepaint(int x, int y, int width, int height);
void enqueueEvent(boolean wait, com.jogamp.newt.event.NEWTEvent event);
diff --git a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
index d3ff2e558..e26947a36 100644
--- a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
+++ b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
@@ -170,7 +170,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
protected AbstractGraphicsConfiguration config;
protected Capabilities caps;
- protected boolean fullscreen, visible;
+ protected boolean fullscreen, visible, hasFocus;
protected int width, height, x, y;
// non fullscreen dimensions ..
@@ -621,6 +621,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
windowHandle = 0;
visible = false;
fullscreen = false;
+ hasFocus = false;
if(unrecoverable) {
destroyScreen();
@@ -919,6 +920,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
enqueueRequestFocus(false); // FIXME: or shall we wait ?
}
+ public boolean hasFocus() {
+ return hasFocus;
+ }
+
public Insets getInsets() {
return new Insets(0,0,0,0);
}
@@ -1614,6 +1619,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
if(DEBUG_IMPLEMENTATION) {
System.err.println("Window.focusChanged: ("+getThreadName()+"): "+focusGained+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle));
}
+ hasFocus = focusGained;
if (focusGained) {
sendWindowEvent(WindowEvent.EVENT_WINDOW_GAINED_FOCUS);
} else {
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index 13d549e24..028f809f0 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -184,6 +184,10 @@ public class GLWindow implements GLAutoDrawable, Window {
window.requestFocus();
}
+ public boolean hasFocus() {
+ return window.hasFocus();
+ }
+
public final Insets getInsets() {
return window.getInsets();
}