From f3f794fe37a7e33a771a4a702f3f46ead4dc6d03 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 23 Dec 2011 00:31:14 +0100 Subject: NEWT Multi-Monitor 1/2: Allow negative window position; Validate Screen-Index; - Allow negative window position, using flag 'autoPosition' to mark a custom user position. This impacts Windows and X11 window creation code, which supports native auto positioning. - Screen: Validate Screen-Index. In 'big-desktop' mode the Screen index is always 0. This is true for X11 with Xinerama enabled and MS-Windows in general. Platforms w/o multiple Screen support always use index 0. - X11: Separate X11 Display/Screen/Window native code in their respective C files - Windows test scripts: use '%*' to catch all arguments - Add missing (c) --- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 114 ++++++++++++++++----- .../test/junit/newt/TestScreenMode00NEWT.java | 33 ++++-- 2 files changed, 112 insertions(+), 35 deletions(-) (limited to 'src/test') diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index e57b26f76..faa7eb311 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -32,8 +32,13 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; +import com.jogamp.newt.Display; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.QuitAdapter; @@ -42,6 +47,11 @@ import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.PointImmutable; +import javax.media.nativewindow.util.DimensionImmutable; + import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; @@ -55,8 +65,23 @@ import org.junit.Test; public class TestGearsES2NEWT extends UITestCase { static GLProfile glp; - static int width, height; + + static int screenIdx = 0; + static PointImmutable wpos; + static DimensionImmutable wsize; + static long duration = 500; // ms + static boolean opaque = true; + static boolean undecorated = false; + static boolean alwaysOnTop = false; + static boolean fullscreen = false; + static boolean pmvUseBackingArray = true; + static boolean vsync = false; + static boolean waitForKey = false; + static boolean mouseVisible = true; + static boolean mouseConfined = false; + static boolean showFPS = false; + @BeforeClass public static void initClass() { /*if(GLProfile.isAvailable(GLProfile.getDefaultEGLDevice(), GLProfile.GLES2)) { @@ -67,10 +92,9 @@ public class TestGearsES2NEWT extends UITestCase { glp = GLProfile.getGL2ES2(); } Assert.assertNotNull(glp); - // width = 512; - // height = 512; - width = 200; - height = 200; + if(null == wsize) { + wsize = new Dimension(200, 200); + } } @AfterClass @@ -79,11 +103,15 @@ public class TestGearsES2NEWT extends UITestCase { protected void runTestGL(GLCapabilities caps, boolean undecorated) throws InterruptedException { System.err.println("requested: "+caps); - final GLWindow glWindow = GLWindow.create(caps); + Display dpy = NewtFactory.createDisplay(null); + Screen screen = NewtFactory.createScreen(dpy, screenIdx); + final GLWindow glWindow = GLWindow.create(screen, caps); Assert.assertNotNull(glWindow); - glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+")"); - glWindow.setSize(width, height); - glWindow.setPosition(100, 100); + glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+"), size "+wsize+", pos "+wpos); + glWindow.setSize(wsize.getWidth(), wsize.getHeight()); + if(null != wpos) { + glWindow.setPosition(wpos.getX(), wpos.getY()); + } glWindow.setUndecorated(undecorated); glWindow.setAlwaysOnTop(alwaysOnTop); glWindow.setFullscreen(fullscreen); @@ -122,6 +150,15 @@ public class TestGearsES2NEWT extends UITestCase { glWindow.addKeyListener(quitAdapter); glWindow.addWindowListener(quitAdapter); + glWindow.addWindowListener(new WindowAdapter() { + public void windowResized(WindowEvent e) { + System.err.println("window resized: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); + } + public void windowMoved(WindowEvent e) { + System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); + } + }); + glWindow.addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent e) { if(e.getKeyChar()=='f') { @@ -188,14 +225,14 @@ public class TestGearsES2NEWT extends UITestCase { } }); - animator.setUpdateFPSFrames(60, System.err); + animator.setUpdateFPSFrames(60, showFPS ? System.err : null); animator.start(); // glWindow.setSkipContextReleaseThread(animator.getThread()); glWindow.setVisible(true); - System.err.println("size/pos: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); System.err.println("chosen: "+glWindow.getChosenCapabilities()); + System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() screenModes = screen.getScreenModes(); Assert.assertTrue(screenModes.size()>0); @@ -119,15 +122,25 @@ public class TestScreenMode00NEWT extends UITestCase { Assert.assertEquals(sm_c.getRotatedWidth(), screen.getWidth()); Assert.assertEquals(sm_c.getRotatedHeight(), screen.getHeight()); - window.destroy(); + screen.removeReference(); - Assert.assertEquals(false,window.isVisible()); - Assert.assertEquals(false,window.isNativeValid()); Assert.assertEquals(false,screen.isNativeValid()); Assert.assertEquals(false,screen.getDisplay().isNativeValid()); } + static int atoi(String a) { + try { + return Integer.parseInt(a); + } catch (Exception ex) { throw new RuntimeException(ex); } + } + public static void main(String args[]) throws IOException { + for(int i=0; i